コード例 #1
0
ファイル: dropbox.php プロジェクト: BlackMac/timetrack
    }
    if (!isset($_SESSION['dropbox_access_token']) && !isset($_GET['response'])) {
        $params = array('oauth_token' => $token['oauth_token'], 'oauth_callback' => $callbackURL);
        header('Location: ' . $authorizationTokenURL . '?' . http_build_query($params));
    } elseif (isset($_GET['response'])) {
        $params = array('oauth_consumer_key' => $consumerKey, 'oauth_nonce' => md5(microtime(true)), 'oauth_signature_method' => 'PLAINTEXT', 'oauth_signature' => $consumerSecret . chr(38) . $requestToken['oauth_token_secret'], 'oauth_timestamp' => time(), 'oauth_version' => '1.0', 'oauth_verifier' => $_GET['uid'], 'oauth_token' => $_GET['oauth_token']);
        $response = file_get_contents($getTokenURL . '?' . http_build_query($params));
        parse_str($response, $token);
        if (!isset($token['oauth_token_secret'], $token["oauth_token"])) {
            echo "<b>Dropbox: Failed to create access token. </b>";
            die;
        }
        // array ( 'oauth_token_secret' => 'yptm8tt3wh3dk9h', 'oauth_token' => 'pn0d2o3w32b2kkw', )
        $_SESSION['dropbox_access_token'] = json_encode($token);
        $options['dropbox'] = array('oauth_token' => $token["oauth_token"], 'oauth_token_secret' => $token["oauth_token_secret"]);
        $timetrack->setOptions($options);
    }
}
include "views/dropbox.phtml";
ob_implicit_flush(true);
ob_end_flush();
$dropbox = new TTDropbox($consumerKey, $consumerSecret, $options['dropbox']['oauth_token'], $options['dropbox']['oauth_token_secret']);
$dropboxFiles = getDropboxFiles($dropbox);
$filesToUpload = array();
// Dateien, die hochgeladen werden müssen
$newDropboxFiles = array();
// Inhalt der neuen dropbox.ini
foreach ($timetrack->getAllDataFilesWithHash() as $absname => $fileInfo) {
    if (!isset($dropboxFiles[$fileInfo['basename']]) || $dropboxFiles[$fileInfo['basename']] != $fileInfo['hash']) {
        $filesToUpload[] = $absname;
    }