示例#1
0
 public static function checkUrl($url)
 {
     return Storage::fetchExternalUrl($url);
     //return ContextualizationScripts::fetchUrl($url);
 }
示例#2
0
 public function urlAction()
 {
     if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
         return;
     }
     $url = isset($_POST['url']) ? trim($_POST['url']) : null;
     if ($url === null) {
         echo '{"error":"Invalid request"}';
         return;
     }
     try {
         $guid = isset($_POST['guid']) ? $_POST['guid'] : uniqid();
         $data = Storage::fetchExternalUrl($url, $guid);
         $name = $name = isset($data['name']) && trim($data['name']) !== "" ? trim($data['name']) : uniqid();
         $name = Storage::escapeFileName($name);
         echo '{"url" : "' . DIRECTORY_SEPARATOR . $guid . DIRECTORY_SEPARATOR . $name . '", "name" : "' . $name . '", "md5":"' . $data['md5'] . '", "size":"' . $data['size'] . '"}';
     } catch (Exception $ex) {
         $res = array("error" => $ex->getMessage());
         echo json_encode($res);
         return;
     }
 }