<?php

Class Check
{

	public static function name($str) {
	
		if(preg_match('/^[a-zA-ZÖÜÓŐÚÉÁŰÍöüóőúéáűí\.\d_\- ]{3,20}$/i', $str))
			return true;

		return false;
	}

	public static function link($str) {
	
		if(!preg_match('/^[a-z0-9\d_\-]{3,20}$/i', $str))
			return true;

		return false;
	}
	
	public static function email($str) {
	
		if(preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/',$str) && strlen($str)<51) 
			return true;

		return false;
	}

	public static function password($str) {
	
		if(strlen($str)<6 || strlen($str)>20)
			return true;

		return false;
	}

	public static function domain($str) {
	
		if (filter_var(gethostbyname($str), FILTER_VALIDATE_IP))
			return true;

		return false;
	}

	public static function title($title) {
		if (strlen($title) > 0 && strlen($title) < 250)
			return true;
		return false;
	}

	public static function slug($str) {
	
		if(preg_match('/^[a-zA-Z\d_\- ]{1,100}$/i', $str))
			return true;

		return false;
	}

	public static function url($url, $lazy = false) {
		if (($lazy && !$url) || !filter_var($url, FILTER_VALIDATE_URL) === false) return true;
		return false;
	}

}