PHP Paste by dingding
Description: None
Hide line numbers

Create new paste
Post a reply
View replies

Paste:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
<?
// Amr Haffar WDD 308 - 11713

// Überprüfen ob User bereits teilgenommen hat, wenn ja, dann Box ausblenden
if ( isset($_COOKIE['played']) && $_SESSION["Login"] !== "1") {
echo "Sie haben bereits an der Ziehung teilgenommen";
    $hide = "none";
} else {
    $hide = "block";
}

// captcha erzeugen und als JPG speichern
$filename = 'prototype_01.jpg';
$percent = 0.08;

list($width, $height) = getimagesize($filename);
$new_width = $width * $percent;
$new_height = $height * $percent;

$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

$font_file = 'fonts/LinLibertine_Re-4.1.8.ttf';
$fg = imagecolorallocate($image_p, 255, 5, 20);

# Zufallszahl mit rand( min_wert, max_wert );
$randomchar1 = rand(65,90);
$randomchar2 = rand(65,90);
$randomchar3 = rand(65,90);

# chr(zahl) gibt entsprechendes Zeichen aus dem ASCII Zeichensatz zurück
$randomchar1 = chr($randomchar1);
$randomchar2 = chr($randomchar2);
$randomchar3 = chr($randomchar3);
$randomstring = $randomchar1.$randomchar2.$randomchar3;

# Captcha code in Session speichern
$_SESSION["Captcha"] = $randomstring;

imagefttext($image_p, 20, 10, 10, 40, $fg, $font_file, $randomstring);

imagejpeg($image_p, 'captcha'.'.jpg', 100);
imagedestroy($image_p);

$_SESSION["Valid"] = "0";
?>

<div style="display:<? echo $hide; ?>">
<h3>Neues Los</h3>
<form action="formcheck.php" method="get">
Name:<br />
<input type="text" name="Name" /><br /><br />
Ihre Zahl:<br />
<select name="Zahl">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
</select><br /><br />
Sicherheitscode:<br /><br />
<img src="captcha.jpg" /><br /><br />
<input type="text" name="CaptchaCode" /> [Case Sensitive]<br /><br />
<input type="submit" />
</form>
</div>

Replies:
No replies posted yet