예제 #1
0
    if (!empty(cot::$extrafields[cot::$db->contact])) {
        foreach (cot::$extrafields[cot::$db->contact] as $exfld) {
            $tag = mb_strtoupper($exfld['field_name']);
            $exfld_val = cot_build_extrafields_data('contact', $exfld, $row['contact_' . $exfld['field_name']]);
            $exfld_title = cot_extrafield_title($exfld, 'contact_');
            $tuman->assign(array('CONTACT_' . $tag . '_TITLE' => $exfld_title, 'CONTACT_' . $tag => $exfld_val, 'CONTACT_' . $tag . '_VALUE' => $row['contact_' . $exfld['field_name']], 'CONTACT_EXTRAFLD_TITLE' => $exfld_title, 'CONTACT_EXTRAFLD' => $exfld['field_type'] == 'file' ? cot_rc_link($cfg['extrafield_files_dir'] . '/' . $exfld_val, $exfld_val) : $exfld_val, 'CONTACT_EXTRAFLD_VALUE' => $row['contact_' . $exfld['field_name']]));
            $tuman->parse('MAIN.DATA.EXTRAFLD');
        }
    }
    $tuman->parse('MAIN.DATA');
}
$sql->closeCursor();
if ($a == '' && !empty($id)) {
    $row = $db->query("SELECT * FROM " . cot::$db->contact . " WHERE contact_id = {$id}")->fetch();
    $tuman->assign(array('CONTACT_DATE' => cot_date('date_full', $row['contact_date']), 'CONTACT_DATE_STAMP' => $row['contact_date'], 'CONTACT_USER' => $row['contact_authorid'] > 0 ? cot_build_user($row['contact_authorid'], $row['contact_author']) : $row['contact_author'], 'CONTACT_EMAIL' => $row['contact_email'], 'CONTACT_ID' => $row['contact_id'], 'CONTACT_DELLINK' => cot_url('admin', 'm=other&p=contact&a=del&id=' . $row['contact_id']), 'CONTACT_VAL' => $row['contact_val'] == 1 ? 'unval' : 'val', 'CONTACT_VALLINK' => cot_url('admin', 'm=other&p=contact&a=' . $val . '&id=' . $row['contact_id']), 'CONTACT_READLINK' => cot_url('admin', 'm=other&p=contact&a=val&id=' . $row['contact_id']), 'CONTACT_UNREADLINK' => cot_url('admin', 'm=other&p=contact&a=unval&id=' . $row['contact_id']), 'CONTACT_SUBJECT' => $row['contact_subject'], 'CONTACT_TEXT' => $row['contact_text'], 'CONTACT_REPLY' => $row['contact_reply'], 'CONTACT_FORM_SEND' => cot_url("admin", 'm=other&p=contact&a=send&id=' . $row['contact_id']), 'CONTACT_FORM_TEXT' => cot_textarea('rtext', $rtext, 8, 64)));
    // Extrafields
    if (!empty(cot::$extrafields[cot::$db->contact])) {
        foreach (cot::$extrafields[cot::$db->contact] as $exfld) {
            $tag = mb_strtoupper($exfld['field_name']);
            $exfld_val = cot_build_extrafields_data('contact', $exfld, $row['contact_' . $exfld['field_name']]);
            $exfld_title = cot_extrafield_title($exfld, 'contact_');
            $tuman->assign(array('CONTACT_' . $tag . '_TITLE' => $exfld_title, 'CONTACT_' . $tag => $exfld_val, 'CONTACT_' . $tag . '_VALUE' => $row['contact_' . $exfld['field_name']], 'CONTACT_EXTRAFLD_TITLE' => $exfld_title, 'CONTACT_EXTRAFLD' => $exfld['field_type'] == 'file' ? cot_rc_link($cfg['extrafield_files_dir'] . '/' . $exfld_val, $exfld_val) : $exfld_val, 'CONTACT_EXTRAFLD_VALUE' => $row['contact_' . $exfld['field_name']]));
            $tuman->parse('MAIN.VIEW.EXTRAFLD');
        }
    }
    $tuman->parse('MAIN.VIEW');
}
cot_display_messages($tuman);
$tuman->assign(array('CONTACT_PAGINATION' => $pagnav['main'], 'CONTACT_PREV' => $pagenav['prev'], 'CONTACT_NEXT' => $pagenav['next']));
$tuman->parse('MAIN');
$plugin_body .= $tuman->text('MAIN');
예제 #2
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;
}
예제 #3
0
/* === Hook === */
foreach (cot_getextplugins('users.register.main') as $pl) {
    include $pl;
}
/* ===== */
$out['subtitle'] = $L['aut_registertitle'];
$out['head'] .= $R['code_noindex'];
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
require_once cot_incfile('forms');
$t->assign(array('USERS_REGISTER_TITLE' => $L['aut_registertitle'], 'USERS_REGISTER_SUBTITLE' => $L['aut_registersubtitle'], 'USERS_REGISTER_ADMINEMAIL' => $cot_adminemail, 'USERS_REGISTER_SEND' => cot_url('users', 'm=register&a=add'), 'USERS_REGISTER_USER' => cot_inputbox('text', 'rusername', $ruser['user_name'], array('size' => 24, 'maxlength' => 100)), 'USERS_REGISTER_EMAIL' => cot_inputbox('text', 'ruseremail', $ruser['user_email'], array('size' => 24, 'maxlength' => 64)), 'USERS_REGISTER_PASSWORD' => cot_inputbox('password', 'rpassword1', '', array('size' => 12, 'maxlength' => 32)), 'USERS_REGISTER_PASSWORDREPEAT' => cot_inputbox('password', 'rpassword2', '', array('size' => 12, 'maxlength' => 32)), 'USERS_REGISTER_COUNTRY' => cot_selectbox_countries($ruser['user_country'], 'rcountry'), 'USERS_REGISTER_TIMEZONE' => cot_selectbox_timezone($ruser['user_timezone'], 'rusertimezone'), 'USERS_REGISTER_GENDER' => cot_selectbox_gender($ruser['user_gender'], 'rusergender'), 'USERS_REGISTER_BIRTHDATE' => cot_selectbox_date(0, 'short', 'ruserbirthdate', cot_date('Y', $sys['now']), cot_date('Y', $sys['now']) - 100, false)));
// Extra fields
if (!empty(cot::$extrafields[cot::$db->users])) {
    foreach (cot::$extrafields[cot::$db->users] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $exfld_val = cot_build_extrafields('ruser' . $exfld['field_name'], $exfld, $ruser['user_' . $exfld['field_name']]);
        $exfld_title = cot_extrafield_title($exfld, 'user_');
        $t->assign(array('USERS_REGISTER_' . $uname => $exfld_val, 'USERS_REGISTER_' . $uname . '_TITLE' => $exfld_title, 'USERS_REGISTER_EXTRAFLD' => $exfld_val, 'USERS_REGISTER_EXTRAFLD_TITLE' => $exfld_title));
        $t->parse('MAIN.EXTRAFLD');
    }
}
/* === Hook === */
foreach (cot_getextplugins('users.register.tags') as $pl) {
    include $pl;
}
/* ===== */
// Error and message handling
cot_display_messages($t);
$t->parse('MAIN');
$t->out('MAIN');
require_once cot::$cfg['system_dir'] . '/footer.php';
예제 #4
0
파일: page.add.php 프로젝트: Roffun/Cotonti
$mskin = cot_tplfile(array('page', 'add', $structure['page'][$rpage['page_cat']]['tpl']));
/* === Hook === */
foreach (cot_getextplugins('page.add.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate($mskin);
$pageadd_array = array('PAGEADD_PAGETITLE' => $L['page_addtitle'], 'PAGEADD_SUBTITLE' => $L['page_addsubtitle'], 'PAGEADD_ADMINEMAIL' => "mailto:" . $cfg['adminemail'], 'PAGEADD_FORM_SEND' => cot_url('page', 'm=add&a=add&c=' . $c), 'PAGEADD_FORM_CAT' => cot_selectbox_structure('page', $rpage['page_cat'], 'rpagecat'), 'PAGEADD_FORM_CAT_SHORT' => cot_selectbox_structure('page', $rpage['page_cat'], 'rpagecat', $c), 'PAGEADD_FORM_KEYWORDS' => cot_inputbox('text', 'rpagekeywords', $rpage['page_keywords'], array('size' => '32', 'maxlength' => '255')), 'PAGEADD_FORM_METATITLE' => cot_inputbox('text', 'rpagemetatitle', $rpage['page_metatitle'], array('size' => '64', 'maxlength' => '255')), 'PAGEADD_FORM_METADESC' => cot_textarea('rpagemetadesc', $rpage['page_metadesc'], 2, 64, array('maxlength' => '255')), 'PAGEADD_FORM_ALIAS' => cot_inputbox('text', 'rpagealias', $rpage['page_alias'], array('size' => '32', 'maxlength' => '255')), 'PAGEADD_FORM_TITLE' => cot_inputbox('text', 'rpagetitle', $rpage['page_title'], array('size' => '64', 'maxlength' => '255')), 'PAGEADD_FORM_DESC' => cot_textarea('rpagedesc', $rpage['page_desc'], 2, 64, array('maxlength' => '255')), 'PAGEADD_FORM_AUTHOR' => cot_inputbox('text', 'rpageauthor', $rpage['page_author'], array('size' => '24', 'maxlength' => '100')), 'PAGEADD_FORM_OWNER' => cot_build_user($usr['id'], htmlspecialchars($usr['name'])), 'PAGEADD_FORM_OWNERID' => $usr['id'], 'PAGEADD_FORM_DATE' => cot_selectbox_date($sys['now'], 'long', 'rpagedate'), 'PAGEADD_FORM_BEGIN' => cot_selectbox_date($sys['now'], 'long', 'rpagebegin'), 'PAGEADD_FORM_EXPIRE' => cot_selectbox_date(0, 'long', 'rpageexpire'), 'PAGEADD_FORM_FILE' => cot_selectbox($rpage['page_file'], 'rpagefile', range(0, 2), array($L['No'], $L['Yes'], $L['Members_only']), false), 'PAGEADD_FORM_URL' => cot_inputbox('text', 'rpageurl', $rpage['page_url'], array('size' => '56', 'maxlength' => '255')), 'PAGEADD_FORM_SIZE' => cot_inputbox('text', 'rpagesize', $rpage['page_size'], array('size' => '56', 'maxlength' => '255')), 'PAGEADD_FORM_TEXT' => cot_textarea('rpagetext', $rpage['page_text'], 24, 120, '', 'input_textarea_editor'), 'PAGEADD_FORM_PARSER' => cot_selectbox($cfg['page']['parser'], 'rpageparser', $parser_list, $parser_list, false));
$t->assign($pageadd_array);
// Extra fields
if (!empty(cot::$extrafields[cot::$db->pages])) {
    foreach (cot::$extrafields[cot::$db->pages] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $exfld_val = cot_build_extrafields('rpage' . $exfld['field_name'], $exfld, $rpage['page_' . $exfld['field_name']]);
        $exfld_title = cot_extrafield_title($exfld, 'page_');
        $t->assign(array('PAGEADD_FORM_' . $uname => $exfld_val, 'PAGEADD_FORM_' . $uname . '_TITLE' => $exfld_title, 'PAGEADD_FORM_EXTRAFLD' => $exfld_val, 'PAGEADD_FORM_EXTRAFLD_TITLE' => $exfld_title));
        $t->parse('MAIN.EXTRAFLD');
    }
}
// Error and message handling
cot_display_messages($t);
/* === Hook === */
foreach (cot_getextplugins('page.add.tags') as $pl) {
    include $pl;
}
/* ===== */
if (cot::$usr['isadmin']) {
    if (cot::$cfg['page']['autovalidate']) {
        $usr_can_publish = TRUE;
    }
예제 #5
0
/* ===== */
foreach ($subcat as $x) {
    $kk++;
    $cat_childs = cot_structure_children('page', $x);
    $sub_count = 0;
    foreach ($cat_childs as $cat_child) {
        $sub_count += (int) $structure['page'][$cat_child]['count'];
    }
    $sub_url_path = $list_url_path;
    $sub_url_path['c'] = $x;
    $t->assign(array('LIST_ROWCAT_ID' => $structure['page'][$x]['id'], 'LIST_ROWCAT_URL' => cot_url('page', $sub_url_path), 'LIST_ROWCAT_TITLE' => $structure['page'][$x]['title'], 'LIST_ROWCAT_DESC' => $structure['page'][$x]['desc'], 'LIST_ROWCAT_ICON' => $structure['page'][$x]['icon'], 'LIST_ROWCAT_COUNT' => $sub_count, 'LIST_ROWCAT_ODDEVEN' => cot_build_oddeven($kk), 'LIST_ROWCAT_NUM' => $kk));
    // Extra fields for structure
    if (!empty(cot::$extrafields[cot::$db->structure])) {
        foreach (cot::$extrafields[cot::$db->structure] as $exfld) {
            $uname = strtoupper($exfld['field_name']);
            $exfld_title = cot_extrafield_title($exfld, 'structure_');
            $t->assign(array('LIST_ROWCAT_' . $uname . '_TITLE' => $exfld_title, 'LIST_ROWCAT_' . $uname => cot_build_extrafields_data('structure', $exfld, cot::$structure['page'][$x][$exfld['field_name']]), 'LIST_ROWCAT_' . $uname . '_VALUE' => cot::$structure['page'][$x][$exfld['field_name']]));
        }
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.LIST_ROWCAT');
}
$pagenav_cat = cot_pagenav('page', $list_url_path + array('d' => $durl), $dc, count($allsub), cot::$cfg['page']['maxlistsperpage'], 'dc');
$t->assign(array('LISTCAT_PAGEPREV' => $pagenav_cat['prev'], 'LISTCAT_PAGENEXT' => $pagenav_cat['next'], 'LISTCAT_PAGNAV' => $pagenav_cat['main']));
$jj = 0;
/* === Hook - Part1 : Set === */
$extp = cot_getextplugins('page.list.loop');
예제 #6
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 (!empty(cot::$extrafields[cot::$db->users])) {
                foreach (cot::$extrafields[cot::$db->users] as $exfld) {
                    $exfld_title = cot_extrafield_title($exfld, 'user_');
                    $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'] = $exfld_title;
                    $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;
}
예제 #7
0
    // Extra fields
    if (!empty(cot::$extrafields[cot::$db->forum_topics])) {
        foreach (cot::$extrafields[cot::$db->forum_topics] as $exfld) {
            $uname = strtoupper($exfld['field_name']);
            $exfld_val = cot_build_extrafields('rtopic' . $exfld['field_name'], $exfld, $rowt['ft_' . $exfld['field_name']]);
            $exfld_title = cot_extrafield_title($exfld, 'forums_topic_');
            $t->assign(array('FORUMS_EDITPOST_TOPIC_' . $uname => $exfld_val, 'FORUMS_EDITPOST_TOPIC_' . $uname . '_TITLE' => $exfld_title, 'FORUMS_EDITPOST_TOPIC_EXTRAFLD' => $exfld_val, 'FORUMS_EDITPOST_TOPIC_EXTRAFLD_TITLE' => $exfld_title));
            $t->parse('MAIN.FORUMS_EDITPOST_FIRSTPOST.TOPIC_EXTRAFLD');
        }
    }
    $t->parse('MAIN.FORUMS_EDITPOST_FIRSTPOST');
}
$t->assign(array('FORUMS_EDITPOST_PAGETITLE' => $toptitle, 'FORUMS_EDITPOST_SUBTITLE' => $L['forums_postedby'] . ": <a href=\"users.php?m=details&id=" . $rowpost['fp_posterid'] . "\">" . $rowpost['fp_postername'] . "</a> @ " . cot_date('datetime_medium', $rowpost['fp_updated']), 'FORUMS_EDITPOST_UPDATED' => cot_date('datetime_medium', $rowpost['fp_updated']), 'FORUMS_EDITPOST_UPDATED_STAMP' => $rowpost['fp_updated'], 'FORUMS_EDITPOST_SEND' => cot_url('forums', "m=editpost&a=update&s=" . $s . "&q=" . $q . "&p=" . $p . '&d=' . $durl . "&" . cot_xg()), 'FORUMS_EDITPOST_TEXT' => cot_textarea('rmsgtext', $rowpost['fp_text'], 20, 56, '', 'input_textarea_' . $minimaxieditor), 'FORUMS_EDITPOST_EDITTIMEOUT' => cot_build_timegap(0, $cfg['forums']['edittimeout'] * 3600)));
// Extra fields
if (!empty(cot::$extrafields[cot::$db->forum_posts])) {
    foreach (cot::$extrafields[cot::$db->forum_posts] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $exfld_val = cot_build_extrafields('rmsg' . $exfld['field_name'], $exfld, $rowpost['fp_' . $exfld['field_name']]);
        $exfld_title = cot_extrafield_title($exfld, 'forums_post_');
        $t->assign(array('FORUMS_EDITPOST_' . $uname => $exfld_val, 'FORUMS_EDITPOST_' . $uname . '_TITLE' => $exfld_title, 'FORUMS_EDITPOST_EXTRAFLD' => $exfld_val, 'FORUMS_EDITPOST_EXTRAFLD_TITLE' => $exfld_title));
        $t->parse('MAIN.EXTRAFLD');
    }
}
/* === Hook === */
foreach (cot_getextplugins('forums.editpost.tags') as $pl) {
    include $pl;
}
/* ===== */
$t->parse('MAIN');
$t->out('MAIN');
require_once $cfg['system_dir'] . '/footer.php';
예제 #8
0
// Extra fields
if (!empty(cot::$extrafields[cot::$db->forum_posts])) {
    foreach (cot::$extrafields[cot::$db->forum_posts] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $exfld_val = cot_build_extrafields('rmsg' . $exfld['field_name'], $exfld, $rmsg['fp_' . $exfld['field_name']]);
        $exfld_title = cot_extrafield_title($exfld, 'forums_post_');
        $t->assign(array('FORUMS_NEWTOPIC_' . $uname => $exfld_val, 'FORUMS_NEWTOPIC_' . $uname . '_TITLE' => $exfld_title, 'FORUMS_NEWTOPIC_EXTRAFLD' => $exfld_val, 'FORUMS_NEWTOPIC_EXTRAFLD_TITLE' => $exfld_title));
        $t->parse('MAIN.EXTRAFLD');
    }
}
// Extra fields
if (!empty(cot::$extrafields[cot::$db->forum_topics])) {
    foreach (cot::$extrafields[cot::$db->forum_topics] as $exfld) {
        $uname = strtoupper($exfld['field_name']);
        $exfld_val = cot_build_extrafields('rtopic' . $exfld['field_name'], $exfld, $rtopic['ft_' . $exfld['field_name']]);
        $exfld_title = cot_extrafield_title($exfld, 'forums_topic_');
        $t->assign(array('FORUMS_NEWTOPIC_TOPIC_' . $uname => $exfld_val, 'FORUMS_NEWTOPIC_TOPIC_' . $uname . '_TITLE' => $exfld_title, 'FORUMS_NEWTOPIC_TOPIC_EXTRAFLD' => $exfld_val, 'FORUMS_NEWTOPIC_TOPIC_EXTRAFLD_TITLE' => $exfld_title));
        $t->parse('MAIN.TOPIC_EXTRAFLD');
    }
}
if (cot::$cfg['forums']['cat_' . $s]['allowprvtopics']) {
    $t->assign('FORUMS_NEWTOPIC_ISPRIVATE', cot_checkbox($rtopic['ft_mode'], 'rtopicmode'));
    $t->parse('MAIN.PRIVATE');
}
/* === Hook === */
foreach (cot_getextplugins('forums.newtopic.tags') as $pl) {
    include $pl;
}
/* ===== */
cot_display_messages($t);
$t->parse('MAIN');
예제 #9
0
            break;
        case 'polls':
            $row['com_url'] = cot_url('polls', 'id=' . $row['com_value'] . "&comments=1", '#c' . $row['com_id']);
            break;
        case 'e_shop':
            $row['com_url'] = cot_url('plug', 'e=e_shop&sh=product&productID=' . $row['com_value'], '#c' . $row['com_id']);
            break;
        default:
            $row['com_url'] = '';
            break;
    }
    $t->assign(array('ADMIN_COMMENTS_ITEM_DEL_URL' => cot_url('admin', 'm=other&p=comments&a=delete&id=' . $row['com_id'] . '&' . cot_xg()), 'ADMIN_COMMENTS_ITEM_ID' => $row['com_id'], 'ADMIN_COMMENTS_CODE' => $row['com_code'], 'ADMIN_COMMENTS_AREA' => $row['com_area'], 'ADMIN_COMMENTS_AUTHOR' => $row['com_author'], 'ADMIN_COMMENTS_DATE' => cot_date('datetime_medium', $row['com_date']), 'ADMIN_COMMENTS_DATE_STAMP' => $row['com_date'], 'ADMIN_COMMENTS_TEXT' => $row['com_text'], 'ADMIN_COMMENTS_URL' => $row['com_url'], 'ADMIN_COMMENTS_ODDEVEN' => cot_build_oddeven($ii)));
    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('ADMIN_COMMENTS_' . $tag . '_TITLE' => $exfld_title, 'ADMIN_COMMENTS_' . $tag => cot_build_extrafields_data('comments', $exfld, $row['com_' . $exfld['field_name']]), 'ADMIN_COMMENTS_' . $tag . '_VALUE' => $row['com_' . $exfld['field_name']]));
        }
    }
    /* === Hook - Part2 : Include === */
    foreach ($extp as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('MAIN.ADMIN_COMMENTS_ROW');
    $ii++;
}
$t->assign(array('ADMIN_COMMENTS_CONFIG_URL' => cot_url('admin', 'm=config&n=edit&o=plug&p=comments'), 'ADMIN_COMMENTS_ADMINWARNINGS' => $adminwarnings, 'ADMIN_COMMENTS_PAGINATION_PREV' => $pagenav['prev'], 'ADMIN_COMMENTS_PAGNAV' => $pagenav['main'], 'ADMIN_COMMENTS_PAGINATION_NEXT' => $pagenav['next'], 'ADMIN_COMMENTS_TOTALITEMS' => $totalitems, 'ADMIN_COMMENTS_COUNTER_ROW' => $ii));
/* === Hook  === */
foreach (cot_getextplugins('admin.comments.tags') as $pl) {
    include $pl;
예제 #10
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, 'DESC_OR_TEXT_CUT' => !empty($page_data['page_desc']) ? htmlspecialchars($page_data['page_desc']) : $text_cut, '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 (!empty(cot::$extrafields[cot::$db->pages])) {
            foreach (cot::$extrafields[cot::$db->pages] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $exfld_title = cot_extrafield_title($exfld, 'page_');
                $temp_array[$tag . '_TITLE'] = $exfld_title;
                $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[cot::$db->structure])) {
            foreach (cot::$extrafields[cot::$db->structure] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $exfld_title = cot_extrafield_title($exfld, 'structure_');
                $temp_array['CAT_' . $tag . '_TITLE'] = $exfld_title;
                $temp_array['CAT_' . $tag] = cot_build_extrafields_data('structure', $exfld, cot::$structure['page'][$page_data['page_cat']][$exfld['field_name']]);
                $temp_array['CAT_' . $tag . '_VALUE'] = cot::$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;
}
예제 #11
0
/**
 * Returns all section tags for coTemplate
 *
 * @param string $cat Forums structure cat code
 * @param string $tag_prefix Prefix for tags
 * @param array $stat Category statistics
 *
 * @return array
 */
function cot_generate_sectiontags($cat, $tag_prefix = '', $stat = NULL)
{
    global $cfg, $structure, $cot_extrafields, $usr, $sys, $L, $db_structure;
    $stat['fs_lt_date'] = !empty($stat['fs_lt_date']) ? $stat['fs_lt_date'] : 0;
    $stat['fs_lt_posterid'] = !empty($stat['fs_lt_posterid']) ? $stat['fs_lt_posterid'] : 0;
    $usr['lastvisit'] = !empty($usr['lastvisit']) ? $usr['lastvisit'] : 0;
    $new_elems = $usr['id'] > 0 && $stat['fs_lt_date'] > $usr['lastvisit'] && $stat['fs_lt_posterid'] != $usr['id'];
    $sections = array($tag_prefix . 'CAT' => $cat, $tag_prefix . 'LOCKED' => $structure['forums'][$cat]['locked'], $tag_prefix . 'TITLE' => $structure['forums'][$cat]['title'], $tag_prefix . 'DESC' => cot_parse_autourls($structure['forums'][$cat]['desc']) . ($structure['forums'][$cat]['locked'] ? ' ' . $L['Locked'] : ''), $tag_prefix . 'ICON' => empty($structure['forums'][$cat]['icon']) ? '' : cot_rc('img_structure_cat', array('icon' => $structure['forums'][$cat]['icon'], 'title' => htmlspecialchars($structure['forums'][$cat]['title']), 'desc' => htmlspecialchars($structure['forums'][$cat]['desc']))), $tag_prefix . 'URL' => cot_url('forums', 'm=topics&s=' . $cat), $tag_prefix . 'SECTIONSURL' => cot_url('forums', 'c=' . $cat), $tag_prefix . 'NEWPOSTS' => $new_elems, $tag_prefix . 'CAT_DEFSTATE' => htmlspecialchars($cfg['forums']['cat_' . $cat]['defstate']));
    if (is_array($stat)) {
        if ($stat['fs_lt_date'] > 0) {
            $sections += array($tag_prefix . 'LASTPOSTDATE' => cot_date('datetime_short', $stat['fs_lt_date']), $tag_prefix . 'LASTPOSTER' => cot_build_user($stat['fs_lt_posterid'], htmlspecialchars($stat['fs_lt_postername'])), $tag_prefix . 'LASTPOST' => cot_rc_link($new_elems ? cot_url('forums', 'm=posts&q=' . $stat['fs_lt_id'] . '&n=unread', '#unread') : cot_url('forums', 'm=posts&q=' . $stat['fs_lt_id'] . '&n=last', '#bottom'), cot_cutstring($stat['fs_lt_title'], 32)), $tag_prefix . 'LASTPOST_URL' => $new_elems ? cot_url('forums', 'm=posts&q=' . $stat['fs_lt_id'] . '&n=unread', '#unread') : cot_url('forums', 'm=posts&q=' . $stat['fs_lt_id'] . '&n=last', '#bottom'), $tag_prefix . 'TIMEAGO' => cot_build_timegap($stat['fs_lt_date'], $sys['now']));
        }
        $sections += array($tag_prefix . 'TOPICCOUNT' => $stat['topiccount'], $tag_prefix . 'LASTPOSTDATE_STAMP' => $stat['fs_lt_date'], $tag_prefix . 'POSTCOUNT' => $stat['postcount'], $tag_prefix . 'VIEWCOUNT' => $stat['viewcount'], $tag_prefix . 'VIEWCOUNT_SHORT' => $stat['viewcount'] > 9999 ? floor($stat['viewcount'] / 1000) . 'k' : $stat['viewcount']);
    }
    if (!is_array($stat) || !$stat['fs_lt_date']) {
        $sections[$tag_prefix . 'LASTPOSTDATE'] = '';
        $sections[$tag_prefix . 'LASTPOSTER'] = '';
        $sections[$tag_prefix . 'LASTPOST'] = '';
        $sections[$tag_prefix . 'TIMEAGO'] = '';
        $sections[$tag_prefix . 'TOPICCOUNT'] = 0;
        $sections[$tag_prefix . 'POSTCOUNT'] = 0;
        $sections[$tag_prefix . 'VIEWCOUNT'] = 0;
        $sections[$tag_prefix . 'VIEWCOUNT_SHORT'] = 0;
    }
    if (!empty(cot::$extrafields[cot::$db->structure])) {
        foreach (cot::$extrafields[cot::$db->structure] as $exfld) {
            $uname = strtoupper($exfld['field_name']);
            $exfld_title = cot_extrafield_title($exfld, 'structure_');
            $sections[$tag_prefix . $uname . '_TITLE'] = $exfld_title;
            $sections[$tag_prefix . $uname] = cot_build_extrafields_data('structure', $exfld, $structure['forums'][$cat][$exfld['field_name']]);
            $sections[$tag_prefix . $uname . '_VALUE'] = $structure['forums'][$cat][$exfld['field_name']];
        }
    }
    return $sections;
}
예제 #12
0
/**
 * Imports Extra fields data
 *
 * @param string $inputname Variable name (or value for source=D)
 * @param $extrafield
 * @param string $source Source type: G (GET), P (POST), C (COOKIE) or D (variable filtering)
 * @param string $oldvalue Old value of extrafield
 * @param string $titlePrefix
 * @return string
 */
function cot_import_extrafields($inputname, $extrafield, $source = 'P', $oldvalue = '', $titlePrefix = '')
{
    global $L;
    $exfld_title = cot_extrafield_title($extrafield, $titlePrefix);
    $import = null;
    switch ($extrafield['field_type']) {
        case 'input':
            $import = $extrafield['field_parse'] == 'Text' ? cot_import($inputname, $source, 'TXT') : cot_import($inputname, $source, 'HTM');
            if (!empty($extrafield['field_params']) && !is_null($import) && !preg_match($extrafield['field_params'], $import)) {
                $errMsg = isset($L['field_pregmatch_' . $extrafield['field_name']]) ? $L['field_pregmatch_' . $extrafield['field_name']] : $exfld_title . ': ' . $L['field_pregmatch'];
                cot_error($errMsg, $inputname);
            }
            break;
        case 'inputint':
        case 'range':
            $extrafield['field_params'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_params']);
            $import = cot_import($inputname, $source, 'INT');
            if (!is_null($import) && !empty($extrafield['field_params'])) {
                list($min, $max) = explode(",", $extrafield['field_params'], 2);
                $min = (int) $min;
                $max = (int) $max;
                if ($import < $min || $import > $max) {
                    $errMsg = isset($L['field_range_' . $extrafield['field_name']]) ? $L['field_range_' . $extrafield['field_name']] : $exfld_title . ': ' . $L['field_range'];
                    cot_error($errMsg, $inputname);
                }
            }
            break;
        case 'currency':
        case 'double':
            $extrafield['field_params'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_params']);
            $import = cot_import($inputname, $source, 'NUM');
            if (!is_null($import)) {
                $import = floatval($import);
            }
            if (!is_null($import) && !empty($extrafield['field_params'])) {
                list($min, $max) = explode(",", $extrafield['field_params'], 2);
                $min = (int) $min;
                $max = (int) $max;
                if ($import < $min || $import > $max) {
                    $errMsg = isset($L['field_range_' . $extrafield['field_name']]) ? $L['field_range_' . $extrafield['field_name']] : $exfld_title . ': ' . $L['field_range'];
                    cot_error($errMsg, $inputname);
                }
            }
            break;
        case 'textarea':
            $import = cot_import($inputname, $source, 'HTM');
            break;
        case 'select':
        case 'radio':
            $extrafield['field_variants'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_variants']);
            $opt_array = explode(",", trim($extrafield['field_variants']));
            $import = cot_import($inputname, $source, 'HTM');
            if (!is_null($import) && !in_array(trim($import), $opt_array)) {
                $errMsg = isset($L['field_notinarray_' . $extrafield['field_name']]) ? $L['field_notinarray_' . $extrafield['field_name']] : $exfld_title . ': ' . $L['field_notinarray'];
                cot_error($errMsg, $inputname);
            }
            break;
        case 'checkbox':
            $import = (int) cot_import($inputname, $source, 'BOL');
            break;
        case 'datetime':
            $extrafield['field_params'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_params']);
            list($min, $max) = explode(",", $extrafield['field_params'], 2);
            $import = cot_import_date($inputname, true, false, $source);
            if (!is_null($import) && ((int) $min > 0 || (int) $max > 0)) {
                list($s_year, $s_month, $s_day, $s_hour, $s_minute) = explode('-', @date('Y-m-d-H-i', $import));
                if ($min > $s_year) {
                    $import = mktime($s_hour, $s_minute, 0, $s_month, $s_day, $min);
                }
                if ($max < $s_year) {
                    $import = mktime($s_hour, $s_minute, 0, $s_month, $s_day, $max);
                }
            }
            break;
        case 'country':
            $import = cot_import($inputname, $source, 'ALP');
            break;
        case 'checklistbox':
            $import = cot_import($inputname, $source, 'ARR');
            $extrafield['field_variants'] = str_replace(array(' , ', ', ', ' ,'), ',', $extrafield['field_variants']);
            $opt_array = explode(',', trim($extrafield['field_variants']));
            if (count($import) < 1) {
                $import = null;
            } elseif (count($import) == 1 && isset($import['nullval'])) {
                $import = array();
            } else {
                unset($import['nullval']);
                foreach ($import as $k => $v) {
                    $import[$k] = cot_import($v, 'D', 'HTM');
                    if (!is_null($import[$k]) && !in_array($import[$k], $opt_array)) {
                        $errMsg = isset($L['field_notinarray_' . $extrafield['field_name']]) ? $L['field_notinarray_' . $extrafield['field_name']] : $exfld_title . ': ' . $L['field_notinarray'];
                        cot_error($errMsg, $inputname);
                    }
                }
            }
            if (is_array($import)) {
                $import = implode(',', $import);
            }
            break;
        case 'file':
            global $lang, $cot_translit, $exfldfiles, $exfldsize, $cfg, $uploadfiles, $pl;
            if ($source == 'P' || $source == 'POST') {
                $import = $_FILES[$inputname];
                $import['delete'] = cot_import('rdel_' . $inputname, 'P', 'BOL') ? 1 : 0;
            } elseif ($source == 'D') {
                $import = $inputname;
            }
            /* === Hook === */
            foreach (cot_getextplugins('extrafields.import.file.first') as $pl) {
                include $pl;
            }
            /* ===== */
            if (is_array($import) && !$import['error'] && !empty($import['name'])) {
                $fname = mb_substr($import['name'], 0, mb_strrpos($import['name'], '.'));
                $ext = mb_strtolower(mb_substr($import['name'], mb_strrpos($import['name'], '.') + 1));
                //check extension
                $extrafield['field_variants'] = str_replace(array(' , ', ', ', ' ,'), ',', mb_strtolower($extrafield['field_variants']));
                $ext_array = explode(",", trim($extrafield['field_variants']));
                if (empty($extrafield['field_variants']) || in_array($ext, $ext_array)) {
                    if ($lang != 'en' && file_exists(cot_langfile('translit', 'core'))) {
                        require_once cot_langfile('translit', 'core');
                        $fname = is_array($cot_translit) ? strtr($fname, $cot_translit) : '';
                    }
                    $fname = str_replace(array(' ', '  ', '__'), '_', $fname);
                    $fname = preg_replace('#[^a-zA-Z0-9\\-_\\.\\ \\+]#', '', $fname);
                    $fname = str_replace('..', '.', $fname);
                    $fname = str_replace('__', '_', $fname);
                    $fname = empty($fname) ? cot_unique() : $fname;
                    // Generate unique file name. Old file - must be removed any way
                    $extrafield['field_params'] = !empty($extrafield['field_params']) ? $extrafield['field_params'] : $cfg['extrafield_files_dir'];
                    $extrafield['field_params'] .= mb_substr($extrafield['field_params'], -1) == '/' ? '' : '/';
                    if (file_exists("{$extrafield['field_params']}{$fname}.{$ext}")) {
                        $fname = $inputname . '_' . date("YmjGis") . '_' . $fname;
                    }
                    $fname .= '.' . $ext;
                    $file['old'] = !empty($oldvalue) && ($import['delete'] || $import['tmp_name']) ? $extrafield['field_params'] . $oldvalue : '';
                    $file['field'] = $extrafield['field_name'];
                    $file['tmp'] = !$import['delete'] ? $import['tmp_name'] : '';
                    $file['new'] = !$import['delete'] ? $extrafield['field_params'] . $fname : '';
                    /* === Hook === */
                    foreach (cot_getextplugins('extrafields.import.file.done') as $pl) {
                        include $pl;
                    }
                    /* ===== */
                    $exfldsize[$extrafield['field_name']] = $import['size'];
                    $uploadfiles[] = $file;
                    $import = $fname;
                } else {
                    $errMsg = isset($L['field_extension_' . $extrafield['field_name']]) ? $L['field_extension_' . $extrafield['field_name']] : $exfld_title . ': ' . $L['field_extension'];
                    cot_error($errMsg, $inputname);
                    $exfldsize[$extrafield['field_name']] = null;
                    $import = null;
                }
            } elseif (is_array($import) && $import['delete']) {
                $exfldsize[$extrafield['field_name']] = 0;
                $import = '';
                $extrafield['field_params'] = !empty($extrafield['field_params']) ? $extrafield['field_params'] : $cfg['extrafield_files_dir'];
                $file['old'] = !empty($oldvalue) ? "{$extrafield['field_params']}/{$oldvalue}" : '';
                $file['field'] = $extrafield['field_name'];
                $uploadfiles[] = $file;
            } else {
                $exfldsize[$extrafield['field_name']] = null;
                $import = null;
            }
            break;
        case 'filesize':
            global $exfldsize;
            $import = $exfldsize[$extrafield['field_variants']];
            break;
    }
    if ((is_null($import) || $import === '') && $extrafield['field_required']) {
        $msg = isset(cot::$L['field_required_' . $extrafield['field_name']]) ? cot::$L['field_required_' . $extrafield['field_name']] : cot::$L['field_required'] . ': ' . $exfld_title;
        cot_error($msg, $inputname);
    }
    return $import;
}