Просмотр файла v0.01a/index.php

Размер файла: 2.17Kb
<?
// 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=$_REQUEST["u"];
$my_pwd=$_REQUEST["p"];

srand((double) microtime() * 1000000); 

if (!$my_uin || !$my_pwd)
	{
		wml_header();xml_header();
		die("<wml>\n<card id=\"card1\">\n<p>ERROR! No USER or PASSWORD stated!</p>\n</card>\n</wml>");		
	}

// Logga in fцrsta gеngen
$srv_cookie_a=icq_login($my_uin,$my_pwd);

if ($srv_cookie_a==false)
	{
		//print "ERROR! COULD NOT CONNECT";
		wml_header();xml_header();
		die("<wml><card id=\"card1\"><p>ERROR! Could not connect!</p></card></wml>");
		//exit;
	}
	
if ($srv_cookie_a["port"]=="")
	{
		//print "ERROR! ".$srv_cookie_a["ip"];
		wml_header();xml_header();
		die("<wml><card id=\"card1\"><p>ERROR! Server returned: ".$srv_cookie_a["ip"]."</p></card></wml>");
		//exit;
	}

$hcookie=b2h($srv_cookie_a["cookie"]);


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

# Vдlj DATABAS
mysql_select_db($db_name);

$query="SELECT uin FROM cookies WHERE uin='".$my_uin."'";
#print "sql = $query\n";

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

if ($num_rows>0)
	{
		$query="UPDATE cookies SET cookie='".$hcookie."', ip='".$srv_cookie_a["ip"]."', port='".$srv_cookie_a["port"]."' WHERE uin=".$my_uin."";
		$updres=mysql_query($query) or die("send_alive Invalid query: " . mysql_error());
	}
else
	{
		$query="INSERT INTO cookies (uin,cookie,ip,port) VALUES ('".$my_uin."','".$hcookie."','".$srv_cookie_a["ip"]."','".$srv_cookie_a["port"]."')";
		$insres=mysql_query($query) or die("send_alive Invalid query: " . mysql_error());
	}

$nocache_no=rand(10000, 99999);

// ANROPAR icqtalk servern
$tmp=exec($php_cli_home."bgrun ".$php_cli_home."php -q ".$SCRIPT_PATH."/icqtalk.php ".$my_uin." >nul",$res);

header("Location: $wwwpath/main.php?u=$my_uin&p=$my_pwd&$nocache_no");
wml_header();
?>