summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apis/clientlog.inc.php26
-rw-r--r--apis/update.inc.php16
-rw-r--r--inc/database.inc.php2
3 files changed, 37 insertions, 7 deletions
diff --git a/apis/clientlog.inc.php b/apis/clientlog.inc.php
index bc235903..43f31917 100644
--- a/apis/clientlog.inc.php
+++ b/apis/clientlog.inc.php
@@ -13,11 +13,25 @@ if (isset($_POST['longdesc'])) $longdesc = $_POST['longdesc'];
$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,
-));
+
+if ($type{0} === '.' && preg_match('#^\[([^\]]+)\]\s*(.*)$#', $description, $out)) {
+ // Special case '.'-type:
+ Database::exec('INSERT INTO statistic (dateline, typeid, clientip, username, data) VALUES (UNIX_TIMESTAMP(), :type, :client, :username, :data)', array(
+ 'type' => $type,
+ 'client' => $ip,
+ 'username' => $out[1],
+ 'data' => $out[2],
+ ));
+
+} else {
+
+ 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";
diff --git a/apis/update.inc.php b/apis/update.inc.php
index ac680aef..4cf03b0e 100644
--- a/apis/update.inc.php
+++ b/apis/update.inc.php
@@ -223,3 +223,19 @@ function update_8()
Database::exec("ALTER TABLE `configtgz` ADD `status` ENUM( 'OK', 'OUTDATED', 'MISSING' ) NOT NULL DEFAULT 'MISSING'");
return true;
}
+
+function update_9()
+{
+ Database::exec("CREATE TABLE IF NOT EXISTS `statistic` (
+ `logid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `dateline` int(10) unsigned NOT NULL,
+ `typeid` varchar(30) NOT NULL,
+ `clientip` varchar(40) NOT NULL,
+ `username` varchar(30) NOT NULL,
+ `data` varchar(255) NOT NULL,
+ PRIMARY KEY (`logid`),
+ KEY `dateline` (`dateline`),
+ KEY `logtypeid` (`typeid`,`dateline`),
+ KEY `clientip` (`clientip`,`dateline`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+} \ No newline at end of file
diff --git a/inc/database.inc.php b/inc/database.inc.php
index efc330fe..3bd42636 100644
--- a/inc/database.inc.php
+++ b/inc/database.inc.php
@@ -20,7 +20,7 @@ class Database
*/
public static function getExpectedSchemaVersion()
{
- return 9;
+ return 10;
}
public static function needSchemaUpdate()