cot_extrafield_movefiles(); } /* === Hook === */ foreach (cot_getextplugins('forums.editpost.update.done') as $pl) { include $pl; } /* ===== */ cot_forums_sectionsetlast($rowpost['fp_cat']); if ($cache) { $cfg['cache_forums'] && $cache->page->clear('forums'); $cfg['cache_index'] && $cache->page->clear('index'); } cot_redirect(cot_url('forums', "m=posts&q=" . $q . '&d=' . $durl, '#' . $p, true)); } require_once cot_incfile('forms'); $crumbs = cot_forums_buildpath($s); $crumbs[] = array(cot_url('forums', "m=posts&p=" . $p, "#" . $p), ($rowt['ft_mode'] == 1 ? '# ' : '') . htmlspecialchars($rowt['ft_title'])); $crumbs[] = array(cot_url('forums', "m=editpost&s={$s}&q=" . $q . "&p=" . $p . "&" . cot_xg()), $L['Edit']); $toptitle = cot_breadcrumbs($crumbs, $cfg['homebreadcrumb']); $toptitle .= $usr['isadmin'] ? $R['forums_code_admin_mark'] : ''; $sys['sublocation'] = $structure['forums'][$s]['title']; $title_params = array('FORUM' => $L['Forums'], 'SECTION' => $structure['forums'][$s]['title'], 'TOPIC' => $rowt['ft_title'], 'EDIT' => $L['Edit']); $out['subtitle'] = cot_title('{EDIT} - {TOPIC}', $title_params); $out['head'] .= $R['code_noindex']; /* === Hook === */ foreach (cot_getextplugins('forums.editpost.main') as $pl) { include $pl; } /* ===== */ require_once $cfg['system_dir'] . '/header.php'; $mskin = cot_tplfile(array('forums', 'editpost', $structure['forums'][$s]['tpl']));
/** * Search by tag in forums * * @param string $query User-entered query string * @global CotDB $db */ function cot_tag_search_forums($query) { global $db, $t, $L, $lang, $cfg, $usr, $qs, $d, $db_tag_references, $db_forum_topics, $o, $row; if (!cot_module_active('forums')) { return; } $query = cot_tag_parse_query($query, 't.ft_id'); if (empty($query)) { return; } $maxperpage = cot::$cfg['maxrowsperpage'] && is_numeric(cot::$cfg['maxrowsperpage']) && cot::$cfg['maxrowsperpage'] > 0 ? cot::$cfg['maxrowsperpage'] : 15; $join_columns = ''; $join_tables = ''; $join_where = ''; switch ($o) { case 'title': $order = 'ORDER BY `ft_title`'; break; case 'date': $order = 'ORDER BY `ft_updated` DESC'; break; case 'category': $order = 'ORDER BY `ft_cat`'; break; default: $order = ''; } /* == Hook == */ foreach (cot_getextplugins('tags.search.forums.query') as $pl) { include $pl; } /* ===== */ $totalitems = $db->query("SELECT DISTINCT COUNT(*)\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_forum_topics} AS t\n\t\t\tON r.tag_item = t.ft_id {$join_tables}\n\t\tWHERE r.tag_area = 'forums' AND ({$query}) {$join_where}")->fetchColumn(); $sql = $db->query("SELECT DISTINCT t.ft_id, t.ft_cat, t.ft_title {$join_columns}\n\t\tFROM {$db_tag_references} AS r LEFT JOIN {$db_forum_topics} AS t\n\t\t\tON r.tag_item = t.ft_id {$join_tables}\n\t\tWHERE r.tag_area = 'forums' AND ({$query}) AND t.ft_id IS NOT NULL {$join_where}\n\t\t{$order}\n\t\tLIMIT {$d}, {$maxperpage}"); $t->assign('TAGS_RESULT_TITLE', $L['tags_Found_in_forums']); if ($sql->rowCount() > 0) { while ($row = $sql->fetch()) { $tags = cot_tag_list($row['ft_id'], 'forums'); $tag_list = ''; $tag_i = 0; foreach ($tags as $tag) { $tag_t = $cfg['plugin']['tags']['title'] ? cot_tag_title($tag) : $tag; $tag_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($tag) : $tag; $tl = $lang != 'en' && $tag_u != $tag ? 1 : null; if ($tag_i > 0) { $tag_list .= ', '; } $tag_list .= cot_rc_link(cot_url('plug', array('e' => 'tags', 'a' => 'forums', 't' => str_replace(' ', '-', $tag_u), 'tl' => $tl)), htmlspecialchars($tag_t)); $tag_i++; } $master = $row['fs_masterid'] > 0 ? array($row['fs_masterid'], $row['fs_mastername']) : false; $t->assign(array('TAGS_RESULT_ROW_URL' => cot_url('forums', 'm=posts&q=' . $row['ft_id']), 'TAGS_RESULT_ROW_TITLE' => htmlspecialchars($row['ft_title']), 'TAGS_RESULT_ROW_PATH' => cot_breadcrumbs(cot_forums_buildpath($row['ft_cat']), false), 'TAGS_RESULT_ROW_TAGS' => $tag_list)); $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_ROW'); } $sql->closeCursor(); $qs_u = $cfg['plugin']['tags']['translit'] ? cot_translit_encode($qs) : $qs; $tl = $lang != 'en' && $qs_u != $qs ? 1 : null; $pagenav = cot_pagenav('plug', array('e' => 'tags', 'a' => 'forums', 't' => $qs_u, 'tl' => $tl), $d, $totalitems, $maxperpage); $t->assign(array('TAGS_PAGEPREV' => $pagenav['prev'], 'TAGS_PAGENEXT' => $pagenav['next'], 'TAGS_PAGNAV' => $pagenav['main'])); } else { $t->parse('MAIN.TAGS_RESULT.TAGS_RESULT_NONE'); } $t->parse('MAIN.TAGS_RESULT'); }
$where_and['or'] = '(' . implode(' OR ', $where_or) . ')'; $where_and = array_diff($where_and, array('')); $where = implode(' AND ', $where_and); $maxitems = $cfg_maxitems - $items; $maxitems = $maxitems < 0 ? 0 : $maxitems; if (!$db->fieldExists($db_forum_topics, "ft_{$rs['frmsort']}")) { $rs['frmsort'] = 'updated'; } $sql = $db->query("SELECT SQL_CALC_FOUND_ROWS p.*, t.*\n\t\t\t \tFROM {$db_forum_posts} AS p, {$db_forum_topics} AS t\n\t\t\t\tWHERE {$where} AND p.fp_topicid = t.ft_id\n\t\t\t\tGROUP BY t.ft_id ORDER BY ft_" . $rs['frmsort'] . " " . $rs['frmsort2'] . "\n\t\t\t\tLIMIT {$d}, {$maxitems}"); $items = $sql->rowCount(); $totalitems[] = $db->query('SELECT FOUND_ROWS()')->fetchColumn(); $jj = 0; while ($row = $sql->fetch()) { if ($row['ft_updated'] > 0) { $post_url = $cfg['plugin']['search']['searchurl'] == 'Single' ? cot_url('forums', 'm=posts&id=' . $row['fp_id'] . '&highlight=' . $hl) : cot_url('forums', 'm=posts&p=' . $row['fp_id'] . '&highlight=' . $hl, '#' . $row['fp_id']); $t->assign(array('PLUGIN_FR_CATEGORY' => cot_breadcrumbs(cot_forums_buildpath($row['ft_cat']), false), 'PLUGIN_FR_TITLE' => cot_rc_link($post_url, htmlspecialchars($row['ft_title'])), 'PLUGIN_FR_TITLE_URL' => $post_url, 'PLUGIN_FR_TEXT' => cot_clear_mark($row['fp_text'], $words), 'PLUGIN_FR_TIME' => $row['ft_updated'] > 0 ? cot_date('datetime_medium', $row['ft_updated']) : cot_date('datetime_medium', $row['fp_updated']), 'PLUGIN_FR_TIMESTAMP' => $row['ft_updated'] > 0 ? $row['ft_updated'] : $row['fp_updated'], 'PLUGIN_FR_ODDEVEN' => cot_build_oddeven($jj), 'PLUGIN_FR_NUM' => $jj)); $t->parse('MAIN.RESULTS.FORUMS.ITEM'); } $jj++; } $sql->closeCursor(); if ($jj > 0) { $t->parse('MAIN.RESULTS.FORUMS'); } } /* === Hook === */ foreach (cot_getextplugins('search.list') as $pl) { include $pl; } /* ===== */ if (array_sum($totalitems) < 1) {
} cot_extrafield_movefiles(); /* === Hook === */ foreach (cot_getextplugins('forums.newtopic.newtopic.done') as $pl) { include $pl; } /* ===== */ if ($cache) { $cfg['cache_forums'] && $cache->page->clear('forums'); $cfg['cache_index'] && $cache->page->clear('index'); } cot_shield_update(45, "New topic"); cot_redirect(cot_url('forums', "m=posts&q={$q}&n=last", '#bottom', true)); } } $toptitle = cot_breadcrumbs(cot_forums_buildpath($s), $cfg['homebreadcrumb']); $toptitle .= $usr['isadmin'] ? $R['forums_code_admin_mark'] : ''; $sys['sublocation'] = $structure['forums'][$s]['title']; $out['subtitle'] = $L['forums_newtopic']; $out['head'] .= $R['code_noindex']; /* === Hook === */ foreach (cot_getextplugins('forums.newtopic.main') as $pl) { include $pl; } /* ===== */ require_once cot_incfile('forms'); require_once $cfg['system_dir'] . '/header.php'; $mskin = cot_tplfile(array('forums', 'newtopic', $structure['forums'][$s]['tpl'])); $t = new XTemplate($mskin); $t->assign(array('FORUMS_NEWTOPIC_PAGETITLE' => $toptitle, 'FORUMS_NEWTOPIC_SUBTITLE' => htmlspecialchars(cot_parse_autourls($structure['forums'][$s]['desc'])), 'FORUMS_NEWTOPIC_SEND' => cot_url('forums', "m=newtopic&a=newtopic&s=" . $s), 'FORUMS_NEWTOPIC_TITLE' => cot_inputbox('text', 'rtopictitle', $rtopic['ft_title'], array('size' => 56, 'maxlength' => 255)), 'FORUMS_NEWTOPIC_DESC' => cot_inputbox('text', 'rtopicdesc', $rtopic['ft_desc'], array('size' => 56, 'maxlength' => 255)), 'FORUMS_NEWTOPIC_TEXT' => cot_textarea('rmsgtext', $rmsg['fp_text'], 20, 56, '', 'input_textarea_' . $minimaxieditor), 'FORUMS_NEWTOPIC_EDITTIMEOUT' => cot_build_timegap(0, $cfg['forums']['edittimeout'] * 3600))); // Extra fields
defined('COT_CODE') && defined('COT_ADMIN') or die('Wrong URL.'); list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('forums', 'any'); cot_block($usr['isadmin']); $t = new XTemplate(cot_tplfile('forums.admin', 'module', true)); require_once cot_incfile('forums', 'module'); $adminpath[] = array(cot_url('admin', 'm=extensions'), $L['Extensions']); $adminpath[] = array(cot_url('admin', 'm=extensions&a=details&mod=' . $m), $cot_modules[$m]['title']); $adminpath[] = array(cot_url('admin', 'm=' . $m), $L['Administration']); $adminhelp = $L['adm_help_forums']; $adminsubtitle = $L['Forums']; /* === Hook === */ foreach (cot_getextplugins('forums.admin.first') as $pl) { include $pl; } /* ===== */ $sql_forums = $db->query("SELECT * FROM {$db_forum_topics} WHERE 1 ORDER BY ft_creationdate DESC LIMIT 10"); $ii = 0; while ($row = $sql_forums->fetch()) { $ii++; $t->assign(array('ADMIN_FORUMS_ROW_II' => $ii, 'ADMIN_FORUMS_ROW_FORUMS' => cot_breadcrumbs(cot_forums_buildpath($row['ft_cat']), false), 'ADMIN_FORUMS_ROW_URL' => cot_url('forums', 'm=posts&q=' . $row['ft_id']), 'ADMIN_FORUMS_ROW_TITLE' => htmlspecialchars($row['ft_title']), 'ADMIN_FORUMS_ROW_POSTCOUNT' => $row['ft_postcount'])); $t->parse('MAIN.ADMIN_FORUMS_ROW_USER'); } $sql_forums->closeCursor(); $t->assign(array('ADMIN_FORUMS_URL_CONFIG' => cot_url('admin', 'm=config&n=edit&o=module&p=forums'), 'ADMIN_FORUMS_URL_STRUCTURE' => cot_url('admin', 'm=structure&n=forums'), 'ADMIN_FORUMS_TOTALTOPICS' => $db->countRows($db_forum_topics), 'ADMIN_FORUMS_TOTALPOSTS' => $db->countRows($db_forum_posts), 'ADMIN_FORUMS_TOTALVIEWS' => $db->query("SELECT SUM(fs_viewcount) FROM {$db_forum_stats}")->fetchColumn())); /* === Hook === */ foreach (cot_getextplugins('forums.admin.tags') as $pl) { include $pl; } /* ===== */ $t->parse('MAIN'); $adminmain = $t->text('MAIN');
function cot_build_recentforums($template, $mode = 'recent', $maxperpage = 5, $d = 0, $titlelength = 0, $rightprescan = true) { global $db, $L, $cfg, $db_forum_topics, $theme, $usr, $sys, $R, $structure; global $totalrecent; $recentitems = new XTemplate(cot_tplfile($template, 'plug')); if ($rightprescan) { $catsub = cot_structure_children('forums', '', true, true, $rightprescan); $incat = "AND ft_cat IN ('" . implode("','", $catsub) . "')"; } /* === Hook === */ foreach (cot_getextplugins('recentitems.recentforums.first') as $pl) { include $pl; } /* ===== */ if ($mode == 'recent') { $sql = $db->query("SELECT * FROM {$db_forum_topics}\n\t\t\tWHERE (ft_movedto IS NULL OR ft_movedto = '') AND ft_mode=0 " . $incat . "\n\t\t\tORDER by ft_updated DESC LIMIT {$maxperpage}"); $totalrecent['topics'] = $maxperpage; } else { $where = "WHERE ft_updated >= {$mode} " . $incat; $totalrecent['topics'] = $db->query("SELECT COUNT(*) FROM {$db_forum_topics} " . $where)->fetchColumn(); $sql = $db->query("SELECT * FROM {$db_forum_topics} " . $where . " ORDER by ft_updated desc LIMIT {$d}, " . $maxperpage); } $ft_num = 0; while ($row = $sql->fetch()) { $row['ft_icon'] = 'posts'; $row['ft_postisnew'] = FALSE; $row['ft_pages'] = ''; $ft_num++; if ((int) $titlelength > 0 && mb_strlen($row['ft_title']) > $titlelength) { $row['ft_title'] = cot_string_truncate($row['ft_title'], $titlelength, false) . "..."; } $build_forum = cot_breadcrumbs(cot_forums_buildpath($row['ft_cat'], false), false); $build_forum_short = cot_rc_link(cot_url('forums', 'm=topics&s=' . $row['ft_cat']), htmlspecialchars($structure['forums'][$row['ft_cat']]['title'])); if ($row['ft_mode'] == 1) { $row['ft_title'] = "# " . $row['ft_title']; } if ($row['ft_movedto'] > 0) { $row['ft_url'] = cot_url('forums', 'm=posts&q=' . $row['ft_movedto']); $row['ft_icon'] = $R['forums_icon_posts_moved']; $row['ft_title'] = $L['Moved'] . ": " . $row['ft_title']; $row['ft_lastpostername'] = $R['forums_code_post_empty']; $row['ft_postcount'] = $R['forums_code_post_empty']; $row['ft_replycount'] = $R['forums_code_post_empty']; $row['ft_viewcount'] = $R['forums_code_post_empty']; $row['ft_lastpostername'] = $R['forums_code_post_empty']; $row['ft_lastposturl'] = cot_url('forums', 'm=posts&q=' . $row['ft_movedto'] . '&n=last', '#bottom'); $row['ft_lastpostlink'] = cot_rc_link($row['ft_lastposturl'], $R['icon_follow']) . ' ' . $L['Moved']; $row['ft_timeago'] = cot_build_timegap($row['ft_updated'], $sys['now']); } else { $row['ft_url'] = cot_url('forums', 'm=posts&q=' . $row['ft_id']); $row['ft_lastposturl'] = $usr['id'] > 0 && $row['ft_updated'] > $usr['lastvisit'] ? cot_url('forums', 'm=posts&q=' . $row['ft_id'] . '&n=unread', '#unread') : cot_url('forums', 'm=posts&q=' . $row['ft_id'] . '&n=last', '#bottom'); $row['ft_lastpostlink'] = $usr['id'] > 0 && $row['ft_updated'] > $usr['lastvisit'] ? cot_rc_link($row['ft_lastposturl'], $R['icon_unread'], 'rel="nofollow"') : cot_rc_link($row['ft_lastposturl'], $R['icon_follow'], 'rel="nofollow"'); $row['ft_lastpostlink'] .= cot_date('datetime_medium', $row['ft_updated']); $row['ft_timeago'] = cot_build_timegap($row['ft_updated'], $sys['now']); $row['ft_replycount'] = $row['ft_postcount'] - 1; if ($row['ft_updated'] > $usr['lastvisit'] && $usr['id'] > 0) { $row['ft_icon'] .= '_new'; $row['ft_postisnew'] = TRUE; } if ($row['ft_postcount'] >= $cfg['forums']['hottopictrigger'] && !$row['ft_state'] && !$row['ft_sticky']) { $row['ft_icon'] = $row['ft_postisnew'] ? 'posts_new_hot' : 'posts_hot'; } else { if ($row['ft_sticky']) { $row['ft_icon'] .= '_sticky'; } if ($row['ft_state']) { $row['ft_icon'] .= '_locked'; } } $row['ft_icon_type'] = $row['ft_icon']; $row['ft_icon'] = cot_rc('forums_icon_topic_t', array('icon' => $row['ft_icon'], 'title' => $L['recentitems_' . $row['ft_icon']])); $row['ft_lastpostername'] = cot_build_user($row['ft_lastposterid'], htmlspecialchars($row['ft_lastpostername'])); } $row['ft_firstpostername'] = cot_build_user($row['ft_firstposterid'], htmlspecialchars($row['ft_firstpostername'])); if ($row['ft_postcount'] > $cfg['forums']['maxtopicsperpage'] && $cfg['forums']['maxtopicsperpage'] > 0) { $row['ft_maxpages'] = ceil($row['ft_postcount'] / $cfg['forums']['maxtopicsperpage']); $row['ft_pages'] = $L['Pages'] . ":"; } $recentitems->assign(array('FORUM_ROW_ID' => $row['ft_id'], 'FORUM_ROW_STATE' => $row['ft_state'], 'FORUM_ROW_ICON' => $row['ft_icon'], 'FORUM_ROW_ICON_TYPE' => $row['ft_icon_type'], 'FORUM_ROW_TITLE' => htmlspecialchars($row['ft_title']), 'FORUM_ROW_PATH' => $build_forum, 'FORUM_ROW_PATH_SHORT' => $build_forum_short, 'FORUM_ROW_DESC' => htmlspecialchars($row['ft_desc']), 'FORUM_ROW_PREVIEW' => $row['ft_preview'] . '...', 'FORUM_ROW_CREATIONDATE' => cot_date('datetime_short', $row['ft_creationdate']), 'FORUM_ROW_CREATIONDATE_STAMP' => $row['ft_creationdate'], 'FORUM_ROW_UPDATED' => $row['ft_lastpostlink'], 'FORUM_ROW_UPDATED_STAMP' => $row['ft_updated'], 'FORUM_ROW_TIMEAGO' => $row['ft_timeago'], 'FORUM_ROW_POSTCOUNT' => $row['ft_postcount'], 'FORUM_ROW_REPLYCOUNT' => $row['ft_replycount'], 'FORUM_ROW_VIEWCOUNT' => $row['ft_viewcount'], 'FORUM_ROW_FIRSTPOSTER' => $row['ft_firstpostername'], 'FORUM_ROW_LASTPOSTER' => $row['ft_lastpostername'], 'FORUM_ROW_LASTPOSTURL' => $row['ft_lastposturl'], 'FORUM_ROW_URL' => $row['ft_url'], 'FORUM_ROW_PAGES' => $row['ft_pages'], 'FORUM_ROW_MAXPAGES' => $row['ft_maxpages'], 'FORUM_ROW_NUM' => $ft_num, 'FORUM_ROW_ODDEVEN' => cot_build_oddeven($ft_num), 'FORUM_ROW' => $row)); $recentitems->parse('MAIN.TOPICS_ROW'); } $sql->closeCursor(); if ($d == 0 && $ft_num == 0) { $recentitems->parse('MAIN.NO_TOPICS_FOUND'); } $recentitems->parse('MAIN'); return $d == 0 || $ft_num > 0 ? $recentitems->text('MAIN') : ''; }
list($pnf, $df, $df_url) = cot_import_pagenav('df', $cfg['plugin']['userlatestposts']['countonpage']); $totalitems = $db->query("SELECT COUNT(*) FROM {$db_forum_posts} p, {$db_forum_topics} t\tWHERE fp_posterid='" . $urr['user_id'] . "' AND p.fp_topicid=t.ft_id")->fetchColumn(); if ($cfg['plugin']['userlatestposts']['ajax']) { $upf_ajax_begin = "<div id='reloadf'>"; $upf_ajax_end = "</div>"; } $pagenav = cot_pagenav('users', 'm=details&id=' . $urr['user_id'], $df, $totalitems, $cfg['plugin']['userlatestposts']['countonpage'], 'df', '', $cfg['plugin']['userlatestposts']['ajax'], "reloadf", 'plug', "r=userlatestposts&id=" . $urr['user_id']); $sqluserlatestposts = $db->query("SELECT p.fp_id, p.fp_topicid, p.fp_updated, t.ft_title, t.ft_id, t.ft_cat\n\t\t FROM {$db_forum_posts} p, {$db_forum_topics} t\n\t\t WHERE fp_posterid='" . $urr['user_id'] . "'\n\t\t AND p.fp_topicid=t.ft_id\n\t\t GROUP BY t.ft_id\n\t\t ORDER BY fp_updated DESC\n\t\t LIMIT {$df}, " . $cfg['plugin']['userlatestposts']['countonpage']); if ($sqluserlatestposts->rowCount() == 0) { $user_posts->parse("USERLATESTPOSTS.NONE"); } else { $ii = 0; while ($row = $sqluserlatestposts->fetch()) { if (cot_auth('forums', $row['ft_cat'], 'R')) { $ii++; $build_forum = cot_breadcrumbs(cot_forums_buildpath($row['ft_cat'], false), false); $user_posts->assign(array("UPF_DATE" => cot_date('datetime_medium', $row['fp_updated']), "UPF_FORUMS" => $build_forum, "UPF_FORUMS_ID" => $row['fp_id'], "UPF_FORUMS_POST_URL" => cot_url('forums', 'm=posts&q=' . $row['fp_topicid'] . '&d=' . $durl, "#" . $row['fp_id']), "UPF_FORUMS_TITLE" => htmlspecialchars($row['ft_title']), "UPF_NUM" => $ii, "UPF_ODDEVEN" => cot_build_oddeven($ii))); $user_posts->parse("USERLATESTPOSTS.YES.TOPIC"); } } $user_posts->assign(array("UPF_AJAX_BEGIN" => $upf_ajax_begin, "UPF_AJAX_END" => $upf_ajax_end, "UPF_PAGENAV" => $pagenav['main'], "UPF_PAGENAV_PREV" => $pagenav['prev'], "UPF_PAGENAV_NEXT" => $pagenav['next'], "UPF_TOTALITEMS" => $totalitems, "UPF_COUNT_ON_PAGE" => $ii)); $user_posts->parse("USERLATESTPOSTS.YES"); } } else { $user_posts->parse("USERLATESTPOSTS.NONE"); } $user_posts->parse("USERLATESTPOSTS"); $user_pos = $user_posts->text("USERLATESTPOSTS"); if (!defined('COT_PLUG')) { $t->assign(array("USERS_DETAILS_LATESTPOSTS" => $user_pos)); } else {