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.64 and 1.65

version 1.64, 2003/03/30 01:12:30 version 1.65, 2003/03/30 21:57:30
Line 19 
Line 19 
  * http://www.platon.sk/projects/phpMyEdit/   * http://www.platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.63 2003/03/29 15:41:18 nepto Exp $ */  /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.64 2003/03/30 01:12:30 nepto Exp $ */
   
 /*  This is a generic table editing program. The table and fields to be  /*  This is a generic table editing program. The table and fields to be
         edited are defined in the calling program.          edited are defined in the calling program.
Line 260  class phpMyEdit
Line 260  class phpMyEdit
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
   
         function encode($field,$str) /* {{{ */  
         {  
                 if (isset($field['dbencode'])) {  
                         return eval(  
                                         'return '  
                                         .$field['dbencode']  
                                         .'(\''.$str.'\');');  
                 } else {  
                         return $str;  
                 }  
         } /* }}} */  
   
         function make_language_labels($language) /* {{{ */          function make_language_labels($language) /* {{{ */
         {          {
                 // just try the first language and variant                  // just try the first language and variant
Line 755  function phpMyEdit_form_control(theForm)
Line 743  function phpMyEdit_form_control(theForm)
         {          {
                 for ($k = 0; $k < $this->num_fds; $k++) {                  for ($k = 0; $k < $this->num_fds; $k++) {
                         if ($this->hidden($k)) {                          if ($this->hidden($k)) {
                                 echo $this->htmlHidden($this->fds[$k], $this->htmlDisplay($this->fdd[$k],                                  echo $this->htmlHidden($this->fds[$k], $row["qf$k"]);
                                                         $row["qf$k"], false, true, false));  
                                 continue;                                  continue;
                         }                          }
                         if (! $this->displayed[$k]) {                          if (! $this->displayed[$k]) {
Line 780  function phpMyEdit_form_control(theForm)
Line 767  function phpMyEdit_form_control(theForm)
                                         echo 'cols="',$this->fdd[$k]['textarea']['cols'],'" ';                                          echo 'cols="',$this->fdd[$k]['textarea']['cols'],'" ';
                                 }                                  }
                                 echo 'name="',$this->fds[$k],'" wrap="virtual">';                                  echo 'name="',$this->fds[$k],'" wrap="virtual">';
                                 echo $this->htmlDisplay(                                  echo htmlspecialchars($this->fdd[$k]['default']);
                                                 $this->fdd[$k], $this->fdd[$k]['default'],  
                                                 false, false, false);  
                                 echo '</textarea>',"\n";                                  echo '</textarea>',"\n";
                         } else {                          } else {
                                 // Simple edit box required                                  // Simple edit box required
Line 795  function phpMyEdit_form_control(theForm)
Line 780  function phpMyEdit_form_control(theForm)
                                 echo '<input class="',$css_class_name,'" type="text" ';                                  echo '<input class="',$css_class_name,'" type="text" ';
                                 echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"';                                  echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"';
                                 echo $size_ml_props,' value="';                                  echo $size_ml_props,' value="';
                                 echo $this->htmlDisplay($this->fdd[$k],$this->fdd[$k]['default'],false,false,false),'">';                                  echo htmlspecialchars($this->fdd[$k]['default']),'">';
                         }                          }
                         echo '</td>',"\n";                          echo '</td>',"\n";
                         if ($this->guidance) {                          if ($this->guidance) {
Line 827  function phpMyEdit_form_control(theForm)
Line 812  function phpMyEdit_form_control(theForm)
                         if ($this->copy_operation() || $this->change_operation()) {                          if ($this->copy_operation() || $this->change_operation()) {
                                 if ($this->hidden($k)) {                                  if ($this->hidden($k)) {
                                         if ($k != $this->key_num) {                                          if ($k != $this->key_num) {
                                                 echo $this->htmlHidden($this->fds[$k], $this->htmlDisplay($this->fdd[$k],                                                  echo $this->htmlHidden($this->fds[$k], $row["qf$k"]);
                                                                         $row["qf$k"], false, true, false));  
                                         }                                          }
                                         continue;                                          continue;
                                 }                                  }
Line 886  function phpMyEdit_form_control(theForm)
Line 870  function phpMyEdit_form_control(theForm)
                         echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], $multiple);                          echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], $multiple);
                 } elseif (isset($this->fdd[$k]['textarea']) && !$this->readonly($k)) {                  } elseif (isset($this->fdd[$k]['textarea']) && !$this->readonly($k)) {
                         echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"';                          echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"';
                         // rows attr                          if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
                         if (isset($this->fdd[$k]['textarea']['rows'])) {  
                                 echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';                                  echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
                         }                          }
                         // cols attr                          if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
                         if (isset($this->fdd[$k]['textarea']['cols'])) {  
                                 echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';                                  echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
                         }                          }
                         // wrap attr  
                         if (isset($this->fdd[$k]['textarea']['wrap'])) {                          if (isset($this->fdd[$k]['textarea']['wrap'])) {
                                 echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';                                  echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
                         } else {                          } else {
                                 echo ' wrap="virtual"';                                  echo ' wrap="virtual"';
                         }                          }
                         echo '>',$this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false);                          echo '>',htmlspecialchars($row["qf$k"]),'</textarea>',"\n";
                         echo $row[$this->fds[$k]],'</textarea>',"\n";  
                 } else {                  } else {
                         $size_ml_props = '';                          $size_ml_props = '';
                         $maxlen = intval($this->fdd[$k]['maxlen']);                          $maxlen = intval($this->fdd[$k]['maxlen']);
Line 911  function phpMyEdit_form_control(theForm)
Line 891  function phpMyEdit_form_control(theForm)
                         $maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';                          $maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
                         echo '<input class="',$css_class_name,'" type="text" ';                          echo '<input class="',$css_class_name,'" type="text" ';
                         echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="';                          echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="';
                         echo $this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false);                          echo htmlspecialchars($row["qf$k"]),'" ',$size_ml_props,'>',"\n";
                         echo '" ',$size_ml_props,'>',"\n";  
                 }                  }
                 echo '</td>',"\n";                  echo '</td>',"\n";
         } /* }}} */          } /* }}} */
