Example #1
0
 function HandleError($errno, $errmsg, $filename, $linenum, $vars)
 {
     date_default_timezone_set('Europe/London');
     $dt = date("[Y-m-d] H:i:s (T)");
     $errortype = array(E_ERROR => 'Error', E_WARNING => 'Warning', E_PARSE => 'Parsing Error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core Error', E_CORE_WARNING => 'Core Warning', E_COMPILE_ERROR => 'Compile Error', E_COMPILE_WARNING => 'Compile Warning', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error');
     $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE);
     $err = "[Error] ";
     $err .= "(" . $dt . ")";
     $err .= "- " . $errno;
     $err .= " " . $errortype[$errno];
     $err .= " " . $errmsg;
     $err .= " [" . $filename;
     $err .= " (" . $linenum . ")]";
     $err .= "\n";
     if ($errno != 2048) {
         //error_log($err, 3, "/home/norek/ctextserv/error.log");
     }
     $err = "" . $errortype[$errno] . "(" . $errno . ")";
     $err .= " - " . $errmsg;
     $err .= " [" . $filename;
     $err .= " (" . $linenum . ")]";
     if ($errno != 2048 && Config::$_opts['EHANDLE'] == 1) {
         IRC::PMsg(Config::$_server['DEB_CHAN'], "4[PHP] " . trim($err) . "");
     }
 }
Example #2
0
 public function message($from, $text)
 {
     // TODO: No external messages flag: +n
     // TODO: Modes +mMbn
     // Announce the message
     foreach ($this->clients as &$client) {
         if ($client == $from) {
             continue;
         }
         // Don't send it to the person who sent it (or the IRC client will echo it twice)
         $client->write(IRC::sprintf(IRC::Message, $from, $this->name, $text));
     }
 }
Example #3
0
	public function parse($data)
	{
		$data = IRC::Parse($data);
		// we can ignore the origin.
		// $origin = $data['origin'];
		$command = $data['command'];
		$params = $data['params'];

		// now we need to find out if there's a method in $this for handling $command
		// if there is, we pass off the rest of $data - the parameters - to it
		// for processing
		if (method_exists($this, "cmd_" . $command))
			call_user_func(array($this, "cmd_" . $command), $params);

		// if there ISN'T a method for handling $command...
		// first we should check if they're registered. We intercept CAP entirely
		// and NICK at least initially, so if the user isn't registered, yell at them
		// like a small child that has just tried to pick up the cat by the ears.
		else if (!$this->isRegistered())
			$this->sendNumeric(451, ":Register first");

		// but if we ARE registered we should probably just be sending the data straight
		// along to the server, but only if we have one!
		else if (is_a($this->myServer, "IRCServer"))
		{
			// pull the last param off if it's freeform
			if ($data['freeform'] === TRUE) $freeform = array_pop($params);
			
			// then we need to rebuild our command
			$data = strtoupper($command) . " " . implode($params);

			// and if we have freeform, stick in on there.
			if (isset($freeform)) $data .= " :" . $freeform;

			// and then send it!
			$this->myServer->send($data);
		}

		// if we get a command we don't recognize, and AREN'T attached to a server,
		// then we have a problem. I see a couple options:
		//	1. ERR_UNKNOWNCOMMAND (421)
		//	2. Some server message about attaching
		// I'm not fully decided either way yet, but I am partial to #1 as it seems
		// more in line with the spirit of the IRC specification.
		else
			$this->sendNumeric(421, "%s :Unknown command", strtoupper($command));
	}
