Skip to content

Commit 06b7fa9

Browse files
author
jwarnier
committed
- fix indentation
- replace double-quotes with single-quotes whenever appropriate
1 parent 5f027cd commit 06b7fa9

File tree

1 file changed

+57
-57
lines changed

1 file changed

+57
-57
lines changed

server/lib/app.inc.php

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131
class app {
3232

33-
var $loaded_modules = array();
34-
var $loaded_plugins = array();
33+
var $loaded_modules = array();
34+
var $loaded_plugins = array();
3535

36-
function app() {
36+
function app() {
3737

3838
global $conf;
3939

@@ -68,34 +68,36 @@ function app() {
6868
}
6969

7070
function uses($classes) {
71-
global $conf;
72-
73-
$cl = explode(',',$classes);
74-
if(is_array($cl)) {
75-
foreach($cl as $classname) {
76-
if(!@is_object($this->$classname)) {
77-
if(is_file($conf['classpath'] . '/'.$classname.'.inc.php') && !is_link($conf['classpath'] . '/'.$classname.'.inc.php')) {
78-
include_once($conf['classpath'] . '/'.$classname.'.inc.php');
79-
$this->$classname = new $classname;
80-
}
71+
72+
global $conf;
73+
74+
$cl = explode(',',$classes);
75+
if(is_array($cl)) {
76+
foreach($cl as $classname) {
77+
if(!@is_object($this->$classname)) {
78+
if(is_file($conf['classpath'].'/'.$classname.'.inc.php') && !is_link($conf['classpath'].'/'.$classname.'.inc.php')) {
79+
include_once($conf['classpath'].'/'.$classname.'.inc.php');
80+
$this->$classname = new $classname;
8181
}
8282
}
8383
}
84+
}
8485
}
8586

8687
function load($classes) {
8788

88-
global $conf;
89-
$cl = explode(',',$classes);
90-
if(is_array($cl)) {
91-
foreach($cl as $classname) {
92-
if(is_file($conf['classpath'] . '/'.$classname.'.inc.php') && !is_link($conf['classpath'] . '/'.$classname.'.inc.php')) {
93-
include_once($conf['classpath'] . '/'.$classname.'.inc.php');
94-
} else {
95-
die('Unable to load: '.$conf['classpath'] . '/'.$classname.'.inc.php');
96-
}
89+
global $conf;
90+
91+
$cl = explode(',',$classes);
92+
if(is_array($cl)) {
93+
foreach($cl as $classname) {
94+
if(is_file($conf['classpath'].'/'.$classname.'.inc.php') && !is_link($conf['classpath'].'/'.$classname.'.inc.php')) {
95+
include_once($conf['classpath'].'/'.$classname.'.inc.php');
96+
} else {
97+
die('Unable to load: '.$conf['classpath'].'/'.$classname.'.inc.php');
9798
}
9899
}
100+
}
99101
}
100102

101103
/*
@@ -106,52 +108,50 @@ function load($classes) {
106108

107109
function log($msg, $priority = 0) {
108110

109-
global $conf;
110-
111-
if($priority >= $conf['log_priority']) {
111+
global $conf;
112+
113+
if($priority >= $conf['log_priority']) {
112114
//if (is_writable($conf["log_file"])) {
113115
if (!$fp = fopen ($conf['log_file'], 'a')) {
114116
die('Unable to open logfile.');
115117
}
116-
switch ($priority) {
117-
case 0:
118-
$priority_txt = 'DEBUG';
118+
switch ($priority) {
119+
case 0:
120+
$priority_txt = 'DEBUG';
119121
break;
120-
case 1:
121-
$priority_txt = 'WARNING';
122+
case 1:
123+
$priority_txt = 'WARNING';
122124
break;
123-
case 2:
124-
$priority_txt = 'ERROR';
125+
case 2:
126+
$priority_txt = 'ERROR';
125127
break;
126-
}
128+
}
127129

128130
if (!fwrite($fp, date('d.m.Y-H:i').' - '.$priority_txt.' - '. $msg."\r\n")) {
129131
die('Unable to write to logfile.');
130132
}
131-
echo date('d.m.Y-H:i').' - '.$priority_txt.' - '. $msg."\n";
132-
fclose($fp);
133-
134-
// Log to database
135-
if(isset($this->dbmaster)) {
136-
$server_id = $conf['server_id'];
137-
$loglevel = $priority;
138-
$tstamp = time();
139-
$message = $this->dbmaster->quote($msg);
140-
$datalog_id = (isset($this->modules->current_datalog_id) && $this->modules->current_datalog_id > 0)?$this->modules->current_datalog_id:0;
141-
if($datalog_id > 0) {
142-
$tmp_rec = $this->dbmaster->queryOneRecord("SELECT count(syslog_id) as number FROM sys_log WHERE datalog_id = $datalog_id AND loglevel = ".LOGLEVEL_ERROR);
143-
//* Do not insert duplicate errors into the web log.
144-
if($tmp_rec['number'] == 0) {
145-
$sql = "INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ('$server_id',$datalog_id,'$loglevel','$tstamp','$message')";
146-
$this->dbmaster->query($sql);
147-
}
148-
} else {
149-
$sql = "INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ('$server_id',0,'$loglevel','$tstamp','$message')";
150-
$this->dbmaster->query($sql);
151-
}
152-
153-
133+
echo date('d.m.Y-H:i').' - '.$priority_txt.' - '. $msg."\n";
134+
fclose($fp);
135+
136+
// Log to database
137+
if(isset($this->dbmaster)) {
138+
$server_id = $conf['server_id'];
139+
$loglevel = $priority;
140+
$tstamp = time();
141+
$message = $this->dbmaster->quote($msg);
142+
$datalog_id = (isset($this->modules->current_datalog_id) && $this->modules->current_datalog_id > 0)?$this->modules->current_datalog_id:0;
143+
if($datalog_id > 0) {
144+
$tmp_rec = $this->dbmaster->queryOneRecord("SELECT count(syslog_id) as number FROM sys_log WHERE datalog_id = $datalog_id AND loglevel = ".LOGLEVEL_ERROR);
145+
//* Do not insert duplicate errors into the web log.
146+
if($tmp_rec['number'] == 0) {
147+
$sql = "INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ('$server_id',$datalog_id,'$loglevel','$tstamp','$message')";
148+
$this->dbmaster->query($sql);
154149
}
150+
} else {
151+
$sql = "INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ('$server_id',0,'$loglevel','$tstamp','$message')";
152+
$this->dbmaster->query($sql);
153+
}
154+
}
155155

156156
//} else {
157157
// die("Unable to write to logfile.");
@@ -167,7 +167,7 @@ function log($msg, $priority = 0) {
167167

168168
function error($msg) {
169169
$this->log($msg,3);
170-
die($msg);
170+
die($msg);
171171
}
172172

173173
}

0 commit comments

Comments
 (0)