...

View Full Version : php proccess not ending what to do creating internal server error



bijaybd
03-17-2010, 12:41 PM
<?

include "session.php";
include "dbconfing.php";

include "gzip.php";

ob_start("obOutputHandler");

wml_header();
$nocache = rand(10000, 99999);
$n = rand(1,1);
$num_msgsin=10;


$id = intval($_SESSION['id']);
$pass = mysql_escape_string($_SESSION['pass']);
$q = mysql_query("SELECT * FROM `chat_users` WHERE `id` = '".$id."' AND `pass` = '".$pass."' LIMIT 1;");
if(mysql_num_rows($q) == 0)
{
echo "<card title=\"Not logged in\">";
echo "<p align=\"$align\">\n";
echo "<small>\n";
echo "Not logged in!<br/>\n";
echo "<a href=\"login.php?".SID."&amp;nocache=$nocache\">Login</a>\n";
echo "</small>";
echo "</p></card></wml>";
ob_end_flush();
exit();
}

$user = mysql_fetch_assoc($q);
$id = $user['id'];
$login = $user['login'];
$posts = $user['posts'];
$name = $user['name'];
$admin = $user['moder'];
$ban = $user['ban'];
$boot = $user['boot'];
$ltime = $user['ltime'];
$retime = $user['retime'];
if($ban == "kill")
{
echo "<card newcontext=\"true\" title=\"BANNED\">\n";
echo "<p align=\"$align\">\n";
echo "<small>\n";
echo "Banned:<br/><b>*</b>Your nickname has been banned!\n";
echo "<br/>";
echo "<a href=\"../index.php?".SID."&amp;nocache=$nocache\">Back</a>";
echo "<br/>$copyright";
wml_foot();
@mysql_close();
ob_end_flush();
exit();}
///////////
if($boot == "boot")
{
echo "<card newcontext=\"true\" title=\"BOOTED\">\n";
echo "<p align=\"$align\">\n";
echo "<small>\n";
echo "Booted:<b>*</b>You have been booted as a warning! This may of been the result of you not sticking to the rules you was given at the begining of registration! Please remember you can be banned! You may now log back in again!\n";
echo "<br/>";
echo "<a href=\"index.php?".SID."&amp;nocache=$nocache\">Back</a>";
echo "<br/>$copyright";
wml_foot();
@mysql_close();
ob_end_flush();
exit();}
///////////

$time_update=$retime;
$del_old_let = @mysql_query("DELETE FROM `chat_msg` WHERE `time` < ".(time() - 21*24*3600)." AND `rid`='0';");
print '<card id="Inbox" title="Inbox" ontimer="inbox.php?'.SID.'&amp;nocache='.$nocache.'&amp;rid='.$rid.'"><timer value="'.$time_update.'"/>';
echo "<p align=\"$align\">";
echo "<small>";

$touserid=mysql_fetch_array(mysql_query("SELECT id FROM `chat_users` WHERE login='$touser' limit 1;"));
if($query)$userid=$touserid[0];
$msg = delhtml($msg);
///////////////////////////////////

$q_filter = @mysql_query("select * from `chat_spam`;");
$ftext = $msg ;
$ftext = str_replace(" ", "", $ftext);
$ftext = strtolower($ftext);
while ($get_fword = @mysql_fetch_array($q_filter)) {
$sfilll = $get_fword['word'];
$nosfx = substr_count($ftext,$sfilll);
if ($nosfx>0) {
$spamword = $sfilll;
$msg= '';
$queryaction = mysql_query("update `chat_users` set boot='boot' where id='$id';");
$actiongmessgae="&#169; System ".getlogin($id)." Pvt Spam!";

if($actiongmessgae)$sql = mysql_query("INSERT INTO `chatmsg` VALUES(0, '" . $id . "', '', '" . $actiongmessgae . "', '" . $to . "', '" . $time . "'," . time() . ", '" . $rid . "', '" . $zero . "');");
}
}

