Esempio n. 1
0
/**
 * Проверяем e-mail
 * @param string $mail - проверяемый e-mail
 *
 * @return bool|string TRUE or Error message
 */
function subscribe_checkEmail($mail = '')
{
    global $db_banlist, $db;
    // Проверяем бан-лист
    if (cot_plugin_active('banlist')) {
        $sql = cot::$db->query("SELECT banlist_reason, banlist_email FROM {$db_banlist}\n            WHERE banlist_email LIKE " . cot::$db->quote('%' . $mail . '%'));
        if ($row = $sql->fetch()) {
            $ret = cot::$L['aut_emailbanned'] . $row['banlist_reason'];
            return $ret;
        }
        $sql->closeCursor();
    }
    if (!cot_check_email($mail)) {
        $ret = cot::$L['subscribe_err_wrongmail'];
        return $ret;
    }
    return true;
}
Esempio n. 2
0
/**
 * Проверкаи запись постов пользователя
 * @param num $user_id - ID пользователя.
 * @return num - возвращаем посты.
 */
function karma_user_post($user_id)
{
    global $db, $db_forum_posts, $db_com, $db_pages, $db_users, $usr;
    if (cot_module_active('forums')) {
        cot::$db->registerTable('forum_posts');
        $frmc = $db->query("SELECT COUNT(*) FROM {$db_forum_posts}  WHERE fp_posterid = {$user_id} ")->fetchColumn();
    }
    if (cot_plugin_active('comments')) {
        cot::$db->registerTable('com');
        $comc = $db->query("SELECT COUNT(*) FROM {$db_com} WHERE com_authorid = {$user_id} ")->fetchColumn();
    }
    if (cot_module_active('page')) {
        cot::$db->registerTable('pages');
        $pgc = $db->query("SELECT COUNT(*) FROM {$db_pages}  WHERE page_ownerid = {$user_id}  and page_state = 0 ")->fetchColumn();
    }
    if (cot_module_active('users')) {
        cot::$db->registerTable('users');
        $klast = explode(":", $usr['profile']['user_karma_auth']);
        $karmasave = $klast[0] . ":" . $klast[1] . ":" . $klast[2] . ":" . ($frmc + $comc + $pgc);
        $db->query("UPDATE {$db_users} SET user_karma_auth = '" . $karmasave . "'   WHERE user_id= {$user_id} ");
    }
    return $frmc + $comc + $pgc;
}
<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=users.profile.update.first, users.edit.update.first, users.register.add.first
 * [END_COT_EXT]
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('usercategories', 'plug');
$catslimit = cot_cfg_usercategories();
$rcats = cot_import('rcats', 'P', 'ARR');
if (is_array($rcats)) {
    $rcats = array_filter($rcats);
    $ruser['user_cats'] = implode(',', $rcats);
    if ($m == 'edit' || $m == 'profile') {
        $groupid = $urr['user_maingrp'];
    } else {
        $groupid = cot_import('ruserusergroup', 'P', 'INT');
    }
    if (!cot_plugin_active('paypro') || cot_plugin_active('paypro') && !cot_getuserpro($urr)) {
        cot_check($catslimit[$groupid]['default'] > 0 && count($rcats) > $catslimit[$groupid]['default'], cot_rc($L['usercategories_error_catslimit'], array('limit' => $catslimit[$groupid]['default'])), 'rcats');
    } elseif (cot_plugin_active('paypro') && cot_getuserpro($urr)) {
        cot_check($catslimit[$groupid]['pro'] > 0 && count($rcats) > $catslimit[$groupid]['pro'], cot_rc($L['usercategories_error_catslimit'], array('limit' => $catslimit[$groupid]['pro'])), 'rcats');
    }
}
Esempio n. 4
0
$tr_t = new XTemplate(cot_tplfile($info ? 'trashcan.info.admin' : 'trashcan.admin', 'plug', true));
$totalitems = (int) $db->query("SELECT COUNT(*) FROM {$db_trash} WHERE tr_parentid=0")->fetchColumn();
$pagenav = cot_pagenav('admin', 'm=other&p=trashcan', $d, $totalitems, $maxperpage, 'd', '', $cfg['jquery'] && $cfg['turnajax']);
$sql_query = $info ? "AND tr_id={$id} LIMIT 1" : "ORDER by tr_id DESC LIMIT {$d}, " . $maxperpage;
$sql = $db->query("SELECT t.*, u.user_name FROM {$db_trash} AS t\n\tLEFT JOIN {$db_users} AS u ON t.tr_trashedby=u.user_id\n\tWHERE tr_parentid=0 {$sql_query}");
$ii = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('trashcan.admin.loop');
/* ===== */
foreach ($sql->fetchAll() as $row) {
    $ii++;
    switch ($row['tr_type']) {
        case 'comment':
            $icon = $R['admin_icon_comments'];
            $typestr = $L['Comment'];
            $enabled = cot_plugin_active('comments') ? 1 : 0;
            break;
        case 'forumpost':
            $icon = $R['admin_icon_forums_posts'];
            $typestr = $L['Post'];
            $enabled = cot_module_active('forums') ? 1 : 0;
            break;
        case 'forumtopic':
            $icon = $R['admin_icon_forums_topics'];
            $typestr = $L['Topic'];
            $enabled = cot_module_active('forums') ? 1 : 0;
            break;
        case 'page':
            $icon = $R['admin_icon_page'];
            $typestr = $L['Page'];
            $enabled = cot_module_active('page') ? 1 : 0;
Esempio n. 5
0
/**
 * Вычищаем ненужные символы из названий и текстов стадий
 *
 * @param array $rstagetitle Массив из title стадий
 * @param array $rstagetext Массив из text стадий
 * @param bool $purifier TRUE - вычистить внутренности скриптов, FALSE - заменить допустимыми символами
 */
function cot_validate_stages(&$rstagetitle, &$rstagetext, $purifier = false)
{
    // Если включен плагин htmlpurifier, то очищаем через него
    if ($purifier === true) {
        if (cot_plugin_active('htmlpurifier') && function_exists('htmlpurifier_filter')) {
            foreach ($rstagetitle as $key => $value) {
                $rstagetitle[$key] = htmlpurifier_filter($value, false);
            }
            foreach ($rstagetext as $key => $value) {
                $rstagetext[$key] = htmlpurifier_filter($value, false);
            }
        } else {
            error_log('Попытка функции cot_validate_stages валидировать title и text с помощью неактивного плагина htmlpurifier');
            return false;
        }
    } else {
        foreach ($rstagetitle as $key => $value) {
            $rstagetitle[$key] = str_replace('<', '&lt;', trim($value));
        }
        foreach ($rstagetext as $key => $value) {
            $rstagetext[$key] = str_replace('<', '&lt;', trim($value));
        }
    }
}
<?php

/**
 * pagecattree Plugin for Cotonti CMF
 *
 * @version 2.0.0
 * @author esclkm, http://www.littledev.ru
 * @copyright (c) 2008-2011 esclkm, http://www.littledev.ru
 */
defined('COT_CODE') or die('Wrong URL.');
$adminpath[] = array(cot_url('admin', 'm=structure'), $L['Structure']);
// Show available module list
if (is_array($extension_structure) && count($extension_structure) > 0) {
    foreach ($extension_structure as $code) {
        $parse = false;
        if (cot_plugin_active($code)) {
            $is_module = false;
            $parse = true;
        }
        if (cot_module_active($code)) {
            $is_module = true;
            $parse = true;
        }
        if ($parse) {
            $ext_info = cot_get_extensionparams($code, $is_module);
            $t->assign(array('ADMIN_STRUCTURE_EXT_URL' => cot_url('admin', 'm=other&p=cateditor&n=' . $code), 'ADMIN_STRUCTURE_EXT_ICO' => $ext_info['icon'], 'ADMIN_STRUCTURE_EXT_NAME' => $ext_info['name']));
            $t->parse('MAIN.ADMIN_STRUCTURE_EXT');
        }
    }
} else {
    $t->parse('MAIN.ADMIN_STRUCTURE_EMPTY');
Esempio n. 7
0
<?php

/**
 * Uninstallation handler
 *
 * @package I18n
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
if (cot_plugin_active('tags')) {
    // Remove i18n-specific tags
    require_once cot_incfile('tags', 'plug');
    global $db_tag_references;
    $db->delete($db_tag_references, "tag_locale != ''");
    $db->query("ALTER TABLE {$db_tag_references} DROP PRIMARY KEY");
    $db->query("ALTER TABLE {$db_tag_references} ADD PRIMARY KEY (`tag`,`tag_area`,`tag_item`)");
    $db->query("ALTER TABLE {$db_tag_references} DROP COLUMN `tag_locale`");
}
Esempio n. 8
0
/**
 * Anti-hammer protection
 *
 * @param int $hammer Hammer rate
 * @param string $action Action type
 * @param int $lastseen User last seen timestamp
 * @return int
 */
function cot_shield_hammer($hammer, $action, $lastseen)
{
    global $cfg, $sys;
    if ($action == 'Hammering') {
        cot_shield_protect();
        cot_shield_clearaction();
        cot_plugin_active('hits') && cot_stat_inc('totalantihammer');
    }
    if ($sys['now'] - $lastseen < 4) {
        $hammer++;
        if ($hammer > $cfg['shieldzhammer']) {
            cot_shield_update(180, 'Hammering');
            cot_log('IP banned 3 mins, was hammering', 'sec');
            $hammer = 0;
        }
    } else {
        if ($hammer > 0) {
            $hammer--;
        }
    }
    return $hammer;
}
Esempio n. 9
0
$pl_cfg = $cfg['plugin']['whosonline'];
$maxuserssperpage = is_numeric($pl_cfg['maxusersperpage']) ? $pl_cfg['maxusersperpage'] : 0;
list($pg, $d, $durl) = cot_import_pagenav('d', $maxuserssperpage);
$maxusers = 0;
if (isset($cfg['plugin']['hits'])) {
    require_once cot_incfile('hits', 'plug');
    $stats = $db->query("SELECT stat_value FROM {$db_stats} WHERE stat_name='maxusers' LIMIT 1")->fetch();
    $maxusers = $stats[0];
}
$count_users = 0;
$count_guests = 0;
if (cot_plugin_active('hiddengroups')) {
    require_once cot_incfile('hiddengroups', 'plug');
    $hiddenusers = cot_hiddengroups_get(cot_hiddengroups_mode(), 'users');
}
$ipsearch = cot_plugin_active('ipsearch');
$out['subtitle'] = $L['WhosOnline'];
$join_condition = "LEFT JOIN {$db_users} AS u ON u.user_id=o.online_userid";
if ($pl_cfg['disable_guests']) {
    $where = "WHERE o.online_userid > 0";
}
$is_user_check = 'IF(o.online_userid > 0,1,0) as is_user';
$limit = $maxuserssperpage ? "LIMIT {$d}, {$maxuserssperpage}" : '';
$sql_users = $db->query("\n\tSELECT DISTINCT u.*, o.*, {$is_user_check}\n\tFROM {$db_online} AS o\n\t{$join_condition} {$where}\n\tORDER BY is_user DESC, online_lastseen DESC {$limit}\n");
$sql_users_count = $db->query("SELECT COUNT(*) as cnt, {$is_user_check} FROM {$db_online} as o {$where} GROUP BY is_user");
$who_guests = 0;
$who_users = 0;
foreach ($sql_users_count as $row) {
    if ($row['is_user']) {
        $who_users = (int) $row['cnt'];
    } else {
Esempio n. 10
0
<?php

/**
 * markItUp! install handler
 *
 * @package MarItUp
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
// Installing new bbcodes
if (cot_plugin_active('bbcode')) {
    require_once cot_incfile('bbcode', 'plug');
    cot_bbcode_remove(0, 'markitup');
    cot_bbcode_add('size', 'pcre', '\\[size=([1-2][0-9])\\](.+?)\\[/size\\]', '<span style="font-size:$1pt">$2</span>', true, 128, 'markitup');
    cot_bbcode_add('table', 'str', '[table]', '<table>', true, 128, 'markitup');
    cot_bbcode_add('table', 'str', '[/table]', '</table>', true, 128, 'markitup');
    cot_bbcode_add('tr', 'str', '[tr]', '<tr>', true, 128, 'markitup');
    cot_bbcode_add('tr', 'str', '[/tr]', '</tr>', true, 128, 'markitup');
    cot_bbcode_add('th', 'str', '[th]', '<th>', true, 128, 'markitup');
    cot_bbcode_add('th', 'str', '[/th]', '</th>', true, 128, 'markitup');
    cot_bbcode_add('td', 'str', '[td]', '<td>', true, 128, 'markitup');
    cot_bbcode_add('td', 'str', '[/td]', '</td>', true, 128, 'markitup');
    cot_bbcode_add('hide', 'callback', '\\[hide\\](.+?)\\[/hide\\]', 'return $usr["id"] > 0 ? $input[1] : "<div class=\\"hidden\\">".$L["Hidden"]."</div>";', true, 150, 'markitup', true);
    cot_bbcode_add('spoiler', 'pcre', '\\[spoiler\\](.+?)\\[/spoiler\\]', '<div style="margin:4px 0px 4px 0px"><input type="button" value="' . $L['Show'] . '" onclick="if(this.parentNode.getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.getElementsByTagName(\'div\')[0].style.display = \'\'; } else { this.parentNode.getElementsByTagName(\'div\')[0].style.display = \'none\'; }" /><div style="display:none" class="spoiler">$1</div></div>', true, 130, 'markitup');
    cot_bbcode_add('spoiler', 'pcre', '\\[spoiler=([^\\]]+)\\](.+?)\\[/spoiler\\]', '<div style="margin:4px 0px 4px 0px"><input type="button" value="$1" onclick="if(this.parentNode.getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.getElementsByTagName(\'div\')[0].style.display = \'\'; } else { this.parentNode.getElementsByTagName(\'div\')[0].style.display = \'none\'; }" /><div style="display:none" class="spoiler">$2</div></div>', true, 130, 'markitup');
    cot_bbcode_clearcache();
}
Esempio n. 11
0
function cot_clear_mark($text, $words)
{
    global $cfg;
    $text = trim($text);
    if (!empty($text)) {
        $text = preg_replace("'\r?\n'", " ", $text);
        $text = preg_replace("'\\s+'", " ", $text);
        if (cot_plugin_active('bbcode')) {
            // BB
            $text = preg_replace("'\\[img.*?/img\\]'si", "", $text);
            $text = preg_replace("'\\[thumb.*?/thumb\\]'si", "", $text);
            $text = preg_replace("'[[^]]*?.*?]'si", "", $text);
        }
        // HTML
        $text = strip_tags($text);
        $text = htmlspecialchars($text, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
        foreach ($words as $i => $w) {
            $p = mb_stripos($text, $w);
            if ($p > 0) {
                $p_arr[] = $p;
            }
        }
        if (count($p_arr)) {
            sort($p_arr);
            $text_result = '';
            $last_pos = -1;
            $delta = 255 / count($p_arr);
            $text_len = mb_strlen($text);
            foreach ($p_arr as $pos_mid) {
                $pos_beg = $pos_mid - $delta;
                if ($pos_beg <= 0) {
                    $pos_beg = 0;
                } else {
                    while ($pos_beg > 0 && mb_substr($text, $pos_beg, 1) != " ") {
                        $pos_beg--;
                    }
                }
                $pos_end = $pos_mid + $delta;
                if ($pos_end > $text_len) {
                    $pos_end = $text_len;
                } else {
                    while ($pos_end < $text_len && mb_substr($text, $pos_end, 1) != " ") {
                        $pos_end++;
                    }
                }
                if ($pos_beg <= $last_pos) {
                    $arOtr[count($arOtr) - 1][1] = $pos_end;
                } else {
                    $arOtr[] = array($pos_beg, $pos_end);
                }
                $last_pos = $pos_end;
            }
            if (count($arOtr)) {
                for ($i = 0; $i < count($arOtr); $i++) {
                    $text_result .= $arOtr[$i][0] <= 0 ? '' : ' ...';
                    $text_result .= mb_substr($text, $arOtr[$i][0], $arOtr[$i][1] - $arOtr[$i][0]);
                    $text_result .= $arOtr[$i][1] >= $text_len ? '' : ' ... ';
                }
            }
        }
        if (mb_strlen($text_result) < 10) {
            $len_cut = 255;
            $len_txt = mb_strlen($text);
            $len_cut = $len_txt < $len_cut ? $len_txt : $len_cut;
            $text_result = mb_substr($text, 0, $len_cut);
            $text_result = $len_cut < $len_txt ? $text_result . '... ' : $text_result;
        }
        foreach ($words as $k => $i) {
            $text_result = str_ireplace($i, '<span class="search_hl">' . $i . '</span>', $text_result);
        }
        return $text_result;
    }
    return "";
}
Esempio n. 12
0
require_once cot_incfile('cateditor', 'plug');
require_once cot_incfile('cateditor', 'plug', 'structure');
require_once cot_langfile('cateditor', 'plug');
cot_rc_add_file($cfg['plugins_dir'] . '/cateditor/lib/jquery.nestable.js');
cot_rc_add_file($cfg['plugins_dir'] . '/cateditor/lib/jquery.cookie.js');
cot_rc_add_file($cfg['plugins_dir'] . '/cateditor/lib/jquery.nestable.css');
cot_rc_add_file($cfg['plugins_dir'] . '/cateditor/lib/cateditor.js');
/* === Hook === */
foreach (cot_getextplugins('admin.structure.first') as $pl) {
    include $pl;
}
/* ===== */
//cot_rc_link_file($cfg['plugins_dir'].'/banners/tpl/admin.css');
// Роутер
// Only if the file exists...
if (is_array($extension_structure) && count($extension_structure) == 1 && (cot_plugin_active($extension_structure[0]) || cot_module_active($extension_structure[0]))) {
    $n = $extension_structure[0];
}
$sub = empty($n) ? 'list' : 'editor';
if (!empty($n)) {
    $cot_structure = new structure($n);
    $is_module = cot_module_active($n);
    if (file_exists(cot_incfile($n, $is_module ? 'module' : 'plug'))) {
        require_once cot_incfile($n, $is_module ? 'module' : 'plug');
    }
}
if (!empty($a) && file_exists(cot_incfile('cateditor', 'plug', 'admin.' . $sub . '.' . $a))) {
    require_once cot_incfile('cateditor', 'plug', 'admin.' . $sub . '.' . $a);
}
if (file_exists(cot_incfile('cateditor', 'plug', 'admin.' . $sub))) {
    $t = new XTemplate(cot_tplfile('cateditor.admin.' . $sub, 'plug'));
 * 
 * @package usergroupselector
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL');
global $db_users, $db_groups, $db_auth, $db_config;
require_once cot_incfile('auth');
// Add field if missing
if (!$db->fieldExists($db_users, "user_usergroup")) {
    $dbres = $db->query("ALTER TABLE `{$db_users}` ADD COLUMN `user_usergroup` int(11) NOT NULL default '0'");
}
// Переносим значение из старого поля user_role в новое поле для группы по-умолчанию
if (cot_plugin_active('freelancers')) {
    if (!$db->fieldExists($db_users, "user_role")) {
        $dbres = $db->query("UPDATE `{$db_users}` SET user_usergroup=user_role WHERE 1");
    }
}
// Дальше проверяем наличие групп в базе, если их нет, то создаем
$group_exists = (bool) $db->query("SELECT grp_id FROM {$db_groups} WHERE grp_id=4")->fetch();
if ($group_exists) {
    $rgroups['grp_name'] = 'Фрилансеры';
    $rgroups['grp_title'] = 'Фрилансер';
    $rgroups['grp_alias'] = 'freelancer';
    $db->update($db_groups, $rgroups, 'grp_id=4');
    $db->update($db_auth, array('auth_rights' => 5), "auth_groupid=4 AND auth_code='projects'");
    // Устанавливаем права только на создание предложений в проектах
}
$group_exists = (bool) $db->query("SELECT grp_id FROM {$db_groups} WHERE grp_alias='employer'")->fetch();
Esempio n. 14
0
    while ($row = $sql->fetch()) {
        unset($row['auth_id']);
        $row['auth_code'] = 'folio';
        $db->insert($db_auth, $row);
    }
    // Копируем записи из таблицы Foliostore в Folio
    // При этом также переименовываем загруженные изображения в плагине Mavatars
    $sql = $db->query("SELECT * FROM {$db_foliostore} WHERE item_store<>1");
    while ($row = $sql->fetch()) {
        $folioid = $row['item_id'];
        unset($row['item_id']);
        unset($row['item_store']);
        unset($row['item_index']);
        $db->insert($db_folio, $row);
        $id = $db->lastInsertId();
        if (cot_plugin_active('mavatars')) {
            if ($mav = $db->query("SELECT * FROM {$db_mavatars} WHERE mav_code=" . $folioid . " AND mav_extension='foliostore'")->fetch()) {
                unset($mav['mav_id']);
                $mav['mav_extension'] = 'folio';
                $mav['mav_code'] = $id;
                $db->insert($db_mavatars, $mav);
            }
        }
    }
} else {
    require_once cot_incfile('structure');
    cot_structure_add('folio', array('structure_area' => 'folio', 'structure_code' => 'programming', 'structure_title' => 'Программирование', 'structure_path' => '001'));
    cot_structure_add('folio', array('structure_area' => 'folio', 'structure_code' => 'management', 'structure_title' => 'Менеджмент', 'structure_path' => '002'));
    cot_structure_add('folio', array('structure_area' => 'folio', 'structure_code' => 'folioing', 'structure_title' => 'Маркетинг и реклама', 'structure_path' => '003'));
    cot_structure_add('folio', array('structure_area' => 'folio', 'structure_code' => 'design', 'structure_title' => 'Дизайн', 'structure_path' => '004'));
    cot_structure_add('folio', array('structure_area' => 'folio', 'structure_code' => 'seo', 'structure_title' => 'Оптимизация (SEO)', 'structure_path' => '005'));
Esempio n. 15
0
 public static function fieldList()
 {
     $fields = array('id' => array('type' => 'int', 'description' => 'id', 'primary' => true), 'alias' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['Alias']), 'state' => array('type' => 'tinyint', 'length' => 1, 'default' => 0, 'description' => cot::$L['Status']), 'category' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'nullable' => false, 'description' => cot::$L['Category']), 'title' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['Title']), 'price' => array('type' => 'decimal(15,2)', 'default' => 0, 'description' => cot::$L['advboard_price']), 'description' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['advboard_desc']), 'text' => array('type' => 'text', 'default' => '', 'description' => cot::$L['Text']), 'person' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['advboard_person']), 'email' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['Email']), 'city' => array('type' => 'int', 'default' => 0, 'description' => cot::$L['advboard_city']), 'city_name' => array('name' => 'city_name', 'type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['advboard_city']), 'phone' => array('type' => 'varchar', 'length' => '255', 'default' => '', 'description' => cot::$L['advboard_phone']), 'sticky' => array('type' => 'tinyint', 'length' => 1, 'default' => 0, 'description' => cot::$L['advboard_sticky']), 'begin' => array('type' => 'int', 'default' => cot::$sys['now'], 'description' => cot::$L['Begin']), 'expire' => array('type' => 'int', 'default' => 0, 'description' => cot::$L['Expire']), 'sort' => array('type' => 'int', 'default' => 0, 'description' => cot::$L['advboard_sort_date']), 'user' => array('type' => 'int', 'default' => 0, 'nullable' => false, 'description' => 'id Владельца'), 'views' => array('type' => 'mediumint', 'length' => 8, 'default' => 0, 'description' => 'Количество просмотров'), 'admin_notified' => array('type' => 'datetime', 'default' => '1970-01-01 00:00:01', 'description' => 'Дата создания'), 'created' => array('type' => 'datetime', 'default' => date('Y-m-d H:i:s', cot::$sys['now']), 'description' => 'Дата создания'), 'created_by' => array('type' => 'int', 'default' => cot::$usr['id'], 'description' => 'Кем создано'), 'updated' => array('type' => 'datetime', 'default' => date('Y-m-d H:i:s', cot::$sys['now']), 'description' => 'Дата обновления'), 'updated_by' => array('type' => 'int', 'default' => cot::$usr['id'], 'description' => 'Кем обновлено'));
     if (cot_plugin_active('regioncity')) {
         $fields['city'] = array('name' => 'city', 'type' => 'link', 'default' => 0, 'description' => cot::$L['advboard_city'], 'link' => array('model' => 'regioncity_model_City', 'relation' => SOM::TO_ONE_NULL, 'label' => 'title'));
     }
     return $fields;
 }
Esempio n. 16
0
         $db->update($db_forum_posts, array('fp_postername' => $newname), 'fp_postername = ?', array($oldname));
         $db->update($db_forum_stats, array('fs_lt_postername' => $newname), 'fs_lt_postername = ?', array($oldname));
     }
     if (cot_module_active('page')) {
         require_once cot_incfile('page', 'module');
         $db->update($db_pages, array('page_author' => $newname), 'page_author = ?', array($oldname));
     }
     if (cot_plugin_active('comments')) {
         require_once cot_incfile('comments', 'plug');
         $db->update($db_com, array('com_author' => $newname), 'com_author = ?', array($oldname));
     }
     if (cot_module_active('pm')) {
         require_once cot_incfile('pm', 'module');
         $db->update($db_pm, array('pm_fromuser' => $newname), 'pm_fromuser = ?', array($oldname));
     }
     if (cot_plugin_active('whosonline')) {
         $db->update($db_online, array('online_name' => $newname), 'online_name = ?', array($oldname));
     }
 }
 $ruser['user_auth'] = '';
 $sql = $db->update($db_users, $ruser, 'user_id=' . $id);
 cot_extrafield_movefiles();
 $ruser['user_maingrp'] = $ruser['user_maingrp'] < COT_GROUP_MEMBERS && $id == 1 ? COT_GROUP_SUPERADMINS : $ruser['user_maingrp'];
 if (!$rusergroupsms[$ruser['user_maingrp']]) {
     $rusergroupsms[$ruser['user_maingrp']] = 1;
 }
 $db->update($db_users, array('user_maingrp' => $ruser['user_maingrp']), 'user_id=' . $id);
 foreach ($cot_groups as $k => $i) {
     if (isset($rusergroupsms[$k])) {
         if ($db->query("SELECT gru_userid FROM {$db_groups_users} WHERE gru_userid={$id} AND gru_groupid={$k}")->rowCount() == 0 && !($id == 1 && in_array($k, array(COT_GROUP_BANNED, COT_GROUP_INACTIVE)))) {
             $db->insert($db_groups_users, array('gru_userid' => (int) $id, 'gru_groupid' => (int) $k));
Esempio n. 17
0
/**
 * Transforms parameters into URL by following user-defined rules.
 * This function can be overloaded by cot_url_custom().
 *
 * @param string $name Module or script name
 * @param mixed $params URL parameters as array or parameter string
 * @param string $tail URL postfix, e.g. anchor
 * @param bool $htmlspecialchars_bypass If TRUE, will not convert & to &amp; and so on.
 * @return string Valid HTTP URL
 * @see cot_url()
 */
function cot_url_custom($name, $params = '', $tail = '', $htmlspecialchars_bypass = false)
{
    global $cot_urltrans, $cot_url_shortcuts;
    $q_s = str_replace('%5B', '[', str_replace('%5D', ']', http_build_query($params)));
    if (isset($cot_url_shortcuts[$name][$q_s])) {
        return $cot_url_shortcuts[$name][$q_s];
    }
    // Preprocess arguments
    if (is_string($params)) {
        $params = cot_parse_str($params);
    }
    // Initialize with something very default
    $url = $name == 'plug' ? 'index.php' : 'index.php?e=' . $name;
    // Detect search areas
    $areas = array();
    if (isset($cot_urltrans[$name]) && count($cot_urltrans[$name]) > 0) {
        $areas[] = $name;
    }
    $areas[] = '*';
    // default area rules
    // Find first matching rule
    $rule = array();
    foreach ($areas as $area) {
        foreach ($cot_urltrans[$area] as $rule) {
            $matched = true;
            foreach ($rule['params'] as $key => $val) {
                if (!isset($params[$key]) || empty($params[$key]) || is_array($val) && !in_array($params[$key], $val) || $val != '*' && $params[$key] != $val) {
                    $matched = false;
                    break;
                }
            }
            if ($matched) {
                $url = $rule['trans'];
                break 2;
            }
        }
    }
    // Some special substitutions
    $spec['_area'] = $name;
    $spec['_host'] = cot::$sys['host'];
    $spec['_rhost'] = $_SERVER['HTTP_HOST'];
    $spec['_path'] = COT_SITE_URI;
    // Transform the data into URL
    if (preg_match_all('#\\{(.+?)\\}#', $url, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $m) {
            if ($p = mb_strpos($m[1], '(')) {
                // Callback
                $func = mb_substr($m[1], 0, $p);
                $arg = mb_substr($m[1], $p + 1, mb_strpos($m[1], ')') - $p - 1);
                $sub = empty($arg) ? $func($params, $spec) : $func($params, $spec, $arg);
                $url = str_replace($m[0], $sub, $url);
            } elseif (mb_strpos($m[1], '!$') === 0) {
                // Unset
                $var = mb_substr($m[1], 2);
                $url = str_replace($m[0], '', $url);
                unset($params[$var]);
            } else {
                // Substitute
                $var = mb_substr($m[1], 1);
                if (isset($spec[$var])) {
                    $url = str_replace($m[0], $spec[$var], $url);
                } elseif (isset($params[$var])) {
                    $url = str_replace($m[0], rawurlencode($params[$var]), $url);
                    unset($params[$var]);
                } else {
                    $url = str_replace($m[0], rawurlencode($GLOBALS[$var]), $url);
                }
            }
        }
    }
    // Support for i18n parameter
    if (cot_plugin_active('i18n')) {
        $i18n_cfg = cot::$cfg['plugin']['i18n'];
        $i18n_rewrite = isset($i18n_cfg['rewrite']) && $i18n_cfg['rewrite'];
        $omit_param = $i18n_cfg['omitmain'] && $params['l'] == cot::$usr['profile']['user_lang'];
        if (isset($params['l']) && $i18n_rewrite && !$omit_param) {
            // Add with slash at the beginning of the URL
            $pos = strpos($url, cot::$sys['site_uri']);
            if (cot::$sys['site_uri'] != '/' && $pos !== false) {
                $url = substr_replace($url, cot::$sys['site_uri'] . rawurlencode($params['l']) . '/', $pos, mb_strlen($sys['site_uri']));
            } else {
                $p = mb_strpos($url, '://');
                if ($p === false) {
                    $url = mb_strpos($url, '/') === 0 ? '/' . rawurlencode($params['l']) . $url : rawurlencode($params['l']) . '/' . $url;
                } else {
                    $p = mb_strpos($url, '/', $p + 3);
                    $url = $p === false ? $url . '/' . rawurlencode($params['l']) : mb_substr($url, 0, $p) . rawurlencode($params['l']) . '/' . mb_substr($url, $p + 1);
                }
            }
            unset($params['l']);
        }
    }
    // Append query string if needed
    if (!empty($params)) {
        $sep = $htmlspecialchars_bypass ? '&' : '&amp;';
        $url_tail = version_compare(PHP_VERSION, '5.4.0', '>=') ? http_build_query($params, '', $sep, PHP_QUERY_RFC3986) : str_replace('+', '%20', http_build_query($params, '', $sep));
        if (!empty($url_tail)) {
            $url .= (mb_strpos($url, '?') === false ? '?' : $sep) . $url_tail;
        }
    }
    // Almost done
    $url .= $tail;
    $url = str_replace('&amp;amp;', '&amp;', $url);
    return $url;
}
Esempio n. 18
0
<?php

/* ====================
[BEGIN_COT_EXT]
Hooks=header.main
[END_COT_EXT]
==================== */
/**
 * Hits
 *
 * @package Hits
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
if (cot_plugin_active('hits') && $env['ext'] != 'admin') {
    require_once cot_incfile('hits', 'plug');
    if ($cache && $cache->mem && $cache->mem->exists('maxusers', 'system')) {
        $maxusers = $cache->mem->get('maxusers', 'system');
    } else {
        $sql = $db->query("SELECT stat_value FROM {$db_stats} where stat_name='maxusers' LIMIT 1");
        $maxusers = (int) @$sql->fetchColumn();
        $cache && $cache->mem && $cache->mem->store('maxusers', $maxusers, 'system', 0);
    }
    if ($maxusers < $sys['whosonline_all_count']) {
        $sql = $db->update($db_stats, array('stat_value' => $sys['whosonline_all_count']), "stat_name='maxusers'");
    }
}
<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=users.profile.update.first, users.edit.update.first, users.register.add.first
 * [END_COT_EXT]
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('usercategories', 'plug');
$catslimit = cot_cfg_usercategories();
$rcats = cot_import('rcats', 'P', 'ARR');
if (is_array($rcats)) {
    $rcats = array_filter($rcats);
    $ruser['user_cats'] = implode(',', $rcats);
    if ($m == 'edit' || $m == 'profile') {
        $groupid = $urr['user_maingrp'];
    } else {
        $groupid = cot_import('ruserusergroup', 'P', 'INT');
    }
    if (!cot_plugin_active('paypro') || cot_plugin_active('paypro') && !cot_getuserpro($urr)) {
        cot_check($catslimit[$groupid] > 0 && count($rcats) > $catslimit[$groupid], cot_rc($L['usercategories_error_catslimit'], array('limit' => $catslimit[$groupid])), 'rcats');
    }
}
Esempio n. 20
0
/**
 * Returns an array containing meta information for all extensions in a directory
 *
 * @param string $dir Directory to search for extensions in
 * @return array Extension code => info array
 */
function cot_extension_list_info($dir)
{
    $ext_list = array();
    clearstatcache();
    $dp = opendir($dir);
    while ($f = readdir($dp)) {
        $path = $dir . '/' . $f;
        if ($f[0] != '.' && is_dir($path) && file_exists("{$path}/{$f}.setup.php")) {
            $info = cot_infoget("{$path}/{$f}.setup.php", 'COT_EXT');
            if (!$info && cot_plugin_active('genoa')) {
                // Try to load old format info
                $info = cot_infoget("{$path}/{$f}.setup.php", 'SED_EXTPLUGIN');
            }
            if (empty($info['Category'])) {
                $info['Category'] = 'misc-ext';
            }
            $ext_list[$f] = $info;
        }
    }
    closedir($dp);
    return $ext_list;
}
<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=projects.add.tags,projects.edit.tags
 * Tags=projects.add.tpl:{PRJADD_FORM_MAVATAR};projects.edit.tpl:{PRJEDIT_FORM_MAVATAR}
 * [END_COT_EXT]
 */
/**
 * mavatarslance for Cotonti CMF
 *
 * @version 1.2.1
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 */
defined('COT_CODE') or die('Wrong URL');
global $cfg;
if (cot_plugin_active('mavatars') && $cfg['plugin']['mavatarslance']['projects']) {
    require_once cot_incfile('mavatars', 'plug');
    if ((int) $id > 0) {
        $code = $item['item_id'];
        $category = $item['item_cat'];
        $mavpr = 'EDIT';
    } else {
        $code = '';
        $category = $ritem['item_cat'];
        $mavpr = 'ADD';
    }
    $mavatar = new mavatar('projects', $category, $code, 'edit');
    $t->assign('PRJ' . $mavpr . '_FORM_MAVATAR', $mavatar->upload_form());
}
Esempio n. 22
0
             $dep_module = strpos($dep_type, 'modules') !== false;
             $arg = $dep_module ? 'mod' : 'pl';
             $dir = $dep_module ? $cfg['modules_dir'] : $cfg['plugins_dir'];
             foreach (explode(',', $info[$dep_type]) as $ext) {
                 $ext = trim($ext);
                 $dep_installed = cot_extension_installed($ext);
                 if ($dep_obligatory) {
                     $dep_class = $dep_installed ? 'highlight_green' : 'highlight_red';
                     $dependencies_satisfied &= $dep_installed;
                 } else {
                     $dep_class = '';
                 }
                 $dep_ext_info = $dir . '/' . $ext . '/' . $ext . '.setup.php';
                 if (file_exists($dep_ext_info)) {
                     $dep_info = cot_infoget($dep_ext_info, 'COT_EXT');
                     if (!$dep_info && cot_plugin_active('genoa')) {
                         // Try to load old format info
                         $dep_info = cot_infoget($dep_ext_info, 'SED_EXTPLUGIN');
                     }
                 } else {
                     $dep_info = array('Name' => $ext);
                 }
                 $t->assign(array('ADMIN_EXTENSIONS_DEPENDENCIES_ROW_CODE' => $ext, 'ADMIN_EXTENSIONS_DEPENDENCIES_ROW_NAME' => $dep_info['Name'], 'ADMIN_EXTENSIONS_DEPENDENCIES_ROW_URL' => $dep_module && file_exists($cfg['modules_dir'] . '/' . $ext) || !$dep_module && file_exists($cfg['plugins_dir'] . '/' . $ext) ? cot_url('admin', "m=extensions&a=details&{$arg}={$ext}") : '#', 'ADMIN_EXTENSIONS_DEPENDENCIES_ROW_TYPE' => $dep_module ? $L['Module'] : $L['Plugin'], 'ADMIN_EXTENSIONS_DEPENDENCIES_ROW_CLASS' => $dep_class));
                 $t->parse('MAIN.DETAILS.DEPENDENCIES.DEPENDENCIES_ROW');
             }
             $t->assign(array('ADMIN_EXTENSIONS_DEPENDENCIES_TITLE' => $L['ext_' . strtolower($dep_type)]));
             $t->parse('MAIN.DETAILS.DEPENDENCIES');
         }
     }
 }
 /* === Hook  === */
