2012-08-21 18:25:56 +00:00
|
|
|
<?php
|
|
|
|
/*
|
2012-08-28 08:59:05 +00:00
|
|
|
----------------------------------------------------------------------
|
|
|
|
AlternC - Web Hosting System
|
|
|
|
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
|
|
https://alternc.org/
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
LICENSE
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License (GPL)
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
Purpose of file: Manage Log files for users
|
|
|
|
----------------------------------------------------------------------
|
2012-08-21 18:25:56 +00:00
|
|
|
*/
|
2012-08-28 08:59:05 +00:00
|
|
|
|
2012-08-21 18:25:56 +00:00
|
|
|
/**
|
|
|
|
* Classe de gestion des erreurs apparaissant lors d'appels API.
|
|
|
|
*/
|
|
|
|
class m_log {
|
|
|
|
|
2012-08-23 07:36:11 +00:00
|
|
|
function m_log(){
|
|
|
|
}
|
2012-08-21 18:25:56 +00:00
|
|
|
|
2012-08-23 07:36:11 +00:00
|
|
|
function list_logs_directory($dir){
|
|
|
|
global $cuid,$err;
|
|
|
|
$err->log("log","list_logs_directory");
|
2012-08-21 18:25:56 +00:00
|
|
|
|
2012-08-23 07:47:30 +00:00
|
|
|
$c=array();
|
2014-02-28 15:25:07 +00:00
|
|
|
foreach( glob("${dir}/*log*") as $absfile) {
|
|
|
|
$c[]=array("name"=>basename($absfile),
|
|
|
|
"creation_date"=>date("F d Y H:i:s.", filectime($absfile)),
|
|
|
|
"filesize"=>filesize($absfile),
|
|
|
|
"downlink"=>"logs_download.php?file=".urlencode(basename($absfile)),
|
|
|
|
);
|
2012-08-21 18:25:56 +00:00
|
|
|
}
|
2014-02-28 15:25:07 +00:00
|
|
|
usort($c,"m_log::compare_logname");
|
2012-08-23 07:36:11 +00:00
|
|
|
return $c;
|
2012-08-21 18:25:56 +00:00
|
|
|
|
2012-08-23 07:36:11 +00:00
|
|
|
}//list_logs
|
2012-08-21 18:25:56 +00:00
|
|
|
|
2014-02-28 15:25:07 +00:00
|
|
|
// Used by list_logs_directory to sort
|
|
|
|
private function compare_logname($a, $b) {
|
|
|
|
return strcmp($a['name'],$b['name']);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-18 10:01:28 +00:00
|
|
|
function hook_menu() {
|
|
|
|
$obj = array(
|
|
|
|
'title' => _("Logs"),
|
|
|
|
'ico' => 'images/logs.png',
|
|
|
|
'link' => 'logs_list.php',
|
|
|
|
'pos' => 130,
|
|
|
|
) ;
|
|
|
|
|
|
|
|
return $obj;
|
|
|
|
}
|
|
|
|
|
2012-08-23 07:36:11 +00:00
|
|
|
function list_logs_directory_all($dirs){
|
|
|
|
global $err;
|
|
|
|
$err->log("log","get_logs_directory_all");
|
|
|
|
$c=array();
|
|
|
|
foreach($dirs as $dir=>$val){
|
|
|
|
$c[$dir]=$this->list_logs_directory($val);
|
|
|
|
}
|
|
|
|
return $c;
|
2012-08-21 18:25:56 +00:00
|
|
|
|
2012-08-23 07:36:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_logs_directory(){
|
2012-08-26 10:22:54 +00:00
|
|
|
global $cuid,$mem,$err;
|
2012-08-23 07:36:11 +00:00
|
|
|
$err->log("log","get_logs_directory");
|
2012-08-27 10:37:58 +00:00
|
|
|
// Return an array to allow multiple directory in the future
|
2013-04-24 15:26:09 +00:00
|
|
|
if(defined('ALTERNC_LOGS_ARCHIVE')){
|
|
|
|
$c=array("dir"=>ALTERNC_LOGS_ARCHIVE."/".$cuid."-".$mem->user["login"]);
|
|
|
|
}else{
|
|
|
|
$c=array("dir"=>ALTERNC_LOGS."/".$cuid."-".$mem->user["login"]);
|
|
|
|
}
|
2012-08-23 07:36:11 +00:00
|
|
|
return $c;
|
|
|
|
}
|
|
|
|
|
|
|
|
function download_link($file){
|
|
|
|
global $err,$mem;
|
|
|
|
$err->log("log","download_link");
|
2012-08-27 10:37:58 +00:00
|
|
|
header("Content-Disposition: attachment; filename=".$file);
|
2012-08-21 18:25:56 +00:00
|
|
|
header("Content-Type: application/force-download");
|
|
|
|
header("Content-Transfer-Encoding: binary");
|
|
|
|
$f=$this->get_logs_directory();
|
|
|
|
$ff=$f['dir']."/".basename($file);
|
|
|
|
set_time_limit(0);
|
2012-08-23 07:36:11 +00:00
|
|
|
readfile($ff);
|
|
|
|
}
|
2012-08-21 18:25:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // end class
|
|
|
|
|