Location: PHPKode > projects > Trunk.net > index.php
<?
ob_start("ob_gzhandler");

require "include/functions.php";
//require "rconpasswords.php";
dbconn(true);
if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST")
{
  $choice = $_POST["choice"];
  if ($CURUSER && $choice != "" && $choice < 256 && $choice == floor($choice))
  {
    $res = 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"];
    $res = mysql_query("SELECT * FROM pollanswers WHERE pollid=$pollid && userid=$userid") or sqlerr();
    $arr = mysql_fetch_assoc($res);
    if ($arr) die("Dupe vote");
    mysql_query("INSERT INTO pollanswers VALUES(0, $pollid, $userid, $choice)") or sqlerr();
    if (mysql_affected_rows() != 1)
      stderr("Error", "An error occured. Your vote has not been counted.");
    header("Location: $BASEURL/");
    die;
  }
  else
    stderr("Error", "Please select an option.");
}
$dt = gmtime() - 86400;
$dt = sqlesc(get_date_time($dt));
$result = mysql_query("SELECT SUM(last_access >= $dt) AS totalolday FROM users") or sqlerr(__FILE__, __LINE__); 

while ($row = mysql_fetch_array ($result)) 
{ 
$totalonlines      = $row["totalolday"]; 
} 

$dt = gmtime() - 10800;
$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 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];
if ($leechers == 0)
  $ratio = 0;
else
  $ratio = round($seeders / $leechers * 100);
$peers = number_format($seeders + $leechers);
$seeders = number_format($seeders);
$leechers = number_format($leechers);

