Esempio n. 1
0
 public function dropbox()
 {
     //return Input::file('uploadfile');
     //return $uploadfile = Input::file('uploadfile');
     //use \Dropbox as dbx;
     $appInfo = \Dropbox\AppInfo::loadFromJsonFile("app_info.json");
     $webAuth = new \Dropbox\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
     $authorizeUrl = $webAuth->start();
     $accessToken = "LUu8h-uvauAAAAAAAAAAHbDw-bulVL7u8BoRAJtedc0-eCDY-Xj4Qxf1iGucUN7j";
     $dbxClient = new \Dropbox\Client($accessToken, "PHP-Example/1.0");
     $accountInfo = $dbxClient->getAccountInfo();
     //  $dbxClient->getAccessToken();
     //return  $dbxClient->_getMetadata("/participant/Fl0dsItC_Airtel.png");
     $host = $dbxClient->getHost();
     return $this->fetchUrl("/participant/Fl0dsItC_Airtel.png");
     //$appendFilePath =  $dbxClient->appendFilePath();
     //print_r($appendFilePath);
     /*echo "1. Go to: " . $authorizeUrl . "\n";
     echo "2. Click \"Allow\" (you might have to log in first).\n";
     echo "3. Copy the authorization code.\n";
     $authCode = \trim(\readline("Enter the authorization code here: "));
     list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
     print "Access Token: " . $accessToken . "\n";  */
     /*$f = fopen(url()."/public/assets/upload/contest_theme_photo/Fl0dsItC_Airtel.png", "rb");
     $result = $dbxClient->uploadFile("/participant/Fl0dsItC_Airtel.png", \Dropbox\WriteMode::add(), $f);
     fclose($f);*/
     $f = fopen("Fl0dsItC_Airtel.png", "w+b");
     $fileMetadata = $dbxClient->getFile("/participant/Fl0dsItC_Airtel.png", $f);
     //return $dbxClient->getMetadata("/participant/Fl0dsItC_Airtel.png");
     fclose($f);
     //return View::make('dropbox/dropbox');
 }
Esempio n. 2
0
function getWebAuth()
{
    $appInfo = dbx\AppInfo::loadFromJsonFile("app-info.json");
    $clientIdentifier = "my-app/1.0";
    $redirectUri = "http://localhost/csv/authfinish.php";
    $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
    return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore);
}
Esempio n. 3
0
function getWebAuth()
{
    $appInfo = dbx\AppInfo::loadFromJsonFile(__DIR__ . '/../test.json');
    $clientIdentifier = "my-app/1.0";
    $redirectUri = "http://localhost:8888/classes/Auth2.php";
    $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
    return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, 'en');
}
 function tryAppJsonServer($str)
 {
     file_put_contents("test.json", $str);
     $appInfo = dbx\AppInfo::loadFromJsonFile("test.json");
     $this->assertEquals($appInfo->getHost()->getContent(), "api-content-test.droppishbox.com");
     $this->assertEquals($appInfo->getHost()->getApi(), "api-test.droppishbox.com");
     $this->assertEquals($appInfo->getHost()->getWeb(), "meta-test.droppishbox.com");
 }
Esempio n. 5
0
 function getWebAuth()
 {
     $appInfo = dbx\AppInfo::loadFromJsonFile("../lib/Dropbox/app-info.json");
     $clientIdentifier = "my-app/1.0";
     $redirectUri = "http://localhost/link_accounts.php?refer=Dropbox";
     $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
     return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, "en");
 }
Esempio n. 6
0
 function testAppJsonServer()
 {
     $correct = array("key" => "an_app_key", "secret" => "an_app_secret", "access_type" => "AppFolder", "host" => "test.droppishbox.com");
     file_put_contents("test.json", json_encode($correct, true));
     $appInfo = dbx\AppInfo::loadFromJsonFile("test.json");
     $this->assertEquals($appInfo->getHost()->getContent(), "api-content-test.droppishbox.com");
     $this->assertEquals($appInfo->getHost()->getApi(), "api-test.droppishbox.com");
     $this->assertEquals($appInfo->getHost()->getWeb(), "meta-test.droppishbox.com");
 }
