90 lines
2.2 KiB
PHP
90 lines
2.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Description of UserValidator.class
|
|
*
|
|
* Rozszerzenie Validatora dla specyficznych danych
|
|
*
|
|
* @author KoPi
|
|
*/
|
|
abstract class UserValidator {
|
|
|
|
/**
|
|
* funkcja sprawdzaja czy podane dane juz istnieja w tabeli uzytkownik
|
|
*
|
|
* @param string $login
|
|
*
|
|
* @return int $amout - ilosc powtarzajacych sie loginow
|
|
*/
|
|
|
|
public function CheckLoginRepeat($login)
|
|
{
|
|
$db = Registry::Get('db');
|
|
$sql = "SELECT count(login) FROM wp_preserve WHERE login=:01";
|
|
|
|
$stmt = $db->prepare($sql)
|
|
->bindParam("01", strip_tags($login) )
|
|
->execute();
|
|
|
|
$amout=$stmt->FetchRow();
|
|
|
|
return $amout[0];
|
|
}
|
|
|
|
/**
|
|
* funkcja sprawdzaja czy podane dane juz istnieja w tabeli uzytkownik
|
|
*
|
|
* @param string $login
|
|
*
|
|
* @return int $amout - ilosc powtarzajacych sie emaili
|
|
*/
|
|
|
|
public function CheckEmailRepeat($email)
|
|
{
|
|
$db = Registry::Get('db');
|
|
$sql = "SELECT count(email) FROM wp_preserve WHERE email=:01";
|
|
|
|
$stmt = $db->prepare($sql)
|
|
->bindParam("01", strip_tags($email) )
|
|
->execute();
|
|
|
|
$amout=$stmt->FetchRow();
|
|
|
|
return $amout[0];
|
|
}
|
|
|
|
public function CheckPassword($password,$hash)
|
|
{
|
|
// sprawdzanie czy haslo jest ok
|
|
$db = Registry::Get('db');
|
|
$sql="SELECT count(login) FROM wp_preserve WHERE hash=:01 AND passwd=:02";
|
|
|
|
$stmt = $db->prepare($sql)
|
|
->bindParam("01",strip_tags($hash) )
|
|
->bindParam("02",strip_tags($password) )
|
|
->execute();
|
|
|
|
$amout=$stmt->FetchRow();
|
|
|
|
return $amout[0];
|
|
}
|
|
|
|
public function ValidatePhotoForm(){
|
|
|
|
|
|
if ( $this->IsEmpty('name', 'Pole zdjêcia jest puste.'))
|
|
{
|
|
$this->IsNotEqualValue('error', 0, 'Wyst±pi³ b³±d serwera.');
|
|
if( $this->IsFile('tmp_name','Przes³anie pliku nie powio³o siê.'))
|
|
{
|
|
$this->IsGoodImageFormat('type','Format przesy³anego pliku nie jest poprawny.');
|
|
}
|
|
$this->IsWithinRange('size','Przesy³any plik jast za du¿y.',0,ALLOWED_FILE_SIZE);
|
|
}
|
|
return $this->GetErrorList();
|
|
|
|
}
|
|
|
|
|
|
}
|
|
?>
|