Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include_once("../connect/connection.php");
- class capcha
- {
- private $conn;
- public function __construct()
- {
- $database=new Database;
- $db=$database->dbConnection();
- $this->conn=$db;
- }
- public function create()
- {
- $_SESSION["capcha_code"]=null;
- $image=imagecreate(100,29);
- imagecolorallocate($image,231,231,231);
- //$text_color=imagecolorallocate($image,100,30,50);
- //$code=rand(1000000,9999999);
- $code="";
- for($j=0; $j<17; $j++)
- {
- $line_color=imagecolorallocate($image,rand(0,200),rand(0,200),rand(0,200));
- imageline($image,rand(1,100),rand(1,29),rand(1,100),rand(1,29),$line_color);
- }
- for($i=0; $i<7; $i++)
- {
- $g_code=rand(1,9);
- $code.=$g_code;
- $text_color=imagecolorallocate($image,rand(0,200),rand(0,200),rand(0,200));
- imagettftext($image,15,rand(1,5),$i*14,rand(18,22),$text_color,"../fonts/Typetys.ttf",$g_code);
- }
- $_SESSION["capcha_code"]=$code;
- return imagejpeg($image);
- }
- public function check($code)
- {
- if($code==$_SESSION["capcha_code"])
- {
- $_SESSION["capcha_code"]=null;
- return 1;
- }else{
- $_SESSION["capcha_code"]=null;
- @$_SESSION["capError"]=$_SESSION["capError"]+1;
- return 0;
- }
- }
- public function xss($username,$password)
- {
- $username=strip_tags($username);
- $username=htmlspecialchars($username);
- $password=strip_tags($password);
- $password=htmlspecialchars($password);
- capcha::checking($username,$password);
- }
- public function checking($user,$pass)
- {
- try
- {
- $password=md5($pass);
- $stmt=$this->conn->prepare("SELECT * FROM `login` WHERE user=:user AND pass=:pass");
- $stmt->execute(array(":user"=>$user,":pass"=>$password));
- $userRow=$stmt->fetch(PDO::FETCH_ASSOC);
- if($stmt->rowCount()==1)
- {
- return 1;
- }else{
- return 0;
- }
- }catch(PDOException $e){
- print_r($e->getMessage());
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement