Page 1 of 2

PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Fri Nov 20, 2009 9:29 pm
by squills
hello, I have a question and hope someone can help me out.

I got an index page that was working 100% the site owner sent me the page, when i try to access it , i get this error
Parse error: syntax error, unexpected $end in C:\site\xampp\htdocs\RTN\index.php on line 586

line 586 is the last line in index.php

I know it cant be open brackets cause same page loads for the site owner
I tried turning magic quotes on and that dont help

Any other ideal?

Also i have used codebreakers delphi for php to open the page and get this error
syntax error, unexpected $end, Expecting T_FILE or T_START_HERDOC (586:5)

Thanks
Squills

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Fri Nov 20, 2009 10:07 pm
by BlaineSch
squills wrote:hello, I have a question and hope someone can help me out.

I got an index page that was working 100% the site owner sent me the page, when i try to access it , i get this error
Parse error: syntax error, unexpected $end in C:\site\xampp\htdocs\RTN\index.php on line 586

line 586 is the last line in index.php

I know it cant be open brackets cause same page loads for the site owner
I tried turning magic quotes on and that dont help

Any other ideal?

Also i have used codebreakers delphi for php to open the page and get this error
syntax error, unexpected $end, Expecting T_FILE or T_START_HERDOC (586:5)

Thanks
Squills
Your probably missing a closing bracket "}" can we see some code?

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Fri Nov 20, 2009 10:10 pm
by squills
Sure its a little long :( but I seam to get the same error when i load up my login.php
Let me know if you see something?

Also i have the original temples i guess you could say that will load.. I guess i could go one by one vs the temple and see what is difference and commit it out then test..
thanks
squills

Code: Select all

<?php
ob_start("ob_gzhandler");
 
require "include/bittorrent.php";
 
dbconn(true);
loggedinorreturn();
 
function mksize2($bytes)
{
if ($bytes < 1000 * 1024)
return number_format($bytes / 1024, 2);
elseif ($bytes < 1000 * 1048576)
return number_format($bytes / 1048576, 2);
elseif ($bytes < 1000 * 1073741824)
return number_format($bytes / 1073741824, 2);
else
return number_format($bytes / 1099511627776, 2);
}
 
if ($_SERVER["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.");
}
 
$registered = number_format(get_row_count("users"));
$torrents = number_format(get_row_count("torrents"));
 
$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 = number_format(get_row_count("peers", "WHERE seeder='yes'"));
$leechers = number_format(get_row_count("peers", "WHERE seeder='no'"));
$peers = number_format($seeders + $leechers);
 
$uniqpeer = number_format(get_row_count("peers", "WHERE connectable='yes'"));
if ($leechers == 0)
$ratio = 0;
else
$ratio = round($seeders / $leechers * 100);
 
$result = mysql_query("SELECT SUM(downloaded) AS totaldl, SUM(uploaded) AS totalul FROM users") or sqlerr(__FILE__, __LINE__);
 
$row = mysql_fetch_assoc($result);
$totaldownloaded = $row[totaldl];
$totaluploaded = $row[totalul];
 
if ($totaldownloaded == 0)
 $totalratio = 0;
else
 $totalratio = round($totaluploaded / $totaldownloaded * 1000)/1000;
 
$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"];
}
 
$dt = gmtime() - 180;
$dt = sqlesc(get_date_time($dt));
$res = mysql_query("SELECT id, username, class, donor, warned 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=#FF0000>" . $arr["username"] . "</font>";
   break;
case UC_ADMINISTRATOR:
   $arr["username"] = "<font color=#FF0000>" . $arr["username"] . "</font>";
   break;
case UC_MODERATOR:
   $arr["username"] = "<font color=#0000FF>" . $arr["username"] . "</font>";
   break;
case UC_UPLOADER:
   $arr["username"] = "<font color=#9900CC>" . $arr["username"] . "</font>";
   break;
case UC_VIP:
   $arr["username"] = "<font color=#FF6600>" . $arr["username"] . "</font>";
   break;
case UC_POWER_USER:
   $arr["username"] = "<font color=#009900>" . $arr["username"] . "</font>";
   break;
 
}
$donator = $arr["donor"] === "yes";
if ($donator)
 $activeusers .= "<nobr>";
$warned = $arr["warned"] === "yes";
if ($warned)
 $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_base_url}star.gif alt='" .DONOR. " {$$arr["donor"]}'></nobr>";
if ($warned)
$activeusers .= "<img src={$pic_base_url}warned.gif alt='" .WARNED. " {$$arr["warned"]}'></nobr>";
}
if (!$activeusers)
$activeusers = "There have been no active users in the last 15 minutes.";
 
function usertable($res) {
global $CURUSER;
?>
<tr><td class="colhead"><span>&nbsp;No. 1&nbsp; </span></td><td align="center" class="colhead"><img src="pic/smilies/thumbsup.gif" alt=""></td>
<?
$num = 0;
while ($a = mysql_fetch_assoc($res))
{
++$num;
$highlight = $USERID == $a["userid"] ? " bgcolor=#BBAF9B" : "";
if ($a["downloaded"])
{
$ratio = $a["uploaded"] / $a["downloaded"];
$color = get_ratio_color($ratio);
$ratio = number_format($ratio, 2);
if ($color)
$ratio = "<font color=$color>$ratio</font>";
}
else
$ratio = "Inf.";
print("<tr$highlight><td align=left$highlight><a href=userdetails.php?id=" .
$a["userid"] . "><b>" . $a["username"] . "</b></a>" .
"</td><td align=right$highlight>" . $ratio ."</td></tr>");
}}
 
 
// stat - countersink
function usertable2($res) {
global $CURUSER;
?>
<tr><td class="colhead"><span>&nbsp;countersink &nbsp; </span></td><td align="center" class="colhead"><img src="pic/smilies/thumbsdown.gif" alt=""></td>
<?
$num = 0;
while ($a = mysql_fetch_assoc($res)) {
++$num;
$highlight = $USERID == $a["userid"] ? " bgcolor=#BBAF9B" : "";
if ($a["downloaded"]) {
$ratio = $a["uploaded"] / $a["downloaded"];
$color = get_ratio_color($ratio);
$ratio = number_format($ratio, 2);
if ($color)
$ratio = "<font color=$color>$ratio</font>";
}
else
$ratio = "Inf.";
print("<tr$highlight><td align=left$highlight><a href=userdetails.php?id=" .
$a["userid"] . "><b>" . $a["username"] . "</b></a>" .
"</td><td align=right$highlight>" . $ratio ."</td></tr>");
}}
 
if (!$CURUSER) {
$ip = getip();
}
 
