Merge branch 'master' of github.com:gebhardtdasense/system into saimod_security

This commit is contained in:
Ulf Gebhardt 2013-05-24 20:07:50 +02:00
commit a920225149
5 changed files with 142 additions and 8 deletions

View File

@ -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'));
}));
}

View File

@ -0,0 +1,18 @@
<?php
if( isset($_GET['truncate'])){
if(\SYSTEM\SECURITY\Security::check(\SYSTEM::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI)){
$con = new \SYSTEM\DB\Connection(\SYSTEM::getSystemDBInfo());
$res = $con->query('TRUNCATE system.sys_log;');
echo '1';
return TRUE;
}else{
echo '0';
return FALSE;
}
}
?>

View File

@ -2,20 +2,90 @@
namespace SYSTEM\SAI; namespace SYSTEM\SAI;
class saimod_sys_error extends \SYSTEM\SAI\SaiModule { 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()); $con = new \SYSTEM\DB\Connection(\SYSTEM\system::getSystemDBInfo());
$res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;'); $res = $con->query('SELECT * FROM system.sys_log ORDER BY time DESC LIMIT 100;');
$now = microtime(true); $now = microtime(true);
$result = '<table class="table table-hover table-condensed" style="overflow: auto;">'. $result = '<div id="table-wrapper"><table class="table table-hover table-condensed" style="overflow: auto;">'.
'<tr>'.'<th>'.'time ago in sec'.'</th>'.'<th>'.'time'.'</th>'.'<th>'.'class'.'</th>'.'<th>'.'message'.'</th>'.'<th>'.'code'.'</th>'.'<th>'.'file'.'</th>'.'<th>'.'line'.'</th>'.'<th>'.'ip'.'</th>'.'<th>'.'querytime'.'</tr>'; '<tr>'.'<th>'.'time ago in sec'.'</th>'.'<th>'.'time'.'</th>'.'<th>'.'class'.'</th>'.'<th>'.'message'.'</th>'.'<th>'.'code'.'</th>'.'<th>'.'file'.'</th>'.'<th>'.'line'.'</th>'.'<th>'.'ip'.'</th>'.'<th>'.'querytime'.'</tr>';
while($r = $res->next()){ while($r = $res->next()){
if($filter !== NULL && $filter !== 'all'){
if(self::tablerow_class($r['class']) === $filter){
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.(int)($now - strtotime($r['time'])).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td>'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</tr>'; $result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.(int)($now - strtotime($r['time'])).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td>'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</tr>';
} }
$result .= '</table>'; }else{
$result .= '<tr class="'.self::tablerow_class($r['class']).'">'.'<td>'.(int)($now - strtotime($r['time'])).'</td>'.'<td>'.$r['time'].'</td>'.'<td>'.$r['class'].'</td>'.'<td>'.$r['message'].'</td>'.'<td>'.$r['code'].'</td>'.'<td>'.$r['file'].'</td>'.'<td>'.$r['line'].'</td>'.'<td>'.$r['ip'].'</td>'.'<td>'.$r['querytime'].'</tr>';
}
}
$result .= '</table></div>';
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 = '<div id="truncate_modal" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>Truncate table system.sys_log</h3>
</div>
<div class="modal-body">
<p>This action will delete all error messages from databse. <br />
Are you sure?</p>
<span id="info_box" />
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Cancel</a>
<a href="#" class="btn btn-danger" id="truncate_table">Yes, delete all!</a>
</div>
</div>
<button id="refresh_error_table" class="btn" style="height: 32px; font-size: 13px;">Refresh</button>
<img id="loader" src="dasense/page/default_developer/img/ajax-loader.gif" style="margin-left: 10px; display: none;"/>
<div id="filter-error" class="btn-group" style="left: 60px;">
<button class="btn active" href="#" id="all">All</button>
<button class="btn" href="#" id="error">Error</button>
<button class="btn" href="#" id="warning">Warning</button>
<button class="btn" href="#" id="success">Info</button>
<button class="btn" href="#" id="info">Deprecated</button>
</diV>
<button data-toggle="modal" href="#truncate_modal" class="btn" style="height: 32px; font-size: 13px; float: right;">Truncate Table</button>
<br /><br />';
$result .= self::build_table($filter);
return $result; 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 right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function src_css(){} 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')));}
} }

View File

@ -5,9 +5,11 @@ namespace SYSTEM\SAI;
class saimod_sys_login extends \SYSTEM\SAI\SaiModule { class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
public static function html_content(){ public static function html_content(){
/*
if( isset($_POST['username']) && isset($_POST['password']) && if( isset($_POST['username']) && isset($_POST['password']) &&
\SYSTEM\SECURITY\Security::login(\SYSTEM\system::getSystemDBInfo(), $_POST['username'], sha1($_POST['password']), md5($_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());} return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/login_success.tpl'), array());}
*/
$vars = array(); $vars = array();
$vars['login'] = 'Login'; $vars['login'] = 'Login';

View File

@ -22,7 +22,7 @@
</div> </div>
</div> </div>
<div id="project_navbar" style="width:150px;float:left;"> <div id="project_navbar" style="width:210px;float:left;">
<div class="navbar-inner"> <div class="navbar-inner">
<ul class="nav nav-list"> <ul class="nav nav-list">
${menu_proj} ${menu_proj}