Posted by rey Wed 7th Mar 2007 13:28 - Syntax is PHP - 17 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
PHP parser reported no syntax errors in this post!
-
-
//For AJAX!!
-
-
$chatpage="chat.xml";
-
{
-
$send=$_POST['send'];
-
}
-
else
-
{
-
$send=3;
-
}
-
$post=0;
-
$showchat=0;
-
$json= '';
-
-
-
if ($send=='1') // If somebody SENT a message
-
{
-
$message= $_POST['message'];
-
$post=1;
-
}
-
elseif ($send=='2') // If somebody wants ALL messages
-
{
-
$showchat='all';
-
}
-
elseif ($send=='3') // If somebody wants NEW messaages
-
{
-
{
-
$last=$_SESSION['lastid'];
-
}
-
else //should never happen... but who knows
-
{
-
$last=$_POST['last_id'];
-
$_SESSION['lastid']=$last;
-
}
-
$showchat='new';
-
}
-
-
-
$user="guest";
-
$password="fottilaetispiezoindue";
-
$database="naerey";
-
$server='switch-case.org';
-
-
if ($post)
-
{
-
'woot','rofl','ouch','lol','love','<3','lmao');
-
'','',
-
'','',
-
'','',
-
'','',
-
'','',
-
'','',
-
'','',
-
'','');
-
//Smileys!
-
-
$ip_=$_SERVER['REMOTE_ADDR'];
-
$query="INSERT INTO `chat_history` values ( '', '$ip_', '$date_', '$time_', '$name', '$message')";
-
-
$query ="INSERT INTO chat_users VALUES ('$ip_', '$date_', '$time_', '$name', '1') ";
-
$query.="ON DUPLICATE KEY UPDATE date='$date_',time='$time_',posts=posts+1,name='$name' ";
-
}
-
-
-
if ($showchat=='all')
-
{
-
$query="SELECT id,name,message,time FROM ( SELECT id,name,message,time FROM ";
-
$query.="chat_history ORDER BY id DESC LIMIT 10 ) AS tmp ORDER BY id";
-
$i=0;
-
while ($i < $num)
-
{
-
$json.= "\n
$_time $_name: $_message
"; -
++$i;
-
}
-
-
$ip_=$_SERVER['REMOTE_ADDR'];
-
$query ="INSERT INTO chat_users VALUES ('$ip_', '$date_', '$time_', '$name', '1') ";
-
$query.="ON DUPLICATE KEY UPDATE date='$date_',time='$time_',name='$name' ";
-
}
-
elseif($showchat=='new')
-
{
-
$query="SELECT id,name,message,time FROM chat_history WHERE id>$last";
-
$i=0;
-
while ($i < $num)
-
{
-
if ($_name==$name)
-
{
-
$_name='You';
-
}
-
$json.= "\n
$_time $_name: $_message
"; -
++$i;
-
}
-
-
$ip_=$_SERVER['REMOTE_ADDR'];
-
$query ="INSERT INTO chat_users VALUES ('$ip_', '$date_', '$time_', '$name', '1') ";
-
$query.="ON DUPLICATE KEY UPDATE date='$date_',time='$time_'";
-
}
-
-
-
if(!$post){$query="SELECTmax(id)FROMchat_history";$result=mysql_query($query,$link);$id=mysql_result($result,0,"max(id)");$users='';$_date=date("d/m/y");$_time=date("His")-14;$users="
- "
.'"'.$_user.'"'.")'>$_user";++$i;}if(!$num){$users.="\n - none
";}$users.="\n";$end_time=microtime(true)-$start_time;$total_time=number_format($end_time,4);$jsonObj=array('dowhat'=>$send,'chat'=>$json,'last_id'=>$id,'users'=>$users,'time'=>$total_time);$_SESSION['lastid']=$id;}else{$end_time=microtime(true)-$start_time;$total_time=number_format($end_time,4);$jsonObj=array ('dowhat'=>'1','time'=>$total_time);}mysql_close();echo json_encode($jsonObj);?>
PermaLink to this entry https://pastebin.co.uk/11525
Posted by rey Wed 7th Mar 2007 13:28 - Syntax is PHP - 17 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
Comments: 0