<commit_before><?php
    class user {
        public $loggedIn = false;
        public $admin = false;

        public function __construct() {
            //Check if user is logging in
            if (isset($_GET['logout'])) {
                $this->logout();
            }

            //Check if user is registering in
            if (isset($_GET['register'])) {
                $this->reg_error = $this->register();
            }

            // Check if user is logged in
            if (isset($_SESSION['uid'])) {
                // Quick hijacking check
                if ($_SESSION['ip'] !== $_SERVER['REMOTE_ADDR'] || $_SESSION['user_agent_id'] !== md5($_SERVER['HTTP_USER_AGENT'])) {
                    $this->logout();
                } else {        
                    $this->loggedIn = true;
                    $this->uid = $_SESSION['uid'];
                    $this->get_details();
                }
            } else {
                //Check if user is logging in
                if (isset($_GET['login']) && isset($_POST['username']) && isset($_POST['password'])) {
                    $user = $_POST['username'];
                    $pass = $_POST['password'];
                    $this->login($user, $pass);
                }
            }

            //Login, register or connect via facebook
            if (isset($_GET['facebook'])) {
                if (isset($_GET['code'])) {
                    $this->oauth('facebook', $_GET['code']);
                } else if ($_GET['error_code'] == '200') {
                    $this->login_error = 'Request declined';
                    $this->connect_msg = 'Request declined';
                }
            }
        }

        private function get_details() {
            global $db, $app;
            $st = $db->prepare('SELECT username, score, status, oauth_id as connected,
                    IFNULL(site_priv, 1) as site_priv, IFNULL(pm_priv, 1) as pm_priv, IFNULL(forum_priv, 1) as forum_priv, IFNULL(pub_priv, 0) as pub_priv
                    FROM users u
                    LEFT JOIN users_priv priv
                    ON u.user_id = priv.user_id
                    WHERE u.user_id = :user_id');
            $st->execute(array(':user_id' => $this->uid));<commit_msg>User connected returns true even if oauth_id is set to 0<commit_after><?php
    class user {
        public $loggedIn = false;
        public $admin = false;

        public function __construct() {
            //Check if user is logging in
            if (isset($_GET['logout'])) {
                $this->logout();
            }

            //Check if user is registering in
            if (isset($_GET['register'])) {
                $this->reg_error = $this->register();
            }

            // Check if user is logged in
            if (isset($_SESSION['uid'])) {
                // Quick hijacking check
                if ($_SESSION['ip'] !== $_SERVER['REMOTE_ADDR'] || $_SESSION['user_agent_id'] !== md5($_SERVER['HTTP_USER_AGENT'])) {
                    $this->logout();
                } else {        
                    $this->loggedIn = true;
                    $this->uid = $_SESSION['uid'];
                    $this->get_details();
                }
            } else {
                //Check if user is logging in
                if (isset($_GET['login']) && isset($_POST['username']) && isset($_POST['password'])) {
                    $user = $_POST['username'];
                    $pass = $_POST['password'];
                    $this->login($user, $pass);
                }
            }

            //Login, register or connect via facebook
            if (isset($_GET['facebook'])) {
                if (isset($_GET['code'])) {
                    $this->oauth('facebook', $_GET['code']);
                } else if ($_GET['error_code'] == '200') {
                    $this->login_error = 'Request declined';
                    $this->connect_msg = 'Request declined';
                }
            }
        }

        private function get_details() {
            global $db, $app;
            $st = $db->prepare('SELECT username, score, status, (oauth_id IS NOT NULL) as connected,
                    IFNULL(site_priv, 1) as site_priv, IFNULL(pm_priv, 1) as pm_priv, IFNULL(forum_priv, 1) as forum_priv, IFNULL(pub_priv, 0) as pub_priv
                    FROM users u
                    LEFT JOIN users_priv priv
                    ON u.user_id = priv.user_id
                    WHERE u.user_id = :user_id');
            $st->execute(array(':user_id' => $this->uid));
{'fraction_non_alphanumeric': 0.13975903614457832, 'fraction_numerical': 0.003723986856516977, 'mean_word_length': 1.380604796663191, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4292006', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1152, 'n_words': 288}