Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class CaptchaView{
- //$answer = "Answer";
- //$NewTryButton = "NewTryButton";
- function MakeCaptchaView(){
- //Du ska möjligtvis ha imagestring som inparameter här.
- echo "Testing CaptchaView";
- $img = imagecreate(80,50); //Ska eventuellt vara 000 istället.
- $background = imagecolorallocate( $img, 0, 0, 255 );
- $text_colour = imagecolorallocate( $img, 255, 255, 0 );
- $line_colour = imagecolorallocate( $img, 128, 255, 0 );
- imageline( $img, 30, 45, 165, 45, $line_colour );
- imagestring( $img, 4, 30, 25, "myRandomString",
- $text_colour );
- imagefill($img, 0, 0, $background);
- header( "Content-type: image/png" );
- imagepng( $img );
- imagecolordeallocate( $line_color );
- imagecolordeallocate( $text_color );
- imagecolordeallocate( $background );
- imagedestroy( $img ); //Bör man verkligen kalla på det här här.
- return $img;
- }
- function NewCaptchaButton(){
- return '<form name="input" method="get">
- <input type="submit" name="NewTryButton" value="Ny Captcha?" />
- </form>';
- }
- public function WantsNewCaptcha(){
- if (isset( $_GET[$this->NewTryButton])) {
- return true;
- }
- else {
- return false;
- }
- }
- function getAnswer(){
- return '<form action="demo_form.asp">
- Whats in da captcha: <input type="text" name="Answer"><br>
- <input type="submit" value="Answer">
- </form>';
- }
- public function GetUserName(){
- if (isset( $_GET[$this->Answer])) {
- return $_GET[$this->Answer];
- }
- else {
- return null;
- }
- }
- //Kör även en isSet funktion som kollar om användaren vill ha en ny bild.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement