Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, March 29, 2024

Diff for phpMyEdit/phpMyEdit.class.php between version 1.220 and 1.221

version 1.220, 2015/09/07 16:02:40 version 1.221, 2017/05/23 15:18:23
Line 19 
Line 19 
  * http://platon.sk/projects/phpMyEdit/   * http://platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.219 2015/07/09 12:15:58 igor Exp $ */  /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.220 2015/09/07 16:02:40 igor 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 319  class phpMyEdit
Line 319  class phpMyEdit
         function sql_connect() /* {{{ */          function sql_connect() /* {{{ */
         {          {
                 $flags = $this->ssl > 0 ? MYSQL_CLIENT_SSL : null;                  $flags = $this->ssl > 0 ? MYSQL_CLIENT_SSL : null;
                 $this->dbh = @ini_get('allow_persistent')                  if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                   ? @mysql_pconnect($this->hn, $this->un, $this->pw, $flags)                          $this->dbh = @ini_get('allow_persistent')
                   : @mysql_connect($this->hn, $this->un, $this->pw, false, $flags);                                  ? mysqli_connect('p:'.$this->hn, $this->un, $this->pw, $flags)
                                   : mysqli_connect($this->hn, $this->un, $this->pw, $flags);
                   } else { // FOR OLD PHP
                           $this->dbh = @ini_get('allow_persistent')
                                   ? @mysql_pconnect($this->hn, $this->un, $this->pw, $flags)
                                   : @mysql_connect($this->hn, $this->un, $this->pw, false, $flags);
                   }
         } /* }}} */          } /* }}} */
   
   
         function sql_disconnect() /* {{{ */          function sql_disconnect() /* {{{ */
         {          {
                 if ($this->close_dbh) {                  if ($this->close_dbh) {
                         @mysql_close($this->dbh);                          if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                                   mysqli_close($this->dbh);
                           } else { // FOR OLD PHP
                                   @mysql_close($this->dbh);
                           }
                         $this->dbh = null;                          $this->dbh = null;
                 }                  }
         } /* }}} */          } /* }}} */
   
         function sql_fetch(&$res, $type = 'a') /* {{{ */          function sql_fetch(&$res, $type = 'a') /* {{{ */
         {          {
                 if($type == 'n') $type = MYSQL_NUM;                  if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                 else $type = MYSQL_ASSOC;                          if($type == 'n') $type = MYSQLI_NUM;
                 return @mysql_fetch_array($res, $type);                          else $type = MYSQLI_ASSOC;
                           return mysqli_fetch_array($res, $type);
                   } else { // FOR OLD PHP
                           if($type == 'n') $type = MYSQL_NUM;
                           else $type = MYSQL_ASSOC;
                           return @mysql_fetch_array($res, $type);
                   }
         } /* }}} */          } /* }}} */
   
         function sql_free_result(&$res) /* {{{ */          function sql_free_result(&$res) /* {{{ */
         {          {
                 return @mysql_free_result($res);                  if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                           return mysqli_free_result($res);
                   } else { // FOR OLD PHP
                           return @mysql_free_result($res);
                   }
         } /* }}} */          } /* }}} */
   
         function sql_affected_rows(&$dbh) /* {{{ */          function sql_affected_rows(&$dbh) /* {{{ */
         {          {
                 return @mysql_affected_rows($dbh);                  if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                           return mysqli_affected_rows($dbh);
                   } else { // FOR OLD PHP
                           return @mysql_affected_rows($dbh);
                   }
         } /* }}} */          } /* }}} */
   
         function sql_field_len(&$res,$field) /* {{{ */          function sql_field_len(&$res,$field) /* {{{ */
         {          {
                 return @mysql_field_len($res, $field);                  if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                           return mysqli_fetch_field_direct($res, $field)->max_length;
                   } else { // FOR OLD PHP
                           return @mysql_field_len($res, $field);
                   }
         } /* }}} */          } /* }}} */
   
         function sql_insert_id() /* {{{ */          function sql_insert_id() /* {{{ */
         {          {
                 return mysql_insert_id($this->dbh);                  if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                           return mysqli_insert_id($this->dbh);
                   } else {
                           return mysql_insert_id($this->dbh);
                   }
         } /* }}} */          } /* }}} */
   
         function sql_limit($start, $more = null) /* {{{ */          function sql_limit($start, $more = null) /* {{{ */
