aboutsummaryrefslogtreecommitdiff
path: root/ratatoeskr/sys/utils.php
blob: 60f90a8a798aabd9cb473e866cdea0953f0cb67d (plain)
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
<?php
/*
 * File: ratatoeskr/sys/utils.php
 *
 * Various useful helper functions.
 *
 * License:
 * This file is part of Ratatöskr.
 * Ratatöskr is licensed unter the MIT / X11 License.
 * See "ratatoeskr/licenses/ratatoeskr" for more information.
 */

/*
 * Function: delete_directory
 * Delete a directory and all of its content.
 */
function delete_directory($dir)
{
    $dir_content = scandir($dir);
    foreach ($dir_content as $f) {
        if (($f == "..") or ($f == ".")) {
            continue;
        }

        $f = "$dir/$f";

        if (is_dir($f)) {
            delete_directory($f);
        } else {
            unlink($f);
        }
    }
    rmdir($dir);
}

/*
 * Constant: SITE_BASE_PATH
 * The Base path of this ratatoeskr site.
 */
define("SITE_BASE_PATH", dirname(dirname(dirname(__FILE__))));