'._('Recent news'); if (get_user_class() >= UC_ADMINISTRATOR) print(" - ["._('News page')."]"); echo '

'; if ($GLOBALS['settings']['cache'] && !($news = unserialize($cache_lite->get('news'))) ) { $res = do_mysql_query("SELECT id,DATE_FORMAT(added, '%Y-%m-%d') as added,body FROM news WHERE ADDDATE(added, INTERVAL 45 DAY) > NOW() ORDER BY added DESC LIMIT 10") or sqlerr(__FILE__, __LINE__); $news = array(); while ($inf = mysql_fetch_assoc($res) ) { $news[] = $inf; } $cache_lite->setLifeTime($GLOBALS['config']['cache_news']); $cache_lite->save( serialize($news), 'news'); } if (count($news) > 0) { print('
    '); foreach ($news as $array) { print("
  • " . $array['added'] . "
    " . nl2br($array['body'])); if (get_user_class() >= UC_ADMINISTRATOR) { print(" [E]"); print(" [D]"); } print("
  • "); } print("
\n"); } } function get_poll() { global $cache_lite, $settings, $CURUSER; // Get current poll if (!$settings['cache'] || !($poll_result = unserialize($cache_lite->get('poll')) ) ) { $res = do_mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr(__FILE__,__LINE__); if( mysql_num_rows($res) == 0) return; $poll_result = mysql_fetch_assoc($res); $cache_lite->setLifeTime($GLOBALS['config']['cache_poll']); $cache_lite->save( serialize($poll_result) ,'poll'); } $o = array($poll_result["option0"], $poll_result["option1"], $poll_result["option2"], $poll_result["option3"], $poll_result["option4"], $poll_result["option5"], $poll_result["option6"], $poll_result["option7"], $poll_result["option8"], $poll_result["option9"], $poll_result["option10"], $poll_result["option11"], $poll_result["option12"], $poll_result["option13"], $poll_result["option14"], $poll_result["option15"], $poll_result["option16"], $poll_result["option17"], $poll_result["option18"], $poll_result["option19"]); // Check if user has already voted $res = do_mysql_query("SELECT * FROM pollanswers WHERE pollid=".$poll_result['id']." AND userid=".$CURUSER['id']) or die(mysql_error()); $arr2 = mysql_fetch_assoc($res); print("

"._('Poll')); if (get_user_class() >= UC_MODERATOR) { print(" - ["._('New')."] - ["._('Edit')."] - ["._('Delete')."] "); } print('

'.$poll_result['question'].'

'); if ($arr2) { // display results if ( $arr2["selection"] ) $uservote = $arr2["selection"]; else $uservote = -1; // we reserve 255 for blank vote. $res = do_mysql_query("SELECT selection, COUNT(selection) as vote_count FROM pollanswers WHERE pollid=".$poll_result['id']." AND selection < 20 GROUP BY selection") or sqlerr(); //$tvotes = mysql_num_rows($res); $vs = array(); // array of vote selections $os = array(); /* Count votes...well mysql did that but we have to get it in an array right ;) */ while( $inf = mysql_fetch_assoc($res) ) { $vs[ $inf['selection'] ] = $inf['vote_count']; } /* Count the votes we have */ $tvotes = array_sum($vs); reset($o); for ($i = 0; $i < count($o); ++$i) if ($o[$i]) $os[$i] = array($vs[$i], $o[$i]); //$os[255] = array($vs[255], 'Blank vote'); // now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2")) if ($poll_result["sort"] == "yes") usort($os, srt); print(''); $i = 0; while ($a = $os[$i]) { if ($i == $uservote) $a[1] .= " *"; if ($tvotes == 0) $p = 0; else $p = round($a[0] / $tvotes * 100); $c= ""; print("\n"); ++$i; } print("
" . $a[1] . "  " . " $p%
\n"); print("

"._('Votes').": $tvotes

\n"); } else { print("
\n"); $i = 0; while ($a = $o[$i]) { print("$a
\n"); ++$i; } print("
"); print(""._('Blank vote (a.k.a. "I just want to see the results!")')."
\n"); print("

"); } ?>
Previous polls

\n"); ?> Comments about Poll