wordpress/wp-content/plugins/sqlite-integration/utilities/utility.php
/**
	 * Method to download a backup file.
	 *
	 * This method uses header() function, so we have to register this function using
	 * admin_init action hook. It must also be declared as public. We check HTTP_REFERER
	 * and input button name, and ,after that, wp_nonce. When the admin_init is executed
	 * it only returns true.
	 *
	 * The database file might be several hundred mega bytes, so we don't use readfile()
	 * but use fread() instead.
	 *
	 * Users can download one file at a time.
	 *
	 * @return 1 if the file name isn't checked, 2 if multiple files are checked, true if succeeded.
	 */
Method to download a backup file.
This method uses header() function, so we have to register this function using
admin_init action hook. It must also be declared as public. We check HTTP_REFERER
and input button name, and ,after that, wp_nonce. When the admin_init is executed
it only returns true.

The database file might be several hundred mega bytes, so we don't use readfile()
but use fread() instead.

Users can download one file at a time.

@return 1 if the file name isn't checked, 2 if multiple files are checked, true if succeeded.
Method to download a backup file . This method uses header () function so we have to register this function using admin_init action hook . It must also be declared as public . We check HTTP_REFERER and input button name and after that wp_nonce . When the admin_init is executed it only returns true . The database file might be several hundred mega bytes so we don ' t use readfile () but use fread () instead . Users can download one file at a time . @return 1 if the file name isn ' t checked 2 if multiple files are checked true if succeeded .
static function download_backup_db() {
		if (is_multisite()) {
			$script_url = network_admin_url('settings.php?page=setting-file');
		} else {
			$script_url = admin_url('options-general.php?page=setting-file');
		}
		if (isset($_POST['download_backup_file']) && stripos($_SERVER['HTTP_REFERER'], $script_url) !== false) {
			check_admin_referer('sqliteintegration-backup-manip-stats');
			if (!isset($_POST['backup_checked'])) return 1;
			$file_names = array();
			$file_names = $_POST['backup_checked'];
			if (count($file_names) != 1) return 2;
			$file_name = $file_names[0];
			$file_path = FQDBDIR . $file_name;
			$blog_name = str_replace(array(' ', '　', ';'), array('_', '_', '_'), get_bloginfo('name'));
			$download_file_name = $blog_name . '_' . $file_name;
			header('Pragma: public');
			header('Cache-Control: must-revalidate,post-check=0,pre-check=0');
			header('Content-Type: application/force-download');
			header('Content-Type: application/octet-stream');
			header('Content-Type: application/download');
			header('Content-Disposition: attachment; filename='.$download_file_name.';');
			header('Content-Transfer-Encoding: binary');
			header('Content-Length: '.filesize($file_path));
			$fp = fopen($file_path, 'r');
			while (!feof($fp)) {
				echo fread($fp, 65536);
				flush();
			}
			fclose($fp);
		}
		return true;
	}
static function download_backup_db ( ) { if ( is_multisite ( ) ) { $ script_url = network_admin_url ( 'settings.php?page=setting-file' ) ; } else { $ script_url = admin_url ( 'options-general.php?page=setting-file' ) ; } if ( isset ( $ _POST [ 'download_backup_file' ] ) && stripos ( $ _SERVER [ 'HTTP_REFERER' ] , $ script_url ) !== false ) { check_admin_referer ( 'sqliteintegration-backup-manip-stats' ) ; if ( ! isset ( $ _POST [ 'backup_checked' ] ) ) return 1 ; $ file_names = array ( ) ; $ file_names = $ _POST [ 'backup_checked' ] ; if ( count ( $ file_names ) != 1 ) return 2 ; $ file_name = $ file_names [ 0 ] ; $ file_path = FQDBDIR . $ file_name ; $ blog_name = str_replace ( array ( ' ' , '　',  ' '), a ray(' _ ',  ' ',  ' '), g t_bloginfo(' n ame')) ; $ download_file_name = $ blog_name . '_' . $ file_name ; header ( 'Pragma: public' ) ; header ( 'Cache-Control: must-revalidate,post-check=0,pre-check=0' ) ; header ( 'Content-Type: application/force-download' ) ; header ( 'Content-Type: application/octet-stream' ) ; header ( 'Content-Type: application/download' ) ; header ( 'Content-Disposition: attachment; filename=' . $ download_file_name . ';' ) ; header ( 'Content-Transfer-Encoding: binary' ) ; header ( 'Content-Length: ' . filesize ( $ file_path ) ) ; $ fp = fopen ( $ file_path , 'r' ) ; while ( ! feof ( $ fp ) ) { echo fread ( $ fp , 65536 ) ; flush ( ) ; } fclose ( $ fp ) ; } return true ; }
Method to download a backup file.
Method to download a backup file .