Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
m_log Class Reference

This class shows error or access logs of web server to the web panel. More...

Public Member Functions

 list_logs_directory ($dir)
 List all logs files in a directory. More...
 
 hook_menu ()
 hook called by the menu class to add menu to the left panel More...
 
 list_logs_directory_all ($dirs)
 list all log files in all log directories More...
 
 get_logs_directory ()
 
 download_link ($file)
 download a log file More...
 
 tail ($file, $lines=20)
 show the last lines of a file More...
 

Private Member Functions

 compare_logname ($a, $b)
 Used by list_logs_directory to sort. More...
 
 compare_logtime ($a, $b)
 Used by list_logs_directory to sort. More...
 

Detailed Description

This class shows error or access logs of web server to the web panel.

Definition at line 26 of file m_log.php.

Member Function Documentation

m_log::compare_logname (   $a,
  $b 
)
private

Used by list_logs_directory to sort.

Definition at line 52 of file m_log.php.

52  {
53  return strcmp($a['name'], $b['name']);
54  }
m_log::compare_logtime (   $a,
  $b 
)
private

Used by list_logs_directory to sort.

Definition at line 60 of file m_log.php.

60  {
61  return $b['mtime'] - $a['mtime'];
62  }
m_log::download_link (   $file)

download a log file

Definition at line 110 of file m_log.php.

References $f, $msg, and get_logs_directory().

110  {
111  global $msg;
112  $msg->log("log", "download_link");
113  header("Content-Disposition: attachment; filename=" . $file . "");
114  header("Content-Type: application/force-download");
115  header("Content-Transfer-Encoding: binary");
116  $f = $this->get_logs_directory();
117  $ff = $f['dir'] . "/" . basename($file);
118  set_time_limit(0);
119  readfile($ff);
120  }
$msg
Definition: config.php:155
get_logs_directory()
Definition: m_log.php:94
m_log::get_logs_directory ( )

Definition at line 94 of file m_log.php.

References $c, $cuid, $mem, $msg, and ALTERNC_LOGS.

Referenced by download_link(), and tail().

94  {
95  global $cuid, $mem, $msg;
96  $msg->log("log", "get_logs_directory");
97  // Return an array to allow multiple directory in the future
98  if (defined('ALTERNC_LOGS_ARCHIVE')) {
99  $c = array("dir" => ALTERNC_LOGS_ARCHIVE . "/" . $cuid . "-" . $mem->user["login"]);
100  } else {
101  $c = array("dir" => ALTERNC_LOGS . "/" . $cuid . "-" . $mem->user["login"]);
102  }
103  return $c;
104  }
const ALTERNC_LOGS
Definition: bootstrap.php:13
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
$c
Definition: bootstrap.php:47
$mem
Definition: bootstrap.php:71
m_log::hook_menu ( )

hook called by the menu class to add menu to the left panel

Definition at line 69 of file m_log.php.

69  {
70  $obj = array(
71  'title' => _("Logs"),
72  'ico' => 'images/logs.png',
73  'link' => 'logs_list.php',
74  'pos' => 130,
75  );
76 
77  return $obj;
78  }
m_log::list_logs_directory (   $dir)

List all logs files in a directory.

Definition at line 31 of file m_log.php.

References $c, $cuid, and $msg.

Referenced by list_logs_directory_all().

31  {
32  global $cuid, $msg;
33  $msg->log("log", "list_logs_directory");
34 
35  $c = array();
36  foreach (glob("${dir}/*log*") as $absfile) {
37  $c[] = array("name" => basename($absfile),
38  "creation_date" => date("F d Y H:i:s", filectime($absfile)),
39  "mtime" => filemtime($absfile),
40  "filesize" => filesize($absfile),
41  "downlink" => urlencode(basename($absfile)),
42  );
43  }
44  usort($c, "m_log::compare_logtime");
45  return $c;
46  }
$msg
Definition: config.php:155
$cuid
Definition: bootstrap.php:43
$c
Definition: bootstrap.php:47
m_log::list_logs_directory_all (   $dirs)

list all log files in all log directories

Definition at line 83 of file m_log.php.

References $c, $msg, $val, and list_logs_directory().

83  {
84  global $msg;
85  $msg->log("log", "get_logs_directory_all");
86  $c = array();
87  foreach ($dirs as $dir => $val) {
88  $c[$dir] = $this->list_logs_directory($val);
89  }
90  return $c;
91  }
$val
Definition: tempovars.php:15
$msg
Definition: config.php:155
list_logs_directory($dir)
List all logs files in a directory.
Definition: m_log.php:31
$c
Definition: bootstrap.php:47
m_log::tail (   $file,
  $lines = 20 
)

show the last lines of a file

Definition at line 125 of file m_log.php.

References $f, $msg, and get_logs_directory().

125  {
126  global $msg;
127  $msg->log("log", "tail");
128  $lines = intval($lines);
129  if ($lines <= 0) {
130  $lines = 20;
131  }
132  $f = $this->get_logs_directory();
133  $ff = $f['dir'] . "/" . basename($file);
134  $out=array();
135  exec("tail -" . $lines . " " . escapeshellarg($ff), $out);
136  return implode("\n", $out);
137  }
$msg
Definition: config.php:155
get_logs_directory()
Definition: m_log.php:94

The documentation for this class was generated from the following file: