Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Piatok, 23. október 2026

Rozdiely pre phpMyEdit/phpMyEdit.class.php medzi verziami 1.189 a 1.190

verzia 1.189, 2006/11/26 13:25:59 verzia 1.190, 2007/04/11 19:39:39
Riadok 19 
Riadok 19 
  * http://platon.sk/projects/phpMyEdit/   * http://platon.sk/projects/phpMyEdit/
  */   */
   
 /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.188 2006-09-08 16:30:31 michal Exp $ */  /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.189 2006-11-26 13:25:59 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.
   
         This program works in three passes.          This program works in three passes.
         * Pass 1 (the last part of the program) displays the selected MySQL          * Pass 1 (the last part of the program) displays the selected SQL
           table in a scrolling table on the screen. Radio buttons are used to            table in a scrolling table on the screen. Radio buttons are used to
           select a record for editing or deletion. If the user chooses Add,            select a record for editing or deletion. If the user chooses Add,
           Change, Copy, View or Delete buttons.            Change, Copy, View or Delete buttons.
Riadok 149  class phpMyEdit
Riadok 149  class phpMyEdit
         var $navigation;        // navigation style          var $navigation;        // navigation style
         var $tabs;                      // TAB names          var $tabs;                      // TAB names
         var $timer = null;      // phpMyEdit_timer object          var $timer = null;      // phpMyEdit_timer object
           var $sd; var $ed;       // sql start and end delimiters '`' in case of MySQL
   
         // Predefined variables          // Predefined variables
         var $comp_ops  = array('<'=>'<','<='=>'<=','='=>'=','>='=>'>=','>'=>'>');          var $comp_ops  = array('<'=>'<','<='=>'<=','='=>'=','>='=>'>=','>'=>'>');
Riadok 306  class phpMyEdit
Riadok 307  class phpMyEdit
                 }                  }
         } /* }}} */          } /* }}} */
   
           /*
            * sql functions
        */
           function sql_connect() /* {{{ */
           {
                   $this->dbh = @ini_get('allow_persistent')
                           ? @mysql_pconnect($this->hn, $this->un, $this->pw)
                           : @mysql_connect($this->hn, $this->un, $this->pw);
           } /* }}} */
   
   
           function sql_disconnect() /* {{{ */
           {
                   if ($this->close_dbh) {
                           @mysql_close($this->dbh);
                           $this->dbh = null;
                   }
           } /* }}} */
   
           function sql_fetch(&$res, $type = 'a') /* {{{ */
           {
                   if($type == 'n') $type = MYSQL_NUM;
                   else $type = MYSQL_ASSOC;
                   return @mysql_fetch_array($res, $type);
           } /* }}} */
   
           function sql_free_result(&$res) /* {{{ */
           {
                   return @mysql_free_result($res);
           } /* }}} */
   
           function sql_affected_rows(&$dbh) /* {{{ */
           {
                   return @mysql_affected_rows($dbh);
           } /* }}} */
   
           function sql_field_len(&$res,$field) /* {{{ */
           {
                   return @mysql_field_len($res, $field);
           } /* }}} */
   
           function sql_insert_id() /* {{{ */
           {
                   return mysql_insert_id($this->dbh);
           } /* }}} */
   
           function sql_limit($start, $more) /* {{{ */
           {
                   return ' LIMIT '.$start.', '.$more.' ';
           } /* }}} */
   
           function sql_delimiter() /* {{{ */
           {
                   $this->sd = '`'; $this->ed='`';
                   return $this->sd;
           } /* }}} */
   
   
         function myquery($qry, $line = 0, $debug = 0) /* {{{ */          function myquery($qry, $line = 0, $debug = 0) /* {{{ */
         {          {
                 global $debug_query;                  global $debug_query;
Riadok 325  class phpMyEdit
Riadok 384  class phpMyEdit
                 return $ret;                  return $ret;
         } /* }}} */          } /* }}} */
   
           /* end of sql functions */
   
         function make_language_labels($language) /* {{{ */          function make_language_labels($language) /* {{{ */
         {          {
                 // just try the first language and variant                  // just try the first language and variant
Riadok 424  class phpMyEdit
Riadok 485  class phpMyEdit
                 }                  }
                 $values = array();                  $values = array();
                 $res    = $this->myquery($this->get_SQL_query($qparts), __LINE__);                  $res    = $this->myquery($this->get_SQL_query($qparts), __LINE__);
                 while ($row = @mysql_fetch_array($res, MYSQL_NUM)) {                  while ($row = $this->sql_fetch($res, 'n')) {
                         $values[$row[0]] = $desc ? $row[1] : $row[0];                          $values[$row[0]] = $desc ? $row[1] : $row[0];
                 }                  }
                 return $values;                  return $values;