Example #4
0
 function CreateSocket()
 {
     echo ">> Connecting to " . Config::$_server['HOST'] . ":" . Config::$_server['PORT'] . "..... ";
     self::$_ConnectionInfo[0]['Context'] = stream_context_create(array());
     stream_context_set_option(self::$_ConnectionInfo[0]['Context'], 'socket', 'bindto', Config::$_server['BIND'] . ':0');
     if (Config::$_opts['SSL'] == 1) {
         stream_context_set_option(self::$_ConnectionInfo[0], array('ssl' => array('verify_peer' => true, 'allow_self_signed' => true, 'local_cert' => Config::$_ssl['SSLCERT'], 'passphrase' => Config::$_ssl['SSLPASS'])));
     }
     //-----------------
     if (Config::$_opts['SSL'] == 1) {
         self::$_ConnectionInfo[0]['socket'] = stream_socket_client('ssl://' . Config::$_server['HOST'] . ':' . Config::$_server['PORT'], $ErrorNumber, $ErrorString, 2.0, STREAM_CLIENT_CONNECT, self::$_ConnectionInfo[0]['Context']);
     } else {
         self::$_ConnectionInfo[0]['socket'] = stream_socket_client('tcp://' . Config::$_server['HOST'] . ':' . Config::$_server['PORT'], $ErrorNumber, $ErrorString, 2.0, STREAM_CLIENT_CONNECT, self::$_ConnectionInfo[0]['Context']);
     }
     if (self::$_ConnectionInfo[0]['socket'] !== false) {
         echo "[OK]\n";
         stream_set_blocking(self::$_ConnectionInfo[0]['socket'], 0);
         IRC::Initialize();
         //Error :: SetErrorHandler();
         //Config :: $_opts['EHANDLE'] = 1;
     } else {
         echo "[ERROR] \n>> Could not connect to server " . Config::$_server['HOST'] . " on port " . Config::$_server['PORT'] . " (" . $ErrorString . ")\n";
     }
 }
Example #5
0
<?php

