Example #1
0
 public function getFilesFromPath($index, $path, $access_token)
 {
     $client = new dbx\Client($access_token, "PHP");
     #get file information from current path;
     $data = $client->getMetadataWithChildren("{$path}");
     #if the file has 'content' (directory) print out the information like normal
     if (array_key_exists('contents', $data) && $data['is_dir'] == 1) {
         $return_dropfiles = array('type' => 'folder');
         $return_dropfiles['content'] = [];
         $return_dropfiles['service'] = 1;
         $return_dropfiles['index'] = $index;
         foreach ($data['contents'] as $file) {
             $temp = [];
             $path = $file['path'];
             //parsing out the filename from the path
             $namefile = explode('/', $path);
             $num = count($namefile) - 1;
             $temp['name'] = $namefile[$num];
             $temp['size'] = $file['size'];
             $temp['kind'] = $file['icon'];
             $temp['path'] = $path;
             array_push($return_dropfiles['content'], $temp);
         }
         return $return_dropfiles;
     } else {
         $link = array('type' => 'file');
         $link['service'] = '1';
         $link['link'] = $client->createTemporaryDirectLink($data['path']);
         return $link;
     }
 }
 public function getFileUrl($hash)
 {
     if (!($remoteFile = $this->fileExists($hash))) {
         throw new \RuntimeException('File not found');
     }
     list($url, $expiration) = $this->client->createTemporaryDirectLink($remoteFile);
     return $url;
 }
Example #3
0
        #if the file has 'content' (directory) print out the information like normal
        if (array_key_exists('contents', $data)) {
            foreach ($data['contents'] as $file) {
                $path = $file['path'];
                //parsing out the filename from the path
                $namefile = explode('/', $path);
                $num = count($namefile) - 1;
                $actualname = $namefile[$num];
                $size = $file['size'];
                $icon = $file['icon'];
                $ref_link = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $email . '&' . $path;
                print "<tr href=\"{$ref_link}\" style=\"text-align: center\"><td class=\"file\" style=\"text-align: center\">{$email}</td><td class=\"file\" style=\"text-align: center\">{$icon}</td><td class=\"file\" style=\"text-align: center\">{$user}</td><td class=\"file\" style=\"text-align: center\">{$actualname}</td><td class=\"file\" style=\"text-align: center\">{$size}</td><td class=\"file\" style=\"text-align: center\"><a class =\"deletefile\" href=\"{$ref_link}&delete\">Delete</a></td></tr>";
            }
        } else {
            #if the file clicked is not a directory (actual file) generate a temp link and download it
            $link = $client->createTemporaryDirectLink($path);
            header("Location: {$link['0']}");
        }
    }
}
?>
   </tbody>
</table>
    <body>
<!--side bar navigation-->
<div id="page-sidebar">
<div>
<a id="linkaccount" href = "linkaccount.php">Link Account</a>
<a id="logout" href = "logout.php">Log Out</a>
</div>
<div id="accountInfo">
Example #4
0
print '<pre>';
# Include the Dropbox SDK libraries
require_once './dropbox-sdk-php-1.1.5/lib/Dropbox/autoload.php';
//MODX_BASE_PATH.
use Dropbox as dbx;
$accessToken = "-QAlimGqvKAAAAAAAAAAjRWBUFnqWI0AuJV06CSJtnvDKFYMpujYYU2h4fN7-Hlv";
// Здесь ваш Access token
$dbxClient = new dbx\Client($accessToken, "ITMO_POKS_FOLDER");
//work
// 					$img_link = $dbxClient->getThumbnail("/1234.jpeg", "jpeg", "xs");
// 					print_r($img_link[0]);
// 					$f = fopen("./LoadedFiles/tmp.png", "w+b");
// 					fwrite($f, $img_link[1]);
//
// 					echo "<img src= './LoadedFiles/tmp.png' />";
$img_link = $dbxClient->createTemporaryDirectLink("/1234.jpeg");
echo "<img class = 'well' src= 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSfNWdwH6eo-pxKROhTDkMmP0kBnZxvp9LJypN9Tlzec0CZklzx' width = '200' height = '200'/>";
echo "<img class = 'well' src = '{$img_link['0']}' width = '200' height = '200'/>";
echo "<img class = 'well'  src='http://sheshtawy.files.wordpress.com/2010/05/extra-firefox.png' width = '200' height = '200'/>";
echo "<img class = 'well'  src='http://sheshtawy.files.wordpress.com/2013/03/cairo_pollution.jpg' width = '200' height = '200' />";
echo "<img class = 'well'  src='http://sheshtawy.files.wordpress.com/2012/12/img_4749.jpg' width = '200' height = '200'/>";
echo "<img class = 'well'  src='http://360tv.ru/binfiles/images/20150911/b7f5b9e7.jpg' width = '200' height = '200'/>";
//	$accountInfo = $dbxClient->getAccountInfo();
// 	print_r($accountInfo);
// 	$f = fopen("./LoadedFiles/snapshot4.png", "rb");
// 	$fileMetadata = $dbxClient->uploadFile("/snapshot4.png", dbx\WriteMode::add(), $f);
// 	fclose($f);
// 	print_r($fileMetadata);
//
// 	$folderMetadata = $dbxClient->getMetadataWithChildren("/");
// 	print_r($folderMetadata);
Example #5
0
require_once "../lib/Dropbox/autoload.php";
use Dropbox as dbx;
$client = new dbx\Client($_SESSION['accounts'][$thing]['token'], "PHP");
#get file information from current path;
$path = $_POST['path'];
$data = $client->getMetadataWithChildren("{$path}");
#if the file has 'content' (directory) print out the information like normal
if (array_key_exists('contents', $data) && $data['is_dir'] == 1) {
    $return_dropfiles = array('type' => 'folder');
    $return_dropfiles['content'] = [];
    $return_dropfiles['service_id'] = $_POST['files'];
    $return_dropfiles['service'] = "1";
    foreach ($data['contents'] as $file) {
        $temp = [];
        $path = $file['path'];
        //parsing out the filename from the path
        $namefile = explode('/', $path);
        $num = count($namefile) - 1;
        $temp['name'] = $namefile[$num];
        $temp['size'] = $file['size'];
        $temp['kind'] = $file['icon'];
        $temp['path'] = $path;
        array_push($return_dropfiles['content'], $temp);
    }
    print json_encode($return_dropfiles);
} else {
    $link = array('type' => 'file');
    $link['service'] = '1';
    $link['link'] = $client->createTemporaryDirectLink($data['path']);
    print json_encode($link);
}