Riadok 499  class phpMyEdit
Riadok 560  class phpMyEdit
                                 if ($parts['orderby'] != '')                                  if ($parts['orderby'] != '')
                                         $ret .= ' ORDER BY '.$parts['orderby'];                                          $ret .= ' ORDER BY '.$parts['orderby'];
                                 if ($parts['limit'] != '')                                  if ($parts['limit'] != '')
                                         $ret .= ' LIMIT '.$parts['limit'];                                          $ret .= ' '.$parts['limit'];
                                 if ($parts['procedure'] != '')                                  if ($parts['procedure'] != '')
                                         $ret .= ' PROCEDURE '.$parts['procedure'];                                          $ret .= ' PROCEDURE '.$parts['procedure'];
                                 break;                                  break;
Riadok 834  function '.$this->js['prefix'].'form_con
Riadok 895  function '.$this->js['prefix'].'form_con
                                                 }                                                  }
                                         }                                          }
   
                                         /* Multiple selects have their name like ``name[]''.                                          /* Multiple selects have their name like ''name[]''.
                                            It is not possible to work with them directly, because                                             It is not possible to work with them directly, because
                                            theForm.name[].something will result into JavaScript                                             theForm.name[].something will result into JavaScript
                                            syntax error. Following search algorithm is provided                                             syntax error. Following search algorithm is provided
Riadok 1041  function '.$this->js['prefix'].'filter_h
Riadok 1102  function '.$this->js['prefix'].'filter_h
                         .$this->key_delim.$this->rec.$this->key_delim.')';                          .$this->key_delim.$this->rec.$this->key_delim.')';
   
                 $res = $this->myquery($this->get_SQL_query($qparts),__LINE__);                  $res = $this->myquery($this->get_SQL_query($qparts),__LINE__);
                 if (! ($row = @mysql_fetch_array($res, MYSQL_ASSOC))) {                  if (! ($row = $this->sql_fetch($res))) {
                         return false;                          return false;
                 }                  }
                 for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) {                  for ($tab = 0, $k = 0; $k < $this->num_fds; $k++) {
Riadok 1956  function '.$this->js['prefix'].'filter_h
Riadok 2017  function '.$this->js['prefix'].'filter_h
                                 'from'   => $this->get_SQL_join_clause(),                                  'from'   => $this->get_SQL_join_clause(),
                                 'where'  => $this->get_SQL_where_from_query_opts());                                  'where'  => $this->get_SQL_where_from_query_opts());
                 $res = $this->myquery($this->get_SQL_query($count_parts), __LINE__);                  $res = $this->myquery($this->get_SQL_query($count_parts), __LINE__);
                 $row = @mysql_fetch_array($res, MYSQL_NUM);                  $row = $this->sql_fetch($res, 'n');
                 $this->total_recs = $row[0];                  $this->total_recs = $row[0];
         } /* }}} */          } /* }}} */
   
Riadok 2003  function '.$this->js['prefix'].'filter_h
Riadok 2064  function '.$this->js['prefix'].'filter_h
                 // Are we doing a listall?                  // Are we doing a listall?
                 $listall = $this->inc <= 0;                  $listall = $this->inc <= 0;
                 /*                  /*
                  * Display the MySQL table in an HTML table                   * Display the SQL table in an HTML table
                  */                   */
                 $this->form_begin();                  $this->form_begin();
                 echo $this->get_origvars_html($this->get_sfn_cgi_vars());                  echo $this->get_origvars_html($this->get_sfn_cgi_vars());
Riadok 2113  function '.$this->js['prefix'].'filter_h
Riadok 2174  function '.$this->js['prefix'].'filter_h
                                 $qparts['orderby'] = join(',', $sort_fields);                                  $qparts['orderby'] = join(',', $sort_fields);
                         }                          }
                 }                  }
                 $qparts['limit'] = $listall ? '' : $this->fm.','.$this->inc;                  $qparts['limit'] = $listall ? '' : $this->sql_limit($this->fm,$this->inc);
   
                 /*                  /*
                  * Main list_table() query                   * Main list_table() query
                  *                   *
                  * Each row of the HTML table is one record from the SQL query. We must                   * Each row of the HTML table is one record from the SQL query. We must
                  * perform this query before filter printing, because we want to use                   * perform this query before filter printing, because we want to use
                  * mysql_field_len() function. We will also fetch the first row to get                   * $this->sql_field_len() function. We will also fetch the first row to get
                  * the field names.                   * the field names.
                  */                   */
                 $query = $this->get_SQL_query($qparts);                  $query = $this->get_SQL_query($qparts);
Riadok 2129  function '.$this->js['prefix'].'filter_h
Riadok 2190  function '.$this->js['prefix'].'filter_h
                         $this->error('invalid SQL query', $query);                          $this->error('invalid SQL query', $query);
                         return false;                          return false;
                 }                  }
                 $row = @mysql_fetch_array($res, MYSQL_ASSOC);                  $row = $this->sql_fetch($res);
   
                 /* FILTER {{{                  /* FILTER {{{
                  *                   *
Riadok 2148  function '.$this->js['prefix'].'filter_h
Riadok 2209  function '.$this->js['prefix'].'filter_h
                                         $this->error('invalid SQL query', $query);                                          $this->error('invalid SQL query', $query);
                                         return false;                                          return false;
                                 }                                  }
                                 $filter_row = @mysql_fetch_array($res, MYSQL_ASSOC);                                  $filter_row = $this->sql_fetch($res);
                         }                          }
                         /* Variable $fields is used to get index of particular field in                          /* Variable $fields is used to get index of particular field in
                            result. That index can be passed in example to mysql_field_len()                             result. That index can be passed in example to $this->sql_field_len()
                            function. Use field names as indexes to $fields array. */                             function. Use field names as indexes to $fields array. */
                         if (is_array($filter_row)) {                          if (is_array($filter_row)) {
                                 $fields = array_flip(array_keys($filter_row));                                  $fields = array_flip(array_keys($filter_row));
Riadok 2202  function '.$this->js['prefix'].'filter_h
Riadok 2263  function '.$this->js['prefix'].'filter_h
                                         } elseif ($this->fdd[$fd]['select'] == 'N' || $this->fdd[$fd]['select'] == 'T') {                                          } elseif ($this->fdd[$fd]['select'] == 'N' || $this->fdd[$fd]['select'] == 'T') {
                                                 $len_props = '';                                                  $len_props = '';
                                                 $maxlen = intval($this->fdd[$k]['maxlen']);                                                  $maxlen = intval($this->fdd[$k]['maxlen']);
                                                 $maxlen > 0 || $maxlen = intval(@mysql_field_len($res, $fields["qf$k"]));                                                  $maxlen > 0 || $maxlen = intval($this->sql_field_len($res, $fields["qf$k"]));
                                                 $size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size']                                                  $size = isset($this->fdd[$k]['size']) ? $this->fdd[$k]['size']
                                                         : ($maxlen < 30 ? min($maxlen, 8) : 12);                                                          : ($maxlen < 30 ? min($maxlen, 8) : 12);
                                                 $len_props .= ' size="'.$size.'"';                                                  $len_props .= ' size="'.$size.'"';
Riadok 2285  function '.$this->js['prefix'].'filter_h
Riadok 2346  function '.$this->js['prefix'].'filter_h
                 $fetched  = true;                  $fetched  = true;
                 $first    = true;                  $first    = true;
                 $rowCount = 0;                  $rowCount = 0;
                 while ((!$fetched && ($row = @mysql_fetch_array($res, MYSQL_ASSOC)) != false)                  while ((!$fetched && ($row = $this->sql_fetch($res)) != false)
                                 || ($fetched && $row != false)) {                                  || ($fetched && $row != false)) {
                         $fetched = false;                          $fetched = false;
                         echo '<tr class="',$this->getCSSclass('row', null, 'next'),'">',"\n";                          echo '<tr class="',$this->getCSSclass('row', null, 'next'),'">',"\n";
Riadok 2414  function '.$this->js['prefix'].'filter_h
Riadok 2475  function '.$this->js['prefix'].'filter_h
                                 $qp['where']  = $this->get_SQL_where_from_query_opts();                                  $qp['where']  = $this->get_SQL_where_from_query_opts();
                                 $tot_query    = $this->get_SQL_query($qp);                                  $tot_query    = $this->get_SQL_query($qp);
                                 $totals_result = $this->myquery($tot_query,__LINE__);                                  $totals_result = $this->myquery($tot_query,__LINE__);
                                 $tot_row       = @mysql_fetch_array($totals_result, MYSQL_ASSOC);                                  $tot_row       = $this->sql_fetch($totals_result);
                         //}                          //}
                         $qp_aggr = $qp;                          $qp_aggr = $qp;
                         echo "\n",'<tr class="TODO-class">',"\n",'<td class="TODO-class">&nbsp;</td>',"\n";                          echo "\n",'<tr class="TODO-class">',"\n",'<td class="TODO-class">&nbsp;</td>',"\n";
Riadok 2550  function '.$this->js['prefix'].'filter_h
Riadok 2611  function '.$this->js['prefix'].'filter_h
                                 $value = "'".addslashes($val)."'";                                  $value = "'".addslashes($val)."'";
                         }                          }
                         if ($query == '') {                          if ($query == '') {
                                 $query = 'INSERT INTO `'.$this->tb.'` (`'.$fd.'`'; // )                                  $query = 'INSERT INTO '.$this->tb.' ('.$fd.''; // )
                                 $query2 = ') VALUES ('.$value.'';                                  $query2 = ') VALUES ('.$value.'';
                         } else {                          } else {
                                 $query  .= ', `'.$fd.'`';                                  $query  .= ', '.$fd.'';
                                 $query2 .= ', '.$value.'';                                  $query2 .= ', '.$value.'';
                         }                          }
                 }                  }
                 $query .= $query2.')';                  $query .= $query2.')';
                 $res    = $this->myquery($query, __LINE__);                  $res    = $this->myquery($query, __LINE__);
                 $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record added'];                  $this->message = $this->sql_affected_rows($this->dbh).' '.$this->labels['record added'];
                 if (! $res) {                  if (! $res) {
                         return false;                          return false;
                 }                  }
                 $this->rec = mysql_insert_id($this->dbh);                  $this->rec = $this->sql_insert_id();
                 // Notify list                  // Notify list
                 if (@$this->notify['insert'] || @$this->notify['all']) {                  if (@$this->notify['insert'] || @$this->notify['all']) {
                         $this->email_notify(false, $newvals);                          $this->email_notify(false, $newvals);
Riadok 2611  function '.$this->js['prefix'].'filter_h
Riadok 2672  function '.$this->js['prefix'].'filter_h
                 $query_oldrec .= ' FROM ' . $this->tb . $where_part;                  $query_oldrec .= ' FROM ' . $this->tb . $where_part;
                 // Additional query (must go before real query)                  // Additional query (must go before real query)
                 $res     = $this->myquery($query_oldrec, __LINE__);                  $res     = $this->myquery($query_oldrec, __LINE__);
                 $oldvals = @mysql_fetch_array($res, MYSQL_ASSOC);                  $oldvals = $this->sql_fetch($res);
                 @mysql_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])