$pvt=mysql_fetch_array(mysql_query("SELECT ban FROM `chat_users` WHERE id='$frmid' limit 1;"));

if($pvt[0] == "kill")
{
$msg= '';
$dbmsg=str_replace(''.$dbmsg.'','Blocked',$dbmsg);
}

$smiley=mysql_fetch_array(mysql_query("SELECT smiley FROM chat_users WHERE id='".$id."'"));
if($smiley[0]==0)
{
///////////////////
$sql = "SELECT * FROM chat_smilies";
$smilies = mysql_query($sql);
while($smilie=mysql_fetch_array($smilies))
{
$scode = $smilie[1];
$spath = $smilie[2];
$msg = str_replace($scode,"<img src=\"$spath\" alt=\"$scode\"/>",$msg);
}

$nos = substr_count($msg,"<img src=");
if($nos>1){
$msg= '';
echo "Only 1 Smiley Allowed<br/></small>";
}
}


///////////////////

$query_msg = @mysql_query("select `msg` from `chatmsg` where frmid='".$id."' order by id desc;");
$prevmsg = @mysql_fetch_array($query_msg);

$updatecount = mysql_query("UPDATE `chatmsg` SET `read` = '0' WHERE `toid` = '" . $id . "';");



$acc = mysql_fetch_array(mysql_query("SELECT `acc`, `uid` FROM `pvtset` where (`uid`='".$id."' AND `who`='".$userid."') OR (`who`='".$id."' AND `uid`='".$userid."') order by id desc LIMIT 1"));
if($acc[0]=="1")
{
if(empty($login))$msg= '';
if(!empty($msg) && $msg!=$prevmsg['msg']) {
if(strlen($msg) > 300)$msg= '';

$sql = mysql_query("INSERT INTO `chatmsg` VALUES(0, '" . $id . "', '" . $user[login] . "', '" . $msg . "', '" . $userid . "', '" . $time . "'," . time() . ", '', '1');");
}
}



if($query=="askdel"){
echo "<b>Are you sure you want to delete all your inbox or private messages?</b><br/>";
print '<a href="inbox.php?'.SID.'&amp;nocache='.$nocache.'&amp;rid='.$rid.'&amp;query=delete">YES</a>';
print '<a href="inbox.php?'.SID.'&amp;nocache='.$nocache.'&amp;rid='.$rid.'"> NO</a><br/>';
}
if($query=="delete"){
$delquery = mysql_query("UPDATE `chatmsg` SET roomid = '100' WHERE roomid = '' AND (frmid = '".$id."' OR toid = '".$id."');");
if($delquery)echo "Your Inbox Has Been Cleared !<br/>\n";
}

if($query=="delnotification"){
$idat = "4870";
$delnoti = mysql_query("DELETE FROM `chatmsg` WHERE roomid = '' AND (frmid = '".$idat."' AND toid = '".$id."');");
if($delnoti)echo "Your Notifications cleared.<br/>\n";
}


if($rid) print "<a href=\"room.php?".SID."&amp;nocache=$nocache&amp;rid=$rid\">RM </a>";

if($p) echo "<a href=\"buddy.php?".SID."&amp;nocache=$nocache&amp;room=$room&amp;m=$n&amp;p=1\"> NM</a>";

print '<a href="sendpm.php?'.SID.'&amp;nocache='.$nocache.'&amp;rid='.$rid.'"> PM</a>
<a href="inbox.php?'.SID.'&amp;nocache='.$nocache.'&amp;rid='.$rid.'"> [R]</a>';
print '<a href="inbox.php?'.SID.'&amp;nocache='.$nocache.'&amp;rid='.$rid.'&amp;query=askdel"> [C]</a>';
print '<a href="inbox.php?'.SID.'&amp;nocache='.$nocache.'&amp;rid='.$rid.'&amp;query=delnotification"> CN</a><br/>';
$sql = mysql_query("SELECT COUNT(*) FROM `chatmsg` WHERE roomid = '' AND (frmid = '".$id."' OR toid = '".$id."');");
$all = mysql_result($sql, 0);
if (isset($_GET['s'])) $s = intval($_GET['s']);
else $s = 0;
if ($s < 0) $s = 0;
if ($s > $all) $s = 0;
$ignor = "";

