getCAPTCHA() public static method

Generate a CAPTCHA string.
public static getCAPTCHA ( boolean $new = false ) : string
$new boolean If true, a new CAPTCHA is created and returned. The current, to-be-confirmed string otherwise.
return string A CAPTCHA string.
Beispiel #1
0
 public function handleAction()
 {
     global $notification, $conf;
     $page = Wicked_Page::getPage($this->referrer());
     if (!$this->allows(Wicked::MODE_EDIT)) {
         $notification->push(sprintf(_("You don't have permission to edit \"%s\"."), $page->pageName()));
     } else {
         if (!empty($GLOBALS['conf']['wicked']['captcha']) && !$GLOBALS['registry']->getAuth() && Horde_String::lower(Horde_Util::getFormData('wicked_captcha')) != Horde_String::lower(Wicked::getCAPTCHA())) {
             $notification->push(_("Random string did not match."), 'horde.error');
             return;
         }
         $text = Horde_Util::getFormData('page_text');
         $changelog = Horde_Util::getFormData('changelog');
         if ($conf['wicked']['require_change_log'] && empty($changelog)) {
             $notification->push(_("You must provide a change log."), 'horde.error');
             $GLOBALS['page_output']->addInlineScript(array('if (document.editform && document.editform.changelog) document.editform.changelog.focus()'), true);
             return;
         }
         if (trim($text) == trim($page->getText())) {
             $notification->push(_("No changes made"), 'horde.warning');
         } else {
             $page->updateText($text, $changelog);
             $notification->push(_("Page Saved"), 'horde.success');
         }
         if ($page->allows(Wicked::MODE_UNLOCKING)) {
             $page->unlock();
         }
     }
     // Show the newly saved page.
     Wicked::url($this->referrer(), true)->redirect();
 }
Beispiel #2
0
 public function handleAction()
 {
     global $notification, $wicked;
     if (!$this->allows(Wicked::MODE_EDIT)) {
         $notification->push(sprintf(_("You don't have permission to create \"%s\"."), $this->referrer()));
     } else {
         if (!empty($GLOBALS['conf']['wicked']['captcha']) && !$GLOBALS['registry']->getAuth() && Horde_String::lower(Horde_Util::getFormData('wicked_captcha')) != Horde_String::lower(Wicked::getCAPTCHA())) {
             $notification->push(_("Random string did not match."), 'horde.error');
             return;
         }
         $text = Horde_Util::getPost('page_text');
         if (empty($text)) {
             $notification->push(_("Pages cannot be empty."), 'horde.error');
             return;
         }
         try {
             $result = $wicked->newPage($this->referrer(), $text);
             $notification->push(_("Page Created"), 'horde.success');
         } catch (Wicked_Exception $e) {
             $notification->push(sprintf(_("Create Failed: %s"), $e->getMessage()), 'horde.error');
         }
     }
     // Show the newly created page.
     Wicked::url($this->referrer(), true)->redirect();
 }