编辑core.php后CakePHP坏了

时间:2015-06-26 03:10:33

标签: php cakephp

我正在使用旧版本的cakePHP项目,配置文件说1.1.18.5850。

我最初遇到路由问题,只有我的索引“/”路由工作,其他一切都坏了。为了查看发生了什么,我更改了core.php文件中的以下行

define('DEBUG',2);

此时一切都停止了。我尝试将其设置为0,但这不起作用。

现在,它似乎向我发送了一个名为default的视图,该视图会引发致命错误。我修复了错误,但我看到的只是空白屏幕,没有任何内容加载。

它应该访问的路径是

$Route->connect('/', array('controller' => 'schools', 'action' => 'login'));

反过来又转到学校控制器

function login() {
        if($this->is_logged==='true') {
            if($this->is_admin==='true') {
                $this->redirect('/admin/');
                exit;
            } elseif(!empty($this->school_info)){   
                $this->redirect('schools/welcome?page');
                exit;
            } 
            elseif(!empty($this->owner_info)){  
                $this->redirect('schools/welcome?page');
                exit;
            } 
        }
        if(!empty($this->params['form'])) {
            $email = $this->clean->go($this->params['form']['username']);
            $password = $this->clean->go($this->params['form']['password']);
            $encrypted = md5($password);

            $owner = $this->Owner->find("`Owner`.`email` = '$email' AND `Owner`.`password` = '$encrypted'");
            $user = $this->User->find("`User`.`email` = '$email' AND `User`.`password` = '$encrypted' AND `User`.`removed` = 0");

            if(!empty($owner)) {
                $this->_writeAuth($owner['Owner']['email'],$owner['Owner']['password']);
                $this->redirect('schools/welcome?page');
                exit;
            }elseif(!empty($user)&&$user['User']['user_type']==='Admin')
            {
                $email = $this->clean->go($this->params['form']['username']);
                $password = $this->clean->go($this->params['form']['password']);
                $encrypted = $this->User->encode($password);

                //$user = $this->User->find("`User`.`email` = '$email' AND `User`.`password` = '$encrypted' AND `User`.`removed` = 0");
                if(!empty($user)) {
                    $this->_writeAuth($user['User']['email'], $user['User']['password']);
                    $this->redirect('/admin/');
                    exit;
                }
            }
            else 
            {   
                $this->flashErrorAndGo('Invalid username or password.');
                $this->redirect('schools/login/');
                exit;
            }
        }
        //$this->render('login','login');
    }

我尝试过做

function login() {die;}

但它没有做任何事情,仍然将视图呈现为“默认”

我对蛋糕并不太熟悉,所以我一直在试图弄清楚发生了什么。一切都工作正常,直到我在core.php中进行了更改,但我将其更改回来,所以我不知道为什么问题仍在继续。任何帮助,将不胜感激。

0 个答案:

没有答案