// stat - Full traffic mod
$resSpeed = mysql_query("SELECT seeders,leechers,id FROM torrents WHERE visible='yes' ORDER BY added DESC") or sqlerr(__FILE__, __LINE__);
while ($rowTmp = mysql_fetch_array ($resSpeed)) {
$seedersTmp = $rowTmp['seeders'];
$leechersTmp = $rowTmp['leechers'];
$torrentId = $rowTmp['id'];
}
 
$registered = number_format(get_row_count("users"));
$unverified = number_format(get_row_count("users", "WHERE status='pending'"));
$torrents = number_format(get_row_count("torrents"));
$disabled = number_format(get_row_count("users", "WHERE enabled='no'"));
$totaldownloaded = mksize($row["totaldl"]);
$totaluploaded = mksize($row["totalul"]);
$USER = number_format(get_row_count("users", "WHERE class='".UC_USER."'"));
$PU = number_format(get_row_count("users", "WHERE class='".UC_POWER_USER."'"));
 
$registered = number_format(get_row_count("users"));
$torrents = number_format(get_row_count("torrents"));
 
$null = 0;
 
 
// peer - seed - leech
$r = mysql_query("SELECT SUM(seeders) FROM torrents") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$seeders = 0 + $a[0];
 
$r = mysql_query("SELECT SUM(leechers) FROM torrents") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$leechers = 0 + $a[0];
 
 
$peersss = round($seeders + $leechers);
 
 
if ($leechers == 0)
$ratio = 0;
else
$ratio = round($seeders / $leechers * 100);
 
 
// totally download data
$result = mysql_query("SELECT SUM(downloaded) AS totaldl, SUM(uploaded) AS totalul FROM users") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
 
$totaldownloaded = $row["totaldl"];
$totaluploaded = $row["totalul"];
$totaldata = $totaldownloaded+$totaluploaded;
 
 
// warned users
$warnedu = number_format(get_row_count("users", "WHERE warned='yes'"));
 
 
// full speed data
//$result = mysql_query("SELECT SUM(downspeed) AS totalds, SUM(upspeed) AS totalus FROM xbt_files_users") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
 
$totaldownloadspeed = $row["totalds"];
$totaluploadspeed = $row["totalus"];
$totalspeed = $totaluploadspeed+$totaldownloadspeed;
 
 
// latest users mod
$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'];
 
// all the size of torrent
$qQ = mysql_query("SELECT size FROM torrents");
while($rts = mysql_fetch_assoc($qQ)) {
$alltsize = $alltsize + $rts[size];
}
 
