本文整理汇总了PHP中cmsCore::checkCaptchaCode方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsCore::checkCaptchaCode方法的具体用法?PHP cmsCore::checkCaptchaCode怎么用?PHP cmsCore::checkCaptchaCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsCore
的用法示例。
在下文中一共展示了cmsCore::checkCaptchaCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shopFinishOrder
function shopFinishOrder($cfg){
$inCore = cmsCore::getInstance();
$inDB = cmsDatabase::getInstance();
$inPage = cmsPage::getInstance();
$inUser = cmsUser::getInstance();
$inConf = cmsConfig::getInstance();
global $_LANG;
if (isset($inUser->id)){ $user_id = $inUser->id; } else { $user_id = 0; }
$sid = session_id();
$inPage->setTitle($_LANG['ORDER_COMPLETE']);
if ($user_id){ $user_sql = "(c.user_id=$user_id OR session_id='$sid')"; } else { $user_sql = "(c.user_id=0 AND c.session_id='$sid')"; }
$sql = "SELECT i.title as title, i.id as id, i.canmany as canmany, i.price as price,
c.id as cid, c.itemscount as itemscount,
cat.id as category_id, cat.title as category
FROM cms_uc_items i, cms_uc_cart c, cms_uc_cats cat
WHERE $user_sql AND c.item_id = i.id AND i.category_id = cat.id
ORDER BY c.pubdate";
$rs = $inDB->query($sql) ;
if ($inDB->num_rows($rs)){
//check user data
$customer = array();
if(!empty($_REQUEST['customer_fio'])) { $customer['fio'] = $inCore->request('customer_fio', 'str'); } else { $error .= $_LANG['EMPTY_NAME'].'<br/>'; }
if(!empty($_REQUEST['customer_phone'])) { $customer['phone'] = $inCore->request('customer_phone', 'str'); } else { $error .= $_LANG['EMPTY_PHONE'].'<br/>'; }
$customer['company'] = $inCore->request('customer_company', 'str');
$customer['email'] = $inCore->request('customer_email', 'str');
$customer['comment'] = $inCore->request('customer_comment', 'str');
if(!cmsCore::checkCaptchaCode()) { $error .= $_LANG['ERR_CAPTCHA'].'<br/>'; }
//BUILD MESSAGE
if($error==''){
// письмо администратору
$a_mail_message = $_LANG['GET_ORDER_FROM_CATALOG']." \"".$inConf->sitename."\".\n\n";
$a_mail_message .= $_LANG['CUSTOMER']."\n-----------------------------\r\n";
$a_mail_message .= $_LANG['FIO'].": " . $customer['fio'] . "\n";
if($customer['company']){
$a_mail_message .= $_LANG['COMPANY'].": " . $customer['company'] . "\n";
}
$a_mail_message .= $_LANG['PHONE'].": " . $customer['phone'] . "\n";
$a_mail_message .= "EMAIL: " . $customer['email'] . "\n";
if($customer['comment']){
$a_mail_message .= $_LANG['ORDER_COMMENT'].": " . @$customer['comment'] . "\n\n";
}
$a_mail_message .= $_LANG['ORDER']."\n---------------------------------\n";
//////////////////////////////////////////////////////////////////////////////////////
// список покупок
$row=0; $total = 0;
$item_mail_message = '';
while($item = $inDB->fetch_assoc($rs)){
$row++;
$item['price'] = shopDiscountPrice($item['id'], $item['category_id'], $item['price']);
$item['totalprice'] = $item['price'] * $item['itemscount'];
$item['price'] = number_format($item['price'], 2, '.', '');
$item['totalprice'] = number_format($item['totalprice'], 2, '.', '');
$total += $item['totalprice'];
$item_mail_message .= $row . '. ' . $item['title'] . ' (' . $item['itemscount'] . ' x ' . $item['price'] . ' '.$_LANG['CURRENCY'].') = ' . $item['totalprice'] . ' '.$_LANG['CURRENCY'] . "\n";
}
ob_start(); shopDiscountsInfo($total); ob_clean();
$total = number_format($total, 2, '.', '');
$item_mail_message .= "\n" . $_LANG['TOTAL_ORDER_PRICE'].': '.$total.' '.$_LANG['CURRENCY'] . "\n";
//////////////////////////////////////////////////////////////////////////////////////
$email_subj = str_replace('{sitename}', $inConf->sitename, $_LANG['EMAIL_SUBJECT']);
$inCore->mailText($cfg['email'], $_LANG['ADMIN_EMAIL_SUBJECT'], $a_mail_message . $item_mail_message);
if ($cfg['notice'] && $customer['email']){
$inCore->mailText($customer['email'], $_LANG['CUSTOMER_EMAIL_SUBJECT'], $item_mail_message);
}
//order completed
echo '<div class="con_heading">'.$_LANG['THANK'].'!</div>';
echo '<p style="clear:both"><b>'.$_LANG['CUSTOMER_EMAIL_SUBJECT'].'.</b><br/>'.$_LANG['CUSTOMER_EMAIL_TEXT'].'</p>';
echo '<p><a href="/">'.$_LANG['CONTINUE'].'</a></p>';
shopClearCart();
} else {
//order failed
echo '<div class="con_heading">'.$_LANG['ERROR'].'!</div>';
echo '<p style="clear:both; color:red">'.$error.'</p>';
echo '<p><a href="/catalog/order.html">'.$_LANG['BACK'].'</a></p>';
}
} else {
//NO ITEMS
echo '<p>'.$_LANG['NOITEMS_IN_CART'].'</p>';
echo '<div id="cart_buttons2">';
echo '<a href="/catalog" title="'.$_LANG['BACK_TO_SHOP'].'">';
echo '<img src="/components/catalog/images/shop/cartback.jpg" border="0" alt="'.$_LANG['BACK_TO_SHOP'].'"/>';
echo '</a> ';
echo '</div>';
}
}
示例2: forms
function forms()
{
cmsCore::loadClass('form');
$do = cmsCore::getInstance()->do;
global $_LANG;
//========================================================================================================================//
//========================================================================================================================//
if ($do == 'view') {
// Получаем форму
$form = cmsForm::getFormData(cmsCore::request('form_id', 'int'));
if (!$form) {
cmsCore::error404();
}
// Получаем данные полей формы
$form_fields = cmsForm::getFormFields($form['id']);
// Если полей нет, 404
if (!$form_fields) {
cmsCore::error404();
}
$errors = array();
$attachment = array();
// Получаем данные формы
// Если не переданы, назад
$form_input = cmsForm::getFieldsInputValues($form['id']);
if (!$form_input) {
$errors[] = $_LANG['FORM_ERROR'];
}
// Проверяем значения формы
foreach ($form_input['errors'] as $field_error) {
if ($field_error) {
$errors[] = $field_error;
}
}
// проверяем каптчу
if (!cmsCore::checkCaptchaCode(cmsCore::request('code', 'str'))) {
$errors[] = $_LANG['ERR_CAPTCHA'];
}
if ($errors) {
if (cmsCore::isAjax()) {
cmsCore::jsonOutput(array('error' => true, 'text' => end($errors)));
} else {
foreach ($errors as $error) {
cmsCore::addSessionMessage($error, 'error');
}
cmsCore::redirectBack();
}
}
if (!cmsUser::checkCsrfToken()) {
cmsCore::error404();
}
// Подготовим начало письма
$mail_message = '<h3>' . $_LANG['FORM'] . ': ' . $form['title'] . '</h3>';
// Добавляем заполненные поля в письмо
foreach ($form_fields as $field) {
// Значение поля
$value = $form_input['values'][$field['id']];
if (!$value) {
continue;
}
if (is_string($value)) {
$mail_message .= '<h5>' . $field['title'] . '</h5><p>' . $value . '</p>';
} elseif (is_array($value)) {
// если массив, значит к форме прикреплен файл
if ($form['sendto'] == 'mail') {
$attachment[] = !empty($value['url']) ? PATH . $value['url'] : '';
} elseif (!empty($value['url'])) {
$mail_message .= '<h5>' . $field['title'] . '</h5><p><a href="' . $value['url'] . '">' . $value['name'] . '</a></p>';
}
}
}
// Отправляем форму
if ($form['sendto'] == 'mail') {
cmsCore::mailText($form['email'], cmsConfig::getConfig('sitename') . ': ' . $form['title'], $mail_message, $attachment);
// удаляем прикрепленные файлы
foreach ($attachment as $attach) {
@unlink($attach);
}
} else {
cmsUser::sendMessage(-2, $form['user_id'], $mail_message);
}
cmsUser::sessionClearAll();
if (cmsCore::isAjax()) {
cmsCore::jsonOutput(array('error' => false, 'text' => $_LANG['FORM_IS_SEND']));
} else {
cmsCore::addSessionMessage($_LANG['FORM_IS_SEND'], 'info');
cmsCore::redirectBack();
}
}
//========================================================================================================================//
}
示例3: faq
//.........这里部分代码省略.........
$inPage->setTitle($shortquest);
$inPage->setDescription($shortquest);
$inPage->addPathway($quest['cat_title'], '/faq/'.$quest['cat_id']);
$inPage->addPathway($shortquest);
cmsPage::initTemplate('components', 'com_faq_read')->
assign('quest', $quest)->
assign('cfg', $cfg)->
assign('labels', array('comments' => $_LANG['ANSWERS'], 'add' => $_LANG['REPLY'], 'rss' => $_LANG['RSS_FEED'], 'not_comments' => $_LANG['NOT_ANSWERS']))->
assign('is_admin', $inUser->is_admin)->
display();
} else { cmsCore::error404(); }
}
///////////////////////////////////// SEND QUEST ////////////////////////////////////////////////////////////////////////////////
if ($do=='sendquest'){
if (!$inUser->id && !$cfg['guest_enabled']){ cmsCore::error404(); }
$inPage->setTitle($_LANG['SET_QUESTION']);
$inPage->addPathway($_LANG['SET_QUESTION']);
$inPage->addHeadJS('components/faq/js/common.js');
$error = '';
$captha_code = $inCore->request('code', 'str', '');
$message = $inCore->request('message', 'str', '');
$category_id = $inCore->request('category_id', 'int', '');
$published = ($inUser->is_admin || $cfg['publish']) ? 1 : 0;
$is_submit = $inCore->inRequest('message');
if ($is_submit && !$inUser->id && !cmsCore::checkCaptchaCode()) { $error = $_LANG['ERR_CAPTCHA']; }
if (!$is_submit || $error){
if (IS_BILLING && $inUser->id){ cmsBilling::checkBalance('faq', 'add_quest'); }
cmsPage::initTemplate('components', 'com_faq_add')->
assign('catslist', $inCore->getListItems('cms_faq_cats', $category_id))->
assign('user_id', $inUser->id)->
assign('message', htmlspecialchars($inCore->request('message', 'html', '')))->
assign('error', $error)->
display();
} else {
//SAVE QUESTION
$sql = "INSERT INTO cms_faq_quests (category_id, pubdate, published, quest, answer, user_id, answeruser_id, answerdate, hits)
VALUES ('$category_id', NOW(), '$published', '$message', '', '{$inUser->id}', 0, NOW(), 0)";
$inDB->query($sql);
$quest_id = $inDB->get_last_id('cms_faq_quests');
if (IS_BILLING && $inUser->id){ cmsBilling::process('faq', 'add_quest'); }
$inPage->setTitle($_LANG['QUESTION_SEND']);
$inPage->addPathway($_LANG['QUESTION_SEND']);
if (!$published){
echo '<div class="con_heading">'.$_LANG['QUESTION_SEND'].'</div>';
echo '<div style="margin-top:10px">'.$_LANG['QUESTION_PREMODER'].'</div>';
echo '<div style="margin-top:10px"><a href="/faq">'.$_LANG['CONTINUE'].'</a></div>';
} elseif ($published) {
$category = $inDB->get_field('cms_faq_cats', "id={$category_id}", 'title');
示例4: board
//.........这里部分代码省略.........
$city = cmsCore::request('city', 'str', '');
if ((cmsCore::m('board')->config['seo_user_access'] && cmsCore::c('user')->id) || cmsCore::c('user')->is_admin) {
$pagetitle = cmsCore::request('pagetitle', 'str', '');
$meta_keys = cmsCore::request('meta_keys', 'str', '');
$meta_desc = cmsCore::request('meta_desc', 'str', '');
} else {
$pagetitle = $meta_keys = $meta_desc = '';
}
$form_input = cmsForm::getFieldsInputValues($cat['form_id']);
$formsdata = cmsCore::c('db')->escape_string(cmsCore::arrayToYaml($form_input['values']));
$vipdays = cmsCore::request('vipdays', 'int', 0);
$published = cmsCore::m('board')->checkPublished($cat);
if (cmsCore::m('board')->config['srok']){ $pubdays = (cmsCore::request('pubdays', 'int') <= 50) ? cmsCore::request('pubdays', 'int') : 50; }
if (!cmsCore::m('board')->config['srok']){ $pubdays = isset(cmsCore::m('board')->config['pubdays']) ? cmsCore::m('board')->config['pubdays'] : 14; }
// Проверяем значения
if (!$title) {
cmsCore::addSessionMessage($_LANG['NEED_TITLE'], 'error');
$errors = true;
}
if (!$content) {
cmsCore::addSessionMessage($_LANG['NEED_TEXT_ADV'], 'error');
$errors = true;
}
if (!$city) {
cmsCore::addSessionMessage($_LANG['NEED_CITY'], 'error');
$errors = true;
}
if (!cmsCore::c('user')->id && !cmsCore::checkCaptchaCode()) {
cmsCore::addSessionMessage($_LANG['ERR_CAPTCHA'], 'error');
$errors = true;
}
// Проверяем значения формы
foreach ($form_input['errors'] as $field_error) {
if ($field_error) {
cmsCore::addSessionMessage($field_error, 'error');
$errors = true;
}
}
if ($errors) {
$item['content'] = htmlspecialchars(stripslashes($_REQUEST['content']));
$item['city'] = stripslashes($city);
$item['title'] = stripslashes($title);
$item['obtype'] = $obtype;
cmsUser::sessionPut('item', $item);
cmsCore::redirect('/board/'. cmsCore::m('board')->category_id .'/add.html');
}
if ($cat['is_photos']) {
// Загружаем фото
$file = cmsCore::m('board')->uploadPhoto('', $cat);
} else {
$file['filename'] = '';
cmsCore::addSessionMessage($_LANG['INFO_CAT_NO_PHOTO'], 'info');
}
$add = array(
'category_id' => cmsCore::m('board')->category_id,
示例5: comments
//.........这里部分代码省略.........
}
// Входные данные
$comment['guestname'] = cmsCore::request('guestname', 'str', '');
$comment['user_id'] = $inUser->id;
if ($model->is_can_bbcode) {
$content = cmsCore::request('content', 'html', '');
$comment['content_bbcode'] = $inDB->escape_string($content);
$content = cmsCore::parseSmiles($content, true);
$comment['content'] = $inDB->escape_string($content);
} else {
$comment['content'] = cmsCore::request('content', 'str', '');
$comment['content_bbcode'] = $comment['content'];
$comment['content'] = str_replace(array('\\r', '\\n'), '<br>', $comment['content']);
}
$comment['parent_id'] = cmsCore::request('parent_id', 'int', 0);
$comment['target'] = cmsCore::request('target', 'str', '');
$comment['target_id'] = cmsCore::request('target_id', 'int', 0);
$comment['ip'] = cmsCore::strClear($_SERVER['REMOTE_ADDR']);
// Проверяем правильность/наличие входных парамеров
// цель комментария
if (!$comment['target'] || !$comment['target_id']) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_UNKNOWN_TARGET']));
}
// Имя гостя отсутствует
if (!$comment['guestname'] && !$inUser->id) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_USER_NAME']));
}
// Текст комментраия отсутствует
if (!$comment['content']) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_COMMENT_TEXT']));
}
// проверяем каптчу
$need_captcha = $model->config['regcap'] ? true : ($inUser->id ? false : true);
if ($need_captcha && !cmsCore::checkCaptchaCode(cmsCore::request('code', 'str', ''))) {
cmsCore::jsonOutput(array('error' => true, 'is_captcha' => true, 'text' => $_LANG['ERR_CAPTCHA']));
}
// получаем массив со ссылкой и заголовком цели комментария
// для этого:
// 1. узнаем ответственный компонент из cms_comment_targets
$target = $inDB->get_fields('cms_comment_targets', "target='{$comment['target']}'", '*');
if (!$target) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_UNKNOWN_TARGET'] . ' #1'));
}
// 2. подключим модель этого компонента
if (cmsCore::loadModel($target['component'])) {
$model_class = 'cms_model_' . $target['component'];
if (class_exists($model_class)) {
$target_model = new $model_class();
}
}
if (!isset($target_model)) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_UNKNOWN_TARGET'] . ' #2'));
}
// 3. запросим массив $target_data[link, title] у метода getCommentTarget модели
$target_data = $target_model->getCommentTarget($comment['target'], $comment['target_id']);
if (!$target_data) {
cmsCore::jsonOutput(array('error' => true, 'text' => $_LANG['ERR_UNKNOWN_TARGET'] . ' #3'));
}
$comment['target_title'] = $target_data['title'];
$comment['target_link'] = $target_data['link'];
// 4. Узнаем видимость комментария в модели $target_model
if (method_exists($target_model, 'getVisibility')) {
$comment['is_hidden'] = $target_model->getVisibility($comment['target'], $comment['target_id']);
} else {
$comment['is_hidden'] = 0;
}
示例6: checkCaptchaCode
/**
* Валидация каптчи
* @return bool
*/
public static function checkCaptchaCode()
{
return cmsCore::checkCaptchaCode();
}
示例7: registration
//.........这里部分代码省略.........
} else {
if(!$item['realname1']) { cmsCore::addSessionMessage($_LANG['TYPE_NAME'], 'error'); $errors = true; }
if(!$item['realname2']) { cmsCore::addSessionMessage($_LANG['TYPE_SONAME'], 'error'); $errors = true; }
$item['nickname'] = trim($item['realname1']) . ' ' . trim($item['realname2']);
}
if (mb_strlen($item['nickname'])<2) { cmsCore::addSessionMessage($_LANG['SHORT_NICKNAME'], 'error'); $errors = true; }
if(cmsCore::m('registration')->getBadNickname($item['nickname'])){
cmsCore::addSessionMessage($_LANG['ERR_NICK_EXISTS'], 'error'); $errors = true;
}
// Проверяем email
if(!$item['email']) { cmsCore::addSessionMessage($_LANG['ERR_EMAIL'], 'error'); $errors = true; }
// День рождения
list($item['bday'], $item['bmonth'], $item['byear']) = array_values(cmsCore::request('birthdate', 'array_int', array()));
$item['birthdate'] = sprintf('%04d-%02d-%02d', $item['byear'], $item['bmonth'], $item['bday']);
// получаем данные конструктора форм
$item['formsdata'] = '';
if(isset(cmsCore::m('users')->config['privforms'])){
if (is_array(cmsCore::m('users')->config['privforms'])){
foreach(cmsCore::m('users')->config['privforms'] as $form_id){
$form_input = cmsForm::getFieldsInputValues($form_id);
$item['formsdata'] .= cmsCore::c('db')->escape_string(cmsCore::arrayToYaml($form_input['values']));
// Проверяем значения формы
foreach ($form_input['errors'] as $field_error) {
if($field_error){ cmsCore::addSessionMessage($field_error, 'error'); $errors = true; }
}
}
}
}
// Проверяем каптчу
if(!cmsCore::checkCaptchaCode()) { cmsCore::addSessionMessage($_LANG['ERR_CAPTCHA'], 'error'); $errors = true; }
// проверяем есть ли такой пользователь
$user_exist = cmsCore::c('db')->get_fields('cms_users', "(login LIKE '{$item['login']}' OR email LIKE '{$item['email']}') AND is_deleted = 0", 'id, login, email');
if($user_exist){
if($user_exist['login'] == $item['login']){
cmsCore::addSessionMessage($_LANG['LOGIN'].' "'.$item['login'].'" '.$_LANG['IS_BUSY'], 'error'); $errors = true;
} else {
cmsCore::addSessionMessage($_LANG['EMAIL_IS_BUSY'], 'error'); $errors = true;
}
}
// В случае ошибок, возвращаемся в форму
if($errors){
cmsUser::sessionPut('item', $item);
cmsCore::redirect('/registration');
}
//////////////////////////////////////////////
//////////// РЕГИСТРАЦИЯ /////////////////////
//////////////////////////////////////////////
$item['is_locked'] = cmsCore::m('registration')->config['act'];
$item['password'] = md5($pass);
$item['orig_password'] = $pass;
$item['group_id'] = cmsCore::m('registration')->config['default_gid'];
$item['regdate'] = date('Y-m-d H:i:s');
$item['logdate'] = date('Y-m-d H:i:s');
if (cmsUser::sessionGet('invite_code')){
$invite_code = cmsUser::sessionGet('invite_code');
$item['invited_by'] = (int)cmsCore::m('users')->getInviteOwner($invite_code);