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


PHP cmsCore::strClear方法代码示例

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


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

示例1: ContentLink

function ContentLink($content_title)
{
    $content_title = cmsCore::strClear($content_title);
    $content = cmsDatabase::getInstance()->get_fields('cms_content', "title LIKE '{$content_title}'", 'seolink, title');
    if ($content) {
        $link = '<a href="/' . $content['seolink'] . '.html" title="' . htmlspecialchars($content['title']) . '">' . $content['title'] . '</a>';
    } else {
        $link = '';
    }
    return $link;
}
开发者ID:deltas1,项目名称:icms1,代码行数:11,代码来源:filter.php

示例2: files

function files()
{
    $inDB = cmsDatabase::getInstance();
    global $_LANG;
    $do = cmsCore::getInstance()->do;
    $model = new cms_model_files();
    //============================================================================//
    // Скачивание
    if ($do == 'view') {
        $fileurl = cmsCore::request('fileurl', 'html', '');
        if (mb_strpos($fileurl, '-') === 0) {
            $fileurl = htmlspecialchars_decode(base64_decode(ltrim($fileurl, '-')));
        }
        $fileurl = cmsCore::strClear($fileurl);
        if (!$fileurl || mb_strstr($fileurl, '..') || strpos($fileurl, '.') === 0) {
            cmsCore::error404();
        }
        if (strpos($fileurl, 'http') === 0) {
            $model->increaseDownloadCount($fileurl);
            cmsCore::redirect($fileurl);
        } elseif (file_exists(PATH . $fileurl)) {
            $model->increaseDownloadCount($fileurl);
            header('Content-Disposition: attachment; filename=' . basename($fileurl) . "\n");
            header('Content-Type: application/x-force-download; name="' . $fileurl . '"' . "\n");
            header('Location:' . $fileurl);
            cmsCore::halt();
        } else {
            cmsCore::halt($_LANG['FILE_NOT_FOUND']);
        }
    }
    //============================================================================//
    if ($do == 'redirect') {
        $url = str_replace(array('--q--', ' '), array('?', '+'), cmsCore::request('url', 'str', ''));
        if (mb_strpos($url, '-') === 0) {
            $url = htmlspecialchars_decode(base64_decode(ltrim($url, '-')));
        }
        $url = cmsCore::strClear($url);
        if (!$url || mb_strstr($url, '..') || strpos($url, '.') === 0) {
            cmsCore::error404();
        }
        // кириллические домены
        $url_host = parse_url($url, PHP_URL_HOST);
        if (preg_match('/^[а-яё]+/iu', $url_host)) {
            cmsCore::loadClass('idna_convert');
            $IDN = new idna_convert();
            $host = $IDN->encode($url_host);
            $url = str_ireplace($url_host, $host, $url);
        }
        cmsCore::redirect($url);
    }
    //============================================================================//
}
开发者ID:vicktorwork,项目名称:cms1,代码行数:52,代码来源:frontend.php

示例3: cmsSubmitKarma

function cmsSubmitKarma($target, $item_id, $points)
{
    $inUser = cmsUser::getInstance();
    $inDB = cmsDatabase::getInstance();
    $ip = cmsCore::strClear($_SERVER['REMOTE_ADDR']);
    $target = cmsCore::strClear($target);
    $points = (int) $points;
    $item_id = (int) $item_id;
    if (cmsAlreadyKarmed($target, $item_id, $inUser->id)) {
        return false;
    }
    //вставляем новый голос
    $sql = "INSERT INTO cms_ratings (item_id, points, ip, target, user_id, pubdate)\n            VALUES ('{$item_id}', '{$points}', '{$ip}', '{$target}', '{$inUser->id}', NOW())";
    $inDB->query($sql);
    //проверяем была ли сделана агрегация для этой цели ранее
    $is_agr = $inDB->rows_count('cms_ratings_total', "target='{$target}' AND item_id = '{$item_id}'", 1);
    //если была, то обновляем
    if ($is_agr) {
        $agr_sql = "UPDATE cms_ratings_total\n                               SET  total_rating = total_rating + ({$points}),\n                                    total_votes  = total_votes + 1\n                               WHERE target='{$target}' AND item_id = '{$item_id}'";
    }
    //если не было, то вставляем
    if (!$is_agr) {
        $agr_sql = "INSERT INTO cms_ratings_total (target, item_id, total_rating, total_votes)\n                                VALUES ('{$target}', '{$item_id}', '{$points}', '1')";
    }
    $inDB->query($agr_sql);
    //получаем информацию о цели
    $info = $inDB->get_fields('cms_rating_targets', "target='{$target}'", '*');
    //если нужно, изменяем рейтинг автора цели
    if ($info['is_user_affect'] && $info['user_weight'] && $info['target_table']) {
        $user_sql = "UPDATE cms_users u,\n                            {$info['target_table']} t\n                     SET u.rating = u.rating + ({$points}*{$info['user_weight']})\n                     WHERE t.user_id = u.id AND t.id = '{$item_id}'";
        $inDB->query($user_sql);
    }
    //проверяем наличие метода updateRatingHook(target, item_id, points) в модели
    //компонента, ответственного за цель
    if ($info['component']) {
        cmsCore::loadModel($info['component']);
        if (class_exists('cms_model_' . $info['component'])) {
            $model_class = 'cms_model_' . $info['component'];
            $model = new $model_class();
            // если метод есть, пользуемся им
            if (method_exists($model, 'updateRatingHook')) {
                $model->updateRatingHook($target, $item_id, $points);
            } else {
                if ($inDB->isFieldExists($info['target_table'], 'rating')) {
                    $sql = "UPDATE {$info['target_table']}\n                            SET rating = rating + ({$points})\n                            WHERE id = '{$item_id}'";
                    $inDB->query($sql);
                }
            }
        }
    }
    return true;
}
开发者ID:4uva4ek,项目名称:svato,代码行数:52,代码来源:lib_karma.php

