public function openPlatformTestCase() { global $_GPC; $post = file_get_contents('php://input'); WeUtility::logging('platform-test-message', $post); $encode_message = $this->xmlExtract($post); $message = aes_decode($encode_message['encrypt'], $this->encodingaeskey); $message = $this->parse($message); $response = array('ToUserName' => $message['from'], 'FromUserName' => $message['to'], 'CreateTime' => TIMESTAMP, 'MsgId' => TIMESTAMP, 'MsgType' => 'text'); if ($message['content'] == 'TESTCOMPONENT_MSG_TYPE_TEXT') { $response['Content'] = 'TESTCOMPONENT_MSG_TYPE_TEXT_callback'; } if ($message['msgtype'] == 'event') { $response['Content'] = $message['event'] . 'from_callback'; } if (strexists($message['content'], 'QUERY_AUTH_CODE')) { list($sufixx, $authcode) = explode(':', $message['content']); $auth_info = $this->getAuthInfo($authcode); WeUtility::logging('platform-test-send-message', var_export($auth_info, true)); $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . $auth_info['authorization_info']['authorizer_access_token']; $data = array('touser' => $message['from'], 'msgtype' => 'text', 'text' => array('content' => $authcode . '_from_api')); $response = ihttp_request($url, urldecode(json_encode($data))); exit(''); } $xml = array('Nonce' => $_GPC['nonce'], 'TimeStamp' => $_GPC['timestamp'], 'Encrypt' => aes_encode(array2xml($response), $this->encodingaeskey, $this->appid)); $signature = array($xml['Encrypt'], $this->token, $_GPC['timestamp'], $_GPC['nonce']); sort($signature, SORT_STRING); $signature = implode($signature); $xml['MsgSignature'] = sha1($signature); exit(array2xml($xml)); }
/** * decrypt_email(&$email) * 解密邮箱 * @param $email 邮箱 * @return string 解密后的邮箱 */ function decrypt_email(&$email) { if (!$email) { return $email; } list($name, $domain) = explode('@', $email); $name2 = substr($name, 1); if (strlen($name2) < 24) { $name2 = ''; } else { /*解密 并base64还原*/ $decode_map = array('-' => '+', '_' => '=', '.' => '/'); $name2 = strtr($name2, $decode_map); $name2 = base64_decode($name2); aes_decode($name2, C('ENCRYPT_EMAIL')); //aes解解码 } $email = $name[0] . trim($name2) . '@' . $domain; return $email; }
pdo_insert('account_wechats', $subaccount_insert); if (is_error($acid)) { message('授权登录新建公众号失败,请重试', url('account/display'), 'error'); } if (empty($_W['isfounder'])) { pdo_insert('uni_account_users', array('uniacid' => $uniacid, 'uid' => $_W['uid'], 'role' => 'owner')); } pdo_update('uni_account', array('default_acid' => $acid), array('uniacid' => $uniacid)); $headimg = ihttp_request($account_info['authorizer_info']['head_img']); $qrcode = ihttp_request($account_info['authorizer_info']['qrcode_url']); file_put_contents(IA_ROOT . '/attachment/headimg_' . $acid . '.jpg', $headimg['content']); file_put_contents(IA_ROOT . '/attachment/qrcode_' . $acid . '.jpg', $qrcode['content']); message('授权登录成功', url('account/display'), 'success'); } elseif ($do == 'ticket') { $post = file_get_contents('php://input'); WeUtility::logging('debug', 'account-ticket' . $post); $encode_ticket = isimplexml_load_string($post, 'SimpleXMLElement', LIBXML_NOCDATA); if (empty($post) || empty($encode_ticket)) { exit('fail'); } $decode_ticket = aes_decode($encode_ticket->Encrypt, $setting['platform']['encodingaeskey']); $ticket_xml = isimplexml_load_string($decode_ticket, 'SimpleXMLElement', LIBXML_NOCDATA); if (empty($ticket_xml)) { exit('fail'); } cache_write('account:ticket', strval($ticket_xml->ComponentVerifyTicket)); exit('success'); } elseif ($do == 'test') { $authurl = $account_platform->getAuthLoginUrl(); echo '<a href="' . $authurl . '%26test=1"><img src="https://open.weixin.qq.com/zh_CN/htmledition/res/assets/res-design-download/icon_button3_2.png" /></a>'; }