Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html lang="pl">
- <head>
- <meta charset="utf8" />
- <title>Rysujemy captchę</title>
- <style>
- #can {
- border-style: solid;
- border-width: 2px;
- border-color: #404040;
- }
- </style>
- </head>
- <body>
- <canvas id="can" width="450" height="150"></canvas>
- <?php
- $captcha = '';
- echo '<script>';
- echo 'var can = document.getElementById("can");';
- echo 'var c = can.getContext("2d");';
- $alph = array_merge(range('a', 'z'), range('A', 'Z'), range('1', '9'));
- $colors = array_merge(range('a', 'f'), range('0', '9'));
- $fonts = array('Arial', 'Tahoma', 'Georgia', 'Verdana', 'Impact');
- for($i = 1; $i < 9; $i++) {
- $n = array_rand($alph);
- $nc = array_rand($colors);
- $nf = array_rand($fonts);
- $letter = $alph[$n];
- $font = $fonts[$nf];
- $color = '#'.$colors[rand(0, 15)].$colors[rand(0, 15)].$colors[rand(0, 15)].$colors[rand(0, 15)].$colors[rand(0, 15)].$colors[rand(0, 15)];
- echo 'c.font = "Bold 30px '.$font.'";';
- echo 'c.fillStyle = "'.$color.'";';
- echo 'c.fillText("'.$letter.'", 45*'.$i.', '.rand(20, 140).');';
- $captcha .= $letter;
- }
- echo '</script><br />';
- echo $captcha;
- ?>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement