forked from ulbpodcast/ezrecorder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib_error.php
More file actions
108 lines (94 loc) · 3.13 KB
/
Copy pathlib_error.php
File metadata and controls
108 lines (94 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/*
* EZCAST EZrecorder
*
* Copyright (C) 2016 Université libre de Bruxelles
*
* Written by Michel Jansens <mjansens@ulb.ac.be>
* Arnaud Wijns <awijns@ulb.ac.be>
* Antoine Dewilde
* UI Design by Julien Di Pietrantonio
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Error managing and logging library
*/
include_once 'global_config.inc';
/**
* Prints the error message on screen
* @param string $msg The message to print
* @param bool $log If set to false, the error won't be logged.
*/
function error_print_message($msg, $log = true) {
//echo '<b>Error: </b>'.$msg;
echo '<script type="text/javascript">window.alert("'.$msg.'");</script>';
if($log) {
log_append('error', $msg);
}
}
/**
* Adds a line in log
* @global string $podman_logs Path to the log file
* @param string $operation The operation done
* @param string $message Additionnal information (parameters)
*/
function log_append($operation, $message = '') {
global $recorder_logs;
// 1) Date/time at which the event occurred
$data = date('Y-m-d-H:i:s');
$data .= ' ';
// 2) IP address of the user that provoked the event
$data .= (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : 'noip';
$data .= ' ';
// 3) Username and realname of the user that provoked the event
// There can be no login if the operation was performed by a CLI tool for instance.
// In that case, we display "nologin" instead.
if(!isset($_SESSION['user_login']) || empty($_SESSION['user_login'])) {
$data .= 'nologin';
}
// General case, where there is a login and (possibly) a real login
else if(isset($_SESSION['real_login'])) {
$data .= $_SESSION['real_login'].'/'.$_SESSION['user_login'];
}
else {
$data .= $_SESSION['user_login'];
}
$data .= ' ';
// 4) Operation performed
$data .= $operation;
// 5) Optionnal parameters
if(!empty($message))
$data .= ': '.$message;
// 6) And we add a carriage return for readability
$data .= PHP_EOL;
// Then we save the new entry
file_put_contents($recorder_logs, $data, FILE_APPEND | LOCK_EX);
}
/**
* Gets or sets an error message
* @staticvar string $last_error
* @param type $msg
* @return string
*/
function error_last_message($msg = '') {
static $last_error="";
if($msg=="")
return $last_error;
else{
$last_error=$msg;
return true;
}
}