Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
m_log.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  AlternC - Web Hosting System
5  Copyright (C) 2000-2012 by the AlternC Development Team.
6  https://alternc.org/
7  ----------------------------------------------------------------------
8  LICENSE
9 
10  This program is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License (GPL)
12  as published by the Free Software Foundation; either version 2
13  of the License, or (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  To read the license please visit http://www.gnu.org/copyleft/gpl.html
21  ----------------------------------------------------------------------
22  Purpose of file: Manage Log files for users
23  ----------------------------------------------------------------------
24 */
25 
26 /**
27 * Classe de gestion des erreurs apparaissant lors d'appels API.
28 */
29 class m_log {
30 
31  function m_log(){
32  }
33 
34  function list_logs_directory($dir){
35  global $cuid,$err;
36  $err->log("log","list_logs_directory");
37 
38  $c=array();
39  foreach( glob("${dir}/*log*") as $absfile) {
40  $c[]=array("name"=>basename($absfile),
41  "creation_date"=>date("F d Y H:i:s.", filectime($absfile)),
42  "filesize"=>filesize($absfile),
43  "downlink"=>"logs_download.php?file=".urlencode(basename($absfile)),
44  );
45  }
46  usort($c,"m_log::compare_logname");
47  return $c;
48 
49  }//list_logs
50 
51  // Used by list_logs_directory to sort
52  private function compare_logname($a, $b) {
53  return strcmp($a['name'],$b['name']);
54  }
55 
56 
57  function hook_menu() {
58  $obj = array(
59  'title' => _("Logs"),
60  'ico' => 'images/logs.png',
61  'link' => 'logs_list.php',
62  'pos' => 130,
63  ) ;
64 
65  return $obj;
66  }
67 
68  function list_logs_directory_all($dirs){
69  global $err;
70  $err->log("log","get_logs_directory_all");
71  $c=array();
72  foreach($dirs as $dir=>$val){
73  $c[$dir]=$this->list_logs_directory($val);
74  }
75  return $c;
76 
77  }
78 
79  function get_logs_directory(){
80  global $cuid,$mem,$err;
81  $err->log("log","get_logs_directory");
82  // Return an array to allow multiple directory in the future
83  if(defined('ALTERNC_LOGS_ARCHIVE')){
84  $c=array("dir"=>ALTERNC_LOGS_ARCHIVE."/".$cuid."-".$mem->user["login"]);
85  }else{
86  $c=array("dir"=>ALTERNC_LOGS."/".$cuid."-".$mem->user["login"]);
87  }
88  return $c;
89  }
90 
91  function download_link($file){
92  global $err,$mem;
93  $err->log("log","download_link");
94  header("Content-Disposition: attachment; filename=".$file);
95  header("Content-Type: application/force-download");
96  header("Content-Transfer-Encoding: binary");
97  $f=$this->get_logs_directory();
98  $ff=$f['dir']."/".basename($file);
99  set_time_limit(0);
100  readfile($ff);
101  }
102 
103 
104 } // end class
105