当前位置: 首页>>代码示例>>PHP>>正文


PHP system::validCapcha方法代码示例

本文整理汇总了PHP中system::validCapcha方法的典型用法代码示例。如果您正苦于以下问题:PHP system::validCapcha方法的具体用法?PHP system::validCapcha怎么用?PHP system::validCapcha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system的用法示例。


在下文中一共展示了system::validCapcha方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addAction

 public function addAction()
 {
     if (user::isGuest() && reg::getKey('/comments/only_reg')) {
         system::stop();
     }
     if (user::isGuest() && !system::validCapcha('random_image')) {
         system::json(array('error' => 1, 'data' => lang::get('FEEDBACK_ERROR1')));
     }
     // Добавляем новый комментарий
     $comment = new comment();
     $comment->setParentId(system::POST('parent_id'));
     $comment->setObjId(system::POST('obj_id'));
     $comment->setUserName(system::POST('username'));
     $comment->setEmail(system::POST('email'));
     $comment->setText(system::POST('text'));
     $comment->setSendEmail(system::POST('send_email'));
     $obj_id = $comment->save();
     if ($obj_id) {
         page::assign('current_url', system::POST('back_url'));
         $html = page::macros('comments')->view($comment->id());
         system::json(array('error' => 0, 'data' => $html));
     } else {
         system::json(array('error' => 2, 'data' => $comment->getErrorListText(' ')));
     }
     if (!empty($_POST['back_url']) && !system::isAjax()) {
         system::redirect($_POST['back_url'] . '#comment' . $obj_id, true);
     } else {
         system::stop();
     }
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:30,代码来源:controller.php

示例2: send_messageAction

 public function send_messageAction()
 {
     if ($form_obj = ormObjects::get(system::POST('form_id'))) {
         $issetErrors = false;
         $answer = array();
         // Проверка капчи
         if ($form_obj->captcha && !system::validCapcha('random_image')) {
             $issetErrors = true;
             $answer = array('field' => 'random_image', 'msg' => lang::get('FEEDBACK_ERROR1'));
         }
         // Если указанно куда, добавляем объект в БД
         if (($form_obj->any_sections || $form_obj->section) && !$issetErrors) {
             // Определяем раздел, в который будем добавлять отзыв
             if ($form_obj->any_sections) {
                 $section = system::POST('section_id', isInt);
             } else {
                 $section = $form_obj->section;
                 $section = !empty($section) ? $section[0] : 0;
             }
             // Создаем объект обратной связи
             $obj = new ormPage();
             $obj->setParent($section);
             $obj->setClass($form_obj->form_class);
             $obj->tabuList('pseudo_url', 'h1', 'keywords', 'title', 'description', 'answer', 'active', 'is_home_page', 'view_in_menu', 'view_submenu', 'in_search', 'in_index', 'in_new_window', 'other_link', 'img_act', 'img_no_act', 'img_h1');
             $obj->loadFromPost();
             $obj->active = 0;
             $obj->view_in_menu = 1;
             $obj->view_submenu = 1;
             $obj->in_search = 1;
             $obj->in_index = 1;
             $obj->is_home_page = 0;
             if ($obj->name != '') {
                 $obj->h1 = $obj->name;
                 $obj->title = $obj->name;
             }
             $obj->pseudo_url = rand(1000, 9999);
             $obj->template_id = ($sect = ormPages::get($form_obj->section)) ? $sect->template_id : 1;
             $obj->form_id = $form_obj->id;
             $obj->setRightForAll(2);
             $obj_id = $obj->save();
             if ($obj_id) {
                 $obj->pseudo_url = $obj_id;
                 $obj->save();
                 $obj = new ormPage($obj_id);
             } else {
                 $issetErrors = true;
                 $f = $obj->getErrorFields();
                 $answer = array('field' => $f['focus'], 'msg' => $obj->getErrorListText(' '));
             }
         }
         if (!$issetErrors) {
             // Отправка нужных писем
             page::assign('site_name', domains::curDomain()->getSiteName());
             page::assign('site_url', domains::curDomain()->getName());
             page::assign('base_email', domains::curDomain()->getEmail());
             while (list($key, $val) = each($_POST)) {
                 page::assign($key, system::checkVar($val, isText));
             }
             if (isset($obj)) {
                 $fields = $obj->getClass()->loadFields();
                 foreach ($fields as $field) {
                     if (in_array($field['f_type'], array(70, 75, 80, 85))) {
                         $fsname = $field['f_sname'];
                         $fvalue = $obj->{$fsname};
                         if ($fvalue != '') {
                             page::assign($fsname, $fvalue);
                         }
                     }
                 }
             }
             // Если указан список адресатов, отправляем письма
             if ($form_obj->mailing_list != '') {
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->admin_sender_address);
                 $mail->FromName = $this->parse($form_obj->admin_sender_name);
                 /*
                                   if (!empty($this->files))
                 for($i = 0; $i < count($this->files); $i++)
                    $mail->AddAttachment($this->files[$i][0], $this->files[$i][1]);
                 */
                 $mail->AddAddress($form_obj->mailing_list);
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->admin_subject);
                 $mail->Body = $this->parse($form_obj->admin_template);
                 $mail->Send();
             }
             // Если нужно, отправляем уведомление пользователю
             if ($form_obj->send_notice && !$issetErrors) {
                 $mail = new phpmailer();
                 $mail->From = $this->parse($form_obj->notice_sender_address);
                 $mail->FromName = $this->parse($form_obj->notice_sender_name);
                 $mail->AddAddress(system::POST('email'));
                 $mail->WordWrap = 50;
                 $mail->IsHTML(true);
                 $mail->Subject = $this->parse($form_obj->notice_subject);
                 $mail->Body = $this->parse($form_obj->notice_template);
                 $mail->Send();
             }
             // Показываем результат
//.........这里部分代码省略.........
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:101,代码来源:controller.php

示例3: add_procAction

 public function add_procAction()
 {
     $answer = array();
     if (!reg::getKey('/users/reg')) {
         system::redirect('/');
     }
     if (!user::isGuest()) {
         system::redirect('/users/edit');
     }
     // Проверка капчи
     if (!system::validCapcha('random_image')) {
         $answer = array('msg' => lang::get('SITE_CAPHCA'), 'field' => 'captcha');
     }
     // Проверка согласия с условиями оферты
     if (reg::getKey('/users/confirm') && !system::POST('confirm', isBool)) {
         $answer = array('msg' => lang::get('USERS_COMFIRM'), 'field' => 'confirm');
     }
     // Добавляем объект
     if (empty($answer)) {
         $obj = new ormObject();
         $obj->setParent(41);
         // Устанавливаем группу "Пользователи сайта"
         $obj->setClass('user');
         $obj->tabuList('def_modul', 'active', 'last_visit', 'last_ip', 'groups');
         $obj->loadFromPost();
         $obj->active = 1;
         $obj->email = $obj->newVal('login');
         $max_tickets = reg::getKey('/booking/max_tickets');
         $obj->place_limit = $max_tickets == '' || $max_tickets == 0 ? 6 : $max_tickets;
         if ($obj->save()) {
             if (reg::getKey('/users/activation')) {
                 // Регистрация с проверкой
                 // Формируем временный ключ активации пользователя
                 $key = md5(date('d.m.Y') . 'activate' . $obj->id);
                 $obj->md5_flag = $key;
                 $obj->active = 0;
                 $obj->save();
                 // Отправляем письмо
                 $url_pre = 'http://' . domains::curDomain()->getName() . languages::pre();
                 page::assign('url', $url_pre . '/users/activate/' . $key);
                 page::assign('passw', system::POST('password'));
                 page::assign('login', $obj->login);
                 page::assign('name', $obj->name);
                 system::sendMail('/users/mails/activate.tpl', $obj->email);
                 $_SESSION['user_email'] = $obj->login;
             } else {
                 // Регистрация без проверки
                 // Отправляем письмо
                 page::assign('passw', system::POST('password'));
                 page::assign('login', $obj->login);
                 page::assign('name', $obj->name);
                 system::sendMail('/users/mails/registration.tpl', $obj->email);
                 // Автоматическая авторизация
                 user::authHim($obj);
             }
             // Все хорошо. Пользователь добавлен.
             if (system::isAjax()) {
                 system::json(array('ok' => 1));
             } else {
                 system::redirect('/users/ok');
             }
         } else {
             // Произошли ошибки
             if ($obj->issetErrors(32)) {
                 $answer = array('msg' => lang::get('USERS_ISSET'), 'field' => 'login');
             } else {
                 $tmp = $obj->getErrorFields();
                 $answer = array('msg' => $obj->getErrorListText(' '), 'field' => $tmp['focus']);
             }
         }
     }
     if (!system::isAjax()) {
         system::savePostToSession();
         system::saveErrorToSession('add_user', $answer);
         if (!empty($_POST['back_url'])) {
             system::redirect($_POST['back_url'], true);
         } else {
             system::redirect('/users/add');
         }
     } else {
         system::json($answer);
     }
 }
开发者ID:sunfun,项目名称:Bagira.CMS,代码行数:83,代码来源:controller.php


注:本文中的system::validCapcha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。