Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     include_once("../connect/connection.php");
  4.     class capcha extends connect
  5.     {
  6.         public static function create()
  7.         {
  8.             $_SESSION["capcha_code"]=null;
  9.             $image=imagecreate(100,29);
  10.             imagecolorallocate($image,231,231,231);
  11.             //$text_color=imagecolorallocate($image,100,30,50);        
  12.             //$code=rand(1000000,9999999);         
  13.             $code="";
  14.             for($j=0; $j<15; $j++)
  15.             {
  16.                 $line_color=imagecolorallocate($image,rand(0,200),rand(0,200),rand(0,200));
  17.                 imageline($image,rand(1,100),rand(1,29),rand(1,100),rand(1,29),$line_color);
  18.             }
  19.             for($i=0; $i<7; $i++)
  20.             {
  21.                 $g_code=rand(1,9);
  22.                 $code.=$g_code;
  23.                 $text_color=imagecolorallocate($image,rand(0,200),rand(0,200),rand(0,200));        
  24.                 imagettftext($image,15,rand(1,5),$i*14,rand(18,22),$text_color,"../fonts/Typetys.ttf",$g_code);
  25.             }                      
  26.             $_SESSION["capcha_code"]=$code;
  27.             return imagejpeg($image);          
  28.         }
  29.         public static function check($code)
  30.         {
  31.             if($code==$_SESSION["capcha_code"])
  32.             {
  33.                 $_SESSION["capcha_code"]=null;
  34.                 return 1;  
  35.             }else{
  36.                 $_SESSION["capcha_code"]=null;
  37.                 return 0;
  38.             }
  39.         }
  40.         public static function xss($username,$password)
  41.         {
  42.             $username=strip_tags($username);
  43.             $username=htmlspecialchars($username);
  44.             $password=strip_tags($password);
  45.             $password=htmlspecialchars($password);
  46.             capcha::login($username,$password);
  47.         }
  48.         public static function login($user,$pass)
  49.         {
  50.             connect::con();        
  51.             if($user==1 and $pass==1)
  52.             {
  53.                 return 1;  
  54.             }else{
  55.                 return 0;  
  56.             }
  57.         }
  58.     }
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement