微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php whmcs hook 重定向你太多次

如何解决php whmcs hook 重定向你太多次

<?PHP
    
        //redirect clients to invoice page if they are overdue. nothing else.
        //provided by https://www.whmcs.guru
        use Illuminate\Database\Capsule\Manager as Capsule;
    
        function check_client_access($vars)
        {
        //what time is it?
        $time = time();
        //are we logged in? If not,then return
        $uid  = $_SESSION['uid'];
        if (empty($uid))
        {
            return;
        }
        $filename = $vars['filename'];
        $displayTitle = $vars['displayTitle'];
        //do we have any unpaid invoices?
        $rows = Capsule::table('tblinvoices')->select('id') ->WHERE ('userid','<=',$uid) ->where('status','=','Unpaid') ->count();
    
        if (empty($rows))
        {
    
            //we have no unpaid invoices. Do not proceed any further
            return;
        }
    
        if (!empty($rows))
        {
            //we have unpaid invoices. Are they overdue?
    
            foreach (Capsule::table('tblinvoices')->select('duedate') ->WHERE ('userid','Unpaid')->get() as $unpaidinvoice) {
    
                $invdue = $unpaidinvoice->duedate;
    
                if (strtotime($invdue) < $time) {
    
                        //all those checks,we're finally where we need to be
                        header('Location: clientarea.PHP?action=invoices'); 
                        
                        exit();
                    }
    
            }
    
        }
    
        }
        add_hook('ClientAreaPage',1,"check_client_access");
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。