Skip to content

Commit 2b849ba

Browse files
committed
Improved the php session file delet function in cron_daily.php
1 parent 391f97a commit 2b849ba

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

server/cron_daily.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
179179
// Cleanup website tmp directories
180180
#######################################################################################################
181181

182+
/*
182183
$sql = "SELECT domain_id, domain, document_root, system_user FROM web_domain WHERE server_id = ".$conf["server_id"];
183184
$records = $app->db->queryAllRecords($sql);
184185
$app->uses('system');
@@ -192,6 +193,19 @@ function setConfigVar( $filename, $varName, $varValue ) {
192193
}
193194
}
194195
}
196+
*/
197+
198+
$sql = "SELECT domain_id, domain, document_root, system_user FROM web_domain WHERE server_id = ".$conf["server_id"];
199+
$records = $app->db->queryAllRecords($sql);
200+
$app->uses('system');
201+
if(is_array($records)) {
202+
foreach($records as $rec){
203+
$tmp_path = realpath(escapeshellcmd($rec["document_root"].'/tmp'));
204+
if($tmp_path != '' && strlen($tmp_path) > 10 && is_dir($tmp_path) && $app->system->is_user($rec['system_user'])){
205+
exec("cd ".$tmp_path."; find -mtime +2 -name 'sess_*' | grep -v -w .no_delete | xargs rm &> /dev/null 2> /dev/null");
206+
}
207+
}
208+
}
195209

196210
#######################################################################################################
197211
// Cleanup logs in master database (only the "master-server")

0 commit comments

Comments
 (0)