YANZ UPLOAD ANJG

1; } // ----------------------------------------------------------------------------- function getServicePath() { global $config; global $serviceid; if ($serviceid === "0") { $mediaPath = $config["mediadb"]; } elseif ($serviceid === "1500") { $mediaPath = str_replace("mediadb","sysdb",$config["mediadb"]); } else { uerr("invalid $serviceid\n", "400 Bad Request"); } return $mediaPath; } // ----------------------------------------------------------------------------- // helper function: replace LAST occurence of a string function substr_replace_last($search, $replace, $str) { if(($pos = strrpos($str, $search)) !== false) { $search_length = strlen($search); $str = substr_replace($str, $replace, $pos, $search_length); } return $str; } // ----------------------------------------------------------------------------- // start of main set_error_handler("userErrorHandler",E_USER_ERROR); $querydata = explode("&",$_SERVER["QUERY_STRING"]); $isattachment = is_int(array_search("cdp=a",$querydata)); $ispassthrough = is_int(array_search("pass=true",$querydata)); $reqdata = explode("/", $_SERVER["PATH_INFO"]); array_shift($reqdata); /* extract serviceid from path, currently unused */ $serviceid = array_shift($reqdata); $filename = $reqdata[count($reqdata) - 1]; $parent = $reqdata[count($reqdata) - 2]; $path = implode("/", $reqdata); $filepath = getFilepath($path); // debug // echo $filename . "\n" . $parent . "\n" . $path . "\n" . $filepath . "\n"; // echo getUroOriginalName($parent) . "\n" . getUroOriginalPath($path, $parent) . "\n" . getFilepath(getUroOriginalPath($path, $parent)) . "\n"; // echo (isGif(getUroOriginalName($parent)) ? "isGif" : "noGif") . "\n" . (isUroThumb($parent, $filename) ? "isThumb" : "noThumb"); // exit(0); if (!file_exists($filepath) || (isGif(getUroOriginalName($parent)) /* isAnimatedGif($filepath) */ && !isUroThumb($parent, $filename))) { if (isUro($parent)) { if ($filename == 'poster') { // request on missing file "poster" in an URO folder, must be a video folder // so we have a video folder without a poster file, so return the "thumb" element $path = substr_replace_last('poster', 'thumb', $path); } else { $path = getUroOriginalPath($path, $parent); } } else { uerr("ERROR: uro resource file [$filepath] not found", "404 [$path] Not Found"); } $filepath = getFilepath($path); if (!file_exists($filepath)) { uerr("ERROR: uro fallback file [$filepath] not found", "404 Not Found"); } } if ($isattachment) { header("Content-Type: " . getContentType($filepath)); header("Content-Length: " . filesize($filepath)); $user_agent = $_SERVER["HTTP_USER_AGENT"]; if (!preg_match("/Safari/", $user_agent) || !preg_match("/iPhone OS (1|2|3|4|5)_/", $user_agent)) { // omit Content-Disposition header for safari on ios <= 5.x due to projects issue #1417 header("Content-Disposition: attachment; filename=\"" . $filename . "\""); } ob_end_clean(); unbufferedPassthru($filepath); } elseif ($ispassthrough) { header("Content-Type: " . getContentType($filepath)); header("Content-Length: " . filesize($filepath)); header("Access-Control-Allow-Origin: *"); $user_agent = $_SERVER["HTTP_USER_AGENT"]; ob_end_clean(); unbufferedPassthru($filepath); } else { $mediaDbPath = preg_replace("/\\/.cm4all\\/uproc.php\\/.*/" , "/", $_SERVER["REQUEST_URI"]) . getServicePath(); $imagePath = preg_replace("/%2F/", "/", urlenc(preg_replace("/^\\/+/", "", $path))); header("Location: " . preg_replace("/\\/\\/+/", "/", $mediaDbPath . "/" . $imagePath)); ob_end_clean(); } // ----------------------------------------------------------------------------- ?>