diff options
Diffstat (limited to 'modules-available/syslog/api.inc.php')
-rw-r--r-- | modules-available/syslog/api.inc.php | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/modules-available/syslog/api.inc.php b/modules-available/syslog/api.inc.php index a8a8b0da..cc64b31c 100644 --- a/modules-available/syslog/api.inc.php +++ b/modules-available/syslog/api.inc.php @@ -25,7 +25,7 @@ if (($user = Request::post('export-user', false, 'string')) !== false) { unset($best); foreach ($srcs as &$src) { if (!isset($src['row'])) { - $src['row'] = $src['res']->fetch(PDO::FETCH_ASSOC); + $src['row'] = $src['res']->fetch(); } if ($src['row'] !== false && (!isset($best) || $src['row']['dateline'] < $best['dateline'])) { $best =& $src['row']; @@ -64,25 +64,17 @@ $longdesc = ''; if (isset($_POST['longdesc'])) $longdesc = $_POST['longdesc']; $longdesc = Request::post('longdesc', '', 'string'); -if ($type{0} !== '.' && $type{0} !== '~') { +if (preg_match('/^[a-z0-9\-]+$/', $type)) { - // Spam from IP - $row = Database::queryFirst('SELECT Count(*) AS cnt FROM clientlog WHERE clientip = :client AND dateline + 1800 > UNIX_TIMESTAMP()', array(':client' => $ip)); + // Spam from IP? + $row = Database::queryFirst('SELECT Count(*) AS cnt FROM clientlog + WHERE clientip = :client AND dateline + 1800 > UNIX_TIMESTAMP()', + [':client' => $ip]); if ($row !== false && $row['cnt'] > 250) { exit(0); } - $ret = Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, machineuuid, description, extra) VALUES (UNIX_TIMESTAMP(), :type, :client, :uuid, :description, :longdesc)', array( - 'type' => $type, - 'client' => $ip, - 'description' => $description, - 'longdesc' => $longdesc, - 'uuid' => $uuid, - ), true); - if ($ret === false) { - error_log("Constraint failed for client log from $uuid for $type : $description"); - die("NOPE.\n"); - } + ClientLog::write(['machineuuid' => $uuid, 'clientip' => $ip], $type, $description, $longdesc); } |