本文整理汇总了PHP中cot_auth函数的典型用法代码示例。如果您正苦于以下问题:PHP cot_auth函数的具体用法?PHP cot_auth怎么用?PHP cot_auth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cot_auth函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cot_advboard_auth
/**
* Returns permissions for a page category.
* @param string $cat Category code
* @return array Permissions array with keys: 'auth_read', 'auth_write', 'isadmin', 'auth_download'
* @todo Реализуй меня
*/
function cot_advboard_auth($cat = null)
{
if (empty($cat)) {
$cat = 'any';
}
$auth = array();
list($auth['auth_read'], $auth['auth_write'], $auth['isadmin'], $auth['auth_download']) = cot_auth('advboard', $cat, 'RWA1');
return $auth;
}
示例2: indexAction
public function indexAction()
{
global $structure;
if (!cot_module_active('rss')) {
cot_die_message(404, TRUE);
}
$c = cot_import('c', 'G', 'TXT');
if (!empty($c)) {
if (!isset($structure['advboard'][$c])) {
cot_die_message(404, TRUE);
}
list(cot::$usr['auth_read'], cot::$usr['auth_write'], cot::$usr['isadmin']) = cot_auth('advboard', $c);
cot_block(cot::$usr['auth_read']);
}
$rss_title = cot::$L['advboard_rss_feed'] . cot::$cfg['maintitle'];
$rss_link = cot::$cfg['mainurl'];
$rss_description = cot::$cfg['subtitle'];
$domain = cot::$sys['domain'];
$condition = array(array('state', advboard_model_Advert::PUBLISHED), array('begin', cot::$sys['now'], '<='), array('SQL', "expire = 0 OR expire > " . cot::$sys['now']));
if (!empty($c)) {
$rss_title = cot::$L['advboard_rss_feed'] . $structure['advboard'][$c]['title'] . ' - ' . cot::$cfg['maintitle'];
$condition[] = array('category', $c);
}
$advertisement = advboard_model_Advert::find($condition, cot::$cfg['rss']['rss_maxitems'], 0, array(array('sort', 'desc')));
$t = new XTemplate(cot_tplfile('rss'));
$now = cot::$sys['now'];
$now += cot::$usr['timezone'] * 3600;
$t->assign(array('RSS_ENCODING' => cot::$cfg['rss']['rss_charset'], 'RSS_TITLE' => htmlspecialchars($rss_title), 'RSS_LINK' => $rss_link, 'RSS_LANG' => cot::$cfg['defaultlang'], 'RSS_DESCRIPTION' => htmlspecialchars($rss_description), 'RSS_DATE' => $this->fixPubDate(date("r", $now))));
if (!empty($advertisement)) {
foreach ($advertisement as $advert) {
$url = $advert->url;
if (!cot_url_check($url)) {
$url = COT_ABSOLUTE_URL . $url;
}
$date = '';
if (!empty($advert->created)) {
$date = strtotime($advert->created);
$date += cot::$usr['timezone'] * 3600;
$date = date('r', $date);
$date = $this->fixPubDate($date);
}
$text = $advert->text;
$textlength = intval(cot::$cfg['rss']['rss_pagemaxsymbols']);
if ($textlength > 0 && mb_strlen($text) > $textlength) {
$text = cot_string_truncate($text, $textlength, true, false, cot::$R['advboard_cuttext']);
}
$t->assign(array('RSS_ROW_TITLE' => htmlspecialchars($advert->title), 'RSS_ROW_DESCRIPTION' => $this->convertRelativeUrls($text), 'RSS_ROW_DATE' => $date, 'RSS_ROW_LINK' => $url));
$t->parse('MAIN.ITEM_ROW');
}
}
$t->parse('MAIN');
// ob_clean();
header('Content-type: text/xml; charset=UTF-8');
echo $t->text('MAIN');
exit;
}
示例3: cot_build_pfs
/**
* Generates a link to PFS
*
* @global array $L
* @global array $cfg
* @global array $usr
* @global array $cot_groups
* @param int $id User ID
* @param string $c1 Form name
* @param string $c2 Input name
* @param string $title Link title
* @param string $parser Custom parser (otional)
* @return string
*/
function cot_build_pfs($id, $c1, $c2, $title, $parser = '')
{
global $L, $cfg, $usr, $cot_groups;
if ($id == 0) {
$res = "<a href=\"javascript:pfs('0','" . $c1 . "','" . $c2 . "','" . $parser . "')\">" . $title . "</a>";
} elseif (cot_auth('pfs', 'a', 'R')) {
$res = "<a href=\"javascript:pfs('" . $id . "','" . $c1 . "','" . $c2 . "','" . $parser . "')\">" . $title . "</a>";
} else {
$res = '';
}
return $res;
}
示例4: cot_generate_sbrtags
function cot_generate_sbrtags($item_data, $tag_prefix = '', $admin_rights = null, $pagepath_home = false)
{
global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_sbr, $db_sbr_stages, $sys;
static $extp_first = null, $extp_main = null;
if (is_null($extp_first)) {
$extp_first = cot_getextplugins('sbrtags.first');
$extp_main = cot_getextplugins('sbrtags.main');
}
/* === Hook === */
foreach ($extp_first as $pl) {
include $pl;
}
/* ===== */
if (!is_array($item_data)) {
$sql = $db->query("SELECT * FROM {$db_sbr} WHERE sbr_id = '" . (int) $item_data . "' LIMIT 1");
$item_data = $sql->fetch();
}
if ($item_data['sbr_id'] > 0 && !empty($item_data['sbr_title'])) {
if (is_null($admin_rights)) {
$admin_rights = cot_auth('plug', 'sbr', 'A');
}
$patharray[] = array(cot_url('sbr'), $L['sbr']);
$patharray[] = array(cot_url('sbr', 'id=' . $item_data['sbr_id']), $item_data['sbr_title']);
$itempath = cot_breadcrumbs($patharray, $pagepath_home, true);
$temp_array = array('ID' => $item_data['sbr_id'], 'STATUS' => $item_data['sbr_status'], 'LOCALSTATUS' => $L['sbr_status_' . $item_data['sbr_status']], 'LABELSTATUS' => $R['sbr_labels'][$item_data['sbr_status']], 'URL' => cot_url('sbr', 'id=' . $item_data['sbr_id']), 'TITLE' => $itempath, 'SHORTTITLE' => $item_data['sbr_title'], 'CREATEDATE' => date('d.m.Y H:i', $item_data['sbr_create']), 'CREATEDATE_STAMP' => $item_data['sbr_create'], 'BEGINDATE' => date('d.m.Y H:i', $item_data['sbr_begin']), 'BEGINDATE_STAMP' => $item_data['sbr_begin'], 'DONEDATE' => date('d.m.Y H:i', $item_data['sbr_done']), 'DONEDATE_STAMP' => $item_data['sbr_done'], 'COST' => $item_data['sbr_cost'], 'TAX' => $item_data['sbr_tax'], 'TOTAL' => $item_data['sbr_cost'] + $item_data['sbr_tax'], 'USER_IS_ADMIN' => $admin_rights || $usr['id'] == $item_data['item_userid']);
if ($admin_rights || $usr['id'] == $item_data['sbr_employer']) {
$temp_array['ADMIN_EDIT'] = cot_rc_link(cot_url('sbr', 'm=edit&id=' . $item_data['sbr_id']), $L['Edit']);
$temp_array['ADMIN_EDIT_URL'] = cot_url('sbr', 'm=edit&id=' . $item_data['sbr_id']);
}
// Extrafields
if (isset($cot_extrafields[$db_sbr])) {
foreach ($cot_extrafields[$db_sbr] as $exfld) {
$tag = mb_strtoupper($exfld['field_name']);
$temp_array[$tag . '_TITLE'] = isset($L['sbr_' . $exfld['field_name'] . '_title']) ? $L['sbr_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
$temp_array[$tag] = cot_build_extrafields_data('sbr', $exfld, $item_data['item_' . $exfld['field_name']]);
}
}
/* === Hook === */
foreach ($extp_main as $pl) {
include $pl;
}
/* ===== */
} else {
$temp_array = array('TITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted'], 'SHORTTITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted']);
}
$return_array = array();
foreach ($temp_array as $key => $val) {
$return_array[$tag_prefix . $key] = $val;
}
return $return_array;
}
示例5: karma_gadget
function karma_gadget($user_id, $user_karma, $location, $location_id, $module = false)
{
global $usr, $cfg, $karma_cache, $color;
$color = explode(",", $cfg['plugin']['karma']['karma_color']);
if (!$karma_cache[$user_id]) {
$negative = !$cfg['plugin']['karma']['neg_rec'] && $usr['profile']['user_karma'] < 0 ? false : true;
$k_add = cot_auth('plug', 'karma', 'W') && $usr['id'] > 0 && $location != 'self' ? true : "";
$karmat = new XTemplate(cot_tplfile(array('karma', 'gadget'), true));
$module = urlencode($module);
$karmat->assign(array("PAGE_KARMA_D" => number_format($user_karma, '1', '.', ' '), "PAGE_KARMA_ADD" => $user_id != $usr['id'] && $k_add ? cot_url('plug', 'r=karma&act=change&lct=' . $location . '&value=add&fp=' . $location_id . '&mod=' . $module) : false, "PAGE_KARMA_DEL" => $user_id != $usr['id'] && $negative && $k_add ? cot_url('plug', 'r=karma&act=change&lct=' . $location . '&value=del&fp=' . $location_id . '&mod=' . $module) : false, "PAGE_KARMA_URL" => $k_add || $location == 'self' ? cot_url('plug', 'r=karma&act=show&fp=' . $user_id) : false, "PAGE_KARMA_MINI" => $cfg['plugin']['karma']['karma_com'] ? '' : 'karma_mini'));
$karmat->parse('MAIN');
$karma_cache[$user_id] = $karmat->text('MAIN');
}
return $karma_cache[$user_id];
}
示例6: cot_ukarma_checkenablescore
function cot_ukarma_checkenablescore($userid, $area = '', $code = '')
{
global $db, $cfg, $sys, $usr, $db_ukarma;
if (cot_auth('plug', 'ukarma', 'W')) {
if ($usr['id'] == $userid) {
return false;
}
if (!cot_auth('plug', 'ukarma', 'A') && $cfg['plugin']['ukarma']['karma_rate'] > 0 && cot_ukarma($usr['id'], '', '', true) < $cfg['plugin']['ukarma']['karma_rate']) {
return false;
}
$where['ukarma_ownerid'] = "ukarma_ownerid=" . $usr['id'];
$where['ukarma_userid'] = "ukarma_userid=" . $userid;
if (!empty($area)) {
$where['ukarma_area'] = "ukarma_area='" . $area . "'";
}
if (!empty($code)) {
$where['ukarma_code'] = "ukarma_code='" . $code . "'";
}
$where = $where ? 'WHERE ' . implode(' AND ', $where) : '';
$score_isset = (bool) $db->query("SELECT ukarma_id FROM {$db_ukarma} {$where}")->fetch();
$score_enabled = !$score_isset ? true : false;
if ($cfg['plugin']['ukarma']['karma_daylimit'] > 0 && !cot_auth('plug', 'ukarma', 'A')) {
$lastdate = $sys['now'] - 24 * 60 * 60;
$score_count = $db->query("SELECT COUNT(*) FROM {$db_ukarma} WHERE ukarma_ownerid=" . $usr['id'] . " AND ukarma_date >" . $lastdate)->fetchColumn();
if ($score_count >= $cfg['plugin']['ukarma']['karma_daylimit']) {
$score_enabled = false;
}
}
if ($cfg['plugin']['ukarma']['karma_personaldaylimit'] > 0 && !cot_auth('plug', 'ukarma', 'A')) {
$lastdate = $sys['now'] - 24 * 60 * 60;
$score_count = $db->query("SELECT COUNT(*) FROM {$db_ukarma} WHERE ukarma_ownerid=" . $usr['id'] . " AND ukarma_userid=" . $userid . " AND ukarma_date >" . $lastdate)->fetchColumn();
if ($score_count >= $cfg['plugin']['ukarma']['karma_personaldaylimit']) {
$score_enabled = false;
}
}
return $score_enabled;
}
}
示例7: defined
<?php
/* ====================
[BEGIN_COT_EXT]
Hooks=search.page.catlist
[END_COT_EXT]
==================== */
/**
* Search in system cat. Adds `system` to form field
*
* @package search_system
* @author Andrey Matsovkin
* @copyright Copyright (c) 2011-2016
* @license Distributed under BSD license.
*/
defined('COT_CODE') or die('Wrong URL.');
$cat = 'system';
if (cot_auth('page', $cat, 'R')) {
$x = $structure['page'][$cat];
$pages_cat_list[$cat] = $x['tpath'];
$pag_catauth[] = $db->prep($cat);
}
示例8: defined
<?php
/**
* [BEGIN_COT_EXT]
* Hooks=market.add.tags
* [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']['market'] && cot_auth('plug', 'tags', 'W')) {
require_once cot_incfile('tags', 'plug');
$t->assign(array('PRDADD_TOP_TAGS' => $L['Tags'], 'PRDADD_TOP_TAGS_HINT' => $L['tags_comma_separated'], 'PRDADD_FORM_TAGS' => cot_rc('tags_input_editpage', array('tags' => ''))));
if (cot_get_caller() == 'i18n.market') {
$t->assign(array('I18N_PRD_TAGS' => implode(', ', cot_tag_list($id)), 'I18N_IPRD_TAGS' => cot_rc('tags_input_editpage', array('tags' => ''))));
}
$t->parse('MAIN.TAGS');
}
示例9: defined
* @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');
$id = cot_import('id', 'G', 'INT');
$r = cot_import('r', 'G', 'ALP');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('projects', 'any', 'RWA');
cot_block($usr['auth_write']);
$item = $db->query("SELECT p.*, u.* FROM {$db_projects} AS p LEFT JOIN {$db_users} AS u ON u.user_id=p.item_userid WHERE item_id=" . (int) $id)->fetch();
if ($item['item_id'] != (int) $id) {
cot_die_message(404, TRUE);
}
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('projects', $item['item_cat']);
cot_block($usr['isadmin'] || $usr['auth_write'] && $usr['id'] == $item['item_userid']);
/* === Hook === */
foreach (cot_getextplugins('projects.preview.first') as $pl) {
include $pl;
}
/* ===== */
if ($a == 'save') {
cot_check_xg();
/* === Hook === */
foreach (cot_getextplugins('projects.preview.save.first') as $pl) {
include $pl;
}
/* ===== */
$prj = array();
if ($cfg['projects']['prevalidate'] && !$usr['isadmin']) {
示例10: cot_import
$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;
}
/* ===== */
if (!$usr['isadmin'] && ($rowpost['fp_posterid'] != $usr['id'] || $cfg['forums']['edittimeout'] != '0' && $sys['now'] - $rowpost['fp_creation'] > $cfg['forums']['edittimeout'] * 3600)) {
cot_log('Attempt to edit a post without rights', 'sec');
cot_die();
}
cot_block($usr['auth_read']);
} else {
cot_die();
}
$is_first_post = $p == $db->query("SELECT fp_id FROM {$db_forum_posts} WHERE fp_topicid = ? ORDER BY fp_id ASC LIMIT 1", array($q))->fetchColumn();
$sql_forums = $db->query("SELECT ft_state, ft_mode, ft_title, ft_desc FROM {$db_forum_topics} WHERE ft_id = {$q} LIMIT 1");
示例11: foreach
$rs['pagsub'][] = 'all';
}
/* === Hook === */
foreach (cot_getextplugins('search.page.catlist') as $pl) {
include $pl;
}
/* ===== */
$t->assign(array('PLUGIN_PAGE_SEC_LIST' => cot_selectbox($rs['pagsub'], 'rs[pagsub][]', array_keys($pages_cat_list), array_values($pages_cat_list), false, 'multiple="multiple" style="width:50%"'), 'PLUGIN_PAGE_RES_SORT' => cot_selectbox($rs['pagsort'], 'rs[pagsort]', array('date', 'title', 'count', 'cat'), array($L['plu_pag_res_sort1'], $L['plu_pag_res_sort2'], $L['plu_pag_res_sort3'], $L['plu_pag_res_sort4']), false), 'PLUGIN_PAGE_RES_SORT_WAY' => cot_radiobox($rs['pagsort2'], 'rs[pagsort2]', array('DESC', 'ASC'), array($L['plu_sort_desc'], $L['plu_sort_asc'])), 'PLUGIN_PAGE_SEARCH_NAMES' => cot_checkbox($rs['pagtitle'] == 1 || count($rs['pagsub']) == 0, 'rs[pagtitle]', $L['plu_pag_search_names']), 'PLUGIN_PAGE_SEARCH_DESC' => cot_checkbox($rs['pagdesc'] == 1 || count($rs['pagsub']) == 0, 'rs[pagdesc]', $L['plu_pag_search_desc']), 'PLUGIN_PAGE_SEARCH_TEXT' => cot_checkbox($rs['pagtext'] == 1 || count($rs['pagsub']) == 0, 'rs[pagtext]', $L['plu_pag_search_text']), 'PLUGIN_PAGE_SEARCH_SUBCAT' => cot_checkbox($rs['pagsubcat'], 'rs[pagsubcat]', $L['plu_pag_set_subsec']), 'PLUGIN_PAGE_SEARCH_FILE' => cot_checkbox($rs['pagfile'] == 1, 'rs[pagfile]', $L['plu_pag_search_file'])));
if ($tab == 'pag' || empty($tab) && $cfg['plugin']['search']['extrafilters']) {
$t->parse('MAIN.PAGES_OPTIONS');
}
}
if (($tab == 'frm' || empty($tab)) && cot_module_active('forums') && $cfg['plugin']['search']['forumsearch']) {
$forum_cat_list['all'] = $L['plu_allsections'];
foreach ($structure['forums'] as $key => $val) {
if (cot_auth('forums', $key, 'R')) {
$forum_cat_list[$key] = $val['tpath'];
$frm_catauth[] = $db->prep($key);
}
}
if ($rs['frmsub'][0] == 'all' || !$rs['frmsub']) {
$rs['frmsub'] = array();
$rs['frmsub'][] = 'all';
}
$t->assign(array('PLUGIN_FORUM_SEC_LIST' => cot_selectbox($rs['frmsub'], 'rs[frmsub][]', array_keys($forum_cat_list), array_values($forum_cat_list), false, 'multiple="multiple" style="width:50%"'), 'PLUGIN_FORUM_RES_SORT' => cot_selectbox($rs['frmsort'], 'rs[frmsort]', array('updated', 'creationdate', 'title', 'postcount', 'viewcount', 'sectionid'), array($L['plu_frm_res_sort1'], $L['plu_frm_res_sort2'], $L['plu_frm_res_sort3'], $L['plu_frm_res_sort4'], $L['plu_frm_res_sort5'], $L['plu_frm_res_sort6']), false), 'PLUGIN_FORUM_RES_SORT_WAY' => cot_radiobox($rs['frmsort2'], 'rs[frmsort2]', array('DESC', 'ASC'), array($L['plu_sort_desc'], $L['plu_sort_asc'])), 'PLUGIN_FORUM_SEARCH_NAMES' => cot_checkbox($rs['frmtitle'] == 1 || count($rs['frmsub']) == 0, 'rs[frmtitle]', $L['plu_frm_search_names']), 'PLUGIN_FORUM_SEARCH_POST' => cot_checkbox($rs['frmtext'] == 1 || count($rs['frmsub']) == 0, 'rs[frmtext]', $L['plu_frm_search_post']), 'PLUGIN_FORUM_SEARCH_ANSW' => cot_checkbox($rs['frmreply'] == 1 || count($rs['frmsub']) == 0, 'rs[frmreply]', $L['plu_frm_search_answ']), 'PLUGIN_FORUM_SEARCH_SUBCAT' => cot_checkbox($rs['frmsubcat'], 'rs[frmsubcat]', $L['plu_frm_set_subsec'])));
if ($tab == 'frm' || empty($tab) && $cfg['plugin']['search']['extrafilters']) {
$t->parse('MAIN.FORUMS_OPTIONS');
}
}
if (!empty($sq)) {
$words = explode(' ', preg_replace("'\\s+'", " ", $sq));
示例12: defined
<?php
/**
* Payments module
*
* @package payments
* @version 1.1.2
* @author CMSWorks Team
* @copyright Copyright (c) CMSWorks.ru
* @license BSD
*/
defined('COT_CODE') or die('Wrong URL.');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('payments', 'any', 'RWA');
cot_block($usr['auth_write']);
require_once cot_incfile('forms');
$n = cot_import('n', 'G', 'ALP');
$pid = cot_import('pid', 'G', 'INT');
$rsumm = cot_import('rsumm', 'G', 'NUM');
if (empty($n)) {
$n = 'history';
}
$t = new XTemplate(cot_tplfile('payments.balance', 'module'));
$t->assign(array('BALANCE_SUMM' => cot_payments_getuserbalance($usr['id']), 'BALANCE_BILLING_URL' => cot_url('payments', 'm=balance&n=billing'), 'BALANCE_HISTORY_URL' => cot_url('payments', 'm=balance&n=history'), 'BALANCE_PAYOUT_URL' => cot_url('payments', 'm=balance&n=payouts'), 'BALANCE_TRANSFER_URL' => cot_url('payments', 'm=balance&n=transfer')));
if ($n == 'billing') {
$pid = cot_import('pid', 'G', 'INT');
if ($a == 'buy') {
$summ = cot_import('summ', 'P', 'NUM');
cot_check(empty($summ), 'payments_balance_billing_error_emptysumm');
cot_check(!empty($summ) && $summ < 0, 'payments_balance_billing_error_wrongsumm');
if (!cot_error_found()) {
$options['desc'] = $L['payments_balance_billing_desc'];
示例13: cot_display_messages
$t->parse('MAIN.BEFORE_AJAX');
$t->parse('MAIN.AFTER_AJAX');
}
cot_display_messages($t);
$title[] = array(cot_url('pm'), $L['Private_Messages']);
$title[] = !$id ? $L['pmsend_title'] : $L['Edit'] . ' #' . $id;
$url_newpm = cot_url('pm', 'm=send');
$url_inbox = cot_url('pm');
$url_sentbox = cot_url('pm', 'f=sentbox');
if (COT_AJAX) {
// Attach rich text editors to AJAX loaded page
$rc_tmp = $out['footer_rc'];
$out['footer_rc'] = '';
if (is_array($cot_plugins['editor'])) {
foreach ($cot_plugins['editor'] as $k) {
if ($k['pl_code'] == $editor && cot_auth('plug', $k['pl_code'], 'R')) {
include $cfg['plugins_dir'] . '/' . $k['pl_file'];
break;
}
}
}
$text_editor_code = $out['footer_rc'];
$out['footer_rc'] = $rc_tmp;
}
$t->assign(array('PMSEND_TITLE' => cot_breadcrumbs($title, $cfg['homebreadcrumb']), 'PMSEND_SENDNEWPM' => $usr['auth_write'] ? cot_rc_link($url_newpm, $L['pm_sendnew'], array('class' => $cfg['pm']['turnajax'] ? 'ajax' : '')) : '', 'PMSEND_SENDNEWPM_URL' => $usr['auth_write'] ? $url_newpm : '', 'PMSEND_INBOX' => cot_rc_link($url_inbox, $L['pm_inbox'], array('class' => $cfg['pm']['turnajax'] ? 'ajax' : '')), 'PMSEND_INBOX_URL' => $url_inbox, 'PMSEND_INBOX_COUNT' => $totalinbox, 'PMSEND_SENTBOX' => cot_rc_link($url_sentbox, $L['pm_sentbox'], array('class' => $cfg['pm']['turnajax'] ? 'ajax' : '')), 'PMSEND_SENTBOX_URL' => $url_sentbox, 'PMSEND_SENTBOX_COUNT' => $totalsentbox, 'PMSEND_FORM_SEND' => cot_url('pm', 'm=send&a=send' . $idurl), 'PMSEND_FORM_TITLE' => cot_inputbox('text', 'newpmtitle', htmlspecialchars($newpmtitle), 'size="56" maxlength="255"'), 'PMSEND_FORM_TEXT' => cot_textarea('newpmtext', $newpmtext, 8, 56, '', 'input_textarea_editor') . $text_editor_code, 'PMSEND_FORM_TOUSER' => cot_textarea('newpmrecipient', $touser, 3, 56, 'class="userinput"'), 'PMSEND_FORM_NOT_TO_SENTBOX' => cot_checkbox(false, 'fromstate', cot::$L['pm_notmovetosentbox'], '', '3')));
/* === Hook === */
foreach (cot_getextplugins('pm.send.tags') as $pl) {
include $pl;
}
/* ===== */
if (!$id) {
示例14: cot_import
$id = cot_import('id', 'G', 'INT');
$c = cot_import('c', 'G', 'TXT');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('market', 'any', 'RWA');
/* === Hook === */
foreach (cot_getextplugins('market.edit.first') as $pl) {
include $pl;
}
/* ===== */
cot_block($usr['auth_read']);
if (!$id || $id < 0) {
cot_die_message(404);
}
$sql = $db->query("SELECT * FROM {$db_market} WHERE item_id='{$id}' LIMIT 1");
cot_die($sql->rowCount() == 0);
$item = $sql->fetch();
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('market', $item['item_cat']);
cot_block($usr['isadmin'] || $usr['auth_write'] && $usr['id'] == $item['item_userid']);
$sys['parser'] = $item['item_parser'];
$parser_list = cot_get_parsers();
if ($a == 'update') {
/* === Hook === */
foreach (cot_getextplugins('market.edit.update.first') as $pl) {
include $pl;
}
/* ===== */
cot_block($usr['isadmin'] || $usr['auth_write'] && $usr['id'] == $item['item_userid']);
$ritem = cot_market_import('POST', $item, $usr);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$rdelete = cot_import('rdelete', 'P', 'BOL');
} else {
$rdelete = cot_import('delete', 'G', 'BOL');
示例15: cot_ratings_display
/**
* Generates ratings 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 $readonly Display as read-only
* @return array Rendered HTML output for ratings and average integer value as an array with 2 elements
* @global CotDB $db
*/
function cot_ratings_display($ext_name, $code, $cat = '', $readonly = false)
{
global $db, $db_ratings, $db_rated, $db_users, $cfg, $usr, $sys, $L, $R;
// Check permissions
list($auth_read, $auth_write, $auth_admin) = cot_auth('plug', 'ratings');
$enabled = cot_ratings_enabled($ext_name, $cat, $code);
if (!$auth_read || !$enabled && !$auth_admin) {
return array('', 0);
}
// Get current rating value
$sql = $db->query("SELECT r.*, (SELECT COUNT(*) FROM {$db_rated} WHERE rated_area = ? AND rated_code = ?) AS `cnt` FROM {$db_ratings} AS r\n\t\tWHERE rating_area = ? AND rating_code = ? LIMIT 1", array($ext_name, $code, $ext_name, $code));
if ($row = $sql->fetch()) {
$rating_average = $row['rating_average'];
$item_has_rating = true;
if ($rating_average < 1) {
$rating_average = 1;
} elseif ($rating_average > 10) {
$rating_average = 10;
}
$rating_cntround = round($rating_average, 0);
$rating_raters_count = $row['cnt'];
} else {
$item_has_rating = false;
$rating_average = 0;
$rating_cntround = 0;
$rating_raters_count = 0;
}
// Render read-only image
$rating_fancy = cot_rc('icon_rating_stars', array('val' => $rating_cntround));
if (!$auth_write || $readonly) {
return array($rating_fancy, $rating_cntround, $rating_raters_count);
}
// Check if the user has voted already for this item
$already_voted = false;
if ($usr['id'] > 0) {
$sql1 = $db->query("SELECT rated_value FROM {$db_rated}\n\t\t\tWHERE rated_area = ? AND rated_code = ? AND rated_userid = ?", array($ext_name, $code, $usr['id']));
if ($rated_value = $sql1->fetchColumn()) {
$already_voted = true;
$rating_uservote = $L['rat_alreadyvoted'] . ' (' . $rated_value . ')';
}
}
if ($already_voted && !$cfg['plugin']['ratings']['ratings_allowchange']) {
return array($rating_fancy, $rating_cntround, $rating_raters_count);
}
$t = new XTemplate(cot_tplfile('ratings', 'plug'));
/* == Hook for the plugins == */
foreach (cot_getextplugins('ratings.main') as $pl) {
include $pl;
}
/* ===== */
// Get some extra information about votes
if ($item_has_rating) {
$sql = $db->query("SELECT COUNT(*) FROM {$db_rated}\n\t\t\tWHERE rated_area = ? AND rated_code = ?", array($ext_name, $code));
$rating_voters = $sql->fetchColumn();
$rating_since = $L['rat_since'] . ' ' . cot_date('datetime_medium', $row['rating_creationdate']);
$rating_since_stamp = $row['rating_creationdate'];
$rating_averageimg = cot_rc('icon_rating_stars', array('val' => $rating_cntround));
} else {
$rating_voters = 0;
$rating_since = '';
$rating_since_stamp = '';
$rating_averageimg = '';
}
// Assign tags
$t->assign(array('RATINGS_CODE' => $code, 'RATINGS_AVERAGE' => round($rating_average), 'RATINGS_AVERAGEIMG' => $rating_averageimg, 'RATINGS_VOTERS' => $rating_voters, 'RATINGS_SINCE' => $rating_since, 'RATINGS_SINCE_STAMP' => $rating_since_stamp, 'RATINGS_FANCYIMG' => $rating_fancy, 'RATINGS_USERVOTE' => $rating_uservote));
/* == Hook for the plugins == */
foreach (cot_getextplugins('ratings.tags') as $pl) {
include $pl;
}
/* ===== */
// Render voting form
$vote_block = $auth_write && (!$already_voted || $cfg['plugin']['ratings']['ratings_allowchange']) ? 'NOTVOTED.' : 'VOTED.';
for ($i = 1; $i <= 10; $i++) {
$checked = $i <= $rating_cntround ? 'checked="checked"' : '';
$t->assign(array('RATINGS_ROW_VALUE' => $i, 'RATINGS_ROW_TITLE' => $L['rat_choice' . $i], 'RATINGS_ROW_CHECKED' => $checked));
$t->parse('RATINGS.' . $vote_block . 'RATINGS_ROW');
}
if ($vote_block == 'NOTVOTED.') {
// 'r=ratings&area=' . $ext_name . '&code=' . $code.'&inr=send'
$t->assign('RATINGS_FORM_SEND', cot_url('plug', array('r' => 'ratings', 'inr' => 'send', 'area' => $ext_name, 'code' => $code, 'cat' => $cat)));
$t->parse('RATINGS.NOTVOTED');
} else {
$t->parse('RATINGS.VOTED');
}
// Parse and return
$t->parse('RATINGS');
$res = $t->text('RATINGS');
return array($res, round($rating_cntround), $rating_raters_count);
}