Пример #1
0
 protected static function removeTestFilesFromWhitelist($path)
 {
     $files = recursive_glob($path, true);
     foreach ($files as $file) {
         if (filetype($file) == 'dir') {
             self::removeTestFilesFromWhitelist($file);
         } else {
             if (substr($file, -8, 8) == 'Test.php') {
                 PHPUnit_Util_Filter::removeFileFromWhitelist($file);
             } else {
                 if (substr($file, -12, 12) == 'TestCase.php') {
                     PHPUnit_Util_Filter::removeFileFromWhitelist($file);
                 }
             }
         }
     }
 }
Пример #2
0
function recursive_glob($pattern = '*', $flags = 0, $path = '')
{
    $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
    $files = glob($path . $pattern, $flags);
    foreach ($paths as $path) {
        $files = array_merge($files, recursive_glob($pattern, $flags, $path));
    }
    return $files;
}
Пример #3
0
# regen ids base
if (isset($_GET['regen'])) {
    $ids = updateIDs($ids, $_GET['regen']);
    header('location:index.php?p=admin&token=' . TOKEN);
    exit;
}
# unzip: convert zip file to folder
if (!empty($_GET['unzip']) && trim($_GET['unzip']) !== false && $_SESSION['zip']) {
    $id = $_GET['unzip'];
    $zipfile = id2file($id);
    $folder = str_ireplace('.zip', '', _basename($zipfile));
    $id = new_folder($folder);
    $destination = id2file($id);
    unzip($zipfile, $destination);
    $sdi = array_flip($ids);
    $unzipped_content = recursive_glob($destination);
    foreach ($unzipped_content as $item) {
        if (empty($sdi[$item])) {
            $ids[uniqid(true)] = $item;
        }
    }
    store($ids);
    //$ids=updateIDs($ids,$id);
    header('location:index.php?p=admin&token=' . TOKEN);
    exit;
}
# renew file id
if (!empty($_GET['renew']) && trim($_GET['renew']) !== false && is_owner($_GET['renew'])) {
    $old_id = $_GET['renew'];
    $path = id2file($old_id);
    unset($ids[$old_id]);
Пример #4
0
 for ($i = 0; $i < count(explode("/", $_SERVER["SCRIPT_NAME"])) - 2; $i++) {
     array_pop($array);
 }
 $_SESSION["web_dir"] = implode($_SESSION["slash"], $array);
 //finding DAws's directory
 if (is_writable($daws_dir) && is_readable($daws_dir)) {
     $_SESSION["daws_directory"] = $daws_dir;
     //no need to look further since we are in it
 } else {
     //lets dance
     $locations = array($_SESSION["web_dir"], realpath($_SESSION["slash"]));
     //we go for a random directory if a proper web directory wasn't found
     foreach ($locations as $location) {
         //uses the recursive glob function for old php versions
         if (disabled_php("glob") == False) {
             $_SESSION["daws_directory"] = recursive_glob(realpath($location));
         } else {
             if (version_compare(PHP_VERSION, '5.0.0') >= 0 && installed_php(null, "RecursiveIteratorIterator") == True) {
                 //Iterator incoming!
                 $_SESSION["daws_directory"] = recursive_iterator($location);
             }
         }
         if (isset($_SESSION["daws_directory"]) && $_SESSION["daws_directory"] != "") {
             break;
         }
     }
 }
 if (basename($_SESSION["daws_directory"]) != "DAws") {
     //We just landed, time to get ready for battle because we got some mofos to kill!
     $_SESSION["daws_directory"] .= "/DAws";
     @mkdir($_SESSION["daws_directory"]);
Пример #5
0
function updateIDs($ids = null, $folder_id = null)
{
    if (!$ids) {
        $ids = unstore();
    }
    $ids = array_map(function ($id) {
        return str_replace('//', '/', $id);
    }, $ids);
    $sdi = array_flip($ids);
    $saveid = $savetree = false;
    $ids = array_flip($sdi);
    # here, all the redundant ids have gone ^^
    # scann all uploads folder (can be long but it's important)
    # or only the requested folder
    if (!empty($folder_id)) {
        $tree = recursive_glob(id2file($folder_id), true);
    } else {
        $tree = recursive_glob($_SESSION['upload_root_path'], true);
    }
    unset($tree[0]);
    # add missing ids
    foreach ($tree as $index => $file) {
        if (!isset($sdi[$file])) {
            $saveid = true;
            $id = uniqid(true);
            $ids[$id] = $file;
        } else {
            unset($sdi[$file]);
        }
    }
    if (empty($folder_id)) {
        # remove ids with no file (not required for single folder update)
        if (!empty($sdi)) {
            $saveid = true;
            foreach ($sdi as $file => $id) {
                if (!is_dir($file) && !is_file($file)) {
                    unset($ids[$id]);
                    if ($remove = array_search($file, $tree)) {
                        unset($tree[$remove]);
                    }
                }
            }
        }
    }
    if ($saveid) {
        store($ids);
        regen_tree($_SESSION['login'], $ids);
    }
    return $ids;
}