/** * @param string $authJsonFile * @param string $clientIdentifier * @param string $prefix */ public function __construct($authJsonFile, $clientIdentifier, $prefix) { $pathError = Dropbox\Path::findError($prefix . 'check'); if ($pathError !== null) { throw new RuntimeException("Dropbox upload prefix error: {$pathError}"); } list($appInfo, $accessToken) = Dropbox\AuthInfo::loadFromJsonFile($authJsonFile); $config = new Dropbox\Config($appInfo, $clientIdentifier); $this->client = new Dropbox\Client($config, $accessToken); $this->prefix = sprintf('%s%x', $prefix, time()); }
public function actionGetdropboxlink($path) { $path = base64_decode($path); $pathError = Dropbox\Path::findError($path); if ($pathError !== null) { throw new CHttpException(500, "Invalid <dropbox-path>: {$pathError}\n"); } $client = new Dropbox\Client(Yii::app()->params['dropboxToken'], 'dropbox-client'); $link = $client->createTemporaryDirectLink($path); echo CJSON::encode($link); Yii::app()->end(); }
$bloc->previous_folder_hash = $metadata['hash']; $bloc->previous_folder = serialize($metadata); $bloc->save(false); } else { $metadata = unserialize($bloc->previous_folder); } } // If it's a folder, remove the 'contents' list from $metadata; print that stuff out after. $children = null; if ($metadata['is_dir']) { $children = $metadata['contents']; unset($metadata['contents']); } if ($children !== null && count($children) > 0) { foreach ($children as $child) { $name = Dropbox\Path::getName($child['path']); if (!$child['is_dir']) { ?> <dl> <dt class="<?php echo preg_replace('/[^A-Za-z0-9_\\-]/', '-', $child['mime_type']); ?> " title="<?php echo Helper::formatMimeType($child['mime_type']); ?> "><a href="javascript:;" title="<?php echo CHtml::encode($name); ?> " dropboxpath="<?php echo base64_encode($child['path']); ?>
/** * create_type * * This creates a new catalog type entry for a catalog * It checks to make sure its parameters is not already used before creating * the catalog. */ public static function create_type($catalog_id, $data) { $apikey = $data['apikey']; $secret = $data['secret']; $path = $data['path']; $getchunk = $data['getchunk']; if (!strlen($apikey) or !strlen($secret)) { Error::add('general', T_('Error: API Key and Secret Required for Dropbox Catalogs')); return false; } $pathError = Dropbox\Path::findError($path); if ($pathError !== null) { Error::add('general', T_('Invalid <dropbox-path>: ' . $pathError)); return false; } // Make sure this app isn't already in use by an existing catalog $sql = 'SELECT `id` FROM `catalog_dropbox` WHERE `apikey` = ?'; $db_results = Dba::read($sql, array($apikey)); if (Dba::num_rows($db_results)) { debug_event('catalog', 'Cannot add catalog with duplicate key ' . $apikey, 1); Error::add('general', sprintf(T_('Error: Catalog with %s already exists'), $apikey)); return false; } $sql = 'INSERT INTO `catalog_dropbox` (`apikey`, `secret`, `path`, `getchunk`, `catalog_id`) VALUES (?, ?, ?, ?, ?)'; Dba::write($sql, array($apikey, $secret, $path, $getchunk ? 1 : 0, $catalog_id)); return true; }