コード例 #1
0
ファイル: dropbox.php プロジェクト: betsyzhang/chyrp
 static function admin_dropbox_settings($admin)
 {
     $config = Config::current();
     if (!Visitor::current()->group->can("change_settings")) {
         show_403(__("Access Denied"), __("You do not have sufficient privileges to change settings."));
     }
     if (empty($_POST)) {
         return $admin->display("dropbox_settings");
     }
     if (!isset($_POST['hash']) or $_POST['hash'] != $config->secure_hashkey) {
         show_403(__("Access Denied"), __("Invalid security key."));
     }
     if (isset($_POST['authorize'])) {
         $data = json_decode(file_get_contents("http://chyrp.net/api/1/dropboxsync.php?keys"), true);
         $app_key = $data["key"];
         $app_secret = $data["secret"];
         $callback = url("/admin/?action=dropbox_oauth");
         try {
             $storage = new \Dropbox\OAuth\Storage\Session();
             // if (!$storage->get("access_token"))
             $storage->delete();
             $OAuth = new \Dropbox\OAuth\Consumer\Curl($app_key, $app_secret, $storage, $callback);
             # Build authorize URL and redirect to Dropbox
             redirect($OAuth->getAuthoriseURL());
         } catch (\Dropbox\Exception $e) {
             error(__("Dropbox Sync Error!", "dropbox"), $e->getMessage());
         }
     }
 }