Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for phpMyEdit/phpMyEdit.class.php between version 1.37 and 1.38

version 1.37, 2002/12/14 04:40:55 version 1.38, 2002/12/14 22:48:05
Line 19 
Line 19 
  * http://www.platon.sk/projects/phpMyEdit/   * http://www.platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.36 2002/12/12 21:42:48 nepto Exp $ */  /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.37 2002/12/14 04:40:55 nepto Exp $ */
   
 /*      phpMyEdit intro {{{ */  /*      phpMyEdit intro {{{ */
 /*  /*
Line 114  if (! function_exists('array_search')) {
Line 114  if (! function_exists('array_search')) {
   
 class phpMyEdit  class phpMyEdit
 {  {
           // Class variables // {{{
         var $hn;        // hostname          var $hn;        // hostname
         var $un;        // user name          var $un;        // user name
         var $pw;        // password          var $pw;        // password
Line 155  class phpMyEdit
Line 156  class phpMyEdit
         var $notify;     // change notification e-mail adresses          var $notify;     // change notification e-mail adresses
         var $logtable;   // name of optional logtable          var $logtable;   // name of optional logtable
         var $navigation; // navigation style          var $navigation; // navigation style
           // }}}
   
         function debug_var($name, $val) /* {{{ */          function debug_var($name, $val) /* {{{ */
         {          {
Line 1288  function form_control(theForm)
Line 1289  function form_control(theForm)
                 return $var;                  return $var;
         } /* }}} */          } /* }}} */
   
           function get_server_var($name) /* {{{ */
           {
                   if (isset($_SERVER[$name])) {
                           return $_SERVER[$name];
                   }
                   global $HTTP_SERVER_VARS;
                   if (isset($HTTP_SERVER_VARS[$name])) {
                           return $HTTP_SERVER_VARS[$name];
                   }
                   global $name;
                   if (isset($$name)) {
                           return $$name;
                   }
                   return null;
           } /* }}} */
   
         /*          /*
          * Debug functions           * Debug functions
          */           */
