Example #1
0
 /**
  * refreshEnd
  *
  * @return void
  */
 protected function refreshEnd()
 {
     func_refresh_end();
 }
Example #2
0
 /**
  * Common restore database method used by actions
  *
  * @param mixed $sqlFile File with SQL data for loading into database
  *
  * @return boolean
  */
 protected function restoreDatabase($sqlFile)
 {
     $result = false;
     // File to create temporary backup to be able rollback database
     $backupSQLFile = LC_DIR_BACKUP . sprintf('sqldump.backup.%d.sql', \XLite\Core\Converter::time());
     // Make the process of restoring database verbose
     $verbose = true;
     // Start
     $this->startDump();
     // Making the temporary backup file
     \Includes\Utils\Operator::flush(static::t('Making backup of the current database state ... '), true);
     $result = \XLite\Core\Database::getInstance()->exportSQLToFile($backupSQLFile, $verbose);
     \Includes\Utils\Operator::flush(static::t('done') . LC_EOL . LC_EOL, true);
     // Loading specified SQL-file to the database
     \Includes\Utils\Operator::flush(static::t('Loading the database from file .'));
     $result = \Includes\Utils\Database::uploadSQLFromFile($sqlFile, $verbose);
     $restore = false;
     if ($result) {
         // If file has been loaded into database successfully
         $message = static::t('Database restored successfully!');
         // Prepare the cache rebuilding
         \XLite::setCleanUpCacheFlag(true);
     } else {
         // If an error occured while loading file into database
         $message = static::t('The database has not been restored because of the errors');
         $restore = true;
     }
     // Display the result message
     \Includes\Utils\Operator::flush(' ' . static::t('done') . LC_EOL . LC_EOL . $message . LC_EOL);
     if ($restore) {
         // Restore database from temporary backup
         \Includes\Utils\Operator::flush(LC_EOL . static::t('Restoring database from the backup .'));
         \Includes\Utils\Database::uploadSQLFromFile($backupSQLFile, $verbose);
         \Includes\Utils\Operator::flush(' ' . static::t('done') . LC_EOL . LC_EOL);
     }
     // Display Javascript to cancel scrolling page to bottom
     func_refresh_end();
     // Display the bottom HTML part
     $this->displayPageFooter();
     // Remove temporary backup file
     unlink($backupSQLFile);
     return $result;
 }