Пример #1
0
 public function __construct()
 {
     global $updraftplus_backup;
     $this->binzip = $updraftplus_backup->binzip;
     if (!is_string($this->binzip)) {
         $this->last_error = "No binary zip was found";
         return false;
     }
     return parent::__construct();
 }
Пример #2
0
 public function checkzip_wpcore($zipfile, &$mess, &$warn, &$err)
 {
     if (!empty($this->wpcore_foundyet) && 3 == $this->wpcore_foundyet) {
         return;
     }
     if (!is_readable($zipfile)) {
         $warn[] = sprintf(__('Unable to read zip file (%s) - could not pre-scan it to check its integrity.', 'updraftplus'), basename($zipfile));
         return;
     }
     if ('.zip' == strtolower(substr($zipfile, -4, 4))) {
         if (!class_exists('UpdraftPlus_PclZip')) {
             require UPDRAFTPLUS_DIR . '/class-zip.php';
         }
         $zip = new UpdraftPlus_PclZip();
         if (!$zip->open($zipfile)) {
             $warn[] = sprintf(__('Unable to open zip file (%s) - could not pre-scan it to check its integrity.', 'updraftplus'), basename($zipfile));
             return;
         }
         # Don't put this in the for loop, or the magic __get() method gets called and opens the zip file every time the loop goes round
         $numfiles = $zip->numFiles;
         for ($i = 0; $i < $numfiles; $i++) {
             $si = $zip->statIndex($i);
             if ($si['name'] == 'wp-admin/index.php') {
                 $this->wpcore_foundyet = $this->wpcore_foundyet | 1;
                 if (3 == $this->wpcore_foundyet) {
                     return;
                 }
             }
             if ($si['name'] == 'xmlrpc.php' || $si['name'] == 'xmlrpc.php/xmlrpc.php') {
                 $this->wpcore_foundyet = $this->wpcore_foundyet | 2;
                 if (3 == $this->wpcore_foundyet) {
                     return;
                 }
             }
         }
         @$zip->close();
     } elseif (preg_match('/\\.tar(\\.(gz|bz2))$/i', $zipfile)) {
         if (!class_exists('UpdraftPlus_Archive_Tar')) {
             if (false === strpos(get_include_path(), UPDRAFTPLUS_DIR . '/includes/PEAR')) {
                 set_include_path(UPDRAFTPLUS_DIR . '/includes/PEAR' . PATH_SEPARATOR . get_include_path());
             }
             require_once UPDRAFTPLUS_DIR . '/includes/PEAR/Archive/Tar.php';
         }
         $p_compress = null;
         if ('.tar.gz' == strtolower(substr($zipfile, -7, 7))) {
             $p_compress = 'gz';
         } elseif ('.tar.bz2' == strtolower(substr($zipfile, -8, 8))) {
             $p_compress = 'bz2';
         }
         $tar = new UpdraftPlus_Archive_Tar($zipfile, $p_compress);
         $list = $tar->listContent();
         foreach ($list as $file) {
             if (is_array($file) && isset($file['filename'])) {
                 if ('wp-admin/index.php' == $file['filename']) {
                     $this->wpcore_foundyet = $this->wpcore_foundyet | 1;
                     if (3 == $this->wpcore_foundyet) {
                         return;
                     }
                 } elseif ('xmlrpc.php' == $file['filename']) {
                     $this->wpcore_foundyet = $this->wpcore_foundyet | 2;
                     if (3 == $this->wpcore_foundyet) {
                         return;
                     }
                 }
             }
         }
     }
 }
Пример #3
0
 public function foreign_gettime($btime, $accepted_foreign, $entry)
 {
     $plugins = $this->accept_archivename(array());
     if (empty($plugins[$accepted_foreign])) {
         return $btime;
     }
     # mktime(): H, M, S, M, D, Y
     switch ($accepted_foreign) {
         case 'backupwordpress':
         case 'backupwordpress2':
             # e.g. example-com-default-1-complete-2014-03-10-11-44-57.zip
             if (preg_match('/(([0-9]{4})-([0-9]{2})-([0-9]{2})-([0-9]{2})-([0-9]{2})-([0-9]{2}))\\.zip$/i', $entry, $tmatch)) {
                 return mktime($tmatch[5], $tmatch[6], $tmatch[7], $tmatch[3], $tmatch[4], $tmatch[2]);
             }
             break;
         case 'simple_backup':
             # e.g. db_backup_2014-03-15_133344.sql.gz | backup-2014-03-15-133345.zip
             # Note that a backup of both files and DB started at the same time may not have the same timestamp on both entities
             # Can also do tar and tar.gz and tar.bz2
             if (preg_match('/^(db_)?backup.([0-9]{4})-([0-9]{2})-([0-9]{2}).([0-9]{2})([0-9]{2})([0-9]{2})\\.(zip|tar(\\.(bz2|gz))?|sql(\\.(gz))?)$/i', $entry, $tmatch)) {
                 $btime = mktime($tmatch[5], $tmatch[6], $tmatch[7], $tmatch[3], $tmatch[4], $tmatch[2]);
                 return $btime - $btime % 60;
             }
         case 'backwpup':
             # e.g. backwpup_430908_2014-03-30_11-41-05.tar
             if (preg_match('/^backwpup_[0-9a-f]+_([0-9]{4})-([0-9]{2})-([0-9]{2})_([0-9]{2})-([0-9]{2})-([0-9]{2})\\.(zip|tar|tar\\.gz|tar\\.bz2)/i', $entry, $tmatch)) {
                 return mktime($tmatch[4], $tmatch[5], $tmatch[6], $tmatch[2], $tmatch[3], $tmatch[1]);
             }
         case 'wpb2d':
             if (!class_exists('UpdraftPlus_PclZip') && file_exists(UPDRAFTPLUS_DIR . '/class-zip.php')) {
                 require_once UPDRAFTPLUS_DIR . '/class-zip.php';
             }
             global $updraftplus;
             $updraft_dir = trailingslashit($updraftplus->backups_dir_location());
             if (file_exists($updraft_dir . $entry) && class_exists('UpdraftPlus_PclZip')) {
                 $transkey = 'ud_forgt_' . md5($entry . filesize($updraft_dir . $entry));
                 $trans = get_transient($transkey);
                 if ($trans > 0) {
                     return $trans;
                 }
                 $zip = new UpdraftPlus_PclZip();
                 $zip->ud_include_mtime();
                 if (!$zip->open($updraft_dir . $entry)) {
                     $updraftplus->log("Could not open zip file to examine (" . $zip->last_error . "); will remove: " . $entry);
                     $btime = time();
                 } else {
                     # Don't put this in the for loop, or the magic __get() method gets called and opens the zip file every time the loop goes round
                     $numfiles = $zip->numFiles;
                     $latest_mtime = -1;
                     for ($i = 0; $i < $numfiles; $i++) {
                         $si = $zip->statIndex($i);
                         if ('wp-content/backups/wordpress-db-backup.sql' == $si['name']) {
                             @$zip->close();
                             $btime = $si['mtime'];
                         } elseif (preg_match('#wp-content/backups/(.*)\\.sql$#i', $si['name'], $matches)) {
                             if ($si['mtime'] > $latest_mtime) {
                                 $latest_mtime = $si['mtime'];
                                 $btime = $si['mtime'];
                             }
                         }
                     }
                     @$zip->close();
                 }
                 set_transient($transkey, $btime, 86400 * 365);
                 return $btime !== false ? $btime : filemtime($updraft_dir . $entry);
             }
             return time();
             break;
         case 'genericsql':
             global $updraftplus;
             $updraft_dir = $updraftplus->backups_dir_location();
             // Using filemtime prevents a new backup being discovered each time 'rescan' is pressed
             return file_exists(trailingslashit($updraft_dir) . $entry) ? filemtime(trailingslashit($updraft_dir) . $entry) : time();
             break;
     }
     return $btime;
 }