Code:
<?php
ob_start("ob_gzhandler");
require "include/bittorrent.php";
dbconn(true);
loggedinorreturn();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//$choice = (int)$_POST["choice"];
#$choice = (int) $_POST["choice"];
$choice = $_POST["choice"];
#if ($CURUSER && $choice != "" && $choice < 256 && $choice == floor($choice)) { Original
if ($CURUSER && ctype_digit($choice) != "" && $choice < 256 && $choice == floor($choice)) { #From TBDEV Fixes
$res = do_mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr();
$arr = mysql_fetch_assoc($res) or die("No poll");
$pollid = $arr["id"];
$userid = $CURUSER["id"];
$insert_pollvote = do_mysql_query("INSERT DELAYED INTO pollanswers VALUES(0, $pollid, $userid, $choice)");
//Check the error we get if the user has already voted
if (mysql_errno() == 1062) {
stderr("Error", "Dupe vote");
}
if (mysql_affected_rows() != 1)
stderr("Error", "An error occured. Your vote has not been counted.");
header("Location: ".$GLOBALS['DEFAULTBASEURL']);
die;
}
else
stderr("Error", "Please select an option.");
}
/*
$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)
$latestuser = "<a href=userdetails.php?id=" . $a["id"] . ">" . $a["username"] . "</a>";
else
$latestuser = $a['username'];
*/
$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'"));
$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'");
$peers = number_format($seeders + $leechers);
$seeders = number_format($seeders);
$leechers = number_format($leechers);
stdhead();
/*?><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/fl5WHj0bZ2Q&color1=0xb1b1b1&color2=0xcfcfcf&hl=en_US&feature=player_embedded&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/fl5WHj0bZ2Q&color1=0xb1b1b1&color2=0xcfcfcf&hl=en_US&feature=player_embedded&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="250" height="160" border=1></embed></object><?*/
print("<table width=737 class=main border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
/*?><center><font size=3 face="comic sans ms"><script language="javascript">
function chrono()
{
jour=Date.parse("Jan 01, 2011 GMT") - Date.parse(new Date);
return(Math.round(jour/(24*60*60*1000)))
}
document.write("Остават "+chrono()+" ден(а) до Нова Година!");
</script></font></center><br><?*/
if (get_user_class() >= UC_ADMINISTRATOR) {
print("<font size=1><b>News - <a class=altlink href=news.php>Admin</b></font></a>");
} else {
print("<font size=1><b>News</b></font><br>");
}
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("<table width=100% class=lista3 border=0 cellspacing=0 cellpadding=10><td style=\"border: none;\"><ul>\n");
while($array = mysql_fetch_array($res)) {
print("<li><b>" . gmdate("Y.m.d",strtotime($array['added'])) . "</b>");
print(" - ".format_comment($array['body'])."");
if (get_user_class() >= UC_MODERATOR)
{
print(" <font size=\"1\">[<a class=altlink href=news.php?action=edit&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . ">E</a>]</font>");
print(" <font size=\"1\">[<a class=altlink href=news.php?action=delete&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . ">D</a>]</font>");
}
print("</li>");
}
print("</ul></td></table>\n"); }
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);
}
if (get_user_class() >= UC_MODERATOR) {
print("<br><font size=1><b>Poll - <a class=altlink href=makepoll.php?returnto=main>New</a> - <a class=altlink href=makepoll.php?action=edit&pollid=$arr[id]&returnto=main>Edit</a> - <a class=altlink href=polls.php?action=delete&pollid=$arr[id]&returnto=main>Delete</b></font></a>");
} else {
print("<br><font size=1><b>Poll</b></font>"); }
if($pollok) {
print("<table width=100% border=0 class=lista3 cellspacing=0 cellpadding=10 style=\"border: none;\"><tr style=\"border: none;\"><td align=center style=\"border: none;\">\n");
print("<table class=lista3 border=0 cellspacing=0 cellpadding=0><tr><td class=text>");
print("<p align=center><b>$question</b></p>\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("<table width=100% border=0 cellspacing=0 cellpadding=0>\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 = " bgcolor=";
print("<tr><td width=1% class=embedded$c><nobr>" . $a[1] . " </nobr></td><td width=99% class=embedded$c>" .
"<img src=\"{$pic_base_url}bar_left.gif\"><img src=\"{$pic_base_url}bar.gif\" height=9 width=" . ($p * 3) .
"><img src=\"{$pic_base_url}bar_right.gif\"> $p%</td></tr>\n");
++$i;
}
print("</table>\n");
$tvotes = number_format($tvotes);
print("<p align=center>Votes: $tvotes</p>\n");
}
else
{
print("<form method=post action=index.php>\n");
$i = 0;
while ($a = $o[$i])
{
print("<input type=radio name=choice value=$i>$a<br>\n");
++$i;
}
print("<br>");
print("<input type=radio name=choice value=255>Blank vote (a.k.a. \"I just want to see the results!\")<br>\n");
print("<p align=center><input type=submit value='Vote!' class=btn></p>");
}
?>
</td></tr></table>
<?
if ($voted)
print("<p align=center><a href=polls.php>Previous Polls</a></p>\n");
?>
</td></tr></table>
<?
} else {
echo "<table width=100% border=0 class=lista cellspacing=0 cellpadding=10><tr><td align=center style=\"border: none;\">\n";
echo "<table class=lista border=0 cellspacing=0 cellpadding=0><tr><td class=text>";
echo"<p align=center><H3>No new poll</h3></p>\n";
echo "</td></tr></table></td></tr></table>";
}
}
?>
<? if (get_user_class() >= UC_VIP) {
$dt = gmtime() - 180;
$dt = sqlesc(get_date_time($dt));
$result = mysql_query("SELECT SUM(last_access >= $dt) AS totalol FROM users") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array ($result))
{
$totalonline = $row["totalol"];
}
$a = @mysql_fetch_assoc(@mysql_query("SELECT id, username, donor FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1")) or die(mysql_error());
if ($CURUSER)
$latestuser = "<a href=userdetails.php?id=" . $a["id"] . ">" . $a["username"] . "</a>";
else
$latestuser = $a['username'];
$dt = gmtime() - 180;
$dt = sqlesc(get_date_time($dt));
$res = mysql_query("SELECT id, username, class, donor, avatar FROM users WHERE last_access >= $dt ORDER BY username") or print(mysql_error());
while ($arr = mysql_fetch_assoc($res))
{
if ($activeusers) $activeusers .= " <font color=orange>-</font> \n";
switch ($arr["class"])
{
case UC_STAFF_LEADER:
$arr["username"] = "" . $arr["username"] . "<img src=pic/admin.gif border=0 height=11px>";
break;
case UC_SYSOP:
$arr["username"] = "" . $arr["username"] . "<img src=pic/admin.gif border=0 height=11px>";
break;
case UC_ADMINISTRATOR:
$arr["username"] = "" . $arr["username"] . "<img src=pic/admin.gif border=0 height=11px>";
break;
case UC_MODERATOR:
$arr["username"] = "" . $arr["username"] . "<img src=pic/admin.gif border=0 height=11px>";
break;
case UC_UPLOADER:
$arr["username"] = "" . $arr["username"] . "<img src=pic/member.gif border=0 height=11px>";
break;
case UC_VIP:
$arr["username"] = "" . $arr["username"] . "<img src=pic/member.gif border=0 height=11px>";
break;
case UC_POWER_USER:
$arr["username"] = "" . $arr["username"] . "<img src=pic/member.gif border=0 height=11px>";
break;
case UC_USER:
$arr["username"] = "" . $arr["username"] . "<img src=pic/guest.gif border=0 height=11px>";
break;
}
$donator = $arr["donated"] > 0;
if ($donator)
$activeusers .= "<nobr>";
if ($CURUSER)
if ($arr["avatar"]) {
$activeusers .= "<a href=\"userdetails.php?id=$arr[id]\" onmouseover=\"{Tip('<img src=" . $arr["avatar"] . " width=150px>');}\" onmouseout=\"UnTip();\"><b>" . $arr["username"] . "</b></a>";
} else {
$activeusers .= "<a href=\"userdetails.php?id=$arr[id]\" onmouseover=\"{Tip('<img src=pic/default_avatar.gif width=100%>');}\" onmouseout=\"UnTip();\"><b>" . $arr["username"] . "</b></a>"; }
else
$activeusers .= "<b>$arr[username]</b>";
if ($donator)
$activeusers .= "<img src=/pic/star.gif alt='Donated $$arr[donated]'></nobr>";
}
if (!$activeusers)
$activeusers = "Активни Потребители за последните 15 минути.";
print("<br><font size=1><b>Active users</b></font> (<font color=red>$totalonline</font>)");
?>
<table width=100% class=lista3 border=0 cellspacing=0 cellpadding=10><tr><td align=left style="border: none">
<?=$activeusers?><br>
</td></tr></table>
<??>
<!--<br><div class="rtop"><div class="r1"></div><div class="r2"></div><div class="r3"></div><div class="r4"></div></div>
<div class="xx">.......</div>
<div class="rbottom"><div class="r4"></div><div class="r3"></div><div class="r2"></div><div class="r1"></div></div>-->
<!--<br><b class="b1h"></b><b class="b2h"></b><b class="b3h"></b><b class="b4h"></b>
<div class="headh">
<h3>Заглавието на блока!</h3>
</div>
<div class="contenth">
<div>Съдържание!</div>
</div>
<b class="b4bh"></b><b class="b3bh"></b><b class="b2bh"></b><b class="b1h"></b>-->
<!--<div style=" background-color: #303030;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid #000;
padding-bottom: 6px; padding-left: 6px; padding-right: 6px; padding-top: 6px;" >Statistics</div>-->
<?if (get_user_class() >= UC_VIP) {?>
<br><?print("<font size=1><b>Stats</b></font>");?>
<table width=100% border=0 class=lista3 cellspacing=0 cellpadding=10><tr><td align=center style="border: none">
<table class=lista3 border=1 cellspacing=0 cellpadding=5 width=150px>
<td class=lista4>Max users</td><td align=right><?=$maxusers?></td></tr>
<td class=lista4>Registered users</td><td align=right><?=$registered?></td></tr>
<td class=lista4>Torrents</td><td align=right><?=$torrents?></td></tr>
<? if (isset($peers)) { ?>
<td class=lista4>Peers</td><td align=right><?=$peers?></td></tr>
<td class=lista4>Seeders</td><td align=right><?=$seeders?></td></tr>
<td class=lista4>Leechers</td><td align=right><?=$leechers?></td></tr>
<? } ?>
</table>
</td></tr></table>
<?}?>
<? }?>
</table>
<?
stdfoot();
?>