示例4: mb_substr

     cmsCore::addSessionMessage($_LANG['ERROR_TYPE_FILE'] . ': ' . $model->config['filestype'], 'error');
     cmsCore::redirectBack();
 }
 if (!in_array($ext, $maytypes, true)) {
     cmsCore::addSessionMessage($_LANG['ERROR_TYPE_FILE'] . ': ' . $model->config['filestype'], 'error');
     cmsCore::redirectBack();
 }
 // Переводим имя файла в транслит
 // отделяем имя файла от расширения
 $name = mb_substr($name, 0, mb_strrpos($name, '.'));
 // транслитируем
 $name = cmsCore::strToURL(preg_replace('/\\.+\\//', '', $name)) . uniqid();
 // присоединяем расширения файла
 $name .= '.' . $ext;
 // Обрабатываем получившееся имя файла для записи в БД
 $name = cmsCore::strClear($name);
 // Проверяем свободное место
 if ($size_mb > $free_mb && $model->config['filessize']) {
     cmsCore::addSessionMessage($_LANG['YOUR_FILE_LIMIT'] . ' (' . $max_mb . ' ' . $_LANG['MBITE'] . ') ' . $_LANG['IS_OVER_LIMIT'] . '<br>' . $_LANG['FOR_NEW_FILE_DEL_OLD'], 'error');
     cmsCore::redirectBack();
 }
 // Загружаем файл
 if ($inCore->moveUploadedFile($data_array['tmp_name'], PATH . '/upload/userfiles/' . $usr['id'] . '/' . $name, $data_array['error'])) {
     // если загрузили фото, проверяем его
     if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png', 'bmp'), true)) {
         $size = getimagesize(PATH . '/upload/userfiles/' . $usr['id'] . '/' . $name);
         if ($size === false) {
             @unlink(PATH . '/upload/userfiles/' . $usr['id'] . '/' . $name);
             continue;
         }
     }
开发者ID:deltas1,项目名称:icms1,代码行数:31,代码来源:files.php

示例5: users

function users()
{
    header('X-Frame-Options: DENY');
    $inCore = cmsCore::getInstance();
    $inPage = cmsPage::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inUser = cmsUser::getInstance();
    global $_LANG;
    $model = new cms_model_users();
    // id пользователя
    $id = cmsCore::request('id', 'int', 0);
    // логин пользователя
    $login = cmsCore::strClear(urldecode(cmsCore::request('login', 'html', '')));
    $do = $inCore->do;
    $page = cmsCore::request('page', 'int', 1);
    $pagetitle = $inCore->getComponentTitle();
    if ($model->config['sw_search'] != 2) {
        $inPage->addPathway($pagetitle, '/users');
    }
    $inPage->setTitle($pagetitle);
    $inPage->setDescription($pagetitle);
    // js только авторизованным
    if ($inUser->id) {
        $inPage->addHeadJS('components/users/js/profile.js');
        $inPage->addHeadJsLang(array('CONFIRM_CLEAN_CAT', 'CHOOSE_RECIPIENT', 'SEND_TO_USER', 'FRIENDSHIP_OFFER', 'STOP_FRIENDLY', 'REALY_STOP_FRIENDLY', 'ENTER_STATUS', 'HAVE_JUST'));
    }
    //============================================================================//
    //========================= Список пользователей  ============================//
    //============================================================================//
    if ($do == 'view') {
        // если запрещен просмотр всех пользователей, 404
        if ($model->config['sw_search'] == 2) {
            cmsCore::error404();
        }
        //очищаем поисковые запросы если пришли со другой страницы
        if (!strstr(cmsCore::getBackURL(), '/users')) {
            cmsUser::sessionClearAll();
        }
        $stext = array();
        // Возможные входные переменные
        $name = cmsCore::getSearchVar('name');
        $city = cmsCore::getSearchVar('city');
        $hobby = cmsCore::getSearchVar('hobby');
        $gender = cmsCore::getSearchVar('gender');
        $orderby = cmsCore::request('orderby', array('karma', 'rating', 'regdate'), 'regdate');
        $orderto = cmsCore::request('orderto', array('asc', 'desc'), 'desc');
        $age_to = (int) cmsCore::getSearchVar('ageto', 'all');
        $age_fr = (int) cmsCore::getSearchVar('agefrom', 'all');
        $group_id = cmsCore::request('group_id', 'int', 0);
        // Флаг о показе только онлайн пользователей
        if (cmsCore::inRequest('online')) {
            cmsUser::sessionPut('usr_online', (bool) cmsCore::request('online', 'int'));
            $page = 1;
        }
        $only_online = cmsUser::sessionGet('usr_online');
        if ($only_online) {
            $stext[] = $_LANG['SHOWING_ONLY_ONLINE'];
        }
        ///////////////////////////////////////
        //////////Условия выборки//////////////
        ///////////////////////////////////////
        // группа
        if ($group_id) {
            $model->whereUserGroupIs($group_id);
            $link['group'] = '/users/group/' . $group_id;
            $_LANG['GROUP_SEARCH_NAME'] = cmsUser::getGroupTitle($group_id);
        }
        // Добавляем в выборку имя, если оно есть
        if ($name) {
            $model->whereNameIs($name);
            $stext[] = $_LANG['NAME'] . " &mdash; " . htmlspecialchars(stripslashes($name));
        }
        // Добавляем в выборку город, если он есть
        if ($city) {
            $model->whereCityIs($city);
            $stext[] = $_LANG['CITY'] . " &mdash; " . htmlspecialchars(stripslashes($city));
        }
        // Добавляем в выборку хобби, если есть
        if ($hobby) {
            $model->whereHobbyIs($hobby);
            $stext[] = $_LANG['HOBBY'] . " &mdash; " . htmlspecialchars(stripslashes($hobby));
        }
        // Добавляем в выборку пол, если есть
        if ($gender) {
            $model->whereGenderIs($gender);
            if ($gender == 'm') {
                $stext[] = $_LANG['MALE'];
            } else {
                $stext[] = $_LANG['FEMALE'];
            }
        }
        // Добавляем в выборку возраст, более
        if ($age_fr) {
            $model->whereAgeFrom($age_fr);
            $stext[] = $_LANG['NOT_YOUNG'] . " {$age_fr} " . $_LANG['YEARS'];
        }
        // Добавляем в выборку возраст, менее
        if ($age_to) {
            $model->whereAgeTo($age_to);
            $stext[] = $_LANG['NOT_OLD'] . " {$age_fr} " . $_LANG['YEARS'];
//.........这里部分代码省略.........
开发者ID:deltas1,项目名称:icms1,代码行数:101,代码来源:frontend.php

示例6: comments

function comments($target = '', $target_id = 0, $labels = array())
{
    $inCore = cmsCore::getInstance();
    $inPage = cmsPage::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inUser = cmsUser::getInstance();
    cmsCore::loadModel('comments');
    $model = new cms_model_comments($labels);
    // Проверяем включени ли компонент
    if (!$inCore->isComponentEnable('comments')) {
        return false;
    }
    // Инициализируем права доступа для группы текущего пользователя
    $model->initAccess();
    global $_LANG;
    $do = $inCore->do;
    $page = cmsCore::request('page', 'int', 1);
    $id = cmsCore::request('id', 'int', 0);
    $login = cmsCore::strClear(urldecode(cmsCore::request('login', 'html', '')));
    $inPage->addHeadJS('components/comments/js/comments.js');
    $inPage->addHeadJsLang(array('EDIT_COMMENT', 'CONFIRM_DEL_COMMENT', 'COMMENT_IN_LINK'));
    //========================================================================================================================//
    //========================================================================================================================//
    if ($do == 'view' && !$target && !$target_id) {
        if (!$login) {
            $myprofile = false;
            $page_title = $inCore->getComponentTitle();
            $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . $_LANG['COMMENTS'] . '" href="' . HOST . '/rss/comments/all/feed.rss">');
        } else {
            // проверяем что пользователь есть
            $user = cmsUser::getShortUserData($login);
            if (!$user) {
                cmsCore::error404();
            }
            // Мои комментарии
            $myprofile = $inUser->id == $user['id'];
            $page_title = $_LANG['COMMENTS'] . ' - ' . $user['nickname'];
            $inPage->addPathway($user['nickname'], cmsUser::getProfileURL($user['login']));
            // Добавляем условие в выборку
            $model->whereUserIs($user['id']);
        }
        $inPage->setTitle($page_title);
        $inPage->addPathway($page_title);
        $inPage->setDescription($model->config['meta_desc'] ? $model->config['meta_desc'] : $page_title);
        $inPage->setKeywords($model->config['meta_keys'] ? $model->config['meta_keys'] : $page_title);
        // флаг модератора
        $is_moder = $inUser->is_admin || $model->is_can_moderate;
        // Не админам только открытые комментарии
        if (!($is_moder || $myprofile)) {
            $model->whereIsShow();
        }
        // Общее количество комментариев
        $total = $model->getCommentsCount(!($is_moder || $myprofile));
        // Сортировка и разбивка на страницы
        $inDB->orderBy('c.pubdate', 'DESC');
        $inDB->limitPage($page, $model->config['perpage']);
        // Сами комментарии
        $comments = $total ? $model->getComments(!($is_moder || $myprofile)) : array();
        $inDB->resetConditions();
        if (!$comments && $page > 1) {
            cmsCore::error404();
        }
        // пагинация
        if (!$login) {
            $pagebar = cmsPage::getPagebar($total, $page, $model->config['perpage'], '/comments/page-%page%');
        } else {
            $pagebar = cmsPage::getPagebar($total, $page, $model->config['perpage'], 'javascript:centerLink(\'/comments/by_user_' . $user['login'] . '/page-%page%\')');
        }
        // Отдаем в шаблон
        cmsPage::initTemplate('components', 'com_comments_list_all')->assign('comments_count', $total)->assign('comments', $comments)->assign('pagebar', $pagebar)->assign('is_user', $inUser->id)->assign('page_title', $page_title)->assign('cfg', $model->config)->assign('is_admin', $is_moder)->display('com_comments_list_all.tpl');
    }
    //========================================================================================================================//
    //========================================================================================================================//
    if (!in_array($do, array('add', 'edit', 'delete')) && $target && $target_id) {
        if (!$model->config['cmm_ajax']) {
            $model->whereTargetIs($target, $target_id);
            $inDB->orderBy('c.pubdate', 'ASC');
            $comments = cmsCore::callEvent('BEFORE_SHOW_COMMENTS', $model->getComments(!($inUser->is_admin || $model->is_can_moderate), true));
            $total = count($comments);
            ob_start();
            cmsPage::initTemplate('components', 'com_comments_list')->assign('comments_count', $total)->assign('comments', $comments)->assign('user_can_moderate', $model->is_can_moderate)->assign('user_can_delete', $model->is_can_delete)->assign('user_can_add', $model->is_can_add)->assign('is_admin', $inUser->is_admin)->assign('is_user', $inUser->id)->assign('cfg', $model->config)->assign('labels', $model->labels)->assign('target', $target)->assign('target_id', $target_id)->display('com_comments_list.tpl');
            $html = ob_get_clean();
        } else {
            $model->whereTargetIs($target, $target_id);
            $total = $model->getCommentsCount(!($inUser->is_admin || $model->is_can_moderate));
            $inDB->resetConditions();
        }
        cmsPage::initTemplate('components', 'com_comments_view')->assign('comments_count', $total)->assign('target', $target)->assign('target_id', $target_id)->assign('is_admin', $inUser->is_admin)->assign('labels', $model->labels)->assign('is_user', $inUser->id)->assign('cfg', $model->config)->assign('user_can_add', $model->is_can_add)->assign('html', isset($html) ? $html : '')->assign('add_comment_js', "addComment('" . $target . "', '" . $target_id . "', 0)")->assign('user_subscribed', cmsUser::isSubscribed($inUser->id, $target, $target_id))->display('com_comments_view.tpl');
    }
    //========================================================================================================================//
    //========================================================================================================================//
    // Добавление комментария, форма добавления в addform.php
    if ($do == 'add') {
        // Только аякс
        if (!cmsCore::isAjax()) {
            cmsCore::error404();
        }
        // Очищаем буфер
        ob_end_clean();
        // Добавлять могут только админы и те, кому разрешено в настройках группы
//.........这里部分代码省略.........
开发者ID:vicktorwork,项目名称:cms1,代码行数:101,代码来源:frontend.php

示例7: content

function content()
{
    $inCore = cmsCore::getInstance();
    $inPage = cmsPage::getInstance();
    $inDB = cmsDatabase::getInstance();
    $inUser = cmsUser::getInstance();
    $model = new cms_model_content();
    define('IS_BILLING', $inCore->isComponentInstalled('billing'));
    if (IS_BILLING) {
        cmsCore::loadClass('billing');
    }
    global $_LANG;
    $id = cmsCore::request('id', 'int', 0);
    $do = $inCore->do;
    $seolink = cmsCore::strClear(urldecode(cmsCore::request('seolink', 'html', '')));
    if (is_numeric($seolink)) {
        cmsCore::error404();
    }
    $page = cmsCore::request('page', 'int', 1);
    ///////////////////////////////////// VIEW CATEGORY ////////////////////////////////////////////////////////////////////////////////
    if ($do == 'view') {
        $cat = $inDB->getNsCategory('cms_category', $seolink);
        // если не найдена категория и мы не на главной, 404
        if (!$cat && $inCore->menuId() !== 1) {
            cmsCore::error404();
        }
        // языки
        $cat = translations::process(cmsConfig::getConfig('lang'), 'content_category', $cat);
        // Плагины
        $cat = cmsCore::callEvent('GET_CONTENT_CAT', $cat);
        // Неопубликованные показываем только админам
        if (!$cat['published'] && !$inUser->is_admin) {
            cmsCore::error404();
        }
        // Проверяем доступ к категории
        if (!$inCore->checkUserAccess('category', $cat['id'])) {
            cmsCore::addSessionMessage($_LANG['NO_PERM_FOR_VIEW_TEXT'] . '<br>' . $_LANG['NO_PERM_FOR_VIEW_RULES'], 'error');
            cmsCore::redirect('/content');
        }
        // если не корень категорий
        if ($cat['NSLevel'] > 0) {
            $inPage->setTitle($cat['pagetitle'] ? $cat['pagetitle'] : $cat['title']);
            $pagetitle = $cat['title'];
            $showdate = $cat['showdate'];
            $showcomm = $cat['showcomm'];
            $inPage->addHead('<link rel="alternate" type="application/rss+xml" title="' . htmlspecialchars($cat['title']) . '" href="' . HOST . '/rss/content/' . $cat['id'] . '/feed.rss">');
        }
        // Если корневая категория
        if ($cat['NSLevel'] == 0) {
            if ($model->config['hide_root']) {
                cmsCore::error404();
            }
            $inPage->setTitle($_LANG['CATALOG_ARTICLES']);
            $pagetitle = $_LANG['CATALOG_ARTICLES'];
            $showdate = 1;
            $showcomm = 1;
        }
        // Получаем дерево категорий
        $path_list = $inDB->getNsCategoryPath('cms_category', $cat['NSLeft'], $cat['NSRight'], 'id, title, NSLevel, seolink, url');
        if ($path_list) {
            $path_list = translations::process(cmsConfig::getConfig('lang'), 'content_category', $path_list);
            foreach ($path_list as $pcat) {
                if (!$inCore->checkUserAccess('category', $pcat['id'])) {
                    cmsCore::addSessionMessage($_LANG['NO_PERM_FOR_VIEW_TEXT'] . '<br>' . $_LANG['NO_PERM_FOR_VIEW_RULES'], 'error');
                    cmsCore::redirect('/content');
                }
                $inPage->addPathway($pcat['title'], $model->getCategoryURL(null, $pcat['seolink']));
            }
        }
        // Получаем подкатегории
        $subcats_list = $model->getSubCats($cat['id']);
        // Привязанный фотоальбом
        $cat_photos = $model->getCatPhotoAlbum($cat['photoalbum']);
        // Получаем статьи
        // Редактор/администратор
        $is_editor = $cat['modgrp_id'] == $inUser->group_id && cmsUser::isUserCan('content/autoadd') || $inUser->is_admin;
        // Условия
        $model->whereCatIs($cat['id']);
        // Общее количество статей
        $total = $model->getArticlesCount($is_editor);
        // Сортировка и разбивка на страницы
        $inDB->orderBy($cat['orderby'], $cat['orderto']);
        $inDB->limitPage($page, $model->config['perpage']);
        // Получаем статьи
        $content_list = $total ? $model->getArticlesList(!$is_editor) : array();
        $inDB->resetConditions();
        if (!$content_list && $page > 1) {
            cmsCore::error404();
        }
        $pagebar = cmsPage::getPagebar($total, $page, $model->config['perpage'], $model->getCategoryURL(null, $cat['seolink'], 0, true));
        $template = $cat['tpl'] ? $cat['tpl'] : 'com_content_view.tpl';
        if ($cat['NSLevel'] > 0) {
            // meta description
            if ($cat['meta_desc']) {
                $meta_desc = $cat['meta_desc'];
            } elseif (mb_strlen(strip_tags($cat['description'])) >= 250) {
                $meta_desc = crop($cat['description']);
            } else {
                $meta_desc = $cat['title'];
            }
//.........这里部分代码省略.........
开发者ID:deltas1,项目名称:icms1,代码行数:101,代码来源:frontend.php

示例8: goToLogin

 /**
  * Запоминает текущий URI в сессии и перенаправляет пользователя на форму логина
  */
 public static function goToLogin()
 {
     self::sessionPut('auth_back_url', cmsCore::strClear($_SERVER['REQUEST_URI']));
     cmsCore::redirect('/login');
 }
开发者ID:vicktorwork,项目名称:cms1,代码行数:8,代码来源:user.class.php

示例9: updatePoll

 /**
  * Обновляет опрос
  * @param array $poll
  * @param array $latest_poll
  * @return bool
  */
 public function updatePoll($poll, $latest_poll)
 {
     global $_LANG;
     $t_poll['title'] = cmsCore::strClear($poll['title']);
     if (!$t_poll['title']) {
         return false;
     }
     $t_poll['description'] = cmsCore::strClear($poll['desc']);
     $t_poll['enddate'] = date("Y-m-d H:i:s", (int) $poll['days'] * 86400 + time());
     $options['result'] = (int) $poll['result'];
     $options['change'] = (int) $poll['change'];
     $t_poll['options'] = cmsCore::arrayToYaml($options);
     // Формируем массив голосов
     foreach ($latest_poll['answers'] as $vote_count) {
         $vote_counts[] = $vote_count;
     }
     // Новый массив вопросов
     foreach ($poll['answers'] as $new_answer) {
         $new_answers[] = strip_tags($new_answer);
     }
     // Результирующий массив
     foreach ($new_answers as $key => $answer) {
         if ($answer) {
             $answers[$answer] = isset($vote_counts[$key]) ? $vote_counts[$key] : 0;
         }
     }
     if (sizeof($answers) < 2) {
         $this->last_addpoll_error = $_LANG['ERR_POLL_VARIANT'];
         return false;
     }
     $t_poll['answers'] = $this->inDB->escape_string(cmsCore::arrayToYaml($answers));
     return $this->inDB->update('cms_forum_polls', cmsCore::callEvent('UPDATE_FORUM_POLL', $t_poll), $latest_poll['id']);
 }
开发者ID:r2git,项目名称:icms1,代码行数:39,代码来源:model.php

示例10: createUser

 private function createUser($profile)
 {
     $inCore = cmsCore::getInstance();
     $inDB = cmsDatabase::getInstance();
     $inUser = cmsUser::getInstance();
     cmsCore::loadClass('actions');
     $nickname = $email = $birthdate = '';
     $advanced = array();
     // для вконтакте поолучаем большой аватар, статус и город
     if (strstr($profile->identity, '//vk.com')) {
         $vk = $this->callVk($profile->uid);
         if ($vk) {
             $advanced = array('city' => $vk->city->title, 'status' => $vk->status, 'photo' => $vk->photo_max_orig);
         }
     }
     if (!empty($profile->name->full_name)) {
         // указано полное имя
         $nickname = $profile->name->full_name;
     } elseif (!empty($profile->name->first_name)) {
         // указано имя и фамилия по-отдельности
         $nickname = $profile->name->first_name;
         if (!empty($profile->name->last_name)) {
             $nickname .= ' ' . $profile->name->last_name;
         }
     } elseif (preg_match('/^(http:\\/\\/)([a-zA-Z0-9\\-_]+)\\.([a-zA-Z0-9\\-_]+)\\.([a-zA-Z]{2,6})([\\/]?)$/i', $profile->identity)) {
         // не указано имя, но передан идентификатор в виде домена
         $nickname = parse_url($profile->identity, PHP_URL_HOST);
     }
     $nickname = cmsCore::strClear($nickname);
     $login = substr(str_replace('-', '', cmsCore::strToURL($nickname)), 0, 15);
     if (!$nickname || !$login) {
         // не указано вообще ничего
         $max = $inDB->get_fields('cms_users', 'id>0', 'id', 'id DESC');
         $nickname = $login = 'user' . ($max['id'] + 1);
     }
     // генерируем пароль
     $pass = md5(substr(md5(microtime() . uniqid()), 0, 8));
     if (!empty($profile->email)) {
         $email = cmsCore::strClear($profile->email);
         $already_email = $inDB->get_field('cms_users', "email='{$email}' AND is_deleted=0", 'email');
         if ($already_email == $email) {
             cmsCore::redirect('/auth/error.html');
         }
     }
     if (!empty($profile->dob)) {
         $birthdate = cmsCore::strClear($profile->dob);
     }
     // проверяем занятость логина
     if ($inDB->get_field('cms_users', "login='{$login}' AND is_deleted=0", 'login') == $login) {
         // если логин занят, добавляем к нему ID
         $max = $inDB->get_fields('cms_users', 'id>0', 'id', 'id DESC');
         $login .= $max['id'] + 1;
     }
     $user_array = cmsCore::callEvent('USER_BEFORE_REGISTER', array('status' => !empty($advanced['status']) ? $advanced['status'] : '', 'status_date' => date('Y-m-d H:i:s'), 'login' => $login, 'nickname' => $nickname, 'password' => $pass, 'email' => $email, 'birthdate' => $birthdate, 'group_id' => $this->reg_model->config['default_gid'], 'regdate' => date('Y-m-d H:i:s'), 'logdate' => date('Y-m-d H:i:s'), 'invited_by' => 0, 'openid' => md5($profile->identity)));
     $user_array['id'] = $user_id = $inDB->insert('cms_users', $user_array);
     // создаем профиль пользователя
     if ($user_id) {
         $filename = 'nopic.jpg';
         // если есть аватар, пробуем скачать
         if (!empty($profile->photo) || !empty($advanced['photo'])) {
             $photo_path = $this->downloadAvatar(!empty($advanced['photo']) ? $advanced['photo'] : $profile->photo);
             if ($photo_path) {
                 cmsCore::includeGraphics();
                 $uploaddir = PATH . '/images/users/avatars/';
                 $filename = md5($photo_path . '-' . $user_id . '-' . time()) . '.jpg';
                 $uploadavatar = $uploaddir . $filename;
                 $uploadthumb = $uploaddir . 'small/' . $filename;
                 $cfg = $inCore->loadComponentConfig('users');
                 @img_resize($photo_path, $uploadavatar, $cfg['medw'], $cfg['medh']);
                 @img_resize($photo_path, $uploadthumb, $cfg['smallw'], $cfg['smallw']);
                 @unlink($photo_path);
             }
         }
         $inUser->loadUserGeo();
         $inDB->insert('cms_user_profiles', array('city' => !empty($advanced['city']) ? $advanced['city'] : $inUser->city, 'user_id' => $user_id, 'imageurl' => $filename, 'gender' => !empty($profile->gender) ? strtolower($profile->gender) : 'm'));
         cmsCore::callEvent('USER_REGISTER', $user_array);
         cmsActions::log('add_user', array('object' => '', 'user_id' => $user_id, 'object_url' => '', 'object_id' => $user_id, 'target' => '', 'target_url' => '', 'target_id' => 0, 'description' => ''));
         if ($this->reg_model->config['send_greetmsg']) {
             $this->reg_model->sendGreetsMessage($user_id);
         }
         return $user_id;
     }
     return false;
 }
开发者ID:4uva4ek,项目名称:svato,代码行数:84,代码来源:plugin.php

示例11: catalog

function catalog(){

    $inCore = cmsCore::getInstance();
    $inPage = cmsPage::getInstance();
    $inDB   = cmsDatabase::getInstance();
    $inUser = cmsUser::getInstance();

    global $_LANG;

    $model = new cms_model_catalog();

    define('IS_BILLING', $inCore->isComponentInstalled('billing'));
    if (IS_BILLING) { cmsCore::loadClass('billing'); }

    $pagetitle = $inCore->getComponentTitle();

	$inPage->addPathway($pagetitle, '/catalog');
	$inPage->setTitle($pagetitle);

	$inPage->setDescription($model->config['meta_desc'] ? $model->config['meta_desc'] : $pagetitle);
    $inPage->setKeywords($model->config['meta_keys'] ? $model->config['meta_keys'] : $pagetitle);

    $cfg = $inCore->loadComponentConfig('catalog');

    if (cmsCore::inRequest('cat_id')){
        $id = cmsCore::request('cat_id', 'int', 0);
    } else {
        $id = cmsCore::request('id', 'int', 0);
    }

    $do = $inCore->do;

    cmsCore::includeFile('components/catalog/includes/shopcore.php');

    //////////////////////////// RATING SUBMISSION ///////////////////////////////////////////////////////////////////
    if (cmsCore::inRequest('rating')){
        $points     = cmsCore::request('points', 'int', 0);
        $item_id    = cmsCore::request('item_id', 'int', 0);
        $ip         = $inUser->ip;
        if (!alreadyVoted($item_id)){
            $inDB->query("INSERT INTO cms_uc_ratings (item_id, points, ip) VALUES ($item_id, $points, '$ip')") ;
            $inDB->query("DELETE FROM cms_uc_ratings WHERE item_id = $item_id AND ip = '0.0.0.0'") ;
        }
    }

    //////////////////////////// SEARCH BY TAG ///////////////////////////////////////////////////////////////////////
    if ($do == 'tag') {

		$tag = $inCore->strClear(urldecode($inCore->request('tag', 'html', '')));

        $sql = "SELECT tag FROM cms_tags WHERE tag = '$tag' AND target='catalog' LIMIT 1";
        $result = $inDB->query($sql) ;
        if ($inDB->num_rows($result)==1){
            $item = $inDB->fetch_assoc($result);
            $query = $inCore->strClear($item['tag']);
            $findsql = "SELECT *
                        FROM cms_uc_items
                        WHERE category_id = '$id' AND published = 1 AND tags LIKE '%$query%'";
            $do = 'cat';
        } else { echo $_LANG['NO_MATCHING_FOUND']; }

    }
    //////////////////////////// ADVANCED SEARCH ////////////////////////////////////////////////////////////////////
    if ($do == 'search') {

        if (cmsCore::inRequest('gosearch')){

            $fdata = cmsCore::request('fdata', 'array', array());
            $query = cmsCore::strClear(implode('%', $fdata));
            $title = cmsCore::request('title', 'str', '');
            $tags  = cmsCore::request('tags', 'str', '');

            if ($query || $title || $tags){

                $findsql = "SELECT i.* , IFNULL(AVG(r.points),0) AS rating
                            FROM cms_uc_items i
                            LEFT JOIN cms_uc_ratings r ON r.item_id = i.id
                            WHERE i.published = 1 AND i.category_id = '$id' ";

                if($query){
                    $findsql .= " AND i.fieldsdata LIKE '%{$query}%' ";
                }
                if($title){
                    $findsql .= " AND i.title LIKE '%$title%' ";
                }
                if($tags){
                    $findsql .= "AND (i.tags LIKE '%".$tags."%')";
                }

                $findsql .=	" GROUP BY i.id";
                $advsearch = 1;
            }
            $do = 'cat';
        } else {
            //show search form
            $sql = "SELECT * FROM cms_uc_cats WHERE id = '$id'";
            $result = $inDB->query($sql) ;

            if ($inDB->num_rows($result)==1){
                $cat = $inDB->fetch_assoc($result);
//.........这里部分代码省略.........
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:101,代码来源:frontend.php

示例12: geo

function geo($do=null) {
    // Определяем местоположение пользователя
    cmsCore::c('user')->loadUserGeo();
    
    $do = isset($do) ? $do : cmsCore::getInstance()->do;

    $field_id = cmsCore::request('field_id', 'int', 0);
    $city_id  = cmsCore::strClear(urldecode(cmsCore::request('city_id', 'html', 0))); // можно передавать как id города, так и название

//========================================================================================================================//
    if ($do == 'view'){
        if (!cmsCore::isAjax()) { cmsCore::error404(); }

        $countries = cmsCore::m('geo')->getCountries();
        $regions   = array();
        $cities    = array();

        $region_id  = false;
        
        // определяем страну
        if (isset(cmsCore::c('user')->geo['country'])) {
            $country_id = cmsCore::c('db')->get_field('cms_geo_countries', "alpha2 = '". cmsCore::c('user')->geo['country'] ."'", 'id');
        } else {
            $country_id = false;
        } 

        if (!$city_id && cmsCore::c('user')->city) {
            $city_id = cmsCore::c('user')->city;
        }

        if ($city_id){

            $city_parents = cmsCore::m('geo')->getCityParents($city_id);

            if($city_parents){

                $region_id  = $city_parents['region_id'];
                $country_id = $city_parents['country_id'];

                $regions = cmsCore::m('geo')->getRegions($country_id);
                $cities  = cmsCore::m('geo')->getCities($region_id);

                $city_id = $city_parents['id'];

            } else {
                $city_id = 0;
            }

        }

        cmsPage::initTemplate('components', 'com_geo_view')->
                assign('field_id', $field_id)->
                assign('city_id', $city_id)->
                assign('country_id', $country_id)->
                assign('region_id', $region_id)->
                assign('countries', $countries)->
                assign('regions', $regions)->
                assign('cities', $cities)->
                display();

    }

//========================================================================================================================//
    if ($do == 'get'){

        if (!cmsCore::isAjax()) { cmsCore::error404(); }

        $type      = cmsCore::request('type', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);

        if (!in_array($type, array('regions', 'cities'))) { cmsCore::error404(); }
        if (!$parent_id) { cmsCore::error404(); }

        switch ( $type ){

            case 'regions': $items = cmsCore::m('geo')->getRegions( $parent_id );
                            break;

            case 'cities':  $items = cmsCore::m('geo')->getCities( $parent_id );
                            break;

            default: $items = array();

        }

        cmsCore::jsonOutput(array(
           'error' => $items ? false : true,
           'items' => $items
        ));

    }

}
开发者ID:Acsac,项目名称:CMS-RuDi,代码行数:93,代码来源:frontend.php

示例13: geo

function geo($do)
{
    $inUser = cmsUser::getInstance();
    $model = new cms_model_geo();
    // Определяем местоположение пользователя
    $inUser->loadUserGeo();
    $do = isset($do) ? $do : cmsCore::getInstance()->do;
    $field_id = cmsCore::request('field_id', 'int', 0);
    $city_id = cmsCore::strClear(urldecode($_REQUEST['city_id']));
    // можно передавать как id города, так и название
    //========================================================================================================================//
    if ($do == 'view') {
        if (!cmsCore::isAjax()) {
            cmsCore::error404();
        }
        $countries = $model->getCountries();
        $regions = array();
        $cities = array();
        $region_id = false;
        $country_id = false;
        if (!$city_id && $inUser->city) {
            $city_id = $inUser->city;
        }
        if ($city_id) {
            $city_parents = $model->getCityParents($city_id);
            if ($city_parents) {
                $region_id = $city_parents['region_id'];
                $country_id = $city_parents['country_id'];
                $regions = $model->getRegions($country_id);
                $cities = $model->getCities($region_id);
                $city_id = $city_parents['id'];
            } else {
                $city_id = 0;
            }
        }
        cmsPage::initTemplate('components', 'com_geo_view')->assign('field_id', $field_id)->assign('city_id', $city_id)->assign('country_id', $country_id)->assign('region_id', $region_id)->assign('countries', $countries)->assign('regions', $regions)->assign('cities', $cities)->display('com_geo_view.tpl');
    }
    //========================================================================================================================//
    if ($do == 'get') {
        if (!cmsCore::isAjax()) {
            cmsCore::error404();
        }
        $type = cmsCore::request('type', 'str', '');
        $parent_id = cmsCore::request('parent_id', 'int', 0);
        if (!in_array($type, array('regions', 'cities'))) {
            cmsCore::error404();
        }
        if (!$parent_id) {
            cmsCore::error404();
        }
        switch ($type) {
            case 'regions':
                $items = $model->getRegions($parent_id);
                break;
            case 'cities':
                $items = $model->getCities($parent_id);
                break;
            default:
                $items = array();
        }
        cmsCore::jsonOutput(array('error' => $items ? false : true, 'items' => $items));
    }
}
开发者ID:4uva4ek,项目名称:svato,代码行数:63,代码来源:frontend.php


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