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

Diff for Metafox/db.inc.php between version 1.31 and 1.32

version 1.31, 2006/10/01 14:34:32 version 1.32, 2007/02/18 21:30:28
Line 17 
Line 17 
  * http://platon.sk/projects/Metafox/   * http://platon.sk/projects/Metafox/
  */   */
   
 /* $Platon: Metafox/db.inc.php,v 1.30 2006-09-20 15:02:07 nepto Exp $ */  /* $Platon: Metafox/db.inc.php,v 1.31 2006-10-01 14:34:32 nepto Exp $ */
   
 /*  /*
  * updates: 23/5/2001, 29/7/2001, 11/10/2001, 2/11/2001, 11/1/2002, 23/7/2002   * updates: 23/5/2001, 29/7/2001, 11/10/2001, 2/11/2001, 11/1/2002, 23/7/2002
Line 347  function ezin_get_articles_todo() /* {{{
Line 347  function ezin_get_articles_todo() /* {{{
         $query = sprintf('SELECT COUNT(*) FROM %s WHERE datetime > SYSDATE()',          $query = sprintf('SELECT COUNT(*) FROM %s WHERE datetime > SYSDATE()',
                         $ezin_sys['db']['tables']['articles']);                          $ezin_sys['db']['tables']['articles']);
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_get_author()');                  or ezin_db_error('ezin_get_articles_todo()');
         if (($row = @mysql_fetch_array($result, MYSQL_NUM)) == false)          if (($row = @mysql_fetch_array($result, MYSQL_NUM)) == false)
                 $row = array();                  $row = array();
         @mysql_free_result($result);          @mysql_free_result($result);
Line 554  function ezin_get_article($article_id) /
Line 554  function ezin_get_article($article_id) /
                 .($ezin_cfg['order_articles_desc'] ? 'DESC' : 'ASC')                  .($ezin_cfg['order_articles_desc'] ? 'DESC' : 'ASC')
                 .', articles.id ASC';                  .', articles.id ASC';
   
         //print "$query<hr>\n";  
   
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_get_article()');                  or ezin_db_error('ezin_get_article()');
   
Line 576  function ezin_get_author($author_id) /*
Line 574  function ezin_get_author($author_id) /*
         global $ezin_db_handle;          global $ezin_db_handle;
   
         $author_id = intval($author_id);          $author_id = intval($author_id);
           $ret_row   = array();
   
         $query = sprintf('SELECT * FROM %s WHERE id = %d',          $query = sprintf('SELECT * FROM %s WHERE id = %d',
                         $ezin_sys['db']['tables']['authors'], $author_id);                          $ezin_sys['db']['tables']['authors'], $author_id);
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_get_author()');                  or ezin_db_error('ezin_get_author() [1]');
         if (($row = @mysql_fetch_array($result, MYSQL_ASSOC)) == false)          if (($row = @mysql_fetch_array($result, MYSQL_ASSOC)) == false)
                 $row = array();                  $row = array();
         @mysql_free_result($result);          @mysql_free_result($result);
           foreach (array_keys($row) as $key) {
                   $ret_row['author_'.$key] = $row[$key];
           }
   
         $ret_row = array();          $query = sprintf('SELECT * FROM %s WHERE author_id = %d LIMIT 1',
                           $ezin_sys['db']['tables']['users'], $author_id);
           $result = @mysql_query($query, $ezin_db_handle)
                   or ezin_db_error('ezin_get_author() [2]');
           if (($row = @mysql_fetch_array($result, MYSQL_ASSOC)) == false)
                   $row = array();
           @mysql_free_result($result);
         foreach (array_keys($row) as $key) {          foreach (array_keys($row) as $key) {
                 $ret_row['author_'.$key] = $row[$key];                  $ret_row['author_'.$key] = $row[$key];
         }          }
Line 594  function ezin_get_author($author_id) /*
Line 601  function ezin_get_author($author_id) /*
         $query = sprintf('SELECT COUNT(*) FROM %s WHERE author_id = %d AND status != "disabled"',          $query = sprintf('SELECT COUNT(*) FROM %s WHERE author_id = %d AND status != "disabled"',
                         $ezin_sys['db']['tables']['articles'], $author_id);                          $ezin_sys['db']['tables']['articles'], $author_id);
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_get_author()');                  or ezin_db_error('ezin_get_author() [3]');
         if (($row = @mysql_fetch_array($result, MYSQL_NUM)) == false)          if (($row = @mysql_fetch_array($result, MYSQL_NUM)) == false)
                 $row = array();                  $row = array();
         @mysql_free_result($result);          @mysql_free_result($result);
   
         $ret_row['author_article_count'] = intval($row[0]);          $ret_row['author_article_count'] = intval($row[0]);
   
         return $ret_row;          return $ret_row;
 } /* }}} */  } /* }}} */
   
   function ezin_save_author($data) /* {{{ */
   {
           global $ezin_sys;
           global $ezin_db_handle;
   
           $escape_function = function_exists('mysql_escape_string')
                   ? 'mysql_escape_string'
                   : 'addslashes';
           foreach (array_keys($data) as $key) {
                   $data[$key] = $escape_function($data[$key]);
           }
   
           $query = sprintf('SELECT COUNT(*) FROM %s WHERE username = "%s"',
                           $ezin_sys['db']['tables']['users'], $data['username']);
           echo $query,'<hr>';
           $result = @mysql_query($query, $ezin_db_handle)
                   or ezin_db_error('ezin_save_author() [1]');
           if (($row = @mysql_fetch_array($result, MYSQL_NUM)) == false)
                   $row = array();
           @mysql_free_result($result);
           $exists = intval($row[0]);
   
           if ($exists) { /* {{{ */
                   // users update
                   $query = sprintf('UPDATE %s SET password="%s" WHERE username="%s"',
                                   $ezin_sys['db']['tables']['users'], $data['password'], $data['username']);
                   $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_save_author() [21]');
                   // author_id
                   $query = sprintf('SELECT COUNT(*) FROM %s WHERE username = "%s"',
                                   $ezin_sys['db']['tables']['users'], $data['username']);
                   $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_save_author() [22]');
                   if (($row = @mysql_fetch_array($result, MYSQL_NUM)) == false)
                           $row = array();
                   @mysql_free_result($result);
                   $author_id = intval($row[0]);
                   // users update
                   $query = sprintf('UPDATE %s SET name="%s",email="%s",homepage="%s",description="%s" WHERE id=%d',
                                   $ezin_sys['db']['tables']['authors'], $data['name'], $data['email'], $data['homepage'],
                                   $data['description'], $author_id);
                   $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_save_author() [23]');
           } /* }}} */
           else { /* {{{ */
                   // authors INSERT
                   $query = sprintf('INSERT INTO %s'
                                   .' (name,email,homepage,description)'
                                   .' VALUES ("%s","%s","%s","%s")',
                                   $ezin_sys['db']['tables']['authors'],
                                   $data['name'], $data['email'], $data['homepage'], $data['description']);
                   $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_save_author() [31]');
                   // author_id
                   $query = 'SELECT LAST_INSERT_ID()';
                   $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_save_author() [32]');
                   if (($row = @mysql_fetch_array($result, MYSQL_NUM)) == false)
                           $row = array();
                   @mysql_free_result($result);
                   $author_id = intval($row[0]);
                   // users INSERT
                   $query = sprintf('INSERT INTO %s'
                                   .' (username,password,author_id,role_id)'
                                   .' VALUES ("%s","%s",%d,8)',
                                   $ezin_sys['db']['tables']['users'],
                                   $data['username'], md5($data['password']), $author_id);
                   $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_save_author() [33]');
           } /* }}} */
   
           return $result;
   } /* }}} */
   
 /*  /*
  * COUNTS MANIPULATION FUNCTIONS   * COUNTS MANIPULATION FUNCTIONS
  */   */
