用户登录注册(安全)(常规、FB、google、paypal) 实战

/* 用户登录界面 */
elseif ($action == 'login')
{
    if($_SESSION['user_id'])
    {
        ecs_header("Location:user.php ");
        exit;
    }
    $smarty->assign('no_need_footer', 1);//不需要页脚
    $smarty->display('user_login.dwt');
}

/**

 *ecs_header这个是ecshop里面一个页面跳转的自定义函数,自定义 header 函数,用于过滤可能出现的安全隐患具体在includes下lib_base.php

 * 自定义 header 函数,用于过滤可能出现的安全隐患
 *
 * @param   string  string  内容
 *
 * @return  void
 **/
function ecs_header($string, $replace = true, $http_response_code = 0)
{
    if (strpos($string, '../upgrade/index.php') === 0)
    {
        echo '<script type="text/javascript">window.location.href="' . $string . '";</script>';
    }
    $string = str_replace(array(" ", " "), array('', ''), $string);
    if (preg_match('/^s*location:/is', $string))
    {
        @header($string . " ", $replace);
        exit();
    }
    if (empty($http_response_code) || PHP_VERSION < '4.3')
    {
        @header($string, $replace);
    }
    else
    {
        @header($string, $replace, $http_response_code);
    }
}

/**

 * 中间串讲:window.location.herf 动态输出跳转

 * javascript中的location.href有很多种用法,主要如下。

 * self.location.href="/url" 当前页面打开URL页面
 * location.href="/url" 当前页面打开URL页面
 * windows.location.href="/url" 当前页面打开URL页面,前面三个用法相同。
 * this.location.href="/url" 当前页面打开URL页面
*parent.location.href="/url" 在父页面打开新页面
*top.location.href="/url" 在顶层页面打开新页面

*如果页面中自定义了frame,那么可将parent self top换为自定义frame的名称,效果是在frame窗口打开url地址

*此外,window.location.href=window.location.href;和 window.location.Reload()和都是刷新当前页面。区别在于是否有提交数据。当有提交数据 时,window.location.Reload();会提示是否提交,window.location.href=window.location.href; 则是向指定的url提交数据

 * window.location.herf 和 window.open();容易混淆; * 一个刷新页面一个不刷新

**/

原文地址:https://www.cnblogs.com/jasonxu19900827/p/5368327.html