Вход Регистрация
Файл: engine/classes/files.class.php
Строк: 67
<?php
/**
 * Класс для работы с файлами
 * 
 * @package Classes
 * @author Shamsik
 * @link http://shcms.ru
 */

class files {
    
/**
     * Аудио и Видио Плеера
     * 
     * @param $name  Название
     * @param $param Параметры вывода
     * @param $style Стили Плееров
     * @param $file  Файл проигрывания
     */
    
public function player($name,$param,$style,$file) {
        
$player '<object '.$param.'>';
        
$player .= '<param name="allowFullScreen" value="true" />';
        
$player .= '<param name="allowScriptAccess" value="always" />';
        
$player .= '<param name="wmode" value="transparent" />';
        
$player .= '<param name="movie" value="'.$name.'" />';
        
$player .= '<param name="flashvars" value="st='.$style.'&amp;file='.$file.'" />';
        
$player .= '<embed src="uppod.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" flashvars="st='.$style.'&amp;file='.$file.'" '.$param.'>';
        
$player .= '</embed>';
        
$player .= ' </object>';
        
    return 
$player;
    }
    
    
/**
     * Функция скачивания файлов
     * 
     * @param $filename Имя файла
     * @param $name Название
     * @param @mimetype
     */
    
public function downloadFile($filename$name$mimetype 'application/octet-stream'
    { 
        if (!
file_exists($filename)) {
            die(
'Файл не найден');
        }        
            
$from $to 0
            
$cr null
            if (isset(
$_SERVER['HTTP_RANGE'])) { 
                
$range substr($_SERVER['HTTP_RANGE'], strpos($_SERVER['HTTP_RANGE'], '=') + 1); 
                
$from strtok($range'-'); 
                
$to strtok('/'); 
                if (
$to 0
                    ++
$to
                if (
$to
                    
$to -= $from
                
header('HTTP/1.1 206 Partial Content'); 
                
$cr 'Content-Range: bytes ' $from '-' . (($to) ? ($to '/' $to 1) : 
                    
filesize($filename)); 
            } else 
                
header('HTTP/1.1 200 Ok'); 
            
$etag md5($filename); 
            
$etag substr($etag08) . '-' substr($etag87) . '-' substr($etag15
                
8); 
            
header('ETag: "' $etag '"'); 
            
header('Accept-Ranges: bytes'); 
            
header('Content-Length: ' . (filesize($filename) - $to $from)); 
            if (
$cr) {
                
header($cr);
            }
            
header('Connection: close'); 
            
header('Content-Type: ' $mimetype); 
            
header('Last-Modified: ' gmdate('r'filemtime($filename))); 
            
$f fopen($filename'r'); 
            
header('Content-Disposition: attachment; filename="' $name '";'); 
            if (
$from) {
                
fseek($f$fromSEEK_SET); 
            }    
            if (!isset(
$to) or empty($to)) { 
                
$size filesize($filename) - $from
            } else { 
                
$size $to
            } 
            
$downloaded 0
            while (!
feof($f) and !connection_status() and ($downloaded $size)) { 
                echo 
fread($f512000); 
                
$downloaded += 512000
                
ob_flush(); 
                
flush(); 
            } 
            
fclose($f); 
    } 



}
Онлайн: 1
Реклама