include "../../php/site.php";
include "../../php/db.php";
include "../../php/irc.php";
$RowsToShow = 50;
$results = null;
$irc = new IRC();
$max = $irc->get_max_id();
if (isset($_GET['id']) && (int) $_GET['id'] > 0) {
    $results = $irc->get_rows_at($_GET['id'], $RowsToShow);
}
echo $irc->render_mobile($results, $max);
Example #6
0
require "db.php";
require "irc.php";
require "github.php";
$input = file_get_contents('php://input');
if (empty($input)) {
    die("This is a webhook for github. You can only use it as a webhook, displaying in a browser is not supported. See https://meta.wikimedia.org/wiki/Wm-bot#Git_Hub");
}
$payload = new GitHub($input);
if (!$payload->IsKnown()) {
    die("Unknown payload");
}
// for debugging only
// file_put_contents("/tmp/github", $entityBody);
// connect to db
$conn = new mysqli('localhost', $github_user, $github_pw);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
// get information for this repository from db
$sql = "SELECT id, name, channel, channel_token FROM wmib.github_repo_info WHERE name = '" . $payload->GetRepositoryName() . "';";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) == 0) {
    die("This repository " . $payload->GetRepositoryName() . " is not known by wm-bot");
}
$messages = $payload->GetMessage();
while ($row = mysqli_fetch_assoc($result)) {
    foreach ($messages as $message) {
        IRC::DeliverMessage($message, $row["channel"], $row["channel_token"]);
    }
}
$conn->close();
Example #7
0
#!/usr/bin/php
<?php 
//Load things
if (isset($argv[1])) {
    require $argv[1];
    chdir(dirname(__FILE__));
} else {
    chdir(dirname(__FILE__));
    require './config.php';
}
require './irc.class.php';
if (!isset($config)) {
    die('No configuration!' . "\n");
}
//Create the bot!
$irc = new IRC($config);
//Load plugins
$irc->loadPlugins();
//And send it online!
$irc->connect();
Example #8
0
    $atom = file_get_contents($feed);
    $xml = simplexml_load_string($atom);
    $s = "<ul>";
    foreach ($xml->entry as $item) {
        if ($max-- == 0) {
            break;
        }
        $link = (string) $item->link['href'];
        $title = (string) $item->title;
        $s .= "<li><a href=\"{$link}\">{$title}</a></li>";
    }
    $s .= "</ul>";
    return render_widget("blog", "BrowserPlus: <a href=\"/blog/\">Blog</a>", $s);
}
// IRC Transcript
$irc = new IRC();
$results = $irc->get_rows($irc->get_max_id(), $tableRowsToShow);
$ircnav = l("#browserplus", "/discuss/");
$irctable = render_table($results, "stamp", "who", "utterance", array("show_long_dates" => true, "top_nav" => "<strong>IRC: {$ircnav}</strong>"));
//$ircwidgets = $irc->render_widget("day") . $irc->render_widget("week") . $irc->render_widget("month");
$ircwidgets = $irc->render_widget("week");
// GIT Projects
$git = new GIT();
$results = $git->get_rows($tableRowsToShow);
$gitnav = "<strong>GitHub: <a href=\"http://www.github.com/browserplus/\">BrowserPlus</a></strong>";
$gittable = render_table($results, "tcommit", "project", "msg", array("show_long_dates" => true, "top_nav" => $gitnav, "url_key" => "url", "url_pat" => "%s"));
$gitwidgets = $git->render_project_widget();
// bugzilla issues
$bugzilla = new Bugzilla();
$issuewidget = $bugzilla->render_widget($listItemsToShow);
// Links Widget
Example #9
0
 public static function processEditThread($change)
 {
     $change['edit_status'] = 'not_reverted';
     if (!isset($s)) {
         $change['edit_score'] = 'N/A';
     } else {
         $change['edit_score'] = $s;
     }
     if (!isVandalism($change['all'], $s)) {
         Feed::bail($change, 'Below threshold', $s);
         return;
     }
     echo 'Is ' . $change['user'] . ' whitelisted ?' . "\n";
     if (Action::isWhitelisted($change['user'])) {
         Feed::bail($change, 'Whitelisted', $s);
         return;
     }
     echo 'No.' . "\n";
     $reason = 'ANN scored at ' . $s;
     $heuristic = '';
     $log = null;
     $diff = 'https://en.wikipedia.org/w/index.php' . '?title=' . urlencode($change['title']) . '&diff=' . urlencode($change['revid']) . '&oldid=' . urlencode($change['old_revid']);
     $report = '[[' . str_replace('File:', ':File:', $change['title']) . ']] was ' . '[' . $diff . ' changed] by ' . '[[Special:Contributions/' . $change['user'] . '|' . $change['user'] . ']] ' . '[[User:'******'user'] . '|(u)]] ' . '[[User talk:' . $change['user'] . '|(t)]] ' . $reason . ' on ' . gmdate('c');
     $oftVand = unserialize(file_get_contents('oftenvandalized.txt'));
     if (rand(1, 50) == 2) {
         foreach ($oftVand as $art => $artVands) {
             foreach ($artVands as $key => $time) {
                 if (time() - $time > 2 * 24 * 60 * 60) {
                     unset($oftVand[$art][$key]);
                 }
             }
         }
     }
     $oftVand[$change['title']][] = time();
     if (count($oftVand[$change['title']]) >= 30) {
         IRC::say('reportchannel', '!admin [[' . $change['title'] . ']] has been vandalized ' . count($oftVand[$change['title']]) . ' times in the last 2 days.');
     }
     file_put_contents('oftenvandalized.txt', serialize($oftVand));
     //IRC::say( 'debugchannel', 'Possible vandalism: ' . $change[ 'title' ] . ' changed by ' . $change[ 'user' ] . ' ' . $reason . '(' . $s . ')' );
     //IRC::say( 'debugchannel', '( https://en.wikipedia.org/w/index.php?title=' . urlencode( $change[ 'title' ] ) . '&action=history | ' . $change[ 'url' ] . ' )' );
     $ircreport = "15[[07" . $change['title'] . "15]] by \"03" . $change['user'] . "15\" (12 " . $change['url'] . " 15) 06" . $s . "15 (";
     checkMySQL();
     $query = 'INSERT INTO `vandalism` ' . '(`id`,`user`,`article`,`heuristic`' . (is_array($log) ? ',`regex`' : '') . ',`reason`,`diff`,`old_id`,`new_id`,`reverted`) ' . 'VALUES ' . '(NULL,\'' . mysql_real_escape_string($change['user']) . '\',' . '\'' . mysql_real_escape_string($change['title']) . '\',' . '\'' . mysql_real_escape_string($heuristic) . '\',' . (is_array($log) ? '\'' . mysql_real_escape_string($logt) . '\',' : '') . '\'' . mysql_real_escape_string($reason) . '\',' . '\'' . mysql_real_escape_string($change['url']) . '\',' . '\'' . mysql_real_escape_string($change['old_revid']) . '\',' . '\'' . mysql_real_escape_string($change['revid']) . '\',0)';
     mysql_query($query, Globals::$mysql);
     $change['mysqlid'] = mysql_insert_id();
     echo 'Should revert?' . "\n";
     list($shouldRevert, $revertReason) = Action::shouldRevert($change);
     $change['revert_reason'] = $revertReason;
     if ($shouldRevert) {
         echo 'Yes.' . "\n";
         $rbret = Action::doRevert($change);
         if ($rbret !== false) {
             $change['edit_status'] = 'reverted';
             RedisProxy::send($change);
             //IRC::say( 'debugchannel', 'Reverted. (' . ( microtime( true ) - $change[ 'startTime' ] ) . ' s)' );
             IRC::say('debugchannel', $ircreport . "04Reverted15) (13" . $revertReason . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
             Action::doWarn($change, $report);
             checkMySQL();
             mysql_query('UPDATE `vandalism` SET `reverted` = 1 WHERE `id` = \'' . mysql_real_escape_string($change['mysqlid']) . '\'', Globals::$mysql);
             Feed::bail($change, $revertReason, $s, true);
         } else {
             $change['edit_status'] = 'beaten';
             $rv2 = API::$a->revisions($change['title'], 1);
             if ($change['user'] != $rv2[0]['user']) {
                 //IRC::say( 'debugchannel', 'Grr! Beaten by ' . $rv2[ 0 ][ 'user' ] );
                 RedisProxy::send($change);
                 IRC::say('debugchannel', $ircreport . "03Not Reverted15) (13Beaten by " . $rv2[0]['user'] . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
                 checkMySQL();
                 mysql_query('INSERT INTO `beaten` (`id`,`article`,`diff`,`user`) VALUES (NULL,\'' . mysql_real_escape_string($change['title']) . '\',\'' . mysql_real_escape_string($change['url']) . '\',\'' . mysql_real_escape_string($rv2[0]['user']) . '\')', Globals::$mysql);
                 Feed::bail($change, 'Beaten by ' . $rv2[0]['user'], $s);
             }
         }
     } else {
         RedisProxy::send($change);
         IRC::say('debugchannel', $ircreport . "03Not Reverted15) (13" . $revertReason . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
         Feed::bail($change, $revertReason, $s);
     }
 }
Example #10
0
 function IRCLogger($text)
 {
     if (Config::$_opts['IRCLOG'] == 1) {
         IRC::PMsg(Config::$_server['LOG_CHAN'], $text);
     }
 }
Example #11
0
<?php

include "../../php/site.php";
include "../../php/db.php";
include "../../php/irc.php";
define("IRC_MAX_ROWS", 150);
$irc = new IRC();
$search_term = "";
$max_id = $irc->get_max_id();
$blurb = false;
$in_search = false;
if (isset($_GET['search'])) {
    $in_search = true;
    $id = $max_id;
    $search_term = h($_GET['search']);
    // don't need to escape search below since we're using PDO
    $results = $irc->find_rows($_GET['search'], IRC_MAX_ROWS);
    $rcount = count($results);
    if ($rcount == 0) {
        $blurb = "No IRC results match that query.";
    } else {
        $blurb = "Results that match '" . h($_GET['search']) . "':";
    }
    $rcount = count($results);
    $nav = l("Current", "/discuss/");
} else {
    if (isset($_GET['id'])) {
        $id = (int) $_GET['id'];
        $id = $max_id - $id < 0 ? $max_id : $id;
    } else {
        $id = $max_id;
 public static function shouldRevert($change)
 {
     $reason = 'Default revert';
     if (preg_match('/(assisted|manual)/iS', Config::$status)) {
         echo 'Revert [y/N]? ';
         if (strtolower(substr(fgets(Globals::$stdin, 3), 0, 1)) != 'y') {
             return array(false, 'Manual mode says no');
         }
     }
     if (!preg_match('/(yes|enable|true)/iS', Globals::$run)) {
         return array(false, 'Run disabled');
     }
     if ($change['user'] == Config::$user) {
         return array(false, 'User is myself');
     }
     if (Config::$angry) {
         return array(true, 'Angry-reverting in angry mode');
     }
     if (time() - Globals::$tfas >= 1800) {
         if (preg_match('/\\(\'\'\'\\[\\[([^|]*)\\|more...\\]\\]\'\'\'\\)/iU', Api::$q->getpage('Wikipedia:Today\'s featured article/' . date('F j, Y')), $tfam)) {
             Globals::$tfas = time();
             Globals::$tfa = $tfam[1];
         }
     }
     if (!self::findAndParseBots($change)) {
         return array(false, 'Exclusion compliance');
     }
     if ($change['all']['user'] == $change['all']['common']['creator']) {
         return array(false, 'User is creator');
     }
     if ($change['all']['user_edit_count'] > 50) {
         if ($change['all']['user_warns'] / $change['all']['user_edit_count'] < 0.1) {
             return array(false, 'User has edit count');
         } else {
             $reason = 'User has edit count, but warns > 10%';
         }
     }
     if (Globals::$tfa == $change['title']) {
         return array(true, 'Angry-reverting on TFA');
     }
     if (preg_match('/\\* \\[\\[(' . preg_quote($change['title'], '/') . ')\\]\\] \\- .*/i', Globals::$aoptin)) {
         IRC::say('debugchannel', 'Angry-reverting [[' . $change['title'] . ']].');
         return array(true, 'Angry-reverting on angry-optin');
     }
     $titles = unserialize(file_get_contents('titles.txt'));
     if (!isset($titles[$change['title'] . $change['user']]) or time() - $titles[$change['title'] . $change['user']] > 24 * 60 * 60) {
         $titles[$change['title'] . $change['user']] = time();
         file_put_contents('titles.txt', serialize($titles));
         return array(true, $reason);
     }
     return array(false, 'Reverted before');
 }
Example #13
0
function cmd_mem($client, $argv)
{
    $mem = mod_mem::format_bytes(memory_get_usage(true));
    $client->write(IRC::sprintf(mod_mem::MemoryUsage, $mem));
}
Example #14
0
<?php

$imagename = $_GET['type'];
switch ($imagename) {
    case 'activity':
        include 'IRC.php';
        $mapper = new IRC();
        $im = $mapper->getUserActivityMap($_GET['ids']);
        break;
    case 'chandetail':
        include 'Channel.php';
        $mapper = new Channel($_GET['ids']);
        $im = $mapper->getDetailmap();
        break;
}
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
Example #15
0
 public function printFooter()
 {
     echo "</td></tr></table>";
     parent::printFooter();
 }
Example #16
0
<?php

include "../../php/site.php";
include "../../php/forum.php";
include "../../php/twitter.php";
include "../../php/db.php";
include "../../php/irc.php";
include "../../php/bugzilla.php";
$RowsToShow = 20;
$t = new Twitter();
$f = new Forum();
$irc = new IRC();
$bugzilla = new Bugzilla();
$twitterSearchItems = $t->render_search_mobile("browserplus", $RowsToShow);
$twitterUserItems = $t->render_user_mobile("browserplus", $RowsToShow);
$max = $irc->get_max_id();
$results = $irc->get_rows($max, $RowsToShow);
$ircItems = $irc->render_mobile($results, $max);
$issueItems = $bugzilla->render_mobile($RowsToShow);
$forumItems = $f->render_mobile($RowsToShow);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>BrowserPlus</title>
  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
  <link rel="apple-touch-icon" href="/m/dashboard-icon.png" />
  <style type="text/css" media="screen">@import "/iui/dashboardx.css";</style><!-- http://www.phpied.com/cssmin-js/ -->
  <script type="application/x-javascript" src="/iui/iuix.js"></script>
  <style type="text/css" media="screen">
 public static function processEditThread($change)
 {
     $change['edit_status'] = 'not_reverted';
     if (!isset($s)) {
         $change['edit_score'] = 'N/A';
         $s = null;
     } else {
         $change['edit_score'] = $s;
     }
     if (!in_array('all', $change) || !isVandalism($change['all'], $s)) {
         Feed::bail($change, 'Below threshold', $s);
         return;
     }
     echo 'Is ' . $change['user'] . ' whitelisted ?' . "\n";
     if (Action::isWhitelisted($change['user'])) {
         Feed::bail($change, 'Whitelisted', $s);
         return;
     }
     echo 'No.' . "\n";
     $reason = 'ANN scored at ' . $s;
     $heuristic = '';
     $log = null;
     $diff = 'https://en.wikipedia.org/w/index.php' . '?title=' . urlencode($change['title']) . '&diff=' . urlencode($change['revid']) . '&oldid=' . urlencode($change['old_revid']);
     $report = '[[' . str_replace('File:', ':File:', $change['title']) . ']] was ' . '[' . $diff . ' changed] by ' . '[[Special:Contributions/' . $change['user'] . '|' . $change['user'] . ']] ' . '[[User:'******'user'] . '|(u)]] ' . '[[User talk:' . $change['user'] . '|(t)]] ' . $reason . ' on ' . gmdate('c');
     $oftVand = unserialize(file_get_contents('oftenvandalized.txt'));
     if (rand(1, 50) == 2) {
         foreach ($oftVand as $art => $artVands) {
             foreach ($artVands as $key => $time) {
                 if (time() - $time > 2 * 24 * 60 * 60) {
                     unset($oftVand[$art][$key]);
                 }
             }
         }
     }
     $oftVand[$change['title']][] = time();
     if (count($oftVand[$change['title']]) >= 30) {
         IRC::say('reportchannel', '!admin [[' . $change['title'] . ']] has been vandalized ' . count($oftVand[$change['title']]) . ' times in the last 2 days.');
     }
     file_put_contents('oftenvandalized.txt', serialize($oftVand));
     $ircreport = "15[[07" . $change['title'] . "15]] by \"03" . $change['user'] . "15\" (12 " . $change['url'] . " 15) 06" . $s . "15 (";
     $change['mysqlid'] = Db::detectedVandalism($change['user'], $change['title'], $heuristic, $reason, $change['url'], $change['old_revid'], $change['revid']);
     echo 'Should revert?' . "\n";
     list($shouldRevert, $revertReason) = Action::shouldRevert($change);
     $change['revert_reason'] = $revertReason;
     if ($shouldRevert) {
         echo 'Yes.' . "\n";
         $rbret = Action::doRevert($change);
         if ($rbret !== false) {
             $change['edit_status'] = 'reverted';
             RedisProxy::send($change);
             IRC::say('debugchannel', $ircreport . "04Reverted15) (13" . $revertReason . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
             Action::doWarn($change, $report);
             Db::vandalismReverted($change['mysqlid']);
             Feed::bail($change, $revertReason, $s, true);
         } else {
             $change['edit_status'] = 'beaten';
             $rv2 = Api::$a->revisions($change['title'], 1);
             if ($change['user'] != $rv2[0]['user']) {
                 RedisProxy::send($change);
                 IRC::say('debugchannel', $ircreport . "03Not Reverted15) (13Beaten by " . $rv2[0]['user'] . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
                 Db::vandalismRevertBeaten($change['mysqlid'], $change['title'], $rv2[0]['user'], $change['url']);
                 Feed::bail($change, 'Beaten by ' . $rv2[0]['user'], $s);
             }
         }
     } else {
         RedisProxy::send($change);
         IRC::say('debugchannel', $ircreport . "03Not Reverted15) (13" . $revertReason . "15) (02" . (microtime(true) - $change['startTime']) . " 15s)");
         Feed::bail($change, $revertReason, $s);
     }
 }
Example #18
0
 function __construct($server, $pgPort = 6667, $user, $pass, $nick, $channel, $callback = null)
 {
     global $pgIRCTrigger, $pgHooks;
     if (func_num_args() > 6) {
         $this->server = $server;
         $this->port = $pgPort;
         $this->user = $user;
         $this->pass = $pass;
         $this->nick = $nick;
         $this->channel = $channel;
         $this->callback = $callback;
     } else {
         $this->server = $server;
         $this->port = 6667;
         $this->user = $pgPort;
         $this->pass = $user;
         $this->nick = $pass;
         $this->channel = $nick;
         $this->callback = $channel;
     }
     $pgHooks['SimpleIRCPrivMSG'][] = $callback;
     $irc = new IRC($this->user, $this->nick, $this->pass, $this->server, $this->port, "Peachy IRC Bot Version " . PEACHYVERSION, $this->channel);
     while (!feof($irc->f)) {
         $parsed = IRC::parseLine(fgets($irc->f, 1024), $pgIRCTrigger, true);
         if (@$parsed['n!u@h'] == 'PING') {
             $irc->sendPong($parsed['payload']);
         }
         if (@$parsed['type'] == '376' || @$parser['type'] == '422') {
             $feed->joinChan();
             sleep(5);
         }
         if (@$parsed['type'] == 'PRIVMSG') {
             Hooks::runHook('SimpleIRCPrivMSG', array(&$parsed, &$irc, &$this));
         }
     }
 }
Example #19
0
 private static function loop($line)
 {
     $d = IRC::split($line);
     if ($d === null) {
         return;
     }
     if ($d['type'] == 'direct') {
         switch ($d['command']) {
             case 'ping':
                 self::send('PONG :' . $d['pieces'][0]);
                 break;
         }
     } else {
         switch ($d['command']) {
             case '376':
             case '422':
                 self::send('JOIN ' . self::$channel);
                 break;
             case 'privmsg':
                 if (strtolower($d['target']) == self::$channel) {
                     $rawmessage = $d['pieces'][0];
                     $message = str_replace("", '', $rawmessage);
                     $message = preg_replace('/\\003(\\d\\d?(,\\d\\d?)?)?/', '', $message);
                     $data = parseFeed($message);
                     if ($data === false) {
                         return;
                     }
                     $data['line'] = $message;
                     $data['rawline'] = $rawmessage;
                     if (stripos('N', $data['flags']) !== false) {
                         self::bail($data, 'New article');
                         return;
                     }
                     $stalkchannel = array();
                     foreach (Globals::$stalk as $key => $value) {
                         if (myfnmatch(str_replace('_', ' ', $key), str_replace('_', ' ', $data['user']))) {
                             $stalkchannel = array_merge($stalkchannel, explode(',', $value));
                         }
                     }
                     foreach (Globals::$edit as $key => $value) {
                         if (myfnmatch(str_replace('_', ' ', $key), str_replace('_', ' ', ($data['namespace'] == 'Main:' ? '' : $data['namespace']) . $data['title']))) {
                             $stalkchannel = array_merge($stalkchannel, explode(',', $value));
                         }
                     }
                     $stalkchannel = array_unique($stalkchannel);
                     foreach ($stalkchannel as $chan) {
                         IRC::say($chan, 'New edit: [[' . ($data['namespace'] == 'Main:' ? '' : $data['namespace']) . $data['title'] . ']] https://en.wikipedia.org/w/index.php?title=' . urlencode($data['namespace'] . $data['title']) . '&diff=prev&oldid=' . urlencode($data['revid']) . ' * ' . $data['user'] . ' * ' . $data['comment']);
                     }
                     switch ($data['namespace'] . $data['title']) {
                         case 'User:'******'/Run':
                             Globals::$run = Api::$q->getpage('User:'******'/Run');
                             break;
                         case 'Wikipedia:Huggle/Whitelist':
                             Globals::$wl = Api::$q->getpage('Wikipedia:Huggle/Whitelist');
                             break;
                         case 'User:'******'/Optin':
                             Globals::$optin = Api::$q->getpage('User:'******'/Optin');
                             break;
                         case 'User:'******'/AngryOptin':
                             Globals::$aoptin = Api::$q->getpage('User:'******'/AngryOptin');
                             break;
                     }
                     if ($data['namespace'] != 'Main:' and !preg_match('/\\* \\[\\[(' . preg_quote($data['namespace'] . $data['title'], '/') . ')\\]\\] \\- .*/i', Globals::$optin)) {
                         self::bail($data, 'Outside of valid namespaces');
                         return;
                     }
                     echo 'Processing: ' . $message . "\n";
                     Process::processEdit($data);
                 }
                 break;
         }
     }
 }
Example #20
0
 function SetNick($nick)
 {
     echo ">> [IRC] Nickname Changed To " . $nick . "\n";
     if (class_exists('Log') && Config::$_log['LOG'] == 1) {
         IRC::LogToIRC("5[IRC] Nickname Changed To " . $nick);
     }
     IRCSock::SendData("NICK " . $nick);
 }
Example #21
0
 public function init()
 {
     if ($this->nick === false || $this->user === false) {
         return false;
     }
     $this->registered = true;
     $this->write(IRC::sprintf(IRC::Connect(), &$this));
     return true;
 }
Example #22
0
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * ClueBot NG is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ClueBot NG.  If not, see <http://www.gnu.org/licenses/>.
 */
declare (ticks=1);
require_once 'includes.php';
pcntl_signal(SIGCHLD, function ($signo) {
    switch ($signo) {
        case SIGCHLD:
            while (($x = pcntl_waitpid(0, $status, WNOHANG)) != -1) {
                if ($x == 0) {
                    break;
                }
                $status = pcntl_wexitstatus($status);
            }
            break;
    }
});
date_default_timezone_set('UTC');
doInit();
IRC::init();
for (;;) {
    Feed::connectLoop();
}
Example #23
0
function cmd_mode($client, $argv)
{
    $name = $argv[0];
    $set = isset($argv[1]) ? implode(' ', array_slice($argv, 1)) : false;
    if (Channel::is_valid($name)) {
        // Valid channel name
        if (($channel = Channel::find($name)) === false) {
            // Channel doesn't exist.
            $client->write(IRC::sprintf(IRC::NoSuchNickChannel, &$client, $name));
            return;
        }
        if ($set === false) {
            // Not setting anything.
            // Modes
            $client->write(IRC::sprintf(IRC::ChannelModes, &$client, $name, $channel->modes->make_string()));
            // Creation time
            $client->write(IRC::sprintf(IRC::ChannelCreated, &$client, $name, $channel->created));
        } else {
            // TODO: Check for mode +o, etc, before allowing this.
            $channel->modes->mode($set);
        }
        return;
    }
    // Treat as a PM
    if (($user = Client::find_by_nick($name)) === false) {
        // Couldn't find a channel or user under this name
        $client->write(IRC::sprintf(IRC::NoSuchNickChannel, &$client, $name));
    } else {
        // Found a user
        // TODO: User modes (oper only?)
    }
}
Example #24
0
<?php

include 'IRC.php';
$thispage = new IRC();
$thispage->printHeader();
if (!isset($_GET['nickvalue'])) {
    $_GET['nickvalue'] = "";
}
if (!isset($_GET['hostvalue'])) {
    $_GET['hostvalue'] = "";
}
if (!isset($_GET['uservalue'])) {
    $_GET['uservalue'] = "";
}
if (!isset($_GET['nicksearch'])) {
    $_GET['nicksearch'] = "";
}
if (!isset($_GET['hostsearch'])) {
    $_GET['hostsearch'] = "";
}
if (!isset($_GET['usersearch'])) {
    $_GET['usersearch'] = "";
}
if (!isset($_GET['action'])) {
    $_GET['action'] = "";
}
switch ($_GET['action']) {
    default:
    case 'search':
        showSearch();
        if ($_GET['nickvalue'] != '' || $_GET['uservalue'] != '' || $_GET['hostvalue'] != '') {
Example #25
0
<?php

include 'IRC.php';
$thispage = new IRC();
$thispage->printHeader();
if (!isset($_GET['action'])) {
    $_GET['action'] = "";
}
switch ($_GET['action']) {
    case 'addserver':
        getaddserver();
    case 'showservers':
        showservers();
        break;
    case 'showlogs':
        showlogs();
        break;
    case 'addlog':
        addlog();
        break;
    case 'logsubmit':
        logsubmit();
        break;
    case 'logsubmitlocal':
        logsubmitlocal();
        break;
}
function getaddserver()
{
    global $thispage;
    if (isset($_GET['servername']) && isset($_GET['serveraddr'])) {
Example #26
0
 public static function init()
 {
     $ircconfig = explode("\n", API::$q->getpage('User:'******'/CBChannels.js'));
     $tmp = array();
     foreach ($ircconfig as $tmpline) {
         if ($tmpline[0] != '#') {
             $tmpline = explode('=', $tmpline, 2);
             $tmp[trim($tmpline[0])] = trim($tmpline[1]);
         }
     }
     self::$chans = $tmp;
 }