Line 928  function phpMyEdit_form_control(theForm)
Line 907  function phpMyEdit_form_control(theForm)
                 $maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';                  $maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
                 echo '<input class="',$this->getCSSclass('value', '', true),'" type="password" ';                  echo '<input class="',$this->getCSSclass('value', '', true),'" type="password" ';
                 echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="';                  echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="';
                 echo $this->htmlDisplay($this->fdd[$k], $row["qf$k"], false, true, false);                  echo htmlspecialchars($row["qf$k"]),'" ',$size_ml_props,'>',"\n";
                 echo '" ',$size_ml_props,'>',"\n";  
                 echo '</td>',"\n";                  echo '</td>',"\n";
         } /* }}} */          } /* }}} */
   
Line 937  function phpMyEdit_form_control(theForm)
Line 915  function phpMyEdit_form_control(theForm)
         {          {
                 $css_class_name = $this->getCSSclass('value', '', true);                  $css_class_name = $this->getCSSclass('value', '', true);
                 echo '<td class="',$css_class_name,'">';                  echo '<td class="',$css_class_name,'">';
                 if (@$this->fdd[$k]['datemask']) {                  echo $this->cellDisplay($k, $row, $css_class_name);
                         $value = $row["qf$k".'_timestamp'];  
                         $value = @date($this->fdd[$k]['datemask'], $value);  
                 } else if (@$this->fdd[$k]['strftimemask']) {  
                         $value = $row["qf$k".'_timestamp'];  
                         $value = @strftime($this->fdd[$k]['strftimemask'], $value);  
                 } else if ($this->is_values2($k, $row["qf$k"])) {  
                         $value = $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']];  
                 } else {  
                         $value = $row["qf$k"];  
                 }  
                 $value = $this->htmlDisplay($this->fdd[$k], $value, true, true, true, false);  
                 if ($this->col_has_URL($k)) {  
                         $key_rec = $row['qf'.$this->key_num];  
                         echo $this->urlDisplay($k, $value, $css_class_name, $key_rec);  
                 } else {  
                         echo nl2br(htmlspecialchars($value));  
                 }  
                 echo '</td>',"\n";                  echo '</td>',"\n";
         } /* }}} */          } /* }}} */
   
