function doload($dir, $allow_directory = true, $may_execute = true) { if (file_exists($dir)) { if (is_file($dir)) { load_local_file($dir, EXTENSION, $may_execute); return true; } elseif (is_dir($dir) && !TRAILING_SLASH && REDIRECT_TRAILING_SLASH) { if ($_SERVER['REQUEST_METHOD'] == "POST") { load_page("404", 503); } else { header('Location: ' . URL . '/'); } return true; } elseif ($allow_directory && is_dir($dir) && (TRAILING_SLASH || FILENAME == '' || HANDLE_TRAILING_SLASH)) { require "defaults.php"; foreach ($defaults as $default => $execute) { # TODO: Optimize this! $extension = explode('.', $default); $extension = $extension[1]; if (file_exists("{$dir}/{$default}")) { if ($execute && $may_execute) { load_script_file("{$dir}/{$default}"); } else { load_local_file("{$dir}/{$default}", $extension); } return true; } } } } if (REQUESTED_FILE == "favicon.ico") { return serve_favicon(); } return false; }
$possible_match = PATH_PREFIX . "{$path_name}/{$pathlet}"; switch ($method_level) { case 0: // Seek Files // If it's a file (without a PHP extension), load it // like a static endpoint. Also load it if we're // proxying the PHP request. if (is_file($possible_match) && (defined("IXG_PROXY") || substr($pathlet, -4) != ".php")) { // If it can be loaded, we're done. Make sure we don't load it as a // directory. // This should match the code to load a static file in // /procedures/local_files.php if (defined("IXG_PROXY") && EXTENSION == "php") { require $possible_match; } else { load_local_file($possible_match, EXTENSION, false); } exit; // We're done, so break // If it's a directory, we're looking for a class within it. Append the // search path with the current segment and continue searching. } elseif (is_dir($possible_match)) { $path_name .= "/{$pathlet}"; break; // If it's a file (ending in .methods.php), start the proverbial car because // we're probably going to wind up with a methodical endpoint. } elseif (!defined("IXG_PROXY") && is_file($possible_match . ".methods.php") && $pathlet != "__default") { if (load_methodfile($possible_match . ".methods.php")) { break; } break 2;