View file v0.01a/icqtalk.php

File size: 2.3Kb
<?
// Wapmess, originally developed by Gцran (depeh) Johansson, Sweden
//
// Feel free to improve this program in any way you can, but please share your version!
// More info and the latest version is avaiable at:
// http://sourceforge.net/projects/wapmess/

#$debug=1;
require("icqlib.php");

$my_uin=$_SERVER["argv"][1];

# Koppla upp mot databasservern
$db = mysql_connect($db_server, $db_user, $db_pass);

# Vдlj DATABAS
mysql_select_db($db_name);

$query="SELECT * FROM cookies WHERE uin='".$my_uin."'";

$sqlres=mysql_query($query) or die("send_alive Invalid query: " . mysql_error());
$num_rows = mysql_num_rows($sqlres);

if ($num_rows==1)
	{
		$row = mysql_fetch_array($sqlres);
		print "i=".$row["ip"]."\n";
		print "p=".$row["port"]."\n";
		print "c=".$row["cookie"]."\n";
		print "u=$my_uin<br>";
		
		$srv_cookie_a["port"]=$row["port"];
		$srv_cookie_a["ip"]=$row["ip"];
		$srv_cookie_a["cookie"]=h2b($row["cookie"]);
	}
else
	{
		print "KAN INTE HITTA COOKIE-UPPGIFTER!! FEL!!";
		exit;
	}

// Skicka bevis att "servern" lever fцr just ditt uin
send_alive($my_uin);

// Logga in fцr andra gеngen
icq_login_cookie($srv_cookie_a);

// Skicka bevis att "servern" lever fцr just ditt uin
send_alive($my_uin);

icq_receive_incoming();	
icq_receive_incoming();	

// Skicka bevis att "servern" lever fцr just ditt uin
send_alive($my_uin);

// Hдmta OFFLINE-meddelanden
$msgs=icq_get_msgs($my_uin);

icq_receive_incoming();
icq_receive_incoming();

// Resetta timern
$nowtime=time();
$timeend = $nowtime+$timeout_seconds;
$ltimeleft=-1;

// Hеll pе tills timer rinner ut
while ($nowtime < $timeend)
	{

		// Rдkna ut hur lеng tid som дr kvar
		$nowtime=time();
		$timeleft = $timeend - $nowtime;
		
		// Kolla om vi ska skriva ut hur mеnga sekunder som дr kvar		
		if ($timeleft%$server_action_rate==0 && $ltimeleft!=$timeleft)
			{
			 #print "seconds until timeout... ".$timeleft."\n";
				$ltimeleft=$timeleft;
				
				// Skicka alla ev. nya meddelanden
				icq_send_msgs();
				
				// Skicka bevis att "servern" lever fцr just ditt uin
				send_alive($my_uin);
				
				// Skicka status-lista till databas pе servern
				send_status_list($uin_status);
				
				icq_receive_incoming();
			}
		
		// Ta emot och parsa data som kommer in
		#icq_receive_incoming();		
		
	}

cli_sendoffline_ack();
fclose($fp);
print "TIMEOUTED...";
?>