Line 1015  function phpMyEdit_form_control(theForm)
Line 976  function phpMyEdit_form_control(theForm)
                 $target = isset($this->fdd[$k]['URLtarget'])                  $target = isset($this->fdd[$k]['URLtarget'])
                         ? 'target="'.htmlspecialchars($this->fdd[$k]['URLtarget']).'" '                          ? 'target="'.htmlspecialchars($this->fdd[$k]['URLtarget']).'" '
                         : '';                          : '';
                 $prefix  = @$this->fdd[$k]['URLprefix'];                  $prefix_found  = false;
                 $postfix = @$this->fdd[$k]['URLpostfix'];                  $postfix_found = false;
                 if (strlen($prefix) > 0 && strncmp($prefix, $urllink, strlen($prefix))) {                  $prefix_ar     = @$this->fdd[$k]['URLprefix'];
                         $urllink = $prefix.$urllink;                  $postfix_ar    = @$this->fdd[$k]['URLpostfix'];
                   is_array($prefix_ar)  || $prefix_ar  = array($prefix_ar);
                   is_array($postfix_ar) || $postfix_ar = array($postfix_ar);
                   foreach ($prefix_ar as $prefix) {
                           if (! strncmp($prefix, $urllink, strlen($prefix))) {
                                   $prefix_found = true;
                                   break;
                           }
                 }                  }
                 if (strlen($postfix) > 0 && strcmp($postfix, substr($urllink, -strlen($postfix)))) {                  foreach ($postfix_ar as $postfix) {
                         $urllink .= $postfix;                          if (! strncmp($postfix, $urllink, strlen($postfix))) {
                                   $postfix_found = true;
                                   break;
                           }
                 }                  }
                   $prefix_found  || $urllink = array_shift($prefix_ar).$urllink;
                   $postfix_found || $urllink = $urllink.array_shift($postfix_ar);
                 if (strlen($urllink) <= 0 || strlen($urldisp) <= 0) {                  if (strlen($urllink) <= 0 || strlen($urldisp) <= 0) {
                         $ret = '&nbsp;';                          $ret = '&nbsp;';
                 } else {                  } else {
Line 1033  function phpMyEdit_form_control(theForm)
Line 1006  function phpMyEdit_form_control(theForm)
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
   
           function cellDisplay($k, $row, $css) /* {{{ */
           {
                   $key_rec = $row['qf'.$this->key_num];
                   if (@$this->fdd[$k]['datemask']) {
                           $value = $row["qf$k".'_timestamp'];
                           $value = @date($this->fdd[$k]['datemask'], $value);
                   } else if (@$this->fdd[$k]['strftimemask']) {
                           $value = $row["qf$k".'_timestamp'];
                           $value = @strftime($this->fdd[$k]['strftimemask'], $value);
                   } else if ($this->is_values2($k, $row["qf$k"])) {
                           $value = $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']];
                   } else {
                           $value = $row["qf$k"];
                   }
                   if (@$this->fdd[$k]['strip_tags']) {
                           $value = strip_tags($value);
                   }
                   if (intval($this->fdd[$k]['trimlen']) > 0 && strlen($value) > $this->fdd[$k]['trimlen']) {
                           $value = ereg_replace("[\r\n\t ]+",' ',$value);
                           $value = substr($value, 0, $this->fdd[$k]['trimlen'] - 3).'...';
                   }
                   if (@$this->fdd[$k]['mask']) {
                           $str = sprintf($field['mask'], $str);
                   }
                   if ($this->col_has_URL($k)) {
                           return $this->urlDisplay($k, $value, $css, $key_rec);
                   }
                   if (strlen($value) <= 0) {
                           return '&nbsp;';
                   }
                   return nl2br(htmlspecialchars($value));
           } /* }}} */
   
         /**          /**
          * Creates HTML hidden input element           * Creates HTML hidden input element
          *           *
Line 1041  function phpMyEdit_form_control(theForm)
Line 1047  function phpMyEdit_form_control(theForm)
          */           */
         function htmlHidden($name, $value) /* {{{ */          function htmlHidden($name, $value) /* {{{ */
         {          {
                 // Here are purpously not used htmlspecialchars()                  return '<input type="hidden" name="'.htmlspecialchars($name)
                 return '<input type="hidden" name="'.$name.'" value="'.$value.'">'."\n";                          .'" value="'.htmlspecialchars($value).'">'."\n";
         } /* }}} */          } /* }}} */
   
         /**          /**
Line 1055  function phpMyEdit_form_control(theForm)
Line 1061  function phpMyEdit_form_control(theForm)
          * @param       multiple        bool for mulptiple selection           * @param       multiple        bool for mulptiple selection
          * @param       nat_sort        bool for natural sorting           * @param       nat_sort        bool for natural sorting
          */           */
         function htmlSelect($name, $class, $kv_array, $selected = null, $multiple = false, $nat_sort = false) /* {{{ */          function htmlSelect($name, $css, $kv_array, $selected = null, $multiple = false, $nat_sort = false) /* {{{ */
         {          {
                 $ret = '<select class="'.htmlspecialchars($class).'" name="'.htmlspecialchars($name);                  $ret = '<select class="'.htmlspecialchars($css).'" name="'.htmlspecialchars($name);
                 if ($multiple) {                  if ($multiple) {
                         $ret  .= '[]" multiple size="'.$this->multiple;                          $ret  .= '[]" multiple size="'.$this->multiple;
                         if (! is_array($selected) && $selected !== null) {                          if (! is_array($selected) && $selected !== null) {
Line 1085  function phpMyEdit_form_control(theForm)
Line 1091  function phpMyEdit_form_control(theForm)
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
   
         /**  
          * Returns HTML text  
          *  
          * @param       field                   field name/number  
          * @param       str                             str to print  
          * @param       usemask                 flag if field mask should be used  
          * @param       usecodec                flag if field codec should be used  
          * @param       disallow_empty  flag if empty string is forbidden on output  
          * @param       escape                  flag if output should be HTML escaped  
          */  
         function htmlDisplay($field, $str,  /* ...) {{{ */  
                         $usemask        = true,  
                         $usecodec       = true,  
                         $disallow_empty = true,  
                         $escape         = true)  
         {  
                 // if there's a field mask, use it as first arg to sprintf  
                 if (isset($field['mask']) && $usemask) {  
                         $str = sprintf($field['mask'], $str);  
                 }  
                 // if db codec is in effect, use it  
                 if ($usecodec && isset($field['dbdecode'])) {  
                         $str = eval('return '.$field['dbdecode'].'(\''.$str.'\');');  
                 }  
                 if ($escape) {  
                         $str = htmlspecialchars($str);  
                 }  
                 if ($disallow_empty) {  
                         strlen($str) <= 0 && $str = '&nbsp;';  
                 }  
                 return $str;  
         } /* }}} */  
   
     /**      /**
      * Returns original variables HTML code for use in forms or links.       * Returns original variables HTML code for use in forms or links.
      *       *
Line 1466  function phpMyEdit_form_control(theForm)
Line 1439  function phpMyEdit_form_control(theForm)
                 }                  }
                 // If sort sequence has changed, restart listing                  // If sort sequence has changed, restart listing
                 $this->qfn != $this->prev_qfn && $this->fm = 0;                  $this->qfn != $this->prev_qfn && $this->fm = 0;
                 if (0) { // TODO: delete me!                  if (0) { // DEBUG
                         echo 'qfn vs. prev_qfn comparsion ';                          echo 'qfn vs. prev_qfn comparsion ';
                         echo '[<b>'.htmlspecialchars($this->qfn).'</b>]';                          echo '[<b>'.htmlspecialchars($this->qfn).'</b>]';
                         echo '[<b>'.htmlspecialchars($this->prev_qfn).'</b>]<br>';                          echo '[<b>'.htmlspecialchars($this->prev_qfn).'</b>]<br>';
Line 1775  function phpMyEdit_form_control(theForm)
Line 1748  function phpMyEdit_form_control(theForm)
                                 || ($fetched && $row != false)) {                                  || ($fetched && $row != false)) {
                         $fetched = false;                          $fetched = false;
                         echo '<tr class="',$this->getCSSclass('row', '', 'next'),'">',"\n";                          echo '<tr class="',$this->getCSSclass('row', '', 'next'),'">',"\n";
                         if ($sys_cols) {                          if ($sys_cols) { /* {{{ */
                                 $key_rec    = $row['qf'.$this->key_num];                                  $key_rec    = $row['qf'.$this->key_num];
                                 $qviewStr   = $qpviewStr   . '&rec='.$key_rec;                                  $qviewStr   = $qpviewStr   . '&rec='.$key_rec;
                                 $qcopyStr   = $qpcopyStr   . '&rec='.$key_rec;                                  $qcopyStr   = $qpcopyStr   . '&rec='.$key_rec;
Line 1868  function phpMyEdit_form_control(theForm)
Line 1841  function phpMyEdit_form_control(theForm)
                                 } elseif ($this->filter_enabled()) {                                  } elseif ($this->filter_enabled()) {
                                         echo '<td class="',$css_class_name,'" colspan=',$sys_cols,'>&nbsp;</td>',"\n";                                          echo '<td class="',$css_class_name,'" colspan=',$sys_cols,'>&nbsp;</td>',"\n";
                                 }                                  }
                         }                          } /* }}} */
                         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 (! $this->displayed[$k]) {                                  if (! $this->displayed[$k]) {
                                         continue;                                          continue;
Line 1889  function phpMyEdit_form_control(theForm)
Line 1862  function phpMyEdit_form_control(theForm)
                                         $colattrs .= ' width="'.$this->fdd[$fd]['width'].'"';                                          $colattrs .= ' width="'.$this->fdd[$fd]['width'].'"';
                                 }                                  }
                                 echo '<td class="',$css_class_name,'"',$colattrs,'>';                                  echo '<td class="',$css_class_name,'"',$colattrs,'>';
                                 if (@$this->fdd[$k]['datemask']) {                                  echo $this->cellDisplay($k, $row, $css_class_name);
                                         $value = $row["qf$k".'_timestamp'];  
                                         $value = @date($this->fdd[$k]['datemask'], $value);  
                                 } else if (@$this->fdd[$k]['strftimemask']) {  
                                         $value = $row["qf$k".'_timestamp'];  
                                         $value = @strftime($this->fdd[$k]['strftimemask'], $value);  
                                 } else if ($this->is_values2($k, $row["qf$k"])) {  
                                         $value = $this->fdd[$k]['values2'][$row['qf'.$k.'_idx']];  
                                 } else {  
                                         $value = $row["qf$k"];  
                                         if (@$this->fdd[$k]['strip_tags']) {  
                                                 $value = strip_tags($value);  
                                         }  
                                 }  
                                 if (isset($this->fdd[$k]['trimlen']) && strlen($value) > $this->fdd[$k]['trimlen']) {  
                                         $value = ereg_replace("[\r\n\t ]+",' ',$value);  
                                         $value = substr($value,0,$this->fdd[$k]['trimlen']-3).'...';  
                                 }  
                                 $value = $this->htmlDisplay($this->fdd[$k], $value, true, true, true, false);  
                                 if ($this->col_has_URL($k)) {  
                                         echo $this->urlDisplay($k, $value, $css_class_name, $key_rec);  
                                 } else {  
                                         echo nl2br(htmlspecialchars($value));  
                                 }  
                                 echo '</td>'."\n";                                  echo '</td>'."\n";
                         }                          } /* }}} */
                         echo '</tr>'."\n";                          echo '</tr>'."\n";
                 }                  }
   
