rendered paste body<?require_once ("Zalgo/class/zalgo.irc.client.php");define("OMEGLE_START", 1);define("OMEGLE_CHATTING", 2);define("OMEGLE_NOTHING", 4);define("TYPING", 1);define("GOT_MESSAGE", 2);define("GOT_ID", 3);define("STRANGER_DISCONNECTED", 4);define("STOP_TYPING", 5);define("CONNECTED", 6);define("WAITING", 7);define("IMPLODED", 8);define("STARTED_MULTICHAT", 9);class Omegle_IO{ var $state, $id, $ref, $wrap, $fp; function __construct($ref, $wrap) { $this->ref = $ref; $this->wrap = $wrap; $this->state = OMEGLE_NOTHING; } function socket_post($url, $data = array(), $port = 80, $blocking = false, $quickie = false) { $params = parse_url($url); #print_r($params); $fp = fsockopen($params['host'], $port); fwrite($fp, "POST {$params['path']} /1.1\r\n"); fwrite($fp, "Host: {$params['host']}\r\n"); if (count($data) > 0) { $datastr = http_build_query($data); fwrite($fp, "Content-Type: application/x-www-form-urlencoded\r\n"); fwrite($fp, "Content-Length: " . strlen($datastr) . "\r\n\r\n"); fwrite($fp, $datastr); } else { fwrite($fp, "Content-Length: 0\r\n\r\n"); } if ($blocking == false) stream_set_blocking($fp, $blocking); if ($quickie == false) $this->fp = $fp; else { $line = fread($fp, 5); fclose($fp); return trim($line); } } function typing() { $res = $this->socket_post("http://omegle.com/typing", array('id' => $this->id), 80, true, true); } function say($msg) { $res = $this->socket_post("http://omegle.com/send", array('id' => $this->id, 'msg' => $msg), 80, true, true); } function start_chat() { $this->socket_post("http://omegle.com/start"); $this->state = OMEGLE_START; } function recieved($line) { switch ($this->state) { case OMEGLE_START: $this->gotid($line); break; case OMEGLE_CHATTING: $this->gottext($line); break; } } function gotid($line) { if (preg_match("/\"([\S]){6}\"$/", $line, $matches)) { $this->id = trim($matches[0], '"'); $this->wrap->do_callback(GOT_ID, $this->ref, $this->id); } $this->do_events(); } function gottext($line) { if (preg_match('/\[(.*)\]$/', $line, $matches)) { $this->actions(json_decode($matches[0], 1)); } else { if (strpos($line, 'null') !== false) { $this->dead(); $this->wrap->do_callback(IMPLODED, $this->ref); } } } function do_events() { if ($this->state == OMEGLE_NOTHING) return; $this->socket_post("http://omegle.com/events", array('id' => $this->id)); $this->state = OMEGLE_CHATTING; } function actions($json) { foreach ($json as $j) { $this->parse_individual_action($j); } $this->do_events(); } function disconnect() { $res = $this->socket_post("http://omegle.com/disconnect", array('id' => $this-> id), 80, true, true); $this->dead(); } function dead() { @fclose($this->fp); $this->id = ''; $this->state = OMEGLE_NOTHING; } function parse_individual_action($j) { switch ($j[0]) { case 'typing': $this->wrap->do_callback(TYPING, $this->ref); break; case 'gotMessage': $this->wrap->do_callback(GOT_MESSAGE, $this->ref, $j[1]); break; case 'strangerDisconnected': $this->dead(); $this->wrap->do_callback(STRANGER_DISCONNECTED, $this->ref); break; case 'connected': $this->wrap->do_callback(CONNECTED, $this->ref); break; case 'waiting': $this->wrap->do_callback(WAITING, $this->ref); break; case 'stoppedTyping': $this->wrap->do_callback(STOP_TYPING, $this->ref); break; default: echo "fallthru $j[0]\r\n"; break; } } function destroy() { unset($this); }}class Omegle_Wrap{ var $io = array(); var $callbacks = array(); var $no = 0; var $remaining = 0; function __construct() { for ($i = 0; $i < 10; $i++) { $this->callbacks[$i] = array(); } } function create_chats($c) { $this->no = $c; $f = "A"; for ($i = 0; $i < $c; $i++) { $f++; } foreach ($this->io as $io) { $io->destroy(); } $this->io = array(); for ($i = "A"; $i < $f; $i++) { $this->io[$i] = new Omegle_IO($i, $this); } } function start_multichat() { foreach ($this->io as $io) { $io->start_chat(); sleep(1); $this->remaining++; } $this->do_callback(STARTED_MULTICHAT, -1); } function recieve_data() { while (true) { $this->recieve_data_once(); usleep(1500); } } function recieve_data_once() { foreach ($this->io as $io) { if ((is_resource($io->fp) && !feof($io->fp)) && $io->state != OMEGLE_NOTHING) { $line = trim(fread($io->fp, 8060)); if (strlen($line) > 0) $io->recieved($line); if (@feof($io->fp)) @fclose($io->fp); } } } function do_callback($type, $ref, $msg = '') { if (@count($this->callbacks[$type]) > 0) { foreach ($this->callbacks[$type] as $cb) { call_user_func($cb, array('ref' => $ref, 'msg' => $msg)); } } } function add_callback($type, $callback) { if (is_callable($callback)) { $this->callbacks[$type][] = $callback; } }}class Omegle_Relay{ function __construct($m) { $this->wrap = $m; } function relay_typing($r) { if ($this->wrap->no != 2) return; foreach ($this->wrap->io as $id => $io) { if ($id != $r['ref']) $io->typing(); } } function relay_msg($r) { foreach ($this->wrap->io as $id => $io) { if ($id != $r['ref']) $io->say($r['msg']); } } function dc_all_others($r) { if ($this->wrap->no == 2 || $this->wrap->remaining == 2) { echo "Partner Disconnected, ending chats \r\n"; foreach ($this->wrap->io as $id => $io) { if ($id != $r['ref']) $io->disconnect(); } $this->wrap->remaining = 0; } else { $this->wrap->remaining--; } } function gotid($r) { echo "[{$r['ref']}] got id: {$r['msg']}\r\n"; } function echo_msg($r) { echo "[{$r['ref']}] {$r['msg']}\r\n"; } function echo_typing($r) { echo "[{$r['ref']}] * is typing\r\n"; }}class Omegle_IRC{ var $chan = "#Om_Test"; var $colors = array("A" => "03", "B" => "04", "C" => "13", "D" => "12", "E" => "15", "F" => "05"); var $chatting = 0; function __construct($z, $w) { $this->z = $z; $this->wrap = $w; } function start_multichat($d) { if ($this->chatting == 0) { $no = @$d['params']; if ($no == '') { $no = 2; } elseif (!is_numeric($no)) { $no = 2; } elseif ($no > 5) $no = 5; elseif ($no < 2) $no = 2; $this->wrap->create_chats($no); $this->chatting = 1; $this->z->privmsg($this->chan, "\x033Starting Omegle_Multichat (\x02$no\x02 participants)"); $this->wrap->start_multichat(); } else { $this->z->privmsg($this->chan, "\x034Already chatting, use \x0311@dc"); } } function disconnect_active() { foreach ($this->wrap->io as $io) { if ($io->state != OMEGLE_NOTHING) $io->disconnect(); } $this->wrap->remaining = 0; $this->chatting = 0; } function end_multichat($d) { if ($this->chatting == 1) { if (@$d['params'] != '') { $id = substr(strtoupper($d['params']), 0, 1); if (isset($this->wrap->io[$id])) { if ($this->wrap->io[$id]->state != OMEGLE_NOTHING) { $this->wrap->io[$id]->disconnect(); $this->z->privmsg($this->chan, "\x033Disconnected \x037[" . $this->mk_color($id) . "\x037]\x033 from these chats."); $this->wrap->remaining--; } else { $this->z->privmsg($this->chan, "\x037[" . $this->mk_color($id) . "\x037]\x033 was already disconnected."); } } else { $this->z->privmsg($this->chan, "\x033???? \x037[" . $this->mk_color($id) . "\x037]\x033 is nonexistant."); } if ($this->wrap->remaining == 1) { $this->z->privmsg($this->chan, "\x034Noone is left. Ended all chats."); $this->disconnect_active(); } if($this->wrap->remaining ) } else { $this->disconnect_active(); $this->z->privmsg($this->chan, "\x034Ended all chats."); } } else { $this->z->privmsg($d['chan'], "\x034No active chats, use \x0311@start"); } } function relay_msg($r) { $this->z->privmsg($this->chan, "\x037[" . $this->mk_color($r['ref']) . "\x037]\x0f {$r['msg']}\r\n"); } function relay_typing($r) { $this->z->action($this->chan, "\x037[" . $this->mk_color($r['ref']) . "\x037]\x036 is typing\r\n"); } function mk_color($r) { return "\x03" . $this->colors[$r] . "$r"; } function relay_id($r) { $this->z->privmsg($this->chan, "\x037[" . $this->mk_color($r['ref']) . "\x037]\x039 connected\x033 {$r['msg']}\r\n"); } function ended($r) { $no = $this->wrap->no; $re = $this->wrap->remaining; echo "REMAINING $re \r\n"; if ($no == 2) { $this->z->privmsg($this->chan, "\x037[" . $this->mk_color($r['ref']) . "\x037]\x034 disconnected, ended all chats. use \x0311@start\x034 to start again."); $this->chatting = 0; } else { if ($re >= 2) { $this->z->privmsg($this->chan, "\x037[" . $this->mk_color($r['ref']) . "\x037]\x034 disconnected"); } else { $this->z->privmsg($this->chan, "\x037[" . $this->mk_color($r['ref']) . "\x037]\x034 disconnected, noone is left :(. use \x0311@start\x0f\x034 to start again."); $this->chatting = 0; } } } function imKicked($chan, $reason, $nick) { $this->z->join($chan); $this->z->privmsg($chan, "\x037I was kicked by\x034 $nick\x039 D: \x037Please don't do that again!\x039 :("); } function inject($d) { if ($this->chatting == 0) { $this->z->privmsg($d['chan'], "\x034No active chats, use \x0311@start"); return; } $id = strtoupper(substr($d['cmd'], 1)); if (isset($this->wrap->io[$id])) { if ($this->wrap->io[$id]->state != OMEGLE_NOTHING) $this->wrap->io[$id]->say($d['params']); } else { $this->z->privmsg($d['chan'], "that id not exist."); } } function injectIRCCommands() { for ($id = "A"; $id < "G"; $id++) { $this->z->registerHandler(PRIVMSG, strtolower($id), array($this, 'inject')); } } function globalz($d) { if ($this->chatting == 0) { $this->z->privmsg($d['chan'], "\x034No active chats, use \x0311@start"); return; } if ($d['params'] == '') $this->z->privmsg($d['chan'], "Say wha?"); else foreach ($this->wrap->io as $io) { if ($io->state != OMEGLE_NOTHING) $io->say($d['params']); } }}$o = new Omegle_Wrap;$z = new Omegle_Relay($o);$i = new Zalgo_ezIRC;$x = new Omegle_IRC($i, $o);$i->set_trigger("@");$i->QueJoin("#om_test");$i->QueOper("Omegle", "yalikeidleakanoperpassword");$i->registerKickFunction(array($x, 'imKicked'));$i->registerHandler(PRIVMSG, "start", array($x, 'start_multichat'));$i->registerHandler(PRIVMSG, "dc", array($x, 'end_multichat'));$i->registerHandler(PRIVMSG, "g", array($x, 'globalz'));$x->injectIRCCommands();$o->add_callback(TYPING, array($z, 'relay_typing'));#$o->add_callback(TYPING, array($x, 'relay_typing'));$o->add_callback(TYPING, array($z, 'echo_typing'));$o->add_callback(GOT_ID, array($z, 'gotid'));$o->add_callback(GOT_ID, array($x, 'relay_id'));$o->add_callback(GOT_MESSAGE, array($z, 'relay_msg'));$o->add_callback(GOT_MESSAGE, array($x, 'relay_msg'));$o->add_callback(GOT_MESSAGE, array($z, 'echo_msg'));$o->add_callback(STRANGER_DISCONNECTED, array($z, 'dc_all_others'));$o->add_callback(STRANGER_DISCONNECTED, array($x, 'ended'));$i->start("wtf.888chan.org", 6667, "OmLOL", "LOL", "<3 e");while (!feof($i->fp)) { $i->parse(); $o->recieve_data_once(); usleep(1500);}