<?php
##
## SENTRY_CLASS.PHP
## Checking all user input
## By Dave Bronckers

class Sentry{

    ## SENTRY CONFIGURATION
    ## 1 = enabled
    ## 0 = disabled

    private $enable = 1;



    ## NO EDITTING BEHIND
    ## THIS COMMENT

    public function __construct(){

        if( $this->enable == 0){

            $this->__destruct();
        }

    }
    public function validateNum( $input ){

        if( !is_numeric( $input )){

            throw new Exception( 'Invoer is niet numeriek.' );

        }
    }
    public function validateMix( $input ){

        if(!preg_match( '/^[a-z0-9]+$/', $input)){

            throw new Exception( 'Gebruikersgegevens zijn niet correct.' );

        }

    }
    public function validateString( $input ){

        if(!preg_match( '/^[a-z0-9]+$/', $input)){

            throw new Exception( 'Invoer is niet alfabetisch.' );

        }

    }
    public function validateEmail( $input ){

        if(!preg_match( '/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/', $input )){

            throw new Exception( 'Invoer bevat verboden tekens.');

        }
    }
    public function validateMinCharCount( $input, $limit ){

        if(strlen($input) < $limit){

            throw new Exception( 'Invoer bevat onvoldoende tekens. Minimaal ' . $limit . ' tekens vereist.');

        }
    }
    public function validateMaxCharCount( $input, $limit ){

        if(strlen($input) > $limit){

            throw new Exception( 'Invoer bevat teveel tekens. Maximaal ' . $limit . ' tekens toegestaan.');

        }
    }
}
?>