Line 2020  function phpMyEdit_form_control(theForm)
Line 1970  function phpMyEdit_form_control(theForm)
                         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($fn);
                                 }                                  }
                                 if ($query == '') {                                  if ($query == '') {
                                         $query = 'INSERT INTO '.$this->tb.' ('.$fd; // )                                          $query = 'INSERT INTO '.$this->tb.' ('.$fd; // )
Line 2039  function phpMyEdit_form_control(theForm)
Line 1989  function phpMyEdit_form_control(theForm)
                                         $fn = $this->get_cgi_var($this->fds[$k]);                                          $fn = $this->get_cgi_var($this->fds[$k]);
                                 }                                  }
                                 $newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn;                                  $newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn;
                                 $vals_quoted[$k] = addslashes($this->encode($this->fdd[$k],$newvals[$this->fds[$k]]));                                  $vals_quoted[$k] = addslashes($newvals[$this->fds[$k]]);
                                 $vals_quoted[$k] = "'".$vals_quoted[$k]."'";                                  $vals_quoted[$k] = "'".$vals_quoted[$k]."'";
                         }                          }
                 }                  }
                   // Creating array of changed keys ($changed)
                   $changed = array_keys($newvals);
                 // Before trigger                  // Before trigger
                 if (isset($this->triggers['insert']['before'])) {                  if (isset($this->triggers['insert']['before'])) {
                         $ret = include($this->triggers['insert']['before']);                          $ret = include($this->triggers['insert']['before']);
Line 2086  function phpMyEdit_form_control(theForm)
Line 2038  function phpMyEdit_form_control(theForm)
                 // Preparing queries                  // Preparing queries
                 $query_real   = '';                  $query_real   = '';
                 $query_oldrec = '';                  $query_oldrec = '';
                   $newvals      = array();
                   $oldvals      = array();
                   $changed      = array();
                 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)) {
                                 $fd = $this->fds[$k];                                  $fd = $this->fds[$k];
Line 2094  function phpMyEdit_form_control(theForm)
Line 2049  function phpMyEdit_form_control(theForm)
                                 }                                  }
                                 $fn = $this->get_cgi_var($fd);                                  $fn = $this->get_cgi_var($fd);
                                 $newValue = $newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn;                                  $newValue = $newvals[$this->fds[$k]] = is_array($fn) ? join(',',$fn) : $fn;
                                 $newValue = addslashes($this->encode($this->fdd[$k], $newValue));                                  $newValue = addslashes($newValue);
                                 if ($query_real == '') {                                  if ($query_real == '') {
                                         $query_real   = 'UPDATE '.$this->tb.' SET '.$fd.'=\''.$newValue.'\'';                                          $query_real   = 'UPDATE '.$this->tb.' SET '.$fd.'=\''.$newValue.'\'';
                                         $query_oldrec = 'SELECT '.$fd;                                          $query_oldrec = 'SELECT '.$fd;
Line 2111  function phpMyEdit_form_control(theForm)
Line 2066  function phpMyEdit_form_control(theForm)
                 $res_old = $this->myquery($query_oldrec, __LINE__);                  $res_old = $this->myquery($query_oldrec, __LINE__);
                 $oldvals = @mysql_fetch_array($res_old, MYSQL_ASSOC);                  $oldvals = @mysql_fetch_array($res_old, MYSQL_ASSOC);
                 @mysql_free_result($res);                  @mysql_free_result($res);
                   // Creating array of changed keys ($changed)
                   for ($k = 0; $k < $this->num_fds; $k++) {
                           $key = $this->fds[$k];
                           if (! $this->processed($k) || $this->readonly($k) || $oldvals[$key] == $newvals[$key]) {
                                   continue;
                           }
                           $changed[] = $key;
                   }
                 // Before trigger                  // Before trigger
                 if (isset($this->triggers['update']['before'])) {                  if (isset($this->triggers['update']['before'])) {
                         $ret = include($this->triggers['update']['before']);                          $ret = include($this->triggers['update']['before']);
Line 2118  function phpMyEdit_form_control(theForm)
Line 2081  function phpMyEdit_form_control(theForm)
                                 return false;                                  return false;
                         }                          }
                 }                  }
                 // Removing the same values  
                 for ($k = 0; $k < $this->num_fds; $k++) {  
                         if (! $this->processed($k) || $this->readonly($k)  
                                         || $oldvals[$this->fds[$k]] == $newvals[$this->fds[$k]]) {  
                                 unset($oldvals[$this->fds[$k]]);  
                                 unset($newvals[$this->fds[$k]]);  
                         }  
                 }  
                 // Real query                  // Real query
                 $res = $this->myquery($query_real, __LINE__);                  $res = $this->myquery($query_real, __LINE__);
                 $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record changed'];                  $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record changed'];
