Exemplo n.º 1
0
 public static function get()
 {
     if (self::$instance == null) {
         self::$instance = new MainWPBackup();
     }
     return self::$instance;
 }
Exemplo n.º 2
0
 protected function backupDB($fileName = '', $ext = 'zip')
 {
     $dirs = MainWPHelper::getMainWPDir('backup');
     $dir = $dirs[0];
     $timestamp = time();
     if ($fileName != '') {
         $fileName .= '-';
     }
     $filepath = $dir . 'dbBackup-' . $fileName . $timestamp . '.sql';
     if ($dh = opendir($dir)) {
         while (($file = readdir($dh)) !== false) {
             if ($file != '.' && $file != '..' && preg_match('/dbBackup-(.*).sql(\\.zip|\\.tar|\\.tar\\.gz|\\.tar\\.bz2)?$/', $file)) {
                 @unlink($dir . $file);
             }
         }
         closedir($dh);
     }
     if (file_exists($filepath)) {
         @unlink($filepath);
     }
     $result = MainWPBackup::get()->createBackupDB($filepath, $ext);
     MainWPHelper::update_option('mainwp_child_last_db_backup_size', filesize($result['filepath']));
     return $result === false ? false : array('timestamp' => $timestamp, 'file' => basename($result['filepath']), 'filesize' => filesize($result['filepath']));
 }