Line 387  class phpMyEdit
Line 419  class phpMyEdit
                         echo '<h4>MySQL query at line ',$line,'</h4>',$this->_htmlspecialchars($qry),'<hr size="1" />',"\n";                          echo '<h4>MySQL query at line ',$line,'</h4>',$this->_htmlspecialchars($qry),'<hr size="1" />',"\n";
                 }                  }
                 if (isset($this->db)) {                  if (isset($this->db)) {
                         $ret = @mysql_db_query($this->db, $qry, $this->dbh);                          if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                                   mysqli_select_db($this->dbh, $this->db);
                                   $ret = mysqli_query($this->dbh, $qry);
                           } else { // FOR OLD PHP
                                   $ret = @mysql_db_query($this->db, $qry, $this->dbh);
                           }
                 } else {                  } else {
                         $ret = @mysql_query($qry, $this->dbh);                          if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                                   $ret = mysqli_query($this->dbh, $qry);
                           } else { // FOR OLD PHP
                                   $ret = @mysql_query($qry, $this->dbh);
                           }
                 }                  }
                 if (! $ret) {                  if (! $ret) {
                         echo '<h4>MySQL error ',mysql_errno($this->dbh),'</h4>';                          if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
                         echo $this->_htmlspecialchars(mysql_error($this->dbh)),'<hr size="1" />',"\n";                                  echo '<h4>MySQL error ',mysqli_errno($this->dbh),'</h4>';
                                   echo $this->_htmlspecialchars(mysqli_error($this->dbh)),'<hr size="1" />',"\n";
                           } else {
                                   echo '<h4>MySQL error ',mysql_errno($this->dbh),'</h4>';
                                   echo $this->_htmlspecialchars(mysql_error($this->dbh)),'<hr size="1" />',"\n";
                           }
                 }                  }
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
Line 1100  function '.$this->js['prefix'].'filter_h
Line 1146  function '.$this->js['prefix'].'filter_h
                                                         $strip_tags, $escape);                                                          $strip_tags, $escape);
                                 }                                  }
                         } elseif (isset ($this->fdd[$k]['textarea'])) {                          } elseif (isset ($this->fdd[$k]['textarea'])) {
                                 echo $this->htmlTextarea($this->cgi['prefix']['data'].$this->fds[$k], $css_class_name, $k, $this->fdd[$k]['default'], $escape);                                  echo $this->htmlTextarea($this->cgi['prefix']['data'].$this->fds[$k], $css_class_name, $k, @$this->fdd[$k]['default'], $escape);
                         } elseif ($this->col_has_php($k)) {                          } elseif ($this->col_has_php($k)) {
                                 echo include($this->fdd[$k]['php']);                                  echo include($this->fdd[$k]['php']);
                         } else {                          } else {
Line 1119  function '.$this->js['prefix'].'filter_h
Line 1165  function '.$this->js['prefix'].'filter_h
                                 echo ($this->readonly($k) ? ' disabled' : '');                                  echo ($this->readonly($k) ? ' disabled' : '');
                                 echo ' name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';                                  echo ' name="',$this->cgi['prefix']['data'].$this->fds[$k],'"';
                                 echo $len_props,' value="';                                  echo $len_props,' value="';
                                 if($escape) echo $this->_htmlspecialchars($this->fdd[$k]['default']);                                  if($escape) echo $this->_htmlspecialchars(@$this->fdd[$k]['default']);
                             else echo $this->fdd[$k]['default'];                              else echo $this->fdd[$k]['default'];
                                 echo '" />';                                  echo '" />';
                         }                          }