Esempio n. 7
0
 public function getWebAuth()
 {
     session_start();
     $appInfo = dbx\AppInfo::loadFromJsonFile("../resources/assets/app-info.json");
     $clientIdentifier = "my-app/1.0";
     $redirectUri = "http://localhost/api/link/dropbox";
     $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
     return new dbx\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, "en");
 }
 public function __construct($appInfoFilePath, &$session)
 {
     try {
         $appInfo = \Dropbox\AppInfo::loadFromJsonFile($appInfoFilePath);
     } catch (\Dropbox\AppInfoLoadException $ex) {
         throw new Exception("Unable to load \"{$appInfoFilePath}\": " . $ex->getMessage());
     }
     $this->appInfo = $appInfo;
     $this->session =& $session;
 }
Esempio n. 9
0
 public function dropboxAuth()
 {
     session_start();
     $appInfo = dbx\AppInfo::loadFromJsonFile(__DIR__ . "\\app-info.json");
     $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
     $webAuth = new dbx\WebAuth($appInfo, "PHP-Example/1.0", 'http://localhost:8080/CloudSync/public/FacebookModel.php', $csrfTokenStore);
     $authorizeUrl = $webAuth->start();
     header('Location: ' . $authorizeUrl);
     exit;
 }
 private function getWebAuth()
 {
     $appInfo = dbx\AppInfo::loadFromJsonFile("dropbox_api.json");
     //$session = Session::all();
     //Session::reflash();
     session_start();
     $csrfTokenStore = new dbx\ArrayEntryStore($_SESSION, "dropbox-auth-csrf-token");
     //echo var_dump($csrfTokenStore);
     //exit;
     return new dbx\WebAuth($appInfo, $this->_appName, "http://localhost/laravelhurrdurr/public/dropboxauth", $csrfTokenStore);
 }
Esempio n. 11
0
function crearCarpeta($folio, $tipo = "PREVIO")
{
    $empresaSes = str_replace(" ", "_", $_SESSION["empresa"]);
    global $cliente_id;
    //cliente de dropbox
    try {
        $appInfo = dbx\AppInfo::loadFromJsonFile("../includes/Dropbox/config.json");
        $accessToken = "jxxJCQnl2ykAAAAAAAAAGRmgdiFo8REFSCcJ-sb19QyT2lPiEEV8g7GiyB2booGP";
        // desde la pagina de app console
        $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
        $root = "/examenes";
        $empresa = "/" . $empresaSes;
        $folder = "/" . $folio;
        //este va a ser el folio del paciente
        $path = $root . $empresa . $folder;
        //creamos el folder
        $createFolder = $dbxClient->createFolder($path);
        //subimos los archivos si se creó el folder
        if ($createFolder) {
            if ($cliente_id == 479) {
                $files_root = "../archivos";
                $files_emp = "/{$empresaSes}";
                $files_type = "/{$tipo}";
                $files_path = $files_root . $files_emp . $files_type;
                foreach (scandir($files_path) as $d) {
                    if ($d == "." || $d == "..") {
                        continue;
                    }
                    $archivos[] = array("filename" => $path . "/" . $d, "file" => file_get_contents("{$files_path}/{$d}"));
                }
            } else {
                switch ($tipo) {
                    case 'PREVIO':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/PREVIO/Radiografias.xlsx")));
                        break;
                    case 'STAFF':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/STAFF/Radiografias.xlsx")));
                        break;
                    case 'OPERARIO':
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Audiometria.xlsx")), array("filename" => $path . "/Fuerza_Equilibrio.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Fuerza_Equilibrio.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/OPERARIO/Radiografias.xlsx")));
                        break;
                    default:
                        $archivos = array(array("filename" => $path . "/Audiometria.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Audiometria.xlsx")), array("filename" => $path . "/Electrocardiograma.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Electrocardiograma.xlsx")), array("filename" => $path . "/Historia_Clinica.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Historia_Clinica.xlsx")), array("filename" => $path . "/Radiografias.xlsx", "file" => file_get_contents("../archivos/{$empresaSes}/Radiografias.xlsx")));
                        break;
                }
            }
            foreach ($archivos as $d) {
                $dbxClient->uploadFileFromString($d["filename"], dbx\WriteMode::add(), $d["file"]);
            }
        }
    } catch (Exception $e) {
    }
}
Esempio n. 12
0
$password = "******";
// database name to backup
$dbName = "cook";
// hostname or IP where database resides
$dbHost = "localhost";
// the zip file will have this prefix
$prefix = "sql_db_cook_";
// Create the database backup file
$sqlFile = $tmpDir . $prefix . date('Y_m_d_h:i:s') . ".sql";
$backupFilename = $prefix . date('Y_m_d_h:i:s') . ".tgz";
$backupFile = $tmpDir . $backupFilename;
echo $createBackup = "mysqldump -h " . $dbHost . " -u " . $user . " --password='******' " . $dbName . " --> " . $sqlFile;
die;
//echo $createBackup;
$createZip = "tar cvzf {$backupFile} {$sqlFile}";
//echo $createZip;
exec($createBackup);
exec($createZip);
//now run the DBox app info and set the client; we are naming the app folder SQL_Backup but CHANGE THAT TO YOUR ACTUAL APP FOLDER NAME;
$appInfo = dbx\AppInfo::loadFromJsonFile(__DIR__ . "/config.json");
$dbxClient = new dbx\Client($accessToken, "SQL_Backup");
//now the main handling of the zipped file upload;
//this message will send in a system e-mail from your cron job (assuming you set up cron to email you);
echo "Uploading {$backupFilename} to Dropbox\n";
//this is the actual Dropbox upload method;
$f = fopen($backupFile, "rb");
$result = $dbxClient->uploadFile('/SQL_Backup/' . $backupFilename, dbx\WriteMode::force(), $f);
fclose($f);
// Delete the temporary files
// unlink($sqlFile);
unlink($backupFile);
Esempio n. 13
0
File: init.php Progetto: russtx/tac
 public static function init()
 {
     require_once pb_backupbuddy::plugin_path() . '/destinations/dropbox2/lib/Dropbox/autoload.php';
     self::$appInfo = dbx\AppInfo::loadFromJsonFile(pb_backupbuddy::plugin_path() . '/destinations/dropbox2/_config.json');
 }