$alltsize = mksize($alltsize);
// stat end!!!
 
 
loggedinorreturn();
/*
$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" , "WHERE enabled='yes'"));
$unverified = number_format(get_row_count("users", "WHERE status='pending'"));
$torrents = number_format(get_row_count("torrents"));
$disabled = number_format(get_row_count("users", "WHERE enabled='no'"));
$totaldownloaded = mksize($row["totaldl"]);
$totaluploaded = mksize($row["totalul"]);
$USER = number_format(get_row_count("users", "WHERE class='".UC_USER."'"));
$PU = number_format(get_row_count("users", "WHERE class='".UC_POWER_USER."'"));
$datet = "".date('Y-m-d')." 00:00:00";
$torrentstoday = number_format(get_row_count("torrents", "WHERE added>='$datet'"));
$registered = number_format(get_row_count("users"));
$torrents = number_format(get_row_count("torrents"));
$topic_res = mysql_query("SELECT SUM(topiccount) AS topics, SUM(postcount) AS posts FROM forums");
$topic_arr = mysql_fetch_assoc($topic_res);
$topics = number_format($topic_arr['topics']);
$postsc = number_format($topic_arr['posts']);
 
 
stdhead("Home");
print("<p><table align=center class=main width=900 cellspacing=0 cellpadding=5 border=0 valign=top><tr><td class=clear align=center style='padding-bottom: 20px' valign=top><center><table width=100% class=main cellpadding=5 valign=top>");
 
 
?> <?
$res = mysql_query("SELECT id,seeders, leechers, name from torrents ORDER BY seeders + leechers DESC LIMIT 10") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0) {
$rank = 0;
print("<tr><td width=80% valign=top class=embedded><p><table cellpadding=5 width=100%>");
print("<tr><td valign=top class=colhead>Rank</td><td width=100% valign=top class=colhead>Top 10 Torrents</td><td align=center class=\"colhead\">Seeders</a></td><td align=center class=\"colhead\">Lechers</td><td align=center class=\"colhead\">Snatched</td>\n");
while ($arr = mysql_fetch_assoc($res)) {
$rank = $rank + 1;
$torrname = htmlspecialchars($arr['name']);
$snc = number_format(get_row_count("snatched" , "WHERE torrentid=$arr[id]"));
print("<tr><td class=main><center>$rank</center></td><td class=main><a href=\"details.php?id=".$arr['id']."&hit=1\" alt=\"".$arr['name']."\" title=\"".$arr['name']."\">".$torrname."</td><td class=bordr align=center >".$arr['seeders']."</a></td><td class=bordr align=center >".number_format($arr['leechers'])."</td><td class=bordr align=center >".$snc."</a></td></tr>\n");
}
print("</td></tr></table></table>\n");
} else {
print("no torrents here :(");
 
}
?><br><br><?
 
$res = mysql_query("SELECT * FROM news WHERE ADDDATE(added, INTERVAL 45 DAY) > NOW() ORDER BY added DESC LIMIT 4") or sqlerr(__FILE__, __LINE__);
if (mysql_num_rows($res) > 0)
{
$counter = 1;
while($array = mysql_fetch_array($res))
{
 
 
$user = mysql_fetch_assoc(mysql_query("SELECT username FROM users WHERE id = $array[userid]")) or sqlerr();
 
 
 
if($counter == "1"){
if (get_user_class() < UC_ADMINISTRATOR){
print("<tr><td width=600 valign=top class=embedded><p><table cellpadding=5 width=100%><tr><td class=colhead><font color=#DC143C>&nbsp;&nbsp;Recent News </font></td></tr><tr><td class=dark><font color=#DC143C>&nbsp;" . gmdate("M-d-y",strtotime($array['added'])) . " - " ."<b><b>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b></b></font></td></tr>
<tr><td style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; padding-right: 10px;'><div id=\"ka".$array['id']."\" style=\"display: block;\"> ".format_comment($array["body"],0). "</div>");
}
if (get_user_class() >= UC_ADMINISTRATOR){
print("<tr><td width=600 valign=top class=embedded><p><table cellpadding=5 width=100%><tr><td class=colhead>&nbsp;&nbsp;Recent News <font class=small>[<a class=altlink href=news.php>News page</a>]</font></td></tr><tr><td class=dark><font color=#DC143C>&nbsp;" . gmdate("M-d-y",strtotime($array['added'])) . " - " ."<b><b>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b></b></font></td></tr>
<tr><td style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; padding-right: 10px;'><div id=\"ka".$array['id']."\" style=\"display: block;\"> ".format_comment($array["body"],0). "</div>");
}
}
if($counter > "1"){
if (get_user_class() < UC_ADMINISTRATOR){
print("<tr><td width=600 valign=top class=embedded><p><table cellpadding=5 width=100%><tr><td class=dark><font color=#DC143C>&nbsp;" . gmdate("M-d-y",strtotime($array['added'])) . " - " ."<b><b>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b></b></font></td></tr>
<tr><td style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; padding-right: 10px;'><div id=\"ka".$array['id']."\" style=\"display: block;\"> ".format_comment($array["body"],0). "</div><br>
<b><p align=left>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b>");
}
if (get_user_class() >= UC_ADMINISTRATOR){
print("<tr><td width=600 valign=top class=embedded><p><table cellpadding=5 width=100%><tr><td class=dark><font color=#DC143C>&nbsp;" . gmdate("M-d-y",strtotime($array['added'])) . " - " ."<b><b>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b></b></font></td></tr>
<tr><td style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; padding-right: 10px;'><div id=\"ka".$array['id']."\" style=\"display: block;\"> ".format_comment($array["body"],0). "</div>");
}
}
 
 
 
$counter = $counter + 1;
 
 
 
 
 
print("</td></tr></table></p><p>");
}
print("</table>");
}
?> <?
print("<table width=100% cellspacing=0 cellpadding=8> ");
 print("<tr><td width=40 align=center class=colhead>Status</td><td class=colhead>Topic Title</td><td width=50 align=center class=colhead>Replies</td><td width=100 align=center class=colhead>Author</td><td width=100 align=center class=colhead>Last Poster</td><td width=100 align=center class=colhead>Date</td></tr>");
 
$for = mysql_query("SELECT topics.* FROM topics INNER JOIN forums ON topics.forumid = forums.id WHERE forums.minclassread <=" . $CURUSER["class"] . " ORDER BY topics.lastpost DESC LIMIT 10");
 
while ($topicarr = mysql_fetch_assoc($for)) {
    $topicid = $topicarr["id"];
    $topic_title = $topicarr["subject"];
    $topic_userid = $topicarr["userid"];
    $topic_views = $topicarr["views"];
    $views = number_format($topic_views);
    $locked = $topicarr["locked"];
 
/// GET TOTAL NUMBER OF POSTS ///
    $res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
    $arr = mysql_fetch_row($res);
    $posts = $arr[0];
    $replies = max(0, $posts - 1);
 
/// GET USERID AND DATE OF LAST POST ///
    $res = mysql_query("SELECT * FROM posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
    $arr = mysql_fetch_assoc($res);
    $postid = 0 + $arr["id"];
    $userid = 0 + $arr["userid"];
    $added = "<nobr>" . $arr["added"] . "</nobr>";
 
/// GET NAME OF LAST POSTER ///
    $res = mysql_query("SELECT id, username FROM users WHERE id=$userid") or sqlerr(__FILE__, __LINE__);
    if (mysql_num_rows($res) == 1) {
        $arr = mysql_fetch_assoc($res);
        $username = "<a href=userdetails.php?id=$userid><b>$arr[username]</b></a>";
    } else {
        $username = "Unknown[$topic_userid]";
    }
 
/// GET NAME OF THE AUTHOR ///
    $res = mysql_query("SELECT username FROM users WHERE id=$topic_userid") or sqlerr(__FILE__, __LINE__);
    if (mysql_num_rows($res) == 1) {
        $arr = mysql_fetch_assoc($res);
        $author = "<a href=userdetails.php?id=$topic_userid><b>$arr[username]</b></a>";
    } else {
        $author = "Unknown[$topic_userid]";
    }
 
/// GETTING THE LAST INFO AND MAKE THE TABLE ROWS ///
    $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
    $a = mysql_fetch_row($r);
    $new = !$a || $postid > $a[0];
    $subject = "<a href=forums.php?action=viewtopic&topicid=$topicid&page=plast#last><b>" . encodehtml($topicarr["subject"]) . "</b></a>";
 
    $resser = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$CURUSER[id] AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
    $asser = mysql_fetch_row($resser);
    $new = !$asser || $topicarr[lastpost] > $asser[0];
    $topicpic = ($locked=='yes' ? ($new ? "s_lockednew" : "s_locked") : ($new ? "s_unlockednew" : "s_unlocked"));
 
    print("<tr><td align=center><img src=pic/$topicpic.png></td><td>$subject</td><td align=center>$replies</td><td align=center>$author</td><td align=center>$username</td><td align=center>$added</td></tr>");
}
 
print("</table>");
?> <?
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["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("<td width=200 valign=top class=embedded style='padding-left: 15px;'><table width=100% cellpadding=5>");
if (get_user_class() < UC_MODERATOR)
print("<tr><td class=colhead><font size=1>Poll</font></td></tr>");
if (get_user_class() >= UC_MODERATOR) {
print("<tr><td class=colhead><font size=1>Poll <font class=small>[<a class=altlink href=makepoll.php?returnto=main><b>New</b></a>]");
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></td></tr><tr>");
}
//print("</td></tr></table>\n");
if($pollok) {
print("<tr><td align=left><div><font color=black><b>&raquo; $question</b></font></div>");
 
$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("<br><table 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 style='margin-bottom: 5px;' width=1% class=embedded><font size=1>" . $a[1] . "<div style='background:transparent; margin-bottom: 5px; padding: 4px;'><img style='vertical-align: -10%;' src='/pic/bar_left.gif'><img src=\"{$pic_base_url}bar.gif\" height=9 width=" . ($p * 1.5) . "><img style='vertical-align: -10%;' src='/pic/bar_right.gif'> $p%</font></div></td></tr>");
++$i;
}
print("</table>\n");
$tvotes = number_format($tvotes);
if ($voted)
print("<font size=1><center>Votes: $tvotes</center></font><br><div align=center ><small><a href=polls.php>Previous Polls</a>&nbsp;</small></div></td></tr></table></form><br>");
}
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></table><br />");
}
 
} else {
echo "<td width=300 valign=top class=embedded style='padding-left: 15px;'><table width=100% cellpadding=5>";
echo "<br><table width=100% border=0 cellspacing=0 cellpadding=0>\n";
echo"<p align=center><H3>No Active Polls</h3></p>\n";
echo "</table></table>";
}
}
 
 
$total_funds1 = mysql_query("SELECT sum(cash) as total_funds FROM funds");
$arr_funds = mysql_fetch_array($total_funds1);
$funds_so_far = $arr_funds["total_funds"];
 
$totalneeded = "999"; //=== set this to your monthly wanted amount
 
$funds_difference = $totalneeded - $funds_so_far;
$Progress_so_far = $funds_so_far / $totalneeded * 100;
if($Progress_so_far >= 100)
$Progress_so_far = "100";
$Progress_so_far2 = $Progress_so_far;
 
if($Progress_so_far >= 100)
$Progress_so_far = "100";
$Progress_so_far2 = $Progress_so_far;
if ($funds_so_far <= 49){
$pic = "pic/loadbarred.gif";
$Progress_so_far2 = 20;
}
elseif ($funds_so_far <= 90)
$pic = "pic/loadbaryellow.gif";
else $pic = "pic/loadbargreen.gif";
 
?>
 
<table width=100% cellpadding=5><tr><td class=colhead><font size=1>Site Statistics</font></td></tr>
<tr>
  <td><font size=1>Online Since: 2009-08-03<br>
    User Limit: <?= $maxusers; ?><br>Registered: <?= $registered; ?>
    <br>Users Online: <?=$totalonline?>
    <br />
Torrents:
<?=$torrents?><br>New Torrents Today: <?=$torrentstoday?><br>Peers:&nbsp;<?=$peersss?><br>Total Traffic:&nbsp;<?=mksize($totaldownloaded + $totaluploaded)?></font><br><font size=1>Total Ratio:&nbsp;<?=$totalratio?><br>
Forum Topics: <?=$topics?><br>Forum Posts: <?=$postsc?></font></font></td></tr></table><br />
 
<table width=100% cellpadding=5><tr>
  <td class=colhead><font size=1>Donate</font></td></tr>
<tr>
  <td><font size=1><center>
<b>Donation Progress:</b>
<table width=100 hight=14 border=2><tr><td width=<?=$Progress_so_far2?>% hight=15 background=<?=$pic?> align=center valign=middle>
<font color=black><?=round($Progress_so_far) ?>%</font></td><td style='padding: 0px; background-image: url(pic/loadbarbg.gif); background-repeat: repeat-x'></td></tr></table>
<br><center><form action=donate.php method=post><input class=button type=submit value="Make A Donation"></form></center>
 
</center></td></tr></table><br /></tr><tr><td colspan=2 class=embedded>
 
<p><font class=small><center>None of the files shown here are hosted on the RTN server's.The tracker only manages connections, it does not have any knowledge of the contents of the files being distributed. The links are provided solely by this site's users. The Owner of this site (http://www.racethe.net) holds NO RESPONSIBILITY if these files are misused in any way and cannot be held responsible for what users post, or any other actions of the users. You may not use this site to distribute or download any material which you do not have the legal rights to.</center></font></p></td></tr></table>
 
<?
stdfoot();
?>

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Fri Nov 20, 2009 10:27 pm
by BlaineSch
Wow dude that some intense code. You should format it a bit better.

If your other pages are doing it I might check the footers/headers if they have any open ones. I could not find any just by skimming through it.

Some formatting tips: always indent between brackets, and always use brackets.. just because you can do if/while/etc without brackets does not mean you should.

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 3:48 am
by iankent
Lol yes that is some difficult to read code!! you should get nusphere, highlights bracket pairs which makes it really easy to check for missing ones, plus built in debugger to check code works instantly :)

squills - that code appears to be fine, there's no missing brackets in there! what exactly is the error you get? your title only gives part of the message. it should say which line and file the error is in.

if it happens on login.php too, do they both include bittorrent.php? If so, that's likely to be where your problem is!

hth

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 7:35 am
by squills
well in my php program i get this error
syntax error, unexpected $end, Expecting T_FILE or T_START_HERDOC (586:5)

when I try to load the page i get this error..
Parse error: syntax error, unexpected $end in "my file locations" at "last line of the code"

also update, in my php program editor i still show that error.. but now when i go to the site page i get 404 error :(
If I use the original index.php page it loads up but if i click on a link it gives me a 404 page error again..

it could be a linking problem?

if you have anymore idea's please let me know
squills

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 7:40 am
by iankent
Almost certainly a missing bracket in one of your files. Not sure why its giving you 404 error now though, it should still be giving a script error if you haven't changed anything. Check that the files are definately there on your server, and if they are, try deleting them and reuploading them from your local copy.

The problem with a missing bracket is that PHP doesn't know exactly where its occured, so it only finds the error at the very last line when it realises its run out of brackets. The only way to solve this is to go through your code and check every block using brackets, but that can take a long time.

As has already been said, if its occuring in multiple pages then either you've made the same mistake a few times, or the error occurs in a file thats being included in both. Either go through and check every set of brackets, or post the code for all files being included in the page giving errors and we can take a look.

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 10:44 am
by squills
ok got ride of the 404 page not found error.. i just deleted and added the files back to server..

I have checked and rechecked the brackets and dont see any that could be missing.. also used Codebreaker RAD which would highlight the brackets. I have open up the bittorrent.php file and get no errors on that page.

Also its just on this index page, the login page no longer gives error..
also i dont know if this matters but I am useing XAMPP to test these files.

Any other suggstion? do you see a link to any other page from this index page...or any function ?

Thanks
squills
:banghead: :banghead: :banghead:

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 10:57 am
by iankent
My best suggestion would be to start at the beginning of that file and reformat the whole thing to make it easier to read. As BlaineSch, you need to always use brackets and indent your code.

Once you've done that, the missing bracket should become more obvious (or disappear as part of the changes!)

Without reformatting it it'll be very difficult to tell

edit:
running on xampp shouldn't be an issue, its definately processing the file through PHP as it displays an error :)

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 11:08 am
by squills
What is weird is this exact code is up and running on my friends server? Is there anything that would have to be changed on the index.php to compensate for this?

could it be a different php ver ? I have no ideal how this is determined or the effect is could have?

thanks for the help
squills

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 11:13 am
by iankent
squills wrote:What is weird is this exact code is up and running on my friends server? Is there anything that would have to be changed on the index.php to compensate for this?

could it be a different php ver ? I have no ideal how this is determined or the effect is could have?

thanks for the help
squills
could be that one version accepts some syntax that the other doesn't, e.g. the use of multiple if/elseif/else statements without brackets, or the configuration could just be different, but its hard to say without finding the cause of it first!

you could try taking a copy of the code on your friends server again just to make sure nothing has changed, but if it wont work then I think you'll just have to accept reformatting it.

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 12:17 pm
by squills
When you say reformating it your talking about just the look of it right.. no code rewriting?

like

{
if....
{
doooo..
}

}

instead of


{
if....{
doooo..
}
}


If so I can do that quick.. or so i hope..only about 700 lines..
"D

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 12:23 pm
by iankent
squills wrote:When you say reformating it your talking about just the look of it right.. no code rewriting?
yes, pretty much. you just need to make sure that when you use while loops, if/then/else statements that you use brackets around them, and indent your code within each set of brackets to make it clear where each block of code starts and ends

e.g. this is reasonably neatly formatted code (i hope)

Code: Select all

 
/* This is quite a long comment
Just in case there's lots to say about something */
 
function MyFunction($param1, $param2, $param3) {
    if ($param1 == "something") {
        // Do something here
        return "boo!";
    } else {
        // Do something else here
        if($param2 == "hello") {
            // do something else here
            return "wassup?";
        }
        return "no wassup?";
    }
}
 
echo "Hello there, how are you?";
echo MyFunction("hello", "something", "blah");
 
as you can see, its much easier in that to see where each set of brackets starts and ends than it is in your existing code!

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 1:06 pm
by squills
Did that help any...as i was formatting it.. I still did not see any difference :( Waiting on friend to send me index.php file agian..

Also how did you get yours to come out with color?

Code: Select all

<?php
ob_start("ob_gzhandler");
 
require "include/bittorrent.php";
 
dbconn(true);
loggedinorreturn();
 
function mksize2($bytes)
{
  if ($bytes < 1000 * 1024)
    return number_format($bytes / 1024, 2);
  elseif ($bytes < 1000 * 1048576)
    return number_format($bytes / 1048576, 2);
  elseif ($bytes < 1000 * 1073741824)
    return number_format($bytes / 1073741824, 2);
  else
    return number_format($bytes / 1099511627776, 2);
}
 
if ($_SERVER["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.");
}
 
  $registered = number_format(get_row_count("users"));
  $torrents = number_format(get_row_count("torrents"));
 
  $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 = number_format(get_row_count("peers", "WHERE seeder='yes'"));
  $leechers = number_format(get_row_count("peers", "WHERE seeder='no'"));
  $peers = number_format($seeders + $leechers);
  $uniqpeer = number_format(get_row_count("peers", "WHERE connectable='yes'"));
  
  if ($leechers == 0)
    $ratio = 0;
  else
    $ratio = round($seeders / $leechers * 100);
 
  $result = mysql_query("SELECT SUM(downloaded) AS totaldl, SUM(uploaded) AS totalul FROM users") or sqlerr(__FILE__, __LINE__);
  $row = mysql_fetch_assoc($result);
  $totaldownloaded = $row[totaldl];
  $totaluploaded = $row[totalul];
  if ($totaldownloaded == 0)
    $totalratio = 0;
  else
    $totalratio = round($totaluploaded / $totaldownloaded * 1000)/1000;
 
  $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"];
    }
 
  $dt = gmtime() - 180;
  $dt = sqlesc(get_date_time($dt));
  $res = mysql_query("SELECT id, username, class, donor, warned 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=#FF0000>" . $arr["username"] . "</font>";
              break;
            case UC_ADMINISTRATOR:
              $arr["username"] = "<font color=#FF0000>" . $arr["username"] . "</font>";
              break;
            case UC_MODERATOR:
              $arr["username"] = "<font color=#0000FF>" . $arr["username"] . "</font>";
              break;
            case UC_UPLOADER:
              $arr["username"] = "<font color=#9900CC>" . $arr["username"] . "</font>";
              break;
            case UC_VIP:
              $arr["username"] = "<font color=#FF6600>" . $arr["username"] . "</font>";
              break;
            case UC_POWER_USER:
              $arr["username"] = "<font color=#009900>" . $arr["username"] . "</font>";
              break;
 
          }
        $donator = $arr["donor"] === "yes";
        if ($donator)
            $activeusers .= "<nobr>";
            $warned = $arr["warned"] === "yes";
        if ($warned)
            $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_base_url}star.gif alt='" .DONOR. " {$$arr["donor"]}'></nobr>";
        if ($warned)
                $activeusers .= "<img src={$pic_base_url}warned.gif alt='" .WARNED. " {$$arr["warned"]}'></nobr>";
    }
 
    if (!$activeusers)
      $activeusers = "There have been no active users in the last 15 minutes.";
 
