<?
/*
* WebIcqLite: ICQ messages sender.
* (C) 2006 Grechishkin Alexey, http://snet-group.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* See http://www.gnu.org/copyleft/lesser.html
*
*/
set_time_limit(0);
ignore_user_abort();
chdir("E:\\xampp\\htdocs\\icq\\3\\");
//Some config
//define('UIN', 476010816);
//define('PASSWORD', '12345678');
define('UIN', 417313850);
define('PASSWORD', '9626318');
include("./config.php");
include("./core.php");
include("./protocols/icq.php");
$icq = new WebIcqLite();
class module
{
var $about = 'none';
var $name = 'module';
function main($message,$icq,$cfg){}
}
function load_module($uin=false)
{
global $icq,$lng;
$module = array('modules'=>array());
$d = @dir("./modules/");
if($d)
{
while (false !== ($entry = $d->read()))
{
if($entry!='.' && $entry!='..' && $entry!='modules.php')
{
include_once('./modules/'.$entry);
$entry = basename($entry,'.php');
if(class_exists($entry))
{
$module['modules'][] = $entry;
$module[$entry] = new $entry();
echo("\n".date('Y.m.d H:i:s').' add module "'.$entry.'" ('.$module[$entry]->about.')');
if($uin) $icq->send_message($uin,$lng['cmd']['loadmod'].'"'.$entry.'" ('.$module[$entry]->about.')');
}
}
}
$d->close();
}
return $module;
}
$module = load_module();
function loadlang($message=false)
{
global $icq,$lng;
if($message)
{
$icq->send_message($message[from],$lng['cmd']['langreload']);
}
if(isset($lng)) unset($lng);
$lng = @parse_ini_file((file_exists("./languages/".$cfg['core']['lng'].".lng"))? "./languages/".$cfg['core']['lng'].".lng":"./languages/en.lng", true);
echo("\n".date('Y.m.d H:i:s').' Loaded languge file ("'.(file_exists("./languages/".$cfg['core']['lng'].".lng"))? "".$cfg['core']['lng']:"en".'").');
if(count($lng)<1) die("\nCan not find lng file!");
return $lng;
}
$lng = loadlang();
function closingapp($web=false,$uin=NULL)
{
global $icq,$lng;
if($web==true)
{
$icq->send_message($uin,$lng['cmd']['dissconnect'].$command);
}
echo("\n\nShuting downd in 3 seconds.");
sleep(1);
echo("\nShuting downd in 2 seconds..");
sleep(1);
echo("\nShuting downd in 1 second...");
sleep(1);
echo("\nBie!!");
if($web==true)
{
$icq->send_message($uin,$lng['cmd']['exit'].$command);
}
$icq->disconnect();
exit();
}
//var_dump($lng);
echo("\n\nConnecting... ");
if($icq->connect(UIN, PASSWORD))
{
echo("OK!");
while(true)
{
if($message = $icq->get_message())
{
$mess = $message[message];
$uin = $message[from];
if(substr($mess,0,1) == '!')
{
$command = substr($mess,1,(strpos($mess," "))?strpos($mess," "):strlen($mess));
$mess = trim(substr($mess,strlen($command),strlen($mess)));
if(in_array($command,$module['modules']))
{
$module[$command]->main($message,$icq,$cfg);
}
elseif(($command == 'rebuild') and (in_array($uin, $cfg['core']['adm'])))
{
echo("\n\n-------------------\nRebuilding by ".$uin."\n");
unset($module);
$icq->send_message($uin,$lng['cmd']['modreload']);
$module = load_module($uin);
$icq->send_message($uin,$lng['cmd']['langreload']);
$lng = loadlang($message);
echo("\nRebuilding done!\n-------------------\n");
}
elseif(($command == 'dissconnect') and (in_array($uin, $cfg['core']['adm'])))
{
closingapp(true,$uin);
}
elseif($command == 'login')
{
if(($mess == $cfg['core']['pas']) and (!in_array($uin, $cfg['core']['adm'])))
{
$cfg['core']['adm'][] = $uin;
$icq->send_message($uin,$lng['cmd']['admnow']);
}
else
{
$icq->send_message($uin,$mess."\n".$cfg['core']['pas']);
}
}
elseif($command == 'admins')
{
$icq->send_message($uin,(count($cfg['core']['adm'])>=1)?$lng['msg']['admins'].implode(', ',$cfg['core']['adm']):$lng['msg']['noadmins']);
}
elseif($command == 'uptime')
{
$time = time() - $START_TIME;
$icq->send_message($uin,$lng['msg']['uptime'].$time.$lng['msg']['seconds']);
}
else
{
$icq->send_message($uin,$lng['cmd']['nocmd'].$command);
}
}
else
{
}
}
}
}
else
{
echo("FAIL! =(\n\nShutting down...");
}
closingapp();
?>