<?php

include_once './includes/database/MySQLDatabase.inc.php';

/**
 * This class is responsible for sanitazing the inputs before SQL requests.
 *
 * @author Thomas Schwery <thomas.schwery@epfl.ch>
 */
class InputSanitizer {
    
    /**
     * Sanitize inputs.
     * 
     * @param string $input
     * @return string
     */
    public static function Sanitize($input) {
        $input = stripslashes($input);
        $input = mysql_real_escape_string($input, MySQLDatabase::getConnection());
        return $input;
    }

    /**
     * Sanitize input to return a string in [a-z].
     * 
     * @param string $input
     * @return string
     */
    public static function Username($input) {
        $input = preg_replace("/[^a-z]+/i", "", $input);
        $input = strtolower($input);
        return $input;
    }

    /**
     *
     * @param string $input
     * @return string
     */
    public static function Number($input) {
        $input = preg_replace("/[^0-9]+/i", "", $input);
        return $input;
    }
}
?>
