function setDropbox() { error_reporting(E_ALL); $this->enable_implicit_flush(); // -- end of unneeded stuff // if there are many files in your Dropbox it can take some time, so disable the max. execution time set_time_limit(0); $dbx = new DropboxClient(array('app_key' => "fv1z1w4yn5039ys", 'app_secret' => "jyzrgispic9cabg", 'app_full_access' => true), 'en'); $access_token = $this->load_token("access"); if (!empty($access_token)) { $dbx->SetAccessToken($access_token); // echo "loaded access token:"; // print_r($access_token); } elseif (!empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = $this->load_token($_GET['oauth_token']); if (empty($request_token)) { die('Request token not found!'); } // get & store access token, the request token is not needed anymore $access_token = $dbx->GetAccessToken($request_token); $this->store_token($access_token, "access"); $this->delete_token($_GET['oauth_token']); } // checks if access token is required if (!$dbx->IsAuthorized()) { // redirect user to dbx auth page $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1"; $auth_url = $dbx->BuildAuthorizeUrl($return_url); $request_token = $dbx->GetRequestToken(); $this->store_token($request_token, $request_token['t']); die("Authentication required. <a href='{$auth_url}'>Click here.</a>"); } return $dbx; }
/** * @param mixed $dbxObj */ public function setDbxObj($token) { error_reporting(E_ALL); $this->enable_implicit_flush(); // -- end of unneeded stuff // if there are many files in your Dropbox it can take some time, so disable the max. execution time set_time_limit(0); $dbx = new \DropboxClient(array('app_key' => $this->APP_KEY, 'app_secret' => $this->APP_SECRET, 'app_full_access' => $this->APP_FULL_ACCESS), 'en'); // $q = \App\Token::where('user_id',1)->get()[0]->access_token; // $access_token = \GuzzleHttp\json_decode($q,true); if (!empty($token)) { $dbx->SetAccessToken((array) \GuzzleHttp\json_decode($token->access_token)); // echo "loaded access token:"; // print_r($access_token); } elseif (!empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = $this->load_token("request_temp"); if (empty($request_token)) { die('Request token not found!'); } // get & store access token, the request token is not needed anymore $access_token = $dbx->GetAccessToken($request_token); $this->setToken($access_token); // $this->store_token($access_token, "access"); $this->delete_token("request_temp"); } // checks if access token is required if (!$dbx->IsAuthorized()) { // redirect user to dbx auth page // $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1"; $auth_url = $dbx->BuildAuthorizeUrl($this->return_url); $request_token = $dbx->GetRequestToken(); $this->store_token($request_token, "request_temp"); // die(redirect($auth_url)); header("Location: {$auth_url}"); exit; } return $dbx; }
if ($s3->putObjectFile($clonerPath . "/" . $file, $_CONFIG['cron_amazon_bucket'], $_CONFIG['cron_amazon_dirname'] . "/" . baseName($file), "private")) { logxx("AMAZON S3: File copied to {" . $_CONFIG['cron_amazon_bucket'] . "}/" . $_CONFIG['cron_amazon_dirname'] . "/" . $file); } else { logxx("AMAZON S3: Failed to copy file to {" . $_CONFIG['cron_amazon_bucket'] . "}/" . $_CONFIG['cron_amazon_dirname'] . "/" . $file); exit; } } else { logxx("AMAZON S3: Unable to create bucket " . $_CONFIG['cron_amazon_bucket'] . " (it may already exist and/or be owned by someone else)!"); exit; } } ###### END ####### STARING DROPBOX MODE if ($_CONFIG['cron_dropbox_active']) { include_once "classes/DropboxClient.php"; $dropbox = new DropboxClient(array('app_key' => $_CONFIG['cron_dropbox_Key'], 'app_secret' => $_CONFIG['cron_dropbox_Secret'], 'app_full_access' => false), 'en'); logxx(); logxx("DROPBOX: Starting communication with the DropBox server..."); // first try to load existing access token $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); //print_r($access_token); } elseif (!empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) { die('Request token not found!'); } // get & store access token, the request token is not needed anymore $access_token = $dropbox->GetAccessToken($request_token);
function authorize_dropbox() { global $_CONFIG; include_once "classes/DropboxClient.php"; $access_token = load_token("access"); if ($_CONFIG["cron_dropbox_active"]) { $dropbox = new DropboxClient(array('app_key' => $_CONFIG['cron_dropbox_Key'], 'app_secret' => $_CONFIG['cron_dropbox_Secret'], 'app_full_access' => false), 'en'); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); } if ($dropbox->IsAuthorized()) { echo "<center><h2>Dropbox Connection Authorized!</h2></center>"; return; } } else { return; } if ($_CONFIG["cron_dropbox_active"] and !empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) { die('Request token not found!'); } // 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']); echo "<center><h2>Dropbox Connection Authorized!</h2></center>"; return; } if (empty($access_token) and $_CONFIG["cron_dropbox_active"]) { //$dropbox->SetAccessToken($access_token); //print_r($access_token); $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "&auth_callback=1"; $auth_url = $dropbox->BuildAuthorizeUrl($return_url); $request_token = $dropbox->GetRequestToken(); store_token($request_token, $request_token['t']); ?> <script> window.location="<?php echo $auth_url; ?> " </script> <?php exit; } }
<?php // these 2 lines are just to enable error reporting and disable output buffering (don't include this in you application!) error_reporting(E_ALL); enable_implicit_flush(); // -- end of unneeded stuff // if there are many files in your Dropbox it can take some time, so disable the max. execution time set_time_limit(0); require_once "DropboxClient.php"; // you have to create an app at https://www.dropbox.com/developers/apps and enter details below: $dropbox = new DropboxClient(array('app_key' => "fv1z1w4yn5039ys", 'app_secret' => "jyzrgispic9cabg", 'app_full_access' => true), 'en'); // first try to load existing access token $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); echo "loaded access token:"; print_r($access_token); } elseif (!empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) { die('Request token not found!'); } // 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
if ($s3->putObjectFile($clonerPath . "/" . $file, $_CONFIG['cron_amazon_bucket'], $_CONFIG['cron_amazon_dirname'] . "/" . baseName($file), "private")) { logxx("AMAZON S3: File copied to {" . $_CONFIG['cron_amazon_bucket'] . "}/" . $_CONFIG['cron_amazon_dirname'] . "/" . $file); } else { logxx("AMAZON S3: Failed to copy file to {" . $_CONFIG['cron_amazon_bucket'] . "}/" . $_CONFIG['cron_amazon_dirname'] . "/" . $file); exit; } } else { logxx("AMAZON S3: Unable to create bucket " . $_CONFIG['cron_amazon_bucket'] . " (it may already exist and/or be owned by someone else)!"); exit; } } ###### END ####### STARING DROPBOX MODE if ($_CONFIG['cron_dropbox_active']) { include_once "classes/DropboxClient.php"; $dropbox = new DropboxClient(array('app_key' => $_CONFIG['cron_dropbox_Key'], 'app_secret' => $_CONFIG['cron_dropbox_Secret'], 'app_full_access' => false), 'en'); logxx(); logxx("DROPBOX: Starting communication with the DropBox server..."); // first try to load existing access token $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); } else { logxx("Please authorize dropbox app from inside the XCloner Settings panel-> Cron Tab, by clicking the 'Click to authorize application' link."); die; } $return = $dropbox->UploadFile($clonerPath . "/" . $file, $_CONFIG['cron_dropbox_dirname'] . "/" . $file); if ($return->error) { logxx($return->error); } else { logxx("File copied to " . $return->path);
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()); } }
/** * DropPHP sample * * http://fabi.me/en/php-projects/dropphp-dropbox-api-client/ * * @author Fabian Schlieper <*****@*****.**> * @copyright Fabian Schlieper 2012 * @version 1.0 * @license See license.txt * */ error_reporting(E_ALL); require_once "DropboxClient.php"; // you have to create an app at https://www.dropbox.com/developers/apps and enter details below: $dropbox = new DropboxClient(array('app_key' => "6gjbij0b95jqul8", 'app_secret' => "t1g8jps6ch5idso", 'app_full_access' => false), 'en'); // first try to load existing access token $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); print_r($access_token); } elseif (!empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) { die('Request token not found!'); } // 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']);
unlock($lockfile); // reset and continue... } # - - - - - - - - - - - - - # get remaining config $sync_app_key = $sync_config["app_key"]; $sync_app_secret = $sync_config["app_secret"]; $sync_directory = $sync_config["db_directory"]; # - - - - - - - - - - - - - # setup Dropbox $dropbox = new DropboxClient(array( 'app_key' => $sync_app_key, 'app_secret' => $sync_app_secret, 'app_full_access' => false, ),'en'); # - - - - - - - - - - - - - # first try to load existing access token $access_token = load_token("access"); if(!empty($access_token)) { $dropbox->SetAccessToken($access_token); } elseif(!empty($_GET['auth_callback'])) // are we coming from dropbox's auth page? { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if(empty($request_token)) die('Request token not found');
echo "No han pasado 24h desde el anterior Backup!<br/>"; } } if ($timeToDoBackup || !$lastBackupLogExists) { $backupFilesName = "SharedSList_backup_files-" . date("Y.m.d") . '.zip'; $backupsPath = HOME . "/../TEMP/backups/"; $backupFiles = $backupsPath . $backupFilesName; $backupDBName = "SharedSList_backup_DB-" . date("Y.m.d") . '.sql'; $backupDB = $backupsPath . $backupDBName; Zip(HOME, $backupFiles); // comprimimos la carpeta public_html backupDB($backupDB); // hacemos el backup de la BBDD Zip($backupDB, $backupDB . ".zip"); // comprimimos el backup de la BBDD $dropbox = new DropboxClient(array('app_key' => DBOX_KEY, 'app_secret' => DBOX_SECRET, 'app_full_access' => false), 'en'); // intentamos recuperar el token de acceso $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); } elseif (!empty($_GET['auth_callback'])) { // cargamos el token recien creado $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) { die('No se ha podido obtener el request token!'); } // obtenemos y guardamos el token de acceso $access_token = $dropbox->GetAccessToken($request_token); store_token($access_token, "access"); delete_token($_GET['oauth_token']); }
<?php require_once "bootstrap.php"; if (!isset($access_token)) { header("Location: ./authorize.php"); exit; } try { // Start a new Dropbox session $session = new DropboxSession($config["dropbox"]["app_key"], $config["dropbox"]["app_secret"], $config["dropbox"]["access_type"], $access_token); $client = new DropboxClient($session); // Retrieve account info if ($info = $client->accountInfo()) { echo "<p>Account Details for User <strong>" . $info["display_name"] . "</strong> - "; echo '<a href="list.php">View Files</a></p>'; echo "<pre>" . print_r($info, true) . "</pre>"; } } catch (Exception $e) { echo "<strong>ERROR (" . $e->getCode() . ")</strong>: " . $e->getMessage(); if ($e->getCode() == 401) { // Remove auth file unlink($config["app"]["authfile"]); // Re auth echo '<p><a href="authorize.php">Click Here to re-authenticate</a></p>'; } }
<?php require_once "bootstrap.php"; if (!isset($access_token)) { header("Location: authorize.php"); exit; } try { // Start a new Dropbox session // The access token should be defined // The session should verify if the token is valid and throw an exception $session = new DropboxSession($config["dropbox"]["app_key"], $config["dropbox"]["app_secret"], $config["dropbox"]["access_type"], $access_token); $client = new DropboxClient($session); $path = !empty($_GET["path"]) ? $_GET["path"] : "/"; // List contents of home directory if ($home = $client->metadata($path)) { echo "<p>Metadata content for <code>" . $path . "</code></p>"; echo "<pre>" . print_r($home, true) . "</pre>"; } } catch (Exception $e) { echo "<strong>ERROR (" . $e->getCode() . ")</strong>: " . $e->getMessage(); if ($e->getCode() == 401) { // Remove auth file unlink($config["app"]["authfile"]); // Re auth echo '<p><a href="authorize.php">Click Here to re-authenticate</a></p>'; } }
* * @author Fabian Schlieper <*****@*****.**> * @copyright Fabian Schlieper 2012 * @version 1.1 * @license See license.txt * */ // these 2 lines are just to enable error reporting and disable output buffering (don't include this in you application!) error_reporting(E_ALL); enable_implicit_flush(); // -- end of unneeded stuff // if there are many files in your Dropbox it can take some time, so disable the max. execution time set_time_limit(0); require_once "DropboxClient.php"; // you have to create an app at https://www.dropbox.com/developers/apps and enter details below: $dropbox = new DropboxClient(array('app_key' => "fv1z1w4yn5039ys", 'app_secret' => "jyzrgispic9cabg", 'app_full_access' => true), 'en'); // first try to load existing access token $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); echo "loaded access token:"; print_r($access_token); } elseif (!empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) { die('Request token not found!'); } // get & store access token, the request token is not needed anymore $access_token = $dropbox->GetAccessToken($request_token); store_token($access_token, "access");
<?php require_once "bootstrap.php"; if (!isset($access_token)) { header("Location: authorize.php"); exit; } try { // Start a new Dropbox session // The access token should be passed // The session should verify if the token is valid and throw an exception $session = new DropboxSession($config["dropbox"]["app_key"], $config["dropbox"]["app_secret"], $config["dropbox"]["access_type"], $access_token); $client = new DropboxClient($session); $src = $config["app"]["datadir"] . "/test.png"; $dest = "/"; // Upload a file if ($response = $client->putFile($src, $dest)) { echo "<p>File successfully uploaded!</p>"; echo "<pre>" . print_r($response, true) . "</pre>"; } } catch (Exception $e) { echo "<strong>ERROR (" . $e->getCode() . ")</strong>: " . $e->getMessage(); if ($e->getCode() == 401) { // Remove auth file unlink($config["app"]["authfile"]); // Re auth echo '<p><a href="authorize.php">Click Here to re-authenticate</a></p>'; } }
<?php require_once "bootstrap.php"; if (!isset($access_token)) { header("Location: authorize.php"); exit; } try { // Start a new Dropbox session // The access token should exist // The session should verify if the token is valid and throw an exception $session = new DropboxSession($config["dropbox"]["app_key"], $config["dropbox"]["app_secret"], $config["dropbox"]["access_type"], $access_token); $client = new DropboxClient($session); $path = !empty($_GET["path"]) ? $_GET["path"] : "/test.png"; $dest = $config["app"]["datadir"] . "/" . basename($path); // Download a file if ($file = $client->getFile($path, $dest)) { if (!empty($dest)) { unset($file["data"]); echo "<p>File saved to: <code>" . $dest . "</code></p>"; echo "<pre>" . print_r($file, true) . "</pre>"; } else { header("Content-type: " . $file["mime"]); echo $file["data"]; exit; } } } catch (Exception $e) { echo "<strong>ERROR (" . $e->getCode() . ")</strong>: " . $e->getMessage(); if ($e->getCode() == 401) { // Remove auth file
// Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Your file was not uploaded!<br/>"; // if everything is ok, try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { echo "The file " . basename($_FILES["fileToUpload"]["name"]) . " has been uploaded.<br/><br/>"; $uploadOk = 2; } else { echo "Sorry, there was an error uploading your file.<br/>"; } } } set_time_limit(0); require_once "DropboxClient.php"; $dropbox = new DropboxClient(array('app_key' => "app_key", 'app_secret' => "app_secret", 'app_full_access' => false), 'en'); function store_token($token, $name) { if (!file_put_contents("tokens/{$name}.token", serialize($token))) { die('<b>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")); } function delete_token($name) {
* * @author Fabian Schlieper <*****@*****.**> * @copyright Fabian Schlieper 2012 * @version 1.1 * @license See license.txt * */ // these 2 lines are just to enable error reporting and disable output buffering (don't include this in you application!) error_reporting(E_ALL); enable_implicit_flush(); // -- end of unneeded stuff // if there are many files in your Dropbox it can take some time, so disable the max. execution time set_time_limit(0); require_once "DropboxClient.php"; // you have to create an app at https://www.dropbox.com/developers/apps and enter details below: $dropbox = new DropboxClient(array('app_key' => "h9wy5qfiytli7b3", 'app_secret' => "21xqna3r57yqmmk", 'app_full_access' => false), 'en'); // first try to load existing access token $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); echo "loaded access token:"; print_r($access_token); } elseif (!empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) { die('Request token not found!'); } // get & store access token, the request token is not needed anymore $access_token = $dropbox->GetAccessToken($request_token); store_token($access_token, "access");
<!-- URL: http://omega.uta.edu/~pss4720/project8/album.php Name: Prawal Sharma UTA ID: 1001104720 --> <?php // display all errors on the browser error_reporting(E_ALL); ini_set('display_errors', 'On'); // if there are many files in your Dropbox it can take some time, so disable the max. execution time set_time_limit(0); require_once "DropboxClient.php"; // you have to create an app at https://www.dropbox.com/developers/apps and enter details below: $dropbox = new DropboxClient(array('app_key' => "h9wy5qfiytli7b3", 'app_secret' => "21xqna3r57yqmmk", 'app_full_access' => false), 'en'); // first try to load existing access token $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); } elseif (!empty($_GET['auth_callback'])) { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) { die('Request token not found!'); } // 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