Advertisement
Guest User

Untitled

a guest
Oct 10th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.76 KB | None | 0 0
  1.  
  2.  
  3. <?php
  4.  
  5. set_time_limit(0);
  6.  
  7. declare(ticks=1);
  8. class XatBot {
  9.  
  10. private $roomID = "31149180";
  11. private $botName = "ChatAiutoBOT";
  12. private $avatar = "http://i56.tinypic.com/slmvxg.jpg";
  13.  
  14. var $botID = "";
  15. var $homePage = 'http://xat.com/Aiuto';
  16. var $access = array('Davide');
  17. var $k = "";
  18. var $status= "";
  19.  
  20. var $allowAccess = array('723517','356566558','303826285');
  21. var $BotOwner = array('723517');
  22. var $userID = "";
  23. var $joinmsg = "";
  24. var $regName = "ChatAiutoBOT";
  25. var $regPassword = "passworddelbot";
  26. var $regInfo = array();
  27. var $loggedIn = true;
  28.  
  29.  
  30. private $maxKicks = 3;
  31. var $banTime = 3000;
  32. var $spam = array("time"=>10, "limit"=>6);
  33. var $filterWords = true;
  34. var $allowByRank;
  35. var $automember = false;
  36. private $autowelcome = "";
  37. var $autokicknull = false;
  38. var $commands = array();
  39. var $censor = array("");
  40.  
  41. var $gamesAllowed = false;
  42. var $gameRunning = false;
  43. var $gameVar = array();
  44.  
  45. var $debug = false;
  46. var $soc = null;
  47. var $packet = array();
  48. var $users = array();
  49. var $auser = array();
  50. var $doneReached = false;
  51. private $autokick = array("");
  52. var $members = array();
  53. var $handler = array();
  54.  
  55. function login() {
  56. $this->loggedIn = false;
  57. if($this->regName==''||$this->regPassword=='') return;
  58. $postData = "Locked=NC&Login=Login&NameEmail=$this->regName&Pin=0&Protected=NC&UserId=0&cp=&k2=0&mode=0&password=$this->regPassword";
  59. $res = $this->post_request('http://xat.com/web_gear/chat/register.php', $postData, 'http://xat.com/web_gear/chat/register.php');
  60. if($res['status']!='ok') return;
  61. $res = $res['content'];
  62. $this->regInfo['pw'] = $this->getBetween(strtolower($res),strtolower($this->regName)."&pw=",'"');
  63. if($this->regInfo['pw']=='') return;
  64. if($this->soc!=null) socket_close($this->soc);
  65. $this->connect("174.36.242.27","10000");
  66. $this->send('<v n="'.$this->regName.'" p="'.$this->regInfo['pw'].'" />');
  67. $this->read();
  68. print_r($this->packet['v']);
  69. $this->regInfo = $this->packet['v'];
  70. $this->userID = $this->packet['v']['i'];
  71. $this->regName = $this->packet['v']['n'];
  72. if(count($this->regInfo)>4) $this->loggedIn = true;
  73. return true;
  74. }
  75. function run() {
  76.  
  77. if($this->login()!=true){
  78. $this->k = "1970311945";
  79. $this->userID = "363095521";
  80. $this->loggedIn = false;
  81. }
  82. $this->connect("174.36.242.26","10000");
  83. $this->join($this->roomID);
  84. while($this->read()!="DIED");
  85. }
  86.  
  87. function connect($ip, $port) {
  88. $this->soc = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
  89. if(!$this->soc) die(socket_strerror(socket_last_error($this->soc)));
  90. if(!socket_connect($this->soc,$ip,$port)) die("Impossibile connettersi.");
  91. }
  92.  
  93.  
  94. function join($roomID) {
  95. $this->send('<y m="1" />');
  96. while(substr_count($this->read(),'<y')<=0);
  97. if($this->loggedIn) {
  98. $p = "";
  99. if(!empty($this->regInfo['n']))
  100. $this->regInfo['N'] = $this->regInfo['n'];
  101. unset($this->regInfo['n']);
  102. $p .= 'q="1" ';
  103. $p .= 'y="'.$this->packet['y']['i'].'" ';
  104. $p .= 'k="'.$this->regInfo['k1'].'" ';
  105. $p .= 'k3="'.$this->regInfo['k3'].'" ';
  106. if(isset($this->regInfo['d1'])) $p .= 'd1="'.$this->regInfo['d1'].'" ';
  107. $p .= 'z="12" p="0" ';
  108. $p .= 'c="'.$this->roomID.'" ';
  109. $p .= 'f="0" ';
  110. $p .= 'u="'.$this->regInfo['i'].'" ';
  111. $p .= 'm0="671088640" ';
  112. $p .= 'm2="32" ';
  113. $p .= 'd0="'.$this->regInfo['d0'].'" ';
  114. if(isset($this->regInfo['d2'])) $p .= 'd2="'.$this->regInfo['d2'].'" ';
  115. $p .= 'd3="'.$this->regInfo['d3'].'" ';
  116. if(isset($this->regInfo['d4'])) $p .= 'd4="'.$this->regInfo['d4'].'" ';
  117. if(isset($this->regInfo['d5'])) $p .= 'd5="'.$this->regInfo['d5'].'" ';
  118. if(isset($this->regInfo['d6'])) $p .= 'd6="'.$this->regInfo['d6'].'" ';
  119. if(isset($this->regInfo['d7'])) $p .= 'd7="'.$this->regInfo['d7'].'" ';
  120. if(isset($this->regInfo['d8'])) $p .= 'd8="'.$this->regInfo['d8'].'" ';
  121. if(isset($this->regInfo['dO'])) $p .= 'dO="'.$this->regInfo['dO'].'" ';
  122. if(isset($this->regInfo['dx'])) $p .= 'dx="'.$this->regInfo['dx'].'" ';
  123. $p .= 'dt="'.$this->regInfo['dt'].'" ';
  124. $p .= 'N="'.$this->regName.'" ';
  125. $p .= 'n="'.$this->botName.'##'.$this->status.'" ';
  126. $p .= 'a="'.$this->avatar.'" ';
  127. $p .= 'h="'.$this->homePage.'" ';
  128. $p .= 'v="0" ';
  129. $p = trim($p);
  130. $this->send('<j2 '.$p.' />');
  131. $this->sendMessage("$this->joinmsg");
  132. } else {
  133. $this->send('<j2 q="1" y="'.$this->packet['y']['i'].'" k="'.$this->k.'" k3="0" z="12" p="0" c="'.$roomID.'" f="0" u="'.$this->userID.'" d0="0" n="'.$this->botName.'" a="'.trim($this->avatar).'" h="$this->homePage" v="0" />');
  134. }
  135. $this->time = time();
  136. }
  137.  
  138. function send($message) {
  139.  
  140. if($this->debug)echo "->>\t $message\n";
  141. socket_write($this->soc, $message."\0", strlen($message)+1);
  142. }
  143.  
  144.  
  145. function read($parse=true) {
  146. $res = rtrim(socket_read($this->soc, 4096));
  147.  
  148. if($this->debug)echo "<<-\t $res\n";
  149. if(!$res) {
  150. return "DIED";
  151. echo $res." then DIED\n";
  152. }
  153. $this->lastPacket = $res;
  154. if($res{strlen($res)-1}!='>') { $res.=$this->read(false);}
  155. if($parse)$this->parse($res);
  156. return $res;
  157. }
  158. function save($state=1) {
  159.  
  160. $save;
  161. foreach($this as $k=>$v) {
  162. if($k!='soc' && $k != 'users')
  163. $save[$k]=$v;
  164. }
  165.  
  166. }
  167. function loadFromDB($content) {
  168. $content = unserialize($content);
  169. foreach($content as $k=>$v) {
  170. if($k!='debug'&&$k!='roomID'&&$k!='sql')
  171. $this->$k = $v;
  172. }
  173. }
  174. function load() {
  175. try {
  176. $content = unserialize(file_get_contents("XatBot.".$this->roomID));
  177. foreach($content as $k=>$v) {
  178.  
  179. if($k!='debug'&&$k!='roomID')
  180. $this->$k = $v;
  181. }
  182.  
  183. } catch(Exception $e) {
  184.  
  185. }
  186. }
  187. function write2file($fn,$content,$mode='w') {
  188. if(!file_exists($fn)&&stristr($mode,'w')==false) return;
  189. $fp = fopen($fn,$mode);
  190. fwrite($fp,$content);
  191. fclose($fp);
  192. }
  193.  
  194. function get($url, $includeHeader=false) {
  195. $urlp = parse_url($url);
  196. $fp = fsockopen($urlp['host'],80);
  197. $path = explode('/',$url,4);
  198. $path = ((count($path)>=4)?$path[3]:"");
  199. $req = "GET /$path HTTP/1.1\r\n";
  200. $req .= "Host: $urlp[host]\r\n";
  201. $req .= "Connessione: Chiusa\r\n\r\n";
  202. fputs($fp, $req);
  203. $res = "";
  204. while(!feof($fp)) $res .= fgets($fp, 4096);
  205. fclose($fp);
  206. if($includeHeader) return $res;
  207. $res = explode("\r\n\r\n",$res,2);
  208. return $res[1];
  209. }
  210.  
  211. function post_request($url, $data, $referer='') {
  212. $url = parse_url($url);
  213. $host = $url['host'];
  214. $path = $url['path'];
  215. $fp = fsockopen($host, 80, $errno, $errstr, 30);
  216. if ($fp){
  217. fputs($fp, "POST $path HTTP/1.1\r\n");
  218. fputs($fp, "Host: $host\r\n");
  219. if ($referer != '')
  220. fputs($fp, "Referer: $referer\r\n");
  221. fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
  222. fputs($fp, "Content-length: ". strlen($data) ."\r\n");
  223. fputs($fp, "Connessione: Chiusa\r\n\r\n");
  224. fputs($fp, $data);
  225. $res = '';
  226. while(!feof($fp)) {
  227.  
  228. $res .= fgets($fp, 128);
  229. }
  230. }
  231. else {
  232. return array(
  233. 'status' => 'err',
  234. 'error' => "$errstr ($errno)"
  235. );
  236. }
  237. fclose($fp);
  238. $res = explode("\r\n\r\n", $res, 2);
  239. $header = isset($res[0]) ? $res[0] : '';
  240. $content = isset($res[1]) ? $res[1] : '';
  241. return array(
  242. 'status' => 'ok',
  243. 'header' => $header,
  244. 'content' => $content
  245. );
  246. }
  247.  
  248.  
  249. function censor($message) {
  250. $badwords = $this->censor;
  251. $message = @ereg_replace('[^A-Za-z0-9 ]','',strtolower(' '.$message.' '));
  252. foreach($badwords as $bad) {
  253. $bad = trim($bad);
  254. if(strpos($message.' ', $bad.' ')!==false) {
  255. if(strlen($bad)>=2) {
  256. return true;
  257. }
  258. }
  259.  
  260. }
  261.  
  262. }
  263.  
  264. function parse($packet) {
  265. if(substr_count($packet,'>')>1) $packet = explode('/>',$packet);
  266. foreach((Array)$packet as $p) {
  267. $p = trim($p);
  268. if(strlen($p)<5) return;
  269. $type = trim(strtolower(substr($p,1,strpos($p.' ',' '))));
  270. $p = trim(str_replace("<$type",'',str_replace('/>','',$p)));
  271. parse_str(str_replace('"','',str_replace('" ','&',str_replace('="','=',str_replace('&','__38',$p)))),$this->packet[$type]);
  272. foreach($this->packet[$type] as $k=>$v) {
  273. $this->packet[$type][$k] = str_replace('__38','&',$v);
  274. }
  275.  
  276.  
  277. $this->handler['type'] = $type;
  278. $this->handler['msg'] = $p;
  279.  
  280. $this->handle();
  281. }
  282. }
  283.  
  284.  
  285. function handle() {
  286. $type = $this->handler['type'];
  287. $msg = $this->handler['msg'];
  288. switch($type) {
  289. case 'a':
  290. if(strtolower($this->regName)==$this->regName&&$this->loggedIn == true) {
  291. if($this->packet['a']['b']!=$this->userID) return;
  292.  
  293. if(!isset($this->packet['a']['c'])&&empty($this->packet['a']['c'])) {
  294. $value = $this->packet['a']['x'] + ($this->packet['a']['s']*13);
  295. if($value >= 1000) {
  296. $this->sendPrivateChat("",$this->packet['a']['u']);
  297. } else {
  298. $this->sendPrivateChat("",$this->packet['a']['u']);
  299.  
  300. $this->send('<a b="'.$this->packet['a']['u'].'" s="'.$this->packet['a']['s'].'" x="'.$this->packet['a']['x'].'" k="T" m="" p="'.$this->regPassword.'" />');
  301.  
  302. }
  303. } else {
  304.  
  305. socket_close($this->soc);
  306. return;
  307.  
  308. }
  309. }
  310. break;
  311. case 'q':
  312. $this->connect($this->packet['q']['d'], $this->packet['q']['p']);
  313. $this->join($this->roomID);
  314. break;
  315.  
  316. case 'z':
  317. $data['id'] = $this->parseU($this->packet['z']['u']);
  318. $this->send('<z d="'.$data['id'].'" u="'.$this->userID.'" t="/ab" />');
  319. break;
  320.  
  321. case 'o':
  322. $this->users[$this->packet['o']['u']]['name'] = $this->packet['o']['n'];
  323. break;
  324. case 'u':
  325. if(in_array($this->packet['u']['u'],$this->autokick)) {$this->kick("(bye)",$this->packet['u']['u'],true);return;}//Auto-Kick
  326.  
  327. if((!isset($this->packet['u']['q'])||empty($this->packet['u']['q']))&&$this->packet['u']['n']==''){
  328. }
  329. $this->users[$this->packet['u']['u']]['name'] = trim($this->packet['u']['n']);
  330. $this->users[$this->packet['u']['u']]['rank'] = ((empty($this->packet['u']['f']))?0:$this->packet['u']['f']);
  331. $this->users[$this->packet['u']['u']]['regName'] = ((!isset($this->packet['u']['N']))?-1:$this->packet['u']['N']);
  332. $this->users[$this->packet['u']['u']]['messages'] = 0;
  333. $this->users[$this->packet['u']['u']]['time'] = 3600;
  334. if(!isset($this->users[$this->packet['u']['u']]['kicks'])) $this->users[$this->packet['u']['u']]['kicks']=0;
  335. if(!isset($this->packet['u']['f'])||empty($this->packet['u']['f'])||$this->f2rank($this->packet['u']['f']) == 0) {
  336. if(!empty($this->packet['u']['n']))
  337. if($this->automember){
  338. $this->member($this->packet['u']['u']);
  339. return;
  340. }
  341. }
  342. if($this->autowelcome!=''&&!isset($this->packet['u']['s']))$this->sendPrivateMessage($this->autowelcome,$this->packet['u']['u']);
  343. if($this->filterWords) {
  344. $nome = $this->packet['u']['n'];
  345. $smile = substr_count($nome,":)")+substr_count($nome,":d")+substr_count($nome,";)")+substr_count($nome,":o")+substr_count($nome,":p")+substr_count($nome,":@")+substr_count($nome,":s")+substr_count($nome,":$")+substr_count($nome,":(")+substr_count($nome,"|-)");
  346. $nome = str_replace(':)','',$nome);
  347. $nome = str_replace(':d','',$nome);
  348. $nome = str_replace(';)','',$nome);
  349. $nome = str_replace(':o','',$nome);
  350. $nome = str_replace(':p','',$nome);
  351. $nome = str_replace(':@','',$nome);
  352. $nome = str_replace(':s','',$nome);
  353. $nome = str_replace(':$','',$nome);
  354. $nome = str_replace(':(','',$nome);
  355. $nome = str_replace('|-)','',$nome);
  356. $nome = str_replace(strstr ($nome,'(glow'),'',$nome);
  357. $nome = str_replace(strstr ($nome,'(hat'),'',$nome);
  358. $smile = $smile + (substr_count($nome,")")+substr_count($nome,"("))/2;
  359. if($smile > 6) ($this->kick("Massimo 6 smile nel nick", $this->packet['u']['u'],false,true));
  360. }
  361. break;
  362. case 'p':
  363. if(isset($this->packet['p']['d'])) {
  364.  
  365. if($this->packet['p']['t']{0}=='!') {
  366. $info = explode(' ',trim($this->packet['p']['t']),2);
  367. switch(strtolower($info[0])) {
  368. case '!mioid':
  369. $this->sendPrivateChat("Il tuo id è: ".($this->parseU($this->packet['p']['u'])), $this->packet['p']['u']);
  370. break;
  371. }
  372. }
  373. }
  374. break;
  375. case 'm':
  376. if(isset($this->packet['m']['s'])) return;
  377. //Filter words
  378. if($this->filterWords) {
  379. if($this->censor($this->packet['m']['t'])) {
  380. $this->kick("a", $this->packet['m']['u'],false,true);
  381. return;
  382. }
  383. if(substr_count($this->packet['m']['t'],":)")+substr_count($this->packet['m']['t'],":d")+substr_count($this->packet['m']['t'],";)")+substr_count($this->packet['m']['t'],":o")+substr_count($this->packet['m']['t'],":p")+substr_count($this->packet['m']['t'],":@")+substr_count($this->packet['m']['t'],":s")+substr_count($this->packet['m']['t'],":$")+substr_count($this->packet['m']['t'],":(")+substr_count($this->packet['m']['t'],"|-)")+(int)(substr_count($this->packet['m']['t'],"(")+substr_count($this->packet['m']['t'],")")/2) > 3) ($this->kick("No flood, massimo 3 smile", $this->packet['m']['u'],false,true));
  384. }
  385. if((isset($this->packet['m']['u']))&&in_array($this->parseU($this->packet['m']['u']),$this->autokick)) {$this->kick("(bye)",$this->packet['u']['u'],true);return;}
  386.  
  387. if($this->packet['m']['t']{0}=='!') {
  388.  
  389. $info = explode(' ',trim($this->packet['m']['t']),2);
  390. $info[1] = @trim($info[1]);
  391. switch(strtolower($info[0])) {
  392.  
  393. //////////////////////////////////////////////// INIZIO COMANDI PER GLI AIUTI ///////////////////////////////////////////////////////
  394.  
  395. case '!mioid':
  396. $this->sendMessage("Il tuo ID è: ".($this->parseU($this->packet['m']['u'])));
  397. break;
  398.  
  399. case '!creachat':
  400. $this->sendMessage("Per creare una chat clicca sulla parola blu CREACHAT e segui questa guida: http://xat-aiuto.com/come-creare-una-chat-su-xat/");
  401. break;
  402.  
  403. case '!prezzi':
  404. $this->sendMessage("Puoi trovare i prezzi aggiornati di trade qui: xat.mx");
  405. break;
  406.  
  407. case '!playlist':
  408. $this->sendMessage("Per inserire una playlist nella tua chat segui questa guida: http://xat-aiuto.com/come-inserire-una-playlist-nella-tua-chat/");
  409. break;
  410.  
  411. case '!radio':
  412. $this->sendMessage("Per aggiungere una radio nella tua chat segui questa guida: http://xat-aiuto.com/come-aggiungere-una-radio/");
  413. break;
  414.  
  415. case '!interno':
  416. $this->sendMessage("Per inserire uno sfondo interno nella tua chat, segui questa guida: http://xat-aiuto.com/come-cambiare-lo-sfondo-interno-di-una-chat/");
  417. break;
  418.  
  419. case '!esterno':
  420. $this->sendMessage("Per inserire uno sfondo esterno nella tua chat, segui questa guida: http://xat-aiuto.com/come-cambiare-lo-sfondo-esterno-di-una-chat/");
  421. break;
  422.  
  423. case '!registrazione':
  424. $this->sendMessage("Per registrarti su xat clicca sulla parola REGISTER e segui questa guida: http://xat-aiuto.com/come-registrarsi-su-xat/");
  425. break;
  426.  
  427. case '!promote':
  428. $this->sendMessage("Per mettere in promote la tua chat clicca sulla parola blu promote e segui questa guida: http://xat-aiuto.com/promuovere-la-tua-chat/");
  429. break;
  430.  
  431. case '!trade':
  432. $this->sendMessage("Per scambiare xats, days e powers puoi usare le chat apposite: xat.com/Baratto / xat.com/Trade / xat.com/Cambio");
  433. break;
  434.  
  435. case '!stamp':
  436. $this->sendMessage("Per fare uno stamp(screenshot)alla chat puoi seguire questa guida: http://xat-aiuto.com/come-fare-uno-stamp-della-chat/");
  437. break;
  438.  
  439. case '!forumfree':
  440. $this->sendMessage("Per inserire la tua chat su forumfree/forumcommunity od un fan club segui questa guida: http://xat-aiuto.com/integrare-una-chat-di-xat-su-forumfree/");
  441. break;
  442.  
  443. case '!supporto':
  444. $this->sendMessage("Puoi contattare il supporto andando su xat.com/support");
  445. break;
  446.  
  447. case '!sondaggio':
  448. $this->sendMessage("Per insrire un sondaggio nella tua chat segui questa guida: http://xat-aiuto.com/aggiungere-un-sondaggio-alla-chat/");
  449. break;
  450.  
  451. case '!lostpsw':
  452. $this->sendMessage("Per recuperare la password del tuo account su xat segui questa guida: http://xat-aiuto.com/recuperare-la-password-dimenticata/");
  453. break;
  454.  
  455. case '!buy':
  456. $this->sendMessage("Puoi comprare xats e days cliccando sulla parola BUY e seguendo questa guida: http://xat-aiuto.com/come-comprare-xats-e-days-con-postepay/");
  457. break;
  458.  
  459. case '!regole':
  460. $this->sendMessage("Puoi trovare le regole della chat andando su: http://xat.com/Aiuto?p=1 oppure direttamente su: http://util.xat.com/wiki/index.php/Chat_Aiuto");
  461. break;
  462.  
  463. case '!reset':
  464. $this->sendMessage("Se vuoi resettare la tua chat segui questa guida: http://xat-aiuto.com/come-resettare-una-chat/");
  465. break;
  466.  
  467. case '!nuovoid':
  468. $this->sendMessage("Per ottenere un nuovo segui questa guida: http://xat-aiuto.com/come-ottenere-un-nuovo-id-su-xat/");
  469. break;
  470.  
  471. case '!effavatar':
  472. $this->sendMessage("Per aggiungere effetti al tuo avatar segui questa guida: http://xat-aiuto.com/come-aggiungere-effetti-allavatar/");
  473. break;
  474.  
  475. case '!avatar':
  476. $this->sendMessage("Per cambiare avatar(immagine)su xat, clicca su HOST , carica l'immagine dal tuo computer, prendi l'unico link che la pagina ti offre e copialo nel campo Picture.");
  477. break;
  478.  
  479. case '!eliminaccount':
  480. $this->sendMessage("Per eliminare il tuo account segui questa guida: http://xat-aiuto.com/come-eliminare-un-account/");
  481. break;
  482.  
  483. case '!lockedout':
  484. $this->sendMessage("Se il tuo account è bloccato, segui questa guida per fartelo sbloccare http://xat-aiuto.com/come-sbloccare-un-account-bloccato/");
  485. break;
  486.  
  487. case '!effavatar':
  488. $this->sendMessage("Per aggiungere effetti al tuo avatar segui questa guida: http://xat-aiuto.com/come-aggiungere-effetti-allavatar/");
  489. break;
  490.  
  491. case '!xatspace':
  492. $this->sendMessage("Per modificare il tuo profilo vai qui: http://xat.com/web_gear/chat/editprofile.php , inserisci il tuo nome utente e la password e inizia a modificare lo xatspace.");
  493. break;
  494.  
  495. case '!comandi':
  496. $this->sendMessage("I comandi del BOT li trovate su: http://xat-aiuto.com/comandi-bot/");
  497. break;
  498.  
  499. case '!phishing':
  500. $this->sendMessage("Per informazioni sul phishing, http://util.xat.com/wiki/index.php/PhishingIT");
  501. break;
  502.  
  503. case '!animate':
  504. $this->sendMessage("Per convertire la vostra immagine da GIF a PNG andate qui: http://util.xat.com/web_gear/chat/ConvertAnimation.php");
  505. break;
  506.  
  507. case '!cell':
  508. $this->sendMessage("Per usare xat con il tuo cellulare, visita m.xat.com");
  509. break;
  510.  
  511. case '!imgswf':
  512. $this->sendMessage("Le chat di xat ora hanno delle restrizioni riguardanti le immagini e i file flash(swf). Vedi: tinyurl.com/x-timages2");
  513. break;
  514.  
  515. case '!sms':
  516. $this->sendMessage("Per comprare xats e days con il vostro cellulare in Italia seguite questa guida: http://xat-aiuto.com/comprare-xats-e-days-con-il-cellulare/");
  517. break;
  518.  
  519. case '!android':
  520. $this->sendMessage("È possibile utilizzare xat sul tuo cellulare Android. Per più informazioni: http://util.xat.com/wiki/index.php/AndroidIT");
  521. break;
  522.  
  523. //////////////////////////////////////////////// FINE COMANDI PER GLI AIUTI ///////////////////////////////////////////////////////
  524.  
  525. //////////////////////////////////////////////// INIZIO ALTRI COMANDI ///////////////////////////////////////////////////////
  526.  
  527.  
  528. case '!dire':
  529. if(!$this->isAllowed($this->packet['m']['u'],6)) return;
  530. if($info[1]{0}=='/') $this->sendMessage("No.");
  531. if($info[1]{0}=='$') $this->sendMessage("No.");
  532. else $this->sendMessage($info[1]);
  533. break;
  534.  
  535. case '!status':
  536. if(!$this->isAllowed($this->packet['m']['u'])) return;
  537. $this->status = ((trim($info[1])!='')?$info[1]:$this->status);
  538. socket_close($this->soc);
  539. $this->connect("174.36.242.26","10024");
  540. $this->join($this->roomID);
  541. $this->save();
  542. if(empty($info[1])) $this->status = '';
  543. break;
  544.  
  545. case '!nome':
  546. if(!$this->isAllowed($this->packet['m']['u'],6)) return;
  547. $this->botName = ((trim($info[1])!='')?$info[1]:$this->botName);
  548. socket_close($this->soc);
  549. $this->connect("174.36.242.26","10024");
  550. $this->join($this->roomID);
  551. $this->save();
  552. break;
  553.  
  554. case '!8ball':
  555. if(!$this->isAllowed($this->packet['m']['u'],6)) return;
  556. $risposta[] = "Potrebbe essere.";
  557. $risposta[] = "Forse.";
  558. $risposta[] = "No.";
  559. $risposta[] = "Non ne sono sicuro.";
  560. $risposta[] = "Sì.";
  561. $risposta[] = "Nemmeno tra 100 anni.";
  562. $risposta[] = "Non penso.";
  563. $this->sendMessage($risposta[array_rand($risposta)]);
  564. break;
  565.  
  566. case '!off':
  567. if(!$this->isAllowed($this->packet['m']['u'],6)) return;
  568. socket_close($this->soc);
  569. break;
  570.  
  571.  
  572. //////////////////////////////////////////////// FINE ALTRI COMANDI ///////////////////////////////////////////////////////
  573.  
  574. if(array_key_exists(substr(strtolower($info[0]),1),$this->commands)) {
  575. $msg = $this->commands[substr(strtolower($info[0]),1)];
  576. $msg = str_replace('[input]',$info[1],$msg);
  577. $this->sendMessage($msg);
  578. }
  579. }
  580. }
  581.  
  582. break;
  583. }
  584. }
  585.  
  586. function parseU($id) {
  587. if(substr_count($id,'_')>=1) $id = substr($id,0,strpos($id,'_'));
  588. return $id;
  589. }
  590. function inStr($needle, $haystack) {
  591. $needlechars = strlen($needle);
  592. for ($i = 0; $i < strlen($haystack); $i++) if (substr($haystack, $i, $needlechars) == $needle) return true;
  593. return false;
  594. }
  595. function getBetween($content,$start,$end){
  596. $r = explode($start, $content);
  597. if (isset($r[1])){
  598. $r = explode($end, $r[1]);
  599. return $r[0];
  600. }
  601. return '';
  602. }
  603.  
  604. function member($id) {
  605. if(!isset($this->members[$id])||$this->members[$id]<(time()-5)) {
  606. $this->send('<c u="'.$id.'" t="/e" />');
  607. $this->members[$id] = time();
  608. }
  609. }
  610. function kick($message, $id, $silent=false, $log=false) {
  611. if($log) {
  612. if(!empty($this->users[$id]['kicks']) ) $this->users[$id]['kicks']++;
  613. else $this->users[$id]['kicks'] = 1;
  614. }
  615. if($silent)$this->send('<c u="'.$id.'" t="/k" />');
  616. else $this->send('<c p="'.$message." ".$this->users[$id]['kicks'].'/'.$this->maxKicks.'" u="'.$id.'" t="/k" />');
  617. }
  618. function ban($message, $id, $time) {
  619. if(empty($time)) $time = banTime;
  620. $this->send('<c p="'.ereg_replace('[^A-Za-z0-9.! ]','',$message).'" u="'.$this->parseU($id).'" t="/g'.$time.'" />');
  621. }
  622. function unban($id) {
  623. $this->send('<c u="'.$this->parseU($id).'" t="/u" />');
  624. }
  625. function restart() {
  626. socket_close($this->soc);
  627. $this->soc = null;
  628. $this->save();
  629. sleep(1);
  630. if($this->botID == 1)
  631. shell_exec("php XatBot.db.class.php4 $this->botID -null >> log1.txt 2>>err1.txt &");
  632. else
  633. shell_exec("php XatBot.db.class.php4 $this->botID -null > /dev/null 2>/dev/null &");
  634. shell_exec('kill -9 '.getmypid());
  635. }
  636. function sendPrivateChat($message, $id) {
  637. if(empty($message))return;
  638. $this->send('<p u="'.$id.'" t="'.$message.'" s="2" d="'.$this->userID.'" />');
  639. }
  640. function sendPrivateMessage($message,$id) {
  641. $id = $this->parseU($id);
  642. if(empty($message))return;
  643. $this->send('<p u="'.$id.'" t="'.$message.'" />');
  644. }
  645. function sendMessage($message) {
  646. if(empty($message))return;
  647. $this->send('<m t="'.$message.'" u="'.$this->userID.'" />');
  648. }
  649.  
  650. function query_str($params, $out = array()) {
  651. if (!is_array($params) || count($params) == 0) return false;
  652. $fga = func_get_args();
  653. $akey = ( !isset($fga[1]) ) ? false : $fga[1];
  654. foreach ($params as $key => $val) {
  655. if ( is_array($val) ) {
  656. query_str($val,$key, $out);
  657. continue;
  658. }
  659. $thekey = ( !$akey ) ? $key : $akey . '['.$key.']';
  660. $out[] = $thekey."=".$val;
  661. }
  662. return implode("&",$out);
  663. }
  664.  
  665. function isValidURL($url){return $this->inStr('http://',$url);}
  666. function f2rank($f) {
  667. $f = $this->parseU($f);
  668.  
  669.  
  670. if($f==-1) return 0;
  671. if((16 & $f)) return -1;
  672. if((1 & $f)&&(2 & $f)) return 1;
  673. if((4 & $f)) return 3;
  674. if((32 & $f)&&(1 & $f)&&!(2 & $f)) return 5;
  675. if(!(1 & $f)&&!(2 & $f)) return 0;
  676. if((16 & $f)) return -1;
  677. if((2 & $f)&&!(1 & $f)) return 2;
  678. }
  679. function sec2hms($sec, $padHours = false) {
  680.  
  681. $hms = "";
  682. $hours = intval(intval($sec) / 3600);
  683. $hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT) . ':' : $hours . ':';
  684. $minutes = intval(($sec / 60) % 60);
  685. $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':';
  686. $seconds = intval($sec % 60);
  687. $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
  688. return $hms;
  689. }
  690.  
  691.  
  692.  
  693. function isAllowed($id,$min) {
  694. $id = $this->parseU($id);
  695. if (in_array($id,$this->allowAccess)) return true;
  696.  
  697. if($this->allowByRank)if($this->f2rank($this->users[$id]['rank'])>=$min) return true;
  698. }
  699. function botOwner($id) {
  700. $id = $this->parseU($id);
  701. if (in_array($id,$this->BotOwner)) return true;
  702. }
  703. function checkMinRank($id,$min) {
  704. $id = $this->parseU($id);
  705. if (in_array($id,$this->allowAccess)) return true;
  706. if($this->f2rank($this->users[$id]['rank'])>=$min) return true;
  707. return in_array(strtolower($this->users[$id]['regName']),$this->access);
  708. }
  709. }
  710. $bot = new XatBot();
  711.  
  712. while(true) {
  713. try {
  714. $bot->run();
  715. } catch(exception $e) {
  716.  
  717. }
  718. }
  719.  
  720. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement