Example #1
0
        if (isset($_SERVER['HTTP_RANGE'])) {
            if ($_SERVER['HTTP_RANGE']) {
                logWrite('file seek');
                fseek($file, $range);
            }
        }
        while (!feof($file) && !connection_aborted() && $bytesSend < $newLength) {
            $buffer = fread($file, $chunkSize);
            echo $buffer;
            flush();
            $bytesSend += strlen($buffer);
        }
        logWrite('sent=' . $bytesSend);
        fclose($file);
        logWrite('file closed');
    }
}
$id = isset($_REQUEST['ID']) ? $_REQUEST['ID'] : '';
$prefix = isset($_REQUEST['prefix']) ? $_REQUEST['prefix'] : 'iu';
$ext = isset($_REQUEST['ext']) ? $_REQUEST['ext'] : 'txt';
$origname = isset($_REQUEST['origname']) ? $_REQUEST['origname'] : $id . "." . $ext;
$path = $config['storage'] . DIRECTORY_SEPARATOR . $prefix . '_files' . DIRECTORY_SEPARATOR . $id;
logWrite('ID=' . $id . ' prefix=' . $prefix . ' ext=' . $ext . ' path=' . $path);
if ($id != '') {
    outputFile($path, $origname);
    //echo('ID='.$id.' prefix='.$prefix.' ext='.$ext.' path='.$path);
    //echo('<br/>size='.filesize($path));
    //}else{
    //	echo('ID='.$id.' prefix='.$prefix.' ext='.$ext.' path='.$path);
    //	echo('<br/>size='.filesize($path));
}
Example #2
0
$twig->addFilter(new Twig_SimpleFilter('t', function ($s) {
    return umiI18n::translate($s);
}));
$page = $variables['full:page'];
umiI18n::$lang = $variables['@lang'];
$tpl = basename($template, '.php');
$vars = array('h1' => $page->getValue('h1'), 'lang' => $variables['@pre-lang'], 'content' => $page->getValue('content'));
$translations = array();
$media = array_key_exists('media', $_REQUEST) && strlen(trim($_REQUEST['media'])) > 0 ? trim($_REQUEST['media']) : false;
$vars['media'] = $media;
if (function_exists('customContent')) {
    $customTpl = customContent($page, $vars);
    if (!empty($customTpl)) {
        $tpl = $customTpl;
    }
}
function outputFile($path, $media)
{
    if ($media) {
        $newPath = dirname($path) . '/' . basename($path, '.tpl') . ".{$media}.tpl";
        if (file_exists($newPath)) {
            $path = $newPath;
        }
    }
    $module =& system_buildin_load('system');
    return $module->getOuterContent($path);
}
echo outputFile(__DIR__ . '/../tpls/content/header.tpl', $media);
echo $twig->render("{$tpl}.html", $vars);
echo outputFile(__DIR__ . '/../tpls/content/footer.tpl', $media);
Example #3
0
            $filedate = substr($match, strrpos($path, '-') + 1);
            //get date of matched file
            $fileage = $time - $filedate;
            //determine file age
            if ($time - $filedate > $expire) {
                //check if file has expired
                foreach ($matches as $file) {
                    unlink($file);
                }
                //delete all expired files
                writeFile($path, $input);
                //write fresh file to server
                outputFile($path, $json);
                //output freshly written file
            } else {
                outputFile($match, $json);
            }
            //else output cached file
        }
        //matched file loop
    }
    //passed urls loop
}
//if no cache bypass loop
if ($json) {
    echo str_replace('\\/', '/', json_encode($allData));
}
//output JSON if flagged (with manual unescaping)
function writeFile($path, $input)
{
    file_put_contents($path, $input);
function render_user_verrsc($param)
{
    $tbl = GetTable('recursos');
    $col = GetCols('recursos');
    list($db) = Getdb();
    $rid = $param['rid'];
    $rs = $db->Execute("SELECT * from {$tbl} WHERE {$col['rid']}={$rid}");
    if ($db->ErrorNo() != 0) {
        $param['ruta'] = "error";
        $param['mensaje'] = "Ha ocurrido leer el archivo de la base de datos.";
        render($param);
        die;
    }
    $recurso = $rs->FetchRow();
    $recurso = fromdbtocms($recurso, 'recursos');
    $ul = vwSessionGetVar('UserLevel');
    $recurso["uid"] = vwSessionGetVar("uid");
    if ($ul < 1) {
        $param['ruta'] = "error";
        $param['mensaje'] = "No tiene nivel para acceder a los recursos. Registrese.";
        render($param);
        die;
    } else {
        if ($ul < 500) {
            if ($recurso['restringido'] == "S") {
                $tbl = GetTable('autorizaciones');
                $col = GetCols('autorizaciones');
                list($db) = Getdb();
                $rid = $param['rid'];
                $sql = "SELECT * FROM {$tbl} where {$col['rid']}={$valor} AND {$col['uid']}=" . vwSessionGetVar('uid') . " ORDER BY {$col['resolucion']} desc";
                $rs = $db->Execute($sql);
                if ($db->ErrorNo() != 0) {
                    $param['ruta'] = "error";
                    $param['mensaje'] = "Ha ocurrido leer el archivo de la base de datos.";
                    render($param);
                    die;
                }
                $aut = $rs->FetchRow();
                $aut = fromdbtocms($aut, 'autorizaciones');
                if ($aut['estado'] != 'C') {
                    $param['ruta'] = "error";
                    $param['mensaje'] = "No dispone de autorizacion para descargar el recurso.";
                    render($param);
                    die;
                }
            }
        }
        eventoRecursos($recurso, "verrsc");
        outputFile($recurso['archivo'], $recurso['did']);
        die;
    }
    die;
}