Riadok 2646  function '.$this->js['prefix'].'filter_h
Riadok 2707  function '.$this->js['prefix'].'filter_h
                 $query_real .= $where_part;                  $query_real .= $where_part;
                 // 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 = $this->sql_affected_rows($this->dbh).' '.$this->labels['record changed'];
                 if (! $res) {                  if (! $res) {
                         return false;                          return false;
                 }                  }
Riadok 2656  function '.$this->js['prefix'].'filter_h
Riadok 2717  function '.$this->js['prefix'].'filter_h
                 }                  }
                 $query_newrec .= ' WHERE ('.$this->key.'='.$this->key_delim.$this->rec.$this->key_delim.')';                  $query_newrec .= ' WHERE ('.$this->key.'='.$this->key_delim.$this->rec.$this->key_delim.')';
                 $res     = $this->myquery($query_newrec, __LINE__);                  $res     = $this->myquery($query_newrec, __LINE__);
                 $newvals = @mysql_fetch_array($res, MYSQL_ASSOC);                  $newvals = $this->sql_fetch($res);
                 @mysql_free_result($res);                  $this->sql_free_result($res);
                 // Creating array of changed keys ($changed)                  // Creating array of changed keys ($changed)
                 $changed = array();                  $changed = array();
                 foreach ($newvals as $fd => $value) {                  foreach ($newvals as $fd => $value) {
Riadok 2696  function '.$this->js['prefix'].'filter_h
Riadok 2757  function '.$this->js['prefix'].'filter_h
                 $query   = 'SELECT * FROM '.$this->tb.' WHERE ('.$this->key.' = '                  $query   = 'SELECT * 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($query, __LINE__);                  $res     = $this->myquery($query, __LINE__);
                 $oldvals = @mysql_fetch_array($res, MYSQL_ASSOC);                  $oldvals = $this->sql_fetch($res);
                 @mysql_free_result($res);                  $this->sql_free_result($res);
                 // Creating array of changed keys ($changed)                  // Creating array of changed keys ($changed)
                 $changed = is_array($oldvals) ? array_keys($oldvals) : array();                  $changed = is_array($oldvals) ? array_keys($oldvals) : array();
                 $newvals = array();                  $newvals = array();
Riadok 2709  function '.$this->js['prefix'].'filter_h
Riadok 2770  function '.$this->js['prefix'].'filter_h
                 $query = 'DELETE FROM '.$this->tb.' WHERE ('.$this->key.' = '                  $query = '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($query, __LINE__);                  $res = $this->myquery($query, __LINE__);
                 $this->message = @mysql_affected_rows($this->dbh).' '.$this->labels['record deleted'];                  $this->message = $this->sql_affected_rows($this->dbh).' '.$this->labels['record deleted'];
                 if (! $res) {                  if (! $res) {
                         return false;                          return false;
                 }                  }
Riadok 2761  function '.$this->js['prefix'].'filter_h
Riadok 2822  function '.$this->js['prefix'].'filter_h
                 $addr  = $this->get_server_var('REMOTE_ADDR');                  $addr  = $this->get_server_var('REMOTE_ADDR');
                 $user  = $this->get_server_var('REMOTE_USER');                  $user  = $this->get_server_var('REMOTE_USER');
                 $body  = 'This notification e-mail was automatically generated by phpMyEdit.'."\n\n".$body;                  $body  = 'This notification e-mail was 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 SQL database '.$this->db.' on '.$this->page_name;
                 $body .= ' by '.($user == '' ? 'unknown user' : "user $user").' from '.$addr;                  $body .= ' by '.($user == '' ? 'unknown user' : "user $user").' from '.$addr;
                 $body .= ' at '.date('d/M/Y H:i').' with the following fields:'."\n\n";                  $body .= ' at '.date('d/M/Y H:i').' with the following fields:'."\n\n";
                 $i = 1;                  $i = 1;
Riadok 2780  function '.$this->js['prefix'].'filter_h
Riadok 2841  function '.$this->js['prefix'].'filter_h
                         $i++;                          $i++;
                 }                  }
                 $body    .= "\n--\r\n"; // \r is needed for signature separating                  $body    .= "\n--\r\n"; // \r is needed for signature separating
                 $body    .= "phpMyEdit\ninstant MySQL table editor and code generator\n";                  $body    .= "phpMyEdit\ninstant SQL table editor and code generator\n";
                 $body    .= "http://platon.sk/projects/phpMyEdit/\n\n";                  $body    .= "http://platon.sk/projects/phpMyEdit/\n\n";
                 $subject  = @$this->notify['prefix'].$subject.' '.$this->dbp.$this->tb;                  $subject  = @$this->notify['prefix'].$subject.' '.$this->dbp.$this->tb;
                 $subject  = trim($subject); // just for sure                  $subject  = trim($subject); // just for sure
