當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XMLParser::getXMLTree方法代碼示例

本文整理匯總了PHP中XMLParser::getXMLTree方法的典型用法代碼示例。如果您正苦於以下問題:PHP XMLParser::getXMLTree方法的具體用法?PHP XMLParser::getXMLTree怎麽用?PHP XMLParser::getXMLTree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XMLParser的用法示例。


在下文中一共展示了XMLParser::getXMLTree方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: insenz_request

function insenz_request($data, $return = TRUE, $fp = '')
{
    global $insenz, $timestamp, $msglang;
    @(include_once DISCUZ_ROOT . './discuz_version.php');
    $authkey = !empty($insenz['authkey']) ? $insenz['authkey'] : 'Discuz!INSENZ';
    $t_hex = sprintf("%08x", $timestamp);
    $postdata = '<?xml version="1.0" encoding="UTF' . '-8"?><request insenz_version="' . INSENZ_VERSION . '" discuz_version="' . DISCUZ_VERSION . ' - ' . DISCUZ_RELEASE . '">' . $data . '</request>';
    $postdata = insenz_authcode($t_hex . md5($authkey . $postdata . $t_hex) . $postdata, 'ENCODE', $authkey);
    if (!$fp && !($fp = @fsockopen($insenz['host'], 80))) {
        if (!$return) {
            return;
        } else {
            return array('status' => 1, 'data' => $msglang['insenz_connect_failed']);
        }
    }
    $insenz['siteid'] = intval($insenz['siteid']);
    @fwrite($fp, "POST http://{$insenz['url']}/discuz.php?s_id={$insenz['siteid']} HTTP/1.0\r\n");
    @fwrite($fp, "Host: {$insenz['host']}\r\n");
    @fwrite($fp, "Content-Type: file\r\n");
    @fwrite($fp, "Content-Length: " . strlen($postdata) . "\r\n\r\n");
    @fwrite($fp, $postdata);
    if (!$return) {
        @fclose($fp);
        return;
    }
    $res = '';
    $isheader = 1;
    while (!feof($fp)) {
        $buffer = @fgets($fp, 1024);
        if (!$isheader) {
            $res .= $buffer;
        } elseif (trim($buffer) == '') {
            $isheader = 0;
        }
    }
    @fclose($fp);
    if (empty($res)) {
        return array('status' => 1, 'data' => $msglang['insenz_connect_failed']);
    }
    if (!($response = insenz_authcode($res, 'DECODE', $authkey))) {
        return array('status' => 1, 'data' => $msglang['insenz_transport_failed']);
    }
    $checkKey = substr($response, 0, 40);
    $response = substr($response, 40);
    $t_hex = substr($checkKey, 0, 8);
    $t = base_convert($t_hex, 16, 10);
    if (abs($timestamp - $t) > 1200) {
        return array('status' => 1, 'data' => $msglang['insenz_connect_timeout']);
    } elseif ($checkKey != $t_hex . md5($authkey . $response . $t_hex)) {
        return array('status' => 1, 'data' => 'Invalid Key or Data');
    }
    require_once DISCUZ_ROOT . './include/xmlparser.class.php';
    $xmlparse = new XMLParser();
    $xmlparseddata = $xmlparse->getXMLTree($response);
    if (!is_array($xmlparseddata) || !is_array($xmlparseddata['response'])) {
        return array('status' => 1, 'data' => $msglang['insenz_transport_failed']);
    }
    return array('status' => 0, 'data' => $xmlparseddata);
}
開發者ID:jonycookie,項目名稱:projectm2,代碼行數:59,代碼來源:insenz.func.php

示例2: insenz_request

function insenz_request($script, $data)
{
    global $timestamp, $insenz;
    @(include_once DISCUZ_ROOT . './discuz_version.php');
    $authkey = $insenz['authkey'];
    $t_hex = sprintf("%08x", $timestamp);
    $postdata = '<?xml version="1.0" encoding="UTF' . '-8"?><request insenz_version="' . INSENZ_VERSION . '" discuz_version="' . DISCUZ_VERSION . ' - ' . DISCUZ_RELEASE . '">' . $data . '</request>';
    $postdata = insenz_authcode($t_hex . md5($authkey . $postdata . $t_hex) . $postdata, 'ENCODE', $authkey);
    if (!($fp = @fsockopen($insenz['host'], 80))) {
        exit;
    }
    @fwrite($fp, "POST http://{$insenz['url']}/{$script}?s_id={$insenz['siteid']} HTTP/1.0\r\n");
    @fwrite($fp, "Host: {$insenz['host']}\r\n");
    @fwrite($fp, "Content-Type: file\r\n");
    @fwrite($fp, "Content-Length: " . strlen($postdata) . "\r\n\r\n");
    @fwrite($fp, $postdata);
    $res = '';
    $isheader = 1;
    while (!feof($fp)) {
        $buffer = @fgets($fp, 1024);
        if (!$isheader) {
            $res .= $buffer;
        } elseif (trim($buffer) == '') {
            $isheader = 0;
        }
    }
    @fclose($fp);
    if (empty($res)) {
        exit;
    }
    if (!($response = insenz_authcode($res, 'DECODE', $authkey))) {
        exit;
    }
    $checkKey = substr($response, 0, 40);
    $response = substr($response, 40);
    $t_hex = substr($checkKey, 0, 8);
    $t = base_convert($t_hex, 16, 10);
    if (abs($timestamp - $t) > 1200) {
        exit;
    } elseif ($checkKey != $t_hex . md5($authkey . $response . $t_hex)) {
        exit;
    }
    require_once DISCUZ_ROOT . './include/xmlparser.class.php';
    $xmlparse = new XMLParser();
    $xmlparseddata = $xmlparse->getXMLTree($response);
    unset($response);
    if (!is_array($xmlparseddata) || !is_array($xmlparseddata['response'])) {
        exit;
    }
    return $xmlparseddata['response'];
}
開發者ID:BGCX067,項目名稱:f2cont-svn-to-git,代碼行數:51,代碼來源:advcache.php


注:本文中的XMLParser::getXMLTree方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。