Ejemplo n.º 1
0
    // get & store access token, the request token is not needed anymore
    $access_token = $dropbox->GetAccessToken($request_token);
    store_token($access_token, "access");
    delete_token($_GET['oauth_token']);
}
// checks if access token is required
if (!$dropbox->IsAuthorized()) {
    // redirect user to dropbox auth page
    $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1";
    $auth_url = $dropbox->BuildAuthorizeUrl($return_url);
    $request_token = $dropbox->GetRequestToken();
    store_token($request_token, $request_token['t']);
    die("Authentication required. <a href='{$auth_url}'>Click here.</a>");
}
// CODE#
$dropbox->DownloadFile($_GET['dbxPath'], 'test_' . basename($_GET['dbxPath']));
function store_token($token, $name)
{
    if (!file_put_contents("tokens/{$name}.token", serialize($token))) {
        die('<br />Could not store token! <b>Make sure that the directory `tokens` exists and is writable!</b>');
    }
}
function load_token($name)
{
    if (!file_exists("tokens/{$name}.token")) {
        return null;
    }
    return @unserialize(@file_get_contents("tokens/{$name}.token"));
}
function delete_token($name)
{
Ejemplo n.º 2
0
$files = $dropbox->GetFiles("", false);
if (empty($files)) {
    $dropbox->UploadFile("leonidas.jpg");
    $files = $dropbox->GetFiles("", false);
}
echo "\r\n\r\n<b>Files:</b>\r\n";
print_r(array_keys($files));
if (!empty($files)) {
    $file = reset($files);
    $test_file = "test_download_" . basename($file->path);
    echo "<img src='" . $dropbox->GetLink($file, false) . "'/></br>";
    echo "\r\n\r\n<b>Meta data of <a href='" . $dropbox->GetLink($file) . "'>{$file->path}</a>:</b>\r\n";
    print_r($dropbox->GetMetadata($file->path));
    echo "{$test_file}</br>";
    echo "\r\n\r\n<b>Downloading {$file->path}:</b>\r\n";
    print_r($dropbox->DownloadFile($file, $test_file));
    echo "\r\n\r\n<b>Uploading {$test_file}:</b>\r\n";
    print_r($dropbox->UploadFile($test_file));
    echo "\r\n done!";
    echo "\r\n\r\n<b>Revisions of {$test_file}:</b>\r\n";
    print_r($dropbox->GetRevisions($test_file));
}
echo "\r\n\r\n<b>Searching for JPG files:</b>\r\n";
$jpg_files = $dropbox->Search("/", ".jpg", 5);
if (empty($jpg_files)) {
    echo "Nothing found.";
} else {
    print_r($jpg_files);
    $jpg_file = reset($jpg_files);
    echo "\r\n\r\n<b>Thumbnail of {$jpg_file->path}:</b>\r\n";
    $img_data = base64_encode($dropbox->GetThumbnail($jpg_file->path));
Ejemplo n.º 3
0
Archivo: sync.php Proyecto: rich13/info
		
		if(file_exists($remote_filepath)){
			$remote_mod = filemtime($remote_filepath);
		} else {
			$remote_mod = 0;
		}

		if($is_dir){
			$download = false;
			@mkdir($remote_filepath);
		}

		if($remote_mod < $db_mod &&
			$download == true){
			
			$dropbox->DownloadFile($file, $remote_filepath);
			
			if($debug){
				$output .= "+ ".$filepath."<br />";
			}

			$output = "+"; # report that we made changes
		}
	}

	$dir_iterator = new RecursiveDirectoryIterator("content/remote/");
	$dir_contents = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::CHILD_FIRST);

	foreach ($dir_contents as $filename) {
		$localfile = str_replace("content/remote/", "", $filename);
		if(!in_array($localfile, $filecheck)){