This repository was archived by the owner on Oct 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcleaner.php
More file actions
71 lines (61 loc) · 2.02 KB
/
Copy pathcleaner.php
File metadata and controls
71 lines (61 loc) · 2.02 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
<?php
/*
* Jyraphe, your web file repository
* Copyright (C) 2008 Julien "axolotl" BERNARD <axolotl@magieeternelle.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('JYRAPHE_ROOT', dirname(__FILE__) . '/');
require_once(JYRAPHE_ROOT . 'libjyraphe/hConfig.php');
require_once(JYRAPHE_ROOT . 'libjyraphe/hClean.php');
// Initialising global hConfig.
hConfig::create();
// Loading cleaner config.
$cfg = parse_ini_file('config.php', true);
$cfg = $cfg['Cleaner'];
// If the cleaner is disabled, redirect to a 404 page.
if(!$cfg['enabled']) {
echo "Error: function is disabled.";
exit;
}
// Doing the hard work.
if ($cfg['allow_ips'] != "" ) {
$cleaner_ip = $cfg['allow_ips'];
$cleaner_ip = explode(',', $cleaner_ip);
} else {
$cleaner_ip = "127.0.0.1";
}
// If the IP is unauthorised, showing a 404 page (security.)
if (isset($_SERVER['SERVER_ADDR'])
&& !in_array($_SERVER['REMOTE_ADDR'], $cleaner_ip)
&& ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'])) {
echo "Error: unauthorised.";
exit;
} else {
echo "Cleaning up the files...";
echo "<br /><br />\n";
$dir_path = hConfig::getVar('var_root') . "links/";
$dir = dir($dir_path);
echo $dir_path;
echo "<br /><br />\n";
while($file = $dir->read()) {
if ($file != '.' && $file != '..') {
echo $file ."<br />\n";
$cleaner = new hClean();
echo $cleaner->clean($file);
}
}
$dir->close();
}
?>