\n".json_encode($info, JSON_PRETTY_PRINT)); } return true; } function backuply_untar_archive($tarname, $untar_path, $file_list = array(), $handle_remote = false){ global $globals, $can_write, $ftp; // Create directory if not there if(!is_dir($untar_path)){ @mkdir($untar_path); } $tar_archive = new backuply_tar($tarname, '', $handle_remote); if(empty($file_list)){ $res = $tar_archive->extractModify($untar_path, ''); }else{ $res = $tar_archive->extractList($file_list, $untar_path); } if(!$res){ return false; } return true; } function backuply_sync_local_backups(){ $backups_dir = backuply_glob('backups'); $backups_info_dir = backuply_glob('backups_info'); if(!file_exists($backups_dir) || !file_exists($backups_info_dir)){ return false; } $backups = @scandir($backups_dir); $backup_info_name = ''; $backup_file_name = ''; foreach($backups as $backup){ if(in_array($backup, ['.', '..', 'index.html', 'index.php', 'tmp'])){ continue; } $info_file_name = str_replace('.tar.gz', '.php', $backup); if(!file_exists($backups_info_dir . '/' . $info_file_name)){ backuply_create_info_file($info_file_name, $backup); } } } // Creates new info file, from the info file in that backup tar.gz function backuply_create_info_file($backup_info_name, $backup_file_name){ $backups_dir = backuply_glob('backups'); $backups_info_dir = backuply_glob('backups_info'); if(empty($backup_info_name) || empty($backup_file_name)){ return true; } include_once BACKUPLY_DIR . '/backuplytar.php'; // Including the Backuply TAR class. $backup_path = $backups_dir . '/' .$backup_file_name; backuply_untar_archive($backup_path, $backups_dir .'/tmp/', array($backup_info_name)); $archived_info = $backups_dir .'/tmp/' .$backup_info_name; if(!file_exists($archived_info)){ return true; } $content = file_get_contents($archived_info); if(!preg_match('/{.*}/s', $content, $json_info) || empty($json_info[0])){ return true; } $info_arr = json_decode($json_info[0], true); if(empty($info_arr['size'])){ $info_arr['size'] = filesize($backup_path); } file_put_contents($backups_info_dir . '/'. $backup_info_name, "