function check_restrictions($dir, $show_root, &$myFiles, $fix_utf8, $status) { global $enable_dir_create_detection; // this is a check if the dir exists - this is a configuration error! if (file_exists($dir)) { $status .= "&dir_exists=true"; } else { $status .= "&dir_exists=false"; // no other checks are made because the directory is not available! return $status; } // now we check if we can delete the current folder - root folder cannot be deleted! $status .= is_tfu_deletable($dir) && $show_root ? "&dir_delete=true" : "&dir_delete=false"; // new we check if we can create folders - we have to check safemode too! set_error_handler("on_error_no_output"); $sm_prob = has_safemode_problem_global() && runsNotAsCgi(); if (is_writeable($dir)) { if ($enable_dir_create_detection) { // the detection of the safemode does not work on all systems - therefore it can be disabled. $status .= $sm_prob ? "&dir_create=subdir" : "&dir_create=true"; } else { $status .= "&dir_create=true"; } } else { $status .= $sm_prob ? "&dir_create=safemode" : "&dir_create=false"; } set_error_handler("on_error"); $nrFiles = count($myFiles); // now we check if can delete files - we only check the 1st file! if ($nrFiles > 0) { $delfile = fix_decoding($myFiles[0], $fix_utf8); // we have to remove the ** before checking $delfile = substr($delfile, 0, strpos($delfile, "**")); $status .= is_tfu_deletable($dir . "/" . $delfile) ? "&file_delete=true" : "&file_delete=false"; } return $status; }
function has_safemode_problem_global() { $isWindows = substr(PHP_OS, 0, 3) == 'WIN'; $no_cgi = runsNotAsCgi(); if (function_exists("posix_getpwuid") && function_exists("posix_getpwuid")) { $userid = posix_geteuid(); $userinfo = posix_getpwuid($userid); $def_user = array("apache", "nobody", "www"); if (in_array($userinfo["name"], $def_user)) { $no_cgi = true; } } if (ini_get('safe_mode') == 1 && $no_cgi && !$isWindows) { return true; } return false; }
usort($myFiles, "cmp_dec"); } reset($myFiles); usort($myDirs, "cmp_dir_dec"); if ($show_root) { array_unshift($myDirs, ".."); } // now we check if we can delete the current folder - root folder cannot be deleted! if (is_tfu_deletable($dir) && $show_root) { $status .= "&dir_delete=true"; } else { $status .= "&dir_delete=false"; } // new we check if we can create folders - we have to check safemode too! set_error_handler("on_error_no_output"); $sm_prob = has_safemode_problem_global() && runsNotAsCgi(); if (is_writeable($dir)) { if ($sm_prob) { $status .= "&dir_create=subdir"; } else { $status .= "&dir_create=true"; } } else { if ($sm_prob) { $status .= "&dir_create=safemode"; } else { $status .= "&dir_create=false"; } } set_error_handler("on_error"); $nrFiles = count($myFiles);