$dt = gmtime() - 10800;
$dt = sqlesc(get_date_time($dt));
$res = mysql_query("SELECT id, username, class FROM users WHERE last_access >= $dt ORDER BY username") or print(mysql_error());
while ($arr = mysql_fetch_assoc($res))
{
if ($activeusers) $activeusers .= ",\n";
switch ($arr["class"])
{
  case UC_SYSOP:
  $arr["username"] = "<font color=#990099>" . $arr["username"] . "</font>";
    break;
case UC_ADMINISTRATOR:
     $arr["username"] = "<font color=#FF0000>" . $arr["username"] . "</font>";
     break;
case UC_MODERATOR:
     $arr["username"] = "<font color=#009933>" . $arr["username"] . "</font>";
     break;
case UC_UPLOADER:
     $arr["username"] = "<font color=#3366FF>" . $arr["username"] . "</font>";
     break;
case UC_VIP:
     $arr["username"] = "<font color=#2587A7>" . $arr["username"] . "</font>";
     break;
 case UC_POWER_USER:
     $arr["username"] = "<font color=#FF9966>" . $arr["username"] . "</font>";
     break;
	 case UC_USER:
}
$donator = $arr["donated"] > 0;
if ($donator)
  $activeusers .= "<nobr>";
if ($CURUSER)
  $activeusers .= "<a href=userdetails.php?id=" . $arr["id"] . "><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 ìèíóòè.";

stdhead();
//echo "<font class=small>Welcome to our newest member, <b>$latestuser</b>!</font>\n";

print("<table width=737 class=main border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
print("<h2>Íîâèíè");
if (get_user_class() >= UC_ADMINISTRATOR)
      print(" - <font class=small>[<a class=altlink href=news.php><b>Íîâà</b></a>]</font>");
print("</h2>\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% border=1 cellspacing=0 cellpadding=10><tr><td class=text>\n<ul>");
      while($array = mysql_fetch_array($res))
      {
        print("<li>" . gmdate("Y-m-d",strtotime($array['added'])) . " - " . $array['body']);
  if (get_user_class() >= UC_ADMINISTRATOR)
  {
          print(" <font size=\"-2\">[<a class=altlink href=news.php?action=edit&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "><b>Ðåäàêòèðàé</b></a>]</font>");
          print(" <font size=\"-2\">[<a class=altlink href=news.php?action=delete&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "><b>Èçòðèé</b></a>]</font>");
  }
  print("</li>");
}
print("</ul></td></tr></table>\n");
}

?><style type="text/css">
<!--
.style1 {color: #990099}
.style2 {color: #FF0000}
.style4 {color: #3366FF}
.style5 {color: #663399}
.style6 {color: #FF9966}
.style7 {color: #000000}
.style8 {color: #2587A7}
.style11 {color: #009933}
-->
</style>
<?
 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("<h2>Poll");

  if (get_user_class() >= UC_MODERATOR)
  {
  	print("<font class=small>");
		print(" - [<a class=altlink href=makepoll.php?returnto=main><b>New</b></a>]\n");
		if($pollok) {
  		print(" - [<a class=altlink href=makepoll.php?action=edit&pollid=$arr[id]&returnto=main><b>Edit</b></a>]\n");
			print(" - [<a class=altlink href=polls.php?action=delete&pollid=$arr[id]&returnto=main><b>Delete</b></a>]");
		}
		print("</font>");
	}
	print("</h2>\n");
	if($pollok) {
		print("<table width=100% border=1 cellspacing=0 cellpadding=10><tr><td align=center>\n");
  	print("<table class=main border=1 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 class=main width=100% border=0 cellspacing=0 cellpadding=0>\n");
    	$i = 0;
    	while ($a = $os[$i])
    	{
      	if ($i == $uservote)
        	$a[1] .= "&nbsp;*";
      	if ($tvotes == 0)
      		$p = 0;
      	else
      		$p = round($a[0] / $tvotes * 100);
      	if ($i % 2)
        	$c = "";
      	else
        	$c = " bgcolor=#ECE9D8";
      	print("<tr><td width=1% class=embedded$c><nobr>" . $a[1] . "&nbsp;&nbsp;</nobr></td><td width=99% class=embedded$c>" .
        	"<img src=/pic/bar_left.gif><img src=/pic/bar.gif height=9 width=" . ($p * 3) .
        	"><img src=/pic/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=1 cellspacing=0 cellpadding=10><tr><td align=center>\n";
  	echo "<table class=main border=1 cellspacing=0 cellpadding=0><tr><td class=text>";
  	echo"<p align=center><H3>Íÿìà àêòèâíè àíêåòè</h3></p>\n";
  	echo "</td></tr></table></td></tr></table>";
	}
}
?>
<?

$res = mysql_query("SELECT * FROM lottery_config") or sqlerr(__FILE__, __LINE__);
while ($arr = mysql_fetch_assoc($res))
$arr_config[$arr['name']] = $arr['value'];

$who_won = explode("|", $arr_config['lottery_winners']);
$who_won = array_unique($who_won);
$lottery_winners = '';
for ($x = 0; $x < count($who_won); $x++)
{
$username = '';
$res2 = mysql_query("SELECT id, username FROM users") or sqlerr(__FILE__, __LINE__);
while ($arr2 = mysql_fetch_assoc($res2))
{
if ($arr2['id'] == $who_won[$x])
{
$username = '<a href="userdetails.php?id='. $arr2['id'] .'">'. $arr2['username'] .'</a>';
$lottery_winners .= (!$lottery_winners) ? $username : ', '. $username;
break;
}
}
}

if (count($who_won) > 1)
$winners = 'Winners';
else
$winners = 'Winner';

if (count($who_won) > 1)
$each = ' (Each)';
else
$each = '';?>
<h2>Ñòàòèñòèêà</h2>
<table width=100% border=1 cellspacing=0 cellpadding=10>
  <tr>
    <td align=center>
      <table class=main border=1 cellspacing=0 cellpadding=5>
        <tr>
          <td class=rowhead>Ëèìèò íà ñàéòà</td><td align=right>5,000</td>
        </tr>
        <tr>
          <td class=rowhead><a href=/users.php tagret=_top>Ðåãèñòðèðàíè ïîòðåáèòåëè</a></td>
          <td align=right><?=$registered?></td>
        </tr>
        <!-- <tr><td class=rowhead>Unconfirmed users</td><td align=right><?=$unverified?></td></tr> -->
        <tr>
          <td class=rowhead><a href=/browse.php tagret=_top>Òîðåíòè</a></td>
          <td align=right><?=$torrents?></td>
        </tr>
        <? if (isset($peers)) { ?>
        <tr>
          <td class=rowhead>Ïèúðè</td>
          <td align=right><?=$peers?></td>
        </tr>
        <tr>
          <td class=rowhead>Ñèéäúðè</td>
          <td align=right><?=$seeders?></td>
        </tr>
        <tr>
          <td class=rowhead>Ëèé÷úðè</td>
          <td align=right><?=$leechers?></td>
        </tr>
        <tr>
          <td class=rowhead>Îòíîøåíèå ñèéäúðè/ëèé÷úðè (%)</td>
          <td align=right><?=$ratio?></td>
        </tr>
        <tr>
          <td class=rowhead>Îáùî ñâàëåíî</td>
          <td align=right><?=mksize($totaldownloaded)?></td>
        </tr>
        <tr>
          <td class=rowhead>Îáùî êà÷åíî</td>
          <td align=right><?=mksize($totaluploaded)?></td>
        </tr>
	<tr>
	<td class=rowhead>Last Lottery</td>
	<td align=right><?=count($who_won)?> <?=$winners?></td>
	</tr>

      <tr>
      <td class=rowhead>Last Amount Won<?=$each?></td>
	<td align=right><?=mksize($arr_config['lottery_winners_amount'])?></td>
	</tr>
	      <tr>
      <td class=rowhead>Date Of Last Lottery<?=$each?></td>
	<td align=right><?=$arr_config['lottery_winners_time']?></td>
	</tr>
        <? } ?>
    </table></td>
  </tr>
</table>
<?
latestforumposts()
?>
<h2>
  <? /*
<h2>Server load</h2>
<table width=100% border=1 cellspacing=0 cellpadding=10><tr><td align=center>
<table class=main border=0 width=402><tr><td style='padding: 0px; background-image: url(/pic/loadbarbg.gif); background-repeat: repeat-x'>
<? $percent = min(100, round(exec('ps ax | grep -c apache') / 256 * 100));
if ($percent <= 70) $pic = "loadbargreen.gif";
elseif ($percent <= 90) $pic = "loadbaryellow.gif";
else $pic = "loadbarred.gif";
$width = $percent * 4;
print("<img height=15 width=$width src=\"/pic/$pic\" alt='$percent%'>"); ?>
  </td>
  </tr>
  </table>
  </td>
  </tr>
  </table>
  */ ?>
  
</h2>
<h2 align="left"><span class="style1"><span class="style7">  ìîìåíòà ñà àêòèâíè <b><?=$totalonline?></b> ïîòðåáèòåëè | Ïðåç ïîñëåäíèòå 24 ÷àñà àêòèâíè ñà áèëè <?=$totalonlines?> ïîòðåáèòåëè</span></span></h2>
<table width=100% border=1 cellspacing=0 cellpadding=10><tr><td class=text>
<?=$activeusers?>
</td></tr></table>
<table width="641" border="1" align="center">
<br>
<center><b><font
           <span class="style1"><span class="style2"><span class="style5"><span class="style6"><span class="style7" class="large"><U> Ëåãåíäà</U> :  </FONT></span>   <FONT

           <span class="style1">[ SysOP | </FONT></span><FONT
           <span class="style1"><span class="style2">Administrator | </FONT></span><FONT
           <span class="style1"><span class="style2"><span class="style11">Moderator | </FONT></span> <FONT
           <span class="style1"><span class="style2"><span class="style4">Uploader |</FONT></span> <FONT
           <span class="style1"><span class="style2"><span class="style5"><span class="style8">VIP | </FONT></span> <FONT
           <span class="style1"><span class="style2"><span class="style5"><span class="style6">Power User | </FONT></span> <FONT
           <span class="style1"><span class="style2"><span class="style5"><span class="style6"><span class="style7">User ]</FONT></span></center>
</table>
<br>
<center></center>
<table width="100%" border="1" align=center background=images/mainbox_bg.jpg>
<td width="100%" height="100%">




<h2><p><center><font class=small color="red"><b>Âíèìàíèå:</b></font> <font class=small> Íèêîé îò ïîêàçâàíèòå ôàéëîâå íå ñå õîñòâà íà òîçè ñúðâúð. Ëèíêîâåòå ñå ïðåäîñòàâÿò åäèíñòâåíî îò ïîòðåáèòåëèòå íà ñàéòà.
Ñîáñòâåíèêúò íà òîçè ñàéò (</font><font class=small color="red"><b><? print("$SITENAME"); ?></b></font><font class=small>) íå íîñè<br>  îòãîâîðíîñò çà ñúäúðæàíèåòî íà ïóáëèêóâàíèòå ñúîáùåíèÿ èëè çà êàêâèòî è äà áèëî äðóãè äåéñòâèÿ,èçâúðøâàíè îò ïîòðåáèòåëèòå.
Íÿìàòå ïðàâî äà èçïîëçâàòå òîçè ñàéò, çà äà ñâàëÿòå èëè ðàçïðîñòðàíÿâàòå ìàòåðèàëè, àêî íÿìàòå ïðàâà äà èçâúðøâàòå òîâà.<br>
</font><font class=small color="red"><b>Âèå íîñèòå îòãîâîðíîñò çà ïðèäúðæàíå êúì òåçè óñëîâèÿ.</b></font></center></p></h2>
</td></tr></table>
</table>

<?
stdfoot();

hit_end();
?>
Return current item: Trunk.net