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

Classe de gestion des erreurs apparaissant lors d'appels API. More...

Public Member Functions

 m_log ()
 
 list_logs_directory ($dir)
 
 hook_menu ()
 
 list_logs_directory_all ($dirs)
 
 get_logs_directory ()
 
 download_link ($file)
 
 tail ($file, $lines=20)
 

Private Member Functions

 compare_logname ($a, $b)
 
 compare_logtime ($a, $b)
 

Detailed Description

Classe de gestion des erreurs apparaissant lors d'appels API.

Definition at line 30 of file m_log.php.

Member Function Documentation

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

Definition at line 54 of file m_log.php.

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

Definition at line 59 of file m_log.php.

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

Definition at line 96 of file m_log.php.

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

96  {
97  global $err;
98  $err->log("log", "download_link");
99  header("Content-Disposition: attachment; filename=" . $file . "");
100  header("Content-Type: application/force-download");
101  header("Content-Transfer-Encoding: binary");
102  $f = $this->get_logs_directory();
103  $ff = $f['dir'] . "/" . basename($file);
104  set_time_limit(0);
105  readfile($ff);
106  }
$err
Definition: bootstrap.php:72
get_logs_directory()
Definition: m_log.php:84
m_log::get_logs_directory ( )

Definition at line 84 of file m_log.php.

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

Referenced by download_link(), and tail().

84  {
85  global $cuid, $mem, $err;
86  $err->log("log", "get_logs_directory");
87  // Return an array to allow multiple directory in the future
88  if (defined('ALTERNC_LOGS_ARCHIVE')) {
89  $c = array("dir" => ALTERNC_LOGS_ARCHIVE . "/" . $cuid . "-" . $mem->user["login"]);
90  } else {
91  $c = array("dir" => ALTERNC_LOGS . "/" . $cuid . "-" . $mem->user["login"]);
92  }
93  return $c;
94  }
const ALTERNC_LOGS
Definition: bootstrap.php:13
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
$c
Definition: bootstrap.php:47
$mem
Definition: bootstrap.php:71
m_log::hook_menu ( )

Definition at line 63 of file m_log.php.

63  {
64  $obj = array(
65  'title' => _("Logs"),
66  'ico' => 'images/logs.png',
67  'link' => 'logs_list.php',
68  'pos' => 130,
69  );
70 
71  return $obj;
72  }
m_log::list_logs_directory (   $dir)

Definition at line 36 of file m_log.php.

References $c, $cuid, and $err.

Referenced by list_logs_directory_all().

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

Definition at line 74 of file m_log.php.

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

74  {
75  global $err;
76  $err->log("log", "get_logs_directory_all");
77  $c = array();
78  foreach ($dirs as $dir => $val) {
79  $c[$dir] = $this->list_logs_directory($val);
80  }
81  return $c;
82  }
$val
Definition: tempovars.php:15
$err
Definition: bootstrap.php:72
list_logs_directory($dir)
Definition: m_log.php:36
$c
Definition: bootstrap.php:47
m_log::m_log ( )

Definition at line 32 of file m_log.php.

32  {
33 
34  }
m_log::tail (   $file,
  $lines = 20 
)

Definition at line 108 of file m_log.php.

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

108  {
109  global $err;
110  $err->log("log", "tail");
111  $lines = intval($lines);
112  if ($lines <= 0) {
113  $lines = 20;
114  }
115  $f = $this->get_logs_directory();
116  $ff = $f['dir'] . "/" . basename($file);
117  $out=array();
118  exec("tail -" . $lines . " " . escapeshellarg($ff), $out);
119  return implode("\n", $out);
120  }
$err
Definition: bootstrap.php:72
get_logs_directory()
Definition: m_log.php:84

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