Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 KB | None | 0 0
  1. <?php
  2. class CaptchaView{
  3.  
  4.     //$answer = "Answer";
  5.     //$NewTryButton = "NewTryButton";
  6.    
  7.     function MakeCaptchaView(){
  8.         //Du ska möjligtvis ha imagestring som inparameter här.
  9.         echo "Testing CaptchaView";
  10.         $img = imagecreate(80,50); //Ska eventuellt vara 000 istället.
  11.         $background =  imagecolorallocate( $img, 0, 0, 255 );
  12.         $text_colour = imagecolorallocate( $img, 255, 255, 0 );
  13.         $line_colour = imagecolorallocate( $img, 128, 255, 0 );
  14.         imageline( $img, 30, 45, 165, 45, $line_colour );
  15.         imagestring( $img, 4, 30, 25, "myRandomString",
  16.         $text_colour );
  17.         imagefill($img, 0, 0, $background);
  18.         header( "Content-type: image/png" );
  19.         imagepng( $img );
  20.        
  21.         imagecolordeallocate( $line_color );
  22.         imagecolordeallocate( $text_color );
  23.         imagecolordeallocate( $background );
  24.         imagedestroy( $img ); //Bör man verkligen kalla på det här här.
  25.         return $img;
  26.     }
  27.    
  28.    
  29.     function NewCaptchaButton(){
  30.         return '<form name="input"  method="get">
  31.         <input type="submit" name="NewTryButton" value="Ny Captcha?" />
  32.         </form>';
  33.      }
  34.      
  35.      public function WantsNewCaptcha(){
  36.         if (isset( $_GET[$this->NewTryButton])) {
  37.          
  38.           return true;
  39.         }
  40.         else {
  41.             return false;
  42.         }
  43.       }
  44.      
  45.      function getAnswer(){
  46.         return '<form action="demo_form.asp">
  47.                     Whats in da captcha: <input type="text" name="Answer"><br>
  48.                     <input type="submit" value="Answer">
  49.                 </form>';
  50.      }
  51.      
  52.      public function GetUserName(){
  53.         if (isset( $_GET[$this->Answer])) {
  54.          
  55.           return $_GET[$this->Answer];
  56.         }
  57.         else {
  58.             return null;
  59.         }
  60.       }
  61.      
  62.     //Kör även en isSet funktion som kollar om användaren vill ha en ny bild.
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement