Example #1
0
/**
 *  encrypt_email($email)
 *  加密邮箱
 * @param  $email 邮箱
 * @return string 加密后的邮箱
 */
function encrypt_email($email)
{
    if (!$email) {
        return $email;
    }
    list($name, $domain) = explode('@', $email);
    $name2 = substr($name, 1);
    if ($name2) {
        aes_encode($name2, C('ENCRYPT_EMAIL'));
        //aes加密
        $name2 = base64_encode($name2);
        //base64转码
        /*特殊字符编码*/
        $encode_map = array('+' => '-', '=' => '_', '/' => '.');
        $name2 = strtr($name2, $encode_map);
    } else {
        $name2 = rand();
        //对于用户名只有一个的邮箱生成随机数掩盖
    }
    return $name[0] . $name2 . '@' . $domain;
}
Example #2
0
 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));
 }