function usertable($res) {
global $CURUSER;
 
?>
<tr><td class="colhead"><span>&nbsp;No. 1&nbsp; </span></td><td align="center" class="colhead"><img src="pic/smilies/thumbsup.gif" alt=""></td>
<?
 
$num = 0;
while ($a = mysql_fetch_assoc($res))
    {
        ++$num;
        $highlight = $USERID == $a["userid"] ? " bgcolor=#BBAF9B" : "";
            if ($a["downloaded"])
                {
                    $ratio = $a["uploaded"] / $a["downloaded"];
                    $color = get_ratio_color($ratio);
                    $ratio = number_format($ratio, 2);
                        if ($color)
                            $ratio = "<font color=$color>$ratio</font>";
                }
                        else
                            $ratio = "Inf.";
                            print("<tr$highlight><td align=left$highlight><a href=userdetails.php?id=" .
                            $a["userid"] . "><b>" . $a["username"] . "</b></a>" .
                            "</td><td align=right$highlight>" . $ratio ."</td></tr>");
    }   
}
 
 
// stat - countersink
function usertable2($res) {
global $CURUSER;
 
?>
<tr><td class="colhead"><span>&nbsp;countersink &nbsp; </span></td><td align="center" class="colhead"><img src="pic/smilies/thumbsdown.gif" alt=""></td>
<?
 
$num = 0;
 
while ($a = mysql_fetch_assoc($res)) {
    ++$num;
    $highlight = $USERID == $a["userid"] ? " bgcolor=#BBAF9B" : "";
        if ($a["downloaded"]) {
            $ratio = $a["uploaded"] / $a["downloaded"];
            $color = get_ratio_color($ratio);
            $ratio = number_format($ratio, 2);
                if ($color)
                    $ratio = "<font color=$color>$ratio</font>";
        }
        else
            $ratio = "Inf.";
            print("<tr$highlight><td align=left$highlight><a href=userdetails.php?id=" .
            $a["userid"] . "><b>" . $a["username"] . "</b></a>" .
            "</td><td align=right$highlight>" . $ratio ."</td></tr>");
}
}   
 
if (!$CURUSER) {
$ip = getip();
}
 
// stat - Full traffic mod
$resSpeed = mysql_query("SELECT seeders,leechers,id FROM torrents WHERE visible='yes' ORDER BY added DESC") or sqlerr(__FILE__, __LINE__);
while ($rowTmp = mysql_fetch_array ($resSpeed)) {
    $seedersTmp = $rowTmp['seeders'];
    $leechersTmp = $rowTmp['leechers'];
    $torrentId = $rowTmp['id'];
}
 
$registered = number_format(get_row_count("users"));
$unverified = number_format(get_row_count("users", "WHERE status='pending'"));
$torrents = number_format(get_row_count("torrents"));
$disabled = number_format(get_row_count("users", "WHERE enabled='no'"));
$totaldownloaded = mksize($row["totaldl"]);
$totaluploaded = mksize($row["totalul"]);
$USER = number_format(get_row_count("users", "WHERE class='".UC_USER."'"));
$PU = number_format(get_row_count("users", "WHERE class='".UC_POWER_USER."'"));
$registered = number_format(get_row_count("users"));
$torrents = number_format(get_row_count("torrents"));
$null = 0;
 
 
// peer - seed - leech
$r = mysql_query("SELECT SUM(seeders) FROM torrents") or sqlerr(__FILE__, __LINE__);
    $a = mysql_fetch_row($r);
    $seeders = 0 + $a[0];
 
$r = mysql_query("SELECT SUM(leechers) FROM torrents") or sqlerr(__FILE__, __LINE__);
    $a = mysql_fetch_row($r);
    $leechers = 0 + $a[0];
 
 
$peersss = round($seeders + $leechers);
 
 
if ($leechers == 0)
    $ratio = 0;
else
    $ratio = round($seeders / $leechers * 100);
 
 
// totally download data
$result = mysql_query("SELECT SUM(downloaded) AS totaldl, SUM(uploaded) AS totalul FROM users") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
 
$totaldownloaded = $row["totaldl"];
$totaluploaded = $row["totalul"];
$totaldata = $totaldownloaded+$totaluploaded;
 
 
// warned users
$warnedu = number_format(get_row_count("users", "WHERE warned='yes'"));
 
 
// full speed data
//$result = mysql_query("SELECT SUM(downspeed) AS totalds, SUM(upspeed) AS totalus FROM xbt_files_users") or sqlerr(__FILE__, __LINE__);
$row = mysql_fetch_assoc($result);
 
$totaldownloadspeed = $row["totalds"];
$totaluploadspeed = $row["totalus"];
$totalspeed = $totaluploadspeed+$totaldownloadspeed;
 
 
// latest users mod
$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'];
 
// all the size of torrent
$qQ = mysql_query("SELECT size FROM torrents");
while($rts = mysql_fetch_assoc($qQ)) {
    $alltsize = $alltsize + $rts[size];
}
 
