$backUrl = documentBackLink($uploadPath); if ($can_upload) { $navigation[] = array('url' => $backUrl, 'name' => $pageName); $pendingCloudUpload = CloudDriveManager::getFileUploadPending(); if ($pendingCloudUpload) { $group_hidden_input .= "<input type='hidden' name='ext' value='true'>"; $pageName = $langDownloadFile; $fileinput = " <div class='form-group'> <label for='fileCloudName' class='col-sm-2 control-label'>$langCloudFile</label> <div class='col-sm-10'> <input type='hidden' class='form-control' id='fileCloudInfo' name='fileCloudInfo' value='".q($pendingCloudUpload)."'> <input type='text' class='form-control' name='fileCloudName' value='" . q(CloudFile::fromJSON($pendingCloudUpload)->name()) . "' readonly> </div> </div>"; } else if (isset($_GET['ext'])) { $group_hidden_input .= "<input type='hidden' name='ext' value='true'>"; $pageName = $langExternalFile; $fileinput = " <div class='form-group'> <label for='fileURL' class='col-sm-2 control-label'>$langExternalFileInfo:</label> <div class='col-sm-10'> <input type='text' class='form-control' id='fileURL' name='fileURL'> </div> </div>"; } else { $pageName = $langDownloadFile; $fileinput = "
$result = Database::get()->querySingle("SELECT id FROM document WHERE $group_sql AND path = ?s LIMIT 1", $uploadPath); if (!$result or !$result->id) { $error = $langImpossible; } } /* ******************************************************************** * UPLOAD FILE * ******************************************************************** */ $action_message = $dialogBox = ''; $extra_path = ''; if (isset($_POST['fileCloudInfo']) or isset($_FILES['userFile'])) { if (isset($_POST['fileCloudInfo'])) { // upload cloud file $cloudfile = CloudFile::fromJSON($_POST['fileCloudInfo']); $uploaded = true; $fileName = $cloudfile->name(); } else if (isset($_FILES['userFile']) and is_uploaded_file($_FILES['userFile']['tmp_name'])) { // upload local file $fileName = $_FILES['userFile']['name']; $userFile = $_FILES['userFile']['tmp_name']; } validateUploadedFile($fileName, $menuTypeID); // check file type // check for disk quotas if ($diskUsed + @$_FILES['userFile']['size'] > $diskQuotaDocument) { Session::Messages($langNoSpace, 'alert-danger'); redirect_to_current_dir(); } elseif (isset($_POST['uncompress']) and $_POST['uncompress'] == 1 and preg_match('/\.zip$/i', $fileName)) { /* ** Unzipping stage ** */ $zipFile = new pclZip($userFile); validateUploadedZipFile($zipFile->listContent(), $menuTypeID);
/** * * @param CloudFile $cloudfile * @param type $path * @return type */ public function store($cloudfile, $path) { if (!$this->isAuthorized()) return CloudDriveResponse::AUTHORIZATION_ERROR; return $this->downloadToFile($this->url() . "/" . $cloudfile->id(), $path, null, $this->username() . ":" . $this->password()); }
/** * * @param CloudFile $cloudfile * @param type $path * @return type */ public function store($cloudfile, $path) { if (!$this->isAuthorized()) return CloudDriveResponse::AUTHORIZATION_ERROR; $key = file_get_contents(realpath(dirname(__FILE__)) . "/googledrive_key.p12"); if (!$key) return CloudDriveResponse::AUTHORIZATION_ERROR; $email = $this->getExtApp()->getParam(GoogleDriveApp::EMAIL)->value(); $cred = new Google_Auth_AssertionCredentials($email, array(Google_Service_Drive::DRIVE), $key); $this->client->setAssertionCredentials($cred); $cred->sub = $email; $request = new Google_Http_Request($cloudfile->id(), 'GET', null, null); $httpRequest = $this->client->getAuth()->authenticatedRequest($request); if ($httpRequest->getResponseHttpCode() == 200) { try { $fout = fopen($path, "w+b"); file_put_contents($path, $httpRequest->getResponseBody()); fclose($fout); return CloudDriveResponse::OK; } catch (Exception $ex) { return CloudDriveResponse::FILE_NOT_SAVED; } } else { return CloudDriveResponse::FILE_NOT_FOUND; } }