Line 1422  function '.$this->js['prefix'].'filter_h
Line 1468  function '.$this->js['prefix'].'filter_h
                         $value = intval($row["qf$k".'_timestamp']);                          $value = intval($row["qf$k".'_timestamp']);
                         $value = $value ? @strftime($this->fdd[$k]['strftimemask'], $value) : '';                          $value = $value ? @strftime($this->fdd[$k]['strftimemask'], $value) : '';
                 } else if ($this->is_values2($k, $row["qf$k"])) {                  } else if ($this->is_values2($k, $row["qf$k"])) {
                         $value = $row['qf'.$k.'_idx'];                          $value = @$row['qf'.$k.'_idx'];
                         if ($this->fdd[$k]['select'] == 'M') {                          if ($this->fdd[$k]['select'] == 'M') {
                                 $value_ar  = explode(',', $value);                                  $value_ar  = explode(',', $value);
                                 $value_ar2 = array();                                  $value_ar2 = array();
Line 2057  function '.$this->js['prefix'].'filter_h
Line 2103  function '.$this->js['prefix'].'filter_h
                 if (in_array($name, array('add','view','change','copy','delete'))) {                  if (in_array($name, array('add','view','change','copy','delete'))) {
                         $enabled_fnc = $name.'_enabled';                          $enabled_fnc = $name.'_enabled';
                         $enabled     = $this->$enabled_fnc();                          $enabled     = $this->$enabled_fnc();
                         if ($name != 'add' && ! $this->total_recs && strstr('LF', $this->page_type))                          if ($name != 'add' && ! @$this->total_recs && strstr('LF', $this->page_type))
                                 $enabled = false;                                  $enabled = false;
                         return $this->htmlSubmit('operation', ucfirst($name),                          return $this->htmlSubmit('operation', ucfirst($name),
                                         $this->getCSSclass($name, $position), false, $enabled ? 0 : $disabled);                                          $this->getCSSclass($name, $position), false, $enabled ? 0 : $disabled);
Line 2687  function '.$this->js['prefix'].'filter_h
Line 2733  function '.$this->js['prefix'].'filter_h
                 // Creating array of changed keys ($changed)                  // Creating array of changed keys ($changed)
                 $changed = array_keys($newvals);                  $changed = array_keys($newvals);
                 // Before trigger, newvals can be efectively changed                  // Before trigger, newvals can be efectively changed
                 if ($this->exec_triggers('insert', 'before', $oldvals, $changed, $newvals) == false) {                  if ($this->exec_triggers('insert', 'before', isset($oldvals) ? $oldvals : null, $changed, $newvals) == false) {
                         return false;                          return false;
                 }                  }
                 // Real query (no additional query in this method)                  // Real query (no additional query in this method)
Line 2735  function '.$this->js['prefix'].'filter_h
Line 2781  function '.$this->js['prefix'].'filter_h
                         $this->myquery($query, __LINE__);                          $this->myquery($query, __LINE__);
                 }                  }
                 // After trigger                  // After trigger
                 if ($this->exec_triggers('insert', 'after', $oldvals, $changed, $newvals) == false) {                  if ($this->exec_triggers('insert', 'after', isset($oldvals) ? $oldvals : null, $changed, $newvals) == false) {
                         return false;                          return false;
                 }                  }
                 return true;                  return true;
Line 2771  function '.$this->js['prefix'].'filter_h
Line 2817  function '.$this->js['prefix'].'filter_h
                 $this->sql_free_result($res);                  $this->sql_free_result($res);
                 // Creating array of changed keys ($changed)                  // Creating array of changed keys ($changed)
                 foreach ($newvals as $fd => $value) {                  foreach ($newvals as $fd => $value) {
                         if ($value != $oldvals[$fd])                          if ($value != @$oldvals[$fd])
                                 $changed[] = $fd;                                  $changed[] = $fd;
                 }                  }
                 // Before trigger                  // Before trigger
                 if ($this->exec_triggers('update', 'before', $oldvals, $changed, $newvals) == false) {                  if ($this->exec_triggers('update', 'before', isset($oldvals) ? $oldvals : null, $changed, $newvals) == false) {
                         return false;                          return false;
                 }                  }
                 // Build the real query respecting changes to the newvals array                  // Build the real query respecting changes to the newvals array
Line 2840  function '.$this->js['prefix'].'filter_h
Line 2886  function '.$this->js['prefix'].'filter_h
                         }                          }
                 }                  }
                 // After trigger                  // After trigger
                 if ($this->exec_triggers('update', 'after', $oldvals, $changed, $newvals) == false) {                  if ($this->exec_triggers('update', 'after', isset($oldvals) ? $oldvals : null, $changed, $newvals) == false) {
                         return false;                          return false;
                 }                  }
                 return true;                  return true;
Line 2858  function '.$this->js['prefix'].'filter_h
Line 2904  function '.$this->js['prefix'].'filter_h
                 $changed = is_array($oldvals) ? array_keys($oldvals) : array();                  $changed = is_array($oldvals) ? array_keys($oldvals) : array();
                 $newvals = array();                  $newvals = array();
                 // Before trigger                  // Before trigger
                 if ($this->exec_triggers('delete', 'before', $oldvals, $changed, $newvals) == false) {                  if ($this->exec_triggers('delete', 'before', isset($oldvals) ? $oldvals : null, $changed, $newvals) == false) {
                         return false;                          return false;
                 }                  }
                 // Real query                  // Real query
Line 2884  function '.$this->js['prefix'].'filter_h
Line 2930  function '.$this->js['prefix'].'filter_h
                         $this->myquery($query, __LINE__);                          $this->myquery($query, __LINE__);
                 }                  }
                 // After trigger                  // After trigger
                 if ($this->exec_triggers('delete', 'after', $oldvals, $changed, $newvals) == false) {                  if ($this->exec_triggers('delete', 'after', isset($oldvals) ? $oldvals : null, $changed, $newvals) == false) {
                         return false;                          return false;
                 }                  }
                 return true;                  return true;
Line 3122  function '.$this->js['prefix'].'filter_h
Line 3168  function '.$this->js['prefix'].'filter_h
                         }                          }
                         // move 'HWR' flags from ['options'] into ['input']                          // move 'HWR' flags from ['options'] into ['input']
                         if (isset($this->fdd[$column]['options'])) {                          if (isset($this->fdd[$column]['options'])) {
                                 stristr($this->fdd[$column]['options'], 'H') && $this->fdd[$column]['input'] .= 'H';                                  stristr($this->fdd[$column]['options'], 'H') && @$this->fdd[$column]['input'] .= 'H';
                                 stristr($this->fdd[$column]['options'], 'W') && $this->fdd[$column]['input'] .= 'W';                                  stristr($this->fdd[$column]['options'], 'W') && @$this->fdd[$column]['input'] .= 'W';
                                 stristr($this->fdd[$column]['options'], 'R') && $this->fdd[$column]['input'] .= 'R';                                  stristr($this->fdd[$column]['options'], 'R') && @$this->fdd[$column]['input'] .= 'R';
                         }                          }
                 }                  }
         } /* }}} */          } /* }}} */

Legend:
Removed from v.1.220  
changed lines
  Added in v.1.221

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