Advertisement
Guest User

Химическая капча Дорифа- исправленная.)

a guest
Jul 11th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. <?php
  2. class imeareactsii
  3. {
  4.  function get_random_question()
  5.     {
  6.     global $l;
  7.     $l=rand(0,4);
  8.     switch($l)
  9.     {
  10.     case 0:
  11.     $res[0]='2R-Hal + 2Na = R-R + 2NaHal\n';
  12.     break;
  13.     case 1:
  14.     $res[0]='Ar-Hal + R-Hal + 2Na = Ar-R + 2NaHal\n';
  15.     break;
  16.     case 2:
  17.     $res[0]='Ar-NO2 + 6H = Ar-NH2 +2H2O\n';
  18.     break;
  19.     case 3:
  20.     $res[0]='C2H2 + H2O = CH3CHO\n';
  21.     break;
  22.     case 4:
  23.     $res[0]='CH4 + HNO3 = CH3NO2 + H2O\n';
  24.     break;
  25.     }
  26.     $res[1]='Название реакции?\nСлово "Реакция" не писать — только название в родительном падеже.';
  27.     return $res;
  28.     }
  29.  function generate_image($canvas)
  30.     {
  31.     global $captcha_font_path,$captcha_img_path;
  32.       $txt=$this->get_random_question();
  33.       $rand=$txt[0];
  34.       $lines=explode("\n",$rand);
  35.       for ($i=0;$i<count($lines);$i++)
  36.       {
  37.       $color = imagecolorallocate($canvas, rand(100,255),rand(100,255) , rand(100,255));
  38.       imagefttext($canvas, 7+rand(0,3), rand (-5,5), 5, 10+$i*10, $color, $captcha_font_path."/LiberationMono-Bold.ttf", $lines[$i]);
  39.       }
  40.       imagefttext($canvas, 8, rand (-5,5), 5, 10+$i*10, $color, $captcha_font_path."/LiberationMono-Bold.ttf", $txt[1]);
  41.       $nme=$this->ucaptcha->get_filename();
  42.       imagepng($canvas,$captcha_img_path."/".$nme.".png");
  43.       $captcha[0]=$nme;
  44.       switch($l)
  45.       {
  46.       case 0:
  47.       $captcha[1]='Вюрца';
  48.       break;
  49.       case 1:
  50.       $captcha[1]='Вюрца-Фиттига';
  51.       break;
  52.       case 2:
  53.       $captcha[1]='Зинина';
  54.       break;
  55.       case 3:
  56.       $captcha[1]='Кучерова';
  57.       break;
  58.       case 4:
  59.       $captcha[1]='Коновалова';
  60.       break;
  61.       }
  62.       return $captcha; 
  63.     }
  64. }
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement