示例#1
0
 function _finalise()
 {
     global $mainframe;
     // The backup is over. Did we encounter any errors?
     if ($this->getError()) {
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Can't finalise due to errors");
         // Notify Super Administrators if it's a front-end backup
         if (!$mainframe->isAdmin()) {
             $this->_mailToSuperAdministrators($this->getError());
         }
         // Oops! Have to reset() because of the error
         $this->reset();
     } else {
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Finalising backup started");
         // Notify Super Administrators if it's a front-end backup
         if (!$mainframe->isAdmin()) {
             $this->_mailToSuperAdministrators();
         }
         // Remove temp files
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Removing temporary files");
         JoomlapackCUBETempfiles::deleteTempFiles();
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Updating statistics");
         // We finished normally. Fetch the stats record
         $this->statmodel = null;
         $this->statmodel = new JoomlapackModelStatistics($this->_statID);
         $this->statmodel->setId($this->_statID);
         $statRecord =& $this->statmodel->getStatistic();
         jimport('joomla.utilities.date');
         $jdate = new JDate();
         $statRecord->backupend = $jdate->toMySQL();
         $statRecord->status = 'complete';
         $this->statmodel->save($statRecord);
         // Apply quotas
         $errorReporting = @error_reporting(0);
         $quotaFiles = $this->statmodel->getOldBackupsToDelete();
         if (count($quotaFiles) > 0) {
             JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Applying quotas");
             jimport('joomla.filesystem.file');
             foreach ($quotaFiles as $file) {
                 // Try to delete the file using either unlink() or, if it fails, the
                 // Joomla!'s JFile::delete method (which might use FTP to do it!).
                 if (!@unlink($file)) {
                     // FIX 2.0: Using JFile::delete raised warnings which messed up XMLRPC output. After all, we write backup files from PHP, using FTP should not be necessary to delete them!
                     JoomlapackLogger::WriteLog(_JP_LOG_WARNING, "Failed to remove old backup file " . $file);
                     /*
                     if(!@JFile::delete($file))
                     {
                     	// Warn if an existing file wasn't deleted when trying to apply quotas
                     	if( JFile::exists($file) ) JoomlapackLogger::WriteLog(_JP_LOG_WARNING, "Failed to remove old backup file ".$file );
                     }
                     */
                 }
             }
         }
         @error_reporting($errorReporting);
         // Set internal variables and go to bed... er... I mean, return control to the user
         $this->_isFinished = true;
         $this->_activeDomain = 'finale';
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Finalising backup ended");
     }
 }