_sent()) { header('Content-Description: File Transfer'); header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . basename($path) . '"'); header('Cache-Control: must-revalidate'); header('Content-Length: ' . $size); header('Content-Transfer-Encoding: binary'); } if ($size < 1024 * 1024 * 60) { ob_end_clean(); readfile($path); exit; } else { ob_end_clean(); $download_rate = 1024 * 10; $file = fopen($path, "r"); while (!feof($file)) { @set_time_limit(20); // send the current file part to the browser print fread($file, round($download_rate * 1024)); // flush the content to the browser ob_flush(); flush(); // sleep one second sleep(1); } fclose($file); exit; } } } } } catch (Exception $error) { $message = 'An exception has occurred. class: '.get_class($error).';msg: '.$error->getMessage().';code: '.$error->getCode().';line: '.$error->getLine().';in_file: '.$error->getFile().';'; error_log($message); echo wp_json_encode(array('result'=>'failed','error'=>$message)); die(); } $admin_url = admin_url(); echo 'file not found. please retry again.'; die(); } public function set_mail_subject($subject, $task){ if(!class_exists('WPvivid_mail_report')) include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-mail-report.php'; $subject=WPvivid_mail_report::create_subject($task); return $subject; } public function set_mail_body($body, $task){ if(!class_exists('WPvivid_mail_report')) include_once WPVIVID_PLUGIN_DIR . '/includes/class-wpvivid-mail-report.php'; $body=WPvivid_mail_report::create_body($task); return $body; } public function wpvivid_handle_mainwp_action($data){ $public_interface = new WPvivid_Public_Interface(); $ret = $public_interface->mainwp_data($data); return $ret; } public function get_zip_object_class($class) { /*if(version_compare(phpversion(),'8.0.0','>=')) { return 'WPvivid_PclZip_Class_Ex'; } return $class;*/ return 'WPvivid_PclZip_Class_Ex'; } public function get_backup_path($backup_item, $file_name) { $path = $backup_item->get_local_path() . $file_name; if (file_exists($path)) { return $path; } else{ $local_setting = get_option('wpvivid_local_setting', array()); if(!empty($local_setting)) { $path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $local_setting['path'] . DIRECTORY_SEPARATOR . $file_name; } else { $path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'wpvividbackups' . DIRECTORY_SEPARATOR . $file_name; } } return $path; } public function get_backup_folder() { $local_setting = get_option('wpvivid_local_setting', array()); if(!empty($local_setting)) { $path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . $local_setting['path'] . DIRECTORY_SEPARATOR; } else { $path = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'wpvividbackups' . DIRECTORY_SEPARATOR; } return $path; } public function get_backup_url($backup_item, $file_name) { $path = $backup_item->get_local_path() . $file_name; if (file_exists($path)) { return $backup_item->get_local_url() . $file_name; } else{ $local_setting = get_option('wpvivid_local_setting', array()); if(!empty($local_setting)) { $url = content_url().DIRECTORY_SEPARATOR.$local_setting['path'].DIRECTORY_SEPARATOR.$file_name; } else { $url = content_url().DIRECTORY_SEPARATOR.'wpvividbackups'.DIRECTORY_SEPARATOR.$file_name; } } return $url; } public function wpvivid_check_add_litespeed_server($task_id) { $litespeed=false; if ( isset( $_SERVER['HTTP_X_LSCACHE'] ) && $_SERVER['HTTP_X_LSCACHE'] ) { $litespeed=true; } elseif ( isset( $_SERVER['LSWS_EDITION'] ) && strpos( $_SERVER['LSWS_EDITION'], 'Openlitespeed' ) === 0 ) { $litespeed=true; } elseif ( isset( $_SERVER['SERVER_SOFTWARE'] ) && $_SERVER['SERVER_SOFTWARE'] == 'LiteSpeed' ) { $litespeed=true; } if($litespeed) { if($this->wpvivid_log->log_file_handle==false) { $this->wpvivid_log->OpenLogFile(WPvivid_taskmanager::get_task_options($task_id,'log_file_name')); } $this->wpvivid_log->WriteLog('LiteSpeed Server.','notice'); if ( ! function_exists( 'got_mod_rewrite' ) ) { require_once ABSPATH . 'wp-admin/includes/misc.php'; } if(function_exists('insert_with_markers')) { if(!function_exists('get_home_path')) require_once(ABSPATH . 'wp-admin/includes/file.php'); $home_path = get_home_path(); $htaccess_file = $home_path . '.htaccess'; if ( ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) ) || is_writable( $htaccess_file ) ) { if ( got_mod_rewrite() ) { $line[]=''; $line[]='RewriteEngine On'; $line[]='RewriteRule .* - [E=noabort:1, E=noconntimeout:1]'; $line[]=''; insert_with_markers($htaccess_file,'WPvivid Rewrite Rule for LiteSpeed',$line); $this->wpvivid_log->WriteLog('Add LiteSpeed Rule','notice'); } else { $this->wpvivid_log->WriteLog('mod_rewrite not found.','notice'); } } else { $this->wpvivid_log->WriteLog('.htaccess file not exists or not writable.','notice'); } } else { $this->wpvivid_log->WriteLog('insert_with_markers function not exists.','notice'); } } } public function wpvivid_check_clear_litespeed_rule($task_id) { $litespeed=false; if ( isset( $_SERVER['HTTP_X_LSCACHE'] ) && $_SERVER['HTTP_X_LSCACHE'] ) { $litespeed=true; } elseif ( isset( $_SERVER['LSWS_EDITION'] ) && strpos( $_SERVER['LSWS_EDITION'], 'Openlitespeed' ) === 0 ) { $litespeed=true; } elseif ( isset( $_SERVER['SERVER_SOFTWARE'] ) && $_SERVER['SERVER_SOFTWARE'] == 'LiteSpeed' ) { $litespeed=true; } if($litespeed) { if($this->wpvivid_log->log_file_handle==false) { $this->wpvivid_log->OpenLogFile(WPvivid_taskmanager::get_task_options($task_id,'log_file_name')); } $this->wpvivid_log->WriteLog('LiteSpeed Server.','notice'); if ( ! function_exists( 'got_mod_rewrite' ) ) { require_once ABSPATH . 'wp-admin/includes/misc.php'; } if(function_exists('insert_with_markers')) { if(!function_exists('get_home_path')) require_once(ABSPATH . 'wp-admin/includes/file.php'); $home_path = get_home_path(); $htaccess_file = $home_path . '.htaccess'; if ( ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) ) || is_writable( $htaccess_file ) ) { if ( got_mod_rewrite() ) { insert_with_markers($htaccess_file,'WPvivid Rewrite Rule for LiteSpeed',''); $this->wpvivid_log->WriteLog('Clear LiteSpeed Rule','notice'); } else { $this->wpvivid_log->WriteLog('mod_rewrite not found.','notice'); } } else { $this->wpvivid_log->WriteLog('.htaccess file not exists or not writable.','notice'); } } else { $this->wpvivid_log->WriteLog('insert_with_markers function not exists.','notice'); } } } }