Example #1
0
 public static function xmlToArray($xml, $isNormal = false)
 {
     $xmlParser = new XMLParse($isNormal);
     $data = $xmlParser->parse($xml);
     $xmlParser->destruct();
     return $data;
 }
Example #2
0
 public function decryptMsg($msgSignature, $timestamp = NULL, $nonce, $postData, &$msg)
 {
     if (strlen($this->encodingAesKey) != 43) {
         return ErrorCode::$IllegalAesKey;
     }
     $pc = new Prpcrypt($this->encodingAesKey);
     $xmlparse = new XMLParse();
     $array = $xmlparse->extract($postData);
     $ret = $array[0];
     if ($ret != 0) {
         return $ret;
     }
     if ($timestamp == NULL) {
         $timestamp = time();
     }
     $encrypt = $array[1];
     $touser_name = $array[2];
     $sha1 = new SHA1();
     $array = $sha1->getSHA1($this->token, $timestamp, $nonce, $encrypt);
     $ret = $array[0];
     if ($ret != 0) {
         return $ret;
     }
     $signature = $array[1];
     if ($signature != $msgSignature) {
         return ErrorCode::$ValidateSignatureError;
     }
     $result = $pc->decrypt($encrypt, $this->appId);
     if ($result[0] != 0) {
         return $result[0];
     }
     $msg = $result[1];
     return ErrorCode::$OK;
 }
Example #3
0
/**
 * List the installed language packs. 
 * @return 
 */
function show_packs()
{
    $frm = e107::getForm();
    $ns = e107::getRender();
    $tp = e107::getParser();
    if (is_readable(e_ADMIN . "ver.php")) {
        include e_ADMIN . "ver.php";
        list($ver, $tmp) = explode(" ", $e107info['e107_version']);
    }
    $lans = getLanList();
    $release_diz = defined("LANG_LAN_30") ? LANG_LAN_30 : "Release Date";
    $compat_diz = defined("LANG_LAN_31") ? LANG_LAN_31 : "Compatibility";
    $lan_pleasewait = deftrue('LAN_PLEASEWAIT') ? $tp->toJS(LAN_PLEASEWAIT) : "Please Wait";
    $lan_displayerrors = deftrue('LANG_LAN_33') ? LANG_LAN_33 : "Display only errors during verification";
    $text = "<form id='lancheck' method='post' action='" . e_SELF . "?tools'>\n\t\t\t<table class='table table-striped'>";
    $text .= "<thead>\n\t\t<tr>\n\t\t<th>" . ADLAN_132 . "</th>\n\t\t<th>" . $release_diz . "</th>\t\t\n\t\t<th>" . $compat_diz . "</th>\n\t\t<th>" . LAN_STATUS . "</td>\n\t\t<th style='width:25%;white-space:nowrap'>" . LAN_OPTIONS . "</td>\n\t\t</tr>\n\t\t</thead>\n\t\t";
    require_once e_HANDLER . "xml_class.php";
    $xm = new XMLParse();
    foreach ($lans as $language) {
        if ($language == "English") {
            continue;
        }
        $metaFile = e_LANGUAGEDIR . $language . "/" . $language . ".xml";
        if (is_readable($metaFile)) {
            $rawData = file_get_contents($metaFile);
            if ($rawData) {
                $array = $xm->parse($rawData);
                $value = $array['e107Language']['attributes'];
            } else {
                $value = array('date' => "&nbsp;", 'compatibility' => '&nbsp;');
            }
        } else {
            $value = array('date' => "&nbsp;", 'compatibility' => '&nbsp;');
        }
        $errFound = isset($_SESSION['lancheck'][$language]['total']) && $_SESSION['lancheck'][$language]['total'] > 0 ? TRUE : FALSE;
        $text .= "<tr>\n\t\t\t<td >" . $language . "</td>\n\t\t\t<td>" . $value['date'] . "</td>\n\t\t\t<td>" . $value['compatibility'] . "</td>\n\t\t\t<td>" . ($ver != $value['compatibility'] || $errFound ? ADMIN_FALSE_ICON : ADMIN_TRUE_ICON) . "</td>\n\t\t\t<td><input type='submit' name='language_sel[{$language}]' value=\"" . LAN_CHECK_2 . "\" class='btn btn-primary' />\n\t\t\t<input type='submit' name='ziplang[{$language}]' value=\"" . LANG_LAN_23 . "\" class='button' onclick=\"this.value = '" . $lan_pleasewait . "'\" /></td>\t\n\t\t\t</tr>";
    }
    $text .= "\n\t\t\n\t\t</tr></table>";
    $text .= "<table class='table table-striped'>";
    $text .= "<thead><tr><th>" . LAN_OPTIONS . "</th></tr></thead><tbody>";
    $srch = array("[", "]");
    $repl = array("<a rel='external' href='http://e107.org/content/About-Us:The-Team#translation-team'>", "</a>");
    $diz = deftrue("LANG_LAN_28") ? LANG_LAN_28 : "Check this box if you're an [e107 certified translator].";
    $checked = varset($_COOKIE['e107_certified']) == 1 ? true : false;
    $text .= "<tr><td>";
    $text .= $frm->checkbox('contribute_pack', 1, $checked, array('label' => str_replace($srch, $repl, $diz)));
    $text .= "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td>";
    $echecked = varset($_SESSION['lancheck-errors-only']) == 1 ? true : false;
    $text .= $frm->checkbox('errorsonly', 1, $echecked, array('label' => $lan_displayerrors));
    $text .= " </td>\n\t\t\n\t\t</tr>";
    //		$text .= "
    //		<tr>
    //		<td>".$frm->checkbox('non-core-plugs-themes',1,$echecked,array('label'=>$lan_displayerrors))."</td>
    //		</tr>
    //		";
    $text .= "</tbody></table>";
    $text .= "</form>";
    $text .= "<div class='smalltext center' style='padding-top:50px'>" . LANG_LAN_AGR . "</div>";
    $ns->tablerender(ADLAN_132 . SEP . LANG_LAN_32, $text);
    return;
}
Example #4
0
 /**
  * 检验消息的真实性,并且获取解密后的明文.
  * <ol>
  *    <li>利用收到的密文生成安全签名,进行签名验证</li>
  *    <li>若验证通过,则提取xml中的加密消息</li>
  *    <li>对消息进行解密</li>
  * </ol>
  *
  * @param $msgSignature string 签名串,对应URL参数的msg_signature
  * @param $timestamp string 时间戳 对应URL参数的timestamp
  * @param $nonce string 随机串,对应URL参数的nonce
  * @param $postData string 密文,对应POST请求的数据
  * @param &$msg string 解密后的原文,当return返回0时有效
  *
  * @return int 成功0,失败返回对应的错误码
  */
 public function DecryptMsg($sMsgSignature, $sTimeStamp = null, $sNonce, $sPostData, &$data)
 {
     if (strlen($this->m_sEncodingAesKey) != 43) {
         return ErrorCode::$IllegalAesKey;
     }
     $pc = new Prpcrypt($this->m_sEncodingAesKey);
     //提取密文
     $xmlparse = new XMLParse();
     $array = $xmlparse->extract($sPostData);
     $ret = $array[0];
     if ($ret != 0) {
         return $ret;
     }
     if ($sTimeStamp == null) {
         $sTimeStamp = time();
     }
     $encrypt = $array[1];
     $touser_name = $array[2];
     //验证安全签名
     $sha1 = new SHA1();
     $array = $sha1->getSHA1($this->m_sToken, $sTimeStamp, $sNonce, $encrypt);
     $ret = $array[0];
     if ($ret != 0) {
         return $ret;
     }
     $signature = $array[1];
     if ($signature != $sMsgSignature) {
         return ErrorCode::$ValidateSignatureError;
     }
     $result = $pc->decrypt($encrypt, $this->m_sCorpid);
     if ($result[0] != 0) {
         return $result[0];
     }
     $sMsg = $result[1];
     $data = array();
     $xml = simplexml_load_string($sMsg, 'SimpleXMLElement', LIBXML_NOCDATA);
     $data = api_json_decode(api_json_encode($xml), TRUE);
     //        if($xml){
     //			foreach ($xml as $key => $value) {
     //				$data[$key] = mb_convert_encoding(strval($value),"GBK","UTF-8");;
     //			}
     //        }
     return ErrorCode::$OK;
 }
Example #5
0
 /**
  * 检验消息的真实性,并且获取解密后的明文.
  * <ol>
  *    <li>利用收到的密文生成安全签名,进行签名验证</li>
  *    <li>若验证通过,则提取xml中的加密消息</li>
  *    <li>对消息进行解密</li>
  * </ol>
  *
  * @param $msgSignature string 签名串,对应URL参数的msg_signature
  * @param $timestamp string 时间戳 对应URL参数的timestamp
  * @param $nonce string 随机串,对应URL参数的nonce
  * @param $postData string 密文,对应POST请求的数据
  * @param &$msg string 解密后的原文,当return返回0时有效
  *
  * @return int 成功0,失败返回对应的错误码
  */
 public function DecryptMsg($sMsgSignature, $sTimeStamp = null, $sNonce, $sPostData, &$sMsg)
 {
     if (strlen($this->m_sEncodingAesKey) != 43) {
         return ErrorCode::$IllegalAesKey;
     }
     $pc = new Prpcrypt($this->m_sEncodingAesKey);
     //提取密文
     $xmlparse = new XMLParse();
     $array = $xmlparse->extract($sPostData);
     $ret = $array[0];
     if ($ret != 0) {
         return $ret;
     }
     if ($sTimeStamp == null) {
         $sTimeStamp = time();
     }
     $encrypt = $array[1];
     $touser_name = $array[2];
     //验证安全签名
     $sha1 = new SHA1();
     $array = $sha1->getSHA1($this->m_sToken, $sTimeStamp, $sNonce, $encrypt);
     $ret = $array[0];
     if ($ret != 0) {
         return $ret;
     }
     $signature = $array[1];
     if ($signature != $sMsgSignature) {
         return ErrorCode::$ValidateSignatureError;
     }
     $result = $pc->decrypt($encrypt, $this->m_sCorpid);
     if ($result[0] != 0) {
         return $result[0];
     }
     $sMsg = $result[1];
     return ErrorCode::$OK;
 }
Example #6
0
 public function loadXML($file, $update = false)
 {
     XMLParse::loadXML($file, $this, $update);
 }
Example #7
0
 /**
  * Export an RSD (Really Simple Discovery) schema.
  *
  * @access public
  * @return array
  */
 public function rsd()
 {
     $apiArray = array('action' => 'rsd');
     $OSres = $this->get_http()->get($this->get_base_url(), $apiArray);
     return $OSres === false || is_null($OSres) ? false : XMLParse::load($OSres);
 }