Line 2134  function phpMyEdit_form_control(theForm)
Line 2089  function phpMyEdit_form_control(theForm)
                 }                  }
                 // Notify list                  // Notify list
                 if (@$this->notify['update'] || @$this->notify['all']) {                  if (@$this->notify['update'] || @$this->notify['all']) {
                         $this->email_notify($oldvals, $newvals);                          if (count($changed) > 0) {
                                   $this->email_notify($oldvals, $newvals);
                           }
                 }                  }
                 // Note change in log table                  // Note change in log table
                 if ($this->logtable) {                  if ($this->logtable) {
                         foreach (array_keys($newvals) as $key) {                          foreach ($changed as $key) {
                                 $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")',
Line 2165  function phpMyEdit_form_control(theForm)
Line 2122  function phpMyEdit_form_control(theForm)
                 for ($k = 0; $k < $this->num_fds; $k++) {                  for ($k = 0; $k < $this->num_fds; $k++) {
                         if ($this->processed($k)) {                          if ($this->processed($k)) {
                                 if ($this->fds[$k] == $this->key) {                                  if ($this->fds[$k] == $this->key) {
                                         $key_col_val = addslashes($this->encode($this->fdd[$k], $fn));                                          $key_col_val = addslashes($fn);
                                 }                                  }
                         }                          }
                 }                  }
Line 2175  function phpMyEdit_form_control(theForm)
Line 2132  function phpMyEdit_form_control(theForm)
                 $res     = $this->myquery($query, __LINE__);                  $res     = $this->myquery($query, __LINE__);
                 $oldvals = @mysql_fetch_array($res, MYSQL_ASSOC);                  $oldvals = @mysql_fetch_array($res, MYSQL_ASSOC);
                 @mysql_free_result($res);                  @mysql_free_result($res);
                   // Creating array of changed keys ($changed)
                   $changed = array_keys($oldvals);
                 // Before trigger                  // Before trigger
                 if (isset($this->triggers['delete']['before'])) {                  if (isset($this->triggers['delete']['before'])) {
                         $ret = include($this->triggers['delete']['before']);                          $ret = include($this->triggers['delete']['before']);
Line 2249  function phpMyEdit_form_control(theForm)
Line 2208  function phpMyEdit_form_control(theForm)
                         $name = isset($this->fdd[$k]['name~'])                          $name = isset($this->fdd[$k]['name~'])
                                 ? $this->fdd[$k]['name~'] : $this->fdd[$k]['name'];                                  ? $this->fdd[$k]['name~'] : $this->fdd[$k]['name'];
                         if ($action == 'update') {                          if ($action == 'update') {
                                   if ($old_vals[$k] == $new_vals[$k]) {
                                           continue;
                                   }
                                 $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, $name, $k, $old_vals[$k], $new_vals[$k]);                                                  $i, $name, $k, $old_vals[$k], $new_vals[$k]);
                         } else {                          } else {

Legend:
Removed from v.1.64  
changed lines
  Added in v.1.65

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