Line 1480  function form_control(theForm)
Line 1497  function form_control(theForm)
          */           */
         function list_table() /* {{{ */          function list_table() /* {{{ */
         {          {
                 global $HTTP_SERVER_VARS;  
                 $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];  
                 // Process any navigation buttons  
   
                 //if (!isset ($this->fm))  
                 if ($this->fm == '') {                  if ($this->fm == '') {
                         $this->fm = 0;                          $this->fm = 0;
                 }                  }
Line 1593  function form_control(theForm)
Line 1605  function form_control(theForm)
   
                 for ($k = 0; $k < $this->num_fds; $k++) {                  for ($k = 0; $k < $this->num_fds; $k++) {
                         $fd = $this->fds[$k];                          $fd = $this->fds[$k];
   
                         /*  
                         if ((stristr($this->fdd[$fd]['options'],'L') || ! isset ($this->fdd[$fd]['options'])) &&  
                                 ! $this->hidden($k)  
                         )  
                         */  
                         if ($this->displayed[$k]) {                          if ($this->displayed[$k]) {
                                 $fdn = $this->fdd[$fd]['name'];                                  $fdn = $this->fdd[$fd]['name'];
                                 if (isset ($this->fdd[$fd]['width'])) {                                  $w   = isset($this->fdd[$fd]['width']) ? ' width="'.$this->fdd[$fd]['width'].'"' : '';
                                         $w = ' width="'.$this->fdd[$fd]['width'].'"';                                  if (! $this->fdd[$fd]['sort'] || $this->hidden($fd) || $this->password($fd)) {
                                           echo '<th'.$w.'>'.$fdn.'</th>'."\n";
                                 } else {                                  } else {
                                         $w = '';  
                                 }  
                                 if ($this->fdd[$fd]['sort']) {  
                                         // Clicking on the current sort field reverses the sort order                                          // Clicking on the current sort field reverses the sort order
                                         $new_sfn = $this->sfn;                                          $new_sfn = $this->sfn;
                                         array_unshift($new_sfn, in_array("$k", $new_sfn, 1) ? "-$k" : $k);                                          array_unshift($new_sfn, in_array("$k", $new_sfn, 1) ? "-$k" : $k);
                                         echo '<th'.$w.'><a href="'.$this->page_name.'?fm=0&fl='.$this->fl;                                          echo '<th'.$w.'><a href="'.$this->page_name.'?fm=0&fl='.$this->fl;
                                         echo '&'.$this->get_sfn_cgi_vars($new_sfn).$this->cgi['persist'];                                          echo '&'.$this->get_sfn_cgi_vars($new_sfn).$this->cgi['persist'];
                                         echo $this->qfn.'">'.$fdn.'</a></th>'."\n";                                          echo $this->qfn.'">'.$fdn.'</a></th>'."\n";
                                 } else {  
                                         echo '<th'.$w.'>'.$fdn.'</th>'."\n";  
                                 }                                  }
                         }                          }
   
Line 1843  function form_control(theForm)
Line 1845  function form_control(theForm)
                         $cgi_persist = $this->cgi['persist'];                          $cgi_persist = $this->cgi['persist'];
                         $cgi_persist != '' && $cgi_persist[0] = '?';                          $cgi_persist != '' && $cgi_persist[0] = '?';
                         echo '<tr><td colspan='.$sys_cols.' align="center">'                          echo '<tr><td colspan='.$sys_cols.' align="center">'
                                 .'<a class="pme_a_t" href="'.$PHP_SELF.$cgi_persist,'">'                                  .'<a class="pme_a_t" href="'.$this->get_server_var('PHP_SELF')
                                 .$this->labels['Clear'].'</a></td>';                                  .$cgi_persist.'">' .$this->labels['Clear'].'</a></td>';
                         echo '<td colspan="'.$this->num_fields_displayed.'">'                          echo '<td colspan="'.$this->num_fields_displayed.'">'
                                 .$this->labels['Sorted By'].': <i>'                                  .$this->labels['Sorted By'].': <i>'
                                 .join(', ', $sort_fields_w).'</i></td></tr>'."\n";                                  .join(', ', $sort_fields_w).'</i></td></tr>'."\n";
Line 1857  function form_control(theForm)
Line 1859  function form_control(theForm)
                 $text_query = $this->make_text_where_from_query_opts();                  $text_query = $this->make_text_where_from_query_opts();
                 if ($text_query != '' && $this->display['query']) {                  if ($text_query != '' && $this->display['query']) {
                         echo '<tr><td colspan='.$sys_cols.' align="center">'                          echo '<tr><td colspan='.$sys_cols.' align="center">'
                                 .'<a class="pme_a_t" href="'.$PHP_SELF                                  .'<a class="pme_a_t" href="'.$this->get_server_var('PHP_SELF')
                                 .'?sfn='.$this->get_sfn_cgi_vars().'&fl='.$this->fl.'&fm='.$this->fm                                  .'?sfn='.$this->get_sfn_cgi_vars().'&fl='.$this->fl.'&fm='.$this->fm
                                 .$this->cgi['persist'].'">'.$this->labels['Clear'].'</a></td>';                                  .$this->cgi['persist'].'">'.$this->labels['Clear'].'</a></td>';
                         echo '<td colspan="'.$this->num_fields_displayed.'">'                          echo '<td colspan="'.$this->num_fields_displayed.'">'
Line 2232  function form_control(theForm)
Line 2234  function form_control(theForm)
         /*          /*
          * Action functions           * Action functions
          */           */
   
         function do_add_record() /* {{{ */          function do_add_record() /* {{{ */
         {          {
                 global $HTTP_SERVER_VARS;                  // Before trigger
                 $REMOTE_USER = $HTTP_SERVER_VARS['REMOTE_USER'];  
                 $REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR'];  
                 $tib         = true;  
                 // check for a before-add trigger  
                 if (isset($this->triggers['insert']['before'])) {                  if (isset($this->triggers['insert']['before'])) {
                         $tib = @include($this->triggers['insert']['before']);                          $ret = include($this->triggers['insert']['before']);
                           if ($ret == false) {
                                   return false;
                           }
                 }                  }
                 if ($tib) {                  // Preparing queries
                         // before trigger returned good status let's do the main operation                  $query       = '';
                         $key_col_val = '';                  $key_col_val = '';
                         $qry = '';                  for ($k = 0; $k < $this->num_fds; $k++) {
                         for ($k = 0; $k < $this->num_fds; $k++) {                          if ($this->processed($k)) {
                                 if ($this->processed($k)) {                                  $fd = $this->fds[$k];
                                         $fd = $this->fds[$k];                                  if ($fd == $this->key) {
                                         if ($fd == $this->key) {                                          $key_col_val = addslashes($this->encode($this->fdd[$k],$fn));
                                                 $key_col_val = addslashes($this->encode($this->fdd[$k],$fn));  
                                         }  
                                         if ($qry == '') {  
                                                 $qry = 'INSERT INTO '.$this->tb.' ('.$fd; // )  
                                         } else {  
                                                 $qry .= ','.$fd;  
                                         }  
                                 }                                  }
                         }                                  if ($query == '') {
                         $tim = false;                                          $query = 'INSERT INTO '.$this->tb.' ('.$fd; // )
                         // do the main operation                                  } else {
                         $vals     = array();                                          $query .= ','.$fd;
                         $vals_ori = array();  
                         for ($k = 0; $k < $this->num_fds; $k++) {  
                                 if ($this->processed($k)) {  
                                         if ($this->readonly($k)) {  
                                                 $fn = (string) @$this->fdd[$k]['default'];  
                                         } else {  
                                                 $fn = $this->get_cgi_var($this->fds[$k]);  
                                         }  
                                         /* Old Jim code: $this->col_is_set($k) && $fn != ''*/  
                                         $vals_ori[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn;  
                                         $vals[$k] = "'".addslashes($this->encode($this->fdd[$k],$vals_ori[$this->fds[$k]]))."'";  
                                 }                                  }
                         }                          }
                         $qry .= ') VALUES ('.join(',',$vals).')'; // )                  }
                         $res = $this->myquery($qry,__LINE__);                  $vals     = array();
                         if ($res) {                  $vals_ori = array();
                                 $tim = true;                  for ($k = 0; $k < $this->num_fds; $k++) {
                           if ($this->processed($k)) {
                                   if ($this->readonly($k)) {
                                           $fn = (string) @$this->fdd[$k]['default'];
                                   } else {
                                           $fn = $this->get_cgi_var($this->fds[$k]);
                                   }
                                   $vals_ori[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn;
                                   $vals[$k] = addslashes($this->encode($this->fdd[$k],$vals_ori[$this->fds[$k]]));
                                   $vals[$k] = "'".$vals[$k]."'";
                         }                          }
                         $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added'];  
                 }                  }
                 if ($tib && $tim && isset($this->triggers['insert']['after'])) {                  // Real query (no additional query in this method)
                         // before executed ok                  $query .= ') VALUES ('.join(',',$vals).')'; // )
                         // main op executed ok                  $res    = $this->myquery($query, __LINE__);
                         // let's do the after trigger                  $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added'];
                         $tia = @include($this->triggers['insert']['after']);                  if (! $res) {
                           return false;
                 }                  }
                 // Notify list                  // Notify list
                 if (@$this->notify['insert'] || @$this->notify['all']) {                  if (@$this->notify['insert'] || @$this->notify['all']) {
Line 2294  function form_control(theForm)
Line 2287  function form_control(theForm)
                 }                  }
                 // Note change in log table                  // Note change in log table
                 if ($this->logtable) {                  if ($this->logtable) {
                         $qry = sprintf('INSERT INTO %s'                          $query = sprintf('INSERT INTO %s'
                                         .' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'                                          .' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'
                                         .' VALUES (NOW(), "%s", "%s", "insert", "%s", "%s", "", "", "%s")',                                          .' VALUES (NOW(), "%s", "%s", "insert", "%s", "%s", "", "", "%s")',
                                         $this->logtable, addslashes($REMOTE_USER), addslashes($REMOTE_ADDR),                                          $this->logtable, addslashes($this->get_server_var('REMOTE_USER')),
                                         addslashes($this->tb), addslashes($key_col_val),                                          addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb),
                                         addslashes(serialize($vals_ori)));                                          addslashes($key_col_val), addslashes(serialize($vals_ori)));
                                 $this->myquery($qry, __LINE__);                          $this->myquery($query, __LINE__);
                   }
                   // After trigger
                   if (isset($this->triggers['insert']['after'])) {
                           $ret = include($this->triggers['insert']['after']);
                           if ($ret == false) {
                                   return false;
                           }
                 }                  }
                   return false;
         } /* }}} */          } /* }}} */
   
         function do_change_record() /* {{{ */          function do_change_record() /* {{{ */
         {          {
                 global $HTTP_SERVER_VARS;                  // Before trigger
                 $REMOTE_USER = $HTTP_SERVER_VARS['REMOTE_USER'];  
                 $REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR'];  
                 $tub         = true;  
                 // check for a before-add trigger  
                 if (isset($this->triggers['update']['before'])) {                  if (isset($this->triggers['update']['before'])) {
                         $tub = @include($this->triggers['update']['before']);                          $ret = include($this->triggers['update']['before']);
                           if ($ret == false) {
                                   return false;
                           }
                 }                  }
                 $tum = false;                  // Preparing queries
                 if ($tub) {                  $query_real   = '';
                         // before trigger returned good status                  $query_oldrec = '';
                         // let's do the main operation                  for ($k = 0; $k < $this->num_fds; $k++) {
                         $qry = '';                          if ($this->processed($k) && !$this->readonly($k)) {
                         $qry_old_rec = '';                                  $fd = $this->fds[$k];
                         for ($k = 0; $k < $this->num_fds; $k++) {                                  if ($fd == $this->key) {
                                 if ($this->processed($k) && !$this->readonly($k)) {                                          $key_col_val = addslashes($this->get_cgi_var($fd));
                                         $fd = $this->fds[$k];                                  }
                                         if ($fd == $this->key) {                                  $fn = $this->get_cgi_var($fd);
                                                 $key_col_val = addslashes($this->get_cgi_var($fd));                                  $newValue = is_array($fn) ? join(',',$fn) : $fn;
                                         }                                  $newValue = addslashes($this->encode($this->fdd[$k], $newValue));
                                         $fn = $this->get_cgi_var($fd);                                  if ($query_real == '') {
                                         /* Old Jim code: $this->col_is_set($k) && $fn != ''*/                                          $query_real   = 'UPDATE '.$this->tb.' SET '.$fd.'=\''.$newValue.'\'';
                                         if (is_array($fn)) {                                          $query_oldrec = 'SELECT '.$fd;
                                                 $newValue = addslashes($this->encode($this->fdd[$k],join(',',$fn)));                                  } else {
                                         } else {                                          $query_real   .= ','.$fd.'=\''.$newValue.'\'';
                                                 $newValue = addslashes($this->encode($this->fdd[$k],$fn));                                          $query_oldrec .= ','.$fd;
                                         }                                  }
                                         if ($qry == '') {                                  $newvalues[$this->fds[$k]] = $fn;
                                                 $qry = 'UPDATE '.$this->tb.' SET '.$fd.'=\''.$newValue.'\'';                          }
                                                 $qry_old_rec = 'SELECT `'.$fd.'`';                  }
                                         } else {                  $where_part = " WHERE (".$this->key.'='.$this->key_delim.$this->rec.$this->key_delim.')';
                                                 $qry .= ','.$fd.'=\''.$newValue.'\'';                  $query_real   .= $where_part;
                                                 $qry_old_rec .= ',`'.$fd.'`';                  $query_oldrec .= ' FROM ' . $this->tb . $where_part;
                                         }                  // Additional query (must go before real query)
                                         $newvalues[$this->fds[$k]] = $fn;                  if (@$this->notify['update'] || @$this->notify['all'] || $this->logtable) {
                                 } elseif ($this->hidden($k)) {                          $res_old   = $this->myquery($query_oldrec, __LINE__);
                                         // XXX do something                          $oldvalues = @mysql_fetch_array($res_old, MYSQL_ASSOC);
                                 }  
                         }  
                         $where = " WHERE (".$this->key.'='.$this->key_delim.$this->rec.$this->key_delim.')';  
                         $qry .= $where;  
                         $qry_old_rec .= ' FROM '.$this->tb.$where;  
                     // Get the old data  
                     $res_old = $this->myquery($qry_old_rec, __LINE__);  
                     $oldvalues = @mysql_fetch_array($res_old, MYSQL_ASSOC);  
                     // Update the data  
                         $res = $this->myquery($qry, __LINE__);  
                     // Find and accumulate the changes  
                         for ($k = 0; $k < $this->num_fds; $k++) {                          for ($k = 0; $k < $this->num_fds; $k++) {
                                 if ($this->processed($k) && !$this->readonly($k)) {                                  if ($this->processed($k) && !$this->readonly($k)) {
                                         if ($oldvalues[$this->fds[$k]] == $newvalues[$this->fds[$k]]) {                                          if ($oldvalues[$this->fds[$k]] == $newvalues[$this->fds[$k]]) {
Line 2363  function form_control(theForm)
Line 2352  function form_control(theForm)
                                         }                                          }
                                 }                                  }
                         }                          }
                         if ($res) {  
                                 $tum = true;  
                         }  
                         $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record changed'];  
                 }                  }
                 if ($tub && $tum && isset($this->triggers['update']['after'])) {                  // Real query
                         // before executed ok                  $res = $this->myquery($query_real, __LINE__);
                         // main op executed ok                  $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record changed'];
                         // let's do the after trigger                  if (! $res) {
                         $tua = @include($this->triggers['update']['after']);                          echo 'haha';
                           return false;
                 }                  }
                 // Notify list                  // Notify list
                 if (@$this->notify['update'] || @$this->notify['all']) {                  if (@$this->notify['update'] || @$this->notify['all']) {
Line 2384  function form_control(theForm)
Line 2370  function form_control(theForm)
                                 $qry = sprintf('INSERT INTO %s'                                  $qry = sprintf('INSERT INTO %s'
                                                 .' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'                                                  .' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'
                                                 .' VALUES (NOW(), "%s", "%s", "update", "%s", "%s", "%s", "%s", "%s")',                                                  .' VALUES (NOW(), "%s", "%s", "update", "%s", "%s", "%s", "%s", "%s")',
                                                 $this->logtable, addslashes($REMOTE_USER), addslashes($REMOTE_ADDR),                                                  $this->logtable, addslashes($this->get_server_var('REMOTE_USER')),
                                                 addslashes($this->tb), addslashes($key_col_val), addslashes($key),                                                  addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb),
                                                   addslashes($key_col_val), addslashes($key),
                                                 addslashes($oldvalues[$key]), addslashes($newvalues[$key]));                                                  addslashes($oldvalues[$key]), addslashes($newvalues[$key]));
                                 $this->myquery($qry, __LINE__);                                  $this->myquery($qry, __LINE__);
                         }                          }
                 }                  }
                   // After trigger
                   if (isset($this->triggers['update']['after'])) {
                           $ret = include($this->triggers['update']['after']);
                           if ($ret == false) {
                                   return false;
                           }
                   }
                   return true;
         } /* }}} */          } /* }}} */
   
         function do_delete_record() /* {{{ */          function do_delete_record() /* {{{ */
         {          {
                 global $HTTP_SERVER_VARS;                  // Before trigger
                 $REMOTE_USER = $HTTP_SERVER_VARS['REMOTE_USER'];  
                 $REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR'];  
                 $tdb         = true;  
                 // check for a before-add trigger  
                 if (isset($this->triggers['delete']['before'])) {                  if (isset($this->triggers['delete']['before'])) {
                         $tdb = include($this->triggers['delete']['before']);                          $ret = include($this->triggers['delete']['before']);
                           if ($ret == false) {
                                   return false;
                           }
                 }                  }
                 $tdm = false;                  // Preparing queries
                 // before trigger returned good status                  for ($k = 0; $k < $this->num_fds; $k++) {
                 // let's do the main operation                          if ($this->processed($k)) {
                 if ($tdb) {                                  if ($this->fds[$k] == $this->key) {
                         // before trigger returned good status                                          $key_col_val = addslashes($this->encode($this->fdd[$k], $fn));
                         // let's do the main operation  
                         for ($k = 0; $k < $this->num_fds; $k++) {  
                                 if ($this->processed($k)) {  
                                         $fd = $this->fds[$k];  
                                         if ($fd == $this->key) {  
                                                 $key_col_val = addslashes($this->encode($this->fdd[$k],$fn));  
                                         }  
                                 }                                  }
                         }                          }
                   }
                         if ($this->logtable) {                  // Additional query
                                 $res = $this->myquery(                  if (@$this->notify['delete'] || @$this->notify['all'] || $this->logtable) {
                                                 'SELECT * FROM '.$this->tb.' WHERE ('.$this->key.' = '                          $query = 'SELECT * FROM '.$this->tb.' WHERE ('.$this->key.' = '
                                                         .$this->key_delim.$this->rec.$this->key_delim.')' // )  
                                                 ,__LINE__);  
                                 $oldrow = mysql_fetch_array($res, MYSQL_ASSOC);  
                         }  
                         $qry = 'DELETE FROM '.$this->tb.' WHERE ('.$this->key.' = '  
                                         .$this->key_delim.$this->rec.$this->key_delim.')'; // )                                          .$this->key_delim.$this->rec.$this->key_delim.')'; // )
                         $res = $this->myquery($qry,__LINE__);                          $res = $this->myquery($query, __LINE__);
                         if ($res) {                          $oldrow = @mysql_fetch_array($res, MYSQL_ASSOC);
                                 $tdm = true;                  }
                         }                  // Real query
                         $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record deleted'];                  $query = 'DELETE FROM '.$this->tb.' WHERE ('.$this->key.' = '
                 }                                  .$this->key_delim.$this->rec.$this->key_delim.')'; // )
                 if ($tdb && $tdm && isset($this->triggers['delete']['after'])) {                  $res = $this->myquery($query, __LINE__);
                         // before executed ok                  $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record deleted'];
                         // main op executed ok                  if (! $res) {
                         // let's do the after trigger                          return false;
                         $tda = include($this->triggers['delete']['after']);  
                 }                  }
                 // Notify list                  // Notify list
                 if (@$this->notify['delete'] || @$this->notify['all']) {                  if (@$this->notify['delete'] || @$this->notify['all']) {
Line 2444  function form_control(theForm)
Line 2425  function form_control(theForm)
                 }                  }
                 // Note change in log table                  // Note change in log table
                 if ($this->logtable) {                  if ($this->logtable) {
                         $qry = sprintf('INSERT INTO %s'                          $query = sprintf('INSERT INTO %s'
                                         .' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'                                          .' (updated, user, host, operation, tab, rowkey, col, oldval, newval)'
                                         .' VALUES (NOW(), "%s", "%s", "delete", "%s", "%s", "%s", "%s", "")',                                          .' VALUES (NOW(), "%s", "%s", "delete", "%s", "%s", "%s", "%s", "")',
                                         $this->logtable, addslashes($REMOTE_USER), addslashes($REMOTE_ADDR),                                          $this->logtable, addslashes($this->get_server_var('REMOTE_USER')),
                                         addslashes($this->tb), addslashes($key_col_val), addslashes($key),                                          addslashes($this->get_server_var('REMOTE_ADDR')), addslashes($this->tb),
                                         addslashes(serialize($oldrow)));                                          addslashes($key_col_val), addslashes($key), addslashes(serialize($oldrow)));
                                 $this->myquery($qry, __LINE__);                          $this->myquery($query, __LINE__);
                   }
                   // After trigger
                   if (isset($this->triggers['delete']['after'])) {
                           $ret = include($this->triggers['delete']['after']);
                           if ($ret == false) {
                                   return false;
                           }
                 }                  }
                   return true;
         } /* }}} */          } /* }}} */
   
         function email_notify($old_vals, $new_vals) /* {{{ */          function email_notify($old_vals, $new_vals) /* {{{ */
         {          {
                 global $HTTP_SERVER_VARS;                  if (! function_exists('mail')) {
                 $REMOTE_USER = $HTTP_SERVER_VARS['REMOTE_USER'];                          return false;
                 $REMOTE_ADDR = $HTTP_SERVER_VARS['REMOTE_ADDR'];                  }
                 $user = $REMOTE_ADDR;  
                 strlen($REMOTE_USER) > 0 && $user = $REMOTE_USER.$user;  
                 if ($old_vals != false && $new_vals != false) {                  if ($old_vals != false && $new_vals != false) {
                         $action  = 'update';                          $action  = 'update';
                         $subject = 'Record updated in';                          $subject = 'Record updated in';
                         $body    = 'An item with '.$this->fdd[$this->key]['name'].' = '                          $body    = 'An item with '.$this->fdd[$this->key]['name'].' = '
                                 .$this->key_delim.$this->rec.$this->key_delim .' was updated in';                                  .$this->key_delim.$this->rec.$this->key_delim .' was updated in';
                           $vals    = $new_vals;
                 } elseif ($new_vals != false) {                  } elseif ($new_vals != false) {
                         $action  = 'insert';                          $action  = 'insert';
                         $subject = 'Record added to';                          $subject = 'Record added to';
Line 2479  function form_control(theForm)
Line 2467  function form_control(theForm)
                 } else {                  } else {
                         return false;                          return false;
                 }                  }
                   $addr  = $this->get_server_var('REMOTE_ADDR');
                   $user  = $this->get_server_var('REMOTE_USER');
                 $body  = 'This notification e-mail is automatically generated by phpMyEdit.'."\n\n".$body;                  $body  = 'This notification e-mail is automatically generated by phpMyEdit.'."\n\n".$body;
                 $body .= ' table '.$this->tb.' in MySQL database '.$this->db.' on '.$this->page_name;                  $body .= ' table '.$this->tb.' in MySQL database '.$this->db.' on '.$this->page_name;
                 $body .= ' by '.$user.' at '.date('d/M/Y H:i').' with the following fields:'."\n\n";                  $body .= ' by '.($user == '' ? 'unknown user' : "user $user").' from '.$addr;
                   $body .= ' at '.date('d/M/Y H:i').' with the following fields:'."\n\n";
                 $i = 1;                  $i = 1;
                 if ($action == 'update') {                  foreach ($vals as $k => $text) {
                         foreach (array_keys($new_vals) as $k) {                          $name = isset($this->fdd[$k]['name~'])
                                   ? $this->fdd[$k]['name~'] : $this->fdd[$k]['name'];
                           if ($action == 'update') {
                                 $body .= sprintf("[%02s] %s (%s)\n      WAS: %s\n      IS:  %s\n",                                  $body .= sprintf("[%02s] %s (%s)\n      WAS: %s\n      IS:  %s\n",
                                                 $i, $this->fdd[$k]['name'], $k, $old_vals[$k], $new_vals[$k]);                                                  $i, $name, $k, $old_vals[$k], $new_vals[$k]);
                                 $i++;                          } else {
                         }                                  $body .= sprintf('[%02s] %s (%s): %s'."\n", $i, $name, $k, $text);
                 } else {  
                         foreach ($vals as $k => $text) {  
                                 $body .= sprintf('[%02s] %s (%s): %s'."\n",  
                                                 $i, $this->fdd[$k]['name'], $k, $text);  
                                 $i++;  
                         }                          }
                           $i++;
                 }                  }
                 $body .= "\n--\n";                  $body    .= "\n--\r\n"; // \r is needed for signature separating
                 $body .= "phpMyEdit - MySQL table editor\n";                  $body    .= "phpMyEdit - instant MySQL table editor and code generator\n";
                 $body .= "http://www.platon.sk/projects/phpMyEdit/\n";                  $body    .= "http://www.platon.sk/projects/phpMyEdit/\n";
                 $subject = @$this->notify['prefix'].$subject.' '.$this->db.'.'.$this->tb;                  $subject  = @$this->notify['prefix'].$subject.' '.$this->db.'.'.$this->tb;
                 $emails  = (array) $this->notify[$action] + (array) $this->notify['all'];                  $wrap_w   = intval(@$this->notify['wrap']);
                   $wrap_w > 0 || $wrap_w = 72;
                   $from     = (string) @$this->notify['from'];
                   $from != '' || $from = 'webmaster@'.strtolower($this->get_server_var('SERVER_NAME'));
                   $headers  = 'From: '.$from."\n".'X-Mailer: PHP/'.phpversion().' (phpMyEdit)';
                   $body     = wordwrap($body, $wrap_w, "\n", 1);
                   $emails   = (array) $this->notify[$action] + (array) $this->notify['all'];
                 foreach ($emails as $email) {                  foreach ($emails as $email) {
                         if (! empty($email)) {                          if (! empty($email)) {
                                 mail($email, $subject, wordwrap($body));                                  mail(trim($email), trim($subject), $body, $headers);
                         }                          }
                 }                  }
                 return true;                  return true;
Line 2611  function form_control(theForm)
Line 2605  function form_control(theForm)
                 foreach ($this->sfn as $key => $val) {                  foreach ($this->sfn as $key => $val) {
                         if (preg_match('/^[-]?\d*$/', $val)) { // skipping numeric keys                          if (preg_match('/^[-]?\d*$/', $val)) { // skipping numeric keys
                                 $val = abs($val);                                  $val = abs($val);
                                 if (in_array($val, $check_ar)) {                                  if (in_array($val, $check_ar) || $this->hidden($val) || $this->password($val)) {
                                         unset($this->sfn[$key]);                                          unset($this->sfn[$key]);
                                 } else {                                  } else {
                                         $check_ar[] = $val;                                          $check_ar[] = $val;
Line 2624  function form_control(theForm)
Line 2618  function form_control(theForm)
                         } else {                          } else {
                                 $minus = '';                                  $minus = '';
                         }                          }
                         if (($val = array_search($val, $this->fds)) === false) {                          if (($val = array_search($val, $this->fds)) === false
                                           || $this->hidden($val) || $this->password($val)) {
                                 unset($this->sfn[$key]);                                  unset($this->sfn[$key]);
                         } else {                          } else {
                                 $val = intval($val);                                  $val = intval($val);
Line 2776  function form_control(theForm)
Line 2771  function form_control(theForm)
          */           */
         function phpMyEdit($opts) /* {{{ */          function phpMyEdit($opts) /* {{{ */
         {          {
                 global $HTTP_SERVER_VARS;  
   
                 /*                  /*
                  * Creating directory variables                   * Creating directory variables
                  */                   */
Line 2841  function form_control(theForm)
Line 2834  function form_control(theForm)
   
                 // language labels (must go after navigation)                  // language labels (must go after navigation)
                 $this->labels = $this->make_language_labels($opts['language']                  $this->labels = $this->make_language_labels($opts['language']
                                 ? $opts['language'] : $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE']);                                  ? $opts['language'] : $this->get_server_var('HTTP_ACCEPT_LANGUAGE'));
   
                 // CGI variables                  // CGI variables
                 $this->cgi['append']    = $opts['cgi']['append'];                  $this->cgi['append']    = $opts['cgi']['append'];
Line 2857  function form_control(theForm)
Line 2850  function form_control(theForm)
                  * Find the URL to post forms                   * Find the URL to post forms
                  */                   */
   
                 $this->page_name = basename($HTTP_SERVER_VARS['PHP_SELF']);                  $this->page_name = basename($this->get_server_var('PHP_SELF'));
   
                 /*                  /*
                  * Sorting variables                   * Sorting variables

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top