Пример #1
0
        $database_size += $v['Data_length'] + $v['Index_length'];
        $all_tables[] = $v['Name'];
    }
    $view->assign('database_size', $database_size);
    $view->assign('all_tables', $all_tables);
    $files = fn_get_dir_contents(Registry::get('config.dir.backups'), false, true, array('.sql', '.tgz', '.zip'), '', true);
    sort($files, SORT_STRING);
    $backup_files = array();
    $date_format = Registry::get('settings.Appearance.date_format') . ' ' . Registry::get('settings.Appearance.time_format');
    if (is_array($files)) {
        $backup_dir = Registry::get('config.dir.backups');
        foreach ($files as $file) {
            $ext = fn_get_file_ext($backup_dir . $file);
            $backup_files[$file]['size'] = filesize($backup_dir . $file);
            $backup_files[$file]['create'] = fn_date_format(filemtime($backup_dir . $file), $date_format);
            if ($ext == 'sql') {
                $backup_files[$file]['type'] = 'database';
            } else {
                $backup_files[$file]['type'] = DataKeeper::getArchiveType($backup_dir . $file);
            }
        }
    }
    $supported_archive_types = array('tgz');
    $validators = new Validators();
    if ($validators->isZipArchiveAvailable()) {
        $supported_archive_types[] = 'zip';
    }
    $view->assign('supported_archive_types', $supported_archive_types);
    $view->assign('backup_files', $backup_files);
    $view->assign('backup_dir', fn_get_rel_dir(Registry::get('config.dir.backups')));
}
Пример #2
0
 /**
  * Gets archive file tree without unpacking
  *
  * @param  string $file_path Path to packed file
  * @param  bool   $only_root gets only root folders and files
  * @return mixed  List of files in packed archive or false if archive cannot be read or archive does not support
  */
 public static function getCompressedFilesList($file_path, $only_root = false)
 {
     $files_list = array();
     $ext = fn_get_file_ext($file_path);
     switch ($ext) {
         case 'zip':
             $validators = new Validators();
             if (!$validators->isZipArchiveAvailable()) {
                 return $files_list;
             }
             $zip = new \ZipArchive();
             if ($zip->open($file_path)) {
                 $num_files = $zip->numFiles;
                 for ($i = 0; $i < $num_files; $i++) {
                     $file_name = $zip->getNameIndex($i);
                     if ($only_root && strpos($file_name, '/') !== false) {
                         $file_name = preg_replace('#/.*$#i', '', $file_name);
                     }
                     $files_list[$file_name] = $i;
                 }
                 $files_list = array_flip($files_list);
             }
             break;
         case 'tgz':
             if ($only_root) {
                 $tgz = new \PharData($file_path);
                 if (!empty($tgz)) {
                     foreach ($tgz as $index => $file) {
                         $files_list[] = $file->getFilename();
                     }
                 }
             } else {
                 $files_list = fn_get_dir_contents('phar://' . $file_path, true, true, '', '', true);
                 return $files_list;
             }
             break;
         default:
             break;
     }
     return $files_list;
 }
Пример #3
0
 /**
  * Check if session.autostart is disabled
  *
  * @return bool true if disabled
  */
 public function isSessionAutostartDisabled()
 {
     $checking_result = parent::isSessionAutostartDisabled();
     return $checking_result;
 }
Пример #4
0
}
if ($mode == 'getfile' && !empty($_REQUEST['file'])) {
    fn_get_file(Registry::get('config.dir.backups') . fn_basename($_REQUEST['file']));
} elseif ($mode == 'manage') {
    // Calculate database size and fill tables array
    $status_data = db_get_array("SHOW TABLE STATUS");
    $database_size = 0;
    $all_tables = array();
    foreach ($status_data as $v) {
        $database_size += $v['Data_length'] + $v['Index_length'];
        $all_tables[] = $v['Name'];
    }
    $files = fn_get_dir_contents(Registry::get('config.dir.backups'), false, true, array('.sql', '.tgz', '.zip'), '', true);
    sort($files, SORT_STRING);
    $date_format = Registry::get('settings.Appearance.date_format') . ' ' . Registry::get('settings.Appearance.time_format');
    $validators = new Validators();
    $backup_files = array();
    $required_phardata = false;
    if (is_array($files)) {
        $backup_dir = Registry::get('config.dir.backups');
        foreach ($files as $file) {
            $ext = fn_get_file_ext($backup_dir . $file);
            $backup_files[$file]['size'] = filesize($backup_dir . $file);
            $backup_files[$file]['create'] = fn_date_format(filemtime($backup_dir . $file), $date_format);
            if ($ext == 'tgz') {
                $backup_files[$file]['type'] = DataKeeper::BACKUP_TYPE_UNKNOWN;
            } else {
                $backup_files[$file]['type'] = DataKeeper::getBackupType($backup_dir . $file);
            }
            $backup_files[$file]['can_be_restored'] = true;
            if ($ext == 'tgz' && !$validators->isPharDataAvailable()) {
Пример #5
0
 /**
  * Gets archive file tree without unpacking
  *
  * @param  string $file_path Path to packed file
  * @param  bool   $only_root gets only root folders and files
  * @return mixed  List of files in packed archive or false if archive cannot be read or archive does not support
  */
 public static function getCompressedFilesList($file_path, $only_root = false)
 {
     $files_list = array();
     $ext = fn_get_file_ext($file_path);
     switch ($ext) {
         case 'zip':
             $validators = new Validators();
             if (!$validators->isZipArchiveAvailable()) {
                 return $files_list;
             }
             $zip = new \ZipArchive();
             if ($zip->open($file_path)) {
                 $num_files = $zip->numFiles;
                 $counter = 0;
                 for ($i = 0; $i < $num_files; $i++) {
                     $file_name = $zip->getNameIndex($i);
                     $parent_directories = fn_get_parent_directory_stack($file_name);
                     if ($only_root) {
                         if (empty($parent_directories)) {
                             $files_list[$file_name] = $counter++;
                         } else {
                             $files_list[end($parent_directories)] = $counter++;
                         }
                     } else {
                         $files_list[$file_name] = $counter++;
                         foreach ($parent_directories as $parent_dir_path) {
                             $files_list[$parent_dir_path] = $counter++;
                         }
                     }
                 }
                 $files_list = array_flip($files_list);
                 $zip->close();
             }
             break;
         case 'tgz':
             $tgz = new \PharData($file_path, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_PATHNAME);
             if ($only_root) {
                 $iterator = $tgz;
             } else {
                 $iterator = new \RecursiveIteratorIterator($tgz, \RecursiveIteratorIterator::SELF_FIRST);
             }
             foreach ($iterator as $path_name => $spl_file_info) {
                 /** @var \SplFileInfo $spl_file_info */
                 $files_list[] = $spl_file_info->isDir() ? rtrim($iterator->getSubPathname(), '\\/') . DIRECTORY_SEPARATOR : $iterator->getSubPathname();
             }
             $tgz = null;
             $iterator = null;
             break;
         default:
             break;
     }
     sort($files_list);
     return $files_list;
 }