Riadok 3001  function '.$this->js['prefix'].'filter_h
Riadok 3062  function '.$this->js['prefix'].'filter_h
                         $this->error('no table defined');                          $this->error('no table defined');
                         return false;                          return false;
                 }                  }
                 $this->dbh = @ini_get('allow_persistent')                  $this->sql_connect();
                         ? @mysql_pconnect($this->hn, $this->un, $this->pw)  
                         : @mysql_connect($this->hn, $this->un, $this->pw);  
                 if (!$this->dbh) {                  if (!$this->dbh) {
                         $this->error('could not connect to MySQL');                          $this->error('could not connect to SQL');
                         return false;                          return false;
                 }                  }
                 return true;                  return true;
         } /* }}} */          } /* }}} */
   
         /*  
          * Database disconnection function  
          */  
         function disconnect() /* {{{ */  
         {  
                 if ($this->close_dbh) {  
                         @mysql_close($this->dbh);  
                         $this->dbh = null;  
                 }  
         } /* }}} */  
   
         /*          /*
          * The workhorse           * The workhorse
          */           */
Riadok 3118  function '.$this->js['prefix'].'filter_h
Riadok 3166  function '.$this->js['prefix'].'filter_h
   
                 /*                  /*
                  * ======================================================================                   * ======================================================================
                  * Pass 1 and Pass 3: display the MySQL table in a scrolling window on                   * Pass 1 and Pass 3: display the SQL table in a scrolling window on
                  * the screen (skip this step in 'Add More' mode)                   * the screen (skip this step in 'Add More' mode)
                  * ======================================================================                   * ======================================================================
                  */                   */
Riadok 3126  function '.$this->js['prefix'].'filter_h
Riadok 3174  function '.$this->js['prefix'].'filter_h
                         $this->list_table();                          $this->list_table();
                 }                  }
   
                 $this->disconnect();                  $this->sql_disconnect();
                 if ($this->display['time'] && $this->timer != null) {                  if ($this->display['time'] && $this->timer != null) {
                         echo $this->timer->end(),' miliseconds';                          echo $this->timer->end(),' miliseconds';
                 }                  }

Legend:
Odstranené z verzie1.189  
zmenené riadky
  Pridané vo verzii1.190

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok