Insane loading time
Posted: Sat Jul 16, 2005 9:46 pm
Okay, I know I've posted about my forums in the past.
And now, the pages seem to load quickly.......... except for one.
It's the showforum.php page
Someone tell me if anything sticks out like a sore thumb.. that would slow my page loading time wayyyyyy down. I'm looking at like 10 seconds every time I load this page. Maybe it's because I escape to HTML too much?
Live example: http://www.showmypro.com/showforum.php?forumid=1ast.
And now, the pages seem to load quickly.......... except for one.
It's the showforum.php page
Someone tell me if anything sticks out like a sore thumb.. that would slow my page loading time wayyyyyy down. I'm looking at like 10 seconds every time I load this page. Maybe it's because I escape to HTML too much?
And now, the pages seem to load quickly.......... except for one.
It's the showforum.php page
Someone tell me if anything sticks out like a sore thumb.. that would slow my page loading time wayyyyyy down. I'm looking at like 10 seconds every time I load this page. Maybe it's because I escape to HTML too much?
Code: Select all
<?
$description = "Browse forum topics";
require 'header.php';
// Update doing section
if(isset($_COOKIE['username']))
{
mysql_query("UPDATE users SET doing = 'Browsing Forums' WHERE username = '$theperson'");
}
// Administration
// Lock thread
if($_POST['action'] == "lockthread")
{
$threadtolock = mysql_real_escape_string(strip_tags($_POST['threadtolock']));
$adminarray = array("scrotaye", "artbalaoro", "potato", "magicflymonkey");
if(in_array($theperson, $adminarray))
{
mysql_query("UPDATE forumtopicmain SET threadstatus = 'locked' WHERE id = '$threadtolock'");
mysql_query("UPDATE forumentries SET threadstatus = 'locked' WHERE topicid = '$threadtolock'");
echo "<p align=center><B>Thread has been locked.</B></p>";
}
}
// Move topic
if($_POST['action'] == "movetopic")
{
$topictomove2 = mysql_real_escape_string(strip_tags($_POST['topictomove2']));
$topictomove = mysql_real_escape_string(strip_tags($_POST['topictomove']));
$adminarray = array("scrotaye", "artbalaoro", "potato", "magicflymonkey");
if(in_array($_COOKIE['username'], $adminarray))
{
mysql_query("UPDATE forumtopicmain SET forumid = '$topictomove' WHERE id = '$topictomove2'");
$movedrepliesquery = mysql_query("SELECT id FROM forumentries WHERE topicid = '$topictomove2'");
while($movedrepliesarray = mysql_fetch_array($movedrepliesquery))
{
mysql_query("UPDATE forumentries SET forumid = '$topictomove' WHERE topicid = '$topictomove2'");
}
echo "<p align=center><B>Topic has been moved.</B></p>";
}
}
// End administration
// Purify $_GET information
$forumid = mysql_real_escape_string(strip_tags($forumid));
// Select the forum name
$forumarray = mysql_fetch_assoc(mysql_query("SELECT topicname FROM forumtopics WHERE id = '$forumid'"));
// Begin pagination for main page
$sql_text = ("SELECT id, topicname, threadstatus, author FROM forumtopicmain WHERE forumid = '$forumid' AND type != 'sticky' ORDER BY lastreply DESC");
if(!$page)
{
$page = 1;
}
$prev_page = $page - 1;
$next_page = $page + 1;
$page_start = (25 * $page) - 25;
$query = mysql_query($sql_text);
$num_rows = mysql_num_rows($query);
if($num_rows <= 25)
{
$num_pages = 1;
} else if
(($num_rows % 25) == 0)
{
$num_pages = ($num_rows / 25);
} else
{
$num_pages = ($num_rows / 25) + 1;
}
$num_pages = (int) $num_pages;
if(($page > $num_pages) || ($page < 0))
{
die("You have specified an invalid page number");
}
$sql_text = $sql_text . " LIMIT $page_start, 25";
$query = mysql_query($sql_text); ?>
<a href="forums.php">Show My Pro Forums</a> > <a href="showforum.php?forumid=<? echo $forumid; ?>"><? echo $forumarray['topicname']; ?></a> > <a href="newforumtopic.php?forumid=<? echo $forumid; ?>"><img src="images/newtopic.gif" alt="New Topic" border="0"></a>
<table width="100%" cellspacing="0" cellpadding="3" style="border: solid 1px #000000">
<tr>
<td style="border: solid 1px #000000" align="center" colspan="5" bgcolor="#CCCCCC"><B><font size="2">A Space For Your Thoughts</font></B>
</td>
</tr>
<tr>
<td style="border: solid 1px #000000" align="center" width="5%" bgcolor="#CCCCCC">
</td>
<td style="border: solid 1px #000000" align="center" width="50%" bgcolor="#CCCCCC"><B><font size="2">Topic</font></B>
</td>
<td style="border: solid 1px #000000" align="center" width="10%" bgcolor="#CCCCCC"><B><font size="2">Replies</font></B>
</td>
<td style="border: solid 1px #000000" align="center" width="15%" bgcolor="#CCCCCC"><B><font size="2">Author</font></B>
</td>
<td style="border: solid 1px #000000" align="center" width="20%" bgcolor="#CCCCCC"><B><font size="2">Last Post</font></B>
</td>
</tr>
<?
// Show stickies first
if($page == "1")
{
$stickyquery = mysql_query("SELECT id, topicname, threadstatus, author FROM forumtopicmain WHERE forumid = '$forumid' AND type = 'sticky' ORDER BY lastreply DESC");
while($stickyarray = mysql_fetch_assoc($stickyquery))
{
$stickyquery2 = mysql_query("SELECT id FROM forumentries WHERE topicid = '".$stickyarray['id']."'");
$stickyreplies = mysql_num_rows($stickyquery2) - 1;
$stickylastpostarray = mysql_fetch_assoc(mysql_query("SELECT time, author FROM forumentries WHERE topicid = '".$stickyarray['id']."' ORDER BY time2 DESC LIMIT 1")); ?>
<tr>
<td style="border: solid 1px #000000" width="5%" align="center"><? if($stickyarray['threadstatus'] == "open"){ ?><img src="images/thread_open.gif"><? } ELSE { ?><img src="images/thread_locked.gif"> <? } ?>
</td>
<td style="border: solid 1px #000000" width="50%" align="left"><a href="showthread.php?threadid=<? echo $stickyarray['id']; ?>&page=1"><? echo "STICKY: ".stripslashes($stickyarray['topicname']).""; ?></a>
</td>
<td style="border: solid 1px #000000" width="10%" align="center"><B><font size="2"><? echo $stickyreplies; ?></B>
</td>
<td style="border: solid 1px #000000" width="15%" align="center"><a href="showme.php?u=<? echo $stickyarray['author']; ?>"><? echo $stickyarray['author']; ?></a>
</td>
<td style="border: solid 1px #000000" width="20%" align="left"><font size="2"><? echo $stickylastpostarray['time']; ?></font><BR><font size="2">by</font> <a href="showme.php?u=<? echo $stickylastpostarray['author']; ?>"><? echo $stickylastpostarray['author']; ?></a>
</td>
</tr>
<?
}
}
// Show the non-stickied topics (most of them)
while($array = mysql_fetch_assoc($query))
{
$query2 = mysql_query("SELECT id FROM forumentries WHERE topicid = '".$array['id']."'");
$replies = mysql_num_rows($query2) - 1;
$lastpostarray = mysql_fetch_assoc(mysql_query("SELECT time, author FROM forumentries WHERE topicid = '".$array['id']."' ORDER BY time2 DESC LIMIT 1"));
// Show the number of pages for each individual topic
$sql_text2 = ("SELECT id FROM forumentries WHERE topicid = '".$array['id']."'");
$query2 = mysql_query($sql_text2);
$page_start2 = (25 * $page2) - 25;
$num_rows2 = mysql_num_rows($query2);
if ($num_rows2 <= 25) { $num_pages2 = 1; } else if
(($num_rows2 % 25) == 0) { $num_pages2 = ($num_rows2 / 25); } else {
$num_pages2 = ($num_rows2 / 25) + 1; }
$num_pages2 = (int) $num_pages2;
$sql_text2 = $sql_text2 . " LIMIT $page_start2, 25"; ?>
<tr>
<td style="border: solid 1px #000000" width="5%" align="center"><? if($array['threadstatus'] == "open"){ ?><img src="images/thread_open.gif"><? } ELSE { ?><img src="images/thread_locked.gif"> <? } ?>
</td>
<td style="border: solid 1px #000000" width="50%" align="left"><a href="showthread.php?threadid=<? echo $array['id']; ?>&page=1"><? echo stripslashes($array['topicname']); ?></a><? if($num_pages2 > 1){ echo "<BR><font size=1>Page: </font>"; for ($i = 1; $i <= $num_pages2; $i++) {echo "<a href=\"showthread.php?threadid=".$array['id']."&page=$i\"><font size=1>$i</font></a> "; } } ?>
</td>
<td style="border: solid 1px #000000" width="10%" align="center"><B><font size="2"><? echo $replies; ?></B>
</td>
<td style="border: solid 1px #000000" width="15%" align="center"><a href="showme.php?u=<? echo $array['author']; ?>"><? echo $array['author']; ?></a>
</td>
<td style="border: solid 1px #000000" width="20%" align="left"><font size="2"><? echo $lastpostarray['time']; ?></font><BR><font size="2">by</font> <a href="showme.php?u=<? echo $lastpostarray['author']; ?>"><? echo $lastpostarray['author']; ?></a>
</td>
</tr><?
} ?>
</table>
<a href="forums.php">Show My Pro Forums</a> > <a href="showforum.php?forumid=<? echo $forumid; ?>"><? echo $forumarray['topicname']; ?></a> > <a href="newforumtopic.php?forumid=<? echo $forumid; ?>"><img src="images/newtopic.gif" alt="New Topic" border="0"></a>
<p class="main"><center>
<?
// Show next 10 pages, previous 10 pages, etc.. for the number of pages in the forum
$limit = $page+10;
if($num_pages >= $limit)
{
if($page != 1)
{
$previouspage = $page - 1;
$previousstart = $previouspage - 9;
if($page == 2)
{
echo "<small><<</small> <a href=\"$PHP_SELF?forumid=$forumid&page=1\">Page 1</a> ";
} ELSE
{
if($previousstart <= 0)
{
echo"<small><<</small> <a href=\"$PHP_SELF?forumid=$forumid&page=1\">Pages 1 - $previouspage</a> ";
} ELSE
{
echo "<small><<</small> <a href=\"$PHP_SELF?forumid=$forumid&page=$previousstart\">Pages $previousstart - $previouspage</a> ";
}
}
}
for($i = $page; $i<$limit; $i++)
{
echo " <a href=\"$PHP_SELF?forumid=$forumid&page=$i\">$i</a> ";
}
$limit2 = $i+9;
if($num_pages <= $limit2)
{
echo " <a href=\"$PHP_SELEF?forumid=$forumid&page=$i\">Pages $i - $num_pages</a> <small>>></small>";
} ELSE
{
echo " <a href=\"$PHP_SELEF?forumid=$forumid&page=$i\">Pages $i - $limit2</a> <small>>></small>";
}
} ELSE
{
for($i = $page; $i<=$num_pages; $i++)
{
echo " <a href=\"$PHP_SELF?forumid=$forumid&page=$i\">$i</a> ";
}
}
?>
</center></p>
<p align="left" class="main"><img src="images/to_e.gif"> Thread Open
<img src="images/tl_e.gif"> Thread Locked</font></p>
<?
// Start administration panel
$adminarray = array("scrotaye", "artbalaoro", "potato", "magicflymonkey");
if(in_array($_COOKIE['username'], $adminarray))
{
?>
<table width="60%" align="center" style="border: solid 1px #000000" cellspacing="0" cellpading="3">
<tr>
<td style="border: solid 1px #000000" align="center" bgcolor="#CCCCCC"><B><font size="2">Administration Panel</font></B>
</td>
</tr>
<tr>
<td style="border: solid 1px #000000" align="center">
<form action="showforum.php?forumid=<? echo $forumid; ?>" method="post">
<input type="hidden" name="action" value="lockthread">
<p align="center"><B><font size="2">Lock Thread</font></B><BR>
<select name="threadtolock">
<option selected>Select</option><?
$threadtolockquery = mysql_query("SELECT id, topicname FROM forumtopicmain WHERE forumid = '$forumid' ORDER BY lastreply DESC LIMIT 25");
while($threadtolockarray = mysql_fetch_assoc($threadtolockquery))
{ ?>
<option value="<? echo $threadtolockarray['id']; ?>"><? echo stripslashes($threadtolockarray['topicname']); ?></option><?
} ?>
</select>
<BR>
<input type="submit" value="Lock">
</form>
<form action="showforum.php?forumid=<? echo $forumid; ?>" method="post">
<input type="hidden" name="action" value="movetopic">
<p align="center"><B><font size="2">Move Topic</font></B></p>
<B><font size="2">Move Topic Named</font></B>
<select name="topictomove2">
<option selected>Select</option><?
$threadtomovequery = mysql_query("SELECT id, topicname FROM forumtopicmain WHERE forumid = '$forumid' ORDER BY lastreply DESC LIMIT 25");
while($threadtomovearray = mysql_fetch_assoc($threadtomovequery)){
?><option value="<? echo $threadtomovearray['id']; ?>"><? echo stripslashes($threadtomovearray['topicname']); ?></option>
<?
} ?>
</select><BR><B><font size="2">To Forum</font></B><BR>
<select name="topictomove">
<option selected>Select</option><?
$topicsmovequery = mysql_query("SELECT topicname, id FROM forumtopics ORDER BY rank");
while($topicsmovearray = mysql_fetch_assoc($topicsmovequery)){ ?>
<option value="<? echo $topicsmovearray['id']; ?>"><? echo $topicsmovearray['topicname']; ?></option><? } ?>
</select><BR>
<input type="submit" value="Move">
</form>
</td>
</tr>
</table><?
}
require 'footer.php'; ?>And now, the pages seem to load quickly.......... except for one.
It's the showforum.php page
Someone tell me if anything sticks out like a sore thumb.. that would slow my page loading time wayyyyyy down. I'm looking at like 10 seconds every time I load this page. Maybe it's because I escape to HTML too much?
Code: Select all
<?
$description = "e;Browse forum topics"e;;
require 'header.php';
// Update doing section
if(isset($_COOKIEї'username']))
{
mysql_query("e;UPDATE users SET doing = 'Browsing Forums' WHERE username = '$theperson'"e;);
}
// Administration
// Lock thread
if($_POSTї'action'] == "e;lockthread"e;)
{
$threadtolock = mysql_real_escape_string(strip_tags($_POSTї'threadtolock']));
$adminarray = array("e;scrotaye"e;, "e;artbalaoro"e;, "e;potato"e;, "e;magicflymonkey"e;);
if(in_array($theperson, $adminarray))
{
mysql_query("e;UPDATE forumtopicmain SET threadstatus = 'locked' WHERE id = '$threadtolock'"e;);
mysql_query("e;UPDATE forumentries SET threadstatus = 'locked' WHERE topicid = '$threadtolock'"e;);
echo "e;<p align=center><B>Thread has been locked.</B></p>"e;;
}
}
// Move topic
if($_POSTї'action'] == "e;movetopic"e;)
{
$topictomove2 = mysql_real_escape_string(strip_tags($_POSTї'topictomove2']));
$topictomove = mysql_real_escape_string(strip_tags($_POSTї'topictomove']));
$adminarray = array("e;scrotaye"e;, "e;artbalaoro"e;, "e;potato"e;, "e;magicflymonkey"e;);
if(in_array($_COOKIEї'username'], $adminarray))
{
mysql_query("e;UPDATE forumtopicmain SET forumid = '$topictomove' WHERE id = '$topictomove2'"e;);
$movedrepliesquery = mysql_query("e;SELECT id FROM forumentries WHERE topicid = '$topictomove2'"e;);
while($movedrepliesarray = mysql_fetch_array($movedrepliesquery))
{
mysql_query("e;UPDATE forumentries SET forumid = '$topictomove' WHERE topicid = '$topictomove2'"e;);
}
echo "e;<p align=center><B>Topic has been moved.</B></p>"e;;
}
}
// End administration
// Purify $_GET information
$forumid = mysql_real_escape_string(strip_tags($forumid));
// Select the forum name
$forumarray = mysql_fetch_assoc(mysql_query("e;SELECT topicname FROM forumtopics WHERE id = '$forumid'"e;));
// Begin pagination for main page
$sql_text = ("e;SELECT id, topicname, threadstatus, author FROM forumtopicmain WHERE forumid = '$forumid' AND type != 'sticky' ORDER BY lastreply DESC"e;);
if(!$page)
{
$page = 1;
}
$prev_page = $page - 1;
$next_page = $page + 1;
$page_start = (25 * $page) - 25;
$query = mysql_query($sql_text);
$num_rows = mysql_num_rows($query);
if($num_rows <= 25)
{
$num_pages = 1;
} else if
(($num_rows % 25) == 0)
{
$num_pages = ($num_rows / 25);
} else
{
$num_pages = ($num_rows / 25) + 1;
}
$num_pages = (int) $num_pages;
if(($page > $num_pages) || ($page < 0))
{
die("e;You have specified an invalid page number"e;);
}
$sql_text = $sql_text . "e; LIMIT $page_start, 25"e;;
$query = mysql_query($sql_text); ?>
<a href="e;forums.php"e;>Show My Pro Forums</a> > <a href="e;showforum.php?forumid=<? echo $forumid; ?>"e;><? echo $forumarrayї'topicname']; ?></a> > <a href="e;newforumtopic.php?forumid=<? echo $forumid; ?>"e;><img src="e;images/newtopic.gif"e; alt="e;New Topic"e; border="e;0"e;></a>
<table width="e;100%"e; cellspacing="e;0"e; cellpadding="e;3"e; style="e;border: solid 1px #000000"e;>
<tr>
<td style="e;border: solid 1px #000000"e; align="e;center"e; colspan="e;5"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>A Space For Your Thoughts</font></B>
</td>
</tr>
<tr>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;5%"e; bgcolor="e;#CCCCCC"e;>&nbsp;
</td>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;50%"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Topic</font></B>
</td>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;10%"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Replies</font></B>
</td>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;15%"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Author</font></B>
</td>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;20%"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Last Post</font></B>
</td>
</tr>
<?
// Show stickies first
if($page == "e;1"e;)
{
$stickyquery = mysql_query("e;SELECT id, topicname, threadstatus, author FROM forumtopicmain WHERE forumid = '$forumid' AND type = 'sticky' ORDER BY lastreply DESC"e;);
while($stickyarray = mysql_fetch_assoc($stickyquery))
{
$stickyquery2 = mysql_query("e;SELECT id FROM forumentries WHERE topicid = '"e;.$stickyarrayї'id']."e;'"e;);
$stickyreplies = mysql_num_rows($stickyquery2) - 1;
$stickylastpostarray = mysql_fetch_assoc(mysql_query("e;SELECT time, author FROM forumentries WHERE topicid = '"e;.$stickyarrayї'id']."e;' ORDER BY time2 DESC LIMIT 1"e;)); ?>
<tr>
<td style="e;border: solid 1px #000000"e; width="e;5%"e; align="e;center"e;><? if($stickyarrayї'threadstatus'] == "e;open"e;){ ?><img src="e;images/thread_open.gif"e;><? } ELSE { ?><img src="e;images/thread_locked.gif"e;> <? } ?>
</td>
<td style="e;border: solid 1px #000000"e; width="e;50%"e; align="e;left"e;><a href="e;showthread.php?threadid=<? echo $stickyarrayї'id']; ?>&page=1"e;><? echo "e;STICKY: "e;.stripslashes($stickyarrayї'topicname'])."e;"e;; ?></a>
</td>
<td style="e;border: solid 1px #000000"e; width="e;10%"e; align="e;center"e;><B><font size="e;2"e;><? echo $stickyreplies; ?></B>
</td>
<td style="e;border: solid 1px #000000"e; width="e;15%"e; align="e;center"e;><a href="e;showme.php?u=<? echo $stickyarrayї'author']; ?>"e;><? echo $stickyarrayї'author']; ?></a>
</td>
<td style="e;border: solid 1px #000000"e; width="e;20%"e; align="e;left"e;><font size="e;2"e;><? echo $stickylastpostarrayї'time']; ?></font><BR><font size="e;2"e;>by</font> <a href="e;showme.php?u=<? echo $stickylastpostarrayї'author']; ?>"e;><? echo $stickylastpostarrayї'author']; ?></a>
</td>
</tr>
<?
}
}
// Show the non-stickied topics (most of them)
while($array = mysql_fetch_assoc($query))
{
$query2 = mysql_query("e;SELECT id FROM forumentries WHERE topicid = '"e;.$arrayї'id']."e;'"e;);
$replies = mysql_num_rows($query2) - 1;
$lastpostarray = mysql_fetch_assoc(mysql_query("e;SELECT time, author FROM forumentries WHERE topicid = '"e;.$arrayї'id']."e;' ORDER BY time2 DESC LIMIT 1"e;));
// Show the number of pages for each individual topic
$sql_text2 = ("e;SELECT id FROM forumentries WHERE topicid = '"e;.$arrayї'id']."e;'"e;);
$query2 = mysql_query($sql_text2);
$page_start2 = (25 * $page2) - 25;
$num_rows2 = mysql_num_rows($query2);
if ($num_rows2 <= 25) { $num_pages2 = 1; } else if
(($num_rows2 % 25) == 0) { $num_pages2 = ($num_rows2 / 25); } else {
$num_pages2 = ($num_rows2 / 25) + 1; }
$num_pages2 = (int) $num_pages2;
$sql_text2 = $sql_text2 . "e; LIMIT $page_start2, 25"e;; ?>
<tr>
<td style="e;border: solid 1px #000000"e; width="e;5%"e; align="e;center"e;><? if($arrayї'threadstatus'] == "e;open"e;){ ?><img src="e;images/thread_open.gif"e;><? } ELSE { ?><img src="e;images/thread_locked.gif"e;> <? } ?>
</td>
<td style="e;border: solid 1px #000000"e; width="e;50%"e; align="e;left"e;><a href="e;showthread.php?threadid=<? echo $arrayї'id']; ?>&page=1"e;><? echo stripslashes($arrayї'topicname']); ?></a><? if($num_pages2 > 1){ echo "e;<BR><font size=1>Page: </font>"e;; for ($i = 1; $i <= $num_pages2; $i++) {echo "e;<a href=\"e;showthread.php?threadid="e;.$arrayї'id']."e;&page=$i\"e;><font size=1>$i</font></a> "e;; } } ?>
</td>
<td style="e;border: solid 1px #000000"e; width="e;10%"e; align="e;center"e;><B><font size="e;2"e;><? echo $replies; ?></B>
</td>
<td style="e;border: solid 1px #000000"e; width="e;15%"e; align="e;center"e;><a href="e;showme.php?u=<? echo $arrayї'author']; ?>"e;><? echo $arrayї'author']; ?></a>
</td>
<td style="e;border: solid 1px #000000"e; width="e;20%"e; align="e;left"e;><font size="e;2"e;><? echo $lastpostarrayї'time']; ?></font><BR><font size="e;2"e;>by</font> <a href="e;showme.php?u=<? echo $lastpostarrayї'author']; ?>"e;><? echo $lastpostarrayї'author']; ?></a>
</td>
</tr><?
} ?>
</table>
<a href="e;forums.php"e;>Show My Pro Forums</a> > <a href="e;showforum.php?forumid=<? echo $forumid; ?>"e;><? echo $forumarrayї'topicname']; ?></a> > <a href="e;newforumtopic.php?forumid=<? echo $forumid; ?>"e;><img src="e;images/newtopic.gif"e; alt="e;New Topic"e; border="e;0"e;></a>
<p class="e;main"e;><center>
<?
// Show next 10 pages, previous 10 pages, etc.. for the number of pages in the forum
$limit = $page+10;
if($num_pages >= $limit)
{
if($page != 1)
{
$previouspage = $page - 1;
$previousstart = $previouspage - 9;
if($page == 2)
{
echo "e;<small><<</small> <a href=\"e;$PHP_SELF?forumid=$forumid&page=1\"e;>Page 1</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"e;;
} ELSE
{
if($previousstart <= 0)
{
echo"e;<small><<</small> <a href=\"e;$PHP_SELF?forumid=$forumid&page=1\"e;>Pages 1 - $previouspage</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"e;;
} ELSE
{
echo "e;<small><<</small> <a href=\"e;$PHP_SELF?forumid=$forumid&page=$previousstart\"e;>Pages $previousstart - $previouspage</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"e;;
}
}
}
for($i = $page; $i<$limit; $i++)
{
echo "e; <a href=\"e;$PHP_SELF?forumid=$forumid&page=$i\"e;>$i</a> "e;;
}
$limit2 = $i+9;
if($num_pages <= $limit2)
{
echo "e;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=\"e;$PHP_SELEF?forumid=$forumid&page=$i\"e;>Pages $i - $num_pages</a> <small>>></small>"e;;
} ELSE
{
echo "e;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=\"e;$PHP_SELEF?forumid=$forumid&page=$i\"e;>Pages $i - $limit2</a> <small>>></small>"e;;
}
} ELSE
{
for($i = $page; $i<=$num_pages; $i++)
{
echo "e; <a href=\"e;$PHP_SELF?forumid=$forumid&page=$i\"e;>$i</a> "e;;
}
}
?>
</center></p>
<p align="e;left"e; class="e;main"e;><img src="e;images/to_e.gif"e;> Thread Open&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="e;images/tl_e.gif"e;> Thread Locked</font></p>
<?
// Start administration panel
$adminarray = array("e;scrotaye"e;, "e;artbalaoro"e;, "e;potato"e;, "e;magicflymonkey"e;);
if(in_array($_COOKIEї'username'], $adminarray))
{
?>
<table width="e;60%"e; align="e;center"e; style="e;border: solid 1px #000000"e; cellspacing="e;0"e; cellpading="e;3"e;>
<tr>
<td style="e;border: solid 1px #000000"e; align="e;center"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Administration Panel</font></B>
</td>
</tr>
<tr>
<td style="e;border: solid 1px #000000"e; align="e;center"e;>
<form action="e;showforum.php?forumid=<? echo $forumid; ?>"e; method="e;post"e;>
<input type="e;hidden"e; name="e;action"e; value="e;lockthread"e;>
<p align="e;center"e;><B><font size="e;2"e;>Lock Thread</font></B><BR>
<select name="e;threadtolock"e;>
<option selected>Select</option><?
$threadtolockquery = mysql_query("e;SELECT id, topicname FROM forumtopicmain WHERE forumid = '$forumid' ORDER BY lastreply DESC LIMIT 25"e;);
while($threadtolockarray = mysql_fetch_assoc($threadtolockquery))
{ ?>
<option value="e;<? echo $threadtolockarrayї'id']; ?>"e;><? echo stripslashes($threadtolockarrayї'topicname']); ?></option><?
} ?>
</select>
<BR>
<input type="e;submit"e; value="e;Lock"e;>
</form>
<form action="e;showforum.php?forumid=<? echo $forumid; ?>"e; method="e;post"e;>
<input type="e;hidden"e; name="e;action"e; value="e;movetopic"e;>
<p align="e;center"e;><B><font size="e;2"e;>Move Topic</font></B></p>
<B><font size="e;2"e;>Move Topic Named</font></B>
<select name="e;topictomove2"e;>
<option selected>Select</option><?
$threadtomovequery = mysql_query("e;SELECT id, topicname FROM forumtopicmain WHERE forumid = '$forumid' ORDER BY lastreply DESC LIMIT 25"e;);
while($threadtomovearray = mysql_fetch_assoc($threadtomovequery)){
?><option value="e;<? echo $threadtomovearrayї'id']; ?>"e;><? echo stripslashes($threadtomovearrayї'topicname']); ?></option>
<?
} ?>
</select><BR><B><font size="e;2"e;>To Forum</font></B><BR>
<select name="e;topictomove"e;>
<option selected>Select</option><?
$topicsmovequery = mysql_query("e;SELECT topicname, id FROM forumtopics ORDER BY rank"e;);
while($topicsmovearray = mysql_fetch_assoc($topicsmovequery)){ ?>
<option value="e;<? echo $topicsmovearrayї'id']; ?>"e;><? echo $topicsmovearrayї'topicname']; ?></option><? } ?>
</select><BR>
<input type="e;submit"e; value="e;Move"e;>
</form>
</td>
&quickly.......... except for one.
It's the showforum.php page
Someone tell me if anything sticks out like a sore thumb.. that would slow my page loading time wayyyyyy down. I'm looking at like 10 seconds every time I load this page. Maybe it's because I escape to HTML too much?Code: Select all
<?
$description = "Browse forum topics"e;;
require 'header.php';
// Update doing section
if(isset($_COOKIEї'username']))
{
mysql_query("e;UPDATE users SET doing = 'Browsing Forums' WHERE username = '$theperson'"e;);
}
// Administration
// Lock thread
if($_POSTї'action'] == "e;lockthread"e;)
{
$threadtolock = mysql_real_escape_string(strip_tags($_POSTї'threadtolock']));
$adminarray = array("e;scrotaye"e;, "e;artbalaoro"e;, "e;potato"e;, "e;magicflymonkey"e;);
if(in_array($theperson, $adminarray))
{
mysql_query("e;UPDATE forumtopicmain SET threadstatus = 'locked' WHERE id = '$threadtolock'"e;);
mysql_query("e;UPDATE forumentries SET threadstatus = 'locked' WHERE topicid = '$threadtolock'"e;);
echo "e;<p align=center><B>Thread has been locked.</B></p>"e;;
}
}
// Move topic
if($_POSTї'action'] == "e;movetopic"e;)
{
$topictomove2 = mysql_real_escape_string(strip_tags($_POSTї'topictomove2']));
$topictomove = mysql_real_escape_string(strip_tags($_POSTї'topictomove']));
$adminarray = array("e;scrotaye"e;, "e;artbalaoro"e;, "e;potato"e;, "e;magicflymonkey"e;);
if(in_array($_COOKIEї'username'], $adminarray))
{
mysql_query("e;UPDATE forumtopicmain SET forumid = '$topictomove' WHERE id = '$topictomove2'"e;);
$movedrepliesquery = mysql_query("e;SELECT id FROM forumentries WHERE topicid = '$topictomove2'"e;);
while($movedrepliesarray = mysql_fetch_array($movedrepliesquery))
{
mysql_query("e;UPDATE forumentries SET forumid = '$topictomove' WHERE topicid = '$topictomove2'"e;);
}
echo "e;<p align=center><B>Topic has been moved.</B></p>"e;;
}
}
// End administration
// Purify $_GET information
$forumid = mysql_real_escape_string(strip_tags($forumid));
// Select the forum name
$forumarray = mysql_fetch_assoc(mysql_query("e;SELECT topicname FROM forumtopics WHERE id = '$forumid'"e;));
// Begin pagination for main page
$sql_text = ("e;SELECT id, topicname, threadstatus, author FROM forumtopicmain WHERE forumid = '$forumid' AND type != 'sticky' ORDER BY lastreply DESC"e;);
if(!$page)
{
$page = 1;
}
$prev_page = $page - 1;
$next_page = $page + 1;
$page_start = (25 * $page) - 25;
$query = mysql_query($sql_text);
$num_rows = mysql_num_rows($query);
if($num_rows <= 25)
{
$num_pages = 1;
} else if
(($num_rows % 25) == 0)
{
$num_pages = ($num_rows / 25);
} else
{
$num_pages = ($num_rows / 25) + 1;
}
$num_pages = (int) $num_pages;
if(($page > $num_pages) || ($page < 0))
{
die("e;You have specified an invalid page number"e;);
}
$sql_text = $sql_text . "e; LIMIT $page_start, 25"e;;
$query = mysql_query($sql_text); ?>
<a href="e;forums.php"e;>Show My Pro Forums</a> > <a href="e;showforum.php?forumid=<? echo $forumid; ?>"e;><? echo $forumarrayї'topicname']; ?></a> > <a href="e;newforumtopic.php?forumid=<? echo $forumid; ?>"e;><img src="e;images/newtopic.gif"e; alt="e;New Topic"e; border="e;0"e;></a>
<table width="e;100%"e; cellspacing="e;0"e; cellpadding="e;3"e; style="e;border: solid 1px #000000"e;>
<tr>
<td style="e;border: solid 1px #000000"e; align="e;center"e; colspan="e;5"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>A Space For Your Thoughts</font></B>
</td>
</tr>
<tr>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;5%"e; bgcolor="e;#CCCCCC"e;>&nbsp;
</td>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;50%"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Topic</font></B>
</td>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;10%"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Replies</font></B>
</td>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;15%"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Author</font></B>
</td>
<td style="e;border: solid 1px #000000"e; align="e;center"e; width="e;20%"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Last Post</font></B>
</td>
</tr>
<?
// Show stickies first
if($page == "e;1"e;)
{
$stickyquery = mysql_query("e;SELECT id, topicname, threadstatus, author FROM forumtopicmain WHERE forumid = '$forumid' AND type = 'sticky' ORDER BY lastreply DESC"e;);
while($stickyarray = mysql_fetch_assoc($stickyquery))
{
$stickyquery2 = mysql_query("e;SELECT id FROM forumentries WHERE topicid = '"e;.$stickyarrayї'id']."e;'"e;);
$stickyreplies = mysql_num_rows($stickyquery2) - 1;
$stickylastpostarray = mysql_fetch_assoc(mysql_query("e;SELECT time, author FROM forumentries WHERE topicid = '"e;.$stickyarrayї'id']."e;' ORDER BY time2 DESC LIMIT 1"e;)); ?>
<tr>
<td style="e;border: solid 1px #000000"e; width="e;5%"e; align="e;center"e;><? if($stickyarrayї'threadstatus'] == "e;open"e;){ ?><img src="e;images/thread_open.gif"e;><? } ELSE { ?><img src="e;images/thread_locked.gif"e;> <? } ?>
</td>
<td style="e;border: solid 1px #000000"e; width="e;50%"e; align="e;left"e;><a href="e;showthread.php?threadid=<? echo $stickyarrayї'id']; ?>&page=1"e;><? echo "e;STICKY: "e;.stripslashes($stickyarrayї'topicname'])."e;"e;; ?></a>
</td>
<td style="e;border: solid 1px #000000"e; width="e;10%"e; align="e;center"e;><B><font size="e;2"e;><? echo $stickyreplies; ?></B>
</td>
<td style="e;border: solid 1px #000000"e; width="e;15%"e; align="e;center"e;><a href="e;showme.php?u=<? echo $stickyarrayї'author']; ?>"e;><? echo $stickyarrayї'author']; ?></a>
</td>
<td style="e;border: solid 1px #000000"e; width="e;20%"e; align="e;left"e;><font size="e;2"e;><? echo $stickylastpostarrayї'time']; ?></font><BR><font size="e;2"e;>by</font> <a href="e;showme.php?u=<? echo $stickylastpostarrayї'author']; ?>"e;><? echo $stickylastpostarrayї'author']; ?></a>
</td>
</tr>
<?
}
}
// Show the non-stickied topics (most of them)
while($array = mysql_fetch_assoc($query))
{
$query2 = mysql_query("e;SELECT id FROM forumentries WHERE topicid = '"e;.$arrayї'id']."e;'"e;);
$replies = mysql_num_rows($query2) - 1;
$lastpostarray = mysql_fetch_assoc(mysql_query("e;SELECT time, author FROM forumentries WHERE topicid = '"e;.$arrayї'id']."e;' ORDER BY time2 DESC LIMIT 1"e;));
// Show the number of pages for each individual topic
$sql_text2 = ("e;SELECT id FROM forumentries WHERE topicid = '"e;.$arrayї'id']."e;'"e;);
$query2 = mysql_query($sql_text2);
$page_start2 = (25 * $page2) - 25;
$num_rows2 = mysql_num_rows($query2);
if ($num_rows2 <= 25) { $num_pages2 = 1; } else if
(($num_rows2 % 25) == 0) { $num_pages2 = ($num_rows2 / 25); } else {
$num_pages2 = ($num_rows2 / 25) + 1; }
$num_pages2 = (int) $num_pages2;
$sql_text2 = $sql_text2 . "e; LIMIT $page_start2, 25"e;; ?>
<tr>
<td style="e;border: solid 1px #000000"e; width="e;5%"e; align="e;center"e;><? if($arrayї'threadstatus'] == "e;open"e;){ ?><img src="e;images/thread_open.gif"e;><? } ELSE { ?><img src="e;images/thread_locked.gif"e;> <? } ?>
</td>
<td style="e;border: solid 1px #000000"e; width="e;50%"e; align="e;left"e;><a href="e;showthread.php?threadid=<? echo $arrayї'id']; ?>&page=1"e;><? echo stripslashes($arrayї'topicname']); ?></a><? if($num_pages2 > 1){ echo "e;<BR><font size=1>Page: </font>"e;; for ($i = 1; $i <= $num_pages2; $i++) {echo "e;<a href=\"e;showthread.php?threadid="e;.$arrayї'id']."e;&page=$i\"e;><font size=1>$i</font></a> "e;; } } ?>
</td>
<td style="e;border: solid 1px #000000"e; width="e;10%"e; align="e;center"e;><B><font size="e;2"e;><? echo $replies; ?></B>
</td>
<td style="e;border: solid 1px #000000"e; width="e;15%"e; align="e;center"e;><a href="e;showme.php?u=<? echo $arrayї'author']; ?>"e;><? echo $arrayї'author']; ?></a>
</td>
<td style="e;border: solid 1px #000000"e; width="e;20%"e; align="e;left"e;><font size="e;2"e;><? echo $lastpostarrayї'time']; ?></font><BR><font size="e;2"e;>by</font> <a href="e;showme.php?u=<? echo $lastpostarrayї'author']; ?>"e;><? echo $lastpostarrayї'author']; ?></a>
</td>
</tr><?
} ?>
</table>
<a href="e;forums.php"e;>Show My Pro Forums</a> > <a href="e;showforum.php?forumid=<? echo $forumid; ?>"e;><? echo $forumarrayї'topicname']; ?></a> > <a href="e;newforumtopic.php?forumid=<? echo $forumid; ?>"e;><img src="e;images/newtopic.gif"e; alt="e;New Topic"e; border="e;0"e;></a>
<p class="e;main"e;><center>
<?
// Show next 10 pages, previous 10 pages, etc.. for the number of pages in the forum
$limit = $page+10;
if($num_pages >= $limit)
{
if($page != 1)
{
$previouspage = $page - 1;
$previousstart = $previouspage - 9;
if($page == 2)
{
echo "e;<small><<</small> <a href=\"e;$PHP_SELF?forumid=$forumid&page=1\"e;>Page 1</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"e;;
} ELSE
{
if($previousstart <= 0)
{
echo"e;<small><<</small> <a href=\"e;$PHP_SELF?forumid=$forumid&page=1\"e;>Pages 1 - $previouspage</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"e;;
} ELSE
{
echo "e;<small><<</small> <a href=\"e;$PHP_SELF?forumid=$forumid&page=$previousstart\"e;>Pages $previousstart - $previouspage</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"e;;
}
}
}
for($i = $page; $i<$limit; $i++)
{
echo "e; <a href=\"e;$PHP_SELF?forumid=$forumid&page=$i\"e;>$i</a> "e;;
}
$limit2 = $i+9;
if($num_pages <= $limit2)
{
echo "e;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=\"e;$PHP_SELEF?forumid=$forumid&page=$i\"e;>Pages $i - $num_pages</a> <small>>></small>"e;;
} ELSE
{
echo "e;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href=\"e;$PHP_SELEF?forumid=$forumid&page=$i\"e;>Pages $i - $limit2</a> <small>>></small>"e;;
}
} ELSE
{
for($i = $page; $i<=$num_pages; $i++)
{
echo "e; <a href=\"e;$PHP_SELF?forumid=$forumid&page=$i\"e;>$i</a> "e;;
}
}
?>
</center></p>
<p align="e;left"e; class="e;main"e;><img src="e;images/to_e.gif"e;> Thread Open&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img src="e;images/tl_e.gif"e;> Thread Locked</font></p>
<?
// Start administration panel
$adminarray = array("e;scrotaye"e;, "e;artbalaoro"e;, "e;potato"e;, "e;magicflymonkey"e;);
if(in_array($_COOKIEї'username'], $adminarray))
{
?>
<table width="e;60%"e; align="e;center"e; style="e;border: solid 1px #000000"e; cellspacing="e;0"e; cellpading="e;3"e;>
<tr>
<td style="e;border: solid 1px #000000"e; align="e;center"e; bgcolor="e;#CCCCCC"e;><B><font size="e;2"e;>Administration Panel</font></B>
</td>
</tr>
<tr>
<td style="e;border: solid 1px #000000"e; align="e;center"e;>
<form action="e;showforum.php?forumid=<? echo $forumid; ?>"e; method="e;post"e;>
<input type="e;hidden"e; name="e;action"e; value="e;lockthread"e;>
<p align="e;center"e;><B><font size="e;2"e;>Lock Thread</font></B><BR>
<select name="e;threadtolock"e;>
<option selected>Select</option><?
$threadtolockquery = mysql_query("e;SELECT id, topicname FROM forumtopicmain WHERE forumid = '$forumid' ORDER BY lastreply DESC LIMIT 25"e;);
while($threadtolockarray = mysql_fetch_assoc($threadtolockquery))
{ ?>
<option value="e;<? echo $threadtolockarrayї'id']; ?>"e;><? echo stripslashes($threadtolockarrayї'topicname']); ?></option><?
} ?>
</select>
<BR>
<input type="e;submit&a