<commit_before><?php
    require_once("signal.class.php");
	require_once("exception.class.php");
    include("rds.php");

    class auth
    {
        public static function login($username, $password) { 
			return self::run(function() use ($username, $password) {
				return auth::REAL_login($username, $password);
			});
		}
        public static function start_register($email) {
			return self::run(function() use ($email) {
				return auth::start_real_register($email);
			});
		}
        public static function register($username, $password, $key) {
			return self::run(function() use ($username, $password, $key) {
				return auth::REAL_register($username, $password, $key);
			});
		}

		public static function check_auth($authcode) {
			return self::run(function() use ($authcode) {
				return auth::GET_verify($authcode);
			});
		}
		
		public static function logout($authcode) {
			return self::run(function() use ($authcode) {
				return auth::GET_logout($authcode);
			});
		}



        /*
			Private methods

			All functions are ran through the run() method
			This ensures consistent error handling

		*/

		private static function run($function) {
			try {
				return $function();
			} catch(DBConnectException $e) {
				return Signal::dbConnectionError();
			} catch(AuthException $e) {
				return Signal::authError();
			} catch(IMGException $e) {
				return Signal::imgError()->setMessage($e->getMessage());
			} catch(Exception $e) {
				return Signal::error()->setMessage($e->getMessage());
			}
		}

        public static function getConnection() {
			include("rds.php");
			$db = new mysqli($dbhost, $username, $password, $dbname);

			if($db->connect_error)
				throw new DBConnectException();
			return $db;
		}

        private static function hash($value) {
			return hash("sha256", $value);<commit_msg>db connect error<commit_after><?php
    require_once("signal.class.php");
	require_once("exception.class.php");
    include("rds.php");

    class auth
    {
        public static function login($username, $password) { 
			return self::run(function() use ($username, $password) {
				return auth::REAL_login($username, $password);
			});
		}
        public static function start_register($email) {
			return self::run(function() use ($email) {
				return auth::start_real_register($email);
			});
		}
        public static function register($username, $password, $key) {
			return self::run(function() use ($username, $password, $key) {
				return auth::REAL_register($username, $password, $key);
			});
		}

		public static function check_auth($authcode) {
			return self::run(function() use ($authcode) {
				return auth::GET_verify($authcode);
			});
		}
		
		public static function logout($authcode) {
			return self::run(function() use ($authcode) {
				return auth::GET_logout($authcode);
			});
		}



        /*
			Private methods

			All functions are ran through the run() method
			This ensures consistent error handling

		*/

		private static function run($function) {
			try {
				return $function();
			} catch(DBConnectException $e) {
				return Signal::dbConnectionError();
			} catch(AuthException $e) {
				return Signal::authError();
			} catch(IMGException $e) {
				return Signal::imgError()->setMessage($e->getMessage());
			} catch(Exception $e) {
				return Signal::error()->setMessage($e->getMessage());
			}
		}

        public static function getConnection() {
			$dbhost = $_SERVER['RDS_HOSTNAME'];
			$dbport = $_SERVER['RDS_PORT'];
			$dbname = "alumni";
		
			$username = $_SERVER['RDS_USERNAME'];
			$password = $_SERVER['RDS_PASSWORD'];
			$db = new mysqli($dbhost, $username, $password, $dbname);

			if($db->connect_errno){
				throw new DBConnectException($db->connect_error);
			}
			return $db;
		}

        private static function hash($value) {
			return hash("sha256", $value);
{'fraction_non_alphanumeric': 0.15316718587746625, 'fraction_numerical': 0.001557632398753894, 'mean_word_length': 3.6533816425120773, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '6363894', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1138, 'n_words': 264}