示例#1
0
     } else {
         echo '?';
     }
     echo 'sub_dir=' . $parent_dir . "'>../</a><br><br>";
 }
 foreach ($directories as $directory) {
     echo "DIR - <a href='";
     the_permalink();
     if (strstr(get_permalink(), '?')) {
         echo '&';
     } else {
         echo '?';
     }
     echo 'sub_dir=' . $sub_dir . "/" . $directory . "'>" . $directory . "</a><br>";
 }
 $files = $db_connection->getfiles($dbdir . "/" . $sub_dir);
 foreach ($files as $file) {
     echo "<a href='";
     the_permalink();
     if (strstr(get_permalink(), '?')) {
         echo '&';
     } else {
         echo '?';
     }
     echo 'get=' . $sub_dir . "/" . $file[0] . "&w=" . $file[1] . "'>" . $file[0] . "</a>";
     if ($shdt != 1) {
         echo " (" . $file[3] . ")";
     }
     if ($shsz != 1) {
         echo " - " . $file[2];
     }
示例#2
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>';
    }
}