IRC notifier

This commit is contained in:
Latif Khalifa
2013-10-04 08:12:26 +02:00
parent da13fdf4ee
commit 1000c4d743
5 changed files with 39 additions and 4 deletions

1
.gitignore vendored
View File

@@ -4,5 +4,6 @@ dumps
incoming_symbols
logs
htdocs/lib/logs
htdocs/lib/irc_passwd
.hg*

View File

@@ -28,6 +28,8 @@ print "Working dir set to " . ReportParser::getWorkPath() . "\n";
mkdir(ReportParser::getWorkPath());
chdir(ReportParser::getWorkPath());
$nr = 0;
foreach($reports as $id)
{
print "Processing report {$id} \n";
@@ -50,9 +52,14 @@ foreach($reports as $id)
$crash->init($id, $r, $stacktrace);
if ($crash->save())
{
$nr++;
ReportParser::setProcessed($id, 1);
}
}
rrmdir(ReportParser::getWorkPath());
if ($nr)
{
IRCNotify::send("#SingularityViewer", "[CrashProcessor] $nr new crash reports. http://crash.singularityviewer.org/crashes.php ");
}

View File

@@ -12,7 +12,7 @@ class DBH
function log($line)
{
//return;
return;
static $f = false;
static $failed = false;
@@ -54,8 +54,8 @@ class DBH
}
$this->query("SET SQL_MODE='TRADITIONAL'");
$this->query("SET NAMES 'utf8'");
//$this->query("SET SQL_MODE='TRADITIONAL'");
$this->query("SET NAMES 'utf8'");
return true;
}

27
htdocs/lib/IRCNotify.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
class IRCNotify
{
function http_post($url, $fields)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
function send($chan, $msg)
{
$fields = array(
"chan" => $chan,
"auth" => file_get_contents(SITE_ROOT . '/lib/irc_passwd'),
"msg" => $msg
);
self::http_post("http://messi.streamgrid.net/~lkalif/lolabot.php", $fields);
}
}

View File

@@ -52,5 +52,5 @@ create table reports(
crash_reason varchar(128),
crash_address varchar(16),
crash_thread integer,
raw_stacktrace text
raw_stacktrace longtext
);