Ejemplo n.º 1
0
}
// checks if access token is required
if (!$dropbox->IsAuthorized()) {
    // redirect user to dropbox auth page
    $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1";
    $auth_url = $dropbox->BuildAuthorizeUrl($return_url);
    $request_token = $dropbox->GetRequestToken();
    store_token($request_token, $request_token['t']);
    die("Authentication required. <a href='{$auth_url}'>Click here.</a>");
}
echo "<pre>";
echo "<b>Account:</b>\r\n";
print_r($dropbox->GetAccountInfo());
$files = $dropbox->GetFiles("", false);
if (empty($files)) {
    $dropbox->UploadFile("leonidas.jpg");
    $files = $dropbox->GetFiles("", false);
}
echo "\r\n\r\n<b>Files:</b>\r\n";
print_r(array_keys($files));
if (!empty($files)) {
    $file = reset($files);
    $test_file = "test_download_" . basename($file->path);
    echo "<img src='" . $dropbox->GetLink($file, false) . "'/></br>";
    echo "\r\n\r\n<b>Meta data of <a href='" . $dropbox->GetLink($file) . "'>{$file->path}</a>:</b>\r\n";
    print_r($dropbox->GetMetadata($file->path));
    echo "{$test_file}</br>";
    echo "\r\n\r\n<b>Downloading {$file->path}:</b>\r\n";
    print_r($dropbox->DownloadFile($file, $test_file));
    echo "\r\n\r\n<b>Uploading {$test_file}:</b>\r\n";
    print_r($dropbox->UploadFile($test_file));
Ejemplo n.º 2
0
    // get & store access token, the request token is not needed anymore
    $access_token = $dropbox->GetAccessToken($request_token);
    store_token($access_token, "access");
    delete_token($_GET['oauth_token']);
}
// checks if access token is required
if (!$dropbox->IsAuthorized()) {
    // redirect user to dropbox auth page
    $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1";
    $auth_url = $dropbox->BuildAuthorizeUrl($return_url);
    $request_token = $dropbox->GetRequestToken();
    store_token($request_token, $request_token['t']);
    die("Authentication required. <a href='{$auth_url}'>Click here.</a>");
}
if ($uploadOk == 2) {
    $dropbox->UploadFile($target_file);
}
$files = $dropbox->GetFiles("", true);
?>
<html>
	<head>
		<title>Dropbox Images</title>
		<style type="text/css">
			.submitLink {
				background-color: transparent;
				text-decoration: underline;
				border: none;
				color: blue;
				cursor: pointer;
			}
			table, td, th{
Ejemplo n.º 3
0
}
echo "<pre>";
echo "<b>Account:</b>\r\n";
print_r($dropbox->GetAccountInfo());
$files = $dropbox->GetFiles("", false);
echo "\r\n\r\n<b>Files:</b>\r\n";
print_r(array_keys($files));
if (!empty($files)) {
    $file = reset($files);
    $test_file = "test_download_" . basename($file->path);
    echo "\r\n\r\n<b>Meta data of {$file->path}:</b>\r\n";
    print_r($dropbox->GetMetadata($file->path));
    echo "\r\n\r\n<b>Downloading {$file->path}:</b>\r\n";
    print_r($dropbox->DownloadFile($file, $test_file));
    echo "\r\n\r\n<b>Uploading {$test_file}:</b>\r\n";
    print_r($dropbox->UploadFile($test_file));
}
function store_token($token, $name)
{
    file_put_contents("tokens/{$name}.token", serialize($token));
}
function load_token($name)
{
    if (!file_exists("tokens/{$name}.token")) {
        return null;
    }
    return @unserialize(@file_get_contents("tokens/{$name}.token"));
}
function delete_token($name)
{
    @unlink("tokens/{$name}.token");
Ejemplo n.º 4
0
        }
        // get & store access token, the request token is not needed anymore
        $access_token = $dropbox->GetAccessToken($request_token);
        store_token($access_token, "access");
        delete_token($_GET['oauth_token']);
    }
    // checks if access token is required
    if (!$dropbox->IsAuthorized()) {
        // redirect user to dropbox auth page
        $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1";
        $auth_url = $dropbox->BuildAuthorizeUrl($return_url);
        $request_token = $dropbox->GetRequestToken();
        store_token($request_token, $request_token['t']);
        die("Authentication required. <a href='{$auth_url}'>Click here.</a>");
    }
    $return = $dropbox->UploadFile($clonerPath . "/" . $file, $_CONFIG['cron_dropbox_dirname'] . "/" . $file);
    if ($return->error) {
        logxx($return->error);
    } else {
        logxx("File copied to " . $return->path);
    }
    #print_r($return);
}
###### END
######## DELETING OLDER BACKUPS ##############################################
if ($_CONFIG['cron_file_delete_act']) {
    logxx("<br />\nDeleting older backups than " . $_CONFIG['cron_file_delete'] . " days: ");
    delete_older_backups($clonerPath);
}
###################END OLDER BACKUPS
$logemail = explode(";", $_CONFIG['cron_logemail']);
Ejemplo n.º 5
0
        // obtenemos y guardamos el token de acceso
        $access_token = $dropbox->GetAccessToken($request_token);
        store_token($access_token, "access");
        delete_token($_GET['oauth_token']);
    }
    // comprobamos si es necesario el token de acceso
    if (!$dropbox->IsAuthorized()) {
        // redireccionamos a la web de autenticación
        $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1";
        $auth_url = $dropbox->BuildAuthorizeUrl($return_url);
        $request_token = $dropbox->GetRequestToken();
        store_token($request_token, $request_token['t']);
        die("Autenticación necesaria. <a href='{$auth_url}'>Pulsa aquí.</a>");
    }
    echo "<b>Guardando {$backupFilesName}</b><br/>";
    $dropbox->UploadFile($backupFiles);
    echo "<b>Guardando {$backupDBName}.zip</b>";
    $dropbox->UploadFile($backupDB . ".zip");
    unlink($backupFiles);
    unlink($backupDB);
    unlink($backupDB . ".zip");
    // escribimos la fecha del backup en un fichero
    file_put_contents(HOME . "/../TEMP/LastBackup.txt", date("Y-m-d H:i:s", time()));
}
/**
 * La función store_token guarda el token
 *
 * @param array $token
 *        	el token que se quiere guardar
 * @param string $name
 *        	la ruta destino del token
Ejemplo n.º 6
0
    // get & store access token, the request token is not needed anymore
    $access_token = $dropbox->GetAccessToken($request_token);
    store_token($access_token, "access");
    delete_token($_GET['oauth_token']);
}
// checks if access token is required
if (!$dropbox->IsAuthorized()) {
    // redirect user to dropbox auth page
    $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1";
    $auth_url = $dropbox->BuildAuthorizeUrl($return_url);
    $request_token = $dropbox->GetRequestToken();
    store_token($request_token, $request_token['t']);
    die("Authentication required. <a href='{$auth_url}'>Click here.</a>");
}
// CODE#
$result = $dropbox->UploadFile($_FILES['upfile']['tmp_name'], $_FILES['upfile']['name']);
print_r($result);
echo "<br><br>Done!";
function store_token($token, $name)
{
    if (!file_put_contents("tokens/{$name}.token", serialize($token))) {
        die('<br />Could not store token! <b>Make sure that the directory `tokens` exists and is writable!</b>');
    }
}
function load_token($name)
{
    if (!file_exists("tokens/{$name}.token")) {
        return null;
    }
    return @unserialize(@file_get_contents("tokens/{$name}.token"));
}
Ejemplo n.º 7
0
 public function indexAction()
 {
     // delete coupon expire
     // $coupon = Utility::deleteExpireCoupon();
     $appKey = 'rqvezrg3abysf3x';
     $appSecret = 'uoye0pmyap6fuoy';
     $service_locator_str = 'doctrine.connection.orm_default';
     $sm = $this->getServiceLocator();
     $service = $sm->get($service_locator_str);
     $params = $service->getParams();
     $host = $params['host'];
     $user = $params['user'];
     $pass = $params['password'];
     $name = $params['dbname'];
     $tables = "*";
     $return = '';
     $link = mysql_connect($host, $user, $pass);
     if ($link) {
         mysql_select_db($name, $link);
         //get all of the tables
         if ($tables == '*') {
             $tables = array();
             $result = mysql_query('SHOW TABLES');
             while ($row = mysql_fetch_row($result)) {
                 $tables[] = $row[0];
             }
         } else {
             $tables = is_array($tables) ? $tables : explode(',', $tables);
         }
         //cycle through
         foreach ($tables as $table) {
             $result = mysql_query('SELECT * FROM ' . $table);
             $num_fields = mysql_num_fields($result);
             $return .= 'DROP TABLE ' . $table . ';';
             $row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE ' . $table));
             $return .= "\n\n" . $row2[1] . ";\n\n";
             for ($i = 0; $i < $num_fields; $i++) {
                 while ($row = mysql_fetch_row($result)) {
                     $return .= 'INSERT INTO ' . $table . ' VALUES(';
                     for ($j = 0; $j < $num_fields; $j++) {
                         $row[$j] = addslashes($row[$j]);
                         $row[$j] = ereg_replace("\n", "\\n", $row[$j]);
                         if (isset($row[$j])) {
                             $return .= '"' . $row[$j] . '"';
                         } else {
                             $return .= '""';
                         }
                         if ($j < $num_fields - 1) {
                             $return .= ',';
                         }
                     }
                     $return .= ");\n";
                 }
             }
             $return .= "\n\n\n";
         }
         $files = glob('public\\backup\\*');
         // get all file names
         foreach ($files as $file) {
             // iterate files
             if (is_file($file)) {
                 unlink($file);
             }
             // delete file
         }
         $directoryBk = 'public/backup/';
         $backupName = 'backup-' . time() . '-' . date("d", time()) . '-' . date('m', time()) . '-' . date('Y', time()) . '.sql';
         //save file
         $handle = fopen($directoryBk . $backupName, "w+");
         // write file
         fwrite($handle, $return);
         // close file
         fclose($handle);
         DropboxUtility::enable_implicit_flush();
         $dropbox = new \DropboxClient(array('app_key' => $appKey, 'app_secret' => $appSecret, 'app_full_access' => false), 'en');
         $accessToken = "AD4_9TIkfjoAAAAAAAA0jFsQImeJnIyvWDrjBa_ND7vP5YjuZFNMbS7jMdvwhCem";
         $accessToken = DropboxUtility::load_token('access');
         if (!empty($accessToken)) {
             $dropbox->SetAccessToken($accessToken);
         } elseif (!empty($_GET['auth_callback'])) {
             $requestToken = DropboxUtility::load_token($_GET['oauth_token']);
             if (empty($requestToken)) {
                 die('Request token not found!');
             }
             // get & store access token, the request token is not needed anymore
             $accessToken = $dropbox->GetAccessToken($requestToken);
             DropboxUtility::store_token($accessToken, "access");
             DropboxUtility::delete_token($_GET['oauth_token']);
         }
         if (!$dropbox->IsAuthorized()) {
             // redirect user to dropbox auth page
             $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1";
             $auth_url = $dropbox->BuildAuthorizeUrl($return_url);
             $request_token = $dropbox->GetRequestToken();
             DropboxUtility::store_token($request_token, $request_token['t']);
             die("Authentication required. <a href='{$auth_url}'>Click here.</a>");
         } else {
             $fileUpload = $dropbox->UploadFile($directoryBk . $backupName);
             print_r($fileUpload);
         }
         // send mail
         $sendMail = MailUtility::sendMailAttachment($directoryBk . $backupName, $backupName, 'Kaffa DB', '*****@*****.**', true);
         die('Backup success!');
     } else {
         die(mysql_error());
     }
 }
Ejemplo n.º 8
0
{
    @apache_setenv('no-gzip', 1);
    @ini_set('zlib.output_compression', 0);
    @ini_set('implicit_flush', 1);
    for ($i = 0; $i < ob_get_level(); $i++) {
        ob_end_flush();
    }
    ob_implicit_flush(1);
    echo "<!-- " . str_repeat(' ', 2000) . " -->";
}
?>

<?php 
if (isset($_FILES["userfile"])) {
    $file = $_FILES['userfile']['name'];
    $dropbox->UploadFile($_FILES['userfile']['tmp_name'], $file);
}
if (isset($_GET["delete"])) {
    $del_image = $_GET["delete"];
    //echo $dropbox->GetLink($del_image,false);
    $dropbox->delete($del_image);
    header("Location: album.php");
}
?>
<html>
	<head>
		<title>Photo Album</title>
	</head>
	<body style="margin: auto; width: 1000px;">
		<div id="header" style="width:1000px; background-color: LightGrey; height: 100px;">
			<div style="padding-top: 30px; margin: auto; text-align: center;">