首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场

Whmcs汽车
EN

Stack Overflow用户
提问于 2016-11-25 12:07:48
回答 1查看 644关注 0票数 0

我们目前正在使用汽车业,我们有下面的方法来自动登录用户使用那里的电子邮件,问题是当电子邮件有一个加号,它不会自动登录。

代码语言:javascript
运行
复制
/**
 * @param $email Clients Email Address to Login
 * @param string $goto is a url endpoint where you want to redirect the user
 */
public static function autoLoginUser( $email, $goto = 'index.php?m=dashboard' )
{
    global $CONFIG;

    /**
     * Define WHMCS url and AuthKey from confguration.php
     */
    $whmcsurl = $CONFIG['SystemURL'] . "/dologin.php";
    $autoauthkey = "Our auth key is here"; //$autoauthkey from configuration.php

    $timestamp = time(); //Get current timestamp
    $hash = sha1($email . $timestamp . $autoauthkey); //Generate Hash

    /**
     * Generate AutoAuth URL & Redirect
     */
    $url = $whmcsurl . "?email=$email&timestamp=$timestamp&hash=$hash&goto=" . urlencode($goto);
    header("Location: $url");
    exit;
}

以前有人试过吗?有一个正常的电子邮件地址工作完美,但在包含加号的电子邮件,它不会自动记录用户。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-08 14:22:25

我不知道为什么whmcs没有记录它,但是我们所做的工作是像下面的代码那样对电子邮件进行编码

代码语言:javascript
运行
复制
/**
 * @param $email Clients Email Address to Login
 * @param string $goto is a url endpoint where you want to redirect the user
 */
public static function autoLoginUser( $email, $goto = 'index.php?m=dashboard' )
{
    global $CONFIG;

    /**
     * Define WHMCS url and AuthKey from confguration.php
     */
    $whmcsurl = $CONFIG['SystemURL'] . "/dologin.php";
    $autoauthkey = "Our auth key is here"; //$autoauthkey from configuration.php

    $timestamp = time(); //Get current timestamp
    $hash = sha1($email . $timestamp . $autoauthkey); //Generate Hash
    $email = 
    /**
     * Generate AutoAuth URL & Redirect
     */
    $url = $whmcsurl . "?email=".urlencode($email)."&timestamp=$timestamp&hash=$hash&goto=" . urlencode($goto);
    header("Location: $url");
    exit;
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40804725

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档