Пример #1
0
 private function __construct()
 {
     try {
         // connects to database
         $this->dbConnection = new PDO("mysql:host=" . App::getDbHost() . ";dbname=" . App::getDbName() . ";port=" . App::getDbPort(), App::getDbUsername(), App::getDbPassword());
         $this->dbConnection->setAttribute(PDO::ATTR_ERRMODE, App::getPDOErrorMode());
         // CHANGE THE ERROR MODE, THROW AN EXCEPTION WHEN AN ERROR IS FOUND
         $this->dbConnection->exec("SET NAMES 'utf8'");
     } catch (PDOException $e) {
         // program ends if exception is found
         throw new Exception("Could not connect to the database." . $e->getMessage());
     }
     // end
 }
Пример #2
0
 } else {
     if (isset($_POST['disconnect-dropbox-excel-btn'])) {
         DropboxFetcher::disconnectServiceType(DropboxCon::SERVICE_APP_EXCEL_BACKUP);
         header('Location: ' . BASE_URL . "cloud/success");
         exit;
     } else {
         if (isBtnRqstDnldDBKeyPrsd()) {
             date_default_timezone_set('Europe/Athens');
             $curWorkingDate = new DateTime();
             $curWorkingHour = intval($curWorkingDate->format('H'));
             $filePath = ROOT_PATH . 'storage/backups/';
             $fileName = 'sass_app_db_' . date('m_d_Y_Hi') . '.sql';
             $zippedFileName = $fileName . '.gz';
             $fullPathName = $filePath . $fileName;
             $dumpSettings = array('compress' => Ifsnop\Mysqldump\Mysqldump::GZIP, 'no-data' => false, 'add-drop-table' => true, 'single-transaction' => false, 'lock-tables' => true, 'add-locks' => true, 'extended-insert' => true, 'disable-foreign-keys-check' => true, 'skip-triggers' => false, 'add-drop-trigger' => true, 'databases' => false, 'add-drop-database' => false, 'hex-blob' => true);
             $dump = new Ifsnop\Mysqldump\Mysqldump(App::getDbName(), App::getDbUsername(), App::getDbPassword(), App::getDbHost(), 'mysql', $dumpSettings);
             $dump->start($fullPathName);
             // all credits: http://stackoverflow.com/q/22046020/2790481
             header("Content-Description: File Transfer");
             header("Content-Disposition: attachment; filename=\"" . basename($zippedFileName) . "\";");
             header("Content-Type: application/octet-stream");
             header("Content-Encoding: binary");
             header("Content-Length: " . filesize($filePath . $zippedFileName));
             header("Expires: 0");
             header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
             header("Cache-Control: private");
             header("Pragma: public");
             ob_clean();
             readfile($filePath . $zippedFileName);
         } else {
             if (isBtnRqstDownloadExcelKeyPrsd()) {