Ejemplo n.º 1
0
 /**
  * Список писем в очереди на отправку
  * @return string
  * @throws Exception
  */
 public function indexAction()
 {
     global $admintitle, $adminpath, $Ls;
     $admintitle = cot::$L['subscribe_queue'];
     $adminpath[] = array(cot_url('admin', array('m' => 'subscribe', 'n' => 'queue')), $admintitle);
     $sort = cot_import('s', 'G', 'ALP');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     $maxrowsperpage = cot::$cfg['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for pages list
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.admin.queue.list.first') as $pl) {
         include $pl;
     }
     /* ===== */
     $sort = empty($sort) ? 'id' : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? 'asc' : $way;
     $urlParams = array('m' => 'subscribe', 'n' => 'queue');
     if ($sort != 'id') {
         $urlParams['s'] = $sort;
     }
     if ($way != 'asc') {
         $urlParams['w'] = $way;
     }
     $where = array();
     // Фильтры
     $allowedFilters = array('sid', 'to_name', 'to_email');
     $f = cot_import('f', 'G', 'ARR');
     $filterForm = array('hidden' => '');
     if (!empty($f)) {
         foreach ($f as $key => $val) {
             if (!in_array($key, $allowedFilters)) {
                 unset($f[$key]);
             }
         }
         if (!empty($f['sid'])) {
             $where['sid'] = array('subscribe', $f['sid']);
             $urlParams['f[sid]'] = $f['sid'];
         }
         if (!empty($f['to_name'])) {
             $where['to_name'] = array('to_name', '*' . $f['to_name'] . '*');
             $urlParams['f[to_name]'] = $f['to_name'];
         }
         if (!empty($f['to_email'])) {
             $where['to_email'] = array('to_email', '*' . $f['to_email'] . '*');
             $urlParams['f[to_email]'] = $f['to_email'];
         }
     }
     if (isset(cot::$cfg['plugin']['urleditor']) && cot::$cfg['plugin']['urleditor']['preset'] != 'handy') {
         $filterForm['hidden'] .= cot_inputbox('hidden', 'm', 'subscribe');
     }
     $filterForm['hidden'] .= cot_inputbox('hidden', 'n', 'queue');
     $condition = array();
     foreach ($where as $key => $val) {
         $condition[] = $val;
     }
     $order = array(array($sort, $way));
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.admin.queue.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = subscribe_model_Queue::count($condition);
     $items = null;
     if ($totallines > 0) {
         $items = subscribe_model_Queue::find($condition, $maxrowsperpage, $d, $order);
     }
     // Если передан номер страницы превышающий максимальный
     if (empty($items) && $totallines > 0 && $pg > 1) {
         $totalpages = ceil($totallines / $maxrowsperpage);
         $args = $urlParams;
         if ($totalpages > 1) {
             if (cot::$cfg['easypagenav']) {
                 $args['d'] = $totalpages;
             } else {
                 $args['d'] = ($totalpages - 1) * $maxrowsperpage;
             }
         }
         cot_redirect(cot_url('admin', $args, '', true));
     }
     //$addNewUrl = cot_url('admin', array('m'=>'subscribe','a' => 'edit'));
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.admin.queue.list.main') as $pl) {
         include $pl;
     }
     /* ===== */
     $pagenav = cot_pagenav('admin', $urlParams, $d, $totallines, $maxrowsperpage, 'd', '', true);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $pagenav['page'] = $pagenav['current'];
     if (!cot::$cfg['easypagenav']) {
         $pagenav['page'] = ($pagenav['current'] - 1) * $maxrowsperpage;
     }
     $subscribes = subscribe_model_Subscribe::keyValPairs();
     $template = array('subscribe', 'admin', 'queue', 'list');
     $view = new View();
     $view->page_title = $admintitle;
     $view->fistNumber = $d + 1;
     $view->items = $items;
     $view->totalitems = $totallines;
     $view->pagenav = $pagenav;
     $view->subscribes = $subscribes;
     $view->urlParams = $urlParams;
     $view->filter = $f;
     $view->filterForm = $filterForm;
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.admin.queue.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
Ejemplo n.º 2
0
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') && defined('COT_ADMIN') or die('Wrong URL.');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('plug', 'trashcan');
cot_block($usr['isadmin']);
require_once cot_incfile('users', 'module');
cot_module_active('page') && (require_once cot_incfile('page', 'module'));
cot_module_active('forums') && (require_once cot_incfile('forums', 'module'));
$cfg['comments'] && (require_once cot_incfile('comments', 'plug'));
require_once cot_incfile('trashcan', 'plug');
require_once cot_langfile('trashcan', 'plug');
$adminhelp = $L['adm_help_trashcan'];
$adminsubtitle = $L['Trashcan'];
$id = cot_import('id', 'G', 'INT');
$maxperpage = $cfg['maxrowsperpage'] && is_numeric($cfg['maxrowsperpage']) && $cfg['maxrowsperpage'] > 0 ? $cfg['maxrowsperpage'] : 15;
list($pg, $d, $durl) = cot_import_pagenav('d', $maxperpage);
$info = $a == 'info' ? 1 : 0;
/* === Hook === */
foreach (cot_getextplugins('trashcan.admin.first') as $pl) {
    include $pl;
}
/* ===== */
if ($a == 'wipe') {
    cot_check_xg();
    /* === Hook === */
    foreach (cot_getextplugins('trashcan.admin.wipe') as $pl) {
        include $pl;
    }
    /* ===== */
    cot_trash_delete($id);
    cot_message('adm_trashcan_deleted');
Ejemplo n.º 3
0
    $ajax = true;
}
if (empty($id) && $usr['id'] > 0) {
    $id = $usr['id'];
}
if ($urr['user_id'] != $id) {
    $sql = $db->query("SELECT user_id FROM {$db_users} WHERE user_id='{$id}' LIMIT 1");
    if ($sql->rowCount() == 0) {
        $disable = true;
    } else {
        $urr['user_id'] = $id;
    }
}
if ($cot_modules['forums'] && !$disable) {
    require_once cot_incfile('forums', 'module');
    list($pnf, $df, $df_url) = cot_import_pagenav('df', $cfg['plugin']['userlatestposts']['countonpage']);
    $totalitems = $db->query("SELECT COUNT(*) FROM {$db_forum_posts} p, {$db_forum_topics} t\tWHERE fp_posterid='" . $urr['user_id'] . "' AND p.fp_topicid=t.ft_id")->fetchColumn();
    if ($cfg['plugin']['userlatestposts']['ajax']) {
        $upf_ajax_begin = "<div id='reloadf'>";
        $upf_ajax_end = "</div>";
    }
    $pagenav = cot_pagenav('users', 'm=details&id=' . $urr['user_id'], $df, $totalitems, $cfg['plugin']['userlatestposts']['countonpage'], 'df', '', $cfg['plugin']['userlatestposts']['ajax'], "reloadf", 'plug', "r=userlatestposts&id=" . $urr['user_id']);
    $sqluserlatestposts = $db->query("SELECT p.fp_id, p.fp_topicid, p.fp_updated, t.ft_title, t.ft_id, t.ft_cat\n\t\t FROM {$db_forum_posts} p, {$db_forum_topics} t\n\t\t WHERE fp_posterid='" . $urr['user_id'] . "'\n\t\t AND p.fp_topicid=t.ft_id\n\t\t GROUP BY t.ft_id\n\t\t ORDER BY fp_updated DESC\n\t\t LIMIT {$df}, " . $cfg['plugin']['userlatestposts']['countonpage']);
    if ($sqluserlatestposts->rowCount() == 0) {
        $user_posts->parse("USERLATESTPOSTS.NONE");
    } else {
        $ii = 0;
        while ($row = $sqluserlatestposts->fetch()) {
            if (cot_auth('forums', $row['ft_cat'], 'R')) {
                $ii++;
                $build_forum = cot_breadcrumbs(cot_forums_buildpath($row['ft_cat'], false), false);
Ejemplo n.º 4
0
 */
/**
 * market module
 *
 * @package market
 * @version 2.5.2
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('market', 'module');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('market', 'any', 'RWA');
$tab = cot_import('tab', 'G', 'ALP');
$category = $tab == 'market' ? cot_import('cat', 'G', 'TXT') : '';
list($pg, $d, $durl) = cot_import_pagenav('dmarket', $cfg['market']['cat___default']['maxrowsperpage']);
//маркет вкладка
$t1 = new XTemplate(cot_tplfile(array('market', 'userdetails'), 'module'));
$t1->assign(array("ADDPRD_URL" => cot_url('market', 'm=add'), "PRD_ADDPRD_URL" => cot_url('market', 'm=add'), "ADDPRD_SHOWBUTTON" => $usr['auth_write'] ? true : false, "RPD_ADDPRD_SHOWBUTTON" => $usr['auth_write'] ? true : false));
$where = array();
$order = array();
if ($usr['id'] == 0 || $usr['id'] != $urr['user_id'] && !$usr['isadmin']) {
    $where['state'] = "item_state=0";
}
if ($category) {
    $where['cat'] = 'item_cat=' . $db->quote($category);
}
$where['owner'] = "item_userid=" . $urr['user_id'];
$order['date'] = "item_date DESC";
$wherecount = $where;
if ($wherecount['cat']) {
Ejemplo n.º 5
0
<?php

/**
 * projects module
 *
 * @package projects
 * @version 2.5.2
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
$userid = cot_import('userid', 'G', 'INT');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin'], $usr['auth_offers']) = cot_auth('projects', $item['item_cat'], 'RWA1');
if ($cfg['projects']['offersperpage'] > 0) {
    list($pn, $d, $d_url) = cot_import_pagenav('d', $cfg['projects']['offersperpage']);
}
/* @var $db CotDB */
/* @var $cache Cache */
/* @var $t Xtemplate */
if ($a == 'addoffer') {
    cot_shield_protect();
    $sql = $db->query("SELECT * FROM {$db_projects_offers} WHERE offer_pid=" . $id . " AND offer_userid=" . $usr['id'] . "");
    cot_block($usr['auth_offers'] && $sql->fetchColumn() == 0 && $usr['id'] != $item['item_userid']);
    /* === Hook === */
    foreach (cot_getextplugins('projects.offers.add.first') as $pl) {
        include $pl;
    }
    /* ===== */
    $roffer['offer_cost_min'] = (int) cot_import('costmin', 'P', 'NUM');
    $roffer['offer_cost_max'] = (int) cot_import('costmax', 'P', 'NUM');
Ejemplo n.º 6
0
 */
defined('COT_CODE') && defined('COT_PLUG') or die('Wrong URL');
if (cot_module_active('page')) {
    require_once cot_incfile('page', 'module');
}
if (cot_module_active('forums')) {
    require_once cot_incfile('forums', 'module');
}
require_once cot_incfile('search', 'plug');
require_once cot_incfile('forms');
$sq = cot_import('sq', 'R', 'TXT');
$sq = $db->prep($sq);
$hl = urlencode(mb_strtoupper($sq));
$tab = cot_import('tab', 'R', 'ALP');
$cfg_maxitems = is_numeric($cfg['plugin']['search']['maxitems']) ? abs(floor($cfg['plugin']['search']['maxitems'])) : 50;
list($pg, $d, $durl) = cot_import_pagenav('d', $cfg_maxitems);
$totalitems = array();
$pag_catauth = array();
$frm_catauth = array();
$rs = $_REQUEST['rs'];
$rs['pagtitle'] = cot_import($rs['pagtitle'], 'D', 'INT');
$rs['pagdesc'] = cot_import($rs['pagdesc'], 'D', 'INT');
$rs['pagtext'] = cot_import($rs['pagtext'], 'D', 'INT');
$rs['pagfile'] = cot_import($rs['pagfile'], 'D', 'INT');
$rs['pagsort'] = cot_import($rs['pagsort'], 'D', 'ALP');
$rs['pagsort'] = empty($rs['pagsort']) ? 'date' : $rs['pagsort'];
$rs['pagsort2'] = cot_import($rs['pagsort2'], 'D', 'ALP') == 'DESC' ? 'DESC' : 'ASC';
$rs['pagsub'] = cot_import($rs['pagsub'], 'D', 'ARR');
$rs['pagsubcat'] = cot_import($rs['pagsubcat'], 'D', 'BOL') ? 1 : 0;
$rs['frmtitle'] = cot_import($rs['frmtitle'], 'D', 'INT');
$rs['frmtext'] = cot_import($rs['frmtext'], 'D', 'INT');
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
$opt = cot_import('opt', 'G', 'ALP');
// display option
$f = cot_import('f', 'G', 'INT');
// folder id
$c1 = cot_import('c1', 'G', 'ALP');
// form name
$c2 = cot_import('c2', 'G', 'ALP');
// input name
$parser = cot_import('parser', 'G', 'ALP');
// custom parser
$userid = cot_import('userid', 'G', 'INT');
// User ID or 0
$gd_supported = array('jpg', 'jpeg', 'png', 'gif');
list($pg, $d, $durl) = cot_import_pagenav('d', $cfg['pfs']['maxpfsperpage']);
// Page number files
list($pgf, $df) = cot_import_pagenav('df', $cfg['pfs']['maxpfsperpage']);
// page number folders
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('pfs', 'a');
cot_block($usr['auth_read']);
$sys['parser'] = empty($parser) ? $cfg['parser'] : $parser;
$pn_c1 = empty($c1) ? '' : '&c1=' . $c1;
$pn_c2 = empty($c2) ? '' : '&c2=' . $c2;
if (!$usr['isadmin'] || $userid === null) {
    $userid = $usr['id'];
} else {
    $more = 'userid=' . $userid;
}
$files_count = 0;
$folders_count = 0;
$standalone = FALSE;
$uid = $userid > 0 ? $userid : $usr['id'];
Ejemplo n.º 9
0
 * [BEGIN_COT_EXT]
 * Hooks=index.tags
 * [END_COT_EXT]
 */
/**
 * projects module
 *
 * @package projects
 * @version 2.5.2
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL.');
require_once cot_incfile('projects', 'module');
list($pn, $p, $d_url) = cot_import_pagenav('p', $cfg['projects']['indexlimit']);
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('projects', 'any', 'RWA');
$t_pr = new XTemplate(cot_tplfile('projects.index', 'module'));
if (is_array($projects_types)) {
    foreach ($projects_types as $i => $pr_type) {
        $t_pr->assign(array('PTYPE_ROW_ID' => $i, 'PTYPE_ROW_TITLE' => $pr_type, 'PTYPE_ROW_URL' => cot_url('projects', 'type=' . $i)));
        $t_pr->parse("SEARCH.PTYPES.PTYPES_ROWS");
    }
}
$t_pr->assign(array('PTYPE_ALL_URL' => cot_url('projects', ''), 'REALIZED_URL' => cot_url('projects', 'realized=1'), "FORPRO_URL" => cot_url('projects', 'forpro=1')));
$t_pr->parse("SEARCH.PTYPES");
$t_pr->assign(array('SEARCH_ACTION_URL' => cot_url('projects', '', '', true), 'SEARCH_SQ' => cot_inputbox('text', 'sq', htmlspecialchars($sq), 'class="schstring"'), "SEARCH_CAT" => cot_projects_selectcat($c, 'c'), "SEARCH_SORTER" => cot_selectbox($sort, "sort", array('', 'costasc', 'costdesc'), array($L['projects_mostrelevant'], $L['projects_costasc'], $L['projects_costdesc']), false)));
foreach ($cot_extrafields[$db_projects] as $exfld) {
    $uname = strtoupper($exfld['field_name']);
    $exfld_val = cot_build_extrafields($exfld['field_name'], $exfld, '');
    $exfld_title = isset($L['projects_' . $exfld['field_name'] . '_title']) ? $L['projects_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
Ejemplo n.º 10
0
 /**
  * основная статистика кликов и показов
  */
 public function indexAction()
 {
     global $admintitle, $adminpath, $structure;
     $admintitle = cot::$L['brs_tracks'];
     $adminpath[] = array(cot_url('admin', array('m' => 'brs', 'n' => 'track')), cot::$L['brs_tracks']);
     $sortFields = array('b.title' => cot::$L['Title'], 'b.category' => cot::$L['Category'], 'b.client' => cot::$L['brs_client'], 't.type' => cot::$L['Type'], 't.track_count' => cot::$L['Count'], 't.date' => cot::$L['Date']);
     $sort = cot_import('s', 'G', 'TXT');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     $f = cot_import('f', 'G', 'ARR');
     // filters
     $f['date_from'] = cot_import_date('f_df', true, false, 'G');
     $f['date_to'] = cot_import_date('f_dt', true, false, 'G');
     $maxrowsperpage = cot::$cfg['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for banners list
     $sort = empty($sort) ? 't.date' : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? 'desc' : $way;
     $urlParams = array('m' => 'brs', 'n' => 'track');
     if ($sort != 't.date') {
         $urlParams['s'] = $sort;
     }
     if ($way != 'desc') {
         $urlParams['w'] = $way;
     }
     $where = array();
     $params = array();
     if (!empty($f)) {
         foreach ($f as $key => $val) {
             $val = trim(cot_import($val, 'D', 'TXT'));
             if (empty($val) && $val !== '0') {
                 continue;
             }
             if (in_array($key, array('b.title'))) {
                 $kkey = str_replace('.', '_', $key);
                 $params[$kkey] = "%{$val}%";
                 $where['filter'][] = "{$key} LIKE :{$kkey}";
                 $urlParams["f[{$key}]"] = $val;
             } elseif ($key == 'date_from') {
                 if ($f[$key] == 0) {
                     continue;
                 }
                 $where['filter'][] = "t.date >= '" . date('Y-m-d H:i:s', $f[$key]) . "'";
                 $urlParams["f_df[year]"] = cot_date('Y', $f[$key]);
                 $urlParams["f_df[month]"] = cot_date('m', $f[$key]);
                 $urlParams["f_df[day]"] = cot_date('d', $f[$key]);
             } elseif ($key == 'date_to') {
                 if ($f[$key] == 0) {
                     continue;
                 }
                 $where['filter'][] = "t.date <= '" . date('Y-m-d H:i:s', $f[$key]) . "'";
                 $urlParams["f_dt[year]"] = cot_date('Y', $f[$key]);
                 $urlParams["f_dt[month]"] = cot_date('m', $f[$key]);
                 $urlParams["f_dt[day]"] = cot_date('d', $f[$key]);
             } else {
                 $kkey = str_replace('.', '_', $key);
                 $params[$kkey] = $val;
                 $where['filter'][] = "{$key} = :{$kkey}";
                 $urlParams["f[{$key}]"] = $val;
             }
         }
         empty($where['filter']) || ($where['filter'] = implode(' AND ', $where['filter']));
     } else {
         $f = array();
     }
     $orderby = "{$sort} {$way}";
     $where = array_filter($where);
     $where = $where ? 'WHERE ' . implode(' AND ', $where) : '';
     $sql = "SELECT `t`.`date`, `t`.`type` , `t`.`track_count`, `t`.`banner`, b.title, b.category, cl.title as client_title,\n                cl.id as client_id\n            FROM " . cot::$db->banner_tracks . " AS t\n            LEFT JOIN " . cot::$db->banners . " AS b ON b.id=t.banner\n            LEFT JOIN " . cot::$db->banner_clients . " AS cl ON cl.id=b.client\n            {$where} ORDER BY {$orderby} LIMIT {$d}, {$maxrowsperpage}";
     $sqlCount = "SELECT COUNT(*)\n            FROM " . cot::$db->banner_tracks . " AS t\n            LEFT JOIN " . cot::$db->banners . " AS b ON b.id=t.banner\n            LEFT JOIN " . cot::$db->banner_clients . " AS cl ON cl.id=b.client\n            {$where}";
     $totallines = cot::$db->query($sqlCount, $params)->fetchColumn();
     $sqllist = cot::$db->query($sql, $params);
     // Без Ajax, а то дата пропадает (UI datetime)
     $pagenav = cot_pagenav('admin', $urlParams, $d, $totallines, $maxrowsperpage);
     $track_types = array(1 => cot::$L['brs_impressions'], 2 => cot::$L['brs_clicks']);
     $items = $sqllist->fetchAll();
     if ($items) {
         foreach ($items as $key => $itemRow) {
             $items[$key]['categoryTitle'] = '';
             if (!empty($itemRow['category']) && !empty($structure['brs'][$itemRow['category']])) {
                 $items[$key]['categoryTitle'] = $structure['brs'][$itemRow['category']]['title'];
             }
             $items[$key]['track_typeTitle'] = $track_types[$itemRow['type']];
         }
     }
     $clients = brs_model_Client::keyValPairs();
     if (!$clients) {
         $clients = array();
     }
     $filterForm = array('hidden' => cot_inputbox('hidden', 'n', 'track'), 'title' => array('element' => cot_inputbox('text', 'f[b.title]', $f['b.title']), 'label' => brs_model_Banner::fieldLabel('title')), 'category' => array('element' => brs_selectbox_structure('brs', $f['b.category'], 'f[b.category]', '', false, false, true), 'label' => brs_model_Banner::fieldLabel('category')), 'client' => array('element' => cot_selectbox($f['b.client'], 'f[b.client]', array_keys($clients), array_values($clients)), 'label' => brs_model_Banner::fieldLabel('client')), 'type' => array('element' => cot_selectbox($f['t.type'], 'f[t.type]', array_keys($track_types), array_values($track_types)), 'label' => cot::$L['Type']), 'date_from' => array('element' => cot_selectbox_date($f['date_from'], 'short', 'f_df'), 'label' => cot::$L['brs_from']), 'date_to' => array('element' => cot_selectbox_date($f['date_to'], 'short', 'f_dt'), 'label' => cot::$L['brs_to']), 'sort' => array('element' => cot_selectbox($sort, 's', array_keys($sortFields), array_values($sortFields), false), 'label' => cot::$L['adm_sort']), 'way' => array('element' => cot_selectbox($way, 'w', array('asc', 'desc'), array(cot::$L['Ascending'], cot::$L['Descending']), false)));
     if (isset(cot::$cfg['plugin']['urleditor']) && cot::$cfg['plugin']['urleditor']['preset'] != 'handy') {
         $filterForm['hidden'] .= cot_inputbox('hidden', 'm', 'brs');
     }
     $template = array('brs', 'admin', 'track');
     $view = new View();
     $view->page_title = $admintitle;
     $view->fistNumber = $d + 1;
     $view->items = $items;
     $view->clients = $clients;
     $view->track_types = $track_types;
     $view->totalitems = $totallines;
     $view->filterForm = $filterForm;
     $view->pagenav = $pagenav;
     //        $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->filter = $f;
     /* === Hook === */
     foreach (cot_getextplugins('brs.admin.track.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
Ejemplo n.º 11
0
<?php

/**
 * Users list
 *
 * @package Users
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
$id = cot_import('id', 'G', 'INT');
$s = cot_import('s', 'G', 'ALP', 16);
$w = cot_import('w', 'G', 'ALP', 4);
list($pg, $d, $durl) = cot_import_pagenav('d', $cfg['users']['maxusersperpage']);
$f = cot_import('f', 'G', 'ALP', 16);
$g = cot_import('g', 'G', 'INT');
$gm = cot_import('gm', 'G', 'INT');
$y = cot_import('y', 'P', 'TXT', 16);
$sq = cot_import('sq', 'G', 'TXT', 16);
unset($localskin, $grpms);
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('users', 'a');
cot_block($usr['auth_read']);
require_once cot_langfile('users', 'module');
require_once cot_langfile('countries', 'core');
$users_sort_tags = array('id' => array('USERS_TOP_USERID', &$L['Userid']), 'name' => array('USERS_TOP_NAME', &$L['Username']), 'maingrp' => array('USERS_TOP_MAINGRP', &$L['Maingroup']), 'country' => array('USERS_TOP_COUNTRY', &$L['Country']), 'occupation' => array('USERS_TOP_OCCUPATION', &$L['Occupation']), 'location' => array('USERS_TOP_LOCATION', &$L['Location']), 'timezone' => array('USERS_TOP_TIMEZONE', &$L['Timezone']), 'birthdate' => array('USERS_TOP_BIRTHDATE', &$L['Birthdate']), 'gender' => array('USERS_TOP_GENDER', &$L['Gender']), 'regdate' => array('USERS_TOP_REGDATE', &$L['Registered']), 'lastlog' => array('USERS_TOP_LASTLOGGED', &$L['Lastlogged']), 'logcount' => array('USERS_TOP_LOGCOUNT', &$L['Count']), 'postcount' => array('USERS_TOP_POSTCOUNT', &$L['Posts']), 'grplevel' => array('USERS_TOP_GRPLEVEL', &$L['Level']), 'grpname' => array('USERS_TOP_GRPTITLE', &$L['Maingroup']));
$users_sort_blacklist = array('email', 'lastip', 'password', 'sid', 'sidtime', 'lostpass', 'auth', 'token');
$users_sort_whitelist = array('id', 'name', 'maingrp', 'country', 'timezone', 'birthdate', 'gender', 'lang', 'regdate');
/* === Hook === */
foreach (cot_getextplugins('users.first') as $pl) {
    include $pl;
}
Ejemplo n.º 12
0
     $sql_injection = $db->query("UPDATE {$db_users} SET user_karma=user_karma + " . $value . " WHERE user_id={$recipient}");
     $popup_body .= karma_error('karma_ms_ok', $L['karma_changed_ok'], $cfg['plugin']['karma']['close_win']);
     break;
 case 'moderate':
     if (!cot_auth('plug', 'karma', 'A')) {
         cot_diefatal($L['low_level']);
     }
     $karma_userid = $db->query("SELECT u.user_id,k.karma_value FROM cot_karma k LEFT JOIN {$db_users} u ON (u.user_id = k.karma_recipient)  WHERE k.karma_id = {$fp}   LIMIT 1 ")->fetch();
     $db->query("DELETE FROM cot_karma WHERE karma_id = {$fp}  LIMIT 1");
     $db->query("UPDATE {$db_users} SET user_karma = user_karma -{$karma_userid['karma_value']} WHERE user_id = {$karma_userid['user_id']}");
     $ku = cot_import('ku', 'G', 'INT');
     $popup_body .= karma_error('karma_ms_ok', $L['karma_del_ok'], true);
     break;
 case 'show':
 default:
     list($pg, $kn) = cot_import_pagenav('kn', $cfg['plugin']['karma']['karma_maxpage']);
     $tmp = $db->query("SELECT COUNT(*),SUM(karma_value) AS karma FROM cot_karma WHERE karma_recipient = {$fp}")->fetch();
     $total_p = $tmp['COUNT(*)'];
     if (cot_plugin_active('comments')) {
         $sql = $db->query("SELECT u.*, k.*,c.com_code,c.com_id FROM cot_karma k LEFT JOIN {$db_users} u ON (u.user_id=k.karma_rater) LEFT JOIN {$db_com} c ON (c.com_id=k.karma_fp) WHERE k.karma_recipient = {$fp}  ORDER BY k.karma_id DESC LIMIT {$kn}, " . $cfg['plugin']['karma']['karma_maxpage'] . "");
     } else {
         $sql = $db->query("SELECT u.*, k.* FROM cot_karma k LEFT JOIN {$db_users} u ON (u.user_id=k.karma_rater)  WHERE k.karma_recipient = {$fp}  ORDER BY k.karma_id DESC LIMIT {$kn}, " . $cfg['plugin']['karma']['karma_maxpage'] . "");
     }
     $sql1 = $db->query("SELECT * FROM {$db_users} WHERE user_id = {$fp} LIMIT 1");
     $thiss = $sql1->fetch();
     $karmaarr = explode(":", $thiss['user_karma_auth']);
     $kr->assign(array("KARMA_NAME_USER" => $thiss['user_name'], "KARMA_USER_VALUE" => number_format($tmp['karma'], '1', '.', ' '), "KARMA_USER_KARMA_FULL" => number_format($thiss['user_karma'], '1', '.', ' '), "KARMA_USERS" => cot_declension($total_p, $L['userkarma']), "KARMA_ADMIN" => cot_auth('plug', 'karma', 'A') ? true : "", "KARMA_AUTH_VALUE" => number_format($karmaarr[1], '1', '.', ' '), "KARMA_AUTH_COUNT" => $karmaarr[2] ? cot_declension($karmaarr[2], $L['user_auth_dec']) : ''));
     if ($cfg['plugin']['karma']['karma_profile']) {
         $kr->assign(cot_generate_usertags($thiss, "KARMA_USER_PROFILE_"));
     }
     if ($total_p == 0 && $thiss['user_karma_auth'] == 0) {
Ejemplo n.º 13
0
 /**
  * Список рассылок
  */
 public function indexAction()
 {
     $maxrowsperpage = cot::$cfg['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for pages list
     $sort = 'title';
     $way = 'asc';
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.list.first') as $pl) {
         include $pl;
     }
     /* ===== */
     $urlParams = array();
     $canonicalUrlParams = array();
     if ($durl > 1) {
         $canonicalUrlParams['d'] = $durl;
     }
     $where = array();
     cot::$out['subtitle'] = $title = cot::$L['subscribe_subscribes'];
     // Building the canonical URL
     cot::$out['canonical_uri'] = cot_url('subscribe', $canonicalUrlParams);
     $condition = array(array('active', 1), array('periodical', 1));
     $order = array(array('active', 'desc'), array($sort, $way));
     $userSubscribesCondition = array();
     if (cot::$usr['id'] > 0) {
         $userSubscribesCondition[] = array('active', 1);
         $userSubscribesCondition[] = array('user', cot::$usr['id']);
         if (!empty(cot::$usr['profile']['user_email'])) {
             //$userSubscribesCondition[] = array('email', cot::$usr['profile']['user_email'], '=', 'OR');
             $userSubscribesCondition = array(array('SQL', 'active=1 AND (user='******'id'] . ' OR email=' . cot::$db->quote(cot::$usr['profile']['user_email']) . ')'));
         }
     }
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = subscribe_model_Subscribe::count($condition);
     $items = null;
     if ($totallines > 0) {
         $items = subscribe_model_Subscribe::find($condition, $maxrowsperpage, $d, $order);
     }
     // Подписки пользователя
     $userSubscribes = null;
     $userSubscribesIds = array();
     if (!empty($items)) {
         if (cot::$usr['id'] > 0) {
             $userSubscribes = subscribe_model_Subscriber::find($userSubscribesCondition, 0, 0, array(array('active', 'desc')));
             if (!empty($userSubscribes)) {
                 foreach ($userSubscribes as $usRow) {
                     $userSubscribesIds[] = $usRow->rawValue('subscribe');
                 }
             }
         }
     }
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.list.main') as $pl) {
         include $pl;
     }
     /* ===== */
     if (cot::$usr['id'] > 0) {
         Resources::linkFileFooter(cot::$cfg['modules_dir'] . '/subscribe/js/subscriber.js');
     }
     $crumbs = array(cot::$L['subscribe_subscribes']);
     $pagenav = cot_pagenav('subscribe', $urlParams, $d, $totallines, $maxrowsperpage);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $breadcrumbs = '';
     if (!empty($crumbs)) {
         $breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     }
     $template = array('subscribe', 'list');
     //        $pageUrlParams = $urlParams;
     //        if($durl > 1) $pageUrlParams['d'] = $durl;
     $view = new View();
     $view->breadcrumbs = $breadcrumbs;
     $view->page_title = htmlspecialchars($title);
     $view->items = $items;
     $view->userSubscribes = $userSubscribes;
     $view->userSubscribesIds = $userSubscribesIds;
     $view->totalitems = $totallines;
     $view->pagenav = $pagenav;
     $view->urlParams = $urlParams;
     //        $view->pageUrlParams = $pageUrlParams;
     /* === Hook === */
     foreach (cot_getextplugins('subscribe.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
Ejemplo n.º 14
0
$qs = cot_import('t', 'G', 'TXT');
if (empty($qs)) {
    $qs = cot_import('t', 'P', 'TXT');
}
$qs = str_replace('-', ' ', $qs);
$tl = cot_import('tl', 'G', 'BOL');
if ($tl && file_exists(cot_langfile('translit', 'core'))) {
    include_once cot_langfile('translit', 'core');
    $qs = strtr($qs, $cot_translitb);
}
// Results per page
$maxperpage = $cfg['maxrowsperpage'] && is_numeric($cfg['maxrowsperpage']) && $cfg['maxrowsperpage'] > 0 ? $cfg['maxrowsperpage'] : 15;
list(, $d) = cot_import_pagenav('d', $maxperpage);
// Tags displayed per page in standalone cloud
$perpage = $cfg['plugin']['tags']['perpage'];
list(, $dt) = cot_import_pagenav('dt', $perpage);
// Array to register areas with tag functions provided
$tag_areas = array();
if (cot_module_active('page')) {
    require_once cot_incfile('page', 'module');
    $tag_areas[] = 'pages';
}
if (cot_module_active('forums')) {
    require_once cot_incfile('forums', 'module');
    $tag_areas[] = 'forums';
}
// Sorting order
$o = cot_import('order', 'P', 'ALP');
if (empty($o)) {
    $o = mb_strtolower($cfg['plugin']['tags']['sort']);
}
Ejemplo n.º 15
0
define('COT_LIST', TRUE);
$env['location'] = 'list';
$s = cot_import('s', 'G', 'ALP');
// order field name without 'page_'
$w = cot_import('w', 'G', 'ALP', 4);
// order way (asc, desc)
$c = cot_import('c', 'G', 'TXT');
// cat code
$o = cot_import('ord', 'G', 'ARR');
// filter field names without 'page_'
$p = cot_import('p', 'G', 'ARR');
// filter values
$maxrowsperpage = $cfg['page']['cat_' . $c]['maxrowsperpage'] ? $cfg['page']['cat_' . $c]['maxrowsperpage'] : $cfg['page']['cat___default']['maxrowsperpage'];
list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
//page number for pages list
list($pgc, $dc, $dcurl) = cot_import_pagenav('dc', $cfg['page']['maxlistsperpage']);
// page number for cats list
if ($c == 'all' || $c == 'system') {
    list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('admin', 'a');
    cot_block($usr['isadmin']);
} elseif ($c == 'unvalidated' || $c == 'saved_drafts') {
    list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('page', 'any');
    cot_block($usr['auth_write']);
} elseif (!isset($structure['page'][$c])) {
    cot_die_message(404, TRUE);
} else {
    list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('page', $c);
    cot_block($usr['auth_read']);
}
/* === Hook === */
foreach (cot_getextplugins('page.list.first') as $pl) {
Ejemplo n.º 16
0
 public static function adsList($condition = array(), $tpl = 'advboard.widget.list', $items = 0, $order = '', $onlyActive = true, $pagination = 'pld', $params = array())
 {
     // Get pagination number if necessary
     if (!empty($pagination)) {
         list($pg, $d, $durl) = cot_import_pagenav($pagination, $items);
     } else {
         $d = 0;
     }
     if (empty($condition)) {
         $condition = array();
     }
     if ($onlyActive) {
         $condition[] = array('begin', cot::$sys['now'], '<=');
         $condition[] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
         $condition[] = array('state', advboard_model_Advert::PUBLISHED);
     }
     if (empty($order)) {
         $order = array(array('state', 'ASC'), array('sort', 'DESC'));
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.widget.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = advboard_model_Advert::count($condition);
     $advertisement = advboard_model_Advert::find($condition, $items, $d, $order);
     // Render pagination
     if (empty($params['module'])) {
         $params['module'] = defined('COT_PLUG') ? 'plug' : cot::$env['ext'];
     }
     if (empty($params['urlParams'])) {
         if (defined('COT_LIST')) {
             global $list_url_path;
             $params['urlParams'] = $list_url_path;
         } elseif (defined('COT_PAGES')) {
             global $al, $id, $pag;
             $params['urlParams'] = empty($al) ? array('c' => $pag['page_cat'], 'id' => $id) : array('c' => $pag['page_cat'], 'al' => $al);
         } else {
             $params['urlParams'] = array();
         }
     }
     if (empty($params['ajax'])) {
         $params['ajax'] = false;
     }
     if (empty($params['target_div'])) {
         $params['target_div'] = '';
     }
     if (empty($params['ajax_module'])) {
         $params['ajax_module'] = '';
     }
     if (empty($params['ajax_params'])) {
         $params['ajax_params'] = array();
     }
     $pagenav = cot_pagenav($params['module'], $params['urlParams'], $d, $totallines, $items, $pagination, '', $params['ajax'], $params['target_div'], $params['ajax_module'], $params['ajax_params']);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $view = new View();
     /* === Hook === */
     foreach (cot_getextplugins('advboard.widget.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     $view->advertisement = $advertisement;
     $view->totalitems = $totallines;
     $view->pagenav = $pagenav;
     return $view->render($tpl);
 }
Ejemplo n.º 17
0
/**
 * Generates comments display for a given item
 *
 * @param string $ext_name Module or plugin code
 * @param string $code Item identifier
 * @param string $cat Item category code (optional)
 * @param bool $force_admin Enforces user to be administrator of comments for this item.
 *	E.g. to moderate his wall even if he is not a moderator
 * @return string Rendered HTML output for comments
 * @global CotDB $db
 */
function cot_comments_display($ext_name, $code, $cat = '', $force_admin = false)
{
    global $db, $db_com, $db_users, $cfg, $usr, $L, $sys, $R, $env, $pg, $cot_extrafields, $cache, $structure;
    // Check permissions and enablement
    list($auth_read, $auth_write, $auth_admin) = cot_auth('plug', 'comments');
    if ($auth_read && $auth_write && $force_admin) {
        $auth_admin = true;
        $_SESSION['cot_comments_force_admin'][$ext_name][$code] = true;
    }
    $enabled = cot_comments_enabled($ext_name, $cat, $code);
    if (!$auth_read || !$enabled && !$auth_admin) {
        return '';
    }
    $comments_join_columns = $comments_join_tables = $comments_join_where = '';
    // Get the URL and parameters
    $link_area = $env['ext'];
    $link_params = $_GET;
    if (defined('COT_PLUG')) {
        $link_area = 'plug';
        $link_params['e'] = $env['ext'];
    }
    if (isset($_GET['rwr'])) {
        unset($link_params['rwr'], $link_params['e']);
    }
    $cot_com_back = array($link_area, $link_params);
    $_SESSION['cot_com_back'][$ext_name][$cat][$code] = $cot_com_back;
    $d_var = 'dcm';
    list($pg, $d, $durl) = cot_import_pagenav($d_var, $cfg['plugin']['comments']['maxcommentsperpage']);
    $d = empty($d) ? 0 : (int) $d;
    if ($auth_write && $enabled) {
        require_once cot_incfile('forms');
    }
    $t = new XTemplate(cot_tplfile('comments', 'plug'));
    /* == Hook == */
    foreach (cot_getextplugins('comments.main') as $pl) {
        include $pl;
    }
    /* ===== */
    $editor = cot::$cfg['plugin']['comments']['markup'] ? 'input_textarea_minieditor' : '';
    $t->assign(array('COMMENTS_CODE' => $code, 'COMMENTS_FORM_SEND' => cot_url('plug', "e=comments&a=send&area={$ext_name}&cat={$cat}&item={$code}"), 'COMMENTS_FORM_AUTHOR' => $usr['id'] > 0 ? $usr['name'] : cot_inputbox('text', 'rname'), 'COMMENTS_FORM_AUTHORID' => $usr['id'], 'COMMENTS_FORM_TEXT' => $auth_write && $enabled ? cot_textarea('rtext', $rtext, 7, 120, '', $editor) . cot_inputbox('hidden', 'cb', base64_encode(serialize($cot_com_back))) : '', 'COMMENTS_DISPLAY' => $cfg['plugin']['comments']['expand_comments'] ? '' : 'none'));
    if ($auth_write && $enabled) {
        // Extra fields
        if (!empty(cot::$extrafields[cot::$db->com])) {
            foreach (cot::$extrafields[cot::$db->com] as $exfld) {
                $uname = strtoupper($exfld['field_name']);
                $exfld_val = cot_build_extrafields('rcomments' . $exfld['field_name'], $exfld, $rcomments[$exfld['field_name']]);
                $exfld_title = cot_extrafield_title($exfld, 'comments_');
                $t->assign(array('COMMENTS_FORM_' . $uname => $exfld_val, 'COMMENTS_FORM_' . $uname . '_TITLE' => $exfld_title, 'COMMENTS_FORM_EXTRAFLD' => $exfld_val, 'COMMENTS_FORM_EXTRAFLD_TITLE' => $exfld_title));
                $t->parse('COMMENTS.COMMENTS_NEWCOMMENT.EXTRAFLD');
            }
        }
        $allowed_time = cot_build_timegap($sys['now'] - $cfg['plugin']['comments']['time'] * 60, $sys['now']);
        $com_hint = cot_rc('com_edithint', array('time' => $allowed_time));
        /* == Hook == */
        foreach (cot_getextplugins('comments.newcomment.tags') as $pl) {
            include $pl;
        }
        /* ===== */
        $usr['id'] == 0 && $t->parse('COMMENTS.COMMENTS_NEWCOMMENT.GUEST');
        if ($usr['id'] == 0 && cot_check_messages() && $cache) {
            if ($ext_name == 'page' && $cfg['cache_page']) {
                $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$cat]['path']));
                $cfg['cache_page'] = false;
            }
        }
        cot_display_messages($t, 'COMMENTS.COMMENTS_NEWCOMMENT');
        $t->assign('COMMENTS_FORM_HINT', $com_hint);
        $t->parse('COMMENTS.COMMENTS_NEWCOMMENT');
    } else {
        $warning = $enabled ? $L['com_regonly'] : $L['com_closed'];
        $t->assign('COMMENTS_CLOSED', $warning);
        $t->parse('COMMENTS.COMMENTS_CLOSED');
    }
    $order = $cfg['plugin']['comments']['order'] == 'Chronological' ? 'ASC' : 'DESC';
    $comments_order = "com_id {$order}";
    /* == Hook == */
    foreach (cot_getextplugins('comments.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $sql = $db->query("SELECT c.*, u.* {$comments_join_columns}\n\t\tFROM {$db_com} AS c LEFT JOIN {$db_users} AS u ON u.user_id = c.com_authorid {$comments_join_tables}\n\t\tWHERE com_area = ? AND com_code = ? {$comments_join_where} ORDER BY {$comments_order} LIMIT ?, ?", array($ext_name, $code, (int) $d, (int) $cfg['plugin']['comments']['maxcommentsperpage']));
    if ($sql->rowCount() > 0 && $enabled) {
        $i = $d;
        $kk = 0;
        $totalitems = cot_comments_count($ext_name, $code);
        /* === Hook - Part1 : Set === */
        $extp = cot_getextplugins('comments.loop');
        /* ===== */
        foreach ($sql->fetchAll() as $row) {
            $i++;
            $kk++;
            $com_admin = $auth_admin ? cot_rc('comments_code_admin', array('ipsearch' => cot_build_ipsearch($row['com_authorip']), 'delete_url' => cot_confirm_url(cot_url('plug', 'e=comments&a=delete&cat=' . $cat . '&id=' . $row['com_id'] . '&' . cot_xg()), 'comments', 'comments_confirm_delete'))) : '';
            $com_text = cot_parse($row['com_text'], $cfg['plugin']['comments']['markup']);
            $time_limit = $sys['now'] < $row['com_date'] + $cfg['plugin']['comments']['time'] * 60 ? TRUE : FALSE;
            $usr['isowner_com'] = $time_limit && ($usr['id'] > 0 && $row['com_authorid'] == $usr['id'] || $usr['id'] == 0 && !empty($_SESSION['cot_comments_edit'][$row['com_id']]) && $usr['ip'] == $row['com_authorip']);
            $com_gup = $sys['now'] - ($row['com_date'] + $cfg['plugin']['comments']['time'] * 60);
            $allowed_time = $usr['isowner_com'] && !$usr['isadmin'] ? ' - ' . cot_build_timegap($sys['now'] + $com_gup, $sys['now']) . $L['plu_comgup'] : '';
            $com_edit = $auth_admin || $usr['isowner_com'] ? cot_rc('comments_code_edit', array('edit_url' => cot_url('plug', 'e=comments&m=edit&cat=' . $cat . '&id=' . $row['com_id']), 'allowed_time' => $allowed_time)) : '';
            if ($row['com_area'] == 'page') {
                if ($usr['id'] == 0 && $usr['isowner_com'] && $cfg['cache_page']) {
                    $cfg['cache_page'] = $cfg['cache_index'] = false;
                }
            }
            $t->assign(array('COMMENTS_ROW_ID' => $row['com_id'], 'COMMENTS_ROW_ORDER' => $cfg['plugin']['comments']['order'] == 'Recent' ? $totalitems - $i + 1 : $i, 'COMMENTS_ROW_URL' => cot_url($link_area, $link_params, '#c' . $row['com_id']), 'COMMENTS_ROW_AUTHOR' => cot_build_user($row['com_authorid'], htmlspecialchars($row['com_author'])), 'COMMENTS_ROW_AUTHORID' => $row['com_authorid'], 'COMMENTS_ROW_TEXT' => $com_text, 'COMMENTS_ROW_DATE' => cot_date('datetime_medium', $row['com_date']), 'COMMENTS_ROW_DATE_STAMP' => $row['com_date'], 'COMMENTS_ROW_ADMIN' => $com_admin, 'COMMENTS_ROW_EDIT' => $com_edit, 'COMMENTS_ROW_ODDEVEN' => cot_build_oddeven($kk), 'COMMENTS_ROW_NUM' => $kk));
            // Extrafields
            if (!empty(cot::$extrafields[cot::$db->com])) {
                foreach (cot::$extrafields[cot::$db->com] as $exfld) {
                    $tag = mb_strtoupper($exfld['field_name']);
                    $exfld_title = cot_extrafield_title($exfld, 'comments_');
                    $t->assign(array('COMMENTS_ROW_' . $tag . '_TITLE' => $exfld_title, 'COMMENTS_ROW_' . $tag => cot_build_extrafields_data('comments', $exfld, $row['com_' . $exfld['field_name']]), 'COMMENTS_ROW_' . $tag . '_VALUE' => $row['com_' . $exfld['field_name']]));
                }
            }
            $t->assign(cot_generate_usertags($row, 'COMMENTS_ROW_AUTHOR_', htmlspecialchars($row['com_author'])));
            /* === Hook - Part2 : Include === */
            foreach ($extp as $pl) {
                include $pl;
            }
            /* ===== */
            $t->parse('COMMENTS.COMMENTS_ROW');
        }
        $pagenav = cot_pagenav($link_area, $link_params, $d, $totalitems, $cfg['plugin']['comments']['maxcommentsperpage'], $d_var, '#comments', $cfg['jquery'] && $cfg['ajax_enabled'], 'comments', 'plug', "e=comments&area={$ext_name}&cat={$cat}&item={$code}");
        $t->assign(array('COMMENTS_PAGES_INFO' => cot_rc('comments_code_pages_info', array('totalitems' => $totalitems, 'onpage' => $i - $d)), 'COMMENTS_PAGES_TOTALITEMS' => $totalitems, 'COMMENTS_PAGES_PAGESPREV' => $pagenav['prev'], 'COMMENTS_PAGES_PAGNAV' => $pagenav['main'], 'COMMENTS_PAGES_PAGESNEXT' => $pagenav['next']));
        $t->parse('COMMENTS.PAGNAVIGATOR');
    } elseif (!$sql->rowCount() && $enabled) {
        $t->assign(array('COMMENTS_EMPTYTEXT' => $L['com_nocommentsyet']));
        $t->parse('COMMENTS.COMMENTS_EMPTY');
    }
    /* == Hook == */
    foreach (cot_getextplugins('comments.tags') as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('COMMENTS');
    $res_display = $t->text('COMMENTS');
    return $res_display;
}
Ejemplo n.º 18
0
 /**
  * Список объявлений
  * @param $c
  * @return string
  * @throws Exception
  */
 public function adList($c)
 {
     global $structure, $cot_extrafields, $db_structure, $Ls;
     if ($c == 'all') {
         cot_block(cot::$usr['isadmin']);
     } elseif (!in_array($c, array('unvalidated', 'saved-drafts'))) {
         if (!isset($structure['advboard'][$c])) {
             cot_die_message(404, TRUE);
         } else {
             list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin']) = cot_auth('advboard', $c);
             cot_block(cot::$usr['auth_read']);
         }
     }
     $sort = cot_import('s', 'G', 'ALP');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     $maxrowsperpage = cot::$cfg['advboard']['cat_' . $c]['maxrowsperpage'] ? cot::$cfg['advboard']['cat_' . $c]['maxrowsperpage'] : cot::$cfg['advboard']['cat___default']['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for pages list
     list($pgc, $dc, $dcurl) = cot_import_pagenav('dc', cot::$cfg['advboard']['maxlistsperpage']);
     // page number for cats list
     // Фильтры для модератора
     $mf = array('period' => 0, 'state' => -2);
     if (cot::$usr['isadmin']) {
         $mf['period'] = isset($_GET['mf']['period']) ? cot_import($_GET['mf']['period'], 'D', 'ALP') : 0;
         $mf['state'] = isset($_GET['mf']['state']) ? cot_import($_GET['mf']['state'], 'D', 'INT') : -2;
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.first') as $pl) {
         include $pl;
     }
     /* ===== */
     $category = array('config' => array());
     if (isset($structure['advboard'][$c])) {
         $category = $structure['advboard'][$c];
         $category['config'] = cot::$cfg['advboard']['cat_' . $c];
     }
     $category['code'] = $c;
     $fields = advboard_model_Advert::getColumns();
     if (empty($sort)) {
         $sort = cot::$cfg['advboard']['cat_' . $c]['order'];
     } elseif (!in_array($sort, $fields)) {
         $sort = 'sort';
     }
     $way = empty($way) ? cot::$cfg['advboard']['cat_' . $c]['way'] : $way;
     $sort = empty($sort) ? cot::$cfg['advboard']['cat___default']['order'] : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? cot::$cfg['advboard']['cat___default']['way'] : $way;
     $urlParams = array('c' => $c);
     if ($sort != cot::$cfg['advboard']['cat_' . $c]['order']) {
         $urlParams['s'] = $sort;
     }
     if ($way != cot::$cfg['advboard']['cat_' . $c]['way']) {
         $urlParams['w'] = $way;
     }
     $canonicalUrlParams = array('c' => $c);
     if ($durl > 1) {
         $canonicalUrlParams['d'] = $durl;
     }
     if ($dcurl > 1) {
         $canonicalUrlParams['dc'] = $dcurl;
     }
     $template = array('advboard', 'list');
     $where = array();
     if ($c == 'unvalidated') {
         $template = array('advboard', 'list', 'unvalidated');
         $where['state'] = array('state', advboard_model_Advert::AWAITING_MODERATION);
         if (!cot::$usr['isadmin']) {
             $where['user'] = array('user', cot::$usr['id']);
         }
         $category['title'] = cot::$L['page_validation'];
         $category['desc'] = cot::$L['page_validation_desc'];
         $sort = 'created';
         $way = 'desc';
     } elseif ($c == 'saved-drafts') {
         $template = array('advboard', 'list', 'unvalidated');
         $where['state'] = array('state', advboard_model_Advert::DRAFT);
         if (!cot::$usr['isadmin']) {
             $where['user'] = array('user', cot::$usr['id']);
         }
         $category['title'] = cot::$L['page_drafts'];
         $category['desc'] = cot::$L['page_drafts_desc'];
         $sort = 'created';
         $way = 'desc';
     } elseif ($c == 'all') {
         $category['title'] = cot::$L['advboard_ads_board'];
     } else {
         $where['category'] = array('category', $c);
         $where['state'] = array('state', advboard_model_Advert::PUBLISHED);
         $where['begin'] = array('begin', cot::$sys['now'], '<=');
         $where['expire'] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
         $template = array('advboard', 'list', $structure['advboard'][$c]['tpl']);
     }
     $moderatorFilters = array();
     if (cot::$usr['isadmin']) {
         if ($mf['state'] == -1) {
             unset($where['state']);
         } elseif ($mf['state'] >= 0 && $mf['state'] < 3) {
             $where['state'] = array('state', $mf['state']);
         }
         if ($mf['period'] == 'all') {
             unset($where['begin'], $where['expire']);
         } elseif ($mf['period'] == 'exp') {
             unset($where['begin']);
             $where['expire'] = array('SQL', "expire > 0 AND expire <= " . cot::$sys['now']);
         } elseif ($mf['period'] == 'fut') {
             unset($where['expire']);
             $where['begin'] = array('begin', cot::$sys['now'], '>');
         }
         $tmp = array(-2 => cot::$R['code_option_empty'], -1 => cot::$L['All'], 0 => cot::$L['advboard_state_0'], 1 => cot::$L['advboard_state_1'], 2 => cot::$L['advboard_state_2']);
         $moderatorFilters['state'] = cot_selectbox($mf['state'], 'mf[state]', array_keys($tmp), array_values($tmp), false);
         $tmp = array('0' => cot::$R['code_option_empty'], 'all' => cot::$L['All'], 'exp' => cot::$L['advboard_expired'], 'fut' => cot::$L['advboard_future']);
         $moderatorFilters['period'] = cot_selectbox(strval($mf['period']), 'mf[period]', array_keys($tmp), array_values($tmp), false);
         $moderatorFilters['action'] = cot_url('advboard', $urlParams);
         $moderatorFilters['hidden'] = '';
         foreach ($urlParams as $key => $val) {
             $moderatorFilters['hidden'] .= cot_inputbox('hidden', $key, $val);
         }
         $moderatorFilters['reset'] = cot_url('advboard', $urlParams);
     }
     cot_die(empty($category['title']) && !cot::$usr['isadmin']);
     cot::$out['desc'] = htmlspecialchars(strip_tags($category['desc']));
     cot::$out['subtitle'] = $category['title'];
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['keywords'])) {
         cot::$out['keywords'] = cot::$cfg['advboard']['cat_' . $c]['keywords'];
     }
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['metadesc'])) {
         cot::$out['desc'] = cot::$cfg['advboard']['cat_' . $c]['metadesc'];
     }
     if (!empty(cot::$cfg['advboard']['cat_' . $c]['metatitle'])) {
         cot::$out['subtitle'] = cot::$cfg['advboard']['cat_' . $c]['metatitle'];
     }
     // Building the canonical URL
     cot::$out['canonical_uri'] = cot_url('advboard', $canonicalUrlParams);
     $condition = array();
     foreach ($where as $key => $val) {
         $condition[] = $val;
     }
     $order = array(array('sticky', 'desc'), array($sort, $way));
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = advboard_model_Advert::count($condition);
     $advertisement = null;
     if ($totallines > 0) {
         $advertisement = advboard_model_Advert::find($condition, $maxrowsperpage, $d, $order);
     }
     $allowComments = cot_plugin_active('comments');
     if ($allowComments) {
         if (!isset(cot::$cfg['advboard']['cat_' . $c])) {
             $allowComments = false;
         } else {
             $allowComments = cot::$cfg['advboard']['cat_' . $c]['enable_comments'];
         }
     }
     $addNewUrl = '';
     if ((cot::$usr['auth_write'] || cot::$usr['isadmin']) && !empty($category['id'])) {
         $addNewUrl = cot_url('advboard', array('a' => 'edit', 'c' => $category['code']));
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.main') as $pl) {
         include $pl;
     }
     /* ===== */
     // 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;
     }
     $kk = 0;
     $allsub = cot_structure_children('advboard', $c, false, false, true, false);
     $subcat = array_slice($allsub, $dc, cot::$cfg['advboard']['maxlistsperpage']);
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.rowcat.first') as $pl) {
         include $pl;
     }
     /* ===== */
     /* === Hook - Part1 : Set === */
     $extp = cot_getextplugins('advboard.list.rowcat.loop');
     /* ===== */
     $subCategories = array();
     foreach ($subcat as $x) {
         $kk++;
         $cat_childs = cot_structure_children('advboard', $x);
         $sub_count = 0;
         foreach ($cat_childs as $cat_child) {
             $sub_count += (int) $structure['advboard'][$cat_child]['count'];
         }
         $sub_url_path = $urlParams;
         $sub_url_path['c'] = $x;
         $subCategories[$x] = $structure['advboard'][$x];
         $subCategories[$x]['config'] = cot::$cfg['advboard']['cat_' . $x];
         $subCategories[$x]['code'] = $x;
         $subCategories[$x]['count'] = $sub_count;
         $subCategories[$x]['num'] = $kk;
         // Extra fields for structure
         foreach ($cot_extrafields[$db_structure] as $exfld) {
             $uname = $exfld['field_name'];
             $val = $structure['advboard'][$x][$exfld['field_name']];
             $subCategories[$x][$uname . '_title'] = isset(cot::$L['structure_' . $exfld['field_name'] . '_title']) ? cot::$L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
             $subCategories[$x][$uname] = cot_build_extrafields_data('structure', $exfld, $val);
             $subCategories[$x][$uname . '_value'] = $val;
         }
         /* === Hook - Part2 : Include === */
         foreach ($extp as $pl) {
             include $pl;
         }
         /* ===== */
     }
     $crumbs = array();
     if (!empty($category['id'])) {
         $crumbs = cot_structure_buildpath('advboard', $c);
         if (cot::$cfg['advboard']['firstCrumb']) {
             array_unshift($crumbs, array(cot_url('advboard'), cot::$L['advboard_ads']));
         }
     }
     // Фильтры для модератора
     if (cot::$usr['isadmin']) {
         if ($mf['period'] != '0') {
             $urlParams['mf[period]'] = $mf['period'];
         }
         if ($mf['state'] != -2) {
             $urlParams['mf[state]'] = $mf['state'];
         }
     }
     $pagenavCategory = cot_pagenav('advboard', $urlParams + array('d' => $durl), $dc, count($allsub), cot::$cfg['advboard']['maxlistsperpage'], 'dc');
     if (empty($pagenavCategory['current'])) {
         $pagenavCategory['current'] = 1;
     }
     $pagenav = cot_pagenav('advboard', $urlParams + array('dc' => $dcurl), $d, $totallines, $maxrowsperpage);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $breadcrumbs = '';
     if (!empty($crumbs)) {
         $breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     }
     $pageUrlParams = $urlParams;
     if ($durl > 1) {
         $pageUrlParams['d'] = $durl;
     }
     $view = new View();
     $view->breadcrumbs = $breadcrumbs;
     $view->page_title = htmlspecialchars($category['title']);
     $view->category = $category;
     $view->subCategories = $subCategories;
     $view->condition = $condition;
     $view->order = $order;
     $view->advertisement = $advertisement;
     $view->totalitems = $totallines;
     $view->allowComments = $allowComments;
     $view->pagenav = $pagenav;
     $view->pagenavCategory = $pagenavCategory;
     $view->moderatorFilters = $moderatorFilters;
     $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->pageUrlParams = $pageUrlParams;
     /* === Hook === */
     foreach (cot_getextplugins('advboard.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
Ejemplo n.º 19
0
/* ====================
[BEGIN_COT_EXT]
Hooks=standalone
[END_COT_EXT]
==================== */
/**
 * Recent pages, topics in forums, users, comments
 *
 * @package RecentItems
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die("Wrong URL.");
$days = cot_import('days', 'G', 'INT');
list($pg, $d, $durl) = cot_import_pagenav('d', $cfg['plugin']['recentitems']['itemsperpage']);
$mode = cot_import('mode', 'G', 'TXT');
if ($days == 0) {
    if ($usr['id'] > 0) {
        $timeback = $usr['lastvisit'];
    } else {
        $days = 1;
    }
}
if ($days > 0) {
    $timeminus = $days * 86400;
    $timeback = $sys['now'] - $timeminus;
}
require_once cot_incfile('recentitems', 'plug');
$totalrecent[] = 0;
if ($cfg['plugin']['recentitems']['newpages'] && cot_module_active('page') && (empty($mode) || $mode == 'pages')) {
/**
 * marketorders plugin
 *
 * @package marketorders
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
$id = cot_import('id', 'G', 'INT');
$status = cot_import('status', 'G', 'ALP');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('plug', 'marketorders');
cot_block($usr['id'] > 0 && $usr['auth_read']);
if ($cfg['plugin']['marketorders']['ordersperpage'] > 0) {
    list($pn, $d, $d_url) = cot_import_pagenav('d', $cfg['plugin']['marketorders']['ordersperpage']);
}
/* === Hook === */
$extp = cot_getextplugins('marketorders.purchases.first');
foreach ($extp as $pl) {
    include $pl;
}
/* ===== */
$out['subtitle'] = $L['market_purchases_title'];
$out['head'] .= $R['code_noindex'];
$mskin = cot_tplfile(array('marketorders', 'purchases'), 'plug');
/* === Hook === */
foreach (cot_getextplugins('marketorders.purchases.main') as $pl) {
    include $pl;
}
/* ===== */
Ejemplo n.º 21
0
/**
 * Forums posts display.
 *
 * @package Forums
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
$s = cot_import('s', 'G', 'TXT');
// section cat
$q = cot_import('q', 'G', 'INT');
// topic id
$p = cot_import('p', 'G', 'INT');
// post id
list($pg, $d, $durl) = cot_import_pagenav('d', $cfg['forums']['maxpostsperpage']);
/* === Hook === */
foreach (cot_getextplugins('forums.editpost.first') as $pl) {
    include $pl;
}
/* ===== */
cot_blockguests();
cot_check_xg();
isset($structure['forums'][$s]) || cot_die();
$sql_forums = $db->query("SELECT * FROM {$db_forum_posts} WHERE fp_id = ? and fp_topicid = ? and fp_cat = ?", array($p, $q, $s));
if ($rowpost = $sql_forums->fetch()) {
    list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('forums', $s);
    /* === Hook === */
    foreach (cot_getextplugins('forums.editpost.rights') as $pl) {
        include $pl;
    }
Ejemplo n.º 22
0
require_once cot_langfile('news', 'plug');
list($pg, $d, $durl) = cot_import_pagenav('d', $cfg['plugin']['news']['maxpages']);
$c = cot_import('c', 'G', 'TXT');
$c = !isset($structure['page'][$c]) ? '' : $c;
$categories = explode(',', $cfg['plugin']['news']['category']);
$jj = 0;
$cats = array();
foreach ($categories as $v) {
    $v = explode('|', trim($v));
    if (isset($structure['page'][$v[0]])) {
        $c = empty($c) ? $v[0] : $c;
        $indexcat = $jj == 0 ? $v[0] : $indexcat;
        $v[2] = (int) $v[2] > 0 ? $v[2] : (int) $cfg['page']['cat_' . $v[0]]['truncatetext'];
        $v[1] = (int) $v[1] > 0 ? $v[1] : (int) $cfg['plugin']['news']['maxpages'];
        $_GET[$v[0] . 'd'] = empty($c) || $jj == 0 || $cfg['plugin']['news']['syncpagination'] ? $_GET['d'] : $_GET[$v[0] . 'd'];
        list($v[3]['pg'], $v[3]['d'], $v[3]['durl']) = cot_import_pagenav($v[0] . 'd', $v[1]);
        $cats[$v[0]] = $v;
        $jj++;
    }
}
if (count($cats) > 0) {
    /* === Hook - Part1 : Set === FIRST === */
    $news_first_extp = cot_getextplugins('news.first');
    /* === Hook - Part1 : Set === LOOP === */
    $news_extp = cot_getextplugins('news.loop');
    /* === Hook - Part1 : Set === TAGS === */
    $news_tags_extp = cot_getextplugins('news.tags');
    /* ===== */
    $catn = 0;
    foreach ($cats as $k => $v) {
        $cat = $catn == 0 ? $c : $v[0];
Ejemplo n.º 23
0
<?php

/**
 * PM
 *
 * @package PM
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('pm', 'a');
cot_block($usr['auth_read']);
$f = cot_import('f', 'G', 'ALP');
// Category inbox, sentbox, archive
list($pg, $d, $durl) = cot_import_pagenav('d', $cfg['pm']['maxpmperpage']);
// pagination
$a = cot_import('a', 'G', 'TXT');
// Action
$filter = cot_import('filter', 'G', 'TXT');
// filter
/*
 * PM States
 * 0 - new message
 * 1 - inbox message
 * 2 - starred message
 * 3 - deleted message
*/
/* === Hook === */
foreach (cot_getextplugins('pm.list.first') as $pl) {
    include $pl;
}
Ejemplo n.º 24
0
 public function indexAction()
 {
     global $structure;
     $uid = cot_import('uid', 'G', 'INT');
     if (empty($uid)) {
         $uid = cot::$usr['id'];
     }
     // Незарегов, если они не смотрят объявления другого пользователя перенаправляем
     if (!$uid) {
         cot_redirect(cot_url('advboard', '', '', true));
     }
     // Проверить существование пользователя
     $user = cot_user_data($uid);
     if (!$user) {
         cot_die_message(404, TRUE);
     }
     $maxrowsperpage = cot::$cfg['advboard']['cat___default']['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for pages list
     $condition = array(array('user', $uid));
     if (!cot::$usr['isadmin'] && $uid != cot::$usr['id']) {
         $condition[] = array('state', advboard_model_Advert::PUBLISHED);
         $condition[] = array('begin', cot::$sys['now'], '<=');
         $condition[] = array('SQL', "expire = 0 OR expire > " . cot::$sys['now']);
     }
     $order = array(array('state', 'ASC'), array('sort', 'DESC'));
     cot::$out['canonical_uri'] = cot_url('advboard', array('m' => 'user', 'uid' => $uid));
     $urlParams = array('m' => 'user');
     if ($uid != cot::$usr['id']) {
         $urlParams['uid'] = $uid;
     }
     $title = '';
     $crumbs = array();
     if ($uid != cot::$usr['id']) {
         cot::$out['subtitle'] = $title = cot::$L['advboard_user_ads'] . ': ' . cot_user_full_name($user);
         $crumbs[] = array(cot_url("users"), cot::$L['Users']);
         $crumbs[] = array(cot_url("users", "m=details&id=" . $user["user_id"] . "&u=" . $user["user_name"]), cot_user_full_name($user));
         $crumbs[] = cot::$L['advboard_user_ads'];
         //            $advUrlParams['uid']  = $user['user_id'];
         $urlParams['uid'] = $user['user_id'];
     } else {
         cot::$out['subtitle'] = $title = cot::$L['advboard_my_ads'];
         $crumbs[] = array(cot_url('users', array('m' => 'details')), cot::$L['advboard_my_page']);
         $crumbs[] = cot::$L['advboard_my_ads'];
     }
     /* === Hook === */
     foreach (cot_getextplugins('advboard.user.list.query') as $pl) {
         include $pl;
     }
     /* ===== */
     $totallines = advboard_model_Advert::count($condition);
     $advertisement = advboard_model_Advert::find($condition, $maxrowsperpage, $d, $order);
     $addNewUrl = '';
     if ((cot::$usr['auth_write'] || cot::$usr['isadmin']) && !empty($structure['advboard'])) {
         // Ищем категорию куда пользователь может подать оьбъявление
         foreach ($structure['advboard'] as $catCode => $catRow) {
             $auth_write = cot_auth('advboard', $catCode, 'W');
             if ($auth_write) {
                 $addNewUrl = cot_url('advboard', array('a' => 'edit', 'c' => $catCode));
                 break;
             }
         }
     }
     $pagenav = cot_pagenav('advboard', $urlParams, $d, $totallines, $maxrowsperpage);
     if (empty($pagenav['current'])) {
         $pagenav['current'] = 1;
     }
     $breadcrumbs = '';
     if (!empty($crumbs)) {
         $breadcrumbs = cot_breadcrumbs($crumbs, cot::$cfg['homebreadcrumb'], true);
     }
     $template = array('advboard', 'list', 'user');
     $pageUrlParams = $urlParams;
     if ($durl > 1) {
         $pageUrlParams['d'] = $durl;
     }
     $view = new View();
     $view->breadcrumbs = $breadcrumbs;
     $view->page_title = htmlspecialchars($title);
     $view->advertisement = $advertisement;
     $view->allowComments = true;
     $view->totalitems = $totallines;
     $view->pagenav = $pagenav;
     $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->pageUrlParams = $pageUrlParams;
     /* === Hook === */
     foreach (cot_getextplugins('advboard.user.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }
Ejemplo n.º 25
0
 * market module
 *
 * @package market
 * @version 2.5.2
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('market', 'any', 'RWA');
cot_block($usr['auth_read']);
$sort = cot_import('sort', 'G', 'ALP');
$c = cot_import('c', 'G', 'ALP');
$sq = cot_import('sq', 'G', 'TXT');
$sq = $db->prep($sq);
$maxrowsperpage = $cfg['market']['cat_' . $c]['maxrowsperpage'] ? $cfg['market']['cat_' . $c]['maxrowsperpage'] : $cfg['market']['cat___default']['maxrowsperpage'];
list($pn, $d, $d_url) = cot_import_pagenav('d', $maxrowsperpage);
/* === Hook === */
foreach (cot_getextplugins('market.list.first') as $pl) {
    include $pl;
}
/* ===== */
if (!empty($c)) {
    $out['subtitle'] = !empty($cfg['market']['cat_' . $c]['metatitle']) ? $cfg['market']['cat_' . $c]['metatitle'] : $cfg['market']['cat___default']['metatitle'];
    $out['subtitle'] = !empty($out['subtitle']) ? $out['subtitle'] : $L['market'];
    $out['desc'] = !empty($cfg['market']['cat_' . $c]['metadesc']) ? $cfg['market']['cat_' . $c]['metadesc'] : $cfg['market']['cat___default']['metadesc'];
    $out['keywords'] = !empty($cfg['market']['cat_' . $c]['keywords']) ? $cfg['market']['cat_' . $c]['keywords'] : $cfg['market']['cat___default']['keywords'];
} else {
    $out['subtitle'] = !empty($cfg['market']['cat___default']['metatitle']) ? $cfg['market']['cat___default']['metatitle'] : $L['market'];
    $out['desc'] = $cfg['market']['cat___default']['metadesc'];
    $out['keywords'] = $cfg['market']['cat___default']['keywords'];
}
 */
/**
 * projects module
 *
 * @package projects
 * @version 2.5.2
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru, littledev.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
require_once cot_incfile('projects', 'module');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('projects', 'any', 'RWA');
$tab = cot_import('tab', 'G', 'ALP');
$category = $tab == 'projects' ? cot_import('cat', 'G', 'TXT') : '';
list($pg, $d, $durl) = cot_import_pagenav('dprj', $cfg['projects']['cat___default']['maxrowsperpage']);
//маркет вкладка
$t1 = new XTemplate(cot_tplfile(array('projects', 'userdetails'), 'module'));
$t1->assign(array("ADDPRJ_URL" => cot_url('projects', 'm=add'), "ADDPRJ_SHOWBUTTON" => $usr['auth_write'] ? true : false));
$where = array();
$order = array();
if ($usr['id'] == 0 || $usr['id'] != $urr['user_id'] && !$usr['isadmin']) {
    $where['state'] = "item_state=0";
}
if ($category) {
    $where['cat'] = 'item_cat=' . $db->quote($category);
}
$where['owner'] = "item_userid=" . $urr['user_id'];
$order['date'] = "item_date DESC";
$wherecount = $where;
if ($wherecount['cat']) {
Ejemplo n.º 27
0
/* ====================
[BEGIN_COT_EXT]
Hooks=standalone
[END_COT_EXT]
==================== */
/**
 * ukarma plugin
 *
 * @package ukarma
 * @version 1.0.0
 * @author CMSWorks Team
 * @copyright Copyright (c) CMSWorks.ru
 * @license BSD
 */
defined('COT_CODE') or die('Wrong URL');
list($pn, $d, $d_url) = cot_import_pagenav('d', $cfg['maxrowsperpage']);
$out['subtitle'] = $L['ukarma_title'];
$t = new XTemplate(cot_tplfile(array('ukarma', 'statistics'), 'plug'));
$where = array();
$order = array();
$where['userid'] = "ukarma_userid=" . $usr['id'];
$order['date'] = "ukarma_date DESC";
/* === Hook === */
foreach (cot_getextplugins('ukarma.statistics.query') as $pl) {
    include $pl;
}
/* ===== */
$where = $where ? 'WHERE ' . implode(' AND ', $where) : '';
$order = $order ? 'ORDER BY ' . implode(', ', $order) : '';
$totalitems = $db->query("SELECT COUNT(*) FROM {$db_ukarma}  \n\t" . $where . "")->fetchColumn();
$sqllist_rowset = $db->query("SELECT * FROM {$db_ukarma} AS k\n\tLEFT JOIN {$db_users} AS u ON u.user_id=k.ukarma_ownerid\n\t" . $where . " \n\t" . $order . "\n\tLIMIT {$d}, " . $cfg['maxrowsperpage'])->fetchAll();
Ejemplo n.º 28
0
 /**
  * Панель управления
  * Список баннеров
  */
 public function indexAction()
 {
     global $admintitle, $adminpath;
     $admintitle = cot::$L['brs_banners'];
     $adminpath[] = array(cot_url('admin', array('m' => 'brs')), cot::$L['brs_banners']);
     $sortFields = array('id' => 'ID', 'title' => cot::$L['Title'], 'category' => cot::$L['Category'], 'published' => cot::$L['brs_published'], 'client' => cot::$L['brs_client'], 'impressions' => cot::$L['brs_impressions'], 'clicks' => cot::$L['brs_clicks'], 'publish_up' => cot::$L['brs_publish_up'], 'publish_down' => cot::$L['brs_publish_down']);
     $sort = cot_import('s', 'G', 'ALP');
     // order field name
     $way = cot_import('w', 'G', 'ALP', 4);
     // order way (asc, desc)
     $f = cot_import('f', 'G', 'ARR');
     // filters
     $maxrowsperpage = cot::$cfg['maxrowsperpage'];
     if ($maxrowsperpage < 1) {
         $maxrowsperpage = 1;
     }
     list($pg, $d, $durl) = cot_import_pagenav('d', $maxrowsperpage);
     //page number for banners list
     $sort = empty($sort) ? 'title' : $sort;
     $way = empty($way) || !in_array($way, array('asc', 'desc')) ? 'asc' : $way;
     $urlParams = array('m' => 'brs');
     if ($sort != 'title') {
         $urlParams['s'] = $sort;
     }
     if ($way != 'asc') {
         $urlParams['w'] = $way;
     }
     $condition = array();
     if (!empty($f)) {
         foreach ($f as $key => $val) {
             $val = trim(cot_import($val, 'D', 'TXT'));
             if (empty($val) && $val !== '0') {
                 continue;
             }
             if (in_array($key, array('title'))) {
                 $condition[] = array($key, "*{$val}*");
                 $urlParams["f[{$key}]"] = $val;
             } else {
                 $condition[] = array($key, $val);
                 $urlParams["f[{$key}]"] = $val;
             }
         }
     } else {
         $f = array();
     }
     $totallines = brs_model_Banner::count($condition);
     $items = brs_model_Banner::find($condition, $maxrowsperpage, $d, $sort . ' ' . $way);
     $pagenav = cot_pagenav('admin', $urlParams, $d, $totallines, $maxrowsperpage, 'd', '', true);
     $template = array('brs', 'admin', 'list');
     $clients = brs_model_Client::keyValPairs();
     if (!$clients) {
         $clients = array();
     }
     $filterForm = array('hidden' => '', 'title' => array('element' => cot_inputbox('text', 'f[title]', $f['title']), 'label' => brs_model_Banner::fieldLabel('title')), 'category' => array('element' => brs_selectbox_structure('brs', $f['category'], 'f[category]', '', false, false, true), 'label' => brs_model_Banner::fieldLabel('category')), 'client' => array('element' => cot_selectbox($f['client'], 'f[client]', array_keys($clients), array_values($clients)), 'label' => brs_model_Banner::fieldLabel('client')), 'published' => array('element' => cot_selectbox($f['published'], 'f[published]', array(0, 1), array(cot::$L['No'], cot::$L['Yes'])), 'label' => brs_model_Banner::fieldLabel('published')), 'sort' => array('element' => cot_selectbox($sort, 's', array_keys($sortFields), array_values($sortFields), false), 'label' => cot::$L['adm_sort']), 'way' => array('element' => cot_selectbox($way, 'w', array('asc', 'desc'), array(cot::$L['Ascending'], cot::$L['Descending']), false)));
     if (isset(cot::$cfg['plugin']['urleditor']) && cot::$cfg['plugin']['urleditor']['preset'] != 'handy') {
         $filterForm['hidden'] .= cot_inputbox('hidden', 'm', 'brs');
     }
     $view = new View();
     $view->page_title = $admintitle;
     $view->fistNumber = $d + 1;
     $view->items = $items;
     $view->clients = $clients;
     $view->totalitems = $totallines;
     $view->filterForm = $filterForm;
     $view->pagenav = $pagenav;
     //        $view->addNewUrl = $addNewUrl;
     $view->urlParams = $urlParams;
     $view->filter = $f;
     /* === Hook === */
     foreach (cot_getextplugins('brs.admin.list.view') as $pl) {
         include $pl;
     }
     /* ===== */
     return $view->render($template);
 }