示例#1
0
文件: Backup.php 项目: hhgr/hhgolf
 /**
  * Returns an instance of the Storage object
  * @return \mithra62\BackupPro\Backup\Storage
  */
 public function getStorage()
 {
     if (is_null($this->storage)) {
         $this->storage = new Backup\Storage($this->getStoragePath());
         $this->storage->setServices($this->getServices());
     }
     return $this->storage;
 }
示例#2
0
文件: Errors.php 项目: hhgr/hhgolf
 /**
  * Runs the tests to make sure the backup directories exist and are writable
  * @param \mithra62\BackupPro\Backup\Storage $storage
  * @return \mithra62\BackupPro\Errors
  */
 public function checkBackupDirs(\mithra62\BackupPro\Backup\Storage $storage)
 {
     $errors = array();
     $index = dirname(__FILE__) . '/../index.html';
     if (!is_writable($storage->getBackupDir())) {
         $errors[] = 'db_dir_missing';
         $errors[] = 'files_dir_missing';
     } else {
         if (!file_exists($storage->getDbBackupDir())) {
             if (!mkdir($storage->getDbBackupDir())) {
                 $errors[] = 'db_dir_missing';
             } else {
                 @copy($index, $storage->getDbBackupDir() . '/index.html');
             }
         } elseif (!is_writable($storage->getDbBackupDir())) {
             $errors[] = 'db_dir_not_writable';
         }
         if (!file_exists($storage->getFileBackupDir())) {
             if (!mkdir($storage->getFileBackupDir())) {
                 $errors[] = 'files_dir_missing';
             } else {
                 @copy($index, $storage->getFileBackupDir() . '/index.html');
             }
         } elseif (!is_writable($storage->getFileBackupDir())) {
             $errors[] = 'files_dir_not_writable';
         }
         if (!file_exists($storage->getDbBackupDir() . '/.meta')) {
             if (!mkdir($storage->getDbBackupDir() . '/.meta')) {
                 $errors[] = 'db_dir_meta_missing';
             }
         }
         if (!file_exists($storage->getFileBackupDir() . '/.meta')) {
             if (!mkdir($storage->getFileBackupDir() . '/.meta')) {
                 $errors[] = 'files_dir_meta_missing';
             }
         }
     }
     return $this;
 }