<commit_before><?php

/**
 * Application level Controller
 *
 * This file is application-wide controller file. You can put all
 * application-wide controller-related methods here.
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
App::uses('Controller', 'Controller');

/**
 * Application Controller
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package       app.Controller
 * @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
 */
class AppController extends Controller {

    public $components = array(
        'Cookie',
        'Session',
        'DebugKit.Toolbar',
        //'Security' => array('csrfUseOnce' => false, 'csrfExpires' => '+1 hour'),
        'Auth' => array(
            //'fields' => array('username' => 'username', 'password' => 'password'),
            'loginAction' => array(
                'admin' => false,
                'controller' => 'users',
                'action' => 'login'
            ),
            'loginRedirect' => '/admin/',
            'logoutAction' => array(
                'admin' => false,
                'controller' => 'users',
                'action' => 'logout'
            ),
            'logoutRedirect' => array(
                'admin' => false,
                'controller' => 'users',
                'action' => 'login'
            ),
            'authorize' => array('Controller'),
            'flash' => array(
                'element' => 'auth',
                'key' => 'auth',
                'params' => array()
            )
        )
    );
    public $uses = array('User');

    public function __construct($request = null, $response = null) {
        App::uses('Hurad', 'Lib');
        Hurad::applyHookProperties('Hook.controller_properties', $this);
        parent::__construct($request, $response);
    }

    public function beforeFilter() {
        parent::beforeFilter();

        //Cookie Configuration
        $this->Cookie->name = 'Hurad';

        //Set default theme
        $this->theme = Configure::read('template');

        $this->cookie_check();

        //Load admin layout
        if (isset($this->request->params['admin'])) {
            $this->layout = 'admin';
        }

        //Set logged_in var in all view
        $this->set('logged_in', $this->Auth->loggedIn());

        //Set current_user var in all view
        $this->set('current_user', $this->Auth->user());

        //Set url var in all view
        $this->set('url', $this->request->url);

        //Set current controller
        $this->set('controller', $this->request->params['controller']);

        //Set current action
        $this->set('action', $this->request->params['action']);

        //Set user_cookie var in all view
        $this->set('user_cookie', $this->Cookie->read('Hurad_User'));

        $this->set('isadmin', $this->isAdmin());

        //Load Option model in all controller
        $this->options = Configure::read('options');

        //Use request in model
        $this->{$this->modelClass}->request = $this->request;

        $this->set('themePath', APP . 'View' . DS . 'Themed' . DS . Configure::read('template') . DS);
    }

    private function isAdmin() {
        $admin = FALSE;
        if (!is_null($this->Auth->user()) && $this->Auth->user('role') == 'admin') {
            $admin = TRUE;
        }
        return $admin;
    }

    private function cookie_check() {
        $cookie = $this->Cookie->read('Auth.User');
        if (!is_array($cookie) || $this->Auth->user()) {
            return;
        }
        $user = $this->User->find('first', array(
            'fields' => array('User.username', 'User.password', 'User.role', 'User.email', 'User.url'),
            'conditions' => array(
                'User.username' => $cookie['User']['username'],
                'User.password' => AuthComponent::password($cookie['User']['password'])
            ),
            'recursive' => 0)
        );
        if ($this->Auth->login($user['User'])) {
            $this->Cookie->write('Auth.User', $cookie, true, '+2 weeks');
        } else {
            $this->Cookie->delete('Auth.User');
        }
    }

}
<commit_msg>Change loginRedirect url.<commit_after><?php

/**
 * Application level Controller
 *
 * This file is application-wide controller file. You can put all
 * application-wide controller-related methods here.
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Controller
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
App::uses('Controller', 'Controller');

/**
 * Application Controller
 *
 * Add your application-wide methods in the class below, your controllers
 * will inherit them.
 *
 * @package       app.Controller
 * @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
 */
class AppController extends Controller {

    public $components = array(
        'Cookie',
        'Session',
        'DebugKit.Toolbar',
        //'Security' => array('csrfUseOnce' => false, 'csrfExpires' => '+1 hour'),
        'Auth' => array(
            //'fields' => array('username' => 'username', 'password' => 'password'),
            'loginAction' => array(
                'admin' => false,
                'controller' => 'users',
                'action' => 'login'
            ),
            'loginRedirect' => '/admin',
            'logoutAction' => array(
                'admin' => false,
                'controller' => 'users',
                'action' => 'logout'
            ),
            'logoutRedirect' => array(
                'admin' => false,
                'controller' => 'users',
                'action' => 'login'
            ),
            'authorize' => array('Controller'),
            'flash' => array(
                'element' => 'auth',
                'key' => 'auth',
                'params' => array()
            )
        )
    );
    public $uses = array('User');

    public function __construct($request = null, $response = null) {
        App::uses('Hurad', 'Lib');
        Hurad::applyHookProperties('Hook.controller_properties', $this);
        parent::__construct($request, $response);
    }

    public function beforeFilter() {
        parent::beforeFilter();

        //Cookie Configuration
        $this->Cookie->name = 'Hurad';

        //Set default theme
        $this->theme = Configure::read('template');

        $this->cookie_check();

        //Load admin layout
        if (isset($this->request->params['admin'])) {
            $this->layout = 'admin';
        }

        //Set logged_in var in all view
        $this->set('logged_in', $this->Auth->loggedIn());

        //Set current_user var in all view
        $this->set('current_user', $this->Auth->user());

        //Set url var in all view
        $this->set('url', $this->request->url);

        //Set current controller
        $this->set('controller', $this->request->params['controller']);

        //Set current action
        $this->set('action', $this->request->params['action']);

        //Set user_cookie var in all view
        $this->set('user_cookie', $this->Cookie->read('Hurad_User'));

        $this->set('isadmin', $this->isAdmin());

        //Load Option model in all controller
        $this->options = Configure::read('options');

        //Use request in model
        $this->{$this->modelClass}->request = $this->request;

        $this->set('themePath', APP . 'View' . DS . 'Themed' . DS . Configure::read('template') . DS);
    }

    private function isAdmin() {
        $admin = FALSE;
        if (!is_null($this->Auth->user()) && $this->Auth->user('role') == 'admin') {
            $admin = TRUE;
        }
        return $admin;
    }

    private function cookie_check() {
        $cookie = $this->Cookie->read('Auth.User');
        if (!is_array($cookie) || $this->Auth->user()) {
            return;
        }
        $user = $this->User->find('first', array(
            'fields' => array('User.username', 'User.password', 'User.role', 'User.email', 'User.url'),
            'conditions' => array(
                'User.username' => $cookie['User']['username'],
                'User.password' => AuthComponent::password($cookie['User']['password'])
            ),
            'recursive' => 0)
        );
        if ($this->Auth->login($user['User'])) {
            $this->Cookie->write('Auth.User', $cookie, true, '+2 weeks');
        } else {
            $this->Cookie->delete('Auth.User');
        }
    }

}

{'fraction_non_alphanumeric': 0.171289948317688, 'fraction_numerical': 0.005273705305347537, 'mean_word_length': 2.0875936177140995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 161, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1434988', 'n_tokens_mistral': 2719, 'n_tokens_neox': 2590, 'n_words': 598}