Readfile chunked
This commit is contained in:
parent
665be9165a
commit
d9eedf84d2
|
@ -139,15 +139,7 @@ class WooCommerce_Widget_Price_Filter extends WP_Widget {
|
|||
)
|
||||
)"));
|
||||
|
||||
if (defined('SHOP_IS_ON_FRONT')) :
|
||||
$link = '';
|
||||
elseif (is_post_type_archive('product') || is_page( get_option('woocommerce_shop_page_id') )) :
|
||||
$link = get_post_type_archive_link('product');
|
||||
else :
|
||||
$link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
|
||||
endif;
|
||||
|
||||
echo '<form method="get" action="'.$link.'">
|
||||
echo '<form method="get" action="'.$_SERVER['REQUEST_URI'].'">
|
||||
<div class="price_slider_wrapper">
|
||||
<div class="price_slider"></div>
|
||||
<div class="price_slider_amount">
|
||||
|
|
|
@ -504,3 +504,40 @@ function woocommerce_exclude_order_comments( $clauses ) {
|
|||
|
||||
}
|
||||
if (!is_admin()) add_filter('comments_clauses', 'woocommerce_exclude_order_comments');
|
||||
|
||||
/**
|
||||
* readfile_chunked
|
||||
*
|
||||
* Reads file in chunks so big downloads are possible without changing PHP.INI - http://codeigniter.com/wiki/Download_helper_for_large_files/
|
||||
*
|
||||
* @access public
|
||||
* @param string file
|
||||
* @param boolean return bytes of file
|
||||
* @return void
|
||||
*/
|
||||
if ( ! function_exists('readfile_chunked')) {
|
||||
function readfile_chunked($file, $retbytes=TRUE) {
|
||||
|
||||
$chunksize = 1 * (1024 * 1024);
|
||||
$buffer = '';
|
||||
$cnt = 0;
|
||||
|
||||
$handle = fopen($file, 'r');
|
||||
if ($handle === FALSE) return FALSE;
|
||||
|
||||
while (!feof($handle)) :
|
||||
$buffer = fread($handle, $chunksize);
|
||||
echo $buffer;
|
||||
ob_flush();
|
||||
flush();
|
||||
|
||||
if ($retbytes) $cnt += strlen($buffer);
|
||||
endwhile;
|
||||
|
||||
$status = fclose($handle);
|
||||
|
||||
if ($retbytes AND $status) return $cnt;
|
||||
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -714,13 +714,13 @@ function woocommerce_download_product() {
|
|||
// Serve it
|
||||
if ($remote_file) :
|
||||
|
||||
@readfile("$file_path") or header('Location: '.$file_path);
|
||||
@readfile_chunked("$file_path") or header('Location: '.$file_path);
|
||||
|
||||
else :
|
||||
|
||||
if (!file_exists($file_path)) wp_die( sprintf(__('File not found. <a href="%s">Go to homepage →</a>', 'woothemes'), home_url()) );
|
||||
|
||||
@readfile("$file_path") or wp_die( sprintf(__('File not found. <a href="%s">Go to homepage →</a>', 'woothemes'), home_url()) );
|
||||
@readfile_chunked("$file_path") or wp_die( sprintf(__('File not found. <a href="%s">Go to homepage →</a>', 'woothemes'), home_url()) );
|
||||
|
||||
endif;
|
||||
|
||||
|
|
Loading…
Reference in New Issue