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.8 and 1.9

version 1.8, 2005/11/26 12:37:58 version 1.9, 2005/11/28 11:53:49
Line 1096  function ezin_check_message_flood() /* {
Line 1096  function ezin_check_message_flood() /* {
 } /* }}} */  } /* }}} */
   
 /*  /*
    * POLL RELATED FUNCTIONS
    */
   
   function ezin_get_poll($section_id, $lang = '') /* {{{ */
   {
           global $ezin_sys;
           global $ezin_db_handle;
   
           $section_id = intval($section_id);
   
           if ($section_id > 0) {
                   $query = 'SELECT'
                           .' polls.id poll_id,'
                           .' polls.question poll_question'
                                   .' FROM '.$ezin_sys['db']['tables']['polls'].' AS polls'
                                   .' WHERE polls.section_id = '.$section_id
                                   .' AND polls.dt_valid_from <= SYSDATE()'
                                   .' AND polls.dt_valid_to   >= SYSDATE()'
                                   .' ORDER BY polls.dt_valid_from DESC LIMIT 1';
                   $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_get_poll() [1]');
                   $row = mysql_fetch_array($result, MYSQL_ASSOC);
                   @mysql_free_result($result);
                   if (is_array($row)) {
                           return $row;
                   }
           }
   
           $query = sprintf('SELECT id FROM %s WHERE type = "global"', $ezin_sys['db']['tables']['sections']);
           if (strlen($lang) > 0) {
                   $query .= sprintf(' AND lang = "%s"', addslashes($lang));
           }
           $result = @mysql_query($query, $ezin_db_handle)
                   or ezin_db_error('ezin_get_poll() [2]');
           $ids_str = '';
           while ($row = @mysql_fetch_array($result, MYSQL_NUM)) {
                   $ids_str != '' && $ids_str .= ',';
                   $ids_str .= $row[0];
           }
           @mysql_free_result($result);
   
           if (strlen($ids_str)) {
                   $query = 'SELECT'
                           .' polls.id poll_id,'
                           .' polls.question poll_question'
                           .' FROM '.$ezin_sys['db']['tables']['polls'].' AS polls'
                           .' WHERE polls.section_id IN ('.$ids_str.')'
                           .' AND polls.dt_valid_from <= SYSDATE()'
                           .' AND polls.dt_valid_to   >= SYSDATE()'
                           .' ORDER BY polls.dt_valid_from DESC LIMIT 1';
                   $result = @mysql_query($query, $ezin_db_handle)
                           or ezin_db_error('ezin_get_poll() [3]');
                   $row = mysql_fetch_array($result, MYSQL_ASSOC);
                   @mysql_free_result($result);
                   if (is_array($row)) {
                           return $row;
                   }
           }
   
           return array('id' => 0, 'question' => '');
   } /* }}} */
   
   function ezin_get_poll_answer_list($poll_id) /* {{{ */
   {
           global $ezin_sys;
           global $ezin_db_handle;
   
           $poll_id = intval($poll_id);
   
           $query = 'SELECT'
                   .' id     poll_answer_id,'
                   .' answer poll_answer,'
                   .' answer poll_answer_answer,'
                   .' votes  poll_answer_votes'
                   .' FROM '.$ezin_sys['db']['tables']['poll_answers']
                   .' WHERE poll_id = '.$poll_id;
           $query .= ' ORDER BY votes DESC, id ASC';
           $result = @mysql_query($query, $ezin_db_handle)
                   or ezin_db_error('ezin_get_poll_answer_list()');
           $array = array();
           $total_votes = 0;
           for ($k = 0; ($array[$k] = mysql_fetch_array($result, MYSQL_ASSOC)); $k++) {
                   $total_votes += $array[$k]['poll_answer_votes'];
           }
           unset($array[$k]);
           for ($k = 0; $k < count($array); $k++) {
                   $array[$k]['poll_answer_pct'] = round(
                                   ($array[$k]['poll_answer_votes'] / max(1, $total_votes)) * 100);
           }
           @mysql_free_result($result);
           return $array;
   } /* }}} */
   
   function ezin_get_poll_answer_list_counts($poll_id) /* {{{ */
   {
           // TODO implement
           return array();
   } /* }}} */
   
   /*
  * FEEDBACK/NEWSLETTER RELATED FUNCTIONS   * FEEDBACK/NEWSLETTER RELATED FUNCTIONS
  */   */
   

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

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