コード例 #1
0
<?php

error_reporting(E_ALL | E_NOTICE | E_WARNING | E_STRICT);
require_once realpath(dirname(__FILE__) . '/../php/Bootstrap.class.php');
Bootstrap::initConfig(dirname(__FILE__) . '/../config/config.ini');
Bootstrap::import('nl.bransom.http.HttpRequestHandler');
Bootstrap::import('nl.bransom.http.HttpResponder');
HttpResponder::handleFatalErrorsOnShutdown();
$restTarget = HttpRequestHandler::getRestTarget($_SERVER['REQUEST_URI'], $_SERVER['PHP_SELF']);
$requestContent = file_get_contents('php://input');
$requestContentType = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : NULL;
$requestHandler = new HttpRequestHandler();
$requestHandler->dispatchRequest($_SERVER['REQUEST_METHOD'], $restTarget, $_SERVER['QUERY_STRING'], $_SERVER['HTTP_ACCEPT'], NULL, $_REQUEST, $requestContent, $requestContentType);
コード例 #2
0
<?php

error_reporting(E_ALL | E_NOTICE | E_WARNING);
require_once realpath(dirname(__FILE__) . '/../../bransom/php/Bootstrap.class.php');
Bootstrap::initConfig(dirname(__FILE__) . '/../../bransom/config/config.ini');
Bootstrap::import('nl.bransom.http.HttpRequestHandler');
Bootstrap::import('nl.bransom.http.HttpResponder');
HttpResponder::handleFatalErrorsOnShutdown();
// e.g. /webitems/newsreader/elsvanwijnen/image/330/data.jpg
$restTarget = HttpRequestHandler::getRestTarget($_SERVER['REQUEST_URI'], $_SERVER['PHP_SELF']);
// e.g [ elsvanwijnen, image, 330, data.jpg ]
if (count($restTarget) > 0) {
    $restTarget[0] = 'webitems';
}
$requestHandler = new HttpRequestHandler();
$requestHandler->dispatchRequest($_SERVER['REQUEST_METHOD'], $restTarget, $_SERVER['QUERY_STRING'], $_SERVER['HTTP_ACCEPT'], 'max-age=3600', $_REQUEST);
コード例 #3
0
ファイル: import.php プロジェクト: RobBosman/vanace.WebItems
$dataXml = $xsltProc->transformToXML($downloadedXml);
// Convert image URL's to Base64 data.
$xmlResultDoc = new DOMDocument();
$xmlResultDoc->loadXML($dataXml);
$namespaceURI = $xmlResultDoc->documentElement->lookupnamespaceURI(NULL);
$imageList = $xmlResultDoc->getElementsByTagNameNS('*', 'image');
foreach ($imageList as $image) {
    $urlNodeList = $image->getElementsByTagNameNS('*', 'url');
    if ($urlNodeList->length == 1) {
        $urlNode = $urlNodeList->item(0);
        // Convert the content of the URL to Base64.
        $base64Data = base64_encode(file_get_contents($urlNode->nodeValue));
        $dataNode = $xmlResultDoc->createElementNS($namespaceURI, 'data', $base64Data);
        $image->replaceChild($dataNode, $urlNode);
    }
}
$dataXml = $xmlResultDoc->saveXML();
if (array_key_exists('saveInDB', $_POST)) {
    // Store the result.
    $restTarget = array('webitems');
    if ($siteId != '') {
        $restTarget[] = 'itemset';
    } else {
        $restTarget[] = 'site';
    }
    $requestHandler = new HttpRequestHandler();
    $requestHandler->dispatchRequest('PUT', $restTarget, 'user=rob', $_SERVER['HTTP_ACCEPT'], NULL, $_REQUEST, $dataXml, 'text/xml');
} else {
    header("Content-type: text/xml");
    echo $dataXml;
}