$alltsize = mksize($alltsize);
// stat end!!!
 
 
loggedinorreturn();
/*
$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" , "WHERE enabled='yes'"));
$unverified = number_format(get_row_count("users", "WHERE status='pending'"));
$torrents = number_format(get_row_count("torrents"));
$disabled = number_format(get_row_count("users", "WHERE enabled='no'"));
$totaldownloaded = mksize($row["totaldl"]);
$totaluploaded = mksize($row["totalul"]);
$USER = number_format(get_row_count("users", "WHERE class='".UC_USER."'"));
$PU = number_format(get_row_count("users", "WHERE class='".UC_POWER_USER."'"));
$datet = "".date('Y-m-d')." 00:00:00";
$torrentstoday = number_format(get_row_count("torrents", "WHERE added>='$datet'"));
$registered = number_format(get_row_count("users"));
$torrents = number_format(get_row_count("torrents"));
$topic_res = mysql_query("SELECT SUM(topiccount) AS topics, SUM(postcount) AS posts FROM forums");
$topic_arr = mysql_fetch_assoc($topic_res);
$topics = number_format($topic_arr['topics']);
$postsc = number_format($topic_arr['posts']);
 
 
stdhead("Home");
print("<p><table align=center class=main width=900 cellspacing=0 cellpadding=5 border=0 valign=top><tr><td class=clear align=center style='padding-bottom: 20px' valign=top><center><table width=100% class=main cellpadding=5 valign=top>");
 
 
?> <?
$res = mysql_query("SELECT id,seeders, leechers, name from torrents ORDER BY seeders + leechers DESC LIMIT 10") or sqlerr(__FILE__, __LINE__);
    if (mysql_num_rows($res) > 0) {
        $rank = 0;
        print("<tr><td width=80% valign=top class=embedded><p><table cellpadding=5 width=100%>");
        print("<tr><td valign=top class=colhead>Rank</td><td width=100% valign=top class=colhead>Top 10 Torrents</td><td align=center class=\"colhead\">Seeders</a></td><td align=center class=\"colhead\">Lechers</td><td align=center class=\"colhead\">Snatched</td>\n");
            while ($arr = mysql_fetch_assoc($res)) {
                $rank = $rank + 1;
                $torrname = htmlspecialchars($arr['name']);
                $snc = number_format(get_row_count("snatched" , "WHERE torrentid=$arr[id]"));
                print("<tr><td class=main><center>$rank</center></td><td class=main><a href=\"details.php?id=".$arr['id']."&hit=1\" alt=\"".$arr['name']."\" title=\"".$arr['name']."\">".$torrname."</td><td class=bordr align=center >".$arr['seeders']."</a></td><td class=bordr align=center >".number_format($arr['leechers'])."</td><td class=bordr align=center >".$snc."</a></td></tr>\n");
            }
        print("</td></tr></table></table>\n");
    } else {
        print("no torrents here :(");
            }
            
?><br><br><?
 
$res = mysql_query("SELECT * FROM news WHERE ADDDATE(added, INTERVAL 45 DAY) > NOW() ORDER BY added DESC LIMIT 4") or sqlerr(__FILE__, __LINE__);
    if (mysql_num_rows($res) > 0)
        {
            $counter = 1;
                while($array = mysql_fetch_array($res))
                    {
                        $user = mysql_fetch_assoc(mysql_query("SELECT username FROM users WHERE id = $array[userid]")) or sqlerr();
                            if($counter == "1"){
                                if (get_user_class() < UC_ADMINISTRATOR){
                                    print("<tr><td width=600 valign=top class=embedded><p><table cellpadding=5 width=100%><tr><td class=colhead><font color=#DC143C>&nbsp;&nbsp;Recent News </font></td></tr><tr><td class=dark><font color=#DC143C>&nbsp;" . gmdate("M-d-y",strtotime($array['added'])) . " - " ."<b><b>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b></b></font></td></tr>
                                    <tr><td style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; padding-right: 10px;'><div id=\"ka".$array['id']."\" style=\"display: block;\"> ".format_comment($array["body"],0). "</div>");
                                }
                                if (get_user_class() >= UC_ADMINISTRATOR){
                                    print("<tr><td width=600 valign=top class=embedded><p><table cellpadding=5 width=100%><tr><td class=colhead>&nbsp;&nbsp;Recent News <font class=small>[<a class=altlink href=news.php>News page</a>]</font></td></tr><tr><td class=dark><font color=#DC143C>&nbsp;" . gmdate("M-d-y",strtotime($array['added'])) . " - " ."<b><b>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b></b></font></td></tr>
                                    <tr><td style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; padding-right: 10px;'><div id=\"ka".$array['id']."\" style=\"display: block;\"> ".format_comment($array["body"],0). "</div>");
                                }
                            }
                            if($counter > "1"){
                                if (get_user_class() < UC_ADMINISTRATOR){
                                    print("<tr><td width=600 valign=top class=embedded><p><table cellpadding=5 width=100%><tr><td class=dark><font color=#DC143C>&nbsp;" . gmdate("M-d-y",strtotime($array['added'])) . " - " ."<b><b>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b></b></font></td></tr>
                                    <tr><td style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; padding-right: 10px;'><div id=\"ka".$array['id']."\" style=\"display: block;\"> ".format_comment($array["body"],0). "</div><br>
                                    <b><p align=left>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b>");
                                }
                                if (get_user_class() >= UC_ADMINISTRATOR){
                                print("<tr><td width=600 valign=top class=embedded><p><table cellpadding=5 width=100%><tr><td class=dark><font color=#DC143C>&nbsp;" . gmdate("M-d-y",strtotime($array['added'])) . " - " ."<b><b>:: <b><a href=userdetails.php?id=" . $array['userid'] . ">$user[username]</a></b></b></font></td></tr>
                                <tr><td style='padding-left: 10px; padding-bottom: 10px; padding-top: 10px; padding-right: 10px;'><div id=\"ka".$array['id']."\" style=\"display: block;\"> ".format_comment($array["body"],0). "</div>");
                                }
                            }
                        $counter = $counter + 1;
                        print("</td></tr></table></p><p>");
                    }
                print("</table>");
        }   
        
?> <?
 
print("<table width=100% cellspacing=0 cellpadding=8> ");
print("<tr><td width=40 align=center class=colhead>Status</td><td class=colhead>Topic Title</td><td width=50 align=center class=colhead>Replies</td><td width=100 align=center class=colhead>Author</td><td width=100 align=center class=colhead>Last Poster</td><td width=100 align=center class=colhead>Date</td></tr>");
 
$for = mysql_query("SELECT topics.* FROM topics INNER JOIN forums ON topics.forumid = forums.id WHERE forums.minclassread <=" . $CURUSER["class"] . " ORDER BY topics.lastpost DESC LIMIT 10");
    while ($topicarr = mysql_fetch_assoc($for)) {
        $topicid = $topicarr["id"];
        $topic_title = $topicarr["subject"];
        $topic_userid = $topicarr["userid"];
        $topic_views = $topicarr["views"];
        $views = number_format($topic_views);
        $locked = $topicarr["locked"];
 
/// GET TOTAL NUMBER OF POSTS ///
        $res = mysql_query("SELECT COUNT(*) FROM posts WHERE topicid=$topicid") or sqlerr(__FILE__, __LINE__);
        $arr = mysql_fetch_row($res);
        $posts = $arr[0];
        $replies = max(0, $posts - 1);
 
/// GET USERID AND DATE OF LAST POST ///
        $res = mysql_query("SELECT * FROM posts WHERE topicid=$topicid ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
        $arr = mysql_fetch_assoc($res);
        $postid = 0 + $arr["id"];
        $userid = 0 + $arr["userid"];
        $added = "<nobr>" . $arr["added"] . "</nobr>";
 
/// GET NAME OF LAST POSTER ///
        $res = mysql_query("SELECT id, username FROM users WHERE id=$userid") or sqlerr(__FILE__, __LINE__);
            if (mysql_num_rows($res) == 1) {
                $arr = mysql_fetch_assoc($res);
                $username = "<a href=userdetails.php?id=$userid><b>$arr[username]</b></a>";
            } else {
                $username = "Unknown[$topic_userid]";
            }
 
/// GET NAME OF THE AUTHOR ///
        $res = mysql_query("SELECT username FROM users WHERE id=$topic_userid") or sqlerr(__FILE__, __LINE__);
            if (mysql_num_rows($res) == 1) {
                $arr = mysql_fetch_assoc($res);
                $author = "<a href=userdetails.php?id=$topic_userid><b>$arr[username]</b></a>";
            } else {
                $author = "Unknown[$topic_userid]";
            }
 
/// GETTING THE LAST INFO AND MAKE THE TABLE ROWS ///
        $r = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$userid AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
        $a = mysql_fetch_row($r);
        $new = !$a || $postid > $a[0];
        $subject = "<a href=forums.php?action=viewtopic&topicid=$topicid&page=plast#last><b>" . encodehtml($topicarr["subject"]) . "</b></a>";
 
        $resser = mysql_query("SELECT lastpostread FROM readposts WHERE userid=$CURUSER[id] AND topicid=$topicid") or sqlerr(__FILE__, __LINE__);
        $asser = mysql_fetch_row($resser);
        $new = !$asser || $topicarr[lastpost] > $asser[0];
        $topicpic = ($locked=='yes' ? ($new ? "s_lockednew" : "s_locked") : ($new ? "s_unlockednew" : "s_unlocked"));
 
        print("<tr><td align=center><img src=pic/$topicpic.png></td><td>$subject</td><td align=center>$replies</td><td align=center>$author</td><td align=center>$username</td><td align=center>$added</td></tr>");
    }
print("</table>");
 
?> <?
 
    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["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("<td width=200 valign=top class=embedded style='padding-left: 15px;'><table width=100% cellpadding=5>");
            if (get_user_class() < UC_MODERATOR)
                print("<tr><td class=colhead><font size=1>Poll</font></td></tr>");
            if (get_user_class() >= UC_MODERATOR) {
                print("<tr><td class=colhead><font size=1>Poll <font class=small>[<a class=altlink href=makepoll.php?returnto=main><b>New</b></a>]");
                    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></td></tr><tr>");
            }
//print("</td></tr></table>\n");
    if($pollok) {
        print("<tr><td align=left><div><font color=black><b>&raquo; $question</b></font></div>");
        $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("<br><table 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 style='margin-bottom: 5px;' width=1% class=embedded><font size=1>" . $a[1] . "<div style='background:transparent; margin-bottom: 5px; padding: 4px;'><img style='vertical-align: -10%;' src='/pic/bar_left.gif'><img src=\"{$pic_base_url}bar.gif\" height=9 width=" . ($p * 1.5) . "><img style='vertical-align: -10%;' src='/pic/bar_right.gif'> $p%</font></div></td></tr>");
                                ++$i;
                            }
                        print("</table>\n");
                        $tvotes = number_format($tvotes);
                        if ($voted)
                            print("<font size=1><center>Votes: $tvotes</center></font><br><div align=center ><small><a href=polls.php>Previous Polls</a>&nbsp;</small></div></td></tr></table></form><br>");
            }
        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></table><br />");
        }
 
    } else {
        echo "<td width=300 valign=top class=embedded style='padding-left: 15px;'><table width=100% cellpadding=5>";
        echo "<br><table width=100% border=0 cellspacing=0 cellpadding=0>\n";
        echo"<p align=center><H3>No Active Polls</h3></p>\n";
        echo "</table></table>";
    }
    }
 
 
    $total_funds1 = mysql_query("SELECT sum(cash) as total_funds FROM funds");
    $arr_funds = mysql_fetch_array($total_funds1);
    $funds_so_far = $arr_funds["total_funds"];
    $totalneeded = "999"; //=== set this to your monthly wanted amount
    $funds_difference = $totalneeded - $funds_so_far;
    $Progress_so_far = $funds_so_far / $totalneeded * 100;
    
    if($Progress_so_far >= 100)
        $Progress_so_far = "100";
    $Progress_so_far2 = $Progress_so_far;
 
    if($Progress_so_far >= 100)
        $Progress_so_far = "100";
    $Progress_so_far2 = $Progress_so_far;
    
    if ($funds_so_far <= 49){
        $pic = "pic/loadbarred.gif";
        $Progress_so_far2 = 20;
    }
    elseif ($funds_so_far <= 90)
        $pic = "pic/loadbaryellow.gif";
    else $pic = "pic/loadbargreen.gif";
 
?>
 
<table width=100% cellpadding=5><tr><td class=colhead><font size=1>Site Statistics</font></td></tr>
<tr>
  <td><font size=1>Online Since: 2009-08-03<br>
    User Limit: <?= $maxusers; ?><br>Registered: <?= $registered; ?>
    <br>Users Online: <?=$totalonline?>
    <br />
Torrents:
<?=$torrents?><br>New Torrents Today: <?=$torrentstoday?><br>Peers:&nbsp;<?=$peersss?><br>Total Traffic:&nbsp;<?=mksize($totaldownloaded + $totaluploaded)?></font><br><font size=1>Total Ratio:&nbsp;<?=$totalratio?><br>
Forum Topics: <?=$topics?><br>Forum Posts: <?=$postsc?></font></font></td></tr></table><br />
 
<table width=100% cellpadding=5><tr>
  <td class=colhead><font size=1>Donate</font></td></tr>
<tr>
  <td><font size=1><center>
<b>Donation Progress:</b>
<table width=100 hight=14 border=2><tr><td width=<?=$Progress_so_far2?>% hight=15 background=<?=$pic?> align=center valign=middle>
<font color=black><?=round($Progress_so_far) ?>%</font></td><td style='padding: 0px; background-image: url(pic/loadbarbg.gif); background-repeat: repeat-x'></td></tr></table>
<br><center><form action=donate.php method=post><input class=button type=submit value="Make A Donation"></form></center>
 
</center></td></tr></table><br /></tr><tr><td colspan=2 class=embedded>
 
<p><font class=small><center>None of the files shown here are hosted on the RTN server's.The tracker only manages connections, it does not have any knowledge of the contents of the files being distributed. The links are provided solely by this site's users. The Owner of this site (http://www.racethe.net) holds NO RESPONSIBILITY if these files are misused in any way and cannot be held responsible for what users post, or any other actions of the users. You may not use this site to distribute or download any material which you do not have the legal rights to.</center></font></p></td></tr></table>
 
 
<?
stdfoot();
?>
 
 

Re: PHP Error (Parse error: syntax error, unexpected $end in )

Posted: Sat Nov 21, 2009 1:38 pm
by squills
good news, i went threw doing some commiting out parts and have nerrowed it down to this section... Once i commit this part out the code gives no errors... Can you see anything wrong with this part?
WARNING ... NOT AS LONG lol

Code: Select all

/*
function usertable($res) {
global $CURUSER;
 
?>
<tr><td class="colhead"><span>&nbsp;No. 1&nbsp; </span></td><td align="center" class="colhead"><img src="pic/smilies/thumbsup.gif" alt=""></td>
<?
 
$num = 0;
while ($a = mysql_fetch_assoc($res))
    {
        ++$num;
        $highlight = $USERID == $a["userid"] ? " bgcolor=#BBAF9B" : "";
            if ($a["downloaded"])
                {
                    $ratio = $a["uploaded"] / $a["downloaded"];
                    $color = get_ratio_color($ratio);
                    $ratio = number_format($ratio, 2);
                        if ($color)
                            $ratio = "<font color=$color>$ratio</font>";
                }
                        else
                            $ratio = "Inf.";
                            print("<tr$highlight><td align=left$highlight><a href=userdetails.php?id=" .
                            $a["userid"] . "><b>" . $a["username"] . "</b></a>" .
                            "</td><td align=right$highlight>" . $ratio ."</td></tr>");
    }
}
 
  
// stat - countersink
function usertable2($res) {
*/global $CURUSER;
 

Also if i run it with that part edited out it loads the page but the bittorrent.php file is messed up some how.. and has a ton of code on the screen.. here is what i think the problem is.. its a small clip of the code.... but the part is blue is ok ..but when it turns yellow all of this is printed out onto the site.. So I assume it has something to do with the => sign..
take a look

Code: Select all

[color=#40BFFF]<?
 
function cleanquotes(&$in){
    if(is_array($in)) return array_walk($in,'cleanquotes');
    return $in=stripslashes($in);
}
if(get_magic_quotes_gpc()){
    array_walk($_GET,'cleanquotes');
    array_walk($_POST,'cleanquotes');
    array_walk($_COOKIE,'cleanquotes');
    array_walk($_REQUEST,'cleanquotes');
}
 
function strip_magic_quotes($arr)
{
foreach ($arr as $k[/color][color=#FF0000] =>[/color] $v)  //From the red part on all text is shown up on the page..
{
if (is_array($v))
{ $arr[$k] = strip_magic_quotes($v); }
else
{ $arr[$k] = stripslashes($v); }
}
 
return $arr;
}
 
function local_user()
{
  return $_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"];
}