Esempio n. 14
0
{
    $file_handle = fopen($csvFile, 'r');
    while (!feof($file_handle)) {
        $line_of_text[] = fgetcsv($file_handle, 1024);
    }
    fclose($file_handle);
    return $line_of_text;
}
$first_csv_file = "data-a.csv";
$second_csv_file = "data-b.csv";
/* Functions End */
/* include Dropbox Library file */
require_once "Dropbox/autoload.php";
use Dropbox as dbx;
//configuration of dropbox
$appInfo = dbx\AppInfo::loadFromJsonFile("app-info.json");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
//access file from dropbox
$accessToken = "4DK3_Q9x-YAAAAAAAAAAS-tnAaiFa42LXEBW2PIWTO4QpfVfMSVtf1kxAhf_WFU3";
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
//list directory of dropbox
$folderMetadata = $dbxClient->getMetadataWithChildren("/");
// Set path to CSV file
$f = fopen($first_csv_file, "w+b");
$csv1_meta = $dbxClient->getFile("/" . $first_csv_file, $f);
fclose($f);
//Set path to CSV file
$f = fopen($second_csv_file, "w+b");
$csv2_meta = $dbxClient->getFile("/" . $second_csv_file, $f);
fclose($f);
$csv1 = readCSV($first_csv_file);
#!/usr/bin/env php
<?php 
// NOTE: You should be using Composer's global autoloader.  But just so these examples
// work for people who don't have Composer, we'll use the library's "autoload.php".
require_once "includes/initialize.php";
use Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("dropboxconfig.json");
// This is a command-line tool (as opposed to a web app), so we can't supply a redirect URI.
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "examples-authorize", "en");
$authorizeUrl = $webAuth->start();
echo "1. Go to: {$authorizeUrl}\n";
echo "2. Click \"Allow\" (you might have to log in first).\n";
echo "3. Copy the authorization code.\n";
$authCode = \trim(\readline("Enter the authorization code here: "));
list($accessToken, $userId) = $webAuth->finish($authCode);
echo "Authorization complete.\n";
echo "- User ID: {$userId}\n";
echo "- Access Token: {$accessToken}\n";
$authArr = array("access_token" => $accessToken);
if (array_key_exists('host', $appInfoJson)) {
    $authArr['host'] = $appInfoJson['host'];
}
$json_options = 0;
if (defined('JSON_PRETTY_PRINT')) {
    $json_options |= JSON_PRETTY_PRINT;
    // Supported in PHP 5.4+
}
$json = json_encode($authArr, $json_options);
if (file_put_contents($argAuthFileOutput, $json) !== false) {
    echo "Saved authorization information to \"{$argAuthFileOutput}\".\n";
} else {
<?php

use RingCentral\SDK\Http\HttpException;
use RingCentral\http\Response;
use RingCentral\SDK;
use Dropbox as dbx;
// require_once "dropbox-sdk/Dropbox/autoload.php";
// ---------------------- Send SMS --------------------
echo "\n";
echo "------------Download Call Recordings to dropbox ----------------";
echo "\n";
try {
    // Dropbox Authentication
    $appInfo = dbx\AppInfo::loadFromJsonFile("app/config.json");
    $webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
    $authorizeUrl = $webAuth->start();
    echo "1. Go to: " . $authorizeUrl . "\n";
    echo "2. Click \"Allow\" (you might have to log in first).\n";
    echo "3. Copy the authorization code.\n";
    $authCode = \trim(\readline("Enter the authorization code here: "));
    list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
    print "Access Token: " . $accessToken . "\n";
    $dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
    // RC call logs
    $callRecordings = $platform->get('/account/~/extension/~/call-log', array('type' => 'Voice', 'withRecording' => 'True'))->json()->records;
    $timePerRecording = 6;
    foreach ($callRecordings as $i => $callRecording) {
        if (property_exists($callRecording, 'recording')) {
            $id = $callRecording->recording->id;
            print "Downloading Call Log Record {$id}" . PHP_EOL;
            $uri = $callRecording->recording->contentUri;
Esempio n. 17
0
<?php

require_once "dropbox-sdk/Dropbox/autoload.php";
use Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("/app.json");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
echo "1. Go to: " . $authorizeUrl . "\n";
echo "2. Click \"Allow\" (you might have to log in first).\n";
echo "3. Copy the authorization code.\n";
$authCode = \trim(\readline("Enter the authorization code here: "));
Esempio n. 18
0
function getAppConfig()
{
    global $appInfoFile;
    try {
        $appInfo = dbx\AppInfo::loadFromJsonFile($appInfoFile);
    } catch (dbx\AppInfoLoadException $ex) {
        throw new Exception("Unable to load \"{$appInfoFile}\": " . $ex->getMessage());
    }
    $clientIdentifier = "examples-web-file-browser";
    $userLocale = null;
    return array($appInfo, $clientIdentifier, $userLocale);
}
Esempio n. 19
0
// redirect if user elevation is not that of admin
if (!$user->isAdmin()) {
    header('Location: ' . BASE_URL . "error-403");
    exit;
}
include_once ROOT_PATH . '/plugins/mysqldump-php-1.4.1/src/Ifsnop/Mysqldump/Mysqldump.php';
$appInfoFile = ROOT_PATH . "config/dropbox.app";
# Include the Dropbox SDK libraries
require_once ROOT_PATH . "plugins/dropbox-sdk/lib/Dropbox/autoload.php";
use Dropbox as dbx;
try {
    $terms = TermFetcher::retrieveAll();
    $accessTokenDatabase = DropboxFetcher::retrieveAccessToken(DropboxCon::SERVICE_APP_DATABASE_BACKUP)[DropboxFetcher::DB_COLUMN_ACCESS_TOKEN];
    $accessTokenExcel = DropboxFetcher::retrieveAccessToken(DropboxCon::SERVICE_APP_EXCEL_BACKUP)[DropboxFetcher::DB_COLUMN_ACCESS_TOKEN];
    //	var_dump($accessTokenDatabase);
    $appInfo = dbx\AppInfo::loadFromJsonFile($appInfoFile);
    $clientIdentifier = "sass-app/1.0";
    $webAuth = new dbx\WebAuthNoRedirect($appInfo, $clientIdentifier, "en");
    if ($accessTokenDatabase !== NULL) {
        try {
            $dbxClientDB = new dbx\Client($accessTokenDatabase, "PHP-Example/1.0");
            $accountInfoDatabase = $dbxClientDB->getAccountInfo();
        } catch (Exception $e) {
            $errors[] = "Could not access Dropbox account database. Maybe user has revoked access?";
        }
    }
    if ($accessTokenExcel !== NULL) {
        try {
            $dbxClientExcel = new dbx\Client($accessTokenExcel, "PHP-Example/1.0");
            $accountInfoExcel = $dbxClientExcel->getAccountInfo();
        } catch (Exception $e) {
Esempio n. 20
0
<?php

# Include the Dropbox SDK libraries
require_once "vendor/dropbox-sdk/Dropbox/autoload.php";
use Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("INSERT_PATH_TO_JSON_CONFIG_PATH");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
$authorizeUrl = $webAuth->start();
echo "1. Go to: " . $authorizeUrl . "\n";
echo "2. Click \"Allow\" (you might have to log in first).\n";
echo "3. Copy the authorization code.\n";
$authCode = \trim(\readline("Enter the authorization code here: "));
list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
print "Access Token: " . $accessToken . "\n";
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
$accountInfo = $dbxClient->getAccountInfo();
print_r($accountInfo);
$f = fopen("working-draft.txt", "rb");
$result = $dbxClient->uploadFile("/working-draft.txt", dbx\WriteMode::add(), $f);
fclose($f);
print_r($result);
$folderMetadata = $dbxClient->getMetadataWithChildren("/");
print_r($folderMetadata);
$f = fopen("working-draft.txt", "w+b");
$fileMetadata = $dbxClient->getFile("/working-draft.txt", $f);
fclose($f);
print_r($fileMetadata);
Esempio n. 21
0
<?php
require_once "vendor/autoload.php";
use Dropbox;

$appInfo = Dropbox\AppInfo::loadFromJsonFile("config.json");
$webAuth = new Dropbox\WebAuthNoRedirect($appInfo, "ArcherSys/1.0");

$authorizeUrl = $webAuth->start();
echo "1. Go to: " . $authorizeUrl . "\n";
echo "2. Click \"Allow\" (you might have to log in first).\n";
echo "3. Copy the authorization code.\n";
$authCode = \trim(\readline("Enter the authorization code here: "));
?>
Esempio n. 22
0
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Carpetas</title>
</head>

<body onload="window.close();">
<?php 
require_once "includes/Dropbox/autoload.php";
require_once "includes/PHPExcel.php";
require_once "includes/PHPExcel/Writer/Excel2007.php";
include_once "includes/funciones.php";
include_once "includes/config.php";
include_once "includes/class.forms.php";
use Dropbox as dbx;
//$accessToken="jxxJCQnl2ykAAAAAAAAAGIx7c4-bnQHeMPVPnUDEaZN72RRVVnXBHxGwO3xWfXhG"; // desde el navegador
$appInfo = dbx\AppInfo::loadFromJsonFile("includes/Dropbox/config.json");
$accessToken = "jxxJCQnl2ykAAAAAAAAAGRmgdiFo8REFSCcJ-sb19QyT2lPiEEV8g7GiyB2booGP";
// desde la pagina de app console
//cliente de dropbox
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
function pax($folio, $nombre, $edad, $empresa)
{
    // Create new PHPExcel object
    $objPHPExcel = new PHPExcel();
    // Add some data
    $objPHPExcel->setActiveSheetIndex(0);
    $objPHPExcel->getActiveSheet()->SetCellValue('A1', $folio);
    $objPHPExcel->getActiveSheet()->SetCellValue('A2', $nombre);
    $objPHPExcel->getActiveSheet()->SetCellValue('A3', $edad);
    $objPHPExcel->getActiveSheet()->SetCellValue('A4', $empresa);
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
<?php

require_once "lib/Dropbox/autoload.php";
use Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("composer.json");
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
$authorizeUrl = $webAuth->start();
echo $authorizeUrl;