diff options
author | Simon Rettberg | 2013-11-27 19:23:45 +0100 |
---|---|---|
committer | Simon Rettberg | 2013-11-27 19:23:45 +0100 |
commit | 2370dbbbddfcbee9e69e1133d78b9992118682bc (patch) | |
tree | a235d8e76c2f26473566f69191dc1f5d2b27a987 /apis | |
parent | Add gzip compression to output (diff) | |
download | slx-admin-2370dbbbddfcbee9e69e1133d78b9992118682bc.tar.gz slx-admin-2370dbbbddfcbee9e69e1133d78b9992118682bc.tar.xz slx-admin-2370dbbbddfcbee9e69e1133d78b9992118682bc.zip |
Added client log feature/view
Diffstat (limited to 'apis')
-rw-r--r-- | apis/clientlog.inc.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/apis/clientlog.inc.php b/apis/clientlog.inc.php new file mode 100644 index 00000000..bc235903 --- /dev/null +++ b/apis/clientlog.inc.php @@ -0,0 +1,23 @@ +<?php + +if (!isset($_POST['type']) || !isset($_POST['description'])) die('Missing options'); + +$ip = $_SERVER['REMOTE_ADDR']; +if (substr($ip, 0, 7) === '::ffff:') $ip = substr($ip, 7); +$type = mb_strtolower($_POST['type']); +$description = $_POST['description']; +$longdesc = ''; +if (isset($_POST['longdesc'])) $longdesc = $_POST['longdesc']; + +// Spam from IP +$row = Database::queryFirst('SELECT Count(*) AS cnt FROM clientlog WHERE clientip = :client AND dateline + 3600 > UNIX_TIMESTAMP()', array(':client' => $ip)); +if ($row !== false && $row['cnt'] > 150) exit(0); + +Database::exec('INSERT INTO clientlog (dateline, logtypeid, clientip, description, extra) VALUES (UNIX_TIMESTAMP(), :type, :client, :description, :longdesc)', array( + ':type' => $type, + ':client' => $ip, + ':description' => $description, + ':longdesc' => $longdesc, +)); +echo "OK.\n"; + |