diff --git a/sai/modules/saimod_sys_error/sai_sys_error.js b/sai/modules/saimod_sys_error/sai_sys_error.js new file mode 100644 index 0000000..1ba62b6 --- /dev/null +++ b/sai/modules/saimod_sys_error/sai_sys_error.js @@ -0,0 +1,43 @@ +function init__SYSTEM_SAI_saimod_sys_error() { + + $('#truncate_table').click(function(){ + + $.ajax({ + type :'GET', + url : './?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_error&truncate=sys_log', + success : function(data) { + + if(data == 1){ + $('#info_box').html("deleting data..."); + $('#truncate_modal').modal('hide'); + $('#content-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_error'); + }else{ + $('#info_box').html("You do not have the permission to truncate table!"); + } + + } + }); + }); + + + $('#refresh_error_table').live("click", (function(){ + + $('img#loader').show(); + + $('#content-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_error'); + + setTimeout("$('img#loader').hide()", 1300); + + })); + + + $("#filter-error button").live("click", (function(){ + + $(this).parents().children().removeClass('active'); + $(this).addClass('active'); + + + $('#table-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_error&filter_error='+$(this).attr('id')); + })); + +} \ No newline at end of file diff --git a/sai/modules/saimod_sys_error/sai_sys_error_truncate.php b/sai/modules/saimod_sys_error/sai_sys_error_truncate.php new file mode 100644 index 0000000..f1479fb --- /dev/null +++ b/sai/modules/saimod_sys_error/sai_sys_error_truncate.php @@ -0,0 +1,18 @@ +query('TRUNCATE system.sys_log;'); + echo '1'; + return TRUE; + }else{ + echo '0'; + return FALSE; + } + +} + +?> diff --git a/sai/modules/saimod_sys_error/saimod_sys_error.php b/sai/modules/saimod_sys_error/saimod_sys_error.php index b4b45ae..6dfb5f6 100644 --- a/sai/modules/saimod_sys_error/saimod_sys_error.php +++ b/sai/modules/saimod_sys_error/saimod_sys_error.php @@ -2,20 +2,90 @@ namespace SYSTEM\SAI; + class saimod_sys_error extends \SYSTEM\SAI\SaiModule { - public static function html_content(){ + + private static function truncate_syslog(){ + if(\SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI)){ + $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); + $res = $con->query('TRUNCATE system.sys_log;'); + return true; + }else{ + return false; + } + } + + + private static function build_table($filter){ + $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo()); $res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;'); - $now = microtime(true); - $result = ''. + $result = '
'. ''.''.''.''.''.''.''.''.''.''; while($r = $res->next()){ - $result .= ''.''.''.''.''.''.''.''.''.''; + + if($filter !== NULL && $filter !== 'all'){ + if(self::tablerow_class($r['class']) === $filter){ + $result .= ''.''.''.''.''.''.''.''.''.''; + } + }else{ + $result .= ''.''.''.''.''.''.''.''.''.''; + } } - $result .= '
'.'time ago in sec'.''.'time'.''.'class'.''.'message'.''.'code'.''.'file'.''.'line'.''.'ip'.''.'querytime'.'
'.(int)($now - strtotime($r['time'])).''.$r['time'].''.$r['class'].''.$r['message'].''.$r['code'].''.$r['file'].''.$r['line'].''.$r['ip'].''.$r['querytime'].'
'.(int)($now - strtotime($r['time'])).''.$r['time'].''.$r['class'].''.$r['message'].''.$r['code'].''.$r['file'].''.$r['line'].''.$r['ip'].''.$r['querytime'].'
'.(int)($now - strtotime($r['time'])).''.$r['time'].''.$r['class'].''.$r['message'].''.$r['code'].''.$r['file'].''.$r['line'].''.$r['ip'].''.$r['querytime'].'
'; + $result .= ''; + + return $result; + + } + + + public static function html_content(){ + + + if( isset($_GET['truncate'])){ + return self::truncate_syslog(); + } + + if( isset($_GET['filter_error'])){ + return self::build_table($_GET['filter_error']); + }else{ + $filter = NULL; + } + + + $result = ' + + +
+ + + + + +
+ +

'; + + + $result .= self::build_table($filter); + return $result; } @@ -40,5 +110,6 @@ class saimod_sys_error extends \SYSTEM\SAI\SaiModule { public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);} public static function src_css(){} - public static function src_js(){} + public static function src_js(){return \SYSTEM\LOG\JsonResult::toString( + array( \SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_error/sai_sys_error.js')));} } \ No newline at end of file diff --git a/sai/modules/saimod_sys_login/saimod_sys_login.php b/sai/modules/saimod_sys_login/saimod_sys_login.php index 6828787..4f77ec6 100644 --- a/sai/modules/saimod_sys_login/saimod_sys_login.php +++ b/sai/modules/saimod_sys_login/saimod_sys_login.php @@ -5,10 +5,12 @@ namespace SYSTEM\SAI; class saimod_sys_login extends \SYSTEM\SAI\SaiModule { public static function html_content(){ + /* if( isset($_POST['username']) && isset($_POST['password']) && \SYSTEM\SECURITY\Security::login(\SYSTEM\system::getSystemDBInfo(), $_POST['username'], sha1($_POST['password']), md5($_POST['password']))){ return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/login_success.tpl'), array());} - + */ + $vars = array(); $vars['login'] = 'Login'; $vars['logout'] = 'Logout'; diff --git a/sai/page/default_page/sai.tpl b/sai/page/default_page/sai.tpl index 23edeef..c061f51 100644 --- a/sai/page/default_page/sai.tpl +++ b/sai/page/default_page/sai.tpl @@ -22,7 +22,7 @@ -
+