function parsedavfolder($url) { $prop = davPROP($url, DAVUSERNAME, DAVPASS); $status = $prop["info"]["http_code"]; if ($status < 400) { if (strpos($prop["result"], '<?xml') !== false) { $xml = xmlstr_to_array(strstr($prop["result"], '<?xml')); $xml = $xml['d:response']; foreach ($xml as $row) { $array[] = array("folder" => isset($row['d:propstat']['d:prop']['d:isFolder']) ? "t" : "f", "name" => $row['d:propstat']['d:prop']['d:displayname'], "size" => isset($row['d:propstat']['d:prop']['d:getcontentlength']) ? $row['d:propstat']['d:prop']['d:getcontentlength'] : "f", "modified" => strtotime($row['d:propstat']['d:prop']['d:getlastmodified']) + LOCALTIME, "href" => $row['d:href']); } array_shift($array); return $array; } else { print "No xml data returned."; } } else { print "Error {$status} - An unexpected error occurred."; } return false; }
<?php require "../includes/config.php"; $prop = davPROP($url, DAVUSERNAME, DAVPASS); $status = $prop["info"]["http_code"]; if ($status < 400) { if (strpos($prop["result"], '<?xml') !== false) { $xml = xmlstr_to_array(strstr($prop["result"], '<?xml')); $xml = $xml['d:response']; foreach ($xml as $row) { $array[] = array("folder" => isset($row['d:propstat']['d:prop']['d:isFolder']) ? "t" : "f", "name" => $row['d:propstat']['d:prop']['d:displayname'], "size" => isset($row['d:propstat']['d:prop']['d:getcontentlength']) ? $row['d:propstat']['d:prop']['d:getcontentlength'] : "f", "modified" => strtotime($row['d:propstat']['d:prop']['d:getlastmodified']) + LOCALTIME, "href" => $row['d:href']); } array_shift($array); return $array; } else { print "No xml data returned."; } } else { print "Error {$status} - An unexpected error occurred."; }
if ($status < 400) { $xml = xmlstr_to_array(strstr($prop["result"], '<?xml')); $xml = $xml['d:response']; $fname = $xml["d:propstat"]["d:prop"]["d:displayname"]; $type = $xml["d:propstat"]["d:prop"]["d:getcontenttype"]; $get = davGET($url, $thiscloud["username"], mcrypt_ecb(MCRYPT_3DES, MCRYPTKEY, $thiscloud["password"], MCRYPT_DECRYPT)); header("Content-disposition: attachment; filename={$fname}"); header("Content-type: {$type}"); echo $get; exit; } else { apologize("Error {$status} - An unexpected error occurred."); } } else { // If Webdav Folder $prop = davPROP($url, $thiscloud["username"], mcrypt_ecb(MCRYPT_3DES, MCRYPTKEY, $thiscloud["password"], MCRYPT_DECRYPT)); $status = $prop["info"]["http_code"]; if ($status < 400) { if (strpos($prop["result"], '<?xml') !== false) { $xml = xmlstr_to_array(strstr($prop["result"], '<?xml')); $xml = $xml['d:response']; foreach ($xml as $row) { $positions[] = array("folder" => isset($row['d:propstat']['d:prop']['d:isFolder']) ? "t" : "f", "name" => $row['d:propstat']['d:prop']['d:displayname'], "size" => isset($row['d:propstat']['d:prop']['d:getcontentlength']) ? $row['d:propstat']['d:prop']['d:getcontentlength'] : "f", "modified" => strtotime($row['d:propstat']['d:prop']['d:getlastmodified']) + LOCALTIME, "href" => $row['d:href']); } if (!isset($_GET["url"])) { $positions[0]["name"] = "Home"; } render("home.php", array("title" => isset($positions[0]["name"]) ? $positions[0]["name"] : "", "positions" => $positions, "clouds" => $clouds, "thiscloud" => $thiscloud)); } else { apologize("No xml data returned."); }
} else { if ($delcloud[0]["cloudnum"] == 2) { // Google Drive require "../includes/gclient.php"; $client->revokeToken(); unset($_SESSION["token"]); } query("DELETE FROM clouds WHERE number = ? AND id = ?", $_GET["dnum"], $_SESSION["id"]); unset($_SESSION["cloud"]); } } elseif ($_SERVER["REQUEST_METHOD"] == "POST") { //IF NEW CLOUD if ($_POST["provider"] == 1) { // if DAV // todo: Check if server is a webdav compliant server. $prop = davPROP($_POST["url"], $_POST["username"], $_POST["password"]); $status = $prop["info"]["http_code"]; if ($status > 399) { apologize("Error {$status} - An unexpected error occurred."); } elseif (strpos($prop["info"]["content_type"], 'xml') === false) { // if content type isn't xml apologize("Improper data returned. Check your input and try again."); } else { query("INSERT INTO clouds (id, cloudnum, username, password, cloudname, url) VALUES (?, ?, ?, ?, ?, ?)", $_SESSION["id"], $_POST["provider"], $_POST["username"], mcrypt_ecb(MCRYPT_3DES, MCRYPTKEY, $_POST["password"], MCRYPT_ENCRYPT), $_POST["name"], $_POST["url"]); $bokk = query("SELECT LAST_INSERT_ID() AS number"); $bokk = $bokk[0]["number"]; $_SESSION["cloud"] = $bokk[0]["number"]; } } elseif ($_POST["provider"] == 2) { // If Google OAuth require "../includes/gclient.php";