0) { $items = $res['children']; $nodes = explode('/',substr($path, 1), 2); $next = $nodes[0]; $rest = count($nodes) > 1 ? $nodes[1] : ""; foreach ($items as $item) { if ($item['name'] == $next) { if (isset($item['folder'])) { return get_item_from_path($item['webUrl'], "/" . $rest); } else if (isset($item['file'])) { $result['pathvalid'] = true; $result['isfolder'] = false; $result['data'] = $item; return $result; } } } } $result['pathvalid'] = false; return $result; } $result = get_item_from_path($share_url, $path); if ($result['pathvalid'] && $result['isfolder'] == false) { $download_url = $result['data']['@content.downloadUrl']; header("Location: $download_url", true, 302); exit(); } ?> Download " . substr($path, 1) . " does not exists!"; ?>