\n"); }else{ stderr("Error", "An error occured."); } } ///////////////////////////////End////////////////////////////// if ($CURUSER) { $a = @mysql_fetch_assoc(@mysql_query("SELECT id,username FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1")) or die(mysql_error()); if ($CURUSER) { $file2 = "$CACHE/index/newestuser.txt"; $expire = 2*60; // 2 minutes if (file_exists($file2) && filemtime($file2) > (time() - $expire)) { $newestuser = unserialize(file_get_contents($file2)); } else { $res = mysql_query("SELECT id,username FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1") or die(mysql_error()); while ($user = mysql_fetch_array($res) ) { $newestuser[] = $user; } $OUTPUT = serialize($newestuser); $fp = fopen($file2,"w"); fputs($fp, $OUTPUT); fclose($fp); } // end else foreach ($newestuser as $a) { $latestuser = "" . $a["username"] . ""; } } $file = "$CACHE/index/stats.txt"; $expire = 10*60; // 10 minutes if (file_exists($file) && filemtime($file) > (time() - $expire)) { $a=unserialize(file_get_contents($file)); $male = $a[1]; $female= $a[2]; $registered = $a[3]; $unverified = $a[4]; $torrents = $a[5]; $ratio = $a[6]; $peers = $a[7]; $seeders = $a[8]; $leechers = $a[9]; $NAT = $a[10]; } else { $male = number_format(get_row_count("users", "WHERE gender='Male'")); $female = number_format(get_row_count("users", "WHERE gender='Female'")); $registered = number_format(get_row_count("users")); $unverified = number_format(get_row_count("users", "WHERE status='pending'")); $torrents = number_format(get_row_count("torrents")); $dead = number_format(get_row_count("torrents", "WHERE visible='no'")); $NAT = number_format(get_row_count("peers", "WHERE connectable='no'")); $r = mysql_query("SELECT value_u FROM avps WHERE arg='seeders'") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_row($r); $seeders = 0 + $a[0]; $r = mysql_query("SELECT value_u FROM avps WHERE arg='leechers'") or sqlerr(__FILE__, __LINE__); $a = mysql_fetch_row($r); $leechers = 0 + $a[0]; $seeders = get_row_count("peers", "WHERE seeder='yes'"); $leechers = get_row_count("peers", "WHERE seeder='no'"); if ($leechers == 0) $ratio = 0; else $ratio = round($seeders / $leechers * 100); $peers = number_format($seeders + $leechers); $seeders = number_format($seeders); $leechers = number_format($leechers); $stats1 = array(1 => "$male", "$female", "$registered","$unverified","$torrents","$ratio","$peers","$seeders","$leechers"); $stats2 = serialize($stats1); $fh = fopen($file, "w"); fwrite($fh,$stats2); fclose($fh); } } stdhead(); //echo "Welcome to our newest member, $latestuser!\n"; $news_title = "Recent news"; print("
"); //print("

Recent news"); if (get_user_class() >= UC_ADMINISTRATOR) $news_title.=" - [News page]"; //print("

\n"); $res = mysql_query("SELECT * FROM news WHERE ADDDATE(added, INTERVAL 45 DAY) > NOW() ORDER BY added DESC LIMIT 10") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { //print("
\n
\n"); end_frame(); } if ($CURUSER) { // Get current poll $res = mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr(); if($pollok=(mysql_num_rows($res))) { $arr = mysql_fetch_assoc($res); $pollid = $arr["id"]; $userid = $CURUSER["id"]; $question = $arr["question"]; $o = array($arr["option0"], $arr["option1"], $arr["option2"], $arr["option3"], $arr["option4"], $arr["option5"], $arr["option6"], $arr["option7"], $arr["option8"], $arr["option9"], $arr["option10"], $arr["option11"], $arr["option12"], $arr["option13"], $arr["option14"], $arr["option15"], $arr["option16"], $arr["option17"], $arr["option18"], $arr["option19"]); // Check if user has already voted $res = mysql_query("SELECT * FROM pollanswers WHERE pollid=$pollid AND userid=$userid") or sqlerr(); $arr2 = mysql_fetch_assoc($res); } //print("

Poll"); $poll_title = "Poll"; if (get_user_class() >= UC_MODERATOR) { $poll_title.=""; $poll_title.=" - [New Poll]\n"; if($pollok) { $poll_title.=" - [Edit]\n"; $poll_title.=" - [Delete]"; } $poll_title.=""; } //print("

\n"); if($pollok) { //print("
\n"); begin_frame($poll_title,true,5); print("
"); print("

$question

\n"); $voted = $arr2; if ($voted) { // display results if ($arr["selection"]) $uservote = $arr["selection"]; else $uservote = -1; // we reserve 255 for blank vote. $res = mysql_query("SELECT selection FROM pollanswers WHERE pollid=$pollid AND selection < 20") or sqlerr(); $tvotes = mysql_num_rows($res); $vs = array(); // array of $os = array(); // Count votes while ($arr2 = mysql_fetch_row($res)) $vs[$arr2[0]] += 1; reset($o); for ($i = 0; $i < count($o); ++$i) if ($o[$i]) $os[$i] = array($vs[$i], $o[$i]); function srt($a,$b) { if ($a[0] > $b[0]) return -1; if ($a[0] < $b[0]) return 1; return 0; } // now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2")) if ($arr["sort"] == "yes") usort($os, srt); print("\n"); $i = 0; while ($a = $os[$i]) { if ($i == $uservote) $a[1] .= " *"; if ($tvotes == 0) $p = 0; else $p = round($a[0] / $tvotes * 100); if ($i % 2) $c = ""; else $c = ""; print("\n"); ++$i; } print("
" . $a[1] . "  " . "\"\"\"\"\"\" $p%
\n"); $tvotes = number_format($tvotes); 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"); end_frame(); ?>
\n"; echo "
"; echo"

No Active Polls

\n"; echo "
"; end_frame(); } } ?>

Message:

refresh
Users Registered
Users Unverified
Male Users
Female Users
Unconnectable Users
Torrents
Dead Torrents
Total Peers Ratio
Seeders
Leechers
Leechers/Seeders (%)
Last Lottery0
Last Lottery
Last Amount Won