function pfopen($filename, $mode = 'r') { if ($this->has_gzip) { return gzopen($filename, $mode); } return pfopen($filename, $mode); }
function analize_packet($packet) { $nol = $GLOBALS['nol']; $socket = $GLOBALS['socket']; $socket2 = $GLOBALS['socket2']; $address = $GLOBALS['address']; $port = $GLOBALS['port']; //$channel=$GLOBALS['channel']; $nick = $GLOBALS['nick']; $oldmessage = $GLOBALS['oldmessage']; $hostt = $GLOBALS['hostt']; $adminip = $GLOBALS['adminip']; $sex = $GLOBALS['sex']; $ES = $GLOBALS['ES']; $here = $GLOBALS['here']; $dbname = $GLOBALS['dbname']; $wow_characters_dbname = $GLOBALS['wow_characters_dbname']; $dbcnx = $GLOBALS['dbcnx']; $n = 0; $word = ""; $packet = @iconv("UTF-8", "windows-1251", $packet); for ($i = 11; $i <= strlen($packet) - 1; $i++) { if ($packet[$i] != $nol) { $word .= $packet[$i]; } else { $parts[] = $word; $word = ""; $n++; } } $channel = $parts[0]; $GLOBALS['channel'] = $channel; if ($word != "") { $parts[$n] = $word; } $flag = $packet[10]; $here[$hostt]['time'] = date('l dS \\of F H:i:s'); $GLOBALS['here'] = $here; //записи для !seen switch ($flag) { case '0': //кто тут? $msg = 'X' . rcode() . '1' . $parts[0] . $nol . $nick . $nol . '11'; if ($ES == 1) { socket_sendto($socket, $msg, strlen($msg), 0, $hostt, $port); } break; case 'L': //кто тут? $msg = 'X' . rcode() . 'K' . $parts[0] . $nol . $channel . $nol . $nick . $nol . '11'; if ($ES == 1) { socket_sendto($socket, $msg, strlen($msg), 0, $address, $port); } break; case '2': //строка в чате $words = Explode(" ", $parts[2]); $words[0] = strtolower($words[0]); if ($oldmessage != $parts[2] && $parts[1] != $nick) { if (@mysql_select_db($dbname, $dbcnx)) { mysql_query("INSERT INTO messages VALUES(0, now(), '{$parts['1']}', '{$parts['0']}', '{$parts['2']}');"); } } if ($parts[1] != $nick) { if ($parts[0] == "#Main") { fputs($socket2, "PRIVMSG " . "#vypress" . " :" . chr(2) . $parts[1] . chr(2) . ": " . str_replace(array(chr(10), chr(13)), ' - ', $parts[2]) . "\n"); } } $oldmessage = $parts[2]; //админские команды if ($words[0] == '!fixdb' && $hostt == $adminip) { mysql_query("REPAIR TABLE messages;"); send_answer("FiXed"); } if ($words[0] == '!clean' && $hostt == $adminip) { mysql_query("TRUNCATE TABLE `messages`;"); send_answer("Cleaned"); } if ($words[0] == '!enter' && $hostt == $adminip) { $msg = 'X' . rcode() . '4' . $nick . $nol . $channel . $nol . '0' . $sex; socket_sendto($socket, $msg, strlen($msg), 0, $address, $port); $GLOBALS['ES'] = 1; } if ($words[0] == '!exit' && $hostt == $adminip) { $msg = 'X' . rcode() . '5' . $nick . $nol . $channel . $nol . '0' . $sex; socket_sendto($socket, $msg, strlen($msg), 0, $address, $port); $GLOBALS['ES'] = 0; } if ($words[0] == '!?' && $hostt == $adminip) { $res = `nmap -p 42323 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 42323/open | cut -f1 | awk '{ print \$2 }'`; send_answer("Доступные хайд-сервера: \n" . $res, 0); $res = `nmap -p 45206 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 45206/open | cut -f1 | awk '{ print \$2 }'`; send_answer("Доступные avin hide [45206] сервера: \n" . $res, 0); } if ($words[0] == '!dos' && $hostt == $adminip && !empty($words[1]) && !empty($words[2])) { $arp_robin = $words[1]; $arp_batman = $words[2]; send_answer("In action! Wait 10 sec", 0); $res = `arp-sk -c 5 -i eth1 -r -d {$arp_robin} -S {$arp_batman} --rand-arp-hwa-src -D {$arp_robin}`; send_answer("Finished!", 0); } //----------------- if ($words[0] == '!date' || $words[0] == '!time') { send_answer(date("D M j H:i:s Y")); } if ($words[0] == '!radio' || $words[0] == '!радио') { send_answer(RadioStat(), 0); } if ($words[0] == '!l2' || $words[0] == '!линейка' || $words[0] == '!л2' || $words[0] == '!lineage') { send_answer(l2Stat(), 0); } if ($words[0] == '!s' || $words[0] == '!поиск') { file_search($words[1]); } if ($words[0] == '!free') { send_answer('1: ' . system('df -h|grep -w /dev/hda1|awk \'{print $4}\'') . ' 2: ' . system('df -h|grep -w /dev/md0|awk \'{print $4}\'')); } if ($words[0] == '!who' || $words[0] == '!кто') { $res = `netstat -tun | grep "192.168.0." |awk '{ print \$4 "\t-\t" \$5}'`; $res = str_replace(":21", ":FTP", $res); $res = str_replace(":22", ":xxx", $res); $res = str_replace(":80", ":WEB", $res); $res = str_replace(":139", ":SMB", $res); $res = str_replace(":445", ":SMB", $res); $res = str_replace(":6667", ":IRC", $res); $res = str_replace(":10000", ":xxx", $res); send_answer("Сетевая нагрузка на сервер: \n" . $res, 0); } #---сканироваие портов if ($words[0] == '!dota' || $words[0] == '!дота') { send_answer("(O) [Поиск...] (O)", 0); $res = `nmap -p 6112 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 6112/open | cut -f1 | awk '{ print \$2 }'`; send_answer("Сейчас в доту играют: \n" . $res, 0); } if ($words[0] == '!bf' || $words[0] == '!бф') { send_answer("(O) [Поиск...] (O)", 0); $res = `nmap -sU -p 22000 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep '22000/open/udp' | cut -f1 | awk '{ print \$2 }'`; send_answer("Сейчас в бф играют: \n" . $res, 0); } if ($words[0] == '!cs' || $words[0] == '!кс') { send_answer("(O) [Поиск...] (O)", 0); $res = `nmap -sU -p 27015 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep '27015/open/udp' | cut -f1 | awk '{ print \$2 }'`; send_answer("Сейчас в кс играют: \n" . $res, 0); } //if ($words[0]=='!wow') {send_answer("(O) [Поиск...] (O)",0); $res=`nmap -p 3724 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 3724/open | cut -f1 | awk '{ print $2 }'` ;send_answer("Онлайн сервера WoW: \n".$res,0);} if ($words[0] == '!http') { send_answer("(O) [Поиск...] (O)", 0); $res = `nmap -p 80 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 80/open | cut -f1 | awk '{ print \$2 }'`; send_answer("Доступные веб-сервера: \n" . $res, 0); } if ($words[0] == '!ftp') { send_answer("(O) [Поиск...] (O)", 0); $res = `nmap -p 21 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 21/open | cut -f1 | awk '{ print \$2 }'`; send_answer("Доступные фтп-сервера: \n" . $res, 0); } if ($words[0] == '!smb') { send_answer("(O) [Поиск...] (O)", 0); $res = `nmap -p 445 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 445/open | cut -f1 | awk '{ print \$2 }'`; send_answer("Доступные шары: \n" . $res, 0); } //if ($words[0]=='!vnc') {send_answer("(O) [Поиск...] (O)",0); $res=`nmap -p 5900 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 5900/open | cut -f1 | awk '{ print $2 }'` ;send_answer("Доступные VNC-сервера у: \n".$res,0);} if ($words[0] == '!inet') { send_answer("(O) [Поиск...] (O)", 0); $res = `nmap -p 1723 -n -P0 --open --min_parallelism 100 --max_scan_delay 0 -oG - 192.168.0.1-254 | grep 1723/open | cut -f1 | awk '{ print \$2 }'`; send_answer("В инете лазят: \n" . $res, 0); } if ($words[0] == '!scanme') { send_answer("[Сканирование...]", 0); $res = `nmap {$hostt}`; send_answer("Результат сканирования: \n" . $res, 0); } #------поиск инфы-- if ($words[0] == '!seen') { if (!empty($here[$words[1]])) { send_answer("Я видел его в " . $here[$words[1]]['time'] . ". Ник: " . $here[$words[1]]['name'] . " Напиздаболил " . $here[$words[1]]['numwords'] . " слов. Последняя фраза: " . $here[$words[1]]['say'], 0); } else { send_answer("Я таких не видел", 0); } } //if ($words[0]=='!info') {if (!empty($words [1])) {$id=$words [1]; $msg = mysql_query ("SELECT * FROM ip WHERE id LIKE '$id';"); if (mysql_num_rows ($msg)>0) {$message = mysql_fetch_array($msg); send_answer("IP: ".$message['id'].", Поганяло: ".$message['name'].", По паспорту: ".$message['fio'].", Адресс: ".$message['adress'].", Тел. мобильный: ".$message['mob'].", Тел. дом.: ".$message['dom'],0); }else send_answer("Я таких не знаю.",0);}else send_answer("Укажи IP.",0); } #-------quests----- //if (($words[0]=='!q')&&($parts[0]=="#vic")) {send_answer("Вопрос викторины: ".$GLOBALS['q_quest']);} if ($parts[2] == $GLOBALS['q_answer'] && $parts[0] == "#vic") { $here[$hostt]['qpoints']++; send_answer("(*) Верный ответ, {$parts['1']}! Вы зарабатываете " . $here[$hostt]['qpoints'] . " очков"); $GLOBALS['answer_nums'] = 0; quest(); } //if ($parts[0]=="#vic") {$GLOBALS['answer_nums']++; if ($GLOBALS['answer_nums']>15) {send_answer("Никто не дал правильного ответа"); quest (); $GLOBALS['answer_nums']=0;}} if ($parts[0] == "#vic" && $words[0] == '!stat') { send_answer("У вас " . $here[$hostt]['qpoints'] . " очков.", 0); } #------ForumStat--- if ($words[0] == '!forum' || $words[0] == '!форум') { $forum_base = "forum"; $forum_rusult = "Обсуждаемые темы: "; if (@mysql_select_db($forum_base, $dbcnx)) { $query = "SELECT threadid,lastposter,title,dateline,userid FROM thread LEFT JOIN user ON (thread.lastposter=user.username) ORDER BY dateline DESC LIMIT 5"; $forum_db_rusult = mysql_query($query, $dbcnx); while ($row = mysql_fetch_array($forum_db_rusult)) { $forum_rusult .= "\n" . $row['title'] . " "; $forum_rusultult .= "[" . $row['lastposter'] . "] "; $forum_rusult .= date("d.m-H:i", $row['dateline']); } send_answer($forum_rusult, 0); //- DO NOT CHANGE } } if ($words[0] == '!n' || $words[0] == '!н' || $words[0] == '!news' || $words[0] == '!новости') { rssread(); } if ($words[0] == '!w' || $words[0] == '!п' || $words[0] == '!погода' || $words[0] == '!weather') { $weather_result = $GLOBALS['weather_result']; if ($weather_result == '') { //adv88=0&adv120=0&town=Владимир&townen=Vladimir&townua=Володимир&date=27&month=9&day=7&wparam1=34036&wparam2=1940756.92&s1=43&s2=43&wt=6&ecv=1& if (!($in = pfopen("http://img.gismeteo.ru/flashinf/FLA27532.TXT"))) { $web_result = "Служба временно недоступна!"; } else { $paars = split('&', $in); foreach ($paars as $paar) { list($parametr, $value) = split('=', $paar); $var[$parametr] = $value; } $t2 = ($var['wparam1'] - 17000 * intval($var['wparam1'] / 17000)) / 9; $t1 = intval($var['wparam1'] / 17000); $town = $var['town']; $hum = intval(($var['wparam2'] - intval($var['wparam2'])) * 100 + 1.8); //влажность $wparam2 = intval($var['wparam2']); $pres = intval($wparam2 / 10000) + 550; //давление $wparam2 = $wparam2 - intval($wparam2 / 10000) * 10000; $ws = intval($wparam2 / 100) - 5; // скорость ветра $wparam2 = $wparam2 - intval($wparam2 / 100) * 100; $wdindx = $wparam2 / 7 - 3; $weather_result = $weather_result . "Погода города " . $town; $weather_result = $weather_result . ". Температура " . $t1 . " - " . $t2 . "°C"; $weather_result = $weather_result . ". Влажность " . $hum . "%"; $weather_result = $weather_result . ". Давление " . $pres . "мм рт/ст"; $weather_result = $weather_result . ". Ветер " . $ws . "м/c"; } } if ($weather_result == '') { $weather_result = 'Чё?'; } send_answer($weather_result, 0); //- DO NOT CHANGE $GLOBALS['weather_result'] = $weather_result; } if ($words[0] == '!last' || $words[0] == '!ласт' || $words[0] == 'ласт') { $forum_base = "forum"; $forum_rusult = "5 Свежих сообщений на фоурме:\n"; //$forum_link = mysql_connect($host,$user,$pass)or die("Не могу соединиться"); if (@mysql_select_db($forum_base, $dbcnx)) { $query = "select a.postid, a.username, a.pagetext, b.title from post a, thread b where a.threadid = b.threadid ORDER BY postid DESC LIMIT 0,5"; $forum_db_rusult = mysql_query($query, $dbcnx); while ($row = mysql_fetch_array($forum_db_rusult)) { $row['pagetext'] = str_replace("\r\n", "", $row['pagetext']); $row['pagetext'] = str_replace("\n", "", $row['pagetext']); $forum_rusult .= "(E) [" . $row['username'] . "] <" . $row['title'] . "> \n\t" . $row['pagetext'] . "\n"; } send_answer($forum_rusult, 0); } } #------- WoW------- if ($words[0] == '!wow' || $words[0] == '!вов') { $ho_string = ""; $al_string = ""; if (@mysql_select_db($wow_characters_dbname, $dbcnx)) { $msg = mysql_query("select * FROM `characters` WHERE `online` = 1;"); if ($msg) { while ($message = mysql_fetch_array($msg)) { $name = $message['name']; $race = $message['race']; $class = $message['class']; $mapid = $message['map']; $pos_x = $message['position_x']; $pos_y = $message['position_y']; $dbdata = explode(" ", $message['data']); $lvl = $dbdata[34]; $al = 0; $ho = 0; //Идентификация рассы и прочей лабуды if ($race == 1) { $al++; $flag = 1; $race = "Человек"; } if ($race == 2) { $ho++; $flag = 2; $race = "Орк"; } if ($race == 3) { $al++; $flag = 1; $race = "Карлик"; } if ($race == 4) { $al++; $flag = 1; $race = "Ночной эльф"; } if ($race == 5) { $ho++; $flag = 2; $race = "Нежить"; } if ($race == 6) { $ho++; $flag = 2; $race = "Таурен"; } if ($race == 7) { $al++; $flag = 1; $race = "Гном"; } if ($race == 8) { $ho++; $flag = 2; $race = "Тролль"; } if ($race == 10) { $ho++; $flag = 2; $race = "Кровавый эльф"; } if ($race == 11) { $al++; $flag = 2; $race = "Дрэней"; } if ($class == 1) { $class = "Воин"; } if ($class == 2) { $class = "Паладин"; } if ($class == 3) { $class = "Охотник"; } if ($class == 4) { $class = "Разбойник"; } if ($class == 5) { $class = "Священник"; } if ($class == 7) { $class = "Шаман"; } if ($class == 8) { $class = "Маг"; } if ($class == 9) { $class = "Колдун"; } if ($class == 11) { $class = "Друид"; } $loc = get_zone_name($mapid, $pos_x, $pos_y); if ($flag == 2) { $ho_string = $ho_string . " {$name} [{$race}/{$class}] lvl: {$lvl} Локация: {$loc}\n"; } if ($flag == 1) { $al_string = $al_string . " {$name} [{$race}/{$class}] lvl: {$lvl} Локация: {$loc}\n"; } } if ($al_string == "") { $al_string = " Никто не играет"; } if ($ho_string == "") { $ho_string = " Никто не играет"; } send_answer("On-line игроки: \n\n Альянс:\n{$al_string}\n Орда:\n{$ho_string}", 0); } } //@mysql_select_db($dbname,$dbcnx); } if ($words[0] == '!top' || $words[0] == '!топ') { $top = ""; $x = 1; if (@mysql_select_db($wow_characters_dbname, $dbcnx)) { $msg = mysql_query("select `name`, `totaltime`, `data`, `online`, `map`, `position_x`, `position_y` FROM `characters` ORDER BY `totaltime` DESC;"); if ($msg) { while ($message = mysql_fetch_array($msg)) { $mapid = $message['map']; $pos_x = $message['position_x']; $pos_y = $message['position_y']; $dbdata = explode(" ", $message['data']); $lvl = $dbdata[34]; if (round($message['totaltime'] / (60 * 60)) > 50) { if ($message['online'] == 1) { $loc = get_zone_name($mapid, $pos_x, $pos_y); $top = $top . $x . ") (I) " . $message['name'] . " " . round($message['totaltime'] / (60 * 60)) . " ч. lvl: {$lvl} Локация: {$loc}\n"; } else { $top = $top . $x . ") " . $message['name'] . " " . round($message['totaltime'] / (60 * 60)) . " ч. lvl: {$lvl} \n"; } } $x++; } send_answer("Топ игроков WoW: \n{$top}", 0); } } //@mysql_select_db($dbname,$dbcnx); } #------цитатник---- if ($words[0] == '!cit' || $words[0] == '!цитата' || $words[0] == '!c' || $words[0] == '!ц') { if (empty($words[1])) { $res = `fortune ru`; } else { $frase = $words[1]; $topic = "fortune ru/" . $frase; $res = `{$topic}`; } send_answer("\n" . iconv("UTF-8", "windows-1251", $res), 0); } if ($words[0] == '!theme' || $words[0] == '!themes') { send_answer("M\$ adv adv_v amur armenian art b0 b11 b12 b13 b2 book citates computer conscience d1 d21 d41 disa do_you_know drink e0 e12 e13 education ego_and_alt eshe feano fidelity flirt fomenko foolish freewill friendship future genious haiku happy human_being if ill innocence just4fun knowledge life life_k love love_s lovers man_and_woman murphy other polit polyakov programming relations religion russia_today sex success sympathy time treason truth truth_and_lie war wealth work", 0); } #----справка------- if ($words[0] == '!help' || $words[0] == '!помощь') { send_answer("\r\n\t\t\t\r\n\t#vic - канал викторины (!stat для показа очков)\r\n\t\r\n\tКоманды которые понимает бот:\r\n\t\tПолный список команд тут \r\n\t\thttp://192.168.0.200/forum/showthread.php?goto=newpost&t=535\r\n\t\t\r\n\tЛоги чата хранятся тут http://192.168.0.200/avin/\r\n\t\t\t", 0); } $here[$hostt]['name'] = $parts[1]; //записи для !seen $here[$hostt]['say'] = $parts[2]; //записи для !seen $here[$hostt]['numwords'] += count(explode(' ', $parts[2])); //записи для !seen array_multisort $GLOBALS['here'] = $here; break; case '4': //мы тут и здароваемся $msg = 'X' . rcode() . '1' . $parts[0] . $nol . $nick . $nol . '11'; if ($ES == 1) { socket_sendto($socket, $msg, strlen($msg), 0, $hostt, $port); } sleep(1); //send_answer("Привет, $parts[0]! Теперь я понимаю IRC протокол! Можешь найти меня на канале $ircchannel на нашем IRC сервере ($ircaddress:$ircport)",0); //send_answer("Здарова, $parts[0]! Не забывай посещать наш форум http://192.168.0.200/forum",0); //$topic="fortune ru/fomenko"; $res=`$topic`; send_answer(iconv("UTF-8", "windows-1251", $res),0); //send_answer(" ;):-O(A) http://192.168.0.200/forum :-PB-):-)",0,"#Main"); http://192.168.0.200:8000/difm send_answer("Важные изменения в ВОВ! Читайте! \n http://192.168.0.200/forum/showthread.php?p=8588#post8588", 0, "#Main"); $here[$hostt]['name'] = $parts[0]; $GLOBALS['here'] = $here; $here[$hostt]['numwords'] = 0; //записи для !seen break; } }