Example #1
0
 function run()
 {
     $prefixCounts = strlen(DB_PREFIX);
     $dbTables = array();
     $tableNames = Database::get()->nativeQuery('SHOW TABLE STATUS FROM ' . DB_NAME . ';');
     foreach ($tableNames as $table) {
         if (DB_PREFIX == substr($table['Name'], 0, $prefixCounts)) {
             $dbTables[] = $table['Name'];
         }
     }
     if (empty($dbTables)) {
         throw new Exception('No tables found for dump.');
     }
     $fileName = '2MoonsBackup_' . date('d_m_Y_H_i_s', TIMESTAMP) . '.sql';
     $filePath = 'includes/backups/' . $fileName;
     require 'includes/classes/SQLDumper.class.php';
     $dump = new SQLDumper();
     $dump->dumpTablesToFile($dbTables, $filePath);
 }
Example #2
0
 function run()
 {
     $prefixCounts = strlen(DB_PREFIX);
     $dbTables = array();
     $sqlTableRaw = $GLOBALS['DATABASE']->query("SHOW TABLE STATUS FROM `" . DB_NAME . "`;");
     while ($table = $GLOBALS['DATABASE']->fetchArray($sqlTableRaw)) {
         if (DB_PREFIX == substr($table['Name'], 0, $prefixCounts)) {
             $dbTables[] = $table['Name'];
         }
     }
     if (empty($dbTables)) {
         throw new Exception('No tables found for dump.');
     }
     $fileName = '2MoonsBackup_' . date('d_m_Y_H_i_s', TIMESTAMP) . '.sql';
     $filePath = 'includes/backups/' . $fileName;
     require 'includes/classes/SQLDumper.class.php';
     $dump = new SQLDumper();
     $dump->dumpTablesToFile($dbTables, $filePath);
 }
Example #3
0
function ShowDumpPage()
{
    global $LNG;
    switch ($_REQUEST['action']) {
        case 'dump':
            $dbTables = HTTP::_GP('dbtables', array());
            if (empty($dbTables)) {
                $template = new template();
                $template->message($LNG['du_not_tables_selected']);
                exit;
            }
            $fileName = '2MoonsBackup_' . date('d_m_Y_H_i_s', TIMESTAMP) . '.sql';
            $filePath = 'includes/backups/' . $fileName;
            require 'includes/classes/SQLDumper.class.php';
            $dump = new SQLDumper();
            $dump->dumpTablesToFile($dbTables, $filePath);
            $template = new template();
            $template->message(sprintf($LNG['du_success'], 'includes/backups/' . $fileName));
            break;
        default:
            $dumpData['perRequest'] = 100;
            $dumpData = array();
            $prefixCounts = strlen(DB_PREFIX);
            $dumpData['sqlTables'] = array();
            $sqlTableRaw = $GLOBALS['DATABASE']->query("SHOW TABLE STATUS FROM `" . DB_NAME . "`;");
            while ($table = $GLOBALS['DATABASE']->fetchArray($sqlTableRaw)) {
                if (DB_PREFIX == substr($table['Name'], 0, $prefixCounts)) {
                    $dumpData['sqlTables'][] = $table['Name'];
                }
            }
            $template = new template();
            $template->assign_vars(array('dumpData' => $dumpData));
            $template->show('DumpPage.tpl');
            break;
    }
}
Example #4
0
 // Create a Backup
 $prefixCounts = strlen(DB_PREFIX);
 $dbTables = array();
 $sqlTableRaw = Database::get()->nativeQuery("SHOW TABLE STATUS FROM `" . DB_NAME . "`;");
 foreach ($sqlTableRaw as $table) {
     if (DB_PREFIX == substr($table['Name'], 0, $prefixCounts)) {
         $dbTables[] = $table['Name'];
     }
 }
 if (empty($dbTables)) {
     throw new Exception('No tables found for dump.');
 }
 $fileName = '2MoonsBackup_' . date('d_m_Y_H_i_s', TIMESTAMP) . '.sql';
 $filePath = 'includes/backups/' . $fileName;
 require 'includes/classes/SQLDumper.class.php';
 $dump = new SQLDumper();
 $dump->dumpTablesToFile($dbTables, $filePath);
 @set_time_limit(600);
 $httpRoot = PROTOCOL . HTTP_HOST . str_replace(array('\\', '//'), '/', dirname(dirname($_SERVER['SCRIPT_NAME'])) . '/');
 $revision = $startRevision - 1;
 $fileList = array();
 $directoryIterator = new DirectoryIterator(ROOT_PATH . 'install/updates/');
 /** @var $fileInfo DirectoryIterator */
 foreach ($directoryIterator as $fileInfo) {
     if (!$fileInfo->isFile()) {
         continue;
     }
     $fileRevision = substr($fileInfo->getFilename(), 7, -4);
     if ($fileRevision > $revision) {
         $fileExtension = pathinfo($filePath, PATHINFO_EXTENSION);
         $key = $fileRevision . ((int) $fileExtension === 'php');