示例#1
0
 function run()
 {
     global $_out;
     $ns = $this->query('form');
     foreach ($ns as $form) {
         if (!$form->getAttribute('action')) {
             $form->setAttribute('action', $_SERVER['REQUEST_URI']);
         }
         if ($this->isSent($form)) {
             //форму отправили
             $xml = new xml($form);
             if (!$this->check($form) && ($res = $this->getSentData($form))) {
                 $resultSQL = $resultMail = true;
                 if (count($res['mysql'])) {
                     $resultSQL = $this->insertDB($res['mysql'], $form);
                 }
                 if ($res['xml']) {
                     $resultMail = $this->sendEmail($res['xml'], $form);
                 }
                 $form->appendChild($xml->createElement('message', array('type' => $resultSQL && $resultMail ? 'success' : 'fail'), xml::getElementText($this->query($resultSQL && $resultMail ? 'form/good' : 'form/fail')->item(0))));
             } else {
                 // Ошибка - заполняем форму
                 $this->fillForm($form);
             }
         }
         if ($form->hasAttribute('appendTo')) {
             $_out->elementIncludeTo($form, $form->getAttribute('appendTo'));
         } elseif (!$this->getSection()) {
             $_out->elementIncludeTo($form, $_out->de());
         } else {
             $_out->addSectionContent($form);
         }
         if ($this->hasCaptcha($form)) {
             $captcha = new captcha();
             $captcha->setLanguage($_out->getLang());
             $captcha->setParamName('captcha');
             $captcha->create('userfiles/cptch.jpg');
         }
     }
 }
示例#2
0
 function run()
 {
     global $_out;
     $captcha = new captcha();
     $captcha->setParamName('captcha');
     if ($form = $this->query('form')->item(0)) {
         //нашли форму
         if (!$form->getAttribute('action')) {
             $form->setAttribute('action', $_SERVER['REQUEST_URI']);
         }
         if ($this->isSent($form)) {
             //форму отправили
             if (!$this->check($form) && ($res = $this->getSentData($form))) {
                 $e = $this->getSection()->getXML()->createElement('final', null);
                 $resultSQL = $resultMail = true;
                 if (count($res['mysql'])) {
                     $resultSQL = $this->insertDB($res['mysql'], $form);
                 }
                 if ($res['xml']) {
                     $resultMail = $this->sendEmail($res['xml'], $form);
                 }
                 if ($resultSQL && $resultMail) {
                     xml::setElementText($e, xml::getElementText($this->getSection()->getXML()->query('good', $form)->item(0)));
                 } else {
                     xml::setElementText($e, xml::getElementText($this->getSection()->getXML()->query('fail', $form)->item(0)));
                 }
                 $form->appendChild($e);
             } else {
                 // Ошибка - заполняем форму
                 $this->fillForm($form);
             }
         }
         $_out->addSectionContent($form);
         $captcha->setLanguage('en');
         $captcha->create('userfiles/cptch.jpg');
     }
 }