$sql = mysql_query("SELECT * FROM `chat_ignor` WHERE `id` = '" . $id . "';");
while ($ignor_arr = mysql_fetch_array($sql)) {
$ignor .= " `frmid` != '" . $ignor_arr['uid'] . "' AND ";
}
$que = @mysql_query("SELECT `login`,`msg`,`seconds`,`time`,`toid`,`frmid` from `chatmsg` WHERE " . $ignor . " roomid = '' AND (frmid = '".$id."' OR toid = '".$id."') order by seconds desc limit $s,$num_msgsin ;");

while($m = @mysql_fetch_array($que)) {



$dblogin = $m['login'];
$dbmsg = $m['msg'];
$dbtime = ($m['time']);
$toid = $m['toid'];
$frmid = $m['frmid'];
$dbmtime = ($m['seconds']);
$username=mysql_fetch_array(mysql_query("SELECT blah FROM `chat_users` WHERE id='$frmid' limit 1;"));
if($username[0] == "blah") $dbmsg=str_replace(''.$dbmsg.'','Hamba Hamba',$dbmsg);
if(!empty($dbmsg) && $msg!=$prevmsg['dbmsg']) {
if(strlen($dbmsg) > 300)$dbmsg= '';
}
$dbmsg = str_replace("php", "", $dbmsg);
$dbmsg = str_replace("PHP", "", $dbmsg);
$dbmsg = str_replace("HTML", "", $dbmsg);
$dbmsg = str_replace("html", "", $dbmsg);
$dbmsg = str_replace("http", "", $dbmsg);
$dbmsg = str_replace("HTTP", "", $dbmsg);
$dbmsg = str_replace("WWW", "", $dbmsg);
$dbmsg = str_replace("www", "", $dbmsg);


print "<a href=\"user.php?".SID."&amp;nocache=$nocache&amp;rid=$rid&amp;dblogin=$dblogin&amp;rap=inbox\">".getlogin($frmid)."</a>&#187;
<a href=\"user.php?".SID."&amp;nocache=$nocache&amp;rid=$rid&amp;dblogin=".getlogin($toid)."&amp;rap=inbox\">".getlogin($toid)."</a>&#187;".$dbmsg."<br/>";
}



if ($all > $s + $num_msgsin) print "<a href=\"".$_SERVER['PHP_SELF']."?".SID."&amp;nocache=$nocache&amp;rid=$rid&amp;s=" . ($s + $num_msgsin) . "\">Old Privates</a><br/>\n";
if ($s > 0) print "<a href=\"".$_SERVER['PHP_SELF']."?".SID."&amp;nocache=$nocache&amp;rid=$rid&amp;s=" . ($s - $num_msgsin) . "\">&lt;</a><br/>\n";
wml_foot();
@mysql_close();
ob_end_flush();
?>




this one is the inbox file of my website.But the proccess are going very high even more then 25 and creating internal server errors.But even i dont have users also i deleted the messages and i have done everything to solve the problem.I contact with my hosting company hostgator they said php coding error the code is not stoping by it self or running by it self something like that.So can anybody tell me what is the problem in it and how do i will solve it out?

tomws
03-17-2010, 01:23 PM
Nothing jumps out on first glance. I might go to each loop and die() there - see if that might help identify which section of code is the slow or infinite loop part. If that finds the problem area, zoom in there and find the problem.

masterofollies
03-17-2010, 01:31 PM
It can also be in one of your include files, if your pulling a string or value from them for this script.

bijaybd
03-17-2010, 01:37 PM
No the problem was not like that someone was doing massive flood in the inbox sending a lot of message so make limitation for the inbox meassage



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum