"Fossies" - the Fresh Open Source Software Archive 
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "ehcleanup.php" see the
Fossies "Dox" file reference documentation.
1 <?
2 /*
3 This file is part of Event Horizon (EVH).
4
5 EVH is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 EVH is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 error_reporting(0);
20 include "inc.php";
21
22 $query='select id, dnldcode, outdate from Sessions where outdate < "' . $mydate . '"';
23 $res = mysql_query($query,$dbh) or die("<p><b>A fatal database error occured</b>.\n<br />Query: " . $query . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());
24
25 while ($row = mysql_fetch_row($res)) {
26 echo "\r\n";
27 $query4 = 'select name,id from Files where sessionid="' . $row[0] . '"';
28 $res4 = mysql_query($query4,$dbh) or die('Query: ' . $query4 . '<br />\nError: (' . mysql_errno() . ') ' . mysql_error());
29 $row4 = mysql_fetch_row($res4);
30
31 if ($savehistory) {
32 // record file deletion into History table;
33 insert_history_entry('expired', $row4[1], $row[0]);
34 }
35
36 echo 'Removing data from Files table for dnldcode: ' . $row[1] . "\r\n";
37 $query2 = 'delete from Files where sessionid=' . $row[0];
38 $res2 = mysql_query($query2,$dbh) or die('<p><b>File was invalid, could not delete.</b>.\n<br />Query: ' . $query2 . '<br />\nError: (' . mysql_errno() . ') ' . mysql_error());
39
40 echo 'Removing data from Sessions table for dnldcode: ' . $row[1] . "\r\n";
41 $query3 = 'delete from Sessions where id=' . $row[0];
42 $res3 = mysql_query($query3,$dbh) or die('<p><b>Session was invalid, could not delete.</b>.\n<br />Query: ' . $query3 . '<br />\nError: (' . mysql_errno() . ') ' . mysql_error());
43
44 echo 'Removing file ' . $row4[0] . ' for dnldcode: ' . $row[1] . "\r\n";
45 remove_files($row[1]);
46 error_log($row[1] . ": Removed via scheduled cron job");
47 }
48
49 error_log("Cleaning up FTP area: " . $ftppath);
50 $dirlisting = scandir($ftppath);
51
52 foreach ($dirlisting as $key => $value) {
53 if (is_dir($ftppath . $value) && $value != '.' && $value != '..') {
54
55 $oldtime = time() - (60 * 60 * 24); // now minus 24 hours (in seconds);
56 $dirinfo = stat($ftppath . $value); // Get info. on directory
57
58 $numfiles = count(scandir($ftppath . $value));
59
60 if ($numfiles == 2) { // Delete if directory is empty;
61 error_log($value . ': Removing empty directory');
62 rmdir($ftppath . $value);
63 }
64 elseif ($dirinfo[9] < $oldtime) { // If older than 24 hours and no valid session entry exists, delete it;
65 $newquery = "select dnldcode from Sessions where dnldcode='$value'";
66 $newres = mysql_query($newquery,$dbh);
67 $newcount = mysql_num_rows($newres);
68
69 if ($newcount == 0) {
70 error_log($value . ': Removing based on exipration');
71 remove_files($value);
72 }
73 }
74 }
75 else {
76 // error_log("Non-dir found: " . $value);
77 }
78 }
79
80 ?>