コード例 #1
0
ファイル: Tools.php プロジェクト: PavloKovalov/seotoaster
 /**
  * Generate new recaptcha 
  *
  * @static
  * @return recaptcha code
  */
 public static function generateRecaptcha($captchaTheme = 'red', $captchaId = null)
 {
     $websiteConfig = Zend_Controller_Action_HelperBroker::getExistingHelper('config')->getConfig();
     if (!empty($websiteConfig) && !empty($websiteConfig[self::RECAPTCHA_PUBLIC_KEY]) && !empty($websiteConfig[self::RECAPTCHA_PRIVATE_KEY])) {
         $options = array('theme' => $captchaTheme);
         $params = null;
         if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
             $params = array('ssl' => Zend_Controller_Front::getInstance()->getRequest()->isSecure(), 'error' => null, 'xhtml' => false);
         }
         if (null !== $captchaId) {
             $options['custom_theme_widget'] = $captchaId;
         }
         $recaptcha = new Zend_Service_ReCaptcha($websiteConfig[self::RECAPTCHA_PUBLIC_KEY], $websiteConfig[self::RECAPTCHA_PRIVATE_KEY], $params, $options);
         return $recaptcha->getHTML();
     }
     return false;
 }