当前位置: 首页>>代码示例>>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;未经允许,请勿转载。