Remove double htmlspecialchars
[aur.git] / scripts / cleanup
blob79994298da45efc6054062607b2cf4af8d37dac3
1 #!/usr/bin/php
2 <?php
3 # Run this script by providing it with the top path of AUR.
4 # In that path you should see a file lib/aur.inc
6 # This will remove files which belong to deleted packages
7 # in unsupported.
9 # ex: php cleanup dev/aur/web
11 $dir = $argv[1];
13 if (empty($dir)) {
14 echo "Please specify AUR directory.\n";
15 exit;
18 set_include_path(get_include_path() . PATH_SEPARATOR . "$dir/lib");
19 include("config.inc.php");
20 include("aur.inc.php");
21 include("pkgfuncs.inc.php");
23 $count = 0;
25 $buckets = scandir(INCOMING_DIR);
26 foreach ($buckets as $bucket) {
27 $bucketpath = INCOMING_DIR . $bucket;
28 if ($bucket == '.' || $bucket == '..' || !is_dir($bucketpath)) {
29 continue;
31 $files = scandir(INCOMING_DIR . $bucket);
32 foreach ($files as $pkgname) {
33 if ($pkgname == '.' || $pkgname == '..') {
34 continue;
36 $fullpath = INCOMING_DIR . $bucket . "/" . $pkgname;
37 if (!pkgid_from_name($pkgname) && is_dir($fullpath)) {
38 echo 'Removing ' . $fullpath . "\n";
39 rm_tree($fullpath);
40 $count++;
45 echo "\nRemoved $count directories.\n";