'.$autotag['parm2'].''; $content = str_replace($autotag['tagstr'],$filelink,$content); return $content; } } /** * This will put an option for forum admin in the command and control block on moderation.php * */ function plugin_cclabel_forum() { global $_CONF; if (SEC_hasRights('forum.edit')) { return array('Forum',$_CONF['site_admin_url'] . "/plugins/forum/index.php",$_CONF['site_url'] . '/forum/images/forum.gif'); } } /** * returns the administrative option for this plugin * */ function plugin_getadminoption_forum() { global $_TABLES, $_CONF; if (SEC_hasRights('forum.edit')) { $numtopics = DB_getITEM($_TABLES['gf_topic'],"count(*)"); return array('Forum', $_CONF['site_admin_url'] . '/plugins/forum/index.php', $numtopics); } } /** * Returns the user menuitem option for this plugin * Only one menu item can be returned. */ function plugin_getuseroption_forum() { global $_CONF, $_TABLES, $LANG_GF00; $regrequired = DB_getITEM($_TABLES['gf_settings'], "registrationrequired"); if (!$regrequired || SEC_hasRights('forum.user')) { return array($LANG_GF00['useradminmenu'], $_CONF['site_url'] . '/forum/gf_userprefs.php', 0); } } function plugin_user_create_forum ($uid) { global $_TABLES; DB_query ("INSERT INTO {$_TABLES['gf_userinfo']} (uid) VALUES ('{$uid}')"); } /** * Called if admin deletes a user - Removes any moderator and Watch Records for user */ function plugin_user_delete_forum ($uid) { global $_TABLES; $username = DB_getItem($_TABLES['users'], "username", "uid=$uid"); DB_query("DELETE FROM {$_TABLES['gf_moderators']} WHERE mod_username='$username'"); DB_query("DELETE FROM {$_TABLES['gf_watch']} WHERE uid ='$uid'"); DB_query("DELETE FROM {$_TABLES['gf_userinfo']} WHERE uid ='$uid'"); DB_query("DELETE FROM {$_TABLES['gf_userprefs']} WHERE uid ='$uid'"); DB_query("DELETE FROM {$_TABLES['gf_log']} WHERE uid ='$uid'"); DB_query("UPDATE {$_TABLES['gf_topic']} SET uid = 1 WHERE uid = '$uid'"); } function plugin_profileextrassave_forum() { global $_USER, $HTTP_POST_VARS, $_TABLES; require_once ($_CONF['path_html'] . 'forum/include/gf_format.php'); $uid = $_USER['uid']; if ($uid > 1) { $location = gf_preparefordb($HTTP_POST_VARS['forum_location'],'html'); $aim = gf_preparefordb($HTTP_POST_VARS['forum_aim'],'html'); $icq = gf_preparefordb($HTTP_POST_VARS['forum_icq'],'html'); $yim = gf_preparefordb($HTTP_POST_VARS['forum_yim'],'html'); $msnm = gf_preparefordb($HTTP_POST_VARS['forum_msnm'],'html'); $interests = gf_preparefordb($HTTP_POST_VARS['forum_interests'],'html'); $occupation = gf_preparefordb($HTTP_POST_VARS['forum_occupation'],'html'); DB_save ($_TABLES['gf_userinfo'], "uid,location,aim,yim,icq,msnm,interests,occupation", "'$uid','$location','$aim','$yim','$icq','$msnm','$interests','$occupation'"); } } function plugin_profilevariablesedit_forum($uid, &$template) { global $_TABLES, $LANG_GF04; $result = DB_query ("SELECT uid,location,aim,yim,icq,yim,msnm,interests,occupation FROM {$_TABLES['gf_userinfo']} WHERE uid = $uid"); $A = DB_fetchArray ($result); $template->set_var('forum_location', $A['location']); $template->set_var('forum_aim', $A['aim']); $template->set_var('forum_icq', $A['icq']); $template->set_var('forum_yim', $A['yim']); $template->set_var('forum_msnm', $A['msnm']); $template->set_var('forum_interests', $A['interests']); $template->set_var('forum_occupation', $A['occupation']); $template->set_var ('lang_forum', $LANG_GF04['label_forum']); $template->set_var ('lang_location', $LANG_GF04['label_location']); $template->set_var ('lang_aim', $LANG_GF04['label_aim']); $template->set_var ('lang_icq', $LANG_GF04['label_icq']); $template->set_var ('lang_yim', $LANG_GF04['label_yim']); $template->set_var ('lang_msnm', $LANG_GF04['label_msnm']); $template->set_var ('lang_interests', $LANG_GF04['label_interests']); $template->set_var ('lang_occupation', $LANG_GF04['label_occupation']); } function plugin_profilevariablesdisplay_forum ($uid, &$template) { global $_TABLES, $_CONF, $LANG_GF02,$LANG_GF04; $postlimit="10"; // How many posts you want displayed $query = DB_query ("SELECT id,date,forum,subject FROM {$_TABLES['gf_topic']} WHERE uid = {$uid} ORDER BY date DESC LIMIT 100"); $numposts = 0; while (list($postid,$date,$forum_id,$subject) = DB_fetchArray($query)) { $grp_id = DB_getItem($_TABLES['gf_forums'],'grp_id',"forum_id='$forum_id'"); $forum_name = DB_getItem($_TABLES['gf_forums'],'forum_name',"forum_id='$forum_id'"); $groupname = DB_getItem($_TABLES['groups'],'grp_name',"grp_id='$grp_id'"); if (SEC_inGroup($groupname) OR $grp_id == 2) { $numposts++; $postdate = COM_getUserDateTimeFormat ($date); $template->set_var ('row_number', $numposts . '.'); $template->set_var ('story_begin_href', ''); $template->set_var ('story_title', $subject); $template->set_var ('story_end_href', ''); $template->set_var ('story_date', $postdate[0]); $template->parse ('forum_post_row', 'strow', true); if ($numposts >= $postlimit) { break; } } } if ($numposts == 0) { $template->set_var ('forum_post_row', '
| $summary_label | "; $retval .= "" . $total_pages . " |
'; $display .= ''; $display .= COM_endBlock(); $display .= COM_siteFooter(); echo $display; exit; } // Check if IP of user has been banned $sqlresult = DB_query ("select * from {$_TABLES['gf_banned_ip']} where host_ip like '$ip'"); $banned = DB_fetchArray ($sqlresult); while($row = $banned){ echo COM_startBlock($LANG_GF00['access_denied']); echo ($LANG_GF02['msg14']); printf ($LANG_GF02['msg15'],$_CONF['site_mail']); echo COM_endBlock(); echo COM_siteFooter(true); exit(); } } function forum_chkUsercanAccess($secure=false) { global $_CONF, $LANG_GF01, $LANG_GF02, $registrationrequired, $_USER; if ($registrationrequired && $_USER['uid'] < 2) { echo '
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
",
"
");
$message = str_replace($search, $replace, $message);
return $message;
}
function forum_statusMessage($message='',$url,$prompt,$post=false,$forum='') {
global $_CONF,$_TABLES,$_USER,$LANG_GF02,$msgauto;
include($_CONF['path_html'] . 'forum/include/config.php');
$imgset = $_CONF['layout_url'] .'/forum/image_set';
if ($prompt=="") {
$prompt = $LANG_GF02['msg140'];
}
$statusmsg_header = new Template($_CONF['path_layout'] . 'forum/layout');
$statusmsg_header->set_file (array ('forum_statusmsg_header'=>'forum_statusmsg_header.thtml'));
$statusmsg_header->set_var ('imgset', $imgset);
$statusmsg_header->set_var ('heading', $LANG_GF02['StatusHeading']);
$statusmsg_header->parse ('output', 'forum_statusmsg_header');
echo $statusmsg_header->finish($statusmsg_header->get_var('output'));
echo $message;
echo ""; } $statusmsg_footer = new Template($_CONF['path_layout'] . 'forum/layout'); $statusmsg_footer->set_file (array ('forum_statusmsg_footer'=>'forum_statusmsg_footer.thtml')); $statusmsg_footer->set_var ('imgset', $imgset); $statusmsg_footer->parse ('output', 'forum_statusmsg_footer'); echo $statusmsg_footer->finish ($statusmsg_footer->get_var('output')); return; } /* Function to create a new forum * * @param string $name Forum name * @param string $category Category id to add the forum * @param string $dscp Optional Category Description * @param string $order Optional Display order * @param string $order Optional Group ID if a private group * @return string Returns the Forum ID for the new forum if successful */ function forum_addForum($name,$category,$dscp="",$order="",$grp_id="") { global $_TABLES, $_USER; DB_query("INSERT INTO {$_TABLES['gf_forums']} (forum_order,forum_name,forum_dscp,forum_cat,grp_id) VALUES ('$order','$name','$dscp','$category','$grp_id')"); $forumid = DB_insertId(); $modquery = DB_query("SELECT * FROM {$_TABLES['gf_moderators']} WHERE mod_username='{$_USER['username']}' AND mod_forum='$forumid'"); if (DB_numrows($modquery) < 1){ DB_query("INSERT INTO {$_TABLES['gf_moderators']} (mod_username,mod_forum,mod_delete,mod_ban,mod_edit,mod_move,mod_stick) VALUES ('$_USER[username]', '$forumid','1','1','1','1','1')"); } return $forumid; } /* Function to delete a forum * * @param string $id Forum id to delete * @return boolean Returns true */ function forum_deleteForum($id) { global $_TABLES; DB_query("DELETE FROM {$_TABLES['gf_forums']} WHERE forum_id='$id'"); DB_query("DELETE FROM {$_TABLES['gf_topic']} WHERE forum='$id'"); DB_query("DELETE FROM {$_TABLES['gf_moderators']} WHERE mod_forum='$id'"); DB_query("DELETE FROM {$_TABLES['gf_watch']} WHERE forum_id ='$id'"); return true; } function phpblock_forum_newposts() { global $_CONF, $_USER, $_TABLES, $LANG_GF01, $LANG_GF02, $mode, $order, $PHP_SELF; $post_limit="5"; // How many posts you want displayed $subject_limit="18"; // The length of characters of the subject you want displayed $latestTopicPost = true; // Set True if only want to show the latest post for a topic $img_dir = $_CONF['layout_url'] . "/forum/image_set"; /* End of User configureable settings */ $pi_name = 'forum'; // Plugin name if (DB_getItem($_TABLES['plugins'],'pi_enabled', 'pi_name = "' .$pi_name. '"')) { if ($mode == "forumblock") { if (($order == "new") OR ($order == "")) { $view_modemsg = sprintf($LANG_GF02['msg74'],$post_limit); if ($latestTopicPost) { $orderby = "lastupdated"; } else { $orderby = "date"; } } elseif ($order == "views") { $view_modemsg = sprintf($LANG_GF02['msg75'],$post_limit); $orderby = "views"; } elseif ($order == "posts") { $view_modemsg = sprintf($LANG_GF02['msg76'],$post_limit); $orderby = "replies"; } } else { $view_modemsg = sprintf($LANG_GF02['msg74'],$post_limit); if ($latestTopicPost) { $orderby = "lastupdated"; } else { $orderby = "date"; } } $block_header = new Template($_CONF['path_layout'] . 'forum/layout'); $block_header->set_file (array ('block_header'=>'block_header.thtml')); $block_header->set_var ('phpself', $PHP_SELF); $block_header->set_var ('layout_url', $_CONF['layout_url']); $block_header->set_var ('LANG_ORDERBY', $LANG_GF01['ORDERBY']); $block_header->set_var ('LANG_NEW', $LANG_GF01['NEW']); $block_header->set_var ('LANG_VIEWS', $LANG_GF01['VIEWS']); $block_header->set_var ('LANG_POSTS', $LANG_GF01['POSTS']); $block_header->set_var ('view_modemsg', $view_modemsg); $block_header->parse ('output', 'block_header'); $retval = $block_header->finish($block_header->get_var('output')); // Select SQL to either show the latest posts even if they are for the same topic // Or show only the lastest post for each of the last updated topics if ($latestTopicPost) { $result = DB_query("SELECT id,forum,name,date,subject,replies,views,uid,pid FROM {$_TABLES['gf_topic']} WHERE PID=0 ORDER BY $orderby DESC"); } else { $result = DB_query("SELECT id,forum,name,date,subject,replies,views,uid,pid FROM {$_TABLES['gf_topic']} ORDER BY $orderby DESC"); } $nrows = DB_numrows($result); $onetwo = 1; $displaycount = 0; for ($i =1; $i <= $nrows; $i++) { $A = DB_fetchArray($result); $forum_id = DB_getItem($_TABLES['gf_topic'],'forum',"id='{$A['id']}'"); $grp_id = DB_getItem($_TABLES['gf_forums'],'grp_id',"forum_id='$forum_id'"); $groupname = DB_getItem($_TABLES['groups'],'grp_name',"grp_id='$grp_id'"); if (SEC_inGroup($groupname) OR $grp_id == 2) { $displaycount++; $fullsubject = $A["subject"]; if (strlen ($A["subject"]) > $subject_limit) { $A["subject"] = substr("$A[subject]", 0, $subject_limit); $A["subject"] .= ".."; $profilelink = ""; } if ($A['replies'] > 0 AND $latestTopicPost) { $lastreplySQL = DB_query("Select uid,name,date from {$_TABLES['gf_topic']} WHERE PID={$A['id']} ORDER BY date DESC LIMIT 1"); list ($uid,$postername,$postdate) = DB_fetchArray($lastreplySQL); } else { $postername = $A['name']; $postdate = $A['date']; $uid = $A['uid']; } if ($uid > 1) { $profilelink = ""; } $block_displayline = new Template($_CONF['path_layout'] . 'forum/layout'); $block_displayline->set_file (array ('block_displayline'=>'block_displayline.thtml')); $block_displayline->set_var ('site_url', $_CONF['site_url']); $block_displayline->set_var ('css_id', $onetwo); $block_displayline->set_var ('img_dir', $img_dir); $block_displayline->set_var ('forum_id', $A['forum']); $block_displayline->set_var ('topic_id', $A['id']); $block_displayline->set_var ('topic_subject', $A['subject']); $block_displayline->set_var ('fullsubject', $fullsubject); $block_displayline->set_var ('topic_id', $A['id']); $block_displayline->set_var ('profilelink', $profilelink); $block_displayline->set_var ('user_name', $postername); $block_displayline->set_var ('LANG_BY', $LANG_GF01['BY']); $block_displayline->set_var ('LANG_ON', $LANG_GF01['ON']); $block_displayline->set_var ('LANG_VIEWS', $LANG_GF01['VIEWS']); $block_displayline->set_var ('LANG_REPLIES', $LANG_GF01['REPLIES']); $block_displayline->set_var ('views', $A['views']); $block_displayline->set_var ('replies', $A['replies']); $block_displayline->set_var ('date', strftime('%m/%d/%y %H:%M %p', $postdate)); $block_displayline->parse ('output', 'block_displayline'); $retval .= $block_displayline->finish($block_displayline->get_var('output')); if ($onetwo == 1) { $onetwo = 2; } else { $onetwo = 1; } if ($displaycount >= $post_limit) { break; } } } return $retval; } else { return ""; } } /** * Display latest forum posts in the center block. * * @param where int where the block will be displayed (0..2) * @param page int page number * @param topic string topic ID * @return string HTML for the center blcok (can be empty) */ function plugin_centerblock_forum ($where = 1, $page = 1, $topic = '') { global $_CONF, $_USER, $_TABLES, $LANG_GF01; global $LANG_GF02, $mode, $order, $PHP_SELF; require_once ($_CONF['path_html'] . 'forum/include/config.php'); $post_limit = 10; // How many posts you want displayed $subject_limit = 30; // The length of the subject you want displayed $UserDateTimePref = false; $img_dir = $_CONF['layout_url'] . '/forum/image_set'; $retval = ''; // Retrieve Centerblock Settings $query = DB_query ("SELECT cb_enable, cb_homepage, cb_where FROM {$_TABLES['gf_settings']}"); list ($cb_enable,$cb_homepage,$cb_where) = DB_fetchArray ($query); // If enabled only for homepage and this is not page 1 or a topic page, // then set disable flag if ($cb_homepage == 1 AND ($page > 1 OR !empty ($topic))) { $cb_enable = 0; } elseif ($cb_homepage == 0 and $page > 1) { $cb_where = 1; // Top of Page } // Check if there are no featured articles in this topic // and if so then place it at the top of the page if (!empty ($topic)) { $wheresql = "WHERE tid='$topic' AND featured > 0"; } else { $wheresql = 'WHERE featured = 1'; } $query = DB_query ("SELECT count(*) as count FROM {$_TABLES['stories']} $wheresql"); $result = DB_fetchArray ($query); if ($result['count'] == 0 and $cb_where == 2) { $cb_where = 1; } if ($cb_enable AND ($cb_where == $where)) { $retval .= COM_startBlock ($LANG_GF02['msg170']); $block_header = new Template ($_CONF['path_layout'] . 'forum/layout'); $block_header->set_file (array ('block_header'=>'centerblock_header.thtml')); $block_header->set_var ('phpself', $PHP_SELF); $block_header->set_var ('site_url', $_CONF['site_url']); $block_header->set_var ('layout_url', $_CONF['layout_url']); $block_header->set_var ('LANG_FORUM', $LANG_GF01['FORUM']); $block_header->set_var ('LANG_TOPIC', $LANG_GF01['TOPIC']); $block_header->set_var ('LANG_LASTPOST', $LANG_GF01['LASTPOST']); $block_header->parse ('output', 'block_header'); $retval .= $block_header->finish ($block_header->get_var ('output')); $result = DB_query ("SELECT id,forum,name,lastupdated,subject,uid,pid,replies,views FROM {$_TABLES['gf_topic']} WHERE pid=0 ORDER BY lastupdated DESC"); $nrows = DB_numrows ($result); $onetwo = 1; $displaycount = 0; $block_displayline = new Template ($_CONF['path_layout'] . 'forum/layout'); $block_displayline->set_file (array ('block_displayline' => 'centerblock_displayline.thtml')); $block_displayline->set_var ('site_url', $_CONF['site_url']); $block_displayline->set_var ('LANG_lastpost', $LANG_GF02['msg160']); $cache_in_group = array (); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray ($result); $fresult = DB_query ("SELECT grp_id, forum_name FROM {$_TABLES['gf_forums']} WHERE forum_id='{$A['forum']}'"); list ($grp_id, $forum_name) = DB_fetchArray ($fresult); if ($grp_id != 2) { if (empty ($cache_in_group[$grp_id])) { $groupname = DB_getItem ($_TABLES['groups'], 'grp_name', "grp_id='$grp_id'"); $cache_in_group[$grp_id] = SEC_inGroup ($groupname); } } if (($grp_id == 2) || $cache_in_group[$grp_id]) { $displaycount++; $fullsubject = $A['subject']; if(strlen ($A['subject']) > $subject_limit) { $A['subject'] = substr ($A['subject'], 0, $subject_limit); $A['subject'] .= '...'; } $query2 = DB_query ("SELECT max(id) as lastid FROM {$_TABLES['gf_topic']} WHERE pid= {$A['id']}"); list ($lastid) = DB_fetchArray ($query2); if (empty ($lastid) OR $lastid < 1) { $lastid = $A['id']; } if ($UserDateTimePref) { $lastdate = COM_getUserDateTimeFormat ($A['lastupdated']); $lastdate = $lastdate[0]; } else { $lastdate = strftime ('%m/%d/%y %H:%M', $A['lastupdated']); } $block_displayline->set_var ('css_id', $onetwo); $block_displayline->set_var ('img_dir', $img_dir); $block_displayline->set_var ('forum_id', $A['forum']); $block_displayline->set_var ('forum_name', $forum_name); $block_displayline->set_var ('topic_id', $A['id']); $block_displayline->set_var ('topic_subject', $A['subject']); $block_displayline->set_var ('fullsubject', $fullsubject); $block_displayline->set_var ('views', $A['views']); $block_displayline->set_var ('replies', $A['replies']); $block_displayline->set_var ('date',$lastdate ); $block_displayline->parse ('output', 'block_displayline'); $retval .= $block_displayline->finish ($block_displayline->get_var ('output')); if ($onetwo == 1) { $onetwo = 2; } else { $onetwo = 1; } if ($displaycount >= $post_limit) { break; } } } $block_header = new Template ($_CONF['path_layout'] . 'forum/layout'); $block_header->set_file (array ('block_header' => 'centerblock_footer.thtml')); $block_header->parse ('output', 'block_header'); $retval .= $block_header->finish ($block_header->get_var ('output')); $retval .= COM_endBlock(); } return $retval; } ?>