示例#1
0
function get_dropbox_dir()
{
    require_code('developer_tools');
    destrictify();
    //get/set login details
    $hash = get_param('hash');
    $dbemail = get_value('db_username_' . $hash);
    $dbpassword = get_value('db_password_' . $hash);
    $sub_dir = get_value('db_sub_dir_' . $hash);
    $sub_dir_new = get_param('sub_dir', '');
    $sub_dir = isset($sub_dir_new) && strlen($sub_dir_new) > 0 ? $sub_dir_new : $sub_dir;
    $dbdir = '';
    set_value('db_username_' . $hash, $dbemail);
    set_value('db_password_' . $hash, $dbpassword);
    set_value('db_sub_dir_' . $hash, $sub_dir);
    //include DropboxConnection class
    if (file_exists(get_file_base() . '/sources_custom/DropboxConnection.php')) {
        require get_file_base() . '/sources_custom/DropboxConnection.php';
    }
    //remove "/" at the end of $sub_dir if any
    while (preg_match('/\\/$/', $sub_dir)) {
        $sub_dir = substr($sub_dir, 0, mb_strlen($sub_dir) - 1);
    }
    echo "You are here: " . $sub_dir . "<hr>";
    try {
        $db_connection = new DropboxConnection($dbemail, $dbpassword);
        $directories = $db_connection->getdirs($dbdir . "/" . $sub_dir);
        if (isset($sub_dir)) {
            $parent_dir_array = explode("/", $sub_dir);
            $parent_dir = '';
            for ($x = 0; $x < count($parent_dir_array) - 1; $x++) {
                $parent_dir .= $parent_dir_array[$x] . "/";
            }
            echo "<a href='" . find_script('dropbox_list') . "?sub_dir=" . $parent_dir . "&hash=" . $hash . "'>../</a><br>";
        }
        foreach ($directories as $directory) {
            echo "DIR - <a href='" . find_script('dropbox_list') . "?hash=" . $hash . "&sub_dir=" . $sub_dir . "/" . $directory . "'>" . $directory . "</a><br>";
        }
        $files = $db_connection->getfiles($dbdir . "/" . $sub_dir);
        foreach ($files as $file) {
            echo "<a href='" . find_script('dropbox_get') . "?hash=" . $hash . "&get=" . $sub_dir . "/" . $file[0] . "&w=" . $file[1] . "'>" . $file[0] . "</a><br>";
        }
    } catch (Exception $e) {
        echo '<span style="color: red">Error: ' . htmlspecialchars($e->getMessage()) . '</span>';
    }
}
示例#2
0
文件: tdp_get.php 项目: pw/wp-dropbox
function tdp_save()
{
    require 'tdp_config.php';
    require 'tdp_DropboxConnection.php';
    $file_to_get = trim($_GET['get']);
    if (preg_match('(^[a-z0-9]+$)', $_GET['w'])) {
        $w = $_GET['w'];
    } else {
        echo "impossible w-string";
        die;
    }
    $db_connection = new DropboxConnection($dbemail, $dbpassword);
    try {
        $data = $db_connection->getfile($dbdir . "/" . $file_to_get, $w);
        $filename = explode("/", $file_to_get);
        $filename = $filename[count($filename) - 1];
        header($data['content_type']);
        header("Content-Disposition: attachment; filename=" . $filename);
        echo $data['data'];
    } catch (Exception $e) {
        echo '<span style="color: red">Error: ' . htmlspecialchars($e->getMessage()) . '</span>';
    }
}
示例#3
0
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    
    This Software is based on Dropbox Uploader version 1.1.3 written by Jaka Jancar
    [jaka@kubje.org] [http://jaka.kubje.org/] and Dropbox Connection v0.4 www.individual-it.net/Software.html
*/
require 'tdp_DropboxConnection.php';
$shdt = get_option('tdp_date');
$shsz = get_option('tdp_size');
$sub_dir = trim($_GET['sub_dir']);
//remove "/" at the end of $sub_dir if any
while (preg_match('/\\/$/', $sub_dir)) {
    $sub_dir = substr($sub_dir, 0, mb_strlen($sub_dir) - 1);
}
echo "Viewing: " . $sub_dir;
try {
    $db_connection = new DropboxConnection($dbemail, $dbpassword);
    $directories = $db_connection->getdirs($dbdir . "/" . $sub_dir);
    if (isset($sub_dir)) {
        $parent_dir_array = explode("/", $sub_dir);
        for ($x = 0; $x < count($parent_dir_array) - 1; $x++) {
            $parent_dir .= $parent_dir_array[$x] . "/";
        }
        echo "<a href='";
        the_permalink();
        if (strstr(get_permalink(), '?')) {
            echo '&';
        } else {
            echo '?';
        }
        echo 'sub_dir=' . $parent_dir . "'>../</a><br><br>";
    }