You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.6 KiB
53 lines
1.6 KiB
<?php
|
|
|
|
class Validation
|
|
{
|
|
public function ValidateSet($var) :bool{
|
|
if (isset($var)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function ValidateNotEmpty($var) :bool{
|
|
if (empty($var)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function ValidateURL(string $url) :bool{
|
|
if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$url)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public function ValidateEmail(string $email) :bool{
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
public function ValidateUsername(string $username) : bool{
|
|
|
|
// if(!filter_var($username,FILTER_VALIDATE_REGEXP,array("options" => array( "regexp" => "^[^&=_'\-+;<>.]{1,18}$" ))))
|
|
// {
|
|
// return false;
|
|
// }
|
|
return true;
|
|
}
|
|
public function ValidatePassword(string $password) : bool{
|
|
if(strlen($password)>100)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
public function ValidateEnigme(string $name,string $statement,string $help,string $reminder,string $example,string $solution,string $test, string $resolutionTime, int $points) : bool{
|
|
if(strlen($name)>50 || strlen($statement) > 250 || strlen($help) > 250 || strlen($reminder) > 250 || strlen($example) > 250 || strlen($solution) > 250 || strlen($test) > 250 || $resolutionTime < 0 || $points < 0)
|
|
return false;
|
|
return true;
|
|
}
|
|
}
|