public function delete($uid) { try { $dropbox = Dropbox::find($uid); $dropbox->delete(); } catch (Exception $e) { return ['success' => false, 'error_message' => $e->getMessage()]; } return ['success' => true]; }
/** * Tests Dropbox->fileopsMove() */ public function testFileopsMove() { $this->dropbox->fileopsCreateFolder(BASE_PATH . 'will_be_moved'); $response = $this->dropbox->fileopsMove(BASE_PATH . 'will_be_moved', BASE_PATH . 'moved'); $this->assertArrayHasKey('hash', $response); $this->assertArrayHasKey('revision', $response); $this->assertArrayHasKey('modified', $response); $this->assertArrayHasKey('path', $response); // cleanup $this->dropbox->fileopsDelete(BASE_PATH . 'moved'); }
<?php /* ======================================================================== * Open eClass * E-learning and Course Management System * ======================================================================== * Copyright 2003-2014 Greek Universities Network - GUnet * A full copyright notice can be read in "/info/copyright.txt". * For a full list of contributors, see "credits.txt". * * Open eClass is an open platform distributed in the hope that it will * be useful (without any warranty), under the terms of the GNU (General * Public License) as published by the Free Software Foundation. * The full license can be read in "/info/license/license_gpl.txt". * * Contact address: GUnet Asynchronous eLearning Group, * Network Operations Center, University of Athens, * Panepistimiopolis Ilissia, 15784, Athens, Greece * e-mail: info@openeclass.org * ======================================================================== */ require_once '../clouddrive.php'; $drive = new Dropbox(); if (strpbrk($_GET['code'], "\r\n")) die(); if (strpbrk($_GET['state'], "\r\n")) die(); header('Location: ../popup.php?' . $drive->getDriveDefaultParameter() . "&code=" . urlencode($_GET['code']) . "&state=" . urlencode($_GET['state'])); die();
$tmpFile = $tmpDir.'/'.str_replace("/\0", '_', $_FILES['file']['name']); if (!move_uploaded_file($_FILES['file']['tmp_name'], $tmpFile)) throw new Exception('Cannot rename uploaded file!'); // Upload //$uploader = new Dropbox('*****@*****.**','initpass'); $dropbox = new Dropbox('0b6mkq8ervg1zd5', 'p9tgw4dpb57e0eh'); $uploader = $dropbox->token('*****@*****.**', 'initpass'); $dropbox->setOAuthToken($uploader['token']); $dropbox->setOAuthTokenSecret($uploader['secret']); $response = $dropbox->filesPost('resumes', $tmpFile); // output response
<?php // require require_once 'config.php'; require_once '../dropbox.php'; // create instance $dropbox = new Dropbox(APPLICATION_KEY, APPLICATION_SECRET); $dropbox->setOAuthToken(TOKEN); $dropbox->setOAuthTokenSecret(TOKEN_SECRET); // oAuth dance //$response = $dropbox->oAuthRequestToken(); //if(!isset($_GET['authorize'])) $dropbox->oAuthAuthorize($response['oauth_token'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] .'?authorize=true'); //else $response = $dropbox->oAuthAccessToken($_GET['oauth_token']); //$response = $dropbox->token(EMAIL, PASSWORD); //$response = $dropbox->account(time() . '*****@*****.**', PASSWORD, 'Tijs', 'Verkoyen'); //$response = $dropbox->accountInfo(); //$response = $dropbox->filesGet(BASE_PATH .'hàh@, $.txt'); //$response = $dropbox->filesPost(BASE_PATH, realpath('../dropbox.php')); //$response = $dropbox->filesPost(BASE_PATH .'with spaces', realpath('../dropbox.php')); //$response = $dropbox->filesPost(BASE_PATH .'met spaties/', realpath('/Users/tijs/Projects/dropbox/tests/with spaces.txt')); //$response = $dropbox->metadata(BASE_PATH .'met spaties'); //$response = $dropbox->thumbnails(BASE_PATH .'image.png'); //$response = $dropbox->fileopsCopy(BASE_PATH . 'image.png', BASE_PATH . 'copy_' . time()); //$response = $dropbox->fileopsCreateFolder(BASE_PATH .'created_'. time()); //$response = $dropbox->fileopsDelete(BASE_PATH .'will_be_deleted'); //$response = $dropbox->fileopsMove(BASE_PATH .'will_be_moved', BASE_PATH .'moved_'. time()); // output (Spoon::dump()) ob_start(); var_dump($response); $output = ob_get_clean(); // cleanup the output
/** * Downloads backup file from Dropbox to root folder on local server. * * @param array $args arguments passed to the function * [consumer_key] -> consumer key of ManageWP Dropbox application * [consumer_secret] -> consumer secret of ManageWP Dropbox application * [oauth_token] -> oauth token of user on ManageWP Dropbox application * [oauth_token_secret] -> oauth token secret of user on ManageWP Dropbox application * [dropbox_destination] -> folder on user's Dropbox account which backup file should be deleted from * [dropbox_site_folder] -> subfolder with site name in dropbox_destination which backup file should be deleted from * [backup_file] -> absolute path of backup file on local server * @return bool|array absolute path to downloaded file is successful, array with error message if not */ function get_dropbox_backup($args) { extract($args); global $mmb_plugin_dir; require_once $mmb_plugin_dir . '/lib/dropbox.php'; $dropbox = new Dropbox($consumer_key, $consumer_secret); $dropbox->setOAuthTokens($oauth_token, $oauth_token_secret); if ($dropbox_site_folder == true) { $dropbox_destination .= '/' . $this->site_name; } $temp = ABSPATH . 'mwp_temp_backup.zip'; try { $file = $dropbox->download($dropbox_destination . '/' . $backup_file); $handle = @fopen($temp, 'w'); $result = fwrite($handle, $file); fclose($handle); if ($result) { return $temp; } else { return false; } } catch (Exception $e) { $this->_log($e->getMessage()); return array('error' => $e->getMessage(), 'partial' => 1); } }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $entries = Dropbox::find($id)->entries; return View::make('dropboxes.show', compact('entries')); }
function repositoryDropbox($args) { extract($args); if (isset($consumer_secret) && !empty($consumer_secret)) { require_once APP_ROOT . '/lib/dropbox.oauth.php'; $dropbox = new Dropbox($consumer_key, $consumer_secret); $dropbox->setOAuthToken($oauth_token); $dropbox->setOAuthTokenSecret($oauth_token_secret); try { $dropbox->accountinfo(); return array('status' => 'success'); } catch (Exception $e) { return array('status' => 'error', 'errorMsg' => $e->getMessage()); } } return array('status' => 'error', 'errorMsg' => 'Consumer Secret not available'); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function files($contract_guid) { // $sync_status = $this->status($contract_guid); // no longer used? $user = Dropbox::find($contract_guid); if (!$user) { throw new Symfony\Component\HttpKernel\Exception\NotFoundHttpException(); } $entries = $user->entries; $apiEntries = []; foreach ($entries->toArray() as $entry) { if ($entry['is_dir']) { continue; // skip directories } // if (is_null($entry['file_sha']) || is_null($entry['etag'])) { // continue; // skip files that are not yet downloaded // } if (strrpos(basename($entry['original_path']), '.')) { $extension = substr(basename($entry['original_path']), strrpos(basename($entry['original_path']), '.')); } else { $extension = ".extensionless"; } if (is_null($entry['file_sha'])) { $local_url = 'https://' . Config::get('app.drobpox_host') . '/download/' . $entry['id']; } else { $local_url = 'https://' . Config::get('app.content_host') . '/dropbox/' . $entry['file_sha'] . $extension; } $remote_url = 'https://www.dropbox.com/home' . dirname($entry['original_path']); // TODO: URL encoding? $created_at = Carbon::createFromFormat('Y-m-d H:i:s', $entry['created_at'])->toRFC2822String(); $updated_at = Carbon::createFromFormat('Y-m-d H:i:s', $entry['updated_at'])->toRFC2822String(); $apiEntry = ['local_url' => $local_url, 'remote_url' => $remote_url, 'original_path' => $entry['original_path'], 'mime_type' => $entry['mime_type'], 'bytes' => $entry['bytes'], 'service_created_at' => $entry['service_created_at'], 'service_updated_at' => $entry['service_updated_at'], 'client_created_at' => $entry['client_created_at'], 'client_updated_at' => $entry['client_updated_at'], 'created_at' => $created_at, 'updated_at' => $updated_at, 'file_sha' => $entry['file_sha'], 'etag' => $entry['etag']]; $apiEntries[] = $apiEntry; } return [$apiEntries]; }
/** * Tests Dropbox::setUp * * @expectedException \phpbu\App\Backup\Sync\Exception */ public function testSetUpNoPath() { $dropbox = new Dropbox(); $dropbox->setup(array('token' => 'this-is-no-token')); }