Esempio n. 23
0
/**
 * Generates page list widget
 * @param  mixed   $categories       Custom parent categories code
 * @param  integer $count            Number of items to show. 0 - all items
 * @param  string  $template         Path for template file
 * @param  string  $order            Sorting order (SQL)
 * @param  string  $condition        Custom selection filter (SQL)
 * @param  mixed   $active_only	     Custom parent category code
 * @param  boolean $use_subcat       Include subcategories TRUE/FALSE
 * @param  boolean $exclude_current  Exclude the current page from the rowset for pages.
 * @param  string  $blacklist        Category black list, semicolon separated
 * @param  string  $pagination       Pagination symbol
 * @param  integer $cache_ttl        Cache lifetime in seconds, 0 disables cache
 * @return string                    Parsed HTML
 */
function cot_page_enum($categories = '', $count = 0, $template = '', $order = '', $condition = '', $active_only = true, $use_subcat = true, $exclude_current = false, $blacklist = '', $pagination = '', $cache_ttl = null)
{
    global $db, $db_pages, $db_users, $structure, $cfg, $sys, $lang, $cache;
    // Compile lists
    if (!is_array($blacklist)) {
        $blacklist = str_replace(' ', '', $blacklist);
        $blacklist = !empty($blacklist) ? explode(',', $blacklist) : array();
    }
    // Get the cats
    if (!empty($categories)) {
        if (!is_array($categories)) {
            $categories = str_replace(' ', '', $categories);
            $categories = explode(',', $categories);
        }
        $categories = array_unique($categories);
        if ($use_subcat) {
            $total_categogies = array();
            foreach ($categories as $cat) {
                $cats = cot_structure_children('page', $cat, $use_subcat);
                $total_categogies = array_merge($total_categogies, $cats);
            }
            $categories = array_unique($total_categogies);
        }
        $categories = count($blacklist) > 0 ? array_diff($categories, $blacklist) : $categories;
        $where['cat'] = "page_cat IN ('" . implode("','", $cats) . "')";
    } elseif (count($blacklist)) {
        $where['cat_black'] = "page_cat NOT IN ('" . implode("','", $blacklist) . "')";
    }
    $where['condition'] = $condition;
    if ($exclude_current && defined('COT_PAGES') && !defined('COT_LIST')) {
        global $id;
        $where['page_id'] = "page_id != {$id}";
    }
    if ($active_only) {
        $where['state'] = "page_state=0";
        $where['date'] = "page_begin <= {$sys['now']} AND (page_expire = 0 OR page_expire > {$sys['now']})";
    }
    // Get pagination number if necessary
    if (!empty($pagination)) {
        list($pg, $d, $durl) = cot_import_pagenav($pagination, $count);
    } else {
        $d = 0;
    }
    // Display the items
    $mskin = file_exists($template) ? $template : cot_tplfile(array('page', 'enum', $template), 'module');
    /* === Hook === */
    foreach (cot_getextplugins('page.enum.query') as $pl) {
        include $pl;
    }
    /* ===== */
    if (cot_plugin_active('comments')) {
        global $db_com;
        require_once cot_incfile('comments', 'plug');
        $cns_join_columns .= ", (SELECT COUNT(*) FROM `{$db_com}` WHERE com_area = 'page' AND com_code = p.page_id) AS com_count";
    }
    $sql_order = empty($order) ? 'ORDER BY page_date DESC' : "ORDER BY {$order}";
    $sql_limit = $count > 0 ? "LIMIT {$d}, {$count}" : '';
    $where = array_filter($where);
    $where = $where ? 'WHERE ' . implode(' AND ', $where) : '';
    $sql_total = "SELECT COUNT(*) FROM {$db_pages} AS p {$cns_join_tables} {$where}";
    $sql_query = "SELECT p.*, u.* {$cns_join_columns} FROM {$db_pages} AS p LEFT JOIN {$db_users} AS u ON p.page_ownerid = u.user_id\n\t\t\t{$cns_join_tables} {$where} {$sql_order} {$sql_limit}";
    $t = new XTemplate($mskin);
    isset($md5hash) || ($md5hash = 'page_enum_' . md5(str_replace($sys['now'], '_time_', $mskin . $lang . $sql_query)));
    if ($cache && (int) $cache_ttl > 0) {
        $page_query_html = $cache->disk->get($md5hash, 'page', (int) $cache_ttl);
        if (!empty($page_query_html)) {
            return $page_query_html;
        }
    }
    $totalitems = $db->query($sql_total)->fetchColumn();
    $sql = $db->query($sql_query);
    $sql_rowset = $sql->fetchAll();
    $jj = 0;
    foreach ($sql_rowset as $pag) {
        $jj++;
        $t->assign(cot_generate_pagetags($pag, 'PAGE_ROW_'));
        $t->assign(array('PAGE_ROW_NUM' => $jj, 'PAGE_ROW_ODDEVEN' => cot_build_oddeven($jj), 'PAGE_ROW_RAW' => $pag));
        $t->assign(cot_generate_usertags($pag, 'PAGE_ROW_OWNER_'));
        /* === Hook === */
        foreach (cot_getextplugins('page.enum.loop') as $pl) {
            include $pl;
        }
        /* ===== */
        if (cot_plugin_active('comments')) {
            $rowe_urlp = empty($pag['page_alias']) ? array('c' => $pag['page_cat'], 'id' => $pag['page_id']) : array('c' => $pag['page_cat'], 'al' => $pag['page_alias']);
            $t->assign(array('PAGE_ROW_COMMENTS' => cot_comments_link('page', $rowe_urlp, 'page', $pag['page_id'], $pag['page_cat'], $pag), 'PAGE_ROW_COMMENTS_COUNT' => cot_comments_count('page', $pag['page_id'], $pag)));
        }
        $t->parse("MAIN.PAGE_ROW");
    }
    // Render pagination
    $url_params = $_GET;
    $url_area = 'index';
    $module_name = cot_import('e', 'G', 'ALP');
    if (cot_module_active($module_name)) {
        $url_area = $url_params['e'];
        unset($url_params['e']);
    }
    if (cot_plugin_active($module_name)) {
        $url_area = 'plug';
    }
    unset($url_params[$pagination]);
    if (!empty($pagination)) {
        $pagenav = cot_pagenav($url_area, $url_params, $d, $totalitems, $count, $pagination);
    }
    $t->assign(array('PAGE_TOP_PAGINATION' => $pagenav['main'], 'PAGE_TOP_PAGEPREV' => $pagenav['prev'], 'PAGE_TOP_PAGENEXT' => $pagenav['next'], 'PAGE_TOP_FIRST' => $pagenav['first'], 'PAGE_TOP_LAST' => $pagenav['last'], 'PAGE_TOP_CURRENTPAGE' => $pagenav['current'], 'PAGE_TOP_TOTALLINES' => $totalitems, 'PAGE_TOP_MAXPERPAGE' => $count, 'PAGE_TOP_TOTALPAGES' => $pagenav['total']));
    /* === Hook === */
    foreach (cot_getextplugins('pagelist.tags') as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse("MAIN");
    $page_query_html = $t->text("MAIN");
    if ($cache && (int) $cache_ttl > 0) {
        $cache->disk->store($md5hash, $page_query_html, 'page');
    }
    return $page_query_html;
}
Esempio n. 24
0
function cot_get_extensionparams($code, $is_module = false)
{
    global $cfg, $cot_modules, $cot_plugins_enabled;
    $dir = $is_module ? $cfg['modules_dir'] : $cfg['plugins_dir'];
    if ($is_module) {
        $name = $cot_modules[$code]['title'];
    } else {
        $name = $cot_plugins_enabled[$code]['title'];
    }
    if (empty($name)) {
        $ext_info = $dir . '/' . $code . '/' . $code . '.setup.php';
        $exists = file_exists($ext_info);
        if ($exists) {
            $info = cot_infoget($ext_info, 'COT_EXT');
            if (!$info && cot_plugin_active('genoa')) {
                // Try to load old format info
                $info = cot_infoget($ext_info, 'SED_EXTPLUGIN');
            }
            $name = $info['Name'];
            $desc = $info['Desc'];
        } else {
            $info = array('Name' => $code);
        }
        $name = $info['Name'];
    }
    $icofile = $dir . '/' . $code . '/' . $code . '.png';
    $icon = file_exists($icofile) ? $icofile : '';
    $langfile = cot_langfile($code, $is_module ? 'module' : 'plug');
    if (file_exists($langfile)) {
        include $langfile;
        if (!empty($L['info_name'])) {
            $name = $L['info_name'];
        }
        if (!empty($L['info_desc'])) {
            $desc = $L['info_desc'];
        }
    }
    return array('name' => htmlspecialchars($name), 'desc' => $desc, 'icon' => $icon);
}
<?php

/**
 * [BEGIN_COT_EXT]
 * Hooks=market.add.add.done,market.edit.update.done
 * [END_COT_EXT]
 */
/**
 * mavatarslance for Cotonti CMF
 *
 * @version 1.2.1
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 */
defined('COT_CODE') or die('Wrong URL');
global $cfg;
if (cot_plugin_active('mavatars') && $cfg['plugin']['mavatarslance']['market']) {
    require_once cot_incfile('mavatars', 'plug');
    if (!cot_error_found()) {
        $mavatar = new mavatar('market', $ritem['item_cat'], $id);
        $mavatar->update();
        $mavatar->upload();
    }
}
Esempio n. 26
0
 public function editAction()
 {
     global $structure, $cot_extrafields, $db_structure;
     $id = cot_import('id', 'G', 'INT');
     // id Объявления
     $c = cot_import('c', 'G', 'TXT');
     $act = cot_import('act', 'G', 'ALP');
     if (empty($act)) {
         $act = cot_import('act', 'P', 'ALP');
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.first') as $pl) {
         include $pl;
     }
     /* ===== */
     // Права на любую категорию доски объявлений
     list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin']) = cot_auth('advboard', 'any');
     cot_block(cot::$usr['auth_write']);
     if (!$c || !isset($structure['advboard'][$c])) {
         cot_die_message(404, TRUE);
     }
     $category = $structure['advboard'][$c];
     $category['config'] = cot::$cfg['advboard']['cat_' . $c];
     $category['code'] = $c;
     // Extra fields for structure
     foreach ($cot_extrafields[$db_structure] as $exfld) {
         $uname = $exfld['field_name'];
         $val = $structure['advboard'][$c][$exfld['field_name']];
         $category[$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
         $category[$uname] = cot_build_extrafields_data('structure', $exfld, $val);
         $category[$uname . '_value'] = $val;
     }
     $published = 0;
     if (!$id) {
         $advert = new advboard_model_Advert();
         $advert->category = $c;
         $advert->user = cot::$usr['id'];
     } else {
         $advert = advboard_model_Advert::getById($id);
         if (!$advert) {
             cot_die_message(404, TRUE);
         }
         if (!cot::$usr['isadmin']) {
             if ($advert->user != cot::$usr['id']) {
                 cot_die_message(404, TRUE);
             }
         }
         if ($c != $advert->category && isset($structure['advboard'][$advert->category])) {
             $tmp = array('c' => $advert->category, 'a' => 'edit', 'id' => $advert->id);
             if (!empty($act)) {
                 $tmp['act'] = $act;
             }
             cot_redirect(cot_url('advboard', array('c' => $advert->category, 'a' => 'edit', 'id' => $advert->id), '', true));
         }
         if ($act == 'clone') {
             $id = null;
             $advert = clone $advert;
             // Установить статус и пользователя нового объекта
             $advert->user = cot::$usr['id'];
             $advert->state = advboard_model_Advert::DRAFT;
         }
         $published = $advert->state < 2 ? 1 : 0;
     }
     //Проверим права на категорию:
     list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin'], cot::$usr['auth_upload']) = cot_auth('advboard', $c, 'RWA1');
     if ($structure['advboard'][$c]['locked'] && !cot::$usr['isadmin']) {
         cot_die_message(602, TRUE);
     } elseif ($advert->id == 0) {
         // Если у пользователя нет прав на подачу объявления, то ищем категорию куда он может подать оьбъявление
         if (!cot::$usr['auth_write']) {
             foreach ($structure['advboard'] as $catCode => $catRow) {
                 $auth_write = cot_auth('advboard', $catCode, 'W');
                 if ($auth_write) {
                     cot_redirect(cot_url('advboard', array('c' => $catCode, 'a' => 'edit'), '', true));
                 }
             }
         }
         cot_block(cot::$usr['auth_write']);
     }
     // Владелец объявления
     $user = array();
     if ($advert->user > 0) {
         $user = cot_user_data($advert->user);
     }
     $periodItems = adv_periodItems($c);
     // Сохранение
     if ($act == 'save') {
         unset($_POST['id'], $_POST['user']);
         cot_shield_protect();
         /* === Hook === */
         foreach (cot_getextplugins('advboard.save.first') as $pl) {
             include $pl;
         }
         /* ===== */
         // импортировать даты
         $begin = (int) cot_import_date('begin');
         $expire = (int) cot_import_date('expire');
         if ($begin == 0) {
             $begin = !empty($advert->begin) ? $advert->begin : cot::$sys['now'];
         }
         // Пересчитать период публикации объявления
         if ($expire == 0 && cot::$cfg['advboard']['cat_' . $c]['maxPeriod'] > 0) {
             $period = cot_import('period', 'P', 'INT');
             $maxPeriod = max($periodItems);
             if (empty($period)) {
                 $period = $maxPeriod;
             }
             if (!cot::$usr['isadmin'] && $period > $maxPeriod) {
                 $period = $maxPeriod;
             }
             if ($period > 0) {
                 $expire = $begin + $period * 86400;
             }
         }
         if ($category['config']['title_require']) {
             $advert->setValidator('title', 'required');
         }
         // Валидатор 'allowemptytext'
         if (!$category['config']['allowemptytext']) {
             $advert->setValidator('text', 'required');
         }
         if ($category['config']['phone_require']) {
             // проверить надичие заполненного поля в профиле пользователя - владельца
             if (empty($user['user_phone'])) {
                 $advert->setValidator('phone', 'required');
             }
         }
         if ($category['config']['city_require']) {
             // Проверить наличие заполненного города (id или названия) в профиле владельца
             if (empty($user['user_city_name']) && empty($user['user_city'])) {
                 if (cot_plugin_active('regioncity')) {
                     $advert->setValidator('city', function ($value) {
                         $value = (int) $value;
                         if ($value == 0) {
                             return cot::$L['field_required'] . ': ' . advboard_model_Advert::fieldLabel('city');
                         }
                         return true;
                     });
                 } else {
                     $advert->setValidator('city_name', 'required');
                 }
             }
         }
         if (cot::$usr['id'] == 0) {
             $advert->setValidator('person', 'required');
             // Email
             $email = cot_import('email', 'P', 'TXT');
             if (cot::$cfg['advboard']['guestEmailRequire']) {
                 if ($email == '') {
                     cot_error(cot::$L['advboard_err_noemail'], 'email');
                 }
             }
             if ($email != '') {
                 $tmp = advert_checkEmail($email);
                 if ($tmp !== true) {
                     cot_error($tmp, 'email');
                 }
             }
             // Капча
             if (cot::$cfg['advboard']['guestUseCaptcha']) {
                 $verify = cot_import('verify', 'P', 'TXT');
                 if (!cot_captcha_validate($verify)) {
                     cot_error(cot::$L['captcha_verification_failed'], 'verify');
                 }
             }
         }
         $advert->setData($_POST);
         $advert->begin = $begin;
         $advert->expire = $expire;
         if (!cot::$usr['isadmin']) {
             if (!cot::$cfg['advboard']['cat_' . $c]['allowSticky']) {
                 $advert->sticky = 0;
             }
             if (cot::$usr['id'] == 0) {
                 $advert->sticky = 0;
             }
             // гости не дают срочных объявлений
         }
         $advert->category = $c;
         if (empty($advert->user) || !cot::$usr['isadmin']) {
             $advert->user = cot::$usr['id'];
         }
         $published = cot_import('published', 'P', 'BOL');
         if (!$published) {
             $advert->state = advboard_model_Advert::DRAFT;
         } elseif (cot::$usr['isadmin'] || cot_auth('advboard', $c, '2')) {
             $advert->state = advboard_model_Advert::PUBLISHED;
         } else {
             $advert->state = advboard_model_Advert::AWAITING_MODERATION;
         }
         /* === Hook === */
         foreach (cot_getextplugins('advboard.save.validate') as $pl) {
             include $pl;
         }
         /* ===== */
         // There is some errors
         if (!$advert->validate() || cot_error_found()) {
             $urlParams = array('c' => $c, 'a' => 'edit');
             if ($advert->id > 0) {
                 $urlParams['id'] = $advert->id;
             }
             cot_redirect(cot_url('advboard', $urlParams, '', true));
         }
         if (empty($advert->sort)) {
             $advert->sort = cot::$sys['now'];
         }
         $isNew = $advert->id == 0;
         // Сохранение
         if ($advert->save()) {
             // Для незарега запомним id страницы для чтого, чтобы он мог ее отредактировать в пределах сесии
             if ($isNew) {
                 if (cot::$usr['id'] == 0) {
                     if (empty($_SESSION['advboard'])) {
                         $_SESSION['advboard'] = array();
                     }
                     if (!in_array($id, $_SESSION['advboard'])) {
                         $_SESSION['advboard'][] = $advert->id;
                     }
                 }
                 if ($advert->state == advboard_model_Advert::PUBLISHED) {
                     cot_message(cot::$L['advboard_created']);
                 }
             } else {
                 if ($advert->state == advboard_model_Advert::PUBLISHED) {
                     cot_message(cot::$L['advboard_updated']);
                 }
             }
             if ($advert->state == advboard_model_Advert::AWAITING_MODERATION) {
                 cot_message(cot::$L['advboard_awaiting_moderation']);
             } elseif ($advert->state == advboard_model_Advert::DRAFT) {
                 cot_message(cot::$L['Saved']);
             }
             $redirectUrl = $advert->getUrl(true);
             /* === Hook === */
             foreach (cot_getextplugins('advboard.save.done') as $pl) {
                 include $pl;
             }
             /* ===== */
             // Редирект на станицу объявления
             cot_redirect($redirectUrl);
         }
     }
     $crumbs = cot_structure_buildpath('advboard', $c);
     if (cot::$cfg['advboard']['firstCrumb']) {
         array_unshift($crumbs, array(cot_url('advboard'), cot::$L['advboard_ads']));
     }
     if (!$id) {
         $crumbs[] = $title = cot::$L['advboard_add_new'];
         cot::$out['subtitle'] = $title;
     } else {
         $crumbs[] = array($advert->url, $advert->title);
         $crumbs[] = cot::$L['Edit'];
         $title = cot::$L['advboard_advert'] . ' #' . $advert->id;
         if (!empty($advert->title)) {
             $title = $advert->title;
         }
         $title .= ': ' . cot::$L['Edit'];
         if (!empty(cot::$out['subtitle'])) {
             $title .= ' - ' . cot::$out['subtitle'];
         }
         cot::$out['subtitle'] = $title;
     }
     // Elemets placeholders
     $placeHolder_Person = '';
     $placeHolder_Phone = '';
     $placeHolder_Email = '';
     $placeHolder_City = '';
     //if($advboard->user == cot::$usr['id'] && cot::$usr['id'] > 0) {
     if (!empty($user)) {
         // Контакное лицо
         $placeHolder_Person = cot_user_full_name($user);
         // Телефон
         if (!empty($user['user_phone'])) {
             $placeHolder_Phone = $user['user_phone'];
         }
         // email
         if (!$user['user_hideemail']) {
             $placeHolder_Email = $user['user_email'];
         }
         // город
         if (!empty($user['user_city_name'])) {
             $placeHolder_City = $user['user_city_name'];
         }
     }
     // 'input_textarea_editor', 'input_textarea_medieditor', 'input_textarea_minieditor', ''
     $editor = 'input_textarea_editor';
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.main') as $pl) {
         include $pl;
     }
     /* ===== */
     $minYear = date('Y');
     $maxYear = $minYear + 30;
     $price = $advert->rawValue('price');
     if ($price <= 0) {
         $price = '';
     }
     $formElements = array('hidden' => array('element' => cot_inputbox('hidden', 'act', 'save')), 'category' => array('element' => cot_selectbox_structure('advboard', $advert->category, 'category'), 'label' => advboard_model_Advert::fieldLabel('category')), 'price' => array('element' => cot_inputbox('text', 'price', $price), 'label' => advboard_model_Advert::fieldLabel('price'), 'hint' => cot::$L['advboard_price_hint']), 'title' => array('element' => cot_inputbox('text', 'title', $advert->rawValue('title')), 'required' => true, 'label' => advboard_model_Advert::fieldLabel('title')), 'description' => array('element' => cot_inputbox('text', 'description', $advert->rawValue('description')), 'label' => advboard_model_Advert::fieldLabel('description')), 'text' => array('element' => cot_textarea('text', $advert->rawValue('text'), 5, 120, '', $editor), 'label' => advboard_model_Advert::fieldLabel('text')), 'person' => array('element' => cot_inputbox('text', 'person', $advert->rawValue('person'), array('class' => 'form-control', 'placeholder' => $placeHolder_Person)), 'label' => advboard_model_Advert::fieldLabel('person'), 'required' => cot::$usr['id'] == 0), 'email' => array('element' => cot_inputbox('text', 'email', $advert->rawValue('email'), array('class' => 'form-control', 'placeholder' => $placeHolder_Email)), 'label' => advboard_model_Advert::fieldLabel('email')), 'city' => array('element' => cot_inputbox('text', 'city_name', $advert->rawValue('city_name'), array('class' => 'form-control', 'placeholder' => $placeHolder_City)), 'label' => advboard_model_Advert::fieldLabel('city_name'), 'required' => $category['config']['city_require']), 'phone' => array('element' => cot_inputbox('text', 'phone', $advert->rawValue('phone'), array('class' => 'form-control', 'placeholder' => $placeHolder_Phone)), 'label' => advboard_model_Advert::fieldLabel('phone'), 'required' => $category['config']['phone_require']), 'sticky' => array('element' => cot_checkbox($advert->sticky, 'sticky', advboard_model_Advert::fieldLabel('sticky')), 'label' => advboard_model_Advert::fieldLabel('sticky')), 'published' => array('element' => cot_checkbox($published, 'published', cot::$L['advboard_published'] . '?'), 'label' => cot::$L['advboard_published'] . '?'), 'begin' => array('element' => cot_selectbox_date($advert->begin, 'long', 'begin', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('begin')), 'expire' => array('element' => cot_selectbox_date($advert->expire, 'long', 'expire', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('expire')), 'sort' => array('element' => cot_selectbox_date($advert->sort, 'long', 'sort', $maxYear, $minYear), 'label' => advboard_model_Advert::fieldLabel('sort')), 'period' => array('element' => cot_selectbox('', 'period', $periodItems, array(), false), 'label' => cot::$L['advboard_period']));
     if (!empty($cot_extrafields[cot::$db->advboard])) {
         // Extra fields for ads
         foreach ($cot_extrafields[cot::$db->advboard] as $exfld) {
             $fName = $exfld['field_name'];
             $formElements[$fName] = array('element' => cot_build_extrafields($fName, $exfld, $advert->rawValue($fName)));
             if ($exfld['field_type'] !== 'checkbox') {
                 $formElements[$fName]['label'] = isset(cot::$L['advboard_' . $exfld['field_name'] . '_title']) ? cot::$L['advboard_' . $exfld['field_name'] . '_title'] : advboard_model_Advert::fieldLabel($fName);
             }
         }
     }
     if (cot_plugin_active('regioncity')) {
         $formElements['city']['element'] = rec_select2_city('city', $advert->rawValue('city'), true, array('class' => 'form-control', 'placeholder' => $placeHolder_City));
     }
     if ($category['config']['city_require']) {
         $formElements['city']['required'] = true;
     }
     if ($category['config']['phone_require']) {
         $formElements['phone']['required'] = true;
     }
     // Hints
     if (!empty($user)) {
         // Контакное лицо
         $formElements['person']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . cot_user_full_name($user);
         // Телефон
         if (!empty($user['user_phone'])) {
             $formElements['phone']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_phone'];
         }
         // email
         if (!$user['user_hideemail']) {
             $formElements['email']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_email'];
         }
         // город
         if (!empty($user['user_city_name'])) {
             $formElements['city']['hint'] = cot::$L['advboard_leave_empty_to_use'] . ": " . $user['user_city_name'];
         }
     }
     if (!cot::$usr['isadmin']) {
         unset($formElements['begin']);
         unset($formElements['expire']);
         unset($formElements['sort']);
         if (cot::$usr['id'] == 0) {
             if (cot::$cfg['advboard']['guestEmailRequire']) {
                 $formElements['email']['required'] = true;
             }
             // Гости не дают срочных объявлений
             unset($formElements['sticky']);
             // Капча
             if (cot::$cfg['advboard']['guestUseCaptcha']) {
                 $formElements['verify'] = array('element' => cot_inputbox('text', 'verify'), 'img' => cot_captcha_generate(), 'label' => cot::$L['advboard_captcha'], 'required' => true);
             }
         }
         if (!cot::$cfg['advboard']['cat_' . $c]['allowSticky'] && isset($formElements['sticky'])) {
             unset($formElements['sticky']);
         }
     } else {
         // Администратор напрямую указывает дату окончания публикации
         unset($formElements['period']);
     }
     $actionParams = array('a' => 'edit', 'c' => $advert->category);
     if ($advert->id > 0) {
         $actionParams['id'] = $advert->id;
     }
     $view = new View();
     $view->breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     $view->page_title = $title;
     $view->category = $category;
     $view->advert = $advert;
     $view->user = $user;
     $view->formElements = $formElements;
     $view->formAction = cot_url('advboard', $actionParams);
     /* === Hook === */
     foreach (cot_getextplugins('advboard.edit.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render(array('advboard', 'edit', $structure['advboard'][$c]['tpl']));
 }
Esempio n. 27
0
            }
            if ($parse) {
                $ext_info = cot_get_extensionparams($code, $is_module);
                $t->assign(array('ADMIN_STRUCTURE_EXT_URL' => cot_url('admin', 'm=structure&n=' . $code), 'ADMIN_STRUCTURE_EXT_ICO' => $ext_info['icon'], 'ADMIN_STRUCTURE_EXT_NAME' => $ext_info['name']));
                $t->parse('LIST.ADMIN_STRUCTURE_EXT');
            }
        }
    } else {
        $t->parse('LIST.ADMIN_STRUCTURE_EMPTY');
    }
    $t->assign(array('ADMIN_STRUCTURE_EXFLDS_URL' => cot_url('admin', 'm=extrafields')));
    $t->parse('LIST');
    $adminmain = $t->text('LIST');
} else {
    $parse = false;
    if (cot_plugin_active($n)) {
        $is_module = false;
        $parse = true;
    }
    if (cot_module_active($n)) {
        $is_module = true;
        $parse = true;
    }
    if (!$parse) {
        cot_redirect(cot_url('admin', 'm=structure', '', true));
    }
    // Edit structure for a module
    if (file_exists(cot_incfile($n, $is_module ? 'module' : 'plug'))) {
        require_once cot_incfile($n, $is_module ? 'module' : 'plug');
    }
    if (empty($adminhelp)) {
Esempio n. 28
0
<?php

/**
 * Ads board module for Cotonti Siena
 *     Uninstallation handler
 *
 * @package Advboard
 * @author Kalnov Alexey    <kalnovalexey@yandex.ru>
 * @copyright (c) Portal30 Studio http://portal30.ru
 */
defined('COT_CODE') or die('Wrong URL');
global $db_com;
// Удалить все файлы и изображения
if (cot_module_active('files')) {
    $files = files_model_File::find(array(array('file_source', 'advboard')));
    if (!empty($files)) {
        foreach ($files as $fileRow) {
            $fileRow->delete();
        }
    }
}
// Удалить все комментарии к этому отзыву
if (cot_plugin_active('comments')) {
    if (empty($db_com)) {
        require_once cot_incfile('comments', 'plug');
    }
    cot::$db->delete($db_com, "com_area='advboard'");
}
 * Hooks=projects.index.loop
 * [END_COT_EXT]
 */
/**
 * plugin tagslance for Cotonti Siena
 * 
 * @package tagslance
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 *  */
defined('COT_CODE') or die('Wrong URL.');
if ($cfg['plugin']['tagslance']['projects']) {
    require_once cot_incfile('tags', 'plug');
    if (cot_plugin_active('i18n') && $i18n_enabled && $i18n_notmain) {
        $tags_extra = array('tag_locale' => $i18n_locale);
    } else {
        $tags_extra = null;
    }
    $item_id = $item['item_id'];
    if (!isset($tags_rowset_list)) {
        $tags_rowset_list = cot_tag_list(array_keys($sqllist_idset), 'projects', $tags_extra);
    }
    $tags = isset($tags_rowset_list[$item_id]) ? $tags_rowset_list[$item_id] : array();
    if (count($tags) > 0) {
        $tag_i = 0;
        foreach ($tags as $tag) {
            $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag;
            $tl = $lang != 'en' && $tag_u != $tag ? 1 : null;
            $t_pr->assign(array('PRJ_ROW_TAGS_ROW_TAG' => $cfg['plugin']['tags']['title'] ? htmlspecialchars(cot_tag_title($tag)) : htmlspecialchars($tag), 'PRJ_ROW_TAGS_ROW_URL' => cot_url('plug', array('e' => 'tags', 'a' => 'projects', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl))));
Esempio n. 30
0
    $t->assign(array('STATISTICS_TOTALDBFILES' => $totaldbfiles, 'STATISTICS_TOTALDBFILESIZE' => floor($totaldbfilesize / 1024)));
}
if (cot_module_active('pm')) {
    require_once cot_incfile('pm', 'module');
    $totalpmsent = cot_stat_get('totalpms');
    $totalpmactive = $db->query("SELECT COUNT(*) FROM {$db_pm} WHERE pm_tostate<2")->fetchColumn();
    $totalpmarchived = $db->query("SELECT COUNT(*) FROM {$db_pm} WHERE pm_tostate=2")->fetchColumn();
    $t->assign(array('STATISTICS_TOTALPMSENT' => $totalpmsent, 'STATISTICS_TOTALPMACTIVE' => $totalpmactive, 'STATISTICS_TOTALPMARCHIVED' => $totalpmarchived));
}
if (cot_module_active('polls')) {
    require_once cot_incfile('polls', 'module');
    $totaldbpolls = $db->countRows($db_polls);
    $totaldbpollsvotes = $db->countRows($db_polls_voters);
    $t->assign(array('STATISTICS_TOTALDBPOLLS' => $totaldbpolls, 'STATISTICS_TOTALDBPOLLSVOTES' => $totaldbpollsvotes));
}
if (cot_plugin_active('ratings')) {
    require_once cot_incfile('ratings', 'plug');
    $totaldbratings = $db->countRows($db_ratings);
    $totaldbratingsvotes = $db->countRows($db_rated);
    $t->assign(array('STATISTICS_TOTALDBRATINGS' => $totaldbratings, 'STATISTICS_TOTALDBRATINGSVOTES' => $totaldbratingsvotes));
}
$t->assign(array('STATISTICS_PLU_URL' => cot_url('plug', 'e=statistics'), 'STATISTICS_SORT_BY_USERCOUNT' => cot_url('plug', 'e=statistics&s=usercount'), 'STATISTICS_MAX_DATE' => $max_date, 'STATISTICS_MAX_HITS' => $max_hits, 'STATISTICS_SINCE' => $since, 'STATISTICS_TOTALDBUSERS' => $totaldbusers, 'STATISTICS_TOTALMAILSENT' => $totalmailsent, 'STATISTICS_TOTALDBVIEWS' => $totaldbviews, 'STATISTICS_UNKNOWN_COUNT' => $totalusers - $ii, 'STATISTICS_TOTALUSERS' => $totalusers));
if ($usr['id'] > 0) {
    /* === Hook === */
    foreach (cot_getextplugins('statistics.user') as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.IS_USER');
} else {
    $t->parse('MAIN.IS_NOT_USER');