Changeset 4 for www/sunrisechat/sunrisechat.php
- Timestamp:
- Jan 14, 2008, 9:48:39 PM (17 years ago)
- Location:
- www
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
www
-
Property svn:ignore
set to
config.php
php_script_error.log
-
Property svn:ignore
set to
-
www/sunrisechat/sunrisechat.php
r1 r4 1 <? 2 include_once('/a/html/is/db.php'); 3 DB_Init('localhost','root','','is');4 DB_Query('SET CHARACTER SET latin2');1 <?php 2 3 include_once('../global.php'); 4 include_once('webchatsend.php'); 5 5 6 $Text2 = getenv('sunrisechat'); 6 $Debug = 0; 7 8 function Packet($Text2) 9 { 10 global $Debug, $Database; 11 //echo("{".$Text2."}".ord($Text2[1]).".".strlen($Text2)."\n"); 12 //echo($Text2.strlen($Text2)."\n"); 7 13 $Text = StrTr($Text2, "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 14 if(strlen($Text) > 1) 15 { 8 16 $Parts = explode('|',$Text); 17 $TargetIP = $Parts[1]; 18 $TargetID = $Parts[2]; 9 19 $SenderIP = $Parts[3]; 10 20 $SenderID = $Parts[4]; … … 16 26 $RoomName = $Parts[9]; 17 27 $RoomType = $Parts[10]; 18 echo('Message: '.$Text);19 DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');20 if( DB_NumRows()>0)28 if($Debug == 1) echo('Message: '.$Text."\n"); 29 $DbResult = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"'); 30 if($DbResult->num_rows > 0) 21 31 { 22 $Row = DB_Row();32 $Row = $DbResult->fetch_array(); 23 33 $Nick = $Row['nick']; 24 34 } else $Nick = ''; 25 DB_Insert('sunrisechat_history',array('time' => 'NOW()', 'nick' => addslashes($Nick), 'text' => addslashes(htmlspecialchars($Text)), 'color' => $Color, 35 echo('<'.$Nick.'>'.$Text." ".addslashes($Text)."\n"); 36 $Database->insert('sunrisechat_history',array('time' => 'NOW()', 'nick' => $Nick, 'text' => $Text, 'color' => $Color, 26 37 'roomname' => $RoomName, 'roomtype' => $RoomType)); 38 } 39 if($Command == 'Alive') 40 { 41 $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"'); 42 if($DbResult->num_rows() > 0) 43 { 44 $Row = $DbResult->fetch_array(); 45 $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()')); 46 } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID)); 47 } 48 if($Command == 'GoOnline') 49 { 50 $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"'); 51 if($DbResult->num_rows() > 0) 52 { 53 $Row = $DbResult->fetch_array(); 54 $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'status' => 'Online')); 55 } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'status' => 'Online')); 56 } 57 if($Command == 'GoAway') 58 { 59 $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"'); 60 if($DbResult->num_rows() > 0) 61 { 62 $Row = $DbResult->fetch_array(); 63 $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'status' => 'Away')); 64 } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'status' => 'Away')); 27 65 } 28 66 if($Command == 'UserInfo') 29 67 { 30 68 $Nick = $Parts[7]; 31 echo('UserInfo: '.$Nick );32 DB_Select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"');33 if( DB_NumRows()>0)69 echo('UserInfo: '.$Nick."\n"); 70 $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$SenderID.' AND sender_ip="'.$SenderIP.'"'); 71 if($DbResult->num_rows() > 0) 34 72 { 35 $Row = DB_Row();36 DB_Update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'nick' => $Nick));37 } else DB_Insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'nick' => $Nick, 'sender_ip' => $SenderIP, 'sender_id' => $SenderID));73 $Row = $DbResult->fetch_array(); 74 $Database->update('sunrisechat_onlinelist','sender_ip="'.$SenderIP.'" AND sender_id='.$SenderID,array('lasttime' => 'NOW()', 'nick' => $Nick, 'operating_system' => $Parts[12], 'status' => $Parts[10])); 75 } else $Database->insert('sunrisechat_onlinelist',array('lasttime' => 'NOW()', 'nick' => $Nick, 'sender_ip' => $SenderIP, 'sender_id' => $SenderID, 'operating_system' => $Parts[12], 'status' => $Parts[10])); 38 76 } 77 if($Command == 'WhoIs') // for WebSunriseChat support 78 { 79 $Result = $Database->select('sunrisechat_onlinelist','*','sender_id='.$TargetID.' AND sender_ip="'.$TargetIP.'" AND operating_system="Fedora Core 2"'); 80 if($DbResult->num_rows() > 0) 81 { 82 $Row = $DbResult->fetch_array(); 83 $_SESSION['DetailInfo'] = $Row['info']; 84 $Nick = $Row['nick']; 85 $_SESSION['nick'] = $Nick; 86 $_SESSION['IP'] = $Row['sender_ip']; 87 $_SESSION['ID'] = $Row['sender_id']; 88 $_SESSION['sequence'] = $Row['sequence']; 89 Send('UserInfo',''); 90 if($Debug == 1) echo('UserInfo: '.$Nick."\n"); 91 } 92 } 93 } 94 //DB_Select('sunrisechat_onlinelist','UNIX_TIMESTAMP(lasttime)'); 95 //$Row = DB_Row(); 96 //echo($Row[0]-(time()-200)."\n"); 97 DB_Delete('sunrisechat_onlinelist','UNIX_TIMESTAMP(lasttime)<'.(time()-30)); 98 } 99 100 $Filename = '/tmp/sunrisechatout'; 101 $Filename2 = '/tmp/sunrisechatin'; 102 $File2 = fopen($Filename2,'w'); 103 while(1) 104 { 105 if(file_exists($Filename)) 106 { 107 $File = fopen($Filename,'r'); 108 $Data = fread($File,65000); 109 fclose($File); 110 unlink($Filename); 111 //echo($Data); 112 $Rows = explode("\n",$Data); 113 array_pop($Rows); 114 foreach($Rows as $Item) 115 { 116 Packet($Item); 117 //echo($Item."\n"); 118 } 119 } 120 sleep(5); 121 } 39 122 40 123 ?>
Note:
See TracChangeset
for help on using the changeset viewer.