Esempio n. 1
0
//  ------------------------------------------------------------------------ //
//  Author: wishcraft (S.F.C., sales@chronolabs.org.au)                      //
//  URL: http://www.chronolabs.org.au/forums/X-Forum/0,17,0,0,100,0,DESC,0   //
//  Project: X-Forum 4                                                       //
//  ------------------------------------------------------------------------ //
include 'header.php';

$forum_id = isset($_POST['forum']) ? intval($_POST['forum']) : 0;
$forum_id = isset($_GET['forum']) ? intval($_GET['forum']) : $forum_id;

$isadmin = forum_isAdmin($forum_id);
if(!$isadmin){
    redirect_header(XOOPS_URL."/index.php", 2, _MD_NORIGHTTOACCESS);
    exit();
}
$is_administrator = forum_isAdmin();

$moderate_handler =& xoops_getmodulehandler('moderate', 'xforum');

if(!empty($_POST["submit"])&&!empty($_POST["expire"])){
	if( !empty($_POST["ip"]) && !preg_match("/^([0-9]{1,3}\.){0,3}[0-9]{1,3}$/", $_POST["ip"])) $_POST["ip"]="";
	if(
		(!empty($_POST["uid"]) && $moderate_handler->getLatest($_POST["uid"])>(time()+$_POST["expire"]*3600*24))
		||
		(!empty($_POST["ip"]) && $moderate_handler->getLatest($_POST["ip"], false)>(time()+$_POST["expire"]*3600*24))
		||
		(empty($_POST["uid"]) && empty($_POST["ip"]))
	){
	}else{
		$moderate_obj =& $moderate_handler->create();
		$moderate_obj->setVar("uid", @$_POST["uid"]);
Esempio n. 2
0
if ( !empty($post_id) ) {
    $xforumtopic =& $topic_handler->getByPost($post_id);
} elseif(!empty($move)) {
    $xforumtopic =& $topic_handler->getByMove($topic_id, ($move == "prev")?-1:1, $forum_id);
    $topic_id = $xforumtopic->getVar("topic_id");
} else {
    $xforumtopic =& $topic_handler->get($topic_id);
}
if ( !is_object($xforumtopic) || !$topic_id = $xforumtopic->getVar('topic_id') ) {
    redirect_header('viewforum.php?forum='.$forum_id, 2, _MD_ERRORTOPIC);
}
$forum_id = $xforumtopic->getVar('forum_id');
$forum_handler =& xoops_getmodulehandler('forum', 'xforum');
$viewtopic_forum =& $forum_handler->get($forum_id);

$isadmin = forum_isAdmin($viewtopic_forum);

if(!$isadmin && $xforumtopic->getVar('approved')<0 ){
    redirect_header("viewforum.php?forum=".$forum_id,2,_MD_NORIGHTTOVIEW);
    exit();
}
if (!$forum_handler->getPermission($viewtopic_forum)){
    redirect_header(XOOPS_URL."/index.php", 2, _MD_NORIGHTTOACCESS);
    exit();
}
/* Only admin has access to admin mode */
if(!$isadmin){
	$type = "";
	$mode = 0;
}
if($mode){
Esempio n. 3
0
    function getAllTopics(&$xforum, $startdate, $start, $sortname, $sortorder, $type = '', $excerpt = 0)
    {
        global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $xforumImage, $xforumUrl, $myts, $xoopsUser, $viewall_forums;
		include_once XOOPS_ROOT_PATH.'/modules/xforum/include/functions.php';
		
        $UserUid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : null;

        $topic_lastread = forum_getcookie('LT', true);

        if (is_object($xforum)) {
            $criteria_forum = ' AND t.forum_id = ' . $xforum->getVar('forum_id');
            $hot_threshold = $xforum->getVar('hot_threshold');
            $allow_subject_prefix = $xforum->getVar('allow_subject_prefix');
        } else {
            $hot_threshold = 10;
            $allow_subject_prefix = 0;
            if (is_array($xforum) && count($xforum) > 0){
                $criteria_forum = ' AND t.forum_id IN (' . implode(',', array_keys($xforum)) . ')';
            }elseif(!empty($xforum)){
                $criteria_forum = ' AND t.forum_id ='.intval($xforum);
            }else{
                $criteria_forum = '';
            }
        }

        $sort = array();
        $criteria_post = ' p.post_time > ' . $startdate;
        $criteria_extra = '';
        $criteria_approve = ' AND t.approved = 1 AND p.approved = 1';
        $post_on = ' p.post_id = t.topic_last_post_id';
        //$post_criteria = '';
        $leftjoin = ' LEFT JOIN ' . $this->db->prefix('xf_posts') . ' p ON p.post_id = t.topic_last_post_id';
        switch ($type) {
            case 'digest':
                $criteria_extra = ' AND t.topic_digest = 1';
                break;
            case 'unreplied':
                $criteria_extra = ' AND t.topic_replies < 1';
                break;
            case 'unread':
				//$time_criterion = max($GLOBALS['last_visit'], $startdate);
                if(empty($xoopsModuleConfig["read_mode"])){
                }elseif($xoopsModuleConfig["read_mode"] ==2){
	        		$leftjoin .= ' LEFT JOIN ' . $this->db->prefix('xf_reads_topic') . ' r ON r.read_item = t.topic_id';
	                $criteria_post .= ' AND (r.read_id IS NULL OR r.post_id < t.topic_last_post_id)';
                }elseif($xoopsModuleConfig["read_mode"] == 1){
	        		$topics = array();
	    			$topic_lastread = forum_getcookie('LT', true);
	        		if(count($topic_lastread)>0) foreach($topic_lastread as $id=>$time){
		        		if($time > $time_criterion) $topics[] = $id;
			        }
			        if(count($topics)>0){
	                	$criteria_extra = ' AND t.topic_id NOT IN ('.implode(",", $topics).')';
                	}
                	$criteria_post = ' p.post_time > ' . max($GLOBALS['last_visit'], $startdate);
                }
                break;
            case 'pending':
		        $post_on = ' p.topic_id = t.topic_id';
        		$criteria_post .= ' AND p.pid=0';
        		$criteria_approve = ' AND t.approved = 0';
                break;
            case 'deleted':
        		$criteria_approve = ' AND t.approved = -1';
                break;
            case 'all': // For viewall.php; do not display sticky topics at first
            case 'active': // same as "all"
                //$criteria_post = ' p.post_time > ' . $startdate;
                break;
            default:
                $criteria_post = ' (p.post_time > ' . $startdate . ' OR t.topic_sticky=1)';
                $sort[] = 't.topic_sticky DESC';
                break;
        }
        
        $select = 	't.*, '.
        			' p.post_time as last_post_time, p.poster_name as last_poster_name, p.icon, p.post_id, p.uid';
        $from = $this->db->prefix("xf_topics") . ' t '.$leftjoin;
        $where = $criteria_post. $criteria_forum . $criteria_extra . $criteria_approve;

        if($excerpt){
        	$select .=', p.post_karma, p.require_reply, pt.post_text';
        	$from .= ' LEFT JOIN ' . $this->db->prefix('xf_posts_text') . ' pt ON pt.post_id = t.topic_last_post_id';
    	}
    	if($sortname == "u.uname"){
        	$sortname = "t.topic_poster";
    	}
    	
        $sort[] = trim($sortname.' '.$sortorder);
        $sort = implode(", ", $sort);
        if(empty($sort)) $sort = 'p.post_time DESC';
        
    	$sql = 	'SELECT '.$select.
    			' FROM '.$from.
    			' WHERE '.$where.
    			' ORDER BY '.$sort;
    			
        if (!$result = $this->db->query($sql, $xoopsModuleConfig['topics_per_page'], $start)) {
            redirect_header('index.php', 2, _MD_ERROROCCURED . '<br />' . $sql);
            exit();
        }

        $subject_array = array();
        if(!empty($allow_subject_prefix) && !empty($xoopsModuleConfig['subject_prefix'])):
        $subjectpres = explode(',', $xoopsModuleConfig['subject_prefix']);
        if (count($subjectpres) > 1) {
            foreach($subjectpres as $subjectpre) {
                $subject_array[] = $subjectpre." ";
            }
        }
        endif;
        $subject_array[0] = null;


        $sticky = 0;
        $topics = array();
        $posters = array();
        $reads = array();
        while ($myrow = $this->db->fetchArray($result)) {
            if ($myrow['topic_sticky']) {
                $sticky++;
            }
            
            // ------------------------------------------------------
            // topic_icon: priority: sticky -> digest -> regular
            
            if ($myrow['topic_haspoll']) {
	            if ($myrow['topic_sticky']) {
	                $topic_icon = forum_displayImage($xforumImage['folder_sticky'], _MD_TOPICSTICKY) . '<br />' . forum_displayImage($xforumImage['poll'], _MD_TOPICHASPOLL);
	            }else{
                	$topic_icon = forum_displayImage($xforumImage['poll'], _MD_TOPICHASPOLL);
	            }
            }elseif($myrow['topic_sticky']) {
                $topic_icon = forum_displayImage($xforumImage['folder_sticky'], _MD_TOPICSTICKY);
            }elseif (!empty($myrow['icon'])) {
                $topic_icon = '<img src="' . XOOPS_URL . '/images/subject/' . htmlspecialchars($myrow['icon']) . '" alt="" />';
            } else {
                $topic_icon = '<img src="' . XOOPS_URL . '/images/icons/no_posticon.gif" alt="" />';
            }
            // ------------------------------------------------------
            // rating_img
            $rating = number_format($myrow['rating'] / 2, 0);
            $rating_img = forum_displayImage($xforumImage[($rating < 1)?'blank':'rate' . $rating]);
            // ------------------------------------------------------
            // topic_page_jump
            $topic_page_jump = '';
            $topic_page_jump_icon = '';
            $totalpages = ceil(($myrow['topic_replies'] + 1) / $xoopsModuleConfig['posts_per_page']);
            if ($totalpages > 1) {
                $topic_page_jump .= '&nbsp;&nbsp;';
                $append = false;
                for ($i = 1; $i <= $totalpages; $i++) {
                    if ($i > 3 && $i < $totalpages) {
	                    if(!$append){
                        	$topic_page_jump .= "...";
                        	$append = true;
                    	}
                    } else {
                        $topic_page_jump .= '[<a href="'.XOOPS_URL.'/modules/xforum/'.'viewtopic.php?topic_id=' . $myrow['topic_id'] . '&amp;start=' . (($i - 1) * $xoopsModuleConfig['posts_per_page']) . '">' . $i . '</a>]';
                        $topic_page_jump_icon = "<a href='" . XOOPS_URL . "/modules/xforum/viewtopic.php?topic_id=" . $myrow['topic_id'] . "&amp;start=" . (($i - 1) * $xoopsModuleConfig['posts_per_page']) . "#forumpost" . $myrow['post_id'] . "'>" . forum_displayImage($xforumImage['docicon']) . "</a>";
                    }
                }
            }
            else {
            	$topic_page_jump_icon = "<a href='" . XOOPS_URL . "/modules/xforum/viewtopic.php?topic_id=" . $myrow['topic_id'] . "#forumpost" . $myrow['post_id'] . "'>" . forum_displayImage($xforumImage['docicon']) . "</a>";
        	}
            // ------------------------------------------------------
            // => topic array
            if (is_object($viewall_forums[$myrow['forum_id']])){
                $forum_link = '<a href="' . XOOPS_URL . '/modules/xforum/viewforum.php?forum=' . $myrow['forum_id'] . '">' . $viewall_forums[$myrow['forum_id']]->getVar('forum_name') . '</a>';
            }else {
	            $forum_link = '';
            }

           	$topic_title = $myts->htmlSpecialChars($myrow['topic_title']);
            if ($myrow['topic_digest']) $topic_title = "<span class='digest'>" . $topic_title . "</span>";

            if( $excerpt == 0 ){
	            $topic_excerpt = "";
            }elseif( ($myrow['post_karma']>0 || $myrow['require_reply']>0) && !forum_isAdmin($xforum) ){
	            $topic_excerpt = "";
            }else{
	            $topic_excerpt = xoops_substr(forum_html2text($myts->displayTarea($myrow['post_text'])), 0, $excerpt);
	            $topic_excerpt = str_replace("[", "&#91;", $myts->htmlSpecialChars($topic_excerpt));
            }

            $topic_subject = ($allow_subject_prefix)?$subject_array[$myrow['topic_subject']]:"";
            $topics[$myrow['topic_id']] = array(
            	'topic_id' => $myrow['topic_id'],
            	'topic_icon' => $topic_icon,
                //'topic_folder' => forum_displayImage($topic_folder),
                'topic_title' => $topic_subject.$topic_title,
                'topic_link' => XOOPS_URL.'/modules/xforum/'.'viewtopic.php?topic_id=' . $myrow['topic_id'] . '&amp;forum=' . $myrow['forum_id'],
                'rating_img' => $rating_img,
                'topic_page_jump' => $topic_page_jump,
                'topic_page_jump_icon' => $topic_page_jump_icon,
                'topic_replies' => $myrow['topic_replies'],
                'topic_poster_uid' => $myrow['topic_poster'],
                'topic_poster_name' => $myts->htmlSpecialChars( ($myrow['poster_name'])?$myrow['poster_name']:$xoopsConfig['anonymous']),
                'topic_views' => $myrow['topic_views'],
                'topic_time' => forum_formatTimestamp($myrow['topic_time']),
                'topic_last_posttime' => forum_formatTimestamp($myrow['last_post_time']),
                'topic_last_poster_uid' => $myrow['uid'],
                'topic_last_poster_name' => $myts->htmlSpecialChars( ($myrow['last_poster_name'])?$myrow['last_poster_name']:$xoopsConfig['anonymous']),
                'topic_forum_link' => $forum_link,
                'topic_excerpt' => $topic_excerpt,
                'stick' => empty($myrow['topic_sticky']),
                "stats" => array($myrow['topic_status'], $myrow['topic_digest'], $myrow['topic_replies']),
                );
                
            /* users */
            $posters[$myrow['topic_poster']] = 1;
            $posters[$myrow['uid']] = 1;
            // reads
            if(!empty($xoopsModuleConfig["read_mode"])){
            	$reads[$myrow['topic_id']] = ($xoopsModuleConfig["read_mode"] == 1)?$myrow['last_post_time']:$myrow["topic_last_post_id"];
        	}
        }
		$posters_name =& forum_getUnameFromIds(array_keys($posters), $xoopsModuleConfig['show_realname'], true);
        $topic_isRead = forum_isRead("topic", $reads);
        
        foreach(array_keys($topics) as $id){
            $topics[$id]["topic_poster"] = !empty($posters_name[$topics[$id]["topic_poster_uid"]])?
                                			$posters_name[$topics[$id]["topic_poster_uid"]]
            								:$topics[$id]["topic_poster_name"];
            $topics[$id]["topic_last_poster"] = !empty($posters_name[$topics[$id]["topic_last_poster_uid"]])?
                                			$posters_name[$topics[$id]["topic_last_poster_uid"]]
            								:$topics[$id]["topic_last_poster_name"];
           	// ------------------------------------------------------
            // topic_folder: priority: newhot -> hot/new -> regular
            list($topic_status, $topic_digest, $topic_replies) = $topics[$id]["stats"];
            if ($topic_status == 1) {
                $topic_folder = $xforumImage['locked_topic'];
            } else {
                if ($topic_digest) $topic_folder = $xforumImage['folder_digest'];
                elseif ($topic_replies >= $hot_threshold) {
	                if(empty($topic_isRead[$id])){
                        $topic_folder = $xforumImage['hot_newposts_topic'];
                    } else {
                        $topic_folder = $xforumImage['hot_folder_topic'];
                    }
                } else {
	                if(empty($topic_isRead[$id])){
                        $topic_folder = $xforumImage['newposts_topic'];
                    } else {
                        $topic_folder = $xforumImage['folder_topic'];
                    }
                }
            }
			$topics[$id]['topic_folder'] = forum_displayImage($topic_folder);
            								
            unset($topics[$id]["topic_poster_name"], $topics[$id]["topic_last_poster_name"], $topics[$id]["stats"]);
        }

        if ( count($topics) > 0) {
	    	$sql = " SELECT DISTINCT topic_id FROM " . $this->db->prefix("xf_posts").
	    	 		" WHERE attachment != ''".
	    	 		" AND topic_id IN (" . implode(',', array_keys($topics)) . ")";
            if($result = $this->db->query($sql)) {
                while (list($topic_id) = $this->db->fetchRow($result)) {
                    $topics[$topic_id]['attachment'] = '&nbsp;' . forum_displayImage($xforumImage['clip'], _MD_TOPICSHASATT);
                }
            }
        }
        return array($topics, $sticky);
    }
Esempio n. 4
0
function forum_checkSubjectPrefixPermission($xforum = 0, $user=-1)
{
	global $xoopsUser, $xoopsModuleConfig;

	if($xoopsModuleConfig['subject_prefix_level']<1){
		return false;
	}
	if($xoopsModuleConfig['subject_prefix_level']==1){
		return true;
	}
	if(is_numeric($user) && $user == -1) $user =& $xoopsUser;
	if(!is_object($user) && intval($user)<1) return false;
	$uid = (is_object($user))?$user->getVar('uid'):intval($user);
	if($xoopsModuleConfig['subject_prefix_level']==2){
		return true;
	}
	if($xoopsModuleConfig['subject_prefix_level']==3){
		if(forum_isAdmin($xforum, $user)) return true;
		else return false;
	}
	if($xoopsModuleConfig['subject_prefix_level']==4){
		if(forum_isAdministrator($user)) return true;
	}
	return false;
}
Esempio n. 5
0

$xoops_pagetitle = $forum_obj->getVar('forum_name') . " [" .$xoopsModule->getVar('name')."]";
if(!empty($xoopsModuleConfig['rss_enable'])){
	$xoops_module_header .= '<link rel="alternate" type="application/xml+rss" title="'.$xoopsModule->getVar('name').'-'.$forum_obj->getVar('forum_name').'" href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/rss.php?f='.$forum_id.'" />';
}

$xoopsOption['template_main'] = 'xforum_viewforum.html';
$xoopsOption['xoops_pagetitle']= $xoops_pagetitle;
$xoopsOption['xoops_module_header']= $xoops_module_header;
include XOOPS_ROOT_PATH."/header.php";
$xoopsTpl->assign('xoops_module_header', $xoops_module_header);
$xoopsTpl->assign('xoops_pagetitle', $xoops_pagetitle);
$xoopsTpl->assign("forum_id", $forum_obj->getVar('forum_id'));

$isadmin = forum_isAdmin($forum_obj);
$xoopsTpl->assign('viewer_level', ($isadmin)?2:(is_object($xoopsUser)?1:0) );
/* Only admin has access to admin mode */
if(!$isadmin){
	$type = (!empty($type) && in_array($type, array("active", "pending", "deleted")))?"":$type;
	$mode = 0;
}
$xoopsTpl->assign('mode', $mode);
$xoopsTpl->assign('type', $type);

if ($xoopsModuleConfig['wol_enabled']){
	$online_handler =& xoops_getmodulehandler('online', 'xforum');
	$online_handler->init($forum_obj);
    $xoopsTpl->assign('online', $online_handler->show_online());
}
Esempio n. 6
0
// To enable image auto-resize by js
$xoops_module_header .= '<script src="'.XOOPS_URL.'/Frameworks/textsanitizer/xoops.js" type="text/javascript"></script>';

$start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
$forum_id = !empty($_GET['forum']) ? intval($_GET['forum']) : 0;
$order = isset($_GET['order'])?$_GET['order']:"DESC";

$uid = !empty($_GET['uid']) ? intval($_GET['uid']) : 0;
$type = (!empty($_GET['type']) && in_array($_GET['type'], array("active", "pending", "deleted", "new")))? $_GET['type'] : "";
$mode = !empty($_GET['mode']) ? intval($_GET['mode']) : 0;
$mode = (!empty($type) && in_array($type, array("active", "pending", "deleted")) )?2:$mode;

$forum_handler =& xoops_getmodulehandler('forum', 'xforum');
$post_handler =& xoops_getmodulehandler('post', 'xforum');

$isadmin = forum_isAdmin($forum_id);
/* Only admin has access to admin mode */
if(!$isadmin){
	$type = in_array($type, array("active", "pending", "deleted"))?"":$type;
	$mode = 0;
}
if($mode){
	$_GET['viewmode'] = "flat";
}

if(empty($forum_id)){
	$xforums = $forum_handler->getForums(0, "view");
	$access_forums = array_keys($xforums);
}else{
	$forum_obj =& $forum_handler->get($forum_id);
	$xforums[$forum_id] =& $forum_obj;
Esempio n. 7
0
    function getPermission($xforum, $topic_locked = 0, $type = "view")
    {
        global $xoopsUser, $xoopsModule;
        static $_cachedTopicPerms;

        if(forum_isAdmin($xforum)) return 1;

        $xforum = is_object($xforum)?$xforum->getVar('forum_id'):intval($xforum);
	    if($xforum<1) return false;

        if (!isset($_cachedTopicPerms)){
            $getpermission = &xoops_getmodulehandler('permission', 'xforum');
            $_cachedTopicPerms = $getpermission->getPermissions("forum", $xforum);
        }

        $type = strtolower($type);
        $perm_item = 'forum_' . $type;
        $permission = (isset($_cachedTopicPerms[$xforum][$perm_item])) ? 1 : 0;

        if ($topic_locked && 'view' != $type) $permission = 0;

        return $permission;
    }
Esempio n. 8
0
}

if ( !empty($_POST['contents_preview']) || !empty($_GET['contents_preview']) ) {
	if (!empty($_POST["attachments_tmp"])){
		$attachments_tmp=unserialize(base64_decode($_POST["attachments_tmp"]));
	}

    $myts =& MyTextSanitizer::getInstance();
    $p_subject = $myts->htmlSpecialChars($myts->stripSlashesGPC($_POST['subject']));
    $dosmiley = empty($_POST['dosmiley']) ? 0 : 1;
    $dohtml = empty($_POST['dohtml']) ? 0 : 1;
    $doxcode = empty($_POST['doxcode']) ? 0 : 1;
    $dobr = empty($_POST['dobr']) ? 0 : 1;
    $p_message = $_POST['message'];
    $p_message = $myts->previewTarea($p_message, $dohtml, $dosmiley, $doxcode, 1, $dobr);
	if($dohtml && !forum_isAdmin($forum_obj) ) {
		//$p_message = forum_textFilter($p_message);
	}

    echo "<table cellpadding='4' cellspacing='1' width='98%' class='outer'>";
    echo "<tr><td class='head'>".$p_subject."</td></tr>";
    if(isset($_POST['poster_name'])){
		$p_poster_name = $myts->htmlSpecialChars($myts->stripSlashesGPC($_POST['poster_name']));
		echo "<tr><td>".$p_poster_name."</td></tr>";
	}
    echo "<tr><td><br />".$p_message."<br /></td></tr></table>";
}

if ( !empty($_POST['contents_upload']) || !empty($_POST['contents_preview']) || !empty($_GET['contents_preview']) || !empty($_POST['editor'])) 
{
Esempio n. 9
0
	$user_karma = $karma_handler->getUserKarma();

    foreach ($forumpostshow as $eachpost) {
    	// Sorry, in order to save queries, we have to hide the non-open post_text even if you have replied or have adequate karma, even an admin.
	    if( $xoopsModuleConfig['enable_karma'] && $eachpost->getVar('post_karma') > 0 ) {
	        $p_message = sprintf(_MD_KARMA_REQUIREMENT, "***", $eachpost->getVar('post_karma'))."</div>";
	    }elseif( $xoopsModuleConfig['allow_require_reply'] && $eachpost->getVar('require_reply') ) {
	        $p_message = _MD_REPLY_REQUIREMENT;
	    }else{
		    $p_message = $eachpost->getVar('post_text');
	    }

    	$isadmin = 0;
    	if($eachpost->getVar('uid')) {
	    	$p_name =forum_getUnameFromId( $eachpost->getVar('uid'), $xoopsModuleConfig['show_realname'] );
			if (forum_isAdmin($forum_obj, $eachpost->getVar('uid'))) $isadmin = 1;
    	}else{
	    	$poster_name = $eachpost->getVar('poster_name');
    		$p_name = (empty($poster_name))?$xoopsConfig['anonymous']:$myts->htmlSpecialChars($poster_name);
		}
		$p_date = formatTimestamp($eachpost->getVar('post_time'));
		/*
	    if( $isadmin && $xoopsModuleConfig['allow_moderator_html']){
	    	$p_subject = $myts->undoHtmlSpecialChars($eachpost->getVar('subject'));
		}else{
	    	$p_subject = $eachpost->getVar('subject');
		}
		*/
	    $p_subject = $eachpost->getVar('subject');
    	$p_content = _MD_BY." <strong> ".$p_name." </strong> "._MD_ON." <strong> ".$p_date."</strong><br /><br />";
    	$p_content .= $p_message;
Esempio n. 10
0
    $attachments=$forumpost->getAttachment();
    $post_karma=$forumpost->getVar('post_karma');
    $require_reply=$forumpost->getVar('require_reply');
    $tags=$forumpost->getVar('tags', "E");
    $hidden = "";

    include 'include/forumform.inc.php';
    if (!$istopic) {
        $forumpost2 =& $post_handler->get($post_id2);

	    $r_message = $forumpost2->getVar('post_text');

    	$isadmin = 0;
    	if($forumpost2->getVar('uid')) {
	    	$r_name = forum_getUnameFromId( $forumpost2->getVar('uid'), $xoopsModuleConfig['show_realname']);
			if (forum_isAdmin($forum_obj, $forumpost2->getVar('uid'))) $isadmin = 1;
    	}else{
	    	$poster_name = $forumpost2->getVar('poster_name');
    		$r_name = (empty($poster_name))?$xoopsConfig['anonymous']:$poster_name;
		}
		$r_date = formatTimestamp($forumpost2->getVar('post_time'));
	    $r_subject = $forumpost2->getVar('subject');

        $r_content = _MD_BY." ".$r_name." "._MD_ON." ".$r_date."<br /><br />";
        $r_content .= $r_message;
        $r_subject=$forumpost2->getVar('subject');
        echo "<table cellpadding='4' cellspacing='1' width='98%' class='outer'><tr><td class='head'>".$r_subject."</td></tr>";
        echo "<tr><td><br />".$r_content."<br /></td></tr></table>";
    }

    include XOOPS_ROOT_PATH.'/footer.php';
Esempio n. 11
0
    function &getPostBody($imageAsSource = false)
    {
        global $xoopsConfig, $xoopsModuleConfig, $xoopsUser, $myts;

        $uid = is_object($xoopsUser)? $xoopsUser->getVar('uid'):0;
		$karma_handler =& xoops_getmodulehandler('karma', 'xforum');
		$user_karma = $karma_handler->getUserKarma();

		$post=array();
		$post['attachment'] = false;
		$post_text = forum_displayTarea($this->vars['post_text']['value'], $this->getVar('dohtml'), $this->getVar('dosmiley'), $this->getVar('doxcode'), $this->getVar('doimage'), $this->getVar('dobr'));
        if (forum_isAdmin($this->getVar('forum_id')) or $this->checkIdentity()) {
            $post['text'] = $post_text. '<br />' .$this->displayAttachment($imageAsSource);
        } elseif ($xoopsModuleConfig['enable_karma'] && $this->getVar('post_karma') > $user_karma) {
            $post['text'] = sprintf(_MD_KARMA_REQUIREMENT, $user_karma, $this->getVar('post_karma'));
        } elseif ($xoopsModuleConfig['allow_require_reply'] && $this->getVar('require_reply') && (!$uid || !isset($viewtopic_users[$uid]))) {
            $post['text'] = _MD_REPLY_REQUIREMENT;
        } else {
            $post['text'] = $post_text. '<br />' .$this->displayAttachment($imageAsSource);
        }
		$member_handler =& xoops_gethandler('member');
        $eachposter = &$member_handler->getUser($this->getVar('uid'));
        if (is_object($eachposter) && $eachposter->isActive()) {
            if ($xoopsModuleConfig['show_realname'] && $eachposter->getVar('name')) {
                $post['author'] = $eachposter->getVar('name');
            } else {
                $post['author'] = $eachposter->getVar('uname');
            }
        	unset($eachposter);
        } else {
           	$post['author'] = $this->getVar('poster_name')?$this->getVar('poster_name'):$xoopsConfig['anonymous'];
        }

        $post['subject'] = forum_htmlSpecialChars($this->vars['subject']['value']);

        $post['date'] = $this->getVar('post_time');

        return $post;
    }
Esempio n. 12
0
    function getPermissions($type = "forum", $id = 0)
    {
        global $xoopsUser;
        static $permissions = array(), $suspension = array();

        $type = (strtolower($type) !="category")?"forum":"category";
        
	    if(is_object($GLOBALS["xoopsModule"]) && $GLOBALS["xoopsModule"]->getVar("dirname")=="xforum"){
        	$modid = $GLOBALS["xoopsModule"]->getVar("mid");
	    }else{
    		$module_handler =& xoops_gethandler('module');
			$xoopsxforum =& $module_handler->getByDirname('xforum');
			$modid = $xoopsxforum->getVar("mid");
			unset($xoopsxforum);
	    }
        
	    $uid = is_object($GLOBALS["xoopsUser"])?$GLOBALS["xoopsUser"]->getVar("uid"):0;
		$ip = forum_getIP(true);
		if (($type == "forum") && !forum_isAdmin($id) && !isset($suspension[$uid][$id]) && !empty($GLOBALS["xoopsModuleConfig"]['enable_usermoderate'])){
			$moderate_handler =& xoops_getmodulehandler('moderate', 'xforum');
			if($moderate_handler->verifyUser($uid,"",$id)){
				$suspension[$uid][$ip][$id] = 1;
			}else{
				$suspension[$uid][$ip][$id] = 0;
			}
		}

        if (!isset($permissions[$type]) || ($id && !isset($permissions[$type][$id]))) {
            // Get group permissions handler
            $gperm_handler =& xoops_gethandler('groupperm');
            // Get user's groups
            $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
            // Create string of groupid's separated by commas, inserted in a set of brackets
            if (count($groups) < 1) return false;
            $groupstring = "(" . implode(',', $groups) . ")";
            // Create criteria for getting only the permissions regarding this module and this user's groups
            $criteria = new CriteriaCompo(new Criteria('gperm_modid', $modid));
            $criteria->add(new Criteria('gperm_groupid', $groupstring, 'IN'));
            if ($id) {
                if (is_array($id)) {
                    $counter = 0;
                    $idstring = "(" . implode(',', $id) . ")";
                    $criteria->add(new Criteria('gperm_itemid', $idstring, 'IN'));
                } else {
                    $criteria->add(new Criteria('gperm_itemid', intval($id)));
                }
            }

            switch ($type) {
                case "forum":
                    $items = array_map("trim",explode(',', FORUM_PERM_ITEMS));

                    $full_items = array();
                    foreach($items as $item) {
	                    /* skip access for suspended users */
						if( !empty($suspension[$uid][$ip][$id]) && in_array($item,array("post", "reply", "edit", "delete", "addpoll", "vote", "attach", "noapprove")) ) continue;
                        $full_items[] = "'forum_" . $item . "'";
                    }
                    $gperm_names = implode(',', $full_items);
                    break;

                case "category":
                    $gperm_names = "'category_access'";
                    break;
            }
            // Add criteria for gpermnames
            $criteria->add(new Criteria('gperm_name', "(" . $gperm_names . ")", 'IN'));
            // Get all permission objects in this module and for this user's groups
            $userpermissions =& $gperm_handler->getObjects($criteria, true);
                        
            // Set the granted permissions to 1
            foreach ($userpermissions as $gperm_id => $gperm) {
                $permissions[$type][$gperm->getVar('gperm_itemid')][$gperm->getVar('gperm_name')] = 1;
            }
            unset($userpermissions);
        }
        // Return the permission array
        return isset($permissions[$type]) ? $permissions[$type] : array();
    }
Esempio n. 13
0
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
//  Author: wishcraft (S.F.C., sales@chronolabs.org.au)                      //
//  URL: http://www.chronolabs.org.au/forums/X-Forum/0,17,0,0,100,0,DESC,0   //
//  Project: X-Forum 4                                                       //
//  ------------------------------------------------------------------------ //

include "header.php";

$type = (!empty($_GET['type']) && in_array($_GET['type'], array("active", "pending", "deleted", "digest", "unreplied", "unread")))? $_GET['type'] : "";
$mode = !empty($_GET['mode']) ? intval($_GET['mode']) : 0;
$mode = (!empty($type) && in_array($type, array("active", "pending", "deleted")))?2:$mode;

$isadmin = forum_isAdmin();
/* Only admin has access to admin mode */
if(!$isadmin){
	$type = (!empty($type) && in_array($type, array("active", "pending", "deleted")))?"":$type;
	$mode = 0;
}

if(!empty($xoopsModuleConfig['rss_enable'])){
	$xoops_module_header .= '<link rel="alternate" type="application/rss+xml" title="'.$xoopsModule->getVar('name').'" href="'.XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname').'/rss.php" />';
}
$xoopsOption['xoops_module_header']= $xoops_module_header;
$xoopsOption['template_main'] = 'xforum_viewall.html';
include XOOPS_ROOT_PATH."/header.php";
$xoopsTpl->assign('xoops_module_header', $xoops_module_header);

$forum_handler =& xoops_getmodulehandler('forum', 'xforum');