Exemplo n.º 1
0
 /**
  * @service
  * @anonym
  *
  * @param $name
  */
 public function getImage(Gpf_Rpc_Params $params)
 {
     $form = new Gpf_Rpc_Form($params);
     $lenght = self::TEXT_LENGTH;
     if (strlen($form->getFieldValue('length'))) {
         $lenght = $form->getFieldValue('length');
     }
     $text = $this->generateText($lenght);
     Gpf_Session::getInstance()->setVar(self::SESSION_PREFIX . $form->getFieldValue('name'), $text);
     $captchaGenerator = new Gpf_Common_Captcha_ImageGenerator($text);
     $height = 50;
     $width = self::TEXT_LENGTH * 30;
     if (strlen($params->get('height'))) {
         $height = $params->get('height');
     }
     if (strlen($params->get('width'))) {
         $height = $params->get('width');
     }
     $captchaGenerator->setSize($width, $height);
     return $captchaGenerator;
 }
 private static function loadFonts()
 {
     if (self::$fonts !== null) {
         return;
     }
     $directory = dirname(__FILE__) . '/font/';
     self::$fonts = array();
     foreach (new Gpf_Io_DirectoryIterator($directory, '.ttf') as $fullName => $file) {
         self::$fonts[$fullName] = $fullName;
     }
 }