示例#1
0
/**
 * get Page data for http response code
 * 
 * returns page xml for http response code, by checking for user page fallback to the core page
 * 
 * @since 3.4
 * @param  int $code http response code
 * @return obj       page xml
 */
function getHttpResponsePage($code)
{
    global $pagesArray;
    if (isset($pagesArray[GSHTTPPREFIX . $code])) {
        // use user created http response page
        return getXml(GSDATAPAGESPATH . GSHTTPPREFIX . $code . '.xml');
    } elseif (file_exists(GSDATAOTHERPATH . $code . '.xml')) {
        // use default http response page
        return getXml(GSDATAOTHERPATH . $code . '.xml');
    }
}
/**
 * Generates pagecachexml obj from pages xml
 * @return simpleXmlobj pagecache xml
 */
function generate_pageCacheXml()
{
    // read in each pages xml file
    $path = GSDATAPAGESPATH;
    $filenames = getXmlFiles($path);
    $xml = @new SimpleXMLExtended('<channel></channel>');
    if (count($filenames) != 0) {
        foreach ($filenames as $file) {
            $data = getXml($path . $file);
            $id = $data->url;
            $pages = $xml->addChild('item');
            // $pages->addChild('url', $id);
            $children = $data->children();
            foreach ($children as $item => $itemdata) {
                if ($item != "content") {
                    $note = $pages->addChild($item);
                    $note->addCData($itemdata);
                }
            }
            // removed from xml , redundant
            # $note = $pages->addChild('slug');
            # $note->addCData($id);
            # $note = $pages->addChild('filename');
            # $note->addCData($file);
        }
    }
    return $xml;
}
示例#3
0
function getStockOnHand($format)
{
    global $apiId, $apiKey;
    if ($format == "xml") {
        return getXml($apiId, $apiKey, "StockOnHand", "");
    } else {
        return getJson($apiId, $apiKey, "StockOnHand", "pageSize=300");
    }
}
示例#4
0
$user_created_404 = GSDATAPAGESPATH . '404.xml';
$data_index = null;
// apply page data if page id exists
if (isset($pagesArray[$id])) {
    $data_index = getXml(GSDATAPAGESPATH . $id . '.xml');
}
// filter to modify data_index obj
$data_index = exec_filter('data_index', $data_index);
// page not found handling
if (!$data_index) {
    if (isset($pagesArray['404'])) {
        // use user created 404 page
        $data_index = getXml($user_created_404);
    } elseif (file_exists($file_404)) {
        // default 404
        $data_index = getXml($file_404);
    } else {
        // fail over
        redirect('404');
    }
    exec_action('error-404');
}
$title = $data_index->title;
$date = $data_index->pubDate;
$metak = $data_index->meta;
$metad = $data_index->metad;
$url = $data_index->url;
$content = $data_index->content;
$parent = $data_index->parent;
$template_file = $data_index->template;
$private = $data_index->private;
function getCustomersByName($customerName, $format)
{
    global $apiId, $apiKey;
    if ($format == "xml") {
        return getXml($apiId, $apiKey, "Customers", "customerName={$customerName}");
    } else {
        return getJson($apiId, $apiKey, "Customers", "customerName={$customerName}");
    }
}
示例#6
0
    // new
    $xml->setIndentString("    ");
    // new
    $xml->startDocument('1.0', 'UTF-8');
    $xml->startElement('root');
    write($xml, $results);
    $xml->endElement();
    $xml->endDocument();
    // new
    $data = $xml->outputMemory(true);
    //$file = file_put_contents(APPPATH . '../uploads/data.xml', $data);
    return $data;
}
$consultant = file_get_contents("http://localhost/api/index.php/api/consultant/333");
$results['consultant'] = json_decode($consultant, true);
$results['consultant'][0]['first_name'] = strtoupper(substr($results['consultant'][0]['first_name'], 0, 1)) . '. ';
$results['consultant'][0]['last_name'] = strtoupper(substr($results['consultant'][0]['last_name'], 0, 1)) . '.';
// Make nb_years_exp in the right format(0, 0.5 or 1)
if (floatval($results['consultant'][0]['nb_years_exp'] * 10) % 10 < 1) {
    $results['consultant'][0]['nb_years_exp'] = intval($results['consultant'][0]['nb_years_exp']);
} elseif (floatval($results['consultant'][0]['nb_years_exp'] * 10) % 10 > 5) {
    $results['consultant'][0]['nb_years_exp'] = intval($results['consultant'][0]['nb_years_exp']) + 1;
} else {
    $results['consultant'][0]['nb_years_exp'] = intval($results['consultant'][0]['nb_years_exp']) + 0.5;
}
var_dump($results);
$results = array_merge($results);
//var_dump($results);
$xml = getXml($results);
echo '<pre>' . $xml . '<pre>';
var_dump(debug_backtrace());
示例#7
0
function updateXml($user, $type, $value)
{
    $rs = FALSE;
    $xsltemplate = 'micka2one19139.xsl';
    $recno = -1;
    $uuid = '';
    if ($type == 'uuid' && $value != '') {
        $uuid = $value;
    } elseif ($type == 'recno' && $value > -1) {
        $recno = $value;
        $uuid = getMdHeader($type, $value, 'uuid', array('single'));
        $type = 'uuid';
    }
    if ($type == 'uuid' && $uuid != '') {
        $xml = getXml($user, $uuid, $xsltemplate, 'data');
        if ($xml === FALSE || $xml == '') {
            setMickaLog('$xml === FALSE', 'ERROR', 'micka_lib_xml.php (updateXml)');
        } else {
            $sql = array();
            array_push($sql, "UPDATE md SET pxml=%s WHERE uuid=%s", $xml, $uuid);
            $rs = _executeSql('update', $sql, array('all'));
        }
    }
    return $rs;
}
示例#8
0
 public function hello()
 {
     error_log('MyAPI hello:');
     $myresponse = array('chello world');
     return getXml($myresponse);
 }
/**
 * Generates pagecachexml obj from pages xml
 * @return simpleXmlobj pagecache xml
 */
function generate_pageCacheXml()
{
    debugLog('page cache: re-generated from disk');
    // read in each pages xml file
    $path = GSDATAPAGESPATH;
    $filenames = getXmlFiles($path);
    $cacheXml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
    if (count($filenames) != 0) {
        foreach ($filenames as $file) {
            // load page xml
            $pageXml = getXml($path . $file);
            if (!$pageXml) {
                continue;
            }
            $id = $pageXml->url;
            // page id
            $cacheItems = $cacheXml->addChild('item');
            // $pages->addChild('url', $id);
            $children = $pageXml->children();
            foreach ($children as $item => $itemdata) {
                // add all fields skip content
                if ($item != "content") {
                    $note = $cacheItems->addChild($item);
                    $note->addCData($itemdata);
                }
            }
            pageCacheAddRoutes($id, $cacheItems);
            // removed from xml , redundant
            # $note = $pages->addChild('slug');
            # $note->addCData($id);
            # $note = $pages->addChild('filename');
            # $note->addCData($file);
        }
    }
    return $cacheXml;
}
示例#10
0
exec_action('index-header');
# get page id (url slug) that is being passed via .htaccess mod_rewrite
if (isset($_GET['id'])) {
    $id = str_replace('..', '', $_GET['id']);
    $id = str_replace('/', '', $id);
    $id = lowercase($id);
} else {
    $id = "index";
}
// filter to modify page id request
$id = exec_filter('indexid', $id);
// $_GET['id'] = $id; // support for plugins that are checking get?
$data_index = null;
// apply page data if page id exists
if (isset($pagesArray[$id])) {
    $data_index = getXml(GSDATAPAGESPATH . $id . '.xml');
}
// filter to modify data_index obj
$data_index = exec_filter('data_index', $data_index);
$file_404 = GSDATAOTHERPATH . GSSLUGNOTFOUND . '.xml';
// Legacy DEPRECATED
$user_created_404 = GSDATAPAGESPATH . GSSLUGNOTFOUND . '.xml';
// legacy DEPRECATED
// page not found handling
if (!$data_index) {
    $httpcode = GSSLUGNOTFOUND;
    $data_index = getHttpResponsePage($httpcode);
    exec_action('error-404');
    // Legacy DEPRECATED
    exec_action('pagenotfound');
}
示例#11
0
function efDrawioParserFunction_Render(&$parser, $name = null, $width = null, $height = null)
{
    global $wgUser, $wgLang, $wgTitle, $wgRightsText, $wgOut, $wgArticlePath, $wgScriptPath, $wgEnableUploads;
    // Don't cache pages with drawio on it
    $parser->disableCache();
    # Validate parameters
    $error = '';
    if ($name == null || strlen($name) == 0) {
        $error .= '<br>Please specify a name for your drawio diagram.';
    }
    if ($width != null && (!is_numeric($width) || $width < 1 || $width > 2000)) {
        $error .= '<br>Please specify the width as a number between 1 and 2000 or leave it away.';
    }
    if ($height != null && (!is_numeric($height) || $height < 1 || $height > 2000)) {
        $error .= '<br>Please specify the height as a number between 1 and 2000 or leave it away.';
    }
    if (strlen($error) > 0) {
        $error = '<b>Sorry.</b>' . $error . '<br>' . 'Usage: <code>{{#drawio:<i>drawio_id</i>}}</code><br>' . 'Example: <code>{{#drawio:drawio_id}}</code><br>';
        return array($error, 'isHTML' => true, 'noparse' => true);
    }
    # The parser function itself
    # The input parameters are wikitext with templates expanded
    # The output should be wikitext too, but in this case, it is HTML
    #return array("param1 is $param1 and param2 is $param2", 'isHTML');
    $isProtected = $parser->getTitle()->isProtected();
    # Generate the image HTML as if viewed by a web request
    $image_name = "Drawio_" . $name . ".png";
    $xml_name = "Drawio_" . $name . ".xml";
    $image = wfFindFile($image_name);
    $output = '';
    //.= "xxx " . print_r($image, true) . " xxx";
    if ($image !== false) {
        if ($image != null) {
            $width = $image->getWidth();
            $height = $image->getHeight();
        }
    }
    // render a header
    //$output = '<table><tr><td>';
    if ($wgEnableUploads && !$isProtected && key_exists('drawiotitle', $_POST) && $_POST['drawiotitle'] == $name) {
        // edit the drawio
        $uploadURL = str_replace('$1', 'Special:Drawio', $wgArticlePath);
        $xml = getXml($xml_name);
        // вывод фрэйма
        $output .= '<a name="Drawio" id="Drawio">' . '<script type="text/javascript" src="' . $wgScriptPath . '/extensions/Drawio/js/drawio.js"></script>' . '<link rel="stylesheet" href="' . $wgScriptPath . '/extensions/Drawio/css/drawio.css">' . '<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">' . '<script src="//code.jquery.com/jquery-1.10.2.js"></script>' . '<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>' . '<link rel="stylesheet" href="/resources/demos/style.css">' . '<script>$(function() {$( "#resizable" ).resizable();});</script>' . '<input type="hidden" id="drawio-xml" value="' . htmlspecialchars($xml) . '">' . '<input type="hidden" id="drawio-name" value="' . htmlspecialchars($name) . '">' . '<input type="hidden" id="drawio-upload-url" value="http://' . $_SERVER['HTTP_HOST'] . $uploadURL . '">' . '<input type="hidden" id="drawio-close-url" value="' . $_SERVER['HTTP_REFERER'] . '"/>' . '<div id="resizable" style="width:100%;height:600px">' . '<iframe style="width:100%;height:100%;" class="drawio-editor-iframe" id="drawio-iframe" src="https://www.draw.io/?embed=1&analytics=0&gapi=0&db=0&od=0&proto=json&spin=1"></iframe>' . '</div>' . '<div class="drawio-editor-mask" id="drawio-editor-mask" style="display:none;">' . '<div class="drawio-editor-saving">Saving...<div class="drawio-editor-saving-x" onclick="jQuery(\'drawio-editor-mask\').css(\'display\',\'none\');">x</div></div>' . '</div>' . '</a>';
    } else {
        // $output = '<table><tr><td>';
        $output = '';
        // Retrieve the page object of the image to determine, whether the user may edit it
        $filtered = preg_replace("/[^" . Title::legalChars() . "]|:/", '-', $name);
        $nt = Title::newFromText($filtered);
        if (!is_null($nt)) {
            $nt =& Title::makeTitle(NS_IMAGE, $nt->getDBkey());
        }
        // Determine if the user has permission to edit the image
        $userCanEdit = $wgEnableUploads && !$isProtected && (is_null($image) || $wgUser->isAllowed('reupload'));
        // If the user can edit the image, display an edit link.
        // We do not display the edit link, if the user is already
        // editing a drawio.
        if ($_GET['action'] != "pdfbook" && $userCanEdit && !key_exists('drawiotitle', $_POST)) {
            $formId = 'Form' . rand();
            global $wgUsePathInfo;
            if (is_null($wgTitle)) {
                return;
            }
            if ($wgUsePathInfo) {
                $action = $wgTitle->getLocalURL() . '#Drawio';
            } else {
                $action = $wgTitle->getLocalURL();
            }
            $output .= '<form name="' . $formId . '" method="post" action="' . $action . '">' . '<input type="hidden" name="drawiotitle" value="' . htmlspecialchars($name) . '">' . '<span class="mw-editsection">' . '<a class="noprint" href="javascript:document.' . $formId . '.submit();">[' . wfMsg('edit') . ' ' . $xml_name . ']</a>' . '<noscript><input type="submit" name="submit" value="' . wfMsg('edit') . '"></input></noscript>' . '</span>';
        }
        // render the drawio
        if ($image === false || $image == null) {
            // the drawio does not exist yet, render an empty rectangle
            $output .= '<div style="border:1px solid #000;text-align:center;' . ($width != null ? 'width:' . $width . 'px;' : '') . ($height != null ? 'height:' . $height . 'px;' : '') . '"' . '>' . htmlspecialchars($name) . '</div>';
        } else {
            $output .= '<a href="/index.php/Image:' . $image_name . '">';
            // Note: We append the timestamp of the image to the
            //       view URL as a query string. This way, we ensure,
            //       that the browser always displays the last edited version
            //       of the image
            $output .= '<img src="' . $image->getViewUrl() . '?version=' . $image->nextHistoryLine()->img_timestamp . '" ' . ($width != null ? 'width="' . $width . '" ' : '') . ($height != null ? 'height="' . $height . '" ' : '') . 'alt="Image:' . $name . '" ' . 'title="Image:' . $name . '" ' . ($isImageMap ? 'usemap="#' . $mapId . '" ' : '') . '></img>';
            if (!$isImageMap) {
                $output .= '</a>';
            }
        }
        // If the user can edit the image, display an edit link.
        // We do not display the edit link, if the user is already
        // editing a drawio.
        if ($_GET['action'] != "pdfbook" && $userCanEdit && !key_exists('drawiotitle', $_POST)) {
            $output .= '</form>';
        }
        // $output .= '</tr></td></table>';
    }
    // render a footer
    //
    $return = array($output, 'isHTML' => true, 'noparse' => true);
    return $return;
}
示例#12
0
$xml_password = '******';
$db_host = 'ivoice00.mysql.ukraine.com.ua';
$db_log = 'ivoice00_db';
$db_pass = '******';
$db_name = 'ivoice00_db';
$db_table = 'temperature';
try {
    if (!testInternet()) {
        error_log('no internet connection');
    }
    if (!testInternet($xml_host)) {
        error_log("no connection with {$xml_host}");
    }
    if (!testDBConnect($db_host, $db_log, $db_pass, $db_name)) {
    }
    $xmlData = getXml($xml_url, $xml_login, $xml_password);
    $xmlData = parseXml($xmlData);
    addRecord($xmlData, $db_host, $db_log, $db_pass, $db_name, $db_table);
} catch (Exception $e) {
    unlink($lock_file);
    throw new Exception($e->getMessage());
}
unlink($lock_file);
/*************/
/* FUNCTIONS */
/*************/
function testInternet($host = 'google.com', $port = 80, $auth = array())
{
    $waitTimeoutInSeconds = 30;
    $header = "GET / HTTP/1.0\r\n\r\n";
    $header .= "Accept: text/html\r\n";
示例#13
0
        $synopsis = mysql_real_escape_string($broadcast->programme->short_synopsis);
        $pid = $broadcast->programme->pid;
        $seriespid = $broadcast->programme->programme->pid;
        if (mysql_num_rows(mysql_query("SELECT start FROM {$servicename} WHERE start = '{$start}'"))) {
            echo "Skipping repeat...<br />";
        } else {
            mysql_query("INSERT INTO {$servicename} (start, end, title, subtitle, synopsis, seriespid, pid) VALUES('{$start}', '{$end}', '{$title}', '{$subtitle}', '{$synopsis}', '{$seriespid}', '{$pid}') ") or die(mysql_error());
        }
    }
}
$bbc1xtraurl = "http://www.bbc.co.uk/1xtra/programmes/schedules/today.xml";
$bbc5liveurl = "http://www.bbc.co.uk/5live/programmes/schedules/today.xml";
$bbc6musicurl = "http://www.bbc.co.uk/6music/programmes/schedules/today.xml";
$bbcasiannetworkurl = "http://www.bbc.co.uk/asiannetwork/programmes/schedules/today.xml";
$bbcradio1url = "http://www.bbc.co.uk/radio1/programmes/schedules/england/today.xml";
$bbcradio2url = "http://www.bbc.co.uk/radio2/programmes/schedules/today.xml";
$bbcradio3url = "http://www.bbc.co.uk/radio3/programmes/schedules/today.xml";
$bbcradio4url = "http://www.bbc.co.uk/radio4/programmes/schedules/fm/today.xml";
$bbcradio7url = "http://www.bbc.co.uk/radio7/programmes/schedules/today.xml";
$worldserviceurl = "http://www.bbc.co.uk/worldservice/programmes/schedules/today.xml";
getXml($bbc1xtraurl, 'bbc1xtra');
getXml($bbc5liveurl, '5live');
getXml($bbc6musicurl, '6music');
getXml($bbcasiannetworkurl, 'asiannetwork');
getXml($bbcradio1url, 'radio1');
getXml($bbcradio2url, 'radio2');
getXml($bbcradio3url, 'radio3');
getXml($bbcradio4url, 'radio4');
getXml($bbcradio7url, 'radio7');
getXml($worldserviceurl, 'worldservice');