Led 17
PHP: regulár na výpis použitých módů
<?php $tmp_source = preg_replace_callback("/\{mod_(.+)\}/", "process_mode", $tmp_source); ?> |
Každý zpracovaný mód projde funkcí process_mode.
You can use the search form below to go through the content and find a specific post or page:
<?php $tmp_source = preg_replace_callback("/\{mod_(.+)\}/", "process_mode", $tmp_source); ?> |
Každý zpracovaný mód projde funkcí process_mode.
<?php /* send_file( string $file [, int $rate ] ) param $file - Path to the file to send param $rate - Speed limit of download in kB/s */ function send_file($file, $rate = 0) { // check if the file exists if (!is_file($file)) { die('404 File Not Found'); } // get the filename, extension, and size $filename = basename($file); $file_extension = strtolower(substr(strrchr($filename, '.'), 1)); $size = filesize($file); // set the mime type based on the extension switch($file_extension) { case 'exe': $ctype = 'application/octet-stream'; break; case 'zip': $ctype = 'application/zip'; break; case 'mp3': $ctype = 'audio/mpeg'; break; case 'mpg': $ctype = 'video/mpeg'; break; case 'avi': $ctype = 'video/x-msvideo'; break; // block access to sensitive file types case 'php': case 'inc': exit; break; default: $ctype='application/force-download'; } // begin writing headers header('Cache-Control: private'); header('Content-Type: ' . $ctype); header('Content-Disposition: attachment; filename=' . $filename); header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); // open the file for reading $fp = fopen($file, 'rb'); // check if http_range was sent by client if(isset($_SERVER['HTTP_RANGE'])) { // if so, calculate the range to use $seek_range = substr($_SERVER['HTTP_RANGE'], 6); $range = explode('-', $seek_range); if($range[0] > 0){ $seek_start = intval($range[0]); } if($range[1] > 0){ $seek_end = intval($range[1]); } // seek to the requested position in the file fseek($fp, $seek_start); // set the range response headers header('HTTP/1.1 206 Partial Content'); header('Content-Length: ' . ($seek_end - $seek_start + 1)); header(sprintf('Content-Range: bytes %d-%d/%d', $seek_start, $seek_end, $size)); } else { // set default response headers header('Content-Length: ' . $size); } // set up the size of each piece of data we send $block_size = 1024; if($rate > 0) { // multiply by rate if specified $block_size *= $rate; } // prevent the script from timing out set_time_limit(0); // start sending the file while(!feof($fp)) { // output data print(fread($fp, $block_size)); flush(); if($rate > 0) { // wait one second before next block if rate is specified sleep(1); } } // close the file fclose($fp); } ?> |
<?php // local file that should be send to the client $local_file = 'your-file.ext'; // filename that the user gets as default $download_file = 'filename-in-browser.ext'; // set the download rate limit (=> 20,5 kb/s) $download_rate = 20.5; if(file_exists($local_file) && is_file($local_file)) { // send headers header('Cache-control: private'); header('Content-Type: application/octet-stream'); header('Content-Length: '.filesize($local_file)); header('Content-Disposition: filename='.$download_file); // flush content flush(); // open file stream $file = fopen($local_file, "r"); while(!feof($file)) { // send the current file part to the browser print fread($file, round($download_rate * 1024)); // flush the content to the browser flush(); // sleep one second sleep(1); } // close file stream fclose($file);} else { die('Error: The file '.$local_file.' does not exist!'); } ?> |
<?php function format_bytes($bytes) { $labels = array('B','KB','MB','GB','TB'); for($x = 0; $bytes >= 1024 && $x < (count($labels) - 1); $bytes /= 1024, $x++); return(round($bytes, 2).' '.$labels[$x]); } ?> |
© Copyright fandaa.name. All rights reserved.
Designed by FTL Free WordPress Themes brought to you by [i] Website Templates