-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.php
36 lines (26 loc) · 1.23 KB
/
image.php
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
<?php
# SETTINGS######################################################################
$width = 100; //øèðèíà èçîáðàæåíèÿ
$height = 25; //âûñîòà èçîáðàæåíèÿ
session_start();
$code = $_SESSION['text'];
# MAIN #########################################################################
// Ñîçäàåì èçîáðàæåíèå
$image = imagecreate($width, $height);
// Ðåãèñòðèðóåì èñïîëüçóåìûå öâåòà
$colorBackgr = imagecolorallocate($image, 255, 255, 255);
$colorText = imagecolorallocate($image, 0, 0, 0);
$colorBorder = imagecolorallocate($image, 192, 192, 192);
$colorLine = imagecolorallocate($image, 64,64,64);
// çàëèâàåì öâåòîì ôîíà
imagefilledrectangle($image, 0, 0, $width - 1, $height - 1, $colorBackgr);
imagerectangle($image, 0, 0, $width - 1, $height - 1, $colorBorder);
// ðèñóåì ñåòêó
for ($i = 0; $i <= $width; $i += 5) imageline($image, $i, 0, $i, $height, $colorBorder);
for ($i = 0; $i <= $height; $i += 5) imageline($image, 0, $i, $width, $i, $colorBorder);
for ($i = 0; $i < 4; $i++) imageline($image, rand(0, $width), rand(0, $height), rand(0, $width), rand(0, $height), $colorLine);
// âûâîäèì òåêñò
imagestring($image, 6, 25, 5, $code, $colorText);
header("Content-type: image/png");
imagepng($image);
?>