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


PHP cmsForm::getFieldsInputValues方法代码示例

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


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

示例1: 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 (!cmsPage::checkCaptchaCode()) {
            $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') {
            $emails = explode(',', $form['email']);
            if ($emails) {
                foreach ($emails as $email) {
                    cmsCore::mailText(trim($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();
        }
    }
    //========================================================================================================================//
}
开发者ID:vicktorwork,项目名称:cms1,代码行数:95,代码来源:frontend.php

示例2: 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 ($model->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($users_model->config['privforms'])) {
            if (is_array($users_model->config['privforms'])) {
                foreach ($users_model->config['privforms'] as $form_id) {
                    $form_input = cmsForm::getFieldsInputValues($form_id);
                    $item['formsdata'] .= $inDB->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 (!cmsPage::checkCaptchaCode()) {
            cmsCore::addSessionMessage($_LANG['ERR_CAPTCHA'], 'error');
            $errors = true;
        }
        // проверяем есть ли такой пользователь
        $user_exist = $inDB->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');
        }
开发者ID:vicktorwork,项目名称:cms1,代码行数:67,代码来源:frontend.php

示例3: users


//.........这里部分代码省略.........
                    // по старому адресу высылаем письмо с подтверждением
                    $letter = cmsCore::getLanguageTextFile('change_email');
                    $letter = str_replace(array('{nickname}', '{codelink}'), array($inUser->nickname, $codelink), $letter);
                    cmsCore::mailText($usr['email'], '', $letter);
                    cmsCore::addSessionMessage(sprintf($_LANG['YOU_CHANGE_EMAIL'], $usr['email']), 'info');
                    // email не меняем
                    $users['email'] = $usr['email'];
                }
            }
            $profiles['showphone'] = cmsCore::request('showphone', 'int', 0);
            $profiles['showmail'] = cmsCore::request('showmail', 'int');
            $profiles['email_newmsg'] = cmsCore::request('email_newmsg', 'int');
            $profiles['showbirth'] = cmsCore::request('showbirth', 'int');
            $profiles['description'] = cmsCore::request('description', 'str', '');
            $users['birthdate'] = (int) $_REQUEST['birthdate']['year'] . '-' . (int) $_REQUEST['birthdate']['month'] . '-' . (int) $_REQUEST['birthdate']['day'];
            $profiles['signature'] = $inDB->escape_string(cmsCore::badTagClear(cmsCore::request('signature', 'html', '')));
            $profiles['signature_html'] = $inDB->escape_string(cmsCore::parseSmiles(cmsCore::request('signature', 'html', ''), true));
            $profiles['allow_who'] = cmsCore::request('allow_who', 'str');
            if (!preg_match('/^([a-zA-Z]+)$/ui', $profiles['allow_who'])) {
                $errors = true;
            }
            $users['icq'] = cmsCore::request('icq', 'str', '');
            $profiles['showicq'] = cmsCore::request('showicq', 'int');
            $profiles['cm_subscribe'] = cmsCore::request('cm_subscribe', 'str');
            if (!preg_match('/^([a-zA-Z]+)$/ui', $profiles['cm_subscribe'])) {
                $errors = true;
            }
            $users['phone'] = cmsCore::request('phone', 'int', 0);
            // получаем данные форм
            $profiles['formsdata'] = '';
            if (isset($model->config['privforms'])) {
                if (is_array($model->config['privforms'])) {
                    foreach ($model->config['privforms'] as $form_id) {
                        $form_input = cmsForm::getFieldsInputValues($form_id);
                        $profiles['formsdata'] .= $inDB->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 ($errors) {
                cmsCore::redirectBack();
            }
            $inDB->update('cms_user_profiles', cmsCore::callEvent('UPDATE_USER_PROFILES', array_merge(array('id' => $usr['pid'], 'user_id' => $usr['id']), $profiles)), $usr['pid']);
            $inDB->update('cms_users', cmsCore::callEvent('UPDATE_USER_USERS', array_merge(array('id' => $usr['id']), $users)), $usr['id']);
            cmsCore::addSessionMessage($_LANG['PROFILE_SAVED'], 'info');
            cmsCore::redirect(cmsUser::getProfileURL($usr['login']));
        }
        if ($opt == 'changepass') {
            $errors = false;
            $oldpass = cmsCore::request('oldpass', 'str');
            $newpass = cmsCore::request('newpass', 'str');
            $newpass2 = cmsCore::request('newpass2', 'str');
            if ($inUser->password != md5($oldpass)) {
                cmsCore::addSessionMessage($_LANG['OLD_PASS_WRONG'], 'error');
                $errors = true;
            }
            if ($newpass != $newpass2) {
                cmsCore::addSessionMessage($_LANG['WRONG_PASS'], 'error');
                $errors = true;
            }
开发者ID:deltas1,项目名称:icms1,代码行数:67,代码来源:frontend.php

示例4: board


//.........这里部分代码省略.........
        $errors = false;

        // проверяем наличие категории
        if (!$cat['id']) {
            cmsCore::addSessionMessage($_LANG['NEED_CAT_ADV'], 'error');
            $errors = true;
        }

        // Проверяем количество добавленных за сутки
        if (!cmsCore::m('board')->checkLoadedByUser24h($cat)){
            cmsCore::addSessionMessage($_LANG['MAX_VALUE_OF_ADD_ADV'], 'error');
            $errors = true;
        }
        // Можем ли добавлять в эту рубрику
        if (!cmsCore::m('board')->checkAdd($cat)){
            cmsCore::addSessionMessage($_LANG['YOU_CANT_ADD_ADV'], 'error');
            $errors = true;
        }

        // входные данные
        $obtype     = icms_ucfirst(cmsCore::request('obtype', 'str', ''));
        $title      = trim(str_ireplace($obtype, '', cmsCore::request('title', 'str', '')));
        $content    = cmsCore::request('content', 'str', '');
        $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;
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:67,代码来源:frontend.php


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