log viewer
This commit is contained in:
parent
cf76cad931
commit
bd034da8f8
3 changed files with 89 additions and 22 deletions
|
@ -25,21 +25,70 @@
|
|||
//require_once('../../config/config.php');
|
||||
require_once('../lib/base.php');
|
||||
require( 'template.php' );
|
||||
|
||||
if( !OC_USER::isLoggedIn()){
|
||||
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
|
||||
header( 'Location: '.OC_HELPER::linkTo( 'index.php' ));
|
||||
exit();
|
||||
}
|
||||
|
||||
OC_APP::setActiveNavigationEntry( "log" );
|
||||
$logs=OC_LOG::get( $dir );
|
||||
//load the script
|
||||
OC_UTIL::addScript( "log", "log" );
|
||||
|
||||
foreach( $logs as &$i ){
|
||||
$i["date"] = date( $CONFIG_DATEFORMAT, $i['timestamp'] );
|
||||
$i["action"] = OC_LOG::$TYPE[$i['type']];
|
||||
$allActions=array('login','logout','read','write','create','delete');
|
||||
|
||||
//check for a submited config
|
||||
if(isset($_POST['size'])){
|
||||
$selectedActions=array();
|
||||
foreach($allActions as $action){
|
||||
if(isset($_POST[$action]) and $_POST[$action]=='on'){
|
||||
$selectedActions[]=$action;
|
||||
}
|
||||
}
|
||||
OC_APPCONFIG::setValue('log','actions',implode(',',$selectedActions));
|
||||
OC_APPCONFIG::setValue('log','pagesize',$_POST['size']);
|
||||
}
|
||||
|
||||
$tmpl = new OC_TEMPLATE( "log", "index", "admin" );
|
||||
$tmpl->assign( "logs", $logs );
|
||||
OC_APP::setActiveNavigationEntry( 'log' );
|
||||
$logs=OC_LOG::get();
|
||||
|
||||
$selectedActions=explode(',',OC_APPCONFIG::getValue('log','actions',implode(',',$allActions)));
|
||||
$logs=OC_LOG::filterAction($logs,$selectedActions);
|
||||
|
||||
$pageSize=OC_APPCONFIG::getValue('log','pagesize',20);
|
||||
$pageCount=ceil(count($logs)/$pageSize);
|
||||
$page=isset($_GET['page'])?$_GET['page']:0;
|
||||
if($page>=$pageCount){
|
||||
$page=$pageCount-1;
|
||||
}
|
||||
|
||||
$logs=array_slice($logs,$page*$pageSize,$pageSize);
|
||||
|
||||
foreach( $logs as &$i ){
|
||||
$i['date'] =$i['timestamp'];
|
||||
}
|
||||
|
||||
$url=OC_HELPER::linkTo( 'log', 'index.php' ).'?page=';
|
||||
$pager=OC_UTIL::getPageNavi($pageCount,$page,$url);
|
||||
if($pager){
|
||||
$pagerHTML=$pager->fetchPage();
|
||||
}else{
|
||||
$pagerHTML='';
|
||||
}
|
||||
|
||||
$showActions=array();
|
||||
foreach($allActions as $action){
|
||||
if(array_search($action,$selectedActions)!==false){
|
||||
$showActions[$action]='checked="checked"';
|
||||
}else{
|
||||
$showActions[$action]='';
|
||||
}
|
||||
}
|
||||
|
||||
$tmpl = new OC_TEMPLATE( 'log', 'index', 'admin' );
|
||||
$tmpl->assign( 'logs', $logs );
|
||||
$tmpl->assign( 'pager', $pagerHTML );
|
||||
$tmpl->assign( 'size', $pageSize );
|
||||
$tmpl->assign( 'showActions', $showActions );
|
||||
$tmpl->printPage();
|
||||
|
||||
?>
|
||||
|
|
21
log/js/log.js
Normal file
21
log/js/log.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
$(document).ready(function() {
|
||||
// Sets the select_all checkbox behaviour :
|
||||
$('#all').click(function() {
|
||||
if($(this).attr('checked')){
|
||||
// Check all
|
||||
$('input.action:checkbox').attr('checked', true);
|
||||
}else{
|
||||
// Uncheck all
|
||||
$('input.action:checkbox').attr('checked', false);
|
||||
}
|
||||
});
|
||||
$('input.action:checkbox').click(function() {
|
||||
if(!$(this).attr('checked')){
|
||||
$('#all').attr('checked',false);
|
||||
}else{
|
||||
if($('input.action:checkbox:checked').length==$('input.action:checkbox').length){
|
||||
$('#all').attr('checked',true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,20 +1,19 @@
|
|||
<div class="controls">
|
||||
<form id="logs_options">
|
||||
<form id="logs_options" method='post'>
|
||||
<p>
|
||||
<span>Filter :</span>
|
||||
|
||||
<input type="checkbox" checked="checked" name="all" id="all" /> <label for="all">All</label>
|
||||
<input type="checkbox" checked="checked" name="logins" id="logins" /> <label for="logins">Logins</label>
|
||||
<input type="checkbox" checked="checked" name="logouts" id="logouts" /> <label for="logouts">Logouts</label>
|
||||
<input type="checkbox" checked="checked" name="downloads" id="downloads" /> <label for="downloads">Downloads</label>
|
||||
<input type="checkbox" checked="checked" name="uploads" id="uploads" /> <label for="uploads">Uploads</label>
|
||||
|
||||
<input type="checkbox" checked="checked" name="creations" id="creations" /> <label for="creations">Creations</label>
|
||||
<input type="checkbox" checked="checked" name="deletions" id="deletions" /> <label for="deletions">Deletions</label>
|
||||
<input type="checkbox" checked="" name="all" id="all" /> <label for="all">All</label>
|
||||
<input type="checkbox" class='action' <?php echo $_['showActions']['login']?> name="login" id="logins" /> <label for="logins">Logins</label>
|
||||
<input type="checkbox" class='action' <?php echo $_['showActions']['logout']?> name="logout" id="logouts" /> <label for="logouts">Logouts</label>
|
||||
<input type="checkbox" class='action' <?php echo $_['showActions']['read']?> name="read" id="downloads" /> <label for="downloads">Downloads</label>
|
||||
<input type="checkbox" class='action' <?php echo $_['showActions']['write']?> name="write" id="uploads" /> <label for="uploads">Uploads</label>
|
||||
<input type="checkbox" class='action' <?php echo $_['showActions']['create']?> name="create" id="creations" /> <label for="creations">Creations</label>
|
||||
<input type="checkbox" class='action' <?php echo $_['showActions']['delete']?> name="delete" id="deletions" /> <label for="deletions">Deletions</label>
|
||||
</p>
|
||||
<p>
|
||||
<span>Show :</span>
|
||||
<input type="text" maxlength="3" size="3" value="10" /> entries per page.
|
||||
<input type="text" maxlength="3" size="3" value="<?php echo $_['size']?>" name='size'/> entries per page.
|
||||
<input class="prettybutton" type="submit" value="Save" />
|
||||
|
||||
</p>
|
||||
|
@ -31,13 +30,11 @@
|
|||
<tbody>
|
||||
<?php foreach($_["logs"] as $entry): ?>
|
||||
<tr>
|
||||
<td class="login"><em><?php echo $entry["user"]; ?></em> <?php echo $entry["message"]; ?></td>
|
||||
<td class="<?php echo $entry["action"]; ?>"><em><?php echo $entry["action"]; ?> <?php echo $entry["user"]; ?></em> <?php echo $entry["info"]; ?></td>
|
||||
<td class="date"><?php echo $entry["date"]; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="controls">
|
||||
<p class="center"><a href="" title="Previous page">←</a> 3/5 <a href="" title="Next page">→</a></p>
|
||||
</div>
|
||||
<?php echo $_['pager'];?>
|
||||
|
|
Loading…
Reference in a new issue