Ejemplo n.º 1
0
		<?php 
if (App::isMobile()) {
    ?>
		<link rel="stylesheet" type="text/css" href="<?php 
    echo APP_SITE;
    ?>
static/css/mobile.css?v=<?php 
    echo App::getVersion();
    ?>
" />
		<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
		<?php 
}
?>
		<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js?v=<?php 
echo App::getVersion();
?>
"></script>
		<script type="text/javascript" src="<?php 
echo APP_SITE;
?>
static/js/main.js"></script>
	</head>
	<body>
		
		<div id="app_header">			
			<div class="app_holder">
				<div id="app_header_inner">
					<a href="<?php 
echo App::link('');
?>
# Include the Dropbox SDK libraries
require_once ROOT_PATH . "plugins/dropbox-sdk/lib/Dropbox/autoload.php";
include_once ROOT_PATH . 'plugins/mysqldump-php-1.4.1/src/Ifsnop/Mysqldump/Mysqldump.php';
use Dropbox as dbx;
try {
    date_default_timezone_set('Europe/Athens');
    // run script only during working hours
    if (!App::isWorkingDateTimeOn()) {
        exit;
    }
    $filePath = ROOT_PATH . 'storage/excel/';
    $curTerms = TermFetcher::retrieveCurrTerm();
    foreach ($curTerms as $curTerm) {
        $curTermId = $curTerm[TermFetcher::DB_COLUMN_ID];
        $curTermName = $curTerm[TermFetcher::DB_COLUMN_NAME];
        $curTermStartDateTime = new DateTime($curTerm[TermFetcher::DB_COLUMN_START_DATE]);
        $curTermYear = $curTermStartDateTime->format('Y');
        $fullPathFile = Excel::saveAppointments($curTermId);
        $fileName = pathinfo($fullPathFile)['filename'] . "." . pathinfo($fullPathFile)['extension'];
        $accessToken = DropboxFetcher::retrieveAccessToken(DropboxCon::SERVICE_APP_EXCEL_BACKUP)[DropboxFetcher::DB_COLUMN_ACCESS_TOKEN];
        $dbxClient = new dbx\Client($accessToken, App::getVersion());
        $adminAccountInfo = $dbxClient->getAccountInfo();
        $f = fopen($fullPathFile, "rb");
        $result = $dbxClient->uploadFile("/storage/excel/{$curTermYear}/{$fileName}", dbx\WriteMode::force(), $f);
        fclose($f);
    }
    exit;
} catch (\Exception $e) {
    App::storeError($e);
    exit;
}