Skip to content

Commit 85c4e5c

Browse files
author
jwarnier
committed
replace double-quotes with single-quotes whenever appropriate
1 parent eaada37 commit 85c4e5c

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

server/cron_daily.php

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
require("lib/config.inc.php");
32-
require("lib/app.inc.php");
31+
require('lib/config.inc.php');
32+
require('lib/app.inc.php');
3333

3434
set_time_limit(0);
3535

3636
// make sure server_id is always an int
37-
$conf["server_id"] = intval($conf["server_id"]);
37+
$conf['server_id'] = intval($conf['server_id']);
3838

3939

4040
// Load required base-classes
@@ -45,36 +45,36 @@
4545
// store the mailbox statistics in the database
4646
#######################################################################################################
4747

48-
$sql = "SELECT mailuser_id,maildir FROM mail_user WHERE server_id = ".$conf["server_id"];
48+
$sql = "SELECT mailuser_id,maildir FROM mail_user WHERE server_id = ".$conf['server_id'];
4949
$records = $app->db->queryAllRecords($sql);
5050
foreach($records as $rec) {
51-
if(@is_file($rec["maildir"].'/ispconfig_mailsize')) {
51+
if(@is_file($rec['maildir'].'/ispconfig_mailsize')) {
5252

5353
// rename file
54-
rename($rec["maildir"].'/ispconfig_mailsize',$rec["maildir"].'/ispconfig_mailsize_save');
54+
rename($rec['maildir'].'/ispconfig_mailsize',$rec['maildir'].'/ispconfig_mailsize_save');
5555

5656
// Read the file
57-
$lines = file($rec["maildir"].'/ispconfig_mailsize_save');
57+
$lines = file($rec['maildir'].'/ispconfig_mailsize_save');
5858
$mail_traffic = 0;
5959
foreach($lines as $line) {
6060
$mail_traffic += intval($line);
6161
}
6262
unset($lines);
6363

6464
// Delete backup file
65-
if(@is_file($rec["maildir"].'/ispconfig_mailsize_save')) unlink($rec["maildir"].'/ispconfig_mailsize_save');
65+
if(@is_file($rec['maildir'].'/ispconfig_mailsize_save')) unlink($rec['maildir'].'/ispconfig_mailsize_save');
6666

6767
// Save the traffic stats in the sql database
68-
$tstamp = date("Y-m");
68+
$tstamp = date('Y-m');
6969

70-
$sql = "SELECT * FROM mail_traffic WHERE month = '$tstamp' AND mailuser_id = ".$rec["mailuser_id"];
70+
$sql = "SELECT * FROM mail_traffic WHERE month = '$tstamp' AND mailuser_id = ".$rec['mailuser_id'];
7171
$tr = $app->dbmaster->queryOneRecord($sql);
7272

73-
$mail_traffic += $tr["traffic"];
74-
if($tr["traffic_id"] > 0) {
75-
$sql = "UPDATE mail_traffic SET traffic = $mail_traffic WHERE traffic_id = ".$tr["traffic_id"];
73+
$mail_traffic += $tr['traffic'];
74+
if($tr['traffic_id'] > 0) {
75+
$sql = "UPDATE mail_traffic SET traffic = $mail_traffic WHERE traffic_id = ".$tr['traffic_id'];
7676
} else {
77-
$sql = "INSERT INTO mail_traffic (month,mailuser_id,traffic) VALUES ('$tstamp',".$rec["mailuser_id"].",$mail_traffic)";
77+
$sql = "INSERT INTO mail_traffic (month,mailuser_id,traffic) VALUES ('$tstamp',".$rec['mailuser_id'].",$mail_traffic)";
7878
}
7979
$app->dbmaster->query($sql);
8080
echo $sql;
@@ -92,9 +92,9 @@ function setConfigVar( $filename, $varName, $varValue ) {
9292
$out = '';
9393
$found = 0;
9494
foreach($lines as $line) {
95-
list($key, $value) = preg_split("/[\t= ]+/", $line, 2);
95+
list($key, $value) = preg_split('/[\t= ]+/', $line, 2);
9696
if($key == $varName) {
97-
$out .= $varName." ".$varValue."\n";
97+
$out .= $varName.' '.$varValue."\n";
9898
$found = 1;
9999
} else {
100100
$out .= $line;
@@ -104,32 +104,32 @@ function setConfigVar( $filename, $varName, $varValue ) {
104104
//* add \n if the last line does not end with \n or \r
105105
if(substr($out,-1) != "\n" && substr($out,-1) != "\r") $out .= "\n";
106106
//* add the new line at the end of the file
107-
if($append == 1) $out .= $varName." ".$varValue."\n";
107+
if($append == 1) $out .= $varName.' '.$varValue."\n";
108108
}
109109

110110
file_put_contents($filename,$out);
111111
}
112112
}
113113

114114

115-
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'webalizer' AND server_id = ".$conf["server_id"];
115+
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'webalizer' AND server_id = ".$conf['server_id'];
116116
$records = $app->db->queryAllRecords($sql);
117117

118118
foreach($records as $rec) {
119-
$yesterday = date("Ymd",time() - 86400);
120-
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$yesterday.'-access.log');
119+
$yesterday = date('Ymd',time() - 86400);
120+
$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log');
121121
if(!@is_file($logfile)) {
122-
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$yesterday.'-access.log.gz');
122+
$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log.gz');
123123
if(!@is_file($logfile)) {
124124
continue;
125125
}
126126
}
127127

128-
$domain = escapeshellcmd($rec["domain"]);
129-
$statsdir = escapeshellcmd($rec["document_root"].'/web/stats');
128+
$domain = escapeshellcmd($rec['domain']);
129+
$statsdir = escapeshellcmd($rec['document_root'].'/web/stats');
130130
$webalizer = '/usr/bin/webalizer';
131131
$webalizer_conf_main = '/etc/webalizer/webalizer.conf';
132-
$webalizer_conf = escapeshellcmd($rec["document_root"].'/log/webalizer.conf');
132+
$webalizer_conf = escapeshellcmd($rec['document_root'].'/log/webalizer.conf');
133133

134134
if(!@is_file($webalizer_conf)) {
135135
copy($webalizer_conf_main,$webalizer_conf);
@@ -150,23 +150,23 @@ function setConfigVar( $filename, $varName, $varValue ) {
150150
// Create awstats statistics
151151
#######################################################################################################
152152

153-
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'awstats' AND server_id = ".$conf["server_id"];
153+
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'awstats' AND server_id = ".$conf['server_id'];
154154
$records = $app->db->queryAllRecords($sql);
155155

156-
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
156+
$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
157157

158158
foreach($records as $rec) {
159-
$yesterday = date("Ymd",time() - 86400);
160-
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$yesterday.'-access.log');
159+
$yesterday = date('Ymd',time() - 86400);
160+
$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log');
161161
if(!@is_file($logfile)) {
162-
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$yesterday.'-access.log.gz');
162+
$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log.gz');
163163
if(!@is_file($logfile)) {
164164
continue;
165165
}
166166
}
167167

168-
$domain = escapeshellcmd($rec["domain"]);
169-
$statsdir = escapeshellcmd($rec["document_root"].'/web/stats');
168+
$domain = escapeshellcmd($rec['domain']);
169+
$statsdir = escapeshellcmd($rec['document_root'].'/web/stats');
170170
$awstats_pl = $web_config['awstats_pl'];
171171
$awstats_buildstaticpages_pl = $web_config['awstats_buildstaticpages_pl'];
172172

@@ -178,8 +178,8 @@ function setConfigVar( $filename, $varName, $varValue ) {
178178

179179
if($awstats_pl != '' && $awstats_buildstaticpages_pl != '' && fileowner($awstats_pl) == 0 && fileowner($awstats_buildstaticpages_pl) == 0) {
180180
exec($command);
181-
rename($rec["document_root"].'/web/stats/awstats.'.$domain.'.html',$rec["document_root"].'/web/stats/index.html');
182-
$app->log("Created awstats statistics with command: $command",LOGLEVEL_DEBUG);
181+
rename($rec['document_root'].'/web/stats/awstats.'.$domain.'.html',$rec['document_root'].'/web/stats/index.html');
182+
$app->log('Created awstats statistics with command: '.$command,LOGLEVEL_DEBUG);
183183
} else {
184184
$app->log("No awstats statistics created. Either $awstats_pl or $awstats_buildstaticpages_pl is not owned by root user.",LOGLEVEL_WARN);
185185
}
@@ -197,27 +197,27 @@ function setConfigVar( $filename, $varName, $varValue ) {
197197
// Manage and compress web logfiles
198198
#######################################################################################################
199199

200-
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ".$conf["server_id"];
200+
$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ".$conf['server_id'];
201201
$records = $app->db->queryAllRecords($sql);
202202
foreach($records as $rec) {
203-
$yesterday = date("Ymd",time() - 86400);
204-
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$yesterday.'-access.log');
203+
$yesterday = date('Ymd',time() - 86400);
204+
$logfile = escapeshellcmd($rec['document_root'].'/log/'.$yesterday.'-access.log');
205205
if(@is_file($logfile)) {
206206
// Compress yesterdays logfile
207207
exec("gzip -c $logfile > $logfile.gz");
208208
unlink($logfile);
209209
}
210210

211211
// rotate and compress the error.log when it exceeds a size of 10 MB
212-
$logfile = escapeshellcmd($rec["document_root"].'/log/error.log');
212+
$logfile = escapeshellcmd($rec['document_root'].'/log/error.log');
213213
if(is_file($logfile) && filesize($logfile) > 10000000) {
214214
exec("gzip -c $logfile > $logfile.1.gz");
215215
exec("cat /dev/null > $logfile");
216216
}
217217

218218
// delete logfiles after 30 days
219-
$month_ago = date("Ymd",time() - 86400 * 30);
220-
$logfile = escapeshellcmd($rec["document_root"].'/log/'.$month_ago.'-access.log.gz');
219+
$month_ago = date('Ymd',time() - 86400 * 30);
220+
$logfile = escapeshellcmd($rec['document_root'].'/log/'.$month_ago.'-access.log.gz');
221221
if(@is_file($logfile)) {
222222
unlink($logfile);
223223
}
@@ -245,14 +245,14 @@ function setConfigVar( $filename, $varName, $varValue ) {
245245
// Cleanup website tmp directories
246246
#######################################################################################################
247247

248-
$sql = "SELECT domain_id, domain, document_root, system_user FROM web_domain WHERE server_id = ".$conf["server_id"];
248+
$sql = "SELECT domain_id, domain, document_root, system_user FROM web_domain WHERE server_id = ".$conf['server_id'];
249249
$records = $app->db->queryAllRecords($sql);
250250
$app->uses('system');
251251
if(is_array($records)) {
252252
foreach($records as $rec){
253-
$tmp_path = realpath(escapeshellcmd($rec["document_root"].'/tmp'));
253+
$tmp_path = realpath(escapeshellcmd($rec['document_root'].'/tmp'));
254254
if($tmp_path != '' && strlen($tmp_path) > 10 && is_dir($tmp_path) && $app->system->is_user($rec['system_user'])){
255-
exec("cd ".$tmp_path."; find -mtime +1 -name 'sess_*' | grep -v -w .no_delete | xargs rm > /dev/null 2> /dev/null");
255+
exec('cd '.$tmp_path."; find . -mtime +1 -name 'sess_*' | grep -v -w .no_delete | xargs rm > /dev/null 2> /dev/null");
256256
}
257257
}
258258
}
@@ -364,12 +364,12 @@ function setConfigVar( $filename, $varName, $varValue ) {
364364
($reseller_traffic_quota > 0 && $web_traffic > $reseller_traffic_quota)) {*/
365365
if($web_traffic_quota > 0 && $web_traffic > $web_traffic_quota) {
366366
$app->dbmaster->datalogUpdate('web_domain', "traffic_quota_lock = 'y',active = 'n'", 'domain_id', $rec['domain_id']);
367-
$app->log("Traffic quota for ".$rec['domain_id']." Exceeded. Disabling website.",LOGLEVEL_DEBUG);
367+
$app->log('Traffic quota for '.$rec['domain_id'].' exceeded. Disabling website.',LOGLEVEL_DEBUG);
368368
} else {
369369
//* unlock the website, if traffic is lower then quota
370370
if($rec['traffic_quota_lock'] == 'y') {
371371
$app->dbmaster->datalogUpdate('web_domain', "traffic_quota_lock = 'n',active = 'y'", 'domain_id', $rec['domain_id']);
372-
$app->log("Traffic quota for ".$rec['domain_id']." ok again. Enabling website.",LOGLEVEL_DEBUG);
372+
$app->log('Traffic quota for '.$rec['domain_id'].' ok again. Re-enabling website.',LOGLEVEL_DEBUG);
373373
}
374374
}
375375
}
@@ -382,7 +382,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
382382
// Create website backups
383383
#######################################################################################################
384384

385-
$server_config = $app->getconf->get_server_config($conf["server_id"], 'server');
385+
$server_config = $app->getconf->get_server_config($conf['server_id'], 'server');
386386
$backup_dir = $server_config['backup_dir'];
387387

388388
if($backup_dir != '') {

0 commit comments

Comments
 (0)