<commit_before><?php
    include 'encrypt.php';
    class User {
        public function exists( $username ) {
            $res = db_select( 
                'users', 
                array( 'username' ), 
                compact( "username" ) 
            );
            if ( mysql_num_rows( $res ) == 1 ) {
                return true;
            }
            return false;
        }

        public function create( $username, $password, $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 ( User::exists( $username ) ) {
                    throw new ModelValidationException( 'user_used' );
                }
                throw new ModelValidationException( 'mail_used' );
            }
            return mysql_insert_id();
        }

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

        public function update( $username, $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>Add some comments<commit_after><?php
    include 'encrypt.php';
    class User {
        public function exists( $username ) {
            $res = db_select( 
                'users', 
                array( 'username' ), 
                compact( "username" ) 
            );
            if ( mysql_num_rows( $res ) == 1 ) {
                return true;
            }
            return false;
        }

        public function create( $username, $password, $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 ( User::exists( $username ) ) {
                    throw new ModelValidationException( 'user_used' );
                }
                throw new ModelValidationException( 'mail_used' );
            }
            return mysql_insert_id();
        }

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

        public function update( $username, $password ) {
            if ( strlen( $password ) <= 6 ) {
                throw new RedirectException( 'index.php?resource=user&method=update&small_pass=yes' );
            }
            $array = encrypt( $password );
            $password = $array[ '<PASSWORD>' ];
            $salt = $array[ 'salt' ];
            db_update(
                'users',
{'fraction_non_alphanumeric': 0.1168631471040492, 'fraction_numerical': 0.0015376729882111738, 'mean_word_length': 1.2705061082024434, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, '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': '181961', 'n_tokens_mistral': 1020, 'n_tokens_neox': 948, 'n_words': 250}