Line 768  function ezin_get_message_count($article
Line 848  function ezin_get_message_count($article
         if ($article_id > 0)          if ($article_id > 0)
                 $query .= ' WHERE article_id = '.$article_id;                  $query .= ' WHERE article_id = '.$article_id;
   
         //print $query . "\n";  
   
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_get_message_count()');                  or ezin_db_error('ezin_get_message_count()');
   
Line 867  function ezin_update_counts($author_id,
Line 945  function ezin_update_counts($author_id,
                         .(! isset($type_ids['s']) ? ', raw_sessions_count = raw_sessions_count + 1' : '')                          .(! isset($type_ids['s']) ? ', raw_sessions_count = raw_sessions_count + 1' : '')
                         .' WHERE id = '.$section_id;                          .' WHERE id = '.$section_id;
                         //.' WHERE '.($section_id > 0 ? 'id = "'.$section_id.'"' : 'type = "global"');                          //.' WHERE '.($section_id > 0 ? 'id = "'.$section_id.'"' : 'type = "global"');
                 //echo $query . '<hr>';  
                 @mysql_query($query, $ezin_db_handle)                  @mysql_query($query, $ezin_db_handle)
                         or ezin_db_error('ezin_update_counts() [2B]');                          or ezin_db_error('ezin_update_counts() [2B]');
         } elseif ($author_id > 0) {          } elseif ($author_id > 0) {
Line 888  function ezin_update_counts($author_id,
Line 965  function ezin_update_counts($author_id,
                         if ($delim == '')                          if ($delim == '')
                                 $delim = ', ';                                  $delim = ', ';
                 }                  }
                 //echo $query . "<hr>";  
                 @mysql_query($query, $ezin_db_handle)                  @mysql_query($query, $ezin_db_handle)
                         or ezin_db_error('ezin_update_counts() [3A]');                          or ezin_db_error('ezin_update_counts() [3A]');
         } else {          } else {
Line 908  function ezin_update_counts($author_id,
Line 984  function ezin_update_counts($author_id,
                                 .' SET timestamp = UNIX_TIMESTAMP(SYSDATE())'                                  .' SET timestamp = UNIX_TIMESTAMP(SYSDATE())'
                                 .' WHERE ip = "'.$remote_addr.'"'                                  .' WHERE ip = "'.$remote_addr.'"'
                                 .' AND type_id = '.$type_id;                                  .' AND type_id = '.$type_id;
                         //echo $query . "<hr>";  
                         @mysql_query($query, $ezin_db_handle)                          @mysql_query($query, $ezin_db_handle)
                                 or ezin_db_error('ezin_update_counts() [3B]');                                  or ezin_db_error('ezin_update_counts() [3B]');
                 }                  }
Line 1011  function ezin_get_message($message_id) /
Line 1086  function ezin_get_message($message_id) /
                 .' AND articles.id = messages.article_id '                  .' AND articles.id = messages.article_id '
                 .' AND messages.id = '.$message_id;                  .' AND messages.id = '.$message_id;
   
         //print "$query\n";  
   
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_get_message()');                  or ezin_db_error('ezin_get_message()');
   
Line 1071  function ezin_save_message($data) /* {{{
Line 1144  function ezin_save_message($data) /* {{{
                         $data['parent'], $data['article_id'], $data['author'], $data['email'],                          $data['parent'], $data['article_id'], $data['author'], $data['email'],
                         $data['homepage'], $data['subject'], $data['message'], $data['ip']);                          $data['homepage'], $data['subject'], $data['message'], $data['ip']);
   
         //print $query . "\n";  
   
         // $result = must be here, see return below          // $result = must be here, see return below
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_save_message()');                  or ezin_db_error('ezin_save_message()');
Line 1099  function ezin_check_message_flood() /* {
Line 1170  function ezin_check_message_flood() /* {
                 .' WHERE ip LIKE "'.addslashes($_SERVER['REMOTE_ADDR']).'%"'                  .' WHERE ip LIKE "'.addslashes($_SERVER['REMOTE_ADDR']).'%"'
                 .' AND UNIX_TIMESTAMP(SYSDATE()) - UNIX_TIMESTAMP(datetime)'                  .' AND UNIX_TIMESTAMP(SYSDATE()) - UNIX_TIMESTAMP(datetime)'
                 .' <= '.$timeout;                  .' <= '.$timeout;
         //echo $query.'<hr>';  
   
         $result = @mysql_query($query, $ezin_db_handle)          $result = @mysql_query($query, $ezin_db_handle)
                 or ezin_db_error('ezin_check_message_flood()');                  or ezin_db_error('ezin_check_message_flood()');

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

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