The SupportIT server www.tojnar.cz is hosted on is being decommissioned. To make the migration faster, we will just copy the current state and convert it to Hakyll incrementally. This mostly imports the tree as is minus accidentally misplaced files. Additionally, the following changes were made: - line separators were converted using dos2unix - file encodings were changed from windows-1250 to utf-8 - highslide and related files are now loaded from root instead of per-gallery copy - uppercase JPG extensions were changed to lowercase remove private
60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
# Martin Hozik
|
|
# 24.5.2008
|
|
# doublethink.cleverweb.cz
|
|
session_start();
|
|
# inicializace
|
|
require './imagelightnessat.func.php';
|
|
require './linear_perspective.class.php';
|
|
$perspective = new linear_perspective();
|
|
|
|
|
|
# konfigurace rozměrů a pozic
|
|
$matrix_dim = array('x' => 80, 'y' => 30);
|
|
$captcha_dim = array('x' => 300, 'y' => 90);
|
|
$distance = array('x' => 1, 'y' => 1, 'z' => 1);
|
|
$metric = array('x' => 10, 'y' => 20, 'z' => 5);
|
|
$offset = array('x' => 0, 'y' => -60);
|
|
|
|
# matrice
|
|
$matrix = imagecreatetruecolor($matrix_dim['x'], $matrix_dim['y']);
|
|
$black = imagecolorexact($matrix, 0, 0, 0);
|
|
$white = imagecolorexact($matrix, 255, 255, 255);
|
|
imagefill($matrix, 0, 0, $white);
|
|
|
|
# font calibri neni kvůli licenčním podmínkám připojen, použijte jakýkoliv svůj
|
|
imagefttext($matrix, 20, 0, 2, 25, $black, './3DCaptcha.ttf', $_SESSION["captcha"]);
|
|
|
|
# výpočet bodů ve 3d
|
|
$point = array();
|
|
for ($x = 0; $x < $matrix_dim['x']; $x++) {
|
|
for ($y = 0; $y < $matrix_dim['y']; $y++) {
|
|
$lightness = imagelightnessat($matrix, $x, $y);
|
|
$point[$x][$y] = $perspective->get_projection(array('x' => $x * $metric['x'] + $distance['x'], 'y' => $lightness * $metric['y'] + $distance['y'], 'z' => ($matrix_dim['y'] - $y) * $metric['z'] + $distance['z']));
|
|
}
|
|
}
|
|
imagedestroy($matrix);
|
|
|
|
|
|
# obrázek captcha
|
|
$captcha = imagecreatetruecolor($captcha_dim['x'], $captcha_dim['y']);
|
|
|
|
# antialiasing čar - pro menší zátěž lze vypnout
|
|
//imageantialias($captcha, true);
|
|
|
|
$black = imagecolorexact($captcha, 255, 0, 0);
|
|
$white = imagecolorexact($captcha, 255, 255, 255);
|
|
imagefill($captcha, 0, 0, $white);
|
|
|
|
# vykreslení vrstevnic
|
|
for ($x = 1; $x < $matrix_dim['x']; $x++) {
|
|
for ($y = 1; $y < $matrix_dim['y']; $y++) {
|
|
imageline($captcha, -$point[$x - 1][$y - 1]['x'] + $offset['x'], -$point[$x - 1][$y - 1]['y'] + $offset['y'], -$point[$x][$y]['x'] + $offset['x'], -$point[$x][$y]['y'] + $offset['y'], $black);
|
|
}
|
|
}
|
|
|
|
# výstup
|
|
header('Content-type: image/png');
|
|
imagepng($captcha);
|
|
?>
|