<commit_before><?php
    include 'encrypt.php';
    class User {
        public $username;
        public $password;
        public $email;

        public function __construct( $username = '', $password = '', $email = '' ) {
            $this->username = $username;
            $this->password = $password;
            $this->email = $email;
        }

        public function exists() {
            $username = $this->username;
            $res = db_select( 
                'users', 
                array( 'username' ), 
                compact( "username" ) 
            );
            if ( mysql_num_rows( $res ) == 1 ) {
                return true;
            }
            return false;
        }

        public function create() {
            $username = $this->username;
            $password = $<PASSWORD>;
            $email = $this->email;
            if ( strlen( $password ) <= 6 ) {
                throw new ModelValidationException( 'small_pass' );
            }
            if ( !Mail::valid( $email ) ) {
                throw new ModelValidationException( 'mail_notvalid' );
            }
            $array = encrypt( $password );
            $password = $array[ 'hash' ];
            $salt = $array[ 'salt' ];
            $res = db_insert( 
                'users', 
                compact( "username", "password", "email", "salt" )
            );
            if ( $res === false ) {
                // if this query caused an error, then we must have a duplicate username or email
                // check if we have a duplicate username
                // if not, we have a duplicate email
                if ( User::exists( $username ) ) {
                    throw new ModelValidationException( 'user_used' );
                }
                throw new ModelValidationException( 'mail_used' );
            }
            return mysql_insert_id();
        }

        public function delete() {
            $username = $this->username;
            db_delete(
                'users',
                compact( "username" )
            );
        }

        public function update() {
            $username = $this->username;
            $password = $this->password;
            if ( strlen( $password ) <= 6 ) {
                throw new RedirectException( 'index.php?resource=user&method=update&small_pass=yes' );
            }
            $array = encrypt( $password );
            $password = $array[ 'hash' ];
            $salt = $array[ 'salt' ];
            db_update(
                'users',<commit_msg>Does some corrections in the active record<commit_after><?php
    include 'encrypt.php';
    class User {
        public $username;
        public $password;
        public $email;

        public function __construct( $username = '', $password = '', $email = '' ) {
            $this->username = $username;
            $this->password = $password;
            $this->email = $email;
        }

        public function exists() {
            $username = $this->username;
            $res = db_select( 
                'users', 
                array( 'username' ), 
                compact( "username" ) 
            );
            if ( mysql_num_rows( $res ) == 1 ) {
                return true;
            }
            return false;
        }

        public function create() {
            $username = $this->username;
            $password = $<PASSWORD>;
            $email = $this->email;
            if ( strlen( $password ) <= 6 ) {
                throw new ModelValidationException( 'small_pass' );
            }
            if ( !Mail::valid( $email ) ) {
                throw new ModelValidationException( 'mail_notvalid' );
            }
            $array = encrypt( $password );
            $password = $array[ '<PASSWORD>' ];
            $salt = $array[ 'salt' ];
            $res = db_insert( 
                'users', 
                compact( "username", "password", "email", "salt" )
            );
            if ( $res === false ) {
                // if this query caused an error, then we must have a duplicate username or email
                // check if we have a duplicate username
                // if not, we have a duplicate email
                if ( $this->exists() ) {
                    throw new ModelValidationException( 'user_used' );
                }
                throw new ModelValidationException( 'mail_used' );
            }
            return mysql_insert_id();
        }

        public function delete() {
            $username = $this->username;
            db_delete(
                'users',
                compact( "username" )
            );
        }

        public function update() {
            $username = $this->username;
            $password = $this->password;
            if ( strlen( $password ) <= 6 ) {
                throw new RedirectException( 'index.php?resource=user&method=update&small_pass=yes' );
            }
            $array = encrypt( $password );
            $password = $array[ 'hash' ];
            $salt = $array[ 'salt' ];
            db_update(
                'users',
{'fraction_non_alphanumeric': 0.11953752694493436, 'fraction_numerical': 0.0011757789535567313, 'mean_word_length': 1.2887892376681613, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 25, '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': '4892445', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1229, 'n_words': 332}