GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — stable-3.1 ( ab573e...c8b3d1 )
by Benjamin
05:04
created

bureau/class/m_log.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
  ----------------------------------------------------------------------
5
  AlternC - Web Hosting System
6
  Copyright (C) 2000-2012 by the AlternC Development Team.
7
  https://alternc.org/
8
  ----------------------------------------------------------------------
9
  LICENSE
10
11
  This program is free software; you can redistribute it and/or
12
  modify it under the terms of the GNU General Public License (GPL)
13
  as published by the Free Software Foundation; either version 2
14
  of the License, or (at your option) any later version.
15
16
  This program is distributed in the hope that it will be useful,
17
  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
  GNU General Public License for more details.
20
21
  To read the license please visit http://www.gnu.org/copyleft/gpl.html
22
  ----------------------------------------------------------------------
23
  Purpose of file: Manage Log files for users
24
  ----------------------------------------------------------------------
25
 */
26
27
/**
28
 * Classe de gestion des erreurs apparaissant lors d'appels API.
29
 */
30
class m_log {
31
32
    function m_log() {
33
        
34
    }
35
36
    function list_logs_directory($dir) {
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
    }
52
53
    // Used by list_logs_directory to sort
54
    private function compare_logname($a, $b) {
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
55
        return strcmp($a['name'], $b['name']);
56
    }
57
58
    // Used by list_logs_directory to sort
59
    private function compare_logtime($a, $b) {
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
60
        return $b['mtime'] - $a['mtime'];
61
    }
62
63
    function hook_menu() {
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
    }
73
74
    function list_logs_directory_all($dirs) {
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
    }
83
84
    function get_logs_directory() {
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
    }
95
96
    function download_link($file) {
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
    }
107
108
    function tail($file, $lines = 20) {
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
    }
121
122
}
123
124
// end class
125