Пример #1
0
/**
 * Returns all page tags for coTemplate
 *
 * @param mixed $page_data Page Info Array or ID
 * @param string $tag_prefix Prefix for tags
 * @param int $textlength Text truncate
 * @param bool $admin_rights Page Admin Rights
 * @param bool $pagepath_home Add home link for page path
 * @param string $emptytitle Page title text if page does not exist
 * @return array
 * @global CotDB $db
 */
function cot_generate_pagetags($page_data, $tag_prefix = '', $textlength = 0, $admin_rights = null, $pagepath_home = false, $emptytitle = '')
{
    global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_pages, $usr, $sys, $cot_yesno, $structure, $db_structure;
    static $extp_first = null, $extp_main = null;
    static $pag_auth = array();
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('pagetags.first');
        $extp_main = cot_getextplugins('pagetags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    if (!is_array($page_data)) {
        $sql = $db->query("SELECT * FROM {$db_pages} WHERE page_id = '" . (int) $page_data . "' LIMIT 1");
        $page_data = $sql->fetch();
    }
    if ($page_data['page_id'] > 0 && !empty($page_data['page_title'])) {
        if (is_null($admin_rights)) {
            if (!isset($pag_auth[$page_data['page_cat']])) {
                $pag_auth[$page_data['page_cat']] = cot_auth('page', $page_data['page_cat'], 'RWA1');
            }
            $admin_rights = (bool) $pag_auth[$page_data['page_cat']][2];
        }
        $pagepath = cot_structure_buildpath('page', $page_data['page_cat']);
        $catpath = cot_breadcrumbs($pagepath, $pagepath_home);
        $page_data['page_pageurl'] = empty($page_data['page_alias']) ? cot_url('page', 'c=' . $page_data['page_cat'] . '&id=' . $page_data['page_id']) : cot_url('page', 'c=' . $page_data['page_cat'] . '&al=' . $page_data['page_alias']);
        $page_link[] = array($page_data['page_pageurl'], $page_data['page_title']);
        $page_data['page_fulltitle'] = cot_breadcrumbs(array_merge($pagepath, $page_link), $pagepath_home);
        if (!empty($page_data['page_url']) && $page_data['page_file']) {
            $dotpos = mb_strrpos($page_data['page_url'], ".") + 1;
            $type = mb_strtolower(mb_substr($page_data['page_url'], $dotpos, 5));
            $page_data['page_fileicon'] = cot_rc('page_icon_file_path', array('type' => $type));
            if (!file_exists($page_data['page_fileicon'])) {
                $page_data['page_fileicon'] = cot_rc('page_icon_file_default');
            }
            $page_data['page_fileicon'] = cot_rc('page_icon_file', array('icon' => $page_data['page_fileicon']));
        } else {
            $page_data['page_fileicon'] = '';
        }
        $date_format = 'datetime_medium';
        $text = cot_parse($page_data['page_text'], $cfg['page']['markup'], $page_data['page_parser']);
        $text_cut = cot_cut_more($text);
        if ($textlength > 0 && mb_strlen($text_cut) > $textlength) {
            $text_cut = cot_string_truncate($text_cut, $textlength);
        }
        $cutted = mb_strlen($text) > mb_strlen($text_cut) ? true : false;
        $cat_url = cot_url('page', 'c=' . $page_data['page_cat']);
        $validate_url = cot_url('admin', "m=page&a=validate&id={$page_data['page_id']}&x={$sys['xk']}");
        $unvalidate_url = cot_url('admin', "m=page&a=unvalidate&id={$page_data['page_id']}&x={$sys['xk']}");
        $edit_url = cot_url('page', "m=edit&id={$page_data['page_id']}");
        $delete_url = cot_url('page', "m=edit&a=update&delete=1&id={$page_data['page_id']}&x={$sys['xk']}");
        $page_data['page_status'] = cot_page_status($page_data['page_state'], $page_data['page_begin'], $page_data['page_expire']);
        $temp_array = array('URL' => $page_data['page_pageurl'], 'ID' => $page_data['page_id'], 'TITLE' => $page_data['page_fulltitle'], 'ALIAS' => $page_data['page_alias'], 'STATE' => $page_data['page_state'], 'STATUS' => $page_data['page_status'], 'LOCALSTATUS' => $L['page_status_' . $page_data['page_status']], 'SHORTTITLE' => htmlspecialchars($page_data['page_title'], ENT_COMPAT, 'UTF-8', false), 'CAT' => $page_data['page_cat'], 'CATURL' => $cat_url, 'CATTITLE' => htmlspecialchars($structure['page'][$page_data['page_cat']]['title']), 'CATPATH' => $catpath, 'CATPATH_SHORT' => cot_rc_link($cat_url, htmlspecialchars($structure['page'][$page_data['page_cat']]['title'])), 'CATDESC' => htmlspecialchars($structure['page'][$page_data['page_cat']]['desc']), 'CATICON' => $structure['page'][$page_data['page_cat']]['icon'], 'KEYWORDS' => htmlspecialchars($page_data['page_keywords']), 'DESC' => htmlspecialchars($page_data['page_desc']), 'TEXT' => $text, 'TEXT_CUT' => $text_cut, 'TEXT_IS_CUT' => $cutted, 'DESC_OR_TEXT' => !empty($page_data['page_desc']) ? htmlspecialchars($page_data['page_desc']) : $text, 'MORE' => $cutted ? cot_rc('list_more', array('page_url' => $page_data['page_pageurl'])) : '', 'AUTHOR' => htmlspecialchars($page_data['page_author']), 'OWNERID' => $page_data['page_ownerid'], 'OWNERNAME' => htmlspecialchars($page_data['user_name']), 'DATE' => cot_date($date_format, $page_data['page_date']), 'BEGIN' => cot_date($date_format, $page_data['page_begin']), 'EXPIRE' => cot_date($date_format, $page_data['page_expire']), 'UPDATED' => cot_date($date_format, $page_data['page_updated']), 'DATE_STAMP' => $page_data['page_date'], 'BEGIN_STAMP' => $page_data['page_begin'], 'EXPIRE_STAMP' => $page_data['page_expire'], 'UPDATED_STAMP' => $page_data['page_updated'], 'FILE' => $cot_yesno[$page_data['page_file']], 'FILE_URL' => empty($page_data['page_url']) ? '' : cot_url('page', 'c=' . $page_data['page_cat'] . '&id=' . $page_data['page_id'] . '&a=dl'), 'FILE_SIZE' => $page_data['page_size'] / 1024, 'FILE_SIZE_BYTES' => $page_data['page_size'], 'FILE_SIZE_READABLE' => cot_build_filesize($page_data['page_size'], 1), 'FILE_ICON' => $page_data['page_fileicon'], 'FILE_COUNT' => $page_data['page_filecount'], 'FILE_COUNTTIMES' => cot_declension($page_data['page_filecount'], $Ls['Times']), 'FILE_NAME' => basename($page_data['page_url']), 'COUNT' => $page_data['page_count'], 'ADMIN' => $admin_rights ? cot_rc('list_row_admin', array('unvalidate_url' => $unvalidate_url, 'edit_url' => $edit_url)) : '', 'NOTAVAILABLE' => $page_data['page_begin'] > $sys['now'] ? $L['page_notavailable'] . cot_build_timegap($sys['now'], $pag['page_begin']) : '');
        // Admin tags
        if ($admin_rights) {
            $validate_confirm_url = cot_confirm_url($validate_url, 'page', 'page_confirm_validate');
            $unvalidate_confirm_url = cot_confirm_url($unvalidate_url, 'page', 'page_confirm_unvalidate');
            $delete_confirm_url = cot_confirm_url($delete_url, 'page', 'page_confirm_delete');
            $temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
            $temp_array['ADMIN_EDIT_URL'] = $edit_url;
            $temp_array['ADMIN_UNVALIDATE'] = $page_data['page_state'] == 1 ? cot_rc_link($validate_confirm_url, $L['Validate'], 'class="confirmLink"') : cot_rc_link($unvalidate_confirm_url, $L['Putinvalidationqueue'], 'class="confirmLink"');
            $temp_array['ADMIN_UNVALIDATE_URL'] = $page_data['page_state'] == 1 ? $validate_confirm_url : $unvalidate_confirm_url;
            $temp_array['ADMIN_DELETE'] = cot_rc_link($delete_confirm_url, $L['Delete'], 'class="confirmLink"');
            $temp_array['ADMIN_DELETE_URL'] = $delete_confirm_url;
        } else {
            if ($usr['id'] == $page_data['page_ownerid']) {
                $temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
                $temp_array['ADMIN_EDIT_URL'] = $edit_url;
            }
        }
        if (cot_auth('page', 'any', 'W')) {
            $clone_url = cot_url('page', "m=add&c={$page_data['page_cat']}&clone={$page_data['page_id']}");
            $temp_array['ADMIN_CLONE'] = cot_rc_link($clone_url, $L['page_clone']);
            $temp_array['ADMIN_CLONE_URL'] = $clone_url;
        }
        // Extrafields
        if (isset($cot_extrafields[$db_pages])) {
            foreach ($cot_extrafields[$db_pages] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array[$tag . '_TITLE'] = isset($L['page_' . $exfld['field_name'] . '_title']) ? $L['page_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array[$tag] = cot_build_extrafields_data('page', $exfld, $page_data['page_' . $exfld['field_name']], $page_data['page_parser']);
                $temp_array[$tag . '_VALUE'] = $page_data['page_' . $exfld['field_name']];
            }
        }
        // Extra fields for structure
        if (isset($cot_extrafields[$db_structure])) {
            foreach ($cot_extrafields[$db_structure] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array['CAT_' . $tag . '_TITLE'] = isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array['CAT_' . $tag] = cot_build_extrafields_data('structure', $exfld, $structure['page'][$page_data['page_cat']][$exfld['field_name']]);
                $temp_array['CAT_' . $tag . '_VALUE'] = $structure['page'][$page_data['page_cat']][$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;
}
Пример #2
0
/**
 * Returns all user tags for XTemplate
 *
 * @param mixed $user_data User Info Array
 * @param string $tag_prefix Prefix for tags
 * @param string $emptyname Name text if user is not exist
 * @param bool $allgroups Build info about all user groups
 * @param bool $cacheitem Cache tags
 * @return array
 * @global CotDB $db
 */
function cot_generate_usertags($user_data, $tag_prefix = '', $emptyname = '', $allgroups = false, $cacheitem = true)
{
    global $db, $cot_extrafields, $cot_groups, $cfg, $L, $user_cache, $db_users;
    static $extp_first = null, $extp_main = null;
    $return_array = array();
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('usertags.first');
        $extp_main = cot_getextplugins('usertags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    $user_id = is_array($user_data) ? (int) $user_data['user_id'] : (is_numeric($user_data) ? (int) $user_data : 0);
    if (isset($user_cache[$user_id])) {
        $temp_array = $user_cache[$user_id];
    } else {
        if (!is_array($user_data) && $user_id > 0) {
            $sql = $db->query("SELECT * FROM {$db_users} WHERE user_id = {$user_id} LIMIT 1");
            $user_data = $sql->fetch();
        } else {
            if (!is_array($user_data)) {
                $user_data = array();
            }
        }
        if (is_array($user_data) && $user_data['user_id'] > 0 && !empty($user_data['user_name'])) {
            $user_data['user_birthdate'] = cot_date2stamp($user_data['user_birthdate']);
            $user_data['user_text'] = cot_parse($user_data['user_text'], $cfg['users']['usertextimg']);
            $temp_array = array('ID' => $user_data['user_id'], 'NAME' => cot_build_user($user_data['user_id'], htmlspecialchars($user_data['user_name'])), 'NICKNAME' => htmlspecialchars($user_data['user_name']), 'DETAILSLINK' => cot_url('users', 'm=details&id=' . $user_data['user_id'] . '&u=' . htmlspecialchars($user_data['user_name'])), 'DETAILSLINKSHORT' => cot_url('users', 'm=details&id=' . $user_data['user_id']), 'FULL_NAME' => htmlspecialchars(cot_user_full_name($user_data)), 'TITLE' => $cot_groups[$user_data['user_maingrp']]['title'], 'MAINGRP' => cot_build_group($user_data['user_maingrp']), 'MAINGRPID' => $user_data['user_maingrp'], 'MAINGRPNAME' => $cot_groups[$user_data['user_maingrp']]['name'], 'MAINGRPTITLE' => cot_build_group($user_data['user_maingrp'], true), 'MAINGRPSTARS' => cot_build_stars($cot_groups[$user_data['user_maingrp']]['level']), 'MAINGRPICON' => cot_build_groupicon($cot_groups[$user_data['user_maingrp']]['icon']), 'COUNTRY' => cot_build_country($user_data['user_country']), 'COUNTRYFLAG' => cot_build_flag($user_data['user_country']), 'TEXT' => $user_data['user_text'], 'EMAIL' => cot_build_email($user_data['user_email'], $user_data['user_hideemail']), 'THEME' => $user_data['user_theme'], 'SCHEME' => $user_data['user_scheme'], 'LANG' => $user_data['user_lang'], 'GENDER' => $user_data['user_gender'] == '' || $user_data['user_gender'] == 'U' ? '' : $L['Gender_' . $user_data['user_gender']], 'BIRTHDATE' => is_null($user_data['user_birthdate']) ? '' : cot_date('date_full', $user_data['user_birthdate']), 'BIRTHDATE_STAMP' => is_null($user_data['user_birthdate']) ? '' : $user_data['user_birthdate'], 'AGE' => is_null($user_data['user_birthdate']) ? '' : cot_build_age($user_data['user_birthdate']), 'TIMEZONE' => cot_build_timezone(cot_timezone_offset($user_data['user_timezone'], false, false)) . ' ' . str_replace('_', ' ', $user_data['user_timezone']), 'REGDATE' => cot_date('datetime_medium', $user_data['user_regdate']), 'REGDATE_STAMP' => $user_data['user_regdate'], 'LASTLOG' => cot_date('datetime_medium', $user_data['user_lastlog']), 'LASTLOG_STAMP' => $user_data['user_lastlog'], 'LOGCOUNT' => $user_data['user_logcount'], 'POSTCOUNT' => $user_data['user_postcount'], 'LASTIP' => $user_data['user_lastip']);
            if ($allgroups) {
                $temp_array['GROUPS'] = cot_build_groupsms($user_data['user_id'], FALSE, $user_data['user_maingrp']);
            }
            // Extra fields
            if (isset($cot_extrafields[$db_users])) {
                foreach ($cot_extrafields[$db_users] as $exfld) {
                    $temp_array[strtoupper($exfld['field_name'])] = cot_build_extrafields_data('user', $exfld, $user_data['user_' . $exfld['field_name']]);
                    $temp_array[strtoupper($exfld['field_name']) . '_TITLE'] = isset($L['user_' . $exfld['field_name'] . '_title']) ? $L['user_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                    $temp_array[strtoupper($exfld['field_name']) . '_VALUE'] = $user_data['user_' . $exfld['field_name']];
                }
            }
        } else {
            $temp_array = array('ID' => 0, 'NAME' => !empty($emptyname) ? $emptyname : $L['Deleted'], 'NICKNAME' => !empty($emptyname) ? $emptyname : $L['Deleted'], 'FULL_NAME' => !empty($emptyname) ? $emptyname : $L['Deleted'], 'MAINGRP' => cot_build_group(1), 'MAINGRPID' => 1, 'MAINGRPSTARS' => '', 'MAINGRPICON' => cot_build_groupicon($cot_groups[1]['icon']), 'COUNTRY' => cot_build_country(''), 'COUNTRYFLAG' => cot_build_flag(''), 'TEXT' => '', 'EMAIL' => '', 'GENDER' => '', 'BIRTHDATE' => '', 'BIRTHDATE_STAMP' => '', 'AGE' => '', 'REGDATE' => '', 'REGDATE_STAMP' => '', 'POSTCOUNT' => '', 'LASTIP' => '');
        }
        /* === Hook === */
        foreach ($extp_main as $pl) {
            include $pl;
        }
        /* ===== */
        if (is_array($user_data) && isset($user_data['user_id'])) {
            $cacheitem && ($user_cache[$user_data['user_id']] = $temp_array);
        }
    }
    foreach ($temp_array as $key => $val) {
        $return_array[$tag_prefix . $key] = $val;
    }
    return $return_array;
}
Пример #3
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;
}
Пример #4
0
}
$item = $sql->fetch();
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('folio', $item['item_cat'], 'RWA');
cot_block($usr['auth_read']);
if ($item['item_state'] != 0 && !$usr['isadmin'] && $usr['id'] != $item['item_userid']) {
    cot_log("Attempt to directly access an un-validated", 'sec');
    cot_redirect(cot_url('message', "msg=930", '', true));
    exit;
}
if ($usr['id'] != $item['item_userid'] && (!$usr['isadmin'] || $cfg['folio']['count_admin'])) {
    $item['item_count']++;
    $db->update($db_folio, array('item_count' => $item['item_count']), "item_id=" . (int) $item['item_id']);
}
$title_params = array('TITLE' => empty($item['item_metatitle']) ? $item['item_title'] : $item['item_metatitle'], 'CATEGORY' => $structure['folio'][$item['item_cat']]['title']);
$out['subtitle'] = cot_title($cfg['folio']['title_folio'], $title_params);
$out['desc'] = !empty($item['item_metadesc']) ? $item['item_metadesc'] : cot_cutstring(strip_tags(cot_parse($item['item_text'], $cfg['folio']['markup'], $item['item_parser'])), 160);
$out['meta_keywords'] = !empty($item['item_keywords']) ? $item['item_keywords'] : $structure['folio'][$item['item_cat']]['keywords'];
// Building the canonical URL
$pageurl_params = array('c' => $item['item_cat']);
empty($al) ? $pageurl_params['id'] = $id : ($pageurl_params['al'] = $al);
$out['canonical_uri'] = cot_url('folio', $pageurl_params);
$mskin = cot_tplfile(array('folio', $structure['folio'][$item['item_cat']]['tpl']));
/* === Hook === */
foreach (cot_getextplugins('folio.main') as $pl) {
    include $pl;
}
/* ===== */
$t = new XTemplate($mskin);
$t->assign(cot_generate_usertags($item, 'PRD_OWNER_'));
$t->assign(cot_generate_foliotags($item, 'PRD_', $cfg['folio']['shorttextlen'], $usr['isadmin'], $cfg['homebreadcrumb']));
/* === Hook === */
[BEGIN_COT_EXT]
Hooks=forums.posts.tags
[END_COT_EXT]
==================== */
/**
 * Polls
 *
 * @package Polls
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
cot_poll_vote();
$poll_form = cot_poll_form($q, cot_url('forums', 'm=posts&q=' . $q), '', 'forum');
if ($poll_form) {
    $t->assign(array('POLLS_TITLE' => cot_parse($poll_form['poll_text'], $cfg['polls']['markup']), 'POLLS_FORM' => $poll_form['poll_block']));
    $t->parse('MAIN.POLLS_VIEW');
    if ($poll_form['poll_alreadyvoted']) {
        $extra = $votecasted ? $L['polls_votecasted'] : $L['polls_alreadyvoted'];
    } else {
        $extra = $L['polls_notyetvoted'];
    }
    $t->assign('POLLS_EXTRATEXT', $extra);
    $t->parse('MAIN.POLLS_EXTRA');
    if (!empty($poll_form['poll_text'])) {
        $rowt['ft_title'] = $L['Poll'] . ": " . $rowt['ft_title'];
    }
    $crumbs = cot_forums_buildpath($s);
    $toppath = cot_breadcrumbs($crumbs, $cfg['homebreadcrumb']);
    $crumbs[] = $rowt['ft_title'];
    $toptitle = cot_breadcrumbs($crumbs, $cfg['homebreadcrumb'], true);
Пример #6
0
Resources::linkFileFooter(cot::$cfg['modules_dir'] . '/pm/js/pm.js');
/* === Title === */
$totallines = $db->query("SELECT COUNT(*) FROM {$db_pm} WHERE {$sqlfilter}")->fetchColumn();
$elem = $f == 'sentbox' ? 'pm_touserid' : 'pm_fromuserid';
$pm_sql = $db->query("SELECT p.*, u.* FROM {$db_pm} AS p\n\t\tLEFT JOIN {$db_users} AS u\n\t\tON u.user_id = p.{$elem}\n\t\tWHERE {$sqlfilter}\n\t\tORDER BY pm_date DESC LIMIT  {$d}," . $cfg['pm']['maxpmperpage']);
$pagenav = cot_pagenav('pm', 'f=' . $f . '&filter=' . $filter, $d, $totallines, $cfg['pm']['maxpmperpage'], 'd', '', $cfg['pm']['turnajax']);
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate(cot_tplfile(array('pm', 'list', $pmalttpl)));
$jj = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('pm.list.loop');
/* ===== */
foreach ($pm_sql->fetchAll() as $row) {
    $jj++;
    $row['pm_icon_readstatus'] = $row['pm_tostate'] == '0' ? cot_rc_link(cot_url('pm', 'm=message&id=' . $row['pm_id']), $R['pm_icon_new'], array('title' => $L['pm_unread'], 'class' => $cfg['pm']['turnajax'] ? 'ajax' : '')) : cot_rc_link(cot_url('pm', 'm=message&id=' . $row['pm_id']), $R['pm_icon'], array('title' => $L['pm_read'], 'class' => 'ajax'));
    $pm_data = cot_parse($row['pm_text'], $cfg['pm']['markup']);
    $pm_desc = cot_string_truncate($pm_data, 100, true, false, '...');
    if ($f == 'sentbox') {
        $star_class = $row['pm_fromstate'] == 2 ? 1 : 0;
    } else {
        $star_class = $row['pm_tostate'] == 2 ? 1 : 0;
    }
    $url_edit = cot_url('pm', 'm=send&id=' . $row['pm_id']);
    $url_delete = cot_url('pm', 'm=edit&a=delete&' . cot_xg() . '&id=' . $row['pm_id'] . '&f=' . $f . '&d=' . $durl);
    $t->assign(array('PM_ROW_ID' => $row['pm_id'], 'PM_ROW_STATE' => $row['pm_tostate'], 'PM_ROW_STAR' => cot_rc($star_class ? 'pm_icon_unstar' : 'pm_icon_star', array('link' => cot_url('pm', 'f=' . $f . '&filter=' . $filter . '&a=star&id=' . $row['pm_id'] . '&d=' . $durl))), 'PM_ROW_STAR_URL' => cot_url('pm', 'f=' . $f . '&filter=' . $filter . '&a=star&id=' . $row['pm_id'] . '&d=' . $durl), 'PM_ROW_DATE' => cot_date('datetime_medium', $row['pm_date']), 'PM_ROW_DATE_STAMP' => $row['pm_date'], 'PM_ROW_TITLE' => cot_rc_link(cot_url('pm', 'm=message&id=' . $row['pm_id']), htmlspecialchars($row['pm_title']), array('class' => $cfg['pm']['turnajax'] ? 'ajax' : '')), 'PM_ROW_URL' => cot_url('pm', 'm=message&id=' . $row['pm_id']), 'PM_ROW_TEXT' => $pm_data, 'PM_ROW_ICON_STATUS' => $row['pm_icon_readstatus'], 'PM_ROW_ICON_STARRED' => $row['pm_icon_starred'], 'PM_ROW_ICON_DELETE' => cot_rc_link($url_delete, $R['pm_icon_trashcan'], array('title' => $L['Delete'], 'class' => $cfg['pm']['turnajax'] ? 'ajax' : '')), 'PM_ROW_ICON_DELETE_CONFIRM' => cot_rc_link(cot_confirm_url($url_delete), $R['pm_icon_trashcan'], array('title' => $L['Delete'], 'class' => $cfg['pm']['turnajax'] ? 'ajax' : '')), 'PM_ROW_DELETE_URL' => $url_delete, 'PM_ROW_DELETE_CONFIRM_URL' => cot_confirm_url($url_delete), 'PM_ROW_ICON_EDIT' => $row['pm_tostate'] == 0 ? cot_rc_link($url_edit, $R['pm_icon_edit'], array('title' => $L['Edit'], 'class' => $cfg['pm']['turnajax'] ? 'ajax' : '')) : '', 'PM_ROW_EDIT_URL' => $row['pm_tostate'] == 0 ? $url_edit : '', 'PM_ROW_DESC' => $pm_desc, 'PM_ROW_ODDEVEN' => cot_build_oddeven($jj), 'PM_ROW_NUM' => $jj));
    $t->assign(cot_generate_usertags($row, 'PM_ROW_USER_'));
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
Пример #7
0
 }
 /* ===== */
 if ($usr['id'] == $item['item_userid'] && $choise_enabled) {
     $t_o->assign(array("OFFER_ROW_SETPERFORMER" => cot_url('projects', 'id=' . $id . '&a=setperformer&userid=' . $offer['user_id'] . '&' . cot_xg()), "OFFER_ROW_REFUSE" => cot_url('projects', 'id=' . $id . '&a=refuse&userid=' . $offer['user_id'] . '&' . cot_xg())));
     /* === Hook - Part2 : Include === */
     foreach ($extp2 as $pl) {
         include $pl;
     }
     /* ===== */
     $t_o->parse("MAIN.ROWS.CHOISE");
 }
 if ($usr['id'] == $offer['offer_userid'] || $usr['id'] == $item['item_userid'] || $usr['isadmin']) {
     $sql_prjposts = $db->query("SELECT * FROM {$db_projects_posts} as p LEFT JOIN {$db_users} as u ON u.user_id=p.post_userid\n\t\t\tWHERE post_pid=" . $id . " AND post_oid=" . $offer['offer_id'] . " ORDER BY post_date ASC");
     while ($posts = $sql_prjposts->fetch()) {
         $t_o->assign(cot_generate_usertags($posts, 'POST_ROW_OWNER_'));
         $t_o->assign(array("POST_ROW_TEXT" => cot_parse($posts['post_text']), "POST_ROW_DATE" => cot_date('d.m.y H:i', $posts['post_date']), "POST_ROW_DATE_STAMP" => $posts['post_date']));
         /* === Hook - Part3 : Include === */
         foreach ($extp3 as $pl) {
             include $pl;
         }
         /* ===== */
         $t_o->parse("MAIN.ROWS.POSTS.POSTS_ROWS");
     }
     $t_o->assign(array("ADDPOST_ACTION_URL" => cot_url('projects', 'id=' . $id . '&oid=' . $offer['offer_id'] . '&a=addpost'), "ADDPOST_TEXT" => cot_textarea('posttext', $offer_post['post_text'], 3, 60), "ADDPOST_OFFERID" => $offer['offer_id']));
     $t_o->parse("MAIN.ROWS.POSTS.POSTFORM");
     $t_o->parse("MAIN.ROWS.POSTS");
 }
 /* === Hook - Part4 : Include === */
 foreach ($extp4 as $pl) {
     include $pl;
 }
$query_limit = $cfg['projects']['offersperpage'] > 0 ? "LIMIT {$d}, " . $cfg['projects']['offersperpage'] : '';
$totalitems = $db->query("SELECT COUNT(*) FROM {$db_projects_offers} AS o \n\tLEFT JOIN {$db_projects} AS p ON o.offer_pid=p.item_id\n\t" . $where . "")->fetchColumn();
$sql = $db->query("SELECT o.* FROM {$db_projects_offers} AS o\n\tLEFT JOIN {$db_projects} AS p ON o.offer_pid=p.item_id\n\t" . $where . "\n\t" . $order . "\n\t" . $query_limit . "");
if ($cfg['projects']['offersperpage'] > 0) {
    $pagenav = cot_pagenav('projects', 'm=useroffers&choise=' . $choise, $d, $totalitems, $cfg['projects']['offersperpage']);
    $t->assign(array("PAGENAV_PAGES" => $pagenav['main'], "PAGENAV_PREV" => $pagenav['prev'], "PAGENAV_NEXT" => $pagenav['next']));
}
$catpatharray[] = array(cot_url('projects'), $L['projects']);
$catpatharray[] = array('', $L['offers_useroffers']);
$catpath = cot_breadcrumbs($catpatharray, $cfg['homebreadcrumb'], true);
$t->assign(array("BREADCRUMBS" => $catpath));
/* === Hook === */
$extp = cot_getextplugins('projects.useroffers.loop');
/* ===== */
while ($offer = $sql->fetch()) {
    $t->assign(cot_generate_projecttags($offer['offer_pid'], 'OFFER_ROW_PROJECT_'));
    $t->assign(array("OFFER_ROW_DATE" => date('d.m.Y H:i', $offer['offer_date']), "OFFER_ROW_TEXT" => cot_parse($offer['offer_text']), "OFFER_ROW_COSTMIN" => number_format($offer['offer_cost_min'], '0', '.', ' '), "OFFER_ROW_COSTMAX" => number_format($offer['offer_cost_max'], '0', '.', ' '), "OFFER_ROW_TIMEMIN" => $offer['offer_time_min'], "OFFER_ROW_TIMEMAX" => $offer['offer_time_max'], "OFFER_ROW_TIMETYPE" => $L['offers_timetype'][$offer['offer_time_type']], "OFFER_ROW_CHOISE" => $offer['offer_choise']));
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse("MAIN.OFFER_ROWS");
}
/* === Hook === */
foreach (cot_getextplugins('projects.useroffers.tags') as $pl) {
    include $pl;
}
/* ===== */
$t->parse("MAIN");
$module_body = $t->text('MAIN');
Пример #9
0
 if ($sql->rowCount() > 0) {
     $row = $sql->fetch();
     if (cot_auth('page', $row['page_cat'], 'R')) {
         $rss_title = $row['page_title'];
         $rss_description = $L['rss_comments_item_desc'];
         $page_args = array('c' => $row['page_cat']);
         if (!empty($row['page_alias'])) {
             $page_args['al'] = $row['page_alias'];
         } else {
             $page_args['id'] = $row['page_id'];
         }
         $sql = $db->query("SELECT c.*, u.user_name\n\t\t\t\t\tFROM {$db_com} AS c\n\t\t\t\t\tLEFT JOIN {$db_users} AS u ON c.com_authorid = u.user_id\n\t\t\t\t\tWHERE com_area = 'page' AND com_code='{$page_id}'\n\t\t\t\t\tORDER BY com_date DESC LIMIT " . $cfg['rss']['rss_maxitems']);
         $i = 0;
         while ($row1 = $sql->fetch()) {
             $items[$i]['title'] = $L['rss_comment_of_user'] . " " . $row1['user_name'];
             $text = cot_parse($row1['com_text'], $cfg['plugin']['comments']['parsebbcodecom']);
             if ((int) $cfg['plugin']['comments']['rss_commentmaxsymbols'] > 0) {
                 $text .= cot_string_truncate($text, $cfg['plugin']['comments']['rss_commentmaxsymbols']) ? '...' : '';
             }
             $items[$i]['description'] = $text;
             $items[$i]['link'] = cot_url('page', $page_args, '#c' . $row1['com_id'], true);
             if (!cot_url_check($items[$i]['link'])) {
                 $items[$i]['link'] = COT_ABSOLUTE_URL . $items[$i]['link'];
             }
             $items[$i]['pubDate'] = cot_date('r', $row1['com_date']);
             $i++;
         }
         // Attach original page text as last item
         $row['page_pageurl'] = cot_url('page', $page_args, '', true);
         $items[$i]['title'] = $L['rss_original'];
         $items[$i]['description'] = cot_parse_page_text($row['page_text'], $row['page_pageurl'], $row['page_parser']);
Пример #10
0
function cot_parse_post_text($post_text)
{
    global $cfg;
    $post_text = cot_parse($post_text, $cfg['forums']['markup']);
    if ((int) $cfg['rss']['rss_postmaxsymbols'] > 0) {
        $post_text = cot_string_truncate($post_text, $cfg['rss']['rss_postmaxsymbols'], true, false, '...');
    }
    return $post_text;
}
Пример #11
0
        $i18n_array = array_merge($i18n_array, array('TITLE' => cot_breadcrumbs(array_merge($pagepath, $page_link), $pagepath_home), 'CATTITLE' => htmlspecialchars($cat_i18n['title']), 'CATPATH' => $catpath, 'CATPATH_SHORT' => cot_rc_link(cot_url('page', 'c=' . $page_data['page_cat'] . $append_param), htmlspecialchars($cat_i18n['title'])), 'CATDESC' => htmlspecialchars($cat_i18n['desc'])));
        if ($admin_rights) {
            $i18n_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
            $i18n_array['ADMIN_EDIT_URL'] = $edit_url;
            $i18n_array['ADMIN_UNVALIDATE'] = $page_data['page_state'] == 1 ? cot_rc_link($validate_url, $L['Validate']) : cot_rc_link($unvalidate_url, $L['Putinvalidationqueue']);
            $i18n_array['ADMIN_UNVALIDATE_URL'] = $page_data['page_state'] == 1 ? $validate_url : $unvalidate_url;
        } else {
            if ($usr['id'] == $page_data['page_ownerid']) {
                $i18n_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
                $i18n_array['ADMIN_EDIT_URL'] = $edit_url;
            }
        }
    } else {
        $cat_i18n =& $structure['page'][$page_data['page_cat']];
    }
    if (!empty($page_data['ipage_title'])) {
        $text = cot_parse($page_data['ipage_text'], $cfg['page']['markup']);
        $text_cut = (int) $textlength > 0 ? cot_string_truncate($text, $textlength) : cot_cut_more($text);
        $cutted = mb_strlen($text) > mb_strlen($text_cut) ? true : false;
        $page_link = array(array(cot_url('page', $urlparams), $page_data['ipage_title']));
        $i18n_array = array_merge($i18n_array, array('URL' => cot_url('page', $urlparams), 'TITLE' => cot_breadcrumbs(array_merge($pagepath, $page_link), $pagepath_home), 'SHORTTITLE' => htmlspecialchars($page_data['ipage_title']), 'DESC' => htmlspecialchars($page_data['ipage_desc']), 'TEXT' => $text, 'TEXT_CUT' => $text_cut, 'TEXT_IS_CUT' => $cutted, 'DESC_OR_TEXT' => !empty($page_data['ipage_desc']) ? htmlspecialchars($page_data['page_desc']) : $text, 'MORE' => $cutted ? cot_rc_link($page_data['page_pageurl'], $L['ReadMore']) : ''));
    }
    //$i18n_array['ADMIN_EDIT'] = '';
    if ($i18n_write) {
        if (!empty($page_data['ipage_id']) && ($i18n_admin || $pag_i18n['ipage_translatorid'] == $usr['id'])) {
            // Edit translation
            $i18n_array['ADMIN_EDIT'] = cot_rc_link(cot_url('plug', "e=i18n&m=page&a=edit&id=" . $page_data['page_id'] . "&l={$i18n_locale}"), $L['Edit']);
        }
    }
    $temp_array = array_merge($temp_array, $i18n_array);
}
Пример #12
0
/**
 * Returns Extra fields data
 *
 * @param string $name Lang row
 * @param array $extrafields Extra fields data
 * @param string $value Existing user value
 * @param string $parser Non-default parser to use
 * @return string
 */
function cot_build_extrafields_data($name, $extrafield, $value, $parser = '')
{
    global $L;
    $parse_type = array('HTML', 'Text');
    switch ($extrafield['field_type']) {
        case 'select':
        case 'radio':
            $value = htmlspecialchars($value);
            return !empty($L[$extrafield['field_name'] . '_' . $value]) ? $L[$extrafield['field_name'] . '_' . $value] : $value;
            break;
        case 'checkbox':
            $value = $value ? 1 : 0;
            return $value;
            break;
        case 'datetime':
            $extrafield['field_params'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_params']);
            list($min, $max, $format) = explode(",", $extrafield['field_params'], 3);
            return empty($format) ? $value : cot_date($format, $value);
            break;
        case 'checklistbox':
            $value = htmlspecialchars($value);
            $value = trim(str_replace(array(' , ', ', ', ' ,'), ',', $value));
            $value = explode(',', $value);
            $sep = !empty($extrafield['field_params']) ? $extrafield['field_params'] : ', ';
            $result = '';
            $i = 0;
            if (is_array($value)) {
                foreach ($value as $k => $v) {
                    if ($i != 0) {
                        $result .= $sep;
                    }
                    $i++;
                    $result .= !empty($L[$extrafield['field_name'] . '_' . $v]) ? $L[$extrafield['field_name'] . '_' . $v] : $v;
                }
            }
            return $result;
            break;
        case 'country':
        case 'file':
        case 'filesize':
            $value = is_null($value) ? '' : $value;
            return $value;
            break;
        case 'input':
        case 'inputint':
        case 'currency':
        case 'double':
        case 'textarea':
        case 'range':
        default:
            $value = is_null($value) ? '' : $value;
            $value = cot_parse($value, $extrafield['field_parse'] == 'Text' ? false : true, $parser);
            return $value;
            break;
    }
}
Пример #13
0
                    $c = $karmaarr[1];
                    $view_url = $karmaarr[0] ? cot_url('page', 'al=' . $karmaarr[0]) : cot_url('page', 'id=' . $row['karma_fp']);
                    $view_title = $L['karma_page'];
                } elseif ($row['karma_locate'] == "com") {
                    $karmaarr = explode(":", $row['karma_al_name']);
                    $view_title = $L['karma_com'];
                    if ($karmaarr[2] == 'page' || empty($karmaarr[2]) && $karmaarr[0]) {
                        // page
                        $c = $karmaarr[1];
                        $view_url = $karmaarr[0] ? cot_url('page', 'al=' . $karmaarr[0], '#c' . $row['com_id']) : cot_url('page', $karmaarr[3], "#c" . $row['com_id']);
                    } elseif ($karmaarr[2] && $karmaarr[3]) {
                        // другой модуль/ плагин
                        $view_url = cot_url($karmaarr[2], $karmaarr[3], '#c' . $row['com_id']);
                    }
                }
                $kr->assign(array("KARMA_USER" => "<a href=\"" . cot_url('users', 'm=details&id=' . $row['user_id'] . '&u=' . $row['user_name']) . "\" target=_blank>" . $row['user_name'] . "</a>", "KARMA_VALUE" => abs($row['karma_value']), "KARMA_CLASS" => $row['karma_value'] < 0 ? "style=\"background:#aa0000\"" : "", "KARMA_TEXT" => cot_parse($row['karma_text']), "KARMA_VIEW_URL" => $view_url, "KARMA_VIEW_TITLE" => $view_title, "KARMA_ADMIN_URL" => cot_url('plug', 'r=karma&act=moderate&fp=' . $row['karma_id'] . '&ku=' . $fp), "KARMA_ADMIN_URL_AJAX" => "OnClick = \"if(confirm('" . $L['Delete'] . "?')){return  ajaxSend({  url: '" . cot_url('plug', 'r=karma&act=moderate&fp=' . $row['karma_id'] . '&ku=' . $fp) . "', divId: 'karma_popup', errMsg: '" . $L['ajaxSenderror'] . "' });}else{return false;} \""));
                if ($cfg['plugin']['karma']['karma_profile']) {
                    $kr->assign(cot_generate_usertags($row, "KARMA_USER_"));
                }
                $kr->parse("MAIN.SHOW.SHOW_ROW");
            }
        }
        $kr->parse("MAIN.SHOW");
        if ($aj) {
            $popup_body .= $kr->text("MAIN.SHOW");
        } else {
            $kr->parse("MAIN");
            $popup_body .= $kr->text("MAIN");
        }
        break;
}
Пример #14
0
    $t->parse('MAIN.POLLS_VIEW');
    $extra = $L['polls_notyetvoted'];
    if ($alreadyvoted) {
        $extra = $votecasted ? $L['polls_votecasted'] : $L['polls_alreadyvoted'];
    }
    $t->assign(array('POLLS_EXTRATEXT' => $extra));
    $t->parse('MAIN.POLLS_EXTRA');
} else {
    $jj = 0;
    $sql = $db->query("SELECT * FROM {$db_polls} WHERE poll_state = 0 AND poll_type = 'index' ORDER BY poll_id DESC");
    /* === Hook - Part1 === */
    $extp = cot_getextplugins('polls.viewall.tags');
    /* ===== */
    foreach ($sql->fetchAll() as $row) {
        $jj++;
        $t->assign(array('POLL_DATE' => cot_date('date_full', $row['poll_creationdate']), 'POLL_DATE_STAMP' => $row['poll_creationdate'], 'POLL_HREF' => cot_url('polls', 'id=' . $row['poll_id']), 'POLL_TEXT' => cot_parse($row['poll_text'], $cfg['polls']['markup']), 'POLL_NUM' => $jj, 'POLL_ODDEVEN' => cot_build_oddeven($jj)));
        /* === Hook - Part2 === */
        foreach ($extp as $pl) {
            include $pl;
        }
        /* ===== */
        $t->parse('MAIN.POLLS_VIEWALL.POLL_ROW');
    }
    if ($jj == 0) {
        $t->parse('MAIN.POLLS_VIEWALL.POLL_NONE');
    }
    $t->parse('MAIN.POLLS_VIEWALL');
}
/* === Hook === */
foreach (cot_getextplugins('polls.tags') as $pl) {
    include $pl;
Пример #15
0
/**
 * Returns all product tags for coTemplate
 *
 * @param mixed $item_data product Info Array or ID
 * @param string $tag_prefix Prefix for tags
 * @param int $textlength Text truncate
 * @param bool $admin_rights product Admin Rights
 * @param bool $pagepath_home Add home link for page path
 * @param string $emptytitle Page title text if page does not exist
 * @return array
 * @global CotDB $db
 */
function cot_generate_markettags($item_data, $tag_prefix = '', $textlength = 0, $admin_rights = null, $pagepath_home = false, $emptytitle = '')
{
    global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_market, $usr, $sys, $cot_yesno, $structure, $db_structure;
    static $extp_first = null, $extp_main = null;
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('markettags.first');
        $extp_main = cot_getextplugins('markettags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    if (!is_array($item_data)) {
        $sql = $db->query("SELECT * FROM {$db_market} WHERE item_id = '" . (int) $item_data . "' LIMIT 1");
        $item_data = $sql->fetch();
    }
    if ($item_data['item_id'] > 0 && !empty($item_data['item_title'])) {
        if (is_null($admin_rights)) {
            $admin_rights = cot_auth('market', $item_data['item_cat'], 'A');
        }
        $item_data['item_pageurl'] = empty($item_data['item_alias']) ? cot_url('market', 'c=' . $item_data['item_cat'] . '&id=' . $item_data['item_id']) : cot_url('market', 'c=' . $item_data['item_cat'] . '&al=' . $item_data['item_alias']);
        $catpatharray[] = array(cot_url('market'), $L['market']);
        $itempatharray[] = array($item_data['item_pageurl'], $item_data['item_title']);
        $patharray = array_merge($catpatharray, cot_structure_buildpath('market', $item_data['item_cat']), $itempatharray);
        $itempath = cot_breadcrumbs($patharray, $pagepath_home, true);
        $patharray = array_merge($catpatharray, cot_structure_buildpath('market', $item_data['item_cat']));
        $catpath = cot_breadcrumbs($patharray, $pagepath_home, true);
        $text = cot_parse($item_data['item_text'], $cfg['market']['markup'], $item_data['item_parser']);
        $text_cut = (int) $textlength > 0 ? cot_string_truncate($text, $textlength) : $text;
        $item_data['item_status'] = cot_market_status($item_data['item_state']);
        $temp_array = array('ID' => $item_data['item_id'], 'ALIAS' => $item_data['item_alias'], 'STATE' => $item_data['item_state'], 'STATUS' => $item_data['item_status'], 'LOCALSTATUS' => $L['market_status_' . $item_data['item_status']], 'URL' => $item_data['item_pageurl'], 'USER_PRDURL' => cot_url('users', 'm=details&id=' . $item_data['item_userid'] . '&u=' . $item_data['user_name'] . '&tab=market'), 'TITLE' => $itempath, 'SHORTTITLE' => $item_data['item_title'], 'CAT' => $item_data['item_cat'], 'CATTITLE' => htmlspecialchars($structure['market'][$item_data['item_cat']]['title']), 'CATURL' => cot_url('market', 'c=' . $item_data['item_cat']), 'CATPATH' => $catpath, 'TEXT' => $text, 'SHORTTEXT' => $text_cut, 'COST' => number_format($item_data['item_cost'], '0', '.', ' '), 'DATE' => cot_date('datetime_medium', $item_data['item_date']), 'DATE_STAMP' => $item_data['item_date'], 'SHOW_URL' => $item_data['item_pageurl'], 'COUNT' => $item_data['item_count'], 'USER_IS_ADMIN' => $admin_rights || $usr['id'] == $item_data['item_userid']);
        if ($admin_rights || $usr['id'] == $item_data['item_userid']) {
            $temp_array['ADMIN_EDIT'] = cot_rc_link(cot_url('market', 'm=edit&id=' . $item_data['item_id']), $L['Edit']);
            $temp_array['ADMIN_EDIT_URL'] = cot_url('market', 'm=edit&id=' . $item_data['item_id']);
            $temp_array['HIDEPRODUCT_URL'] = cot_url('market', 'm=edit&id=' . $item_data['item_id'] . ($item_data['item_state'] == 1 ? '&a=public' : '&a=hide'));
            $temp_array['HIDEPRODUCT_TITLE'] = $item_data['item_state'] == 1 ? $L['Publish'] : $L['Hide'];
        }
        // Extrafields
        if (isset($cot_extrafields[$db_market])) {
            foreach ($cot_extrafields[$db_market] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array[$tag . '_TITLE'] = isset($L['market_' . $exfld['field_name'] . '_title']) ? $L['market_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array[$tag] = cot_build_extrafields_data('market', $exfld, $item_data['item_' . $exfld['field_name']]);
            }
        }
        // Extra fields for structure
        if (isset($cot_extrafields[$db_structure])) {
            foreach ($cot_extrafields[$db_structure] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array['CAT_' . $tag . '_TITLE'] = isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array['CAT_' . $tag] = cot_build_extrafields_data('structure', $exfld, $structure['market'][$item_data['item_cat']][$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;
}
Пример #16
0
/* ===== */
$fp_num = 0;
foreach ($sql_forums->fetchAll() as $row) {
    $row['user_text'] = $cfg['forums']['cat_' . $s]['allowusertext'] ? $row['user_text'] : '';
    $fp_num++;
    $rowquote_url = $usr['id'] > 0 ? cot_url('forums', 'm=posts&s=' . $s . '&q=' . $q . '&quote=' . $row['fp_id'] . '&d=' . $durl . '&n=last', '#np') : '';
    $rowquote = $usr['id'] > 0 ? cot_rc('forums_rowquote', array('url' => $rowquote_url)) : '';
    $rowedit_url = ($usr['isadmin'] || $row['fp_posterid'] == $usr['id'] && ($cfg['forums']['edittimeout'] == '0' || $sys['now'] - $row['fp_creation'] < $cfg['forums']['edittimeout'] * 3600)) && $usr['id'] > 0 ? cot_url('forums', 'm=editpost&s=' . $s . '&q=' . $q . '&p=' . $row['fp_id'] . '&d=' . $durl . '&' . cot_xg()) : '';
    $rowedit = ($usr['isadmin'] || $row['fp_posterid'] == $usr['id'] && ($cfg['forums']['edittimeout'] == '0' || $sys['now'] - $row['fp_creation'] < $cfg['forums']['edittimeout'] * 3600)) && $usr['id'] > 0 ? cot_rc('forums_rowedit', array('url' => $rowedit_url)) : '';
    $rowdelete_url = $usr['id'] > 0 && ($usr['isadmin'] || $row['fp_posterid'] == $usr['id'] && ($cfg['forums']['edittimeout'] == '0' || $sys['now'] - $row['fp_creation'] < $cfg['forums']['edittimeout'] * 3600)) ? cot_confirm_url(cot_url('forums', 'm=posts&a=delete&' . cot_xg() . '&s=' . $s . '&q=' . $q . '&p=' . $row['fp_id'] . '&d=' . $durl), 'forums', 'forums_confirm_delete_post') : '';
    $rowdelete = $usr['id'] > 0 && ($usr['isadmin'] || $row['fp_posterid'] == $usr['id'] && ($cfg['forums']['edittimeout'] == '0' || $sys['now'] - $row['fp_creation'] < $cfg['forums']['edittimeout'] * 3600) && $fp_num > 1) ? cot_rc('forums_rowdelete', array('url' => $rowdelete_url)) : '';
    if (!empty($row['fp_updater'])) {
        $row['fp_updatedby'] = sprintf($L['forums_updatedby'], htmlspecialchars($row['fp_updater']), cot_date('datetime_medium', $row['fp_updated']), cot_build_timegap($row['fp_updated'], $sys['now']));
    }
    $t->assign(cot_generate_usertags($row, 'FORUMS_POSTS_ROW_USER'));
    $t->assign(array('FORUMS_POSTS_ROW_ID' => $row['fp_id'], 'FORUMS_POSTS_ROW_POSTID' => 'post_' . $row['fp_id'], 'FORUMS_POSTS_ROW_IDURL' => cot_url('forums', 'm=posts&id=' . $row['fp_id']), 'FORUMS_POSTS_ROW_URL' => cot_url('forums', 'm=posts&q=' . $row['fp_topicid'] . '&d=' . $durl, "#" . $row['fp_id']), 'FORUMS_POSTS_ROW_CREATION' => cot_date('datetime_medium', $row['fp_creation']), 'FORUMS_POSTS_ROW_CREATION_STAMP' => $row['fp_creation'], 'FORUMS_POSTS_ROW_UPDATED' => cot_date('datetime_medium', $row['fp_updated']), 'FORUMS_POSTS_ROW_UPDATED_STAMP' => $row['fp_updated'], 'FORUMS_POSTS_ROW_UPDATER' => htmlspecialchars($row['fp_updater']), 'FORUMS_POSTS_ROW_UPDATEDBY' => $row['fp_updatedby'], 'FORUMS_POSTS_ROW_TEXT' => cot_parse($row['fp_text'], $cfg['forums']['markup'] && $cfg['forums']['cat_' . $s]['allowbbcodes']), 'FORUMS_POSTS_ROW_ANCHORLINK' => cot_rc('forums_code_post_anchor', array('id' => $row['fp_id'])), 'FORUMS_POSTS_ROW_POSTERNAME' => cot_build_user($row['fp_posterid'], htmlspecialchars($row['fp_postername'])), 'FORUMS_POSTS_ROW_POSTERID' => $row['fp_posterid'], 'FORUMS_POSTS_ROW_POSTERIP' => $usr['isadmin'] ? cot_build_ipsearch($row['fp_posterip']) : '', 'FORUMS_POSTS_ROW_DELETE' => $rowdelete, 'FORUMS_POSTS_ROW_DELETE_URL' => $rowdelete_url, 'FORUMS_POSTS_ROW_EDIT' => $rowedit, 'FORUMS_POSTS_ROW_EDIT_URL' => $rowedit_url, 'FORUMS_POSTS_ROW_QUOTE' => $rowquote, 'FORUMS_POSTS_ROW_QUOTE_URL' => $rowquote_url, 'FORUMS_POSTS_ROW_BOTTOM' => (empty($id) ? $d + $fp_num : $id) == $totalposts ? $R['forums_code_bottom'] : ($usr['id'] > 0 && $n == 'unread' && $row['fp_creation'] > $usr['lastvisit'] ? $R['forums_code_unread'] : ''), 'FORUMS_POSTS_ROW_ODDEVEN' => cot_build_oddeven($fp_num), 'FORUMS_POSTS_ROW_NUM' => $fp_num, 'FORUMS_POSTS_ROW_ORDER' => empty($id) ? $d + $fp_num : $id));
    foreach ($cot_extrafields[$db_forum_posts] as $exfld) {
        $tag = mb_strtoupper($exfld['field_name']);
        $t->assign(array('FORUMS_POSTS_ROW_' . $tag . '_TITLE' => isset($L['forums_posts_' . $exfld['field_name'] . '_title']) ? $L['forums_posts_' . $exfld['field_name'] . '_title'] : $exfld['field_description'], 'FORUMS_POSTS_ROW_' . $tag => cot_build_extrafields_data('forums', $exfld, $row['fp_' . $exfld['field_name']], $cfg['forums']['markup'] && $cfg['forums']['cat_' . $s]['allowbbcodes']), 'FORUMS_POSTS_ROW_' . $tag . '_VALUE' => $row['fp_' . $exfld['field_name']]));
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.FORUMS_POSTS_ROW');
}
$lastpage = $d + $cfg['forums']['maxpostsperpage'] < $totalposts ? FALSE : TRUE;
$pagenav = cot_pagenav('forums', "m=posts&q={$q}", $d, $totalposts, $cfg['forums']['maxpostsperpage']);
$jumpbox[cot_url('forums')] = $L['Forums'];
foreach ($structure['forums'] as $key => $val) {
Пример #17
0
 if (empty($text)) {
     $text = $advert->text;
 }
 $user = null;
 $userLang = cot::$cfg['defaultlang'];
 $owner = $advert->getOwner();
 if ($owner['user_id'] > 0) {
     if (cot::$cfg['defaultlang'] != $owner['user_lang']) {
         $userLang = $owner['user_lang'];
         include cot_langfile('main', 'core', cot::$cfg['defaultlang'], $owner['user_lang']);
         include cot_langfile('advboard', 'module', cot::$cfg['defaultlang'], $owner['user_lang']);
     }
 }
 // Выдержка с поста
 //        $len_cut = 500;  // Длина выдержки с поста (символов)
 $advComText = cot_parse($comarray['com_text'], cot::$cfg['plugin']['comments']['markup']);
 //        $advComText = cot_string_truncate($advComText, $len_cut, true, false, '...');
 // /Выдержка с поста
 // Автор комментария
 $advCommenterName = cot::$L['Anonymous'];
 $advCommenterUrl = '';
 if (cot::$usr['id'] > 0) {
     $advCommenterName = cot_user_full_name(cot::$usr['profile']);
     $advCommenterUrl = cot_url('users', array('m' => 'details', 'id' => cot::$usr['id'], 'u' => htmlspecialchars(cot::$usr['name'])));
     if (!cot_url_check($advCommenterUrl)) {
         $advCommenterUrl = COT_ABSOLUTE_URL . $advCommenterUrl;
     }
 } elseif ($comarray['com_author'] != '') {
     $advCommenterName = $comarray['com_author'];
 }
 // /Автор комментария
Пример #18
0
/**
 * Renders user signature text
 *
 * @param string $text Signature text
 * @return string
 */
function cot_build_usertext($text)
{
    global $cfg;
    return cot_parse($text, $cfg['users']['usertextimg']);
}
Пример #19
0
<?php

/* ====================
[BEGIN_COT_EXT]
Hooks=ajax
[END_COT_EXT]
==================== */
/**
 * Simple AJAX previewer for MarkItUp!
 *
 * @package MarItUp
 * @copyright (c) Cotonti Team
 * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt
 */
defined('COT_CODE') or die('Wrong URL');
// Preview contents
$text = cot_import('text', 'P', 'HTM');
$style = '<link rel="stylesheet" type="text/css" href="' . $cfg['themes_dir'] . '/' . $theme . '/' . $theme . '.css" />' . "\n";
cot_sendheaders();
echo $style . '<body class="preview">' . cot_parse($text) . '</body>';
Пример #20
0
                $cache->db->store('update_info', $update_info, COT_DEFAULT_REALM, 86400);
            }
        } elseif (function_exists('curl_init')) {
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, 'http://www.cotonti.com/update-check');
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
            $update_info = curl_exec($curl);
            if ($update_info) {
                $update_info = json_decode($update_info, TRUE);
                $cache->db->store('update_info', $update_info, COT_DEFAULT_REALM, 86400);
            }
            curl_close($curl);
        }
    }
    if ($update_info['update_ver'] > $cfg['version']) {
        $t->assign(array('ADMIN_HOME_UPDATE_REVISION' => sprintf($L['home_update_revision'], $cfg['version'], htmlspecialchars($update_info['update_ver'])), 'ADMIN_HOME_UPDATE_MESSAGE' => cot_parse($update_info['update_message'])));
        $t->parse('MAIN.UPDATE');
    }
}
$sql = $db->query("SHOW TABLES");
foreach ($sql->fetchAll(PDO::FETCH_NUM) as $row) {
    $table_name = $row[0];
    $status = $db->query("SHOW TABLE STATUS LIKE '{$table_name}'");
    $status1 = $status->fetch();
    $status->closeCursor();
    $tables[] = $status1;
}
foreach ($tables as $dat) {
    $table_length = $dat['Index_length'] + $dat['Data_length'];
    $total_length += $table_length;
    $total_rows += $dat['Rows'];
Пример #21
0
/**
 * Generates Poll form
 *
 * @param int $id Poll ID or Poll Code if $type is not epmty
 * @param string $formlink Poll form url
 * @param string $theme Poll template name
 * @param string $type Poll type
 * @return array
 * @global CotDB $db
 */
function cot_poll_form($id, $formlink = '', $theme = '', $type = '')
{
    global $db, $cfg, $db_polls, $db_polls_options, $db_polls_voters, $usr;
    $canvote = false;
    if (!is_array($id)) {
        $id = (int) $id;
        $where = !$type ? "poll_id = {$id}" : "poll_type = '" . $db->prep($type) . "' AND poll_code = '{$id}'";
        $sql = $db->query("SELECT * FROM {$db_polls} WHERE {$where} LIMIT 1");
        if (!($row = $sql->fetch())) {
            return false;
        }
    } else {
        $row = $id;
    }
    $id = $row['poll_id'];
    $alreadyvoted = 0;
    if ($cfg['polls']['ip_id_polls'] == 'id' && $usr['id'] > 0) {
        $where = "pv_userid = '" . $usr['id'] . "'";
        $canvote = true;
    } else {
        $where = $usr['id'] > 0 ? "(pv_userid = '" . $usr['id'] . "' OR pv_userip = '" . $usr['ip'] . "')" : "pv_userip = '" . $usr['ip'] . "'";
        $canvote = true;
    }
    $sql2 = $db->query("SELECT pv_id FROM {$db_polls_voters} WHERE pv_pollid = {$id} AND {$where} LIMIT 1");
    $alreadyvoted = $sql2->rowCount() == 1 ? 1 : 0;
    $themefile = cot_tplfile(array('polls', $theme), 'module');
    $t = new XTemplate($themefile);
    if ($alreadyvoted) {
        $poll_block = 'POLL_VIEW_VOTED';
    } elseif (!$canvote) {
        $poll_block = 'POLL_VIEW_DISABLED';
    } elseif ($row['poll_state']) {
        $poll_block = 'POLL_VIEW_LOCKED';
    } else {
        $poll_block = 'POLL_VIEW';
    }
    $sql2 = $db->query("SELECT SUM(po_count) FROM {$db_polls_options} WHERE po_pollid = {$id}");
    $totalvotes = $sql2->fetchColumn();
    $sql1 = $db->query("SELECT po_id, po_text, po_count FROM {$db_polls_options} WHERE po_pollid = {$id} ORDER by po_id ASC");
    while ($row1 = $sql1->fetch()) {
        $po_id = $row1['po_id'];
        $po_count = $row1['po_count'];
        $percent = @round(100 * ($po_count / $totalvotes), 1);
        $input_type = $row['poll_multiple'] ? 'checkbox' : 'radio';
        $polloptions_input = $alreadyvoted || !$canvote ? "" : '<input type="' . $input_type . '" name="vote[]" value="' . $po_id . '" />&nbsp;';
        // TODO - to resorses
        $polloptions = cot_parse($row1['po_text'], $cfg['polls']['markup']);
        $t->assign(array('POLL_OPTIONS' => $polloptions, 'POLL_PER' => $percent, 'POLL_COUNT' => $po_count, 'POLL_INPUT' => $polloptions_input));
        $t->parse($poll_block . ".POLLTABLE");
    }
    $sql1->closeCursor();
    $t->assign(array('POLL_VOTERS' => $totalvotes, 'POLL_SINCE' => cot_date('datetime_medium', $row['poll_creationdate']), 'POLL_SINCE_STAMP' => $row['poll_creationdate'], 'POLL_SINCE_SHORT' => cot_date('date_short', $row['poll_creationdate']), 'POLL_TITLE' => cot_parse($row['poll_text'], $cfg['polls']['markup']), 'POLL_ID' => $id, 'POLL_FORM_URL' => empty($formlink) ? cot_url('polls', 'id=' . $id) : $formlink, 'POLL_FORM_BUTTON' => $pollbutton));
    $t->parse($poll_block);
    $row['poll_alreadyvoted'] = $alreadyvoted;
    $row['poll_count'] = $totalvotes;
    $row['poll_block'] = $t->text($poll_block);
    return $row;
}
Пример #22
0
    if (!empty($c) && isset($structure['folio'][$c])) {
        $mtch = $structure['folio'][$c]['path'] . ".";
        $mtchlen = mb_strlen($mtch);
        $catsub = array();
        $catsub[] = $c;
        foreach ($structure['folio'] as $i => $x) {
            if (mb_substr($x['path'], 0, $mtchlen) == $mtch) {
                $catsub[] = $i;
            }
        }
        $sqllist = $db->query("SELECT p.*, u.* FROM {$db_folio} AS p\n\t\t\t\tLEFT JOIN {$db_users} AS u ON p.item_userid = u.user_id\n\t\t\tWHERE item_state=0 AND item_cat IN ('" . implode("','", $catsub) . "') \n\t\t\tORDER BY item_date DESC LIMIT " . $cfg['rss']['rss_maxitems']);
    } else {
        $sqllist = $db->query("SELECT p.*, u.* FROM {$db_folio} AS p\n\t\t\t\tLEFT JOIN {$db_users} AS u ON p.item_userid = u.user_id\n\t\t\tWHERE item_state=0 \n\t\t\tORDER BY item_date DESC LIMIT " . $cfg['rss']['rss_maxitems']);
    }
    $i = 0;
    $sqllist_rowset = $sqllist->fetchAll();
    $sqllist_idset = array();
    foreach ($sqllist_rowset as $item) {
        $sqllist_idset[$item['item_id']] = $item['item_alias'];
    }
    foreach ($sqllist_rowset as $row) {
        $row['item_pageurl'] = empty($row['item_alias']) ? cot_url('folio', 'c=' . $row['item_cat'] . '&id=' . $row['item_id'], '', true) : cot_url('folio', 'c=' . $row['item_cat'] . '&al=' . $row['item_alias'], '', true);
        $items[$i]['title'] = $row['item_title'];
        $items[$i]['link'] = COT_ABSOLUTE_URL . $row['item_pageurl'];
        $items[$i]['pubDate'] = cot_date('r', $row['item_date']);
        $items[$i]['description'] = cot_parse($row['item_text']);
        $items[$i]['fields'] = cot_generate_foliotags($row);
        $i++;
    }
    $sqllist->closeCursor();
}
Пример #23
0
             cot_redirect(cot_url('plug', "e=i18n&m=page&a=edit&id={$id}&l={$i18n_locale}", '', true));
             exit;
         }
         $db->update($db_i18n_pages, $pag_i18n, "ipage_id = ? AND ipage_locale = ?", array($id, $i18n_locale));
         /* === Hook === */
         foreach (cot_getextplugins('i18n.page.edit.update') as $pl) {
             include $pl;
         }
         /* =============*/
         cot_message('Updated');
         $page_urlp = empty($pag['page_alias']) ? 'c=' . $pag['page_cat'] . "&id={$id}&l={$i18n_locale}" : 'c=' . $pag['page_cat'] . '&al=' . $pag['page_alias'] . '&l=' . $i18n_locale;
         cot_redirect(cot_url('page', $page_urlp, '', true, false, true));
     }
     $out['subtitle'] = $L['i18n_editing'];
     $t = new XTemplate(cot_tplfile('i18n.page', 'plug'));
     $t->assign(array('I18N_ACTION' => cot_url('plug', "e=i18n&m=page&a=edit&id={$id}&l={$i18n_locale}"), 'I18N_TITLE' => $L['i18n_editing'], 'I18N_ORIGINAL_LANG' => $i18n_locales[$cfg['defaultlang']], 'I18N_LOCALIZED_LANG' => $i18n_locales[$i18n_locale], 'I18N_PAGE_TITLE' => htmlspecialchars($pag['page_title']), 'I18N_PAGE_DESC' => htmlspecialchars($pag['page_desc']), 'I18N_PAGE_TEXT' => cot_parse($pag['page_text'], $cfg['page']['markup']), 'I18N_IPAGE_TITLE' => htmlspecialchars($pag_i18n['ipage_title']), 'I18N_IPAGE_DESC' => htmlspecialchars($pag_i18n['ipage_desc']), 'I18N_IPAGE_TEXT' => cot_textarea('translate_text', $pag_i18n['ipage_text'], 32, 80, '', 'input_textarea_editor')));
     cot_display_messages($t);
     /* === Hook === */
     foreach (cot_getextplugins('i18n.page.edit.tags') as $pl) {
         include $pl;
     }
     /* =============*/
 } elseif ($a == 'delete' && ($i18n_admin || $usr['id'] == $pag['ipage_translatorid'])) {
     // Send to trashcan if available
     if ($cfg['plugin']['trashcan']['trash_page']) {
         require_once cot_incfile('trashcan', 'plug');
         $row = $db->query("SELECT * FROM {$db_i18n_pages}\n\t\t\t\tWHERE ipage_id = {$id} AND ipage_locale = '{$i18n_locale}'")->fetch();
         cot_trash_put('i18n_page', $L['i18n_translation'] . " #{$id} ({$i18n_locale}) " . $row['ipage_title'], $id, $row);
     }
     $db->delete($db_i18n_pages, "ipage_id = {$id} AND ipage_locale = '{$i18n_locale}'");
     /* === Hook === */
Пример #24
0
 */
defined('COT_CODE') or die('Wrong URL');
if ($cfg['polls']['maxpolls'] > 0) {
    require_once cot_incfile('polls', 'module');
    cot_poll_vote();
    $indexpolls = new XTemplate(cot_tplfile(array('polls', 'index'), false));
    $sqlmode = $cfg['polls']['mode'] == 'Recent polls' ? 'poll_creationdate DESC' : 'RAND()';
    $res = 0;
    $sql_polls = $db->query("SELECT * FROM {$db_polls} WHERE poll_type='index' AND poll_state='0' ORDER by {$sqlmode} LIMIT " . $cfg['polls']['maxpolls']);
    /* === Hook - Part1 === */
    $extp = cot_getextplugins('polls.index.tags');
    /* ===== */
    foreach ($sql_polls->fetchAll() as $row_p) {
        $res++;
        $poll_form = cot_poll_form($row_p, cot_url('index', ''), 'index');
        $indexpolls->assign(array('IPOLLS_ID' => $row_p['poll_id'], 'IPOLLS_TITLE' => cot_parse($row_p['poll_text'], $cfg['polls']['markup']), 'IPOLLS_URL' => cot_url('polls', 'id=' . $row_p['poll_id']), 'IPOLLS_FORM' => $poll_form['poll_block']));
        /* === Hook - Part2 === */
        foreach ($extp as $pl) {
            include $pl;
        }
        /* ===== */
        $indexpolls->parse('INDEXPOLLS.POLL');
    }
    $indexpolls->assign('IPOLLS_ALL', cot_url('polls', 'id=viewall'));
    if (!$res) {
        $indexpolls->assign('IPOLLS_ERROR', $L['None']);
        $indexpolls->parse('INDEXPOLLS.ERROR');
    }
    $indexpolls->parse('INDEXPOLLS');
    $t->assign('INDEX_POLLS', $indexpolls->text('INDEXPOLLS'));
}