Back to index

php5  5.3.10
Functions
open_basedir.inc File Reference

Go to the source code of this file.

Functions

 recursive_delete_directory ($directory)
 create_directories ()
 delete_directories ()
 test_open_basedir_error ($function)
 test_open_basedir_before ($function, $change=TRUE)
 test_open_basedir_after ($function)
 test_open_basedir_array ($function)
 test_open_basedir ($function)

Function Documentation

Definition at line 60 of file open_basedir.inc.

                              {
    delete_directories();
    $directory = getcwd();

    var_dump(mkdir($directory."/test"));
    var_dump(mkdir($directory."/test/ok"));
    var_dump(mkdir($directory."/test/bad"));
    file_put_contents($directory."/test/ok/ok.txt", "Hello World!");
    file_put_contents($directory."/test/bad/bad.txt", "Hello World!");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 71 of file open_basedir.inc.

                              {
    $directory = (getcwd()."/test");
    recursive_delete_directory($directory);
}

Here is the call graph for this function:

Here is the caller graph for this function:

recursive_delete_directory ( directory)

Definition at line 19 of file open_basedir.inc.

                                                {

    // Remove any trailing slash first
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }

    // Make sure the directory is valid
    if (is_dir($directory) == FALSE) {
        return FALSE;
    } 

    // Check we can access the directory
    if (is_readable($directory) == FALSE) {
        return FALSE;
    }

    $handle = opendir($directory);

    // Scan through the directory contents
    while (FALSE !== ($item = readdir($handle))) {
        if ($item != '.') {
             if ($item != '..') {
                $path = ($directory.'/'.$item);
                if (is_dir($path) == TRUE) {
                    recursive_delete_directory($path);
                } else {
                                   @chmod($path, 0777);
                    unlink($path);
                }
            }
        }
    }

    closedir($handle);
       @chmod($directory, 0777);
    rmdir($directory);

    return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

test_open_basedir ( function)

Definition at line 124 of file open_basedir.inc.

                                      {
    global $savedDirectory;
    test_open_basedir_before($function);
    test_open_basedir_error($function);     
    var_dump($function("./../."));
    var_dump($function("../ok"));
    var_dump($function("ok.txt"));
    var_dump($function("../ok/ok.txt"));
    $directory = $savedDirectory;
    var_dump($function($directory."/test/ok/ok.txt"));
    var_dump($function($directory."/test/ok/../ok/ok.txt"));
    test_open_basedir_after($function);
}

Here is the call graph for this function:

test_open_basedir_after ( function)

Definition at line 104 of file open_basedir.inc.

                                            {
    echo "*** Finished testing open_basedir configuration [$function] ***\n";
}

Here is the caller graph for this function:

test_open_basedir_array ( function)

Definition at line 109 of file open_basedir.inc.

                                            {
    global $savedDirectory;

    test_open_basedir_before($function);
    test_open_basedir_error($function); 
    var_dump(is_array($function("./../.")));
    var_dump(is_array($function("../ok")));
    var_dump(is_array($function("ok.txt")));
    var_dump(is_array($function("../ok/ok.txt")));
    $directory = $savedDirectory;
    var_dump(is_array($function($directory."/test/ok/ok.txt")));
    var_dump(is_array($function($directory."/test/ok/../ok/ok.txt")));
    test_open_basedir_after($function);
}

Here is the call graph for this function:

test_open_basedir_before ( function,
change = TRUE 
)

Definition at line 89 of file open_basedir.inc.

                                                             {
    global $savedDirectory;
    echo "*** Testing open_basedir configuration [$function] ***\n";
    $directory = getcwd();
    $savedDirectory = $directory;
    var_dump(chdir($directory));
    create_directories();

    // Optionally change directory
    if ($change == TRUE) {
        var_dump(chdir($directory."/test/ok"));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

test_open_basedir_error ( function)

Definition at line 76 of file open_basedir.inc.

                                            {
    global $savedDirectory;
    var_dump($function("../bad"));
    var_dump($function("../bad/bad.txt"));
    var_dump($function(".."));
    var_dump($function("../"));
    var_dump($function("/"));
    var_dump($function("../bad/."));
    $directory = $savedDirectory;
    var_dump($function($directory."/test/bad/bad.txt"));
    var_dump($function($directory."/test/bad/../bad/bad.txt"));
}

Here is the caller graph for this function: