<td><?php echo generateText('city', $edit_shipping['city']); ?> <td> </tr> <tr style="height: 35px;"> <td>State:</td> <td><?php echo generateText('state', $edit_shipping['state']); ?> <td> </tr> <tr style="height: 35px;"> <td>Zip:</td> <td><?php echo generateText('zip', $edit_shipping['zip']); ?> <td> </tr> <tr> <td><button class="btn btn-large" type="submit" name="submit" value="submit">Submit</button></td> <td></td> </tr> </table> <!-- begin form footer --> <?php if (isset($_GET['edit_unid'])) { echo '<input type="hidden" name="edit_unid" value="' . $_GET['edit_unid'] . '" />';
<?php function generateText() { return strtolower(substr(md5(uniqid('')), 4, 10)); } session_start(); $texto = $_SESSION['captcha_text'] = generateText(); if (!function_exists('imagecreate')) { die('Você precisa da extensão GD para executar este script'); } // cria um quadro branco $nova_img = imagecreatetruecolor(200, 200); // algumas cores que serão utilizadas $branco = imagecolorallocate($nova_img, 255, 255, 255); $azul = imagecolorallocate($nova_img, 0, 0, 255); $vermelho = imagecolorallocate($nova_img, 255, 0, 0); $verde = imagecolorallocate($nova_img, 0, 255, 0); // preenche a imagem com branco imagefill($nova_img, 0, 0, $branco); $len = strlen($texto); $cores = array($azul, $vermelho, $verde); $start_x = 2; $deslocamento = 17; // cria o texto usando uma fonte "melhor" for ($i = 0; $i < $len; $i++) { imagettftext($nova_img, 20, 0, $start_x += $deslocamento, 100, $cores[rand(0, 2)], "./calligra.ttf", $texto[$i]); } imagepng($nova_img, '/tmp/captcha.png'); imagedestroy($nova_img);