Esempio n. 1
0
function internal_error($txt)
{
    header("HTTP/1.0 500 Internal Server Error");
    nocache();
    if ($txt) {
        print $txt;
    }
    die;
}
Esempio n. 2
0
function PageMaker($xmlfile, $xslfile)
{
    global $options, $id, $df, $cacheLifeTime;
    # Инициализация системы кэширования
    // Подключаем класс вывода PEAR::Cache_Lite
    require_once 'cache/output.php';
    // Создаем объект класса Cache_Lite_Output
    $cache = new Cache_Lite_Output($options);
    // Устанавливаем время жизни кэша для данной части
    $cache->setLifeTime($cacheLifeTime[$id]);
    if (!$cache->start($id)) {
        # Передаем путь к запрошенному документу на вход модуля анализа и преобразования XML+XSLT,
        # формирующего на выходе запрошенный документ в XHTML-формате.
        require_once "inc/nstoxhtml.inc";
        require_once "inc/setformat.inc";
        require_once "inc/nocache.inc";
        $outputformat = 'xml';
        //if ($xslfile !== "xsl/rbcrss.xsl") $xslfile = "xsl/layout.xsl";
        $domxml = new DOMDocument();
        $domxml->substituteEntities = true;
        $domxml->load($xmlfile);
        @fclose($df);
        # Снимаем блокировку с файла *
        $domxsl = new DOMDocument();
        $domxsl->load($xslfile);
        setOutputFormat($domxsl, $outputformat);
        $xsl = new xsltProcessor();
        $xsl->importStylesheet($domxsl);
        $outdom = $xsl->transformtoDOC($domxml);
        $outdom = nstoxhtml($outdom);
        $outdom->formatoutput = true;
        nocache();
        $page = $outdom->saveXML();
        echo TrimStr($page);
        $cache->end();
    }
}
Esempio n. 3
0
<?php

ini_set("display_errors", "On");
error_reporting(E_ALL ^ E_NOTICE);
include "funciones.php";
nocache();
include_once "connect.php";
$link = conectarse();
//include("funciones.php");
$arr = array();
$arr1 = array();
$n = $_GET['n'];
if (!$n) {
    $n = $_POST['n'];
}
$fechayhora = date("Y-m-d H:i", time());
switch ($n) {
    case 11:
        //
        $sqlquery = "select codtipdoc,destipdoc from tb_tipdoc where esttipdoc=1";
        $stmt = mysql_query($sqlquery);
        while ($obj = mysql_fetch_object($stmt)) {
            $arr[] = $obj;
        }
        echo '{"tipdocper":' . json_encode($arr) . '}';
        break;
        break;
    case 15:
        //
        break;
    case 16:
Esempio n. 4
0
/**
 * Dump a JSON response along with the appropriate headers.
 *
 * @param mixed $obj object to serialize into JSON
 * @param string $func for JSONP output, this is the callback name
 *
 * @return void
 */
function json($obj, $func = null)
{
    nocache();
    if (!$func) {
        header('Content-type: application/json');
        echo json_encode($obj);
    } else {
        header('Content-type: application/javascript');
        echo ";{$func}(" . json_encode($obj) . ");";
    }
}
Esempio n. 5
0
<?php

namespace cms;

isset($this) && $this instanceof Sphido or die('Sorry can be executed only from Sphido');
// check AJAX request
isAjax() or status(500) and die(json(['message' => 'Not AJAX request, but nice try :-)']));
// response all AJAX requests
nocache(json(['message' => 'Well done! It\'s AJAX request']));
Esempio n. 6
0
    assert(headers_get_clean() === ['x-powered-by: dispatch', 'x-authored-by: noodlehaus']);
    # cookie fetch
    $_COOKIE = ['name' => 'dispatch'];
    assert(cookies('name') === 'dispatch');
    assert(cookies('invalid') === null);
    # cookie set
    cookies('title', 'john & marsha', time() + 3600, '/');
    assert(strpos(headers_get_clean()[0], 'Set-Cookie: title=john+%26+marsha; expires=') === 0);
    # json response
    ob_start();
    json(['name' => 'dispatch']);
    assert(ob_get_clean() === json_encode(['name' => 'dispatch']));
    assert(strpos(headers_get_clean()[0], 'Content-type: application/json') === 0);
    # no-cache headers
    ob_start();
    nocache('dispatch');
    ob_get_clean();
    $list = headers_get_clean();
    assert($list[0] === 'Expires: Tue, 13 Mar 1979 18:00:00 GMT');
    assert(strpos($list[1], 'Last-Modified: ') === 0);
    assert($list[2] === 'Cache-Control: no-store, no-cache, must-revalidate');
    assert($list[3] === 'Cache-Control: post-check=0, pre-check=0');
    assert($list[4] === 'Pragma: no-cache');
    # status
    status(201);
    assert(http_response_code() === 201);
    # redirect (we can't test halting flag)
    redirect('/redir1', 302);
    assert(http_response_code() === 302);
    assert(headers_get_clean()[0] === 'Location: /redir1');
} else {