$Content = "";
$ContentSpans = "";
$PopReplaceMode = 2;
$SuspendHotpops = false;
$DoGeneralContentActivity = true;
error_reporting(0);
// echo "
8052mcu.com is temporarily offline for maintenance";
// exit;
// ini_set('display_errors', 1);
//phpinfo();
//exit;
//echo "Temporarily offline... back within 10 minutes...
";
//exit;
/*
$file = fopen("/proc/loadavg", "r");
$ln = fgets($file);
fclose($file);
$loadavg = strtok($ln, " ");
if($loadavg > 6)
sleep(8);
else if($loadavg > 5)
sleep(5);
else if($loadavg > 4)
sleep(4);
//else if($loadavg > 3)
// sleep(3);
//else if($loadavg > 2)
// sleep(1);
//else if($loadavg > 2)
// sleep(3);
*/
include "_routines.php"; /* Get the common routines */
include "_popupwords.php"; // Get the keywords into $POP
$REMOTE_ADDR = $_SERVER["REMOTE_ADDR"];
$REMOTE_HOST = $REMOTE_ADDR; // $_SERVER["REMOTE_HOST"];
$SCRIPT_NAME = $_SERVER["SCRIPT_NAME"];
$BROWSER = getenv("HTTP_USER_AGENT");
if(strstr("*58-186-92-xxx-dynamic.hcm.fpt.vn*218.subnet125-164-124.speedy.telkom.net.id*", "*$REMOTE_HOST*") != false )
{
echo "Disabled, contact webmaster at craigsteiner@8052.com";
exit;
}
if(substr($REMOTE_ADDR, 0, 10) == "60.169.78.") exit; // Johnson, Wesley | LaRod Stephens-Howling
if(strstr($REMOTE_ADDR, "96.47.225.") != false) exit;
if(strstr($REMOTE_ADDR, "96.47.224.") != false) exit;
if(strstr($REMOTE_ADDR, "173.44.37.") != false) exit;
if(strstr($REMOTE_ADDR, "68.169.80.") != false) exit;
if(strstr($REMOTE_ADDR, "64.188.59.") != false) exit;
// ConnectToDatabase();
// $REQUESTEDFILE = $_SERVER["SCRIPT_URL"];
// $REQUESTEDFILE = "http://www.8052.com".$_SERVER["REQUEST_URI"];
$REQUESTEDFILE = $_SERVER["REQUEST_URI"];
$x = strpos($REQUESTEDFILE, "?");
if($x > 0)
$REQUESTEDFILE = substr($REQUESTEDFILE, 0, $x);
$EXTENSION = "";
if(substr($REQUESTEDFILE, strlen($REQUESTEDFILE) - 1, 1) == "/")
$REQUESTEDFILE = substr($REQUESTEDFILE, 0, strlen($REQUESTEDFILE) - 1);
if(strpos($REQUESTEDFILE, ".") == false)
{
// Pure directory name
$Pathname = $REQUESTEDFILE;
$Filename = "";
}
else
{
$Filename = basename($REQUESTEDFILE);
$Pathname = substr($REQUESTEDFILE, 0, strlen($REQUESTEDFILENAME) - strlen($Filename));
if(substr($Pathname, strlen($Pathname) - 1, 1) == "/")
$Pathname = substr($Pathname, 0, strlen($Pathname) - 1);
}
$FindPeriod = strrpos($Filename, ".");
if($FindPeriod > 0)
{
$EXTENSION = substr($Filename, $FindPeriod);
$Filename = substr($Filename, 0, $FindPeriod);
}
if($Filename == "")
$Filename = "index";
if(substr($Pathname, strlen($Pathname) - 1, 1) != "/")
$Pathname .= "/";
$HOMEPAGE = false;
$FORUMPAGE = false;
$OTHERPAGE = false;
$STOREPAGE = false;
if($Filename == "index" && $Pathname == "/")
$HOMEPAGE = true;
if($Pathname == "/store/")
$STOREPAGE = true;
// Get the right file content
// echo "Pathname: $Pathname
Filename $Filename
";
//exit;
/*************************************************************
* *
* IDENTIFY SPIDERS *
* *
*************************************************************/
$Spider = "";
$HoldBrowser = strtoupper($BROWSER);
if(strstr($HoldBrowser, "GOOGLEBOT") != false)
$Spider = "SG";
else if(strstr($HoldBrowser, "YAHOO! SLURP") != false)
$Spider = "SY";
else if(strstr($HoldBrowser, "DOTBOT") != false)
$Spider = "SD";
else if(strstr($HoldBrowser, "WORLDSEARCH BOT") != false)
$Spider = "S1";
else if(strstr($HoldBrowser, "BAIDUSPIDER") != false)
$Spider = "S2";
else if(strstr($HoldBrowser, "YAHOO! DE SLURP") != false)
$Spider = "SY";
else if(strstr($HoldBrowser, "SPIDER") != false)
$Spider = "S3";
else if(strstr($HoldBrowser, "YODAOBOT") != false)
$Spider = "SD";
else if(strstr($HoldBrowser, "MSNBOT") != false)
$Spider = "SM";
else if(strstr($HoldBrowser, "ASK JEEVES") != false)
$Spider = "SA";
else if(strstr($HoldBrowser, "AOLBUILD") != false)
$Spider = "S2";
//if($Spider != "")
// sleep(6); // Slow down spiders
/*************************************************************
* *
* MANAGE ACTIVITY DATABASE *
* *
*************************************************************/
if(0) // $Spider == "")
{
$Throttled = 0;
// Insert Throttle Record
$SQL = "INSERT INTO SiteActivityThrottle SET ";
$SQL .= " IPAddress=\"".addslashes($REMOTE_ADDR)."\"";
$SQL .= ", Time=".time();
$updateUser = mysql_db_query ( $sDB, $SQL, $nConnection );
// Now find if we have too many hits in last 60 seconds
$SQL = "SELECT * FROM SiteActivityThrottle WHERE ";
$SQL .= " IPAddress=\"".addslashes($REMOTE_ADDR)."\"";
$SQL .= " AND Time>".(time() - 60); // Last Minute
$updateUser = mysql_db_query ( $sDB, $SQL, $nConnection );
$cntActivity = mysql_num_rows($updateUser);
if($idUser > 0)
{
// THROTTLE FOR LOGGED IN USER
if($cntActivity > 25)
{
echo "Slow down, cowboy, you've requested $cntActivity in the last minute... leave some server for someone else.
";
exit;
}
else if($cntActivity >= 15) // More than one every 6 seconds sustained for 10 hits
{
//sleep(5);
$Throttled = $cntActivity;
}
else if($cntActivity >= 10) // More than one every 6 seconds sustained for 10 hits
{
//sleep(3);
$Throttled = $cntActivity;
}
}
else
{
// THROTTLE FOR NOT LOGGED IN USER
if($cntActivity > 20)
{
echo "Slow down, cowboy, you've requested $cntActivity in the last minute... leave some server for someone else.
";
exit;
}
else if($cntActivity >= 10) // More than one every 6 seconds sustained for 10 hits
{
//sleep(5);
$Throttled = $cntActivity;
}
else if($cntActivity >= 5) // More than one every 6 seconds sustained for 10 hits
{
//sleep(3);
$Throttled = $cntActivity;
}
}
// Insert activity
$SQL = "UPDATE SiteActivity SET ";
$SQL .= "LastActivity=".time();
$SQL .= ", Throttled=$cntActivity";
$SQL .= ", Page=\"".addslashes($SCRIPT_NAME )."\"";
$SQL .= ", Browser=\"".addslashes($HoldBrowser)."\"";
$SQL .= ", HitCount=HitCount+1";
if($Spider != "")
$SQL .= ", Spider=1";
if($idUser == 0)
$SQL .= ", UserID=0, Username=\"\"";
else
{
$SQL .= ", UserId=\"$idUser\" ";
$SQL .= ", Username=\"$UserName\" ";
}
$SQL .= " WHERE (IPAddress=\"".addslashes($REMOTE_ADDR)."\") ";
// $SQL .= " OR UserId=\"$idUser\") ";
$updateUser = mysql_db_query ( $sDB, $SQL, $nConnection );
if(mysql_affected_rows() == 0)
{
// Couldn't update, so try inserting
$SQL = "INSERT INTo SiteActivity SET ";
$SQL .= "FirstActivity=".time();
$SQL .= ", LastActivity=".time();
$SQL .= ", Throttled=$cntActivity";
$SQL .= ", Page=\"NEWSTART--".addslashes($SCRIPT_NAME)."\"";
$SQL .= ", Browser=\"".addslashes($HoldBrowser)."\"";
$SQL .= ", HitCount=1";
$SQL .= ", IPAddress=\"".addslashes($REMOTE_ADDR)."\" ";
$SQL .= ", UserId=\"$idUser\" ";
$SQL .= ", Username=\"$UserName\" ";
if($Spider != "")
$SQL .= ", Spider=1";
$updateDate = mysql_db_query ( $sDB, $SQL, $nConnection );
//if($idUser != 0)
// {
// // Also delete the same IP address with idUser=0 since the
// // user just logged in and any previous idUser=0 at that IP
// // address is probably the same user, but before logging on
// $SQL = "DELETE FROM SiteActivity WHERE ";
// $SQL .= "UserID=0 AND ";
// $SQL .= ", IPAddress=\"".addslashes($REMOTE_ADDR)."\" ";
// $updateDate = mysql_db_query ( $sDB, $SQL, $nConnection );
// }
}
$GuestCount = 0;
$RegUserList = "";
if($idUser)
{
// Load user list from ActivityList
$SQL = "SELECT * FROM SiteActivity WHERE Spider=0 ORDER BY LastActivity DESC";
$dynUserList = mysql_db_query($sDB, $SQL, $nConnection );
$NumberOfUsersOnline = mysql_num_rows($dynUserList);
$GuestCount = 0;
$RegUserList = "";
for($x = 0; $x < $NumberOfUsersOnline; $x++)
{
$ThisIdUser = mysql_result($dynUserList, $x, "UserID");
$ThisUsername = mysql_result($dynUserList, $x, "UserName");
if($ThisIdUser == 0)
$GuestCount++;
else
{
if($RegUserList != "")
$RegUserList .= ", ";
$RegUserList .= "".ucwords($ThisUsername)."";
}
}
}
}
$ForumID= -1;
for($x = 0; ;$x++)
{
if(!IsSet($FORUM[$x]["ID"]) || $FORUM[$x]["ID"] == "")
continue;
if($FORUM[$x]["ID"] == "none")
break;
if($FORUM[$x]["DIRECTORY"] == "none")
continue;
$ForumDirLength = strlen($FORUM[$x]["DIRECTORY"]);
if($FORUM[$x]["DIRECTORY"] == substr($Pathname, 0, $ForumDirLength))
{
$ForumParameters = substr($Pathname, $ForumDirLength);
$ForumDirectory = substr($Pathname, 0, $ForumDirLength);
$ForumDescription = $FORUM[$x]["NAME"];
$ForumID = $FORUM[$x]["ID"];
$FORUMPAGE = true;
break;
}
}
$DirectoryAsFilename = strtok($Pathname, "/");
$DoGeneralContentActivity = false;
if(!$FORUMPAGE && !$HOMEPAGE && !$STOREPAGE)
$OTHERPAGE = true;
//echo "Pathname=$Pathname
Filename=$Filename
DAF=$DirectoryAsFilename
";
//echo "Base=".basename($REQUESTEDFILE)."
";
//echo "Test: ../content".$Pathname."/$Filename.php = ".file_exists("../content".$Pathname."/$Filename.php")."
";
//echo "Extension: $EXTENSION
";
//exit;
if($Pathname == "/admin/")
{
if($UserAccess & ACCESS_WEBMASTER)
{
include "admin/$Filename.php";
}
else
{
Header("Location: /");
}
// exit;
}
else if(substr($Pathname, 0, 7) == "/users/")
{
// USER HOME PAGE
$UserHomeDirectory = strtok(substr($Pathname, 7), "/");
//echo "USer home page";
//echo "Pathname=$Pathname
Filename=$Filename
DAF=$DirectoryAsFilename
";
//echo "UserHomeDirectory=$UserHomeDirectory
";
//exit;
include "_showhomepage.php";
//
//echo "Base=".basename($REQUESTEDFILE)."
";
//echo "Test: ../content".$Pathname."/$Filename.php = ".file_exists("../content".$Pathname."/$Filename.php")."
";
// exit;
}
else if($Filename == "index" && file_exists("$DirectoryAsFilename.php"))
{
include "$DirectoryAsFilename.php";
}
else if(file_exists("../content".$Pathname."/$Filename.php"))
{
$Content = file_get_contents("../content".$Pathname."/$Filename.php");
$DoGeneralContentActivity = true;
}
else if(file_exists("../content/".$DirectoryAsFilename.".php"))
{
$Content = file_get_contents("../content/".$DirectoryAsFilename.".php");
$DoGeneralContentActivity = true;
}
else if(file_exists("$Filename.php"))
{
include "$Filename.php";
exit;
}
else if(strstr($Pathname, "codelib/files") != false )
{
$BaseName = basename($REQUESTEDFILE);
if($BaseName != "index.php")
{
$FileToDownload = $BaseName;
}
else
{
$FileToDownload = strtok(substr($Pathname, 9), "/");
}
if(!file_exists(CODELIBDIRECTORY."/$FileToDownload"))
{
echo "404 File Doesn't exist";
exit;
}
//echo "Need to download: $FileToDownload
";
header("Content-disposition: attachment; filename=\"$FileToDownload\"");
readfile(CODELIBDIRECTORY."/$FileToDownload");
exit;
}
else if($ForumID > -1)
{
// $Content = "In Forum Mode $ForumMode $Pathname
";
$ForumActivity = strtok($ForumParameters, "/");
$ForumAuxData = strtok("/");
$ForumAuxData2 = strtok("/");
$ForumAuxData3 = strtok("/");
if($ForumActivity == "")
{
$ForumActivity = "page";
$ForumAuxData = "1";
}
// Process old request format:
// Such as: http://www.8052.com/forum/read.phtml?id=158448
$GetThread = GetVar("thread");
$GetReadID = GetVar("id");
if($GetThread != "")
{
Header("Location: $Pathname"."thread/$GetThread");
exit;
}
else if($GetReadID != "")
{
Header("Location: $Pathname"."read/$GetReadID");
exit;
}
switch($ForumActivity)
{
case "MarkAsNew": include "forum/markAllAsNew.php"; exit; break;
case "score": include "forum/scoremessage.php"; exit; break;
case "page": include "forum/mainlist.php"; break;
case "thread": include "forum/thread.php"; break;
case "read": include "forum/readsinglemessage.php"; break;
case "code":
include "forum/savecode.php"; break;
// Here we need to display code # ForumAuxData2 for message ForumAuxData
// echo "Test";
exit;
break;
case "post":
case "reply";
case "edit";
include "forum/post.php"; break;
//case "reply";
//case "edit";
// include "forum/post.php"; break;
case "MarkSticky":
case "undeletethread":
case "deletethread":
case "closethread":
case "openthread":
case "hidethread":
case "unhidethread":
case "movethread":
case "movepost";
case "deletepost";
if($UserAccess & ACCESS_MODMASTER)
{
include "forum/forumadmin.php";
break;
}
default:
$Content = file_get_contents("../content/Error404.php");
header("HTTP/1.0 404 Not Found");
break;
}
}
else
{
$DoGeneralContentActivity = true;
if($Filename == "index" && file_exists("../contentactive/$DirectoryAsFilename.php"))
{
include "../contentactive/$DirectoryAsFilename.php";
$DoGeneralContentActivity = false;
// exit;
}
else if(file_exists("../contentactive".$Pathname."/$Filename.php"))
{
include "../contentactive".$Pathname."/$Filename.php";
$DoGeneralContentActivity = false;
}
// Sub directories below /content/
else if(file_exists("../content/$DirectoryAsFilename/".basename($REQUESTEDFILE).".php"))
$Content = file_get_contents("../content/$DirectoryAsFilename/".basename($REQUESTEDFILE).".php");
else if(file_exists("../content/$Pathname/".basename($REQUESTEDFILE)))
{
$mimes = GetMimeTypes();
if (isset($mimes[strtolower(substr($EXTENSION, 1))]))
header("Content-Type: ".$mimes[strtolower($EXTENSION)]);
readfile("../content/$Pathname/".basename($REQUESTEDFILE));
exit;
}
else if(file_exists("../content/$Filename.php"))
$Content = file_get_contents("../content/$Filename.php");
else if(file_exists("../content/$Filename.phtml"))
$Content = file_get_contents("../content/$Filename.php");
else if(file_exists("../contentactive/$Filename.php"))
{
//echo "Got here1
";
// include "../contentactive/$Filename.php";
// echo "Got here
";
}
else
{
$Content = file_get_contents("../content/Error404.php");
header("HTTP/1.0 404 Not Found");
}
}
if($DoGeneralContentActivity)
{
// Replace all things we need to replace
$NextReplace = strtok($ReplaceList, ",");
while($NextReplace != false)
{
$ReplaceContent = $$NextReplace;
$ReplaceString = "";
// echo "$NextReplace is to be replace with ".htmlentities($ReplaceContent)."
";
$Content = str_replace($ReplaceString, $ReplaceContent, $Content);
$NextReplace = strtok(",");
}
if(strstr($Content, "") == false && !$SuspendHotpops)
SubstitutePopLinks(); // Add context-sensitive pop links unless found in the file
// Extract Title From Content
if(strstr($Content, "") != false)
{
$Startpos = strpos(strtoupper($Content), "");
$Endpos = strpos(strtoupper($Content), "");
$TITLE = substr($Content, $Startpos + 7, $Endpos - $Startpos - 7);
// Remove TITLE tag from Content
$Content = substr($Content, 0, $Startpos).substr($Content,$Endpos + 8);
}
include "../contentsupport/_sidebar.php";
echo $Content; // Dump the page
}
include "../contentsupport/_footer.php";
// Here we need to display any pop-up spans
echo "$ContentSpans"; // Dump any spans collected for hot-sensitive words
if($idUser != 0)
{
echo "";
?>
CURRENTLY ONLINE
echo "$GuestCount guests";
if($RegUserList != "")
echo " and the following registered users:
$RegUserList";
?>
}
echo "";
echo "