Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();//projekt 2
- header("Content-type: image/jpeg");
- header("Cache-Control: no-cache, must-revalidate");
- header("Pragma: no-cache");
- $skrifttyper[] = 'OpenSans-Regular.ttf';//"Arial.ttf";
- $skrifttyper[] = 'Oswald-Regular.ttf';//"Tahoma.ttf";
- $skrifttyper[] = 'Raleway-Regular.ttf';//"Impact.ttf";
- $skrifttyper[] = 'Ubuntu-Medium.ttf';//"Verdana.ttf";
- $skrifttyper[] = 'Dosis-Medium.ttf';//"Georgia.ttf";
- $width=250;
- $height=60;
- $image = imagecreatetruecolor($width,$height);//Danner billedet
- $y=0;$x=0;
- for($i=0;$i<($width*$height);$i++)
- { $color = imagecolorallocate($image, mt_rand(155, 255), mt_rand(155, 255), mt_rand(155, 255));
- imagesetpixel($image, ($x - 1), $y, $color);
- $x += 1;
- if($x >= $width)
- { $y += 1;
- $x = 1;
- }
- }
- //----------------laver security-kode til brug i ny-bruger.php---------------
- $input='';
- $tegn = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz";
- for($i=0;$i<6;$i++)
- { $input.=substr($tegn, mt_rand(0, (strlen($tegn) - 1)), 1);
- }
- //-----------------indsætter security-kode i SESSION som bruges i opret-bruger.php-----------------
- $_SESSION['security_code'] = $input;
- $x = mt_rand(5, 35);//Startpunkt 10,$height
- $y = mt_rand(35, 50);//Startpunkt 35,50
- for($i=0;$i<strlen($input);$i++)
- { $color = imagecolorallocate($image, mt_rand(0, 155), mt_rand(0, 155), mt_rand(0, 155));
- $font = "font/".$skrifttyper[mt_rand(0, (count($skrifttyper) - 1))];
- //$font = "C:/Windows/Fonts/".$skrifttyper[mt_rand(0, (count($skrifttyper) - 1))];
- imagettftext($image, mt_rand(25, 30), mt_rand(-10, 10), $x, $y, $color, $font, substr($input, $i, 1));
- $x += mt_rand(25, 40);
- $y += mt_rand(-5, 5);
- }
- for($i=0;$i<mt_rand(4, 6);$i++)
- { $color = imagecolorallocate($image, mt_rand(0, $width), mt_rand(0, $width), mt_rand(0, $width));
- if(mt_rand(0, 2) == 1)
- { imageellipse($image, mt_rand(50,150), mt_rand(10, 50), mt_rand(10, $height), mt_rand(10, $height),$color);
- }
- else
- { imageline($image, mt_rand(0, 50), mt_rand(0, $height), mt_rand(100, $width), mt_rand(0, $height), $color);
- }
- }
- for($i=0;$i<mt_rand(250, 500);$i++)
- { $color = imagecolorallocate($image, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255));
- imagesetpixel($image, mt_rand(0, $width), mt_rand(0, $height), $color);
- }
- imagejpeg($image);
- ImageDestroy($image);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement