From 478a6b0a4ab70a3d2819caeba0451a8af03be1db Mon Sep 17 00:00:00 2001 From: rylon Date: Fri, 9 Jan 2015 15:36:42 +0100 Subject: [PATCH 01/34] postgress fixes - new features transported to pg environment --- cron/cron_log2sqlite.php | 13 +++++++++-- dbd/qq/SYS_LOG_MONTH.php | 2 +- dbd/qq/SYS_LOG_MONTH_DEL.php | 2 +- dbd/qq/SYS_LOG_OLDEST.php | 2 +- dbd/sql/pg/data/sai_api.sql | 23 +++++++++++++++++-- dbd/sql/pg/data/system_cron.sql | 1 + .../qq/SYS_SAIMOD_CRON_CHANGE.php | 2 +- .../saimod_sys_cron/saimod_sys_cron.php | 2 +- 8 files changed, 38 insertions(+), 9 deletions(-) create mode 100644 dbd/sql/pg/data/system_cron.sql diff --git a/cron/cron_log2sqlite.php b/cron/cron_log2sqlite.php index 76af1c4..0c20518 100644 --- a/cron/cron_log2sqlite.php +++ b/cron/cron_log2sqlite.php @@ -43,6 +43,15 @@ class cron_log2sqlite extends \SYSTEM\CRON\cronjob{ while($row = $res->next()){ set_time_limit(30); $i++; + /*new \SYSTEM\LOG\INFO('INSERT OR IGNORE INTO '.\SYSTEM\DBD\system_log::NAME_MYS. + '(`ID`, `class`, `message`, `code`, `file`, `line`, `trace`, `ip`, `querytime`, `time`,'. + ' `server_name`, `server_port`, `request_uri`, `post`,'. + ' `http_referer`, `http_user_agent`, `user`, `thrown`)'. + 'VALUES ('.$row['ID'].', \''.\SQLite3::escapeString($row['class']).'\', \''.\SQLite3::escapeString($row['message']).'\', '. + $row['code'].', \''.\SQLite3::escapeString($row['file']).'\', '.$row['line'].', \''.\SQLite3::escapeString($row['trace']).'\', \''. + $row['ip'].'\', '.$row['querytime'].', \''.$row['time'].'\', \''. + \SQLite3::escapeString($row['server_name']).'\', '.($row['server_port'] ? $row['server_port'] : 'NULL').', \''.\SQLite3::escapeString($row['request_uri']).'\', \''.\SQLite3::escapeString($row['post']).'\', \''. + \SQLite3::escapeString($row['http_referer']).'\', \''.\SQLite3::escapeString($row['http_user_agent']).'\', '.($row['user'] ? $row['user'] : 'NULL').','.true.');');*/ if(!$con->exec('INSERT OR IGNORE INTO '.\SYSTEM\DBD\system_log::NAME_MYS. '(`ID`, `class`, `message`, `code`, `file`, `line`, `trace`, `ip`, `querytime`, `time`,'. ' `server_name`, `server_port`, `request_uri`, `post`,'. @@ -50,8 +59,8 @@ class cron_log2sqlite extends \SYSTEM\CRON\cronjob{ 'VALUES ('.$row['ID'].', \''.\SQLite3::escapeString($row['class']).'\', \''.\SQLite3::escapeString($row['message']).'\', '. $row['code'].', \''.\SQLite3::escapeString($row['file']).'\', '.$row['line'].', \''.\SQLite3::escapeString($row['trace']).'\', \''. $row['ip'].'\', '.$row['querytime'].', \''.$row['time'].'\', \''. - \SQLite3::escapeString($row['server_name']).'\', '.$row['server_port'].', \''.\SQLite3::escapeString($row['request_uri']).'\', \''.\SQLite3::escapeString($row['post']).'\', \''. - \SQLite3::escapeString($row['http_referer']).'\', \''.\SQLite3::escapeString($row['http_user_agent']).'\', '.$row['user'].','.true.');')){ + \SQLite3::escapeString($row['server_name']).'\', '.($row['server_port'] ? $row['server_port'] : 'NULL').', \''.\SQLite3::escapeString($row['request_uri']).'\', \''.\SQLite3::escapeString($row['post']).'\', \''. + \SQLite3::escapeString($row['http_referer']).'\', \''.\SQLite3::escapeString($row['http_user_agent']).'\', '.($row['user'] ? $row['user'] : 'NULL').','.true.');')){ new \SYSTEM\LOG\ERROR('failed to insert into log archiev'); return cronstatus::CRON_STATUS_FAIL; } diff --git a/dbd/qq/SYS_LOG_MONTH.php b/dbd/qq/SYS_LOG_MONTH.php index 5a1101f..d6aa7cc 100644 --- a/dbd/qq/SYS_LOG_MONTH.php +++ b/dbd/qq/SYS_LOG_MONTH.php @@ -5,7 +5,7 @@ class SYS_LOG_MONTH extends \SYSTEM\DB\QP { protected static function query(){ return new \SYSTEM\DB\QQuery(get_class(), //pg -'SELECT * FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE MONTH(time) = $1 AND YEAR(time) = $2 ORDER BY time ASC', +'SELECT * FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE EXTRACT(MONTH FROM time)::INTEGER = $1 AND EXTRACT(YEAR FROM time)::INTEGER = $2 ORDER BY time ASC', //mys 'SELECT * FROM '.\SYSTEM\DBD\system_log::NAME_MYS.' WHERE MONTH(time) = ? AND YEAR(time) = ? ORDER BY time ASC' );}} \ No newline at end of file diff --git a/dbd/qq/SYS_LOG_MONTH_DEL.php b/dbd/qq/SYS_LOG_MONTH_DEL.php index 100cee9..ce1a642 100644 --- a/dbd/qq/SYS_LOG_MONTH_DEL.php +++ b/dbd/qq/SYS_LOG_MONTH_DEL.php @@ -5,7 +5,7 @@ class SYS_LOG_MONTH_DEL extends \SYSTEM\DB\QP { protected static function query(){ return new \SYSTEM\DB\QQuery(get_class(), //pg -'DELETE FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE MONTH(time) = $1 AND YEAR(time) = $2;', +'DELETE FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE EXTRACT(MONTH FROM time)::INTEGER = $1 AND EXTRACT(YEAR FROM time)::INTEGER = $2;', //mys 'DELETE FROM '.\SYSTEM\DBD\system_log::NAME_MYS.' WHERE MONTH(time) = ? AND YEAR(time) = ?;' );}} \ No newline at end of file diff --git a/dbd/qq/SYS_LOG_OLDEST.php b/dbd/qq/SYS_LOG_OLDEST.php index 7d5459d..b5332a1 100644 --- a/dbd/qq/SYS_LOG_OLDEST.php +++ b/dbd/qq/SYS_LOG_OLDEST.php @@ -5,7 +5,7 @@ class SYS_LOG_OLDEST extends \SYSTEM\DB\QQ { protected static function query(){ return new \SYSTEM\DB\QQuery(get_class(), //pg -'SELECT MONTH(time) as month, YEAR(time) as year FROM '.\SYSTEM\DBD\system_log::NAME_PG.' ORDER BY time ASC LIMIT 1', +'SELECT EXTRACT(MONTH FROM time)::INTEGER as month, EXTRACT(YEAR FROM time)::INTEGER as year FROM '.\SYSTEM\DBD\system_log::NAME_PG.' ORDER BY time ASC LIMIT 1', //mys 'SELECT MONTH(time) as month, YEAR(time) as year FROM '.\SYSTEM\DBD\system_log::NAME_MYS.' ORDER BY time ASC LIMIT 1' );}} \ No newline at end of file diff --git a/dbd/sql/pg/data/sai_api.sql b/dbd/sql/pg/data/sai_api.sql index 30f0cc0..c04f787 100644 --- a/dbd/sql/pg/data/sai_api.sql +++ b/dbd/sql/pg/data/sai_api.sql @@ -19,6 +19,11 @@ INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, ve INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (27, 42, 2, 11, 'create', 'locale', 'LANG'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (30, 42, 2, 10, 'files', 'cat', 'STRING'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (31, 42, 3, 30, 'files', 'id', 'STRING'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (50, 42, 2, 10, 'pagestates', 'group', 'UINT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (51, 42, 1, 50, NULL, 'js', NULL); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (52, 42, 2, 51, NULL, 'group', 'UINT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (55, 42, 1, 50, NULL, 'css', NULL); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (56, 42, 2, 55, NULL, 'group', 'UINT'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (40, 42, 4, -1, NULL, '_lang', 'LANG'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (41, 42, 4, -1, NULL, '_result', 'RESULT'); @@ -43,6 +48,7 @@ INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, ve -- INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (220, 42, 0, 200, 'stats', 'name', null); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (221, 42, 3, 220, null, 'filter', 'UINT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (222, 42, 3, 220, null, 'db', 'STRING'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (300, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_security', 'action', NULL); @@ -70,7 +76,16 @@ INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, ve -- INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (500, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_config', 'action', NULL); --- INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (600, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_api', 'action', NULL); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (600, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_api', 'action', NULL); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (601, 42, 2, 600, 'addcall', 'ID', 'INT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (602, 42, 2, 600, 'addcall', 'group', 'INT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (603, 42, 2, 600, 'addcall', 'type', 'INT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (604, 42, 2, 600, 'addcall', 'parentID', 'INT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (605, 42, 2, 600, 'addcall', 'parentValue', 'STRING'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (606, 42, 2, 600, 'addcall', 'name', 'STRING'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (607, 42, 2, 600, 'addcall', 'verify', 'ALL'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (608, 42, 2, 600, 'deletecall', 'ID', 'INT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (609, 42, 2, 600, 'deletedialog', 'ID', 'INT'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (700, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_locale', 'action', NULL); @@ -114,6 +129,8 @@ INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, ve INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1002, 42, 2, 1000, 'open', 'todo', 'INT'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1003, 42, 2, 1000, 'close', 'todo', 'INT'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1004, 42, 2, 1000, 'add', 'todo', 'STRING'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1010, 42, 2, 1000, 'edit', 'todo', 'INT'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1011, 42, 2, 1000, 'edit', 'message', 'STRING'); -- INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1100, 42, 0, 0, '_SYSTEM_SAI_saimod_sys_docu', 'action', NULL); @@ -126,4 +143,6 @@ INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, ve INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1205, 42, 2, 1200, 'add', 'day_week', 'INT'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1206, 42, 2, 1200, 'add', 'month', 'INT'); INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1208, 42, 2, 1200, 'del', 'cls', 'STRING'); -INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1209, 42, 2, 1200, 'deldialog', 'cls', 'STRING'); \ No newline at end of file +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1209, 42, 2, 1200, 'deldialog', 'cls', 'STRING'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1210, 42, 2, 1200, 'change', 'cls', 'STRING'); +INSERT INTO system.api ("ID", "group", type, "parentID", "parentValue", name, verify) VALUES (1211, 42, 2, 1200, 'change', 'status', 'INT'); \ No newline at end of file diff --git a/dbd/sql/pg/data/system_cron.sql b/dbd/sql/pg/data/system_cron.sql new file mode 100644 index 0000000..87cbb0a --- /dev/null +++ b/dbd/sql/pg/data/system_cron.sql @@ -0,0 +1 @@ +INSERT INTO system.cron (class, min, hour, day, day_week, month, last_run, status) VALUES ('\SYSTEM\CRON\cron_log2sqlite', 0, 0, 0, 0, 0, NULL, 0); \ No newline at end of file diff --git a/sai/modules/saimod_sys_cron/qq/SYS_SAIMOD_CRON_CHANGE.php b/sai/modules/saimod_sys_cron/qq/SYS_SAIMOD_CRON_CHANGE.php index dc690a3..aa278b5 100644 --- a/sai/modules/saimod_sys_cron/qq/SYS_SAIMOD_CRON_CHANGE.php +++ b/sai/modules/saimod_sys_cron/qq/SYS_SAIMOD_CRON_CHANGE.php @@ -5,7 +5,7 @@ class SYS_SAIMOD_CRON_CHANGE extends \SYSTEM\DB\QP { protected static function query(){ return new \SYSTEM\DB\QQuery(get_class(), //pg -'UPDATE '.\SYSTEM\DBD\system_cron::NAME_PG.' SET status = $1 WHERE `class` = $2;', +'UPDATE '.\SYSTEM\DBD\system_cron::NAME_PG.' SET status = $1 WHERE class = $2;', //mys 'UPDATE '.\SYSTEM\DBD\system_cron::NAME_MYS.' SET status = ? WHERE `class` = ?;' );}} diff --git a/sai/modules/saimod_sys_cron/saimod_sys_cron.php b/sai/modules/saimod_sys_cron/saimod_sys_cron.php index d7a9e43..0ce889b 100644 --- a/sai/modules/saimod_sys_cron/saimod_sys_cron.php +++ b/sai/modules/saimod_sys_cron/saimod_sys_cron.php @@ -20,7 +20,7 @@ class saimod_sys_cron extends \SYSTEM\SAI\SaiModule { public static function sai_mod__system_sai_saimod_sys_cron_action_change($cls,$status){ if(!\SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI_CRON)){ throw new \SYSTEM\LOG\ERROR("You dont have edit Rights - Cant proceeed");} - \SYSTEM\DBD\SYS_SAIMOD_CRON_CHANGE::QI(array($status,$cls)); + \SYSTEM\DBD\SYS_SAIMOD_CRON_CHANGE::QI(array($status, $cls)); return \SYSTEM\LOG\JsonResult::ok(); } From 905f323efb533544e9b3f87c95a54f6f02d897c2 Mon Sep 17 00:00:00 2001 From: rylon Date: Tue, 20 Jan 2015 10:02:28 +0100 Subject: [PATCH 02/34] pg fixes cron --- cron/cron_log2sqlite.php | 26 ++++++++++++++------------ dbd/qq/SYS_LOG_MONTH.php | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cron/cron_log2sqlite.php b/cron/cron_log2sqlite.php index 0c20518..d618749 100644 --- a/cron/cron_log2sqlite.php +++ b/cron/cron_log2sqlite.php @@ -40,35 +40,37 @@ class cron_log2sqlite extends \SYSTEM\CRON\cronjob{ $con->exec('begin transaction'); $res = \SYSTEM\DBD\SYS_LOG_MONTH::QQ(array($oldest['month'],$oldest['year'])); $i = 0; + $j = 0; while($row = $res->next()){ set_time_limit(30); - $i++; - /*new \SYSTEM\LOG\INFO('INSERT OR IGNORE INTO '.\SYSTEM\DBD\system_log::NAME_MYS. - '(`ID`, `class`, `message`, `code`, `file`, `line`, `trace`, `ip`, `querytime`, `time`,'. - ' `server_name`, `server_port`, `request_uri`, `post`,'. - ' `http_referer`, `http_user_agent`, `user`, `thrown`)'. - 'VALUES ('.$row['ID'].', \''.\SQLite3::escapeString($row['class']).'\', \''.\SQLite3::escapeString($row['message']).'\', '. - $row['code'].', \''.\SQLite3::escapeString($row['file']).'\', '.$row['line'].', \''.\SQLite3::escapeString($row['trace']).'\', \''. - $row['ip'].'\', '.$row['querytime'].', \''.$row['time'].'\', \''. - \SQLite3::escapeString($row['server_name']).'\', '.($row['server_port'] ? $row['server_port'] : 'NULL').', \''.\SQLite3::escapeString($row['request_uri']).'\', \''.\SQLite3::escapeString($row['post']).'\', \''. - \SQLite3::escapeString($row['http_referer']).'\', \''.\SQLite3::escapeString($row['http_user_agent']).'\', '.($row['user'] ? $row['user'] : 'NULL').','.true.');');*/ + $i++; $j++; + $row['time'] = array_key_exists('time_pg', $row) ? $row['time_pg'] : '\''.$row['time'].'\''; if(!$con->exec('INSERT OR IGNORE INTO '.\SYSTEM\DBD\system_log::NAME_MYS. '(`ID`, `class`, `message`, `code`, `file`, `line`, `trace`, `ip`, `querytime`, `time`,'. ' `server_name`, `server_port`, `request_uri`, `post`,'. ' `http_referer`, `http_user_agent`, `user`, `thrown`)'. 'VALUES ('.$row['ID'].', \''.\SQLite3::escapeString($row['class']).'\', \''.\SQLite3::escapeString($row['message']).'\', '. $row['code'].', \''.\SQLite3::escapeString($row['file']).'\', '.$row['line'].', \''.\SQLite3::escapeString($row['trace']).'\', \''. - $row['ip'].'\', '.$row['querytime'].', \''.$row['time'].'\', \''. + $row['ip'].'\', '.$row['querytime'].', '.$row['time'].', \''. \SQLite3::escapeString($row['server_name']).'\', '.($row['server_port'] ? $row['server_port'] : 'NULL').', \''.\SQLite3::escapeString($row['request_uri']).'\', \''.\SQLite3::escapeString($row['post']).'\', \''. \SQLite3::escapeString($row['http_referer']).'\', \''.\SQLite3::escapeString($row['http_user_agent']).'\', '.($row['user'] ? $row['user'] : 'NULL').','.true.');')){ new \SYSTEM\LOG\ERROR('failed to insert into log archiev'); return cronstatus::CRON_STATUS_FAIL; } + if($j > 5000){ + $j = 0; + set_time_limit(30); + if(!$con->exec('end transaction')){ + new \SYSTEM\LOG\ERROR('failed to insert into log archiev'); + return cronstatus::CRON_STATUS_FAIL;}; + $con->exec('begin transaction'); + } } + set_time_limit(30); if(!$con->exec('end transaction')){ new \SYSTEM\LOG\ERROR('failed to insert into log archiev'); return cronstatus::CRON_STATUS_FAIL;}; - + set_time_limit(30); //delete from database if(!\SYSTEM\DBD\SYS_LOG_MONTH_DEL::QI(array($oldest['month'],$oldest['year']))){ new \SYSTEM\LOG\ERROR('failed to delete log entries'); diff --git a/dbd/qq/SYS_LOG_MONTH.php b/dbd/qq/SYS_LOG_MONTH.php index d6aa7cc..89c28dc 100644 --- a/dbd/qq/SYS_LOG_MONTH.php +++ b/dbd/qq/SYS_LOG_MONTH.php @@ -5,7 +5,7 @@ class SYS_LOG_MONTH extends \SYSTEM\DB\QP { protected static function query(){ return new \SYSTEM\DB\QQuery(get_class(), //pg -'SELECT * FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE EXTRACT(MONTH FROM time)::INTEGER = $1 AND EXTRACT(YEAR FROM time)::INTEGER = $2 ORDER BY time ASC', +'SELECT extract(epoch from now()) as time_pg,* FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE EXTRACT(MONTH FROM time)::INTEGER = $1 AND EXTRACT(YEAR FROM time)::INTEGER = $2 ORDER BY time ASC', //mys 'SELECT * FROM '.\SYSTEM\DBD\system_log::NAME_MYS.' WHERE MONTH(time) = ? AND YEAR(time) = ? ORDER BY time ASC' );}} \ No newline at end of file From 9f703c5c5e5172755fe3656006cafd25adf7c192 Mon Sep 17 00:00:00 2001 From: rylon Date: Thu, 29 Jan 2015 17:25:53 +0100 Subject: [PATCH 03/34] cron extraction fixed for pg and huge dataload --- cron/cron_log2sqlite.php | 27 +++++++-------------------- dbd/qq/SYS_LOG_DEL.php | 11 +++++++++++ dbd/qq/SYS_LOG_MONTH.php | 4 ++-- 3 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 dbd/qq/SYS_LOG_DEL.php diff --git a/cron/cron_log2sqlite.php b/cron/cron_log2sqlite.php index d618749..f963ea3 100644 --- a/cron/cron_log2sqlite.php +++ b/cron/cron_log2sqlite.php @@ -9,11 +9,9 @@ class cron_log2sqlite extends \SYSTEM\CRON\cronjob{ if( $oldest['year'] >= $now_year && $oldest['month'] >= $now_month){ return cronstatus::CRON_STATUS_SUCCESFULLY;} - $filename = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CRON_LOG2SQLITE_PATH).$oldest['year'].'.'.$oldest['month'].'.db'; //extract whole month to file $con = new \SYSTEM\DB\Connection(new \SYSTEM\DB\DBInfoSQLite($filename)); - //create table $con->query('CREATE TABLE IF NOT EXISTS `system_log` ('. ' `ID` INT(10) NOT NULL,'. @@ -38,43 +36,32 @@ class cron_log2sqlite extends \SYSTEM\CRON\cronjob{ //write data as trasaction $con->exec('begin transaction'); + set_time_limit(30); $res = \SYSTEM\DBD\SYS_LOG_MONTH::QQ(array($oldest['month'],$oldest['year'])); - $i = 0; - $j = 0; while($row = $res->next()){ set_time_limit(30); - $i++; $j++; - $row['time'] = array_key_exists('time_pg', $row) ? $row['time_pg'] : '\''.$row['time'].'\''; + $row['time'] = array_key_exists('time_pg', $row) ? date("Y-m-d H:i:s", $row['time_pg']) : $row['time']; if(!$con->exec('INSERT OR IGNORE INTO '.\SYSTEM\DBD\system_log::NAME_MYS. '(`ID`, `class`, `message`, `code`, `file`, `line`, `trace`, `ip`, `querytime`, `time`,'. ' `server_name`, `server_port`, `request_uri`, `post`,'. ' `http_referer`, `http_user_agent`, `user`, `thrown`)'. 'VALUES ('.$row['ID'].', \''.\SQLite3::escapeString($row['class']).'\', \''.\SQLite3::escapeString($row['message']).'\', '. $row['code'].', \''.\SQLite3::escapeString($row['file']).'\', '.$row['line'].', \''.\SQLite3::escapeString($row['trace']).'\', \''. - $row['ip'].'\', '.$row['querytime'].', '.$row['time'].', \''. + $row['ip'].'\', '.$row['querytime'].', \''.$row['time'].'\', \''. \SQLite3::escapeString($row['server_name']).'\', '.($row['server_port'] ? $row['server_port'] : 'NULL').', \''.\SQLite3::escapeString($row['request_uri']).'\', \''.\SQLite3::escapeString($row['post']).'\', \''. \SQLite3::escapeString($row['http_referer']).'\', \''.\SQLite3::escapeString($row['http_user_agent']).'\', '.($row['user'] ? $row['user'] : 'NULL').','.true.');')){ new \SYSTEM\LOG\ERROR('failed to insert into log archiev'); return cronstatus::CRON_STATUS_FAIL; } - if($j > 5000){ - $j = 0; - set_time_limit(30); - if(!$con->exec('end transaction')){ - new \SYSTEM\LOG\ERROR('failed to insert into log archiev'); - return cronstatus::CRON_STATUS_FAIL;}; - $con->exec('begin transaction'); - } + //Delete single + if(!\SYSTEM\DBD\SYS_LOG_DEL::QI(array($row['ID']))){ + new \SYSTEM\LOG\ERROR('failed to delete log entries'); + return cronstatus::CRON_STATUS_FAIL;} } set_time_limit(30); if(!$con->exec('end transaction')){ new \SYSTEM\LOG\ERROR('failed to insert into log archiev'); return cronstatus::CRON_STATUS_FAIL;}; - set_time_limit(30); - //delete from database - if(!\SYSTEM\DBD\SYS_LOG_MONTH_DEL::QI(array($oldest['month'],$oldest['year']))){ - new \SYSTEM\LOG\ERROR('failed to delete log entries'); - return cronstatus::CRON_STATUS_FAIL;} return cronstatus::CRON_STATUS_SUCCESFULLY; } diff --git a/dbd/qq/SYS_LOG_DEL.php b/dbd/qq/SYS_LOG_DEL.php new file mode 100644 index 0000000..d1f592b --- /dev/null +++ b/dbd/qq/SYS_LOG_DEL.php @@ -0,0 +1,11 @@ + Date: Thu, 29 Jan 2015 17:28:27 +0100 Subject: [PATCH 04/34] 10.000 values @ one time instead of 1.000 --- dbd/qq/SYS_LOG_MONTH.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbd/qq/SYS_LOG_MONTH.php b/dbd/qq/SYS_LOG_MONTH.php index 75e2b44..19ddf45 100644 --- a/dbd/qq/SYS_LOG_MONTH.php +++ b/dbd/qq/SYS_LOG_MONTH.php @@ -5,7 +5,7 @@ class SYS_LOG_MONTH extends \SYSTEM\DB\QP { protected static function query(){ return new \SYSTEM\DB\QQuery(get_class(), //pg -'SELECT extract(epoch from time) as time_pg,* FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE EXTRACT(MONTH FROM time)::INTEGER = $1 AND EXTRACT(YEAR FROM time)::INTEGER = $2 LIMIT 1000;',//ORDER BY time ASC +'SELECT extract(epoch from time) as time_pg,* FROM '.\SYSTEM\DBD\system_log::NAME_PG.' WHERE EXTRACT(MONTH FROM time)::INTEGER = $1 AND EXTRACT(YEAR FROM time)::INTEGER = $2 LIMIT 10000;',//ORDER BY time ASC //mys -'SELECT * FROM '.\SYSTEM\DBD\system_log::NAME_MYS.' WHERE MONTH(time) = ? AND YEAR(time) = ? ORDER BY time ASC LIMIT 1000;' +'SELECT * FROM '.\SYSTEM\DBD\system_log::NAME_MYS.' WHERE MONTH(time) = ? AND YEAR(time) = ? ORDER BY time ASC LIMIT 10000;' );}} \ No newline at end of file From bc5e7df87cefe05560eb16d11a8ad725d9024818 Mon Sep 17 00:00:00 2001 From: rylon Date: Wed, 11 Mar 2015 13:54:53 +0100 Subject: [PATCH 05/34] cron_cache_delete implemented --- cron/cron_cache_delete.php | 9 +++++++++ dbd/qq/SYS_CACHE_DELETE_ALL.php | 10 ++++++++++ dbd/sql/mysql/data/system_cron.sql | 3 ++- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 cron/cron_cache_delete.php create mode 100644 dbd/qq/SYS_CACHE_DELETE_ALL.php diff --git a/cron/cron_cache_delete.php b/cron/cron_cache_delete.php new file mode 100644 index 0000000..6b14080 --- /dev/null +++ b/cron/cron_cache_delete.php @@ -0,0 +1,9 @@ + Date: Thu, 12 Mar 2015 02:18:45 +0100 Subject: [PATCH 06/34] saimod sys locale pg fix --- sai/modules/saimod_sys_text/saimod_sys_text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sai/modules/saimod_sys_text/saimod_sys_text.php b/sai/modules/saimod_sys_text/saimod_sys_text.php index 18faa84..ffb5970 100644 --- a/sai/modules/saimod_sys_text/saimod_sys_text.php +++ b/sai/modules/saimod_sys_text/saimod_sys_text.php @@ -70,7 +70,7 @@ class saimod_sys_text extends \SYSTEM\SAI\SaiModule { $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); $res = null; if(\SYSTEM\system::isSystemDbInfoPG()){ - $res = $con->prepare('newText' ,'UPDATE '.\SYSTEM\DBD\system_locale_string::NAME_PG.' SET "'.$lang.'"=$1 WHERE category = $1 AND id=$2;', array($newtext, $category, $id)); + $res = $con->prepare('newText' ,'UPDATE '.\SYSTEM\DBD\system_locale_string::NAME_PG.' SET "'.$lang.'"=$1 WHERE category = $2 AND id=$3;', array($newtext, $category, $id)); } else { $res = $con->prepare('newText' ,'UPDATE '.\SYSTEM\DBD\system_locale_string::NAME_MYS.' SET '.$lang.'=? WHERE category = ? AND id=?;', array($newtext, $category, $id)); } From 2a2330b6d22a4ab9cb6c722b48ac107b8c36dd63 Mon Sep 17 00:00:00 2001 From: rylon Date: Wed, 8 Apr 2015 17:25:39 +0200 Subject: [PATCH 07/34] saistart analytics, fixed sai log user counting --- .../qq/SYS_SAIMOD_LOG_ANALYTICS.php | 18 +++++++++++++ .../qq/SYS_SAIMOD_LOG_BASIC_VISITOR.php | 4 +-- .../qq/SYS_SAIMOD_LOG_UNIQUE_BASIC.php | 4 +-- .../qq/SYS_SAIMOD_LOG_UNIQUE_REFERER.php | 4 +-- sai/modules/saimod_sys_log/saimod_sys_log.php | 25 +++++++++++++++--- .../tpl/saimod_sys_log_analytics.tpl | 26 +++++++++++++++++++ .../tpl/saimod_sys_log_stats.tpl | 2 +- .../saistart_sys_sai/saistart_sys_sai.php | 1 + .../saistart_sys_sai/tpl/content_loggedin.tpl | 9 +------ 9 files changed, 75 insertions(+), 18 deletions(-) create mode 100644 sai/modules/saimod_sys_log/qq/SYS_SAIMOD_LOG_ANALYTICS.php create mode 100644 sai/modules/saimod_sys_log/tpl/saimod_sys_log_analytics.tpl diff --git a/sai/modules/saimod_sys_log/qq/SYS_SAIMOD_LOG_ANALYTICS.php b/sai/modules/saimod_sys_log/qq/SYS_SAIMOD_LOG_ANALYTICS.php new file mode 100644 index 0000000..da49f4d --- /dev/null +++ b/sai/modules/saimod_sys_log/qq/SYS_SAIMOD_LOG_ANALYTICS.php @@ -0,0 +1,18 @@ + $file));} } + //positioning problem + //$vars['analytics'] = self::analytics(); return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_log/tpl/saimod_sys_log_stats.tpl'), $vars);} public static function sai_mod__SYSTEM_SAI_saimod_sys_log_action_stats_name_class_system($filter,$db){ @@ -99,7 +118,7 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule { $res = $con->prepare('unique_basic', 'SELECT datetime(strftime("%s",'.\SYSTEM\DBD\system_log::FIELD_TIME.') - strftime("%s",'.\SYSTEM\DBD\system_log::FIELD_TIME.')%:filter,"unixepoch", "localtime") as day,' .'count(*) as count,' - .'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,' + .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_USER.') as user_unique,' .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique,' .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_SERVER_NAME.') as server_name_unique' .' FROM '.\SYSTEM\DBD\system_log::NAME_MYS @@ -169,7 +188,7 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule { $res = $con->prepare('unique_referer', 'SELECT datetime(strftime("%s",'.\SYSTEM\DBD\system_log::FIELD_TIME.') - strftime("%s",'.\SYSTEM\DBD\system_log::FIELD_TIME.')%:filter,"unixepoch", "localtime") as day,' .'count(*) as count,' - .'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,' + .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_USER.') as user_unique,' .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique,' .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_HTTP_REFERER.') as http_referer_unique,' .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_HTTP_USER_AGENT.') as http_user_agent_unique' @@ -193,7 +212,7 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule { $res = $con->prepare('basic_visitor', 'SELECT datetime(strftime("%s",'.\SYSTEM\DBD\system_log::FIELD_TIME.') - strftime("%s",'.\SYSTEM\DBD\system_log::FIELD_TIME.')%:filter,"unixepoch", "localtime") as day,' .'count(*) as count,' - .'count(distinct "'.\SYSTEM\DBD\system_log::FIELD_USER.'") as user_unique,' + .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_USER.') as user_unique,' .'count(distinct '.\SYSTEM\DBD\system_log::FIELD_IP.') as ip_unique' .' FROM '.\SYSTEM\DBD\system_log::NAME_MYS .' GROUP BY day' diff --git a/sai/modules/saimod_sys_log/tpl/saimod_sys_log_analytics.tpl b/sai/modules/saimod_sys_log/tpl/saimod_sys_log_analytics.tpl new file mode 100644 index 0000000..e9cad3f --- /dev/null +++ b/sai/modules/saimod_sys_log/tpl/saimod_sys_log_analytics.tpl @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
TodayWeekMonth
Log${log_today}${log_week}${log_month}
IPs${ip_today}${ip_week}${ip_month}
Users${user_today}${user_week}${user_month}
\ No newline at end of file diff --git a/sai/modules/saimod_sys_log/tpl/saimod_sys_log_stats.tpl b/sai/modules/saimod_sys_log/tpl/saimod_sys_log_stats.tpl index a004b46..2f0bb19 100644 --- a/sai/modules/saimod_sys_log/tpl/saimod_sys_log_stats.tpl +++ b/sai/modules/saimod_sys_log/tpl/saimod_sys_log_stats.tpl @@ -6,7 +6,7 @@
+
+
+ +
+
+ + +
+ \ No newline at end of file diff --git a/sai/modules/saistart_sys_sai/tpl/content_loggedin.tpl b/sai/modules/saistart_sys_sai/tpl/content_loggedin.tpl index 1dbeab6..1981b27 100644 --- a/sai/modules/saistart_sys_sai/tpl/content_loggedin.tpl +++ b/sai/modules/saistart_sys_sai/tpl/content_loggedin.tpl @@ -19,7 +19,29 @@ Current SYSTEM Version: ${git_system}
- ${logout} +

${basic_logout}

+ + + + + + + + + + + + + +
${basic_username}${username}
${basic_locale}${locale}
${basic_admin_rights}${isadmin}
+ ${basic_text_logout} +
+
+
+ + +
+
diff --git a/sai/modules/saistart_sys_sai/tpl/login.tpl b/sai/modules/saistart_sys_sai/tpl/login.tpl deleted file mode 100644 index 7682d4c..0000000 --- a/sai/modules/saistart_sys_sai/tpl/login.tpl +++ /dev/null @@ -1,33 +0,0 @@ -

${basic_login}

-${basic_text_login} -
-
-
-
-
- -
-
- -
-
- - -
-
\ No newline at end of file diff --git a/sai/modules/saistart_sys_sai/tpl/logout.tpl b/sai/modules/saistart_sys_sai/tpl/logout.tpl deleted file mode 100644 index 5c71dbe..0000000 --- a/sai/modules/saistart_sys_sai/tpl/logout.tpl +++ /dev/null @@ -1,11 +0,0 @@ -

${basic_logout}

-${basic_text_logout} -
-
-
-
-
- - -
-
\ No newline at end of file From 20593db5d294ae96fed65b6bee2d3a1d660a1934 Mon Sep 17 00:00:00 2001 From: rylon Date: Wed, 8 Apr 2015 17:58:07 +0200 Subject: [PATCH 09/34] update locale in current session on switch --- system/locale.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/locale.php b/system/locale.php index efce804..5afee22 100644 --- a/system/locale.php +++ b/system/locale.php @@ -10,7 +10,8 @@ class locale { \SYSTEM\SECURITY\Security::save(self::SESSION_KEY, $lang); if(\SYSTEM\SECURITY\Security::isLoggedIn()){ - $user = \SYSTEM\SECURITY\Security::getUser(); + $user = \SYSTEM\SECURITY\Security::getUser(); + $user->locale = $lang; \SYSTEM\DBD\SYS_LOCALE_SET_LOCALE::Q1(array($lang, $user->id)); } From 64881854abeccbe2304998182c8f722f5355b736 Mon Sep 17 00:00:00 2001 From: rylon Date: Wed, 8 Apr 2015 19:00:45 +0200 Subject: [PATCH 10/34] saimod langswitcher, sai css --- sai/modules/autoload.inc | 1 + .../saimod_sys_langswitcher/autoload.inc | 4 ++ .../saimod_sys_langswitcher.php | 17 +++++++ .../saimod_sys_langswitcher}/tpl/language.tpl | 0 sai/page/css/sai.css | 46 ++++++++++++++----- sai/page/default_page.php | 9 ---- sai/page/tpl/sai.tpl | 27 ++++++----- 7 files changed, 70 insertions(+), 34 deletions(-) create mode 100644 sai/modules/saimod_sys_langswitcher/autoload.inc create mode 100644 sai/modules/saimod_sys_langswitcher/saimod_sys_langswitcher.php rename sai/{page => modules/saimod_sys_langswitcher}/tpl/language.tpl (100%) diff --git a/sai/modules/autoload.inc b/sai/modules/autoload.inc index 4bb638c..796292d 100644 --- a/sai/modules/autoload.inc +++ b/sai/modules/autoload.inc @@ -13,4 +13,5 @@ require_once dirname(__FILE__).'/saimod_sys_cache/autoload.inc'; require_once dirname(__FILE__).'/saimod_sys_cron/autoload.inc'; require_once dirname(__FILE__).'/saimod_sys_todo/autoload.inc'; require_once dirname(__FILE__).'/saimod_sys_docu/autoload.inc'; +require_once dirname(__FILE__).'/saimod_sys_langswitcher/autoload.inc'; require_once dirname(__FILE__).'/saimod_sys_login/autoload.inc'; \ No newline at end of file diff --git a/sai/modules/saimod_sys_langswitcher/autoload.inc b/sai/modules/saimod_sys_langswitcher/autoload.inc new file mode 100644 index 0000000..29ebcbf --- /dev/null +++ b/sai/modules/saimod_sys_langswitcher/autoload.inc @@ -0,0 +1,4 @@ + $lang));} + return $result; + } + public static function right_public(){return true;} + public static function right_right(){} + + //public static function css(){} + //public static function js(){} +} \ No newline at end of file diff --git a/sai/page/tpl/language.tpl b/sai/modules/saimod_sys_langswitcher/tpl/language.tpl similarity index 100% rename from sai/page/tpl/language.tpl rename to sai/modules/saimod_sys_langswitcher/tpl/language.tpl diff --git a/sai/page/css/sai.css b/sai/page/css/sai.css index 9344ed1..3ccab6d 100644 --- a/sai/page/css/sai.css +++ b/sai/page/css/sai.css @@ -1,24 +1,48 @@ -/* - Document : index.css - Created on : 31.01.2013, 01:59:37 - Author : CHRIS MEURISCH - Description: - Purpose of the stylesheet follows. -*/ - -.brand-logo{ +#sai_logo { + padding-left: 10px; float: left; padding-top: 8px; padding-right: 10px; } +#sai_brand{ + width: 170px; +} -.footer{ + +#sai_navbar{ + height:40px; +} + +#project_navbar{ + width:224px; + position: fixed; + left: 0px; + bottom: 0px; + top: 38px; +} + +#content-wrapper{ + overflow: auto; + position: absolute; + top: 40px; + bottom: 0px; + left: 224px; + right: 0px; + padding: 15px; + min-width:1000px; +} + +#content{ + width:100% +} + +#footer{ text-align: right; padding-right: 20px; color: #777; } -.footer a{ +#footer a{ color: #777; } diff --git a/sai/page/default_page.php b/sai/page/default_page.php index e526fd6..9290fb7 100644 --- a/sai/page/default_page.php +++ b/sai/page/default_page.php @@ -48,14 +48,6 @@ class default_page extends \SYSTEM\PAGE\Page { ''; return $result; } - - private static function lang_switcher(){ - $result = ''; - $langs = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_LANGS); - foreach($langs as $lang){ - $result .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'page/tpl/language.tpl'),array('lang' => $lang));} - return $result; - } public function html($_escaped_fragment_ = NULL){ $vars = array(); @@ -68,7 +60,6 @@ class default_page extends \SYSTEM\PAGE\Page { $vars['menu_proj'] = self::menu_proj(); $vars['title'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_TITLE); $vars['copyright'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_COPYRIGHT); - $vars['lang_switcher'] = self::lang_switcher(); $vars = array_merge($vars,\SYSTEM\locale::getStrings(\SYSTEM\DBD\system_locale_string::VALUE_CATEGORY_SYSTEM_SAI)); return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new \SYSTEM\PSAI(),'page/tpl/sai.tpl'), $vars); diff --git a/sai/page/tpl/sai.tpl b/sai/page/tpl/sai.tpl index c35b87a..29fb295 100644 --- a/sai/page/tpl/sai.tpl +++ b/sai/page/tpl/sai.tpl @@ -8,28 +8,27 @@ ${js} -