Ejemplo n.º 1
0
 function &getInstance($mydirname)
 {
     static $instance;
     if (!isset($instance)) {
         $instance = new BulletinGP($mydirname);
     }
     $instance->BulletinGP($mydirname);
     return $instance;
 }
Ejemplo n.º 2
0
function bulletin_get_submenu($mydirname)
{
    static $submenus_cache;
    if (!empty($submenus_cache[$mydirname])) {
        return $submenus_cache[$mydirname];
    }
    $db =& Database::getInstance();
    $myts =& MyTextSanitizer::getInstance();
    $categories = array(0 => array('pid' => -1, 'name' => '', 'url' => '', 'sub' => array()));
    require_once dirname(dirname(__FILE__)) . '/class/bulletingp.php';
    //ver3.0 can_read access
    $gperm =& BulletinGP::getInstance($mydirname);
    $can_read_topic_ids = $gperm->makeOnTopics('can_read');
    if (empty($can_read_topic_ids)) {
        return array();
    }
    // categories query
    //ver2.0 $sql = "SELECT topic_id,topic_pid,topic_title FROM ".$db->prefix($mydirname."_topics")." ORDER BY topic_title" ;
    //ver3.0
    $sql = 'SELECT topic_id,topic_pid,topic_title';
    $sql .= ' FROM ' . $db->prefix($mydirname . '_topics');
    $sql .= ' WHERE topic_id IN (' . implode(',', $can_read_topic_ids) . ')';
    $sql .= ' ORDER BY topic_title';
    $crs = $db->query($sql);
    if ($crs) {
        while ($cat_row = $db->fetchArray($crs)) {
            $topic_id = intval($cat_row['topic_id']);
            $categories[$topic_id] = array('name' => $myts->makeTboxData4Show($cat_row['topic_title']), 'url' => 'index.php?storytopic=' . $topic_id, 'pid' => $cat_row['topic_pid']);
        }
    }
    // restruct categories
    $submenus_cache[$mydirname] = array_merge($categories[0]['sub'], bulletin_restruct_categories($categories, 0));
    return $submenus_cache[$mydirname];
}
Ejemplo n.º 3
0
function b_bulletin_bigstory_show($options) {

	global $xoopsDB;

	$myts =& MyTextSanitizer::getInstance();

	$mydirname = empty( $options[0] ) ? basename( dirname( dirname( __FILE__ ) ) ) : $options[0] ;
	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;
	if (!isset($options[1])){
		$options[1] = 0 ;//(0=show all for d3pipes)
	}
	$categories = empty($options[1]) ? 0 : array_map( 'intval' , explode( ',' , $options[1] ) ) ;//(0=show all)

	require dirname( dirname( __FILE__ ) ).'/include/configs.inc.php';
	require_once dirname(dirname(__FILE__)).'/class/bulletingp.php' ;

	$block = array();
//ver3.0 can_read access
	$gperm =& BulletinGP::getInstance($mydirname) ;
	$can_read_topic_ids = $gperm->makeOnTopics('can_read');
	if (empty($can_read_topic_ids)){
		return false;
	}

	$tdate = mktime(0,0,0,date("n"),date("j"),date("Y"));
//ver2.0
//	$result = $xoopsDB->query("SELECT storyid, title FROM ".$xoopsDB->prefix("{$mydirname}_stories")." WHERE published > ".$tdate." AND published < ".time()." AND (expired > ".time()." OR expired = 0) ORDER BY counter DESC",1,0);
//ver3.0
	$sql = "SELECT s.*, t.topic_pid, t.topic_imgurl, t.topic_title, t.topic_created, t.topic_modified";
	$sql .= ' FROM ' . $xoopsDB->prefix($mydirname.'_stories') . ' s, ' . $xoopsDB->prefix($mydirname.'_topics') . ' t';
	$sql .= ' WHERE s.type > 0 AND s.published < '.time().' AND s.published > 0 AND (s.expired = 0 OR s.expired > '.time().') AND s.topicid = t.topic_id AND s.block = 1';
	$sql .= " AND s.published > ".$tdate;
	if (!empty($categories)){
		$sql .= ' AND s.topicid IN ('.implode(',',$categories).')';
	}
	$sql .= ' AND s.topicid IN ('.implode(',',$can_read_topic_ids).')';
	$sql .= " ORDER BY counter DESC";
	$result = $xoopsDB->query($sql,1,0);
	//ver3.0 fix when all no data
	while ( $myrow = $xoopsDB->fetchArray($result) ) {
		$block['message'] = _MB_BULLETIN_TMRSI;
		$block['title']   = $myts->makeTboxData4Show($myrow['title']);//ver3.0 changed
		$block['storyid'] = $myrow['storyid'];//ver3.0 changed
		$block['raw_data'] = $myrow;
	}
	if (empty($block)){
		$block['message'] = _MB_BULLETIN_NOTYET;
	}


	$block['mydirname'] = $mydirname;


	return $block;

}
Ejemplo n.º 4
0
 function bulletin_whatsnew_base($mydirname, $limit = 0, $offset = 0, $category_option = '')
 {
     $db =& Database::getInstance();
     $categories = empty($category_option) ? 0 : array_map('intval', explode(',', $category_option));
     //(0=show all)
     $myts =& MyTextSanitizer::getInstance();
     require_once dirname(dirname(__FILE__)) . '/class/bulletingp.php';
     $ret = array();
     //ver3.0 can_read access
     $gperm =& BulletinGP::getInstance($mydirname);
     $can_read_topic_ids = $gperm->makeOnTopics('can_read');
     if (empty($can_read_topic_ids)) {
         return $ret;
     }
     // DB table name
     $sql = "SELECT s.*, t.topic_pid, t.topic_imgurl, t.topic_title, t.topic_created, t.topic_modified";
     $sql .= ' FROM ' . $db->prefix($mydirname . '_stories') . ' s, ' . $db->prefix($mydirname . '_topics') . ' t';
     $sql .= ' WHERE s.type > 0 AND s.published < ' . time() . ' AND s.published > 0 AND (s.expired = 0 OR s.expired > ' . time() . ') AND s.topicid = t.topic_id AND s.block = 1';
     if (!empty($categories)) {
         $sql .= ' AND s.topicid IN (' . implode(',', $categories) . ')';
     }
     $sql .= ' AND s.topicid IN (' . implode(',', $can_read_topic_ids) . ')';
     $sql .= ' ORDER BY published DESC';
     $result = $db->query($sql, $limit, $offset);
     $URL_MOD = XOOPS_URL . "/modules/" . $mydirname;
     $i = 0;
     while ($row = $db->fetchArray($result)) {
         $id = $row['storyid'];
         $catid = $row['topicid'];
         // bulletin 2.02
         $ret[$i]['link'] = $URL_MOD . "/index.php?page=article&storyid=" . $id;
         $ret[$i]['pda'] = $URL_MOD . "/index.php?page=print&storyid=" . $id;
         $ret[$i]['cat_link'] = $URL_MOD . "/index.php?storytopic=" . $catid;
         $ret[$i]['title'] = $row['title'];
         $ret[$i]['cat_name'] = $row['topic_title'];
         $ret[$i]['time'] = $row['published'];
         $ret[$i]['uid'] = $row['uid'];
         $ret[$i]['hits'] = $row['counter'];
         $ret[$i]['id'] = $id;
         // description
         $html = $row['html'];
         $smiley = $row['smiley'];
         $xcode = $row['xcode'];
         $image = 1;
         $br = $row['br'];
         $desc = $row['hometext'];
         $desc = $myts->displayTarea($desc, $html, $smiley, $xcode, $image, $br);
         $ret[$i]['description'] = $desc;
         $i++;
     }
     return $ret;
 }
Ejemplo n.º 5
0
 function bulletin_search_base($mydirname, $queryarray, $andor, $limit, $offset, $userid)
 {
     global $xoopsDB;
     $showcontext = isset($_GET['showcontext']) ? $_GET['showcontext'] : 0;
     if ($showcontext == 1 && function_exists('search_make_context')) {
         $sql = "SELECT storyid,uid,title,published,hometext,bodytext,html,smiley FROM " . $xoopsDB->prefix($mydirname . "_stories") . " WHERE published > 0 AND published <= " . time() . " AND (expired = 0 OR expired >= " . time() . " )";
     } else {
         $sql = "SELECT storyid,uid,title,published FROM " . $xoopsDB->prefix($mydirname . "_stories") . " WHERE published > 0 AND published <= " . time() . " AND (expired = 0 OR expired >= " . time() . " )";
     }
     //ver3.0
     $gperm =& BulletinGP::getInstance($mydirname);
     $can_read_topic_ids = $gperm->makeOnTopics('can_read');
     $sql .= " AND topicid IN (" . implode(',', $can_read_topic_ids) . ")";
     if ($userid != 0) {
         $sql .= " AND uid=" . $userid . " ";
     }
     // because count() returns 1 even if a supplied variable
     // is not an array, we must check if $querryarray is really an array
     if (is_array($queryarray) && ($count = count($queryarray))) {
         $sql .= " AND ((hometext LIKE '%{$queryarray['0']}%' OR bodytext LIKE '%{$queryarray['0']}%' OR title LIKE '%{$queryarray['0']}%')";
         for ($i = 1; $i < $count; $i++) {
             $sql .= " {$andor} ";
             $sql .= "(hometext LIKE '%{$queryarray[$i]}%' OR bodytext LIKE '%{$queryarray[$i]}%' OR title LIKE '%{$queryarray[$i]}%')";
         }
         $sql .= ") ";
     }
     $sql .= "ORDER BY published DESC";
     $result = $xoopsDB->query($sql, $limit, $offset);
     $ret = array();
     $i = 0;
     $myts =& MyTextSanitizer::getInstance();
     while ($myrow = $xoopsDB->fetchArray($result)) {
         $ret[$i]['image'] = 'images/forum.gif';
         $ret[$i]['link'] = 'index.php?page=article&amp;storyid=' . $myrow['storyid'];
         $ret[$i]['title'] = $myrow['title'];
         $ret[$i]['time'] = $myrow['published'];
         $ret[$i]['uid'] = $myrow['uid'];
         if (!empty($myrow['hometext'])) {
             $context = $myrow['hometext'] . $myrow['bodytext'];
             $context = strip_tags($myts->displayTarea(strip_tags($context), $myrow['html'], $myrow['smiley'], 1));
             $ret[$i]['context'] = search_make_context($context, $queryarray);
         }
         $i++;
     }
     return $ret;
 }
Ejemplo n.º 6
0
} else {
	$xoopsTpl->assign('displaynav', false);
}

// Links from the calendar (if there is a date)
if( !empty($caldate) && preg_match('/([0-9]{4})-([0-9]{2})-([0-9]{2})/', $caldate, $datearr) ){
	$articles = Bulletin::getAllToday( $mydirname , $storynum, $start, $caldate, true , true);
	$xoopsTpl->assign('displaynav', false);
}else{
// If the normal display
	$articles = Bulletin::getAllPublished( $mydirname , $storynum, $start, $storytopic, 1, true, true, true);//ver3.0 changed
}

$scount = count($articles);
$gperm =& BulletinGP::getInstance($mydirname) ;

// Loop of the article
for ( $i = 0; $i < $scount; $i++ ) {
	$story = array();

	$story['id']         = $articles[$i]->getVar('storyid');
	$story['posttime']   = formatTimestamp($articles[$i]->getVar('published'), $bulletin_date_format);
	$story['text']       = $articles[$i]->getVar('hometext');
	$story['topicid']    = $articles[$i]->getVar('topicid');
	$story['topic']      = $articles[$i]->topic_title();
	$story['title']      = $articles[$i]->getVar('title');
	$story['hits']       = $articles[$i]->getVar('counter');
	$story['title_link'] = true;

	$topic_perm = $gperm->get_viewtopic_perm_of_current_user($story['topicid'] , $articles[$i]->getVar('uid'));
Ejemplo n.º 7
0
function b_bulletin_calendar_show($options) {

	global $xoopsDB;

	$mydirname = empty( $options[0] ) ? basename( dirname( dirname( __FILE__ ) ) ) : $options[0] ;
	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;

	$mytrustdirpath = dirname( dirname( __FILE__ ) ) ;

	require_once dirname(dirname(__FILE__)).'/class/bulletin_cal.php';
	require_once dirname(dirname(__FILE__)).'/class/bulletingp.php' ;

	$block = array();
//ver3.0 can_read access
	$gperm =& BulletinGP::getInstance($mydirname) ;
	$can_read_topic_ids = $gperm->makeOnTopics('can_read');
//	if (empty($can_read_topic_ids)){
//		return false;
//	}

	$today = isset( $_GET['today'] ) ? $_GET['today'] : date('Y-m') ;

	$year  = date('Y');
	$month = date('m');

	if(preg_match('/([0-9]{4})-([0-9]{2})/', $today, $todayarr)){
		$year  = $todayarr[1];
		$month = $todayarr[2];
	}
	if(!checkdate($month,1,$year)){
		$year  = date('Y');
		$month = date('m');
	}

	$weekname = array(_MB_BULLETIN_SUN,_MB_BULLETIN_MON,_MB_BULLETIN_TUE,_MB_BULLETIN_WED,_MB_BULLETIN_THE,_MB_BULLETIN_FRI,_MB_BULLETIN_SAT);

	//
	$sql = "SELECT published FROM ".$xoopsDB->prefix( "{$mydirname}_stories" );
	if (!empty($can_read_topic_ids)){
		$sql .= ' WHERE topicid IN ('.implode(',',$can_read_topic_ids).')';
		if (!$gperm->group_perm(2)){
			$sql .= " AND type > 0";
		}
	}else{
		if (!$gperm->group_perm(2)){
			$sql .= " WHERE type > 0";
		}
	}
	$sql .= " ORDER BY published ASC";
	list($startday) = $xoopsDB->fetchRow($xoopsDB->query($sql));

	$sql = "SELECT published FROM ".$xoopsDB->prefix( "{$mydirname}_stories" );
	if (!empty($can_read_topic_ids)){
		$sql .= ' WHERE topicid IN ('.implode(',',$can_read_topic_ids).')';
		if (!$gperm->group_perm(2)){
			$sql .= " AND type > 0";
		}
	}else{
		if (!$gperm->group_perm(2)){
			$sql .= " WHERE type > 0";
		}
	}
	$sql .= " ORDER BY published DESC";
	list($endday) = $xoopsDB->fetchRow($xoopsDB->query($sql));

	$starttimestamp4sql = mktime(0,0,0,$month,1,$year);
	$endtimestamp4sql   = mktime(0,0,0,$month+1,1,$year);

	$sql = "SELECT storyid, published FROM ".$xoopsDB->prefix( "{$mydirname}_stories" );
	$sql .= " WHERE published > 0 AND published <= ".time()." AND (expired = 0 OR expired > ".time().") AND $starttimestamp4sql <= published AND published < $endtimestamp4sql";
	if (!empty($can_read_topic_ids)){
		$sql .= ' AND topicid IN ('.implode(',',$can_read_topic_ids).')';
	}else{
		$sql .= ' AND topicid IN (0)';
	}
	if (!$gperm->group_perm(2)){
		$sql .= " AND type > 0";
	}
	$result = $xoopsDB->query($sql);


	$cal = new Bulletin_Cal;
	$cal->setDate($today, $startday, $endday);
	$cal->setWeekName( $weekname );
	while(list($storyid, $published) = $xoopsDB->fetchRow($result)){
		$day = intval(date('d', $published));
		$cal->setLink($day, XOOPS_URL.'/modules/'.$mydirname.'/index.php?caldate='.date('Y-m-d', $published));
	}
	$cal->setTitle(_MB_BULLETIN_DATE_FORMAT);
	$block['content'] = $cal->getThemeCalendar();

	return $block;

}
Ejemplo n.º 8
0
function b_bulletin_new_show($options)
{
    $mydirname = empty($options[0]) ? basename(dirname(dirname(__FILE__))) : $options[0];
    if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
        die('Invalid mydirname');
    }
    $selected_order = empty($options[1]) || !in_array($options[1], b_bulletin_new_allowed_order()) ? 'published DESC' : $options[1];
    $display_count = empty($options[2]) ? 0 : intval($options[2]);
    //Number display for each category
    $Length_title = empty($options[3]) ? 255 : intval($options[3]);
    //Length of the title
    $show_body = empty($options[4]) ? 0 : intval($options[4]);
    //Number of articles showing body for each category
    if (!isset($options[5])) {
        $options[5] = 0;
        //(0=show all for d3pipes)
    }
    $categories = empty($options[5]) ? 0 : array_map('intval', explode(',', $options[5]));
    //(0=show all)
    require dirname(dirname(__FILE__)) . '/include/configs.inc.php';
    require_once dirname(dirname(__FILE__)) . '/class/bulletingp.php';
    $block = array();
    //ver3.0 can_read access
    $gperm =& BulletinGP::getInstance($mydirname);
    $can_read_topic_ids = $gperm->makeOnTopics('can_read');
    if (empty($can_read_topic_ids)) {
        return false;
    }
    $sql = "SELECT s.*, t.topic_pid, t.topic_imgurl, t.topic_title, t.topic_created, t.topic_modified";
    $sql .= ' FROM ' . $xoopsDB->prefix($mydirname . '_stories') . ' s, ' . $xoopsDB->prefix($mydirname . '_topics') . ' t';
    $sql .= ' WHERE s.published < ' . time() . ' AND s.published > 0 AND (s.expired = 0 OR s.expired > ' . time() . ') AND s.topicid = t.topic_id AND s.block = 1';
    if (!$gperm->group_perm(2)) {
        $sql .= " AND s.type > 0";
    }
    if (!empty($categories)) {
        $sql .= ' AND s.topicid IN (' . implode(',', $categories) . ')';
    }
    $sql .= ' AND s.topicid IN (' . implode(',', $can_read_topic_ids) . ')';
    $sql .= ' ORDER BY ' . $selected_order;
    //
    if ($show_body > 0) {
        //ver2.0$sql  = sprintf('SELECT s.storyid, s.topicid, s.title, s.hometext, s.bodytext, s.published, s.expired, s.counter, s.comments, s.uid, s.topicimg, s.html, s.smiley, s.br, s.xcode, t.topic_title, t. topic_imgurl FROM %s s, %s t WHERE s.type > 0 AND s.published < %u AND s.published > 0 AND (s.expired = 0 OR s.expired > %3$u) AND s.topicid = t.topic_id AND s.block = 1 ORDER BY %s', $table_stories, $table_topics, time(), $selected_order);
        $result = $xoopsDB->query($sql, $show_body, 0);
        while ($myrow = $xoopsDB->fetchArray($result)) {
            $fullstory = array();
            // GIJ
            $fullstory['id'] = $myrow['storyid'];
            $fullstory['posttime'] = formatTimestamp($myrow['published'], $bulletin_date_format);
            $fullstory['date'] = formatTimestamp($myrow['published'], $bulletin_date_format);
            $fullstory['published'] = intval($myrow['published']);
            $fullstory['topicid'] = $myrow['topicid'];
            $fullstory['topic'] = $myts->makeTboxData4Show($myrow['topic_title']);
            $fullstory['title'] = $myts->makeTboxData4Show($myrow['title']);
            $fullstory['text'] = $myts->displayTarea($myrow['hometext'], $myrow['html'], $myrow['smiley'], $myrow['xcode'], 1, $myrow['br']);
            $fullstory['hits'] = $myrow['counter'];
            $fullstory['title_link'] = true;
            //
            $fullstory['uid'] = $myrow['uid'];
            $fullstory['uname'] = XoopsUser::getUnameFromId($myrow['uid']);
            $fullstory['realname'] = XoopsUser::getUnameFromId($myrow['uid'], 1);
            $fullstory['morelink'] = '';
            //
            if (myStrlenText($myrow['bodytext']) > 1) {
                $fullstory['bytes'] = sprintf(_MB_BULLETIN_BYTESMORE, myStrlenText($myrow['bodytext']));
                $fullstory['readmore'] = true;
            } else {
                $fullstory['bytes'] = 0;
                $fullstory['readmore'] = false;
            }
            //
            $ccount = $myrow['comments'];
            if ($ccount == 0) {
                $fullstory['comentstotal'] = _MB_BULLETIN_COMMENTS;
            } elseif ($ccount == 1) {
                $fullstory['comentstotal'] = _MB_BULLETIN_ONECOMMENT;
            } else {
                $fullstory['comentstotal'] = sprintf(_MB_BULLETIN_NUMCOMMENTS, $ccount);
            }
            //
            $fullstory['adminlink'] = 0;
            //
            if ($myrow['topicimg']) {
                $fullstory['topic_url'] = makeTopicImgURL($bulletin_topicon_path, $myrow['topic_imgurl']);
                $fullstory['align'] = topicImgAlign($myrow['topicimg']);
            }
            //ver3.0
            $topic_perm = $gperm->get_viewtopic_perm_of_current_user($myrow['topicid'], $myrow['uid']);
            $fullstory = array_merge($fullstory, $topic_perm);
            $fullstory['type'] = $myrow['type'];
            $fullstory['raw_data'] = $myrow;
            $block['fullstories'][] = $fullstory;
        }
    }
    if ($display_count - $show_body > 0) {
        //ver2.0$sql  = sprintf('SELECT storyid, title, published, expired, counter, uid FROM %s WHERE type > 0 AND published < %u AND published > 0 AND (expired = 0 OR expired > %2$u) AND block = 1 ORDER BY %s', $table_stories, time(), $selected_order);
        $result = $xoopsDB->query($sql, $display_count - $show_body, $show_body);
        while ($myrow = $xoopsDB->fetchArray($result)) {
            $story = array();
            //
            $story['title'] = $myts->makeTboxData4Show(xoops_substr($myrow['title'], 0, $Length_title + 3, '...'));
            $story['id'] = $myrow['storyid'];
            $story['date'] = formatTimestamp($myrow['published'], $bulletin_date_format);
            $story['published'] = intval($myrow['published']);
            $story['hits'] = $myrow['counter'];
            $story['uid'] = $myrow['uid'];
            $story['uname'] = XoopsUser::getUnameFromId($myrow['uid']);
            $story['realname'] = XoopsUser::getUnameFromId($myrow['uid'], 1);
            //ver3.0
            $topic_perm = $gperm->get_viewtopic_perm_of_current_user($myrow['topicid'], $myrow['uid']);
            $story = array_merge($story, $topic_perm);
            $story['type'] = $myrow['type'];
            $story['raw_data'] = $myrow;
            $block['stories'][] = $story;
        }
    }
    if (!empty($block)) {
        $block['mod_config'] = @$bulletin_configs;
        $block['lang_postedby'] = _POSTEDBY;
        $block['lang_on'] = _ON;
        $block['lang_reads'] = _READS;
        $block['lang_readmore'] = _MB_BULLETIN_READMORE;
        $block['type'] = $selected_order;
        $block['mydirurl'] = XOOPS_URL . '/modules/' . $mydirname;
        $block['mydirname'] = $mydirname;
    }
    return $block;
}
Ejemplo n.º 9
0
 function store()
 {
     $mode = empty($this->topic_id) ? 'insert' : 'udpate';
     parent::store();
     if ($mode == 'insert') {
         $this->topic_id = $this->db->getInsertId();
         $this->db->query("UPDATE " . $this->table . " SET topic_created=UNIX_TIMESTAMP(),topic_modified=UNIX_TIMESTAMP() WHERE topic_id=" . $this->topic_id);
         //ver3.0
         $gperm =& BulletinGP::getInstance($this->mydirname);
         $result = $gperm->insertdefaultpermissions($this->topic_id);
     } else {
         $this->db->query("UPDATE " . $this->table . " SET topic_modified=UNIX_TIMESTAMP() WHERE topic_id=" . $this->topic_id);
     }
 }
Ejemplo n.º 10
0
	if ( file_exists(XOOPS_TRUST_PATH.'/modules/bulletin/admin/category_access.php') ) {
		//ver3.0 can_read access
		$gperm =& BulletinGP::getInstance($plugin['dirname']) ;
		$checkright = $gperm->checkRight('module_read', $mid, $groups);
		$can_read_topic_ids = $gperm->makeOnTopics('can_read');

		if (empty($can_read_topic_ids) || !$checkright){
			$sql .= ' AND topicid IN (0)';
		}else{
			$sql .= ' AND topicid IN ('.implode(',',$can_read_topic_ids).')';
		}
		if (!$gperm->group_perm(2)){
			$sql .= " AND type > 0";
		}
	}else{
		$gperm =new BulletinGP() ;
		$checkright = $gperm->checkRight('module_read', $mid, $groups);
		if ( !$checkright){
			$sql .= ' AND topicid IN (0)';
		}
		$sql .= " AND type > 0";
	}

	$result = $db->query( $sql ) ;

	while( list( $title , $id , $server_time ) = $db->fetchRow( $result ) ) {
		$user_time = $server_time + $tzoffset_s2u ;
		if( date( 'n' , $user_time ) != $this->month ) continue ;
		$target_date = date('j',$user_time) ;
		$tmp_array = array(
			'dotgif' => $plugin['dotgif'] ,
Ejemplo n.º 11
0
function b_bulletin_recent_comments_show($options)
{
    global $xoopsDB;
    $mydirname = empty($options[0]) ? basename(dirname(dirname(__FILE__))) : $options[0];
    if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
        die('Invalid mydirname');
    }
    if (!isset($options[1])) {
        $options[1] = 0;
        //(0=show all for d3pipes)
    }
    $categories = empty($options[1]) ? 0 : array_map('intval', explode(',', $options[1]));
    //(0=show all)
    $rs = $xoopsDB->query("SELECT mid FROM " . $xoopsDB->prefix('modules') . " WHERE dirname='{$mydirname}'");
    list($bulletin_mid) = $xoopsDB->fetchRow($rs);
    require_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
    require_once dirname(dirname(__FILE__)) . '/class/bulletingp.php';
    $block = array();
    //ver3.0 can_read access
    $gperm =& BulletinGP::getInstance($mydirname);
    $can_read_topic_ids = $gperm->makeOnTopics('can_read');
    if (empty($can_read_topic_ids)) {
        return false;
    }
    $comment_handler =& xoops_gethandler('comment');
    $member_handler =& xoops_gethandler('member');
    $criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
    $criteria->add(new Criteria('com_modid', $bulletin_mid));
    $criteria->setLimit(10);
    $criteria->setSort('com_created');
    $criteria->setOrder('DESC');
    $comments =& $comment_handler->getObjects($criteria, true);
    //ver3.0
    $storyids = array();
    foreach (array_keys($comments) as $i) {
        $storyids[] = $comments[$i]->getVar('com_itemid');
    }
    if (empty($storyids)) {
        return false;
    }
    $can_read_storyids = array();
    $sql = "SELECT s.storyid";
    $sql .= ' FROM ' . $xoopsDB->prefix($mydirname . '_stories') . ' s, ' . $xoopsDB->prefix($mydirname . '_topics') . ' t';
    //TODO published only
    //	$sql .= ' WHERE s.type > 0 AND s.published < '.time().' AND s.published > 0 AND (s.expired = 0 OR s.expired > '.time().') AND s.topicid = t.topic_id AND s.block = 1';
    //	$sql .= ' AND s.storyid IN ('.implode(',',$storyids).')';
    $sql .= ' WHERE s.storyid IN (' . implode(',', $storyids) . ')';
    if (!empty($categories)) {
        $sql .= ' AND s.topicid IN (' . implode(',', $categories) . ')';
    }
    $sql .= ' AND s.topicid IN (' . implode(',', $can_read_topic_ids) . ')';
    $result = $xoopsDB->query($sql);
    while ($myrow = $xoopsDB->fetchArray($result)) {
        $can_read_storyids[] = $myrow['storyid'];
    }
    if (empty($can_read_storyids)) {
        return false;
    }
    foreach (array_keys($comments) as $i) {
        if (!in_array($comments[$i]->getVar('com_itemid'), $can_read_storyids)) {
            continue;
        }
        $mid = $comments[$i]->getVar('com_modid');
        $com['id'] = $i;
        $com['title'] = $comments[$i]->getVar('com_title');
        $com['time'] = formatTimestamp($comments[$i]->getVar('com_created'), 'm');
        $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
        $com['uid'] = $comments[$i]->getVar('com_uid');
        $com['itemid'] = $comments[$i]->getVar('com_itemid');
        $com['rootid'] = $comments[$i]->getVar('com_rootid');
        $com['url'] = XOOPS_URL . '/modules/' . $mydirname . '/index.php?page=article&amp;storyid=' . $com['itemid'] . '&amp;com_id=' . $i . '&amp;com_rootid=' . $com['rootid'] . '#comment' . $i;
        if ($comments[$i]->getVar('com_uid') > 0) {
            $poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
            if (is_object($poster)) {
                $com['poster'] = $poster->getVar('uname');
            }
        }
        $block['comments'][] =& $com;
        unset($com);
    }
    if (empty($block)) {
        return false;
    }
    return $block;
}
Ejemplo n.º 12
0
		}
	} else {
		echo ' "<b>'.htmlspecialchars(stripslashes($queries[0])).'</b>"';
	}

//ver3.0
	include_once XOOPS_TRUST_PATH."/modules/bulletin/class/bulletingp.php";

	echo '<form name="stories">';
	$time = time();
	foreach ($mids as $mid) {
		$mid = intval($mid);
		if ( in_array($mid, $modules_mid) ) {
			$sql = "SELECT storyid, title, published FROM ".$xoopsDB->prefix( $modules_dir[$mid].'_stories' )." WHERE type > 0 AND published > 0 AND published <= $time AND (expired = 0 OR expired > $time)";
//ver3.0
			$gperm =& BulletinGP::getInstance($modules_dir[$mid]) ;
			$can_read_topic_ids = $gperm->makeOnTopics('can_read');
			$sql .= " AND topicid IN (".implode(',',$can_read_topic_ids).")";

			if ( is_array($queries) && $count = count($queries) ) {
				$sql .= " AND ((hometext LIKE '%$queries[0]%' OR bodytext LIKE '%$queries[0]%' OR title LIKE '%$queries[0]%')";
				for($i=1;$i<$count;$i++){
					$sql .= " $andor ";
					$sql .= "(hometext LIKE '%$queries[$i]%' OR bodytext LIKE '%$queries[$i]%' OR title LIKE '%$queries[$i]%')";
				}
				$sql .= ") ";
			}
			$sql .= "ORDER BY published DESC";

			$result = $xoopsDB->query($sql, ($showall > 0 )?0:5, 0);
Ejemplo n.º 13
0
 function getPublishedDays($mydirname, $limit = 0, $start = 0, $gpermited = false)
 {
     $db =& Database::getInstance();
     $gperm =& BulletinGP::getInstance($mydirname);
     $sql = "SELECT published FROM " . $db->prefix($mydirname . '_stories');
     //ver2.0$sql .= " WHERE type > 0 AND published>0 AND published<=".time()." AND expired <= ".time();
     //ver3.0
     $sql .= " WHERE published>0 AND published<=" . time() . " AND expired <= " . time();
     if (!$gpermited) {
         $sql .= " AND type > 0";
     } elseif (!$gperm->group_perm(2)) {
         $sql .= " AND type > 0";
     }
     if ($gpermited) {
         $can_read_topic_ids = $gperm->makeOnTopics('can_read');
         $sql .= " AND topicid IN (" . implode(',', $can_read_topic_ids) . ")";
     }
     $sql .= " ORDER BY published ASC";
     $result = $db->query($sql, intval($limit), intval($start));
     $ret = array();
     while (list($myrow) = $db->fetchRow($result)) {
         $ret[] = $myrow;
     }
     return $ret;
 }
Ejemplo n.º 14
0
function b_bulletin_category_new_show($options) {

	$mydirname = empty( $options[0] ) ? basename( dirname( dirname( __FILE__ ) ) ) : $options[0] ;
	if( preg_match( '/[^0-9a-zA-Z_-]/' , $mydirname ) ) die( 'Invalid mydirname' ) ;
	$selected_order = empty( $options[1] ) || ! in_array( $options[1] , b_bulletin_category_new_allowed_order() ) ? 'published DESC' : $options[1] ;
	$display_count = empty($options[2]) ? 0 :intval($options[2]);//Number display for each category
	$Length_title = empty($options[3]) ? 255 :intval($options[3]);//Length of the title
	$categories = empty($options[4]) ? 0 : array_map( 'intval' , explode( ',' , $options[4] ) ) ;//(0=show all)
	$show_body = empty($options[5]) ? 0 :intval($options[5]);//Number of articles showing body for each category
	$show_category_icon = empty($options[6]) ? 0 :intval($options[6]);//(yes or no) ,Display category icon
//ver3.0 fix
	if ($show_body > $display_count){
		$show_body = $display_count;
	}

	require dirname( dirname( __FILE__ ) ).'/include/configs.inc.php';
	require_once XOOPS_ROOT_PATH.'/class/xoopstree.php';
	require_once dirname(dirname(__FILE__)).'/class/bulletingp.php' ;

	$mytree = new XoopsTree($table_topics,'topic_id','topic_pid');

	$arr = array();
//ver3.0 can_read access
	$gperm =& BulletinGP::getInstance($mydirname) ;
	$can_read_topic_ids = $gperm->makeOnTopics('can_read');
	if (empty($can_read_topic_ids)){
		return false;
	}

	// Query to get the root category
		$sql_topics = "SELECT topic_id, topic_title, topic_imgurl";
		$sql_topics .= " FROM ".$xoopsDB->prefix($mydirname."_topics") ;
	if( empty($categories) ){
		// Get categories all from route
		$sql_topics .= " WHERE topic_pid=0";
		$sql_topics .= " AND topic_id IN (".implode(",",$can_read_topic_ids).")";
		$sql_topics .= " ORDER BY topic_title";
	}else{
		// when category
		$sql_topics .= " WHERE topic_id IN (".implode(",",$categories).")";
		$sql_topics .= " AND topic_id IN (".implode(",",$can_read_topic_ids).")";
	}
	$result = $xoopsDB->query($sql_topics);
	$topics_count = $xoopsDB->getRowsNum($result);
	if (empty($topics_count)){
		return false;
	}

	$block = array();

	while( list($topic_id, $topic_title, $topic_imgurl) = $xoopsDB->fetchRow($result) ){
		$topic = array();
		$topic['title'] = $myts->makeTboxData4Show($topic_title);
		$topic['id'] = $topic_id;

		// Set the image topic
		if ($topic_imgurl != '' && file_exists($bulletin_topicon_path.$topic_imgurl) && $show_category_icon) {
			$topic['topic_url'] = str_replace(XOOPS_ROOT_PATH,XOOPS_URL,$bulletin_topicon_path).$topic_imgurl;
			$topic['show_category_icon'] = 1;
		}else{
			$topic['show_category_icon'] = 0;
		}

		$where = sprintf("s.published < %u AND s.published > 0 AND (s.expired = 0 OR s.expired > %1\$u) AND s.block = 1 AND (s.topicid=%u", time(), $topic_id);
		if (!$gperm->group_perm(2)){
			$where .= " AND s.type > 0";
		}

		// View the directory to include children categorys
		$arr = $mytree->getAllChildId($topic_id);
		$size = count($arr);
		for($i=0;$i<$size;$i++){
			$where .= " OR s.topicid=".$arr[$i];
		}
		$where .= ")";
//ver3.0 can_read access
		$where .= " AND s.topicid IN (".implode(',',$can_read_topic_ids).")";

		// see more... for topics
		$sql = sprintf("SELECT COUNT(*) FROM %s s WHERE %s", $xoopsDB->prefix($mydirname."_stories"), $where);
		list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql));
		if($count>$display_count){
			$topic['morelink'] = 1;
		}
		$topic['lang_morelink'] = _MORE;

//ver3.0
		$sql = "SELECT s.*, t.topic_pid, t.topic_imgurl, t.topic_title, t.topic_created, t.topic_modified";
		$sql .= " FROM " . $xoopsDB->prefix($mydirname."_stories") . " s, " . $xoopsDB->prefix($mydirname."_topics") . " t";
		$sql .= " WHERE " . $where . " AND s.topicid = t.topic_id";
		$sql .= " ORDER BY $selected_order";

		// Show body
		if($show_body > 0){

//ver2.0	$sql  = sprintf('SELECT s.storyid, s.topicid, s.title, s.hometext, s.bodytext, s.published, s.expired, s.counter, s.comments, s.uid, s.topicimg, s.html, s.smiley, s.br, s.xcode, t.topic_title, t. topic_imgurl FROM %s s, %s t WHERE %s AND s.topicid = t.topic_id %s', $table_stories, $table_topics, $where, $order);

			$result2 = $xoopsDB->query($sql,$show_body,0);

			while ( $myrow = $xoopsDB->fetchArray($result2) ) {
				$fullstory = array() ; // GIJ
				$fullstory['id']       = $myrow['storyid'];
				$fullstory['posttime'] = formatTimestamp($myrow['published'], $bulletin_date_format);
				$fullstory['date']     = formatTimestamp($myrow['published'], $bulletin_date_format);
				$fullstory['published'] = intval($myrow['published']);
				$fullstory['topicid']  = $myrow['topicid'];
				$fullstory['topic']    = $myts->makeTboxData4Show($myrow['topic_title']);
				$fullstory['title']    = $myts->makeTboxData4Show($myrow['title']);
				$fullstory['text']     = $myts->displayTarea($myrow['hometext'],$myrow['html'],$myrow['smiley'],$myrow['xcode'],1,$myrow['br']);
				$fullstory['hits']     = $myrow['counter'];
				$fullstory['title_link'] = true;
				//Assign the user information
				$fullstory['uid']      = $myrow['uid'];
				$fullstory['uname']    = XoopsUser::getUnameFromId($myrow['uid']);
				$fullstory['realname'] = XoopsUser::getUnameFromId($myrow['uid'], 1);
				$fullstory['morelink'] = '';

				// Length counting process
				if ( myStrlenText($myrow['bodytext']) > 1 ) {
					$fullstory['bytes']    = sprintf(_MB_BULLETIN_BYTESMORE, myStrlenText($myrow['bodytext']));
					$fullstory['readmore'] = true;
				}else{
					$fullstory['bytes']    = 0;
					$fullstory['readmore'] = false;
				}

				// Assign a number of comments
				$ccount = $myrow['comments'];
				if( $ccount == 0 ){
					$fullstory['comentstotal'] = _MB_BULLETIN_COMMENTS;
				}elseif( $ccount == 1 ) {
					$fullstory['comentstotal'] = _MB_BULLETIN_ONECOMMENT;
				}else{
					$fullstory['comentstotal'] = sprintf(_MB_BULLETIN_NUMCOMMENTS, $ccount);
				}

				// Links for administrato //old verssion
				$fullstory['adminlink'] = 0;

				// Image Topic
				if ( $myrow['topicimg'] ) {
					$fullstory['topic_url'] = makeTopicImgURL($bulletin_topicon_path, $myrow['topic_imgurl']);
					$fullstory['align']     = topicImgAlign($myrow['topicimg']);
				}
//ver3.0
				$topic_perm = $gperm->get_viewtopic_perm_of_current_user($myrow['topicid'] , $myrow['uid']);
				$fullstory = array_merge($fullstory,$topic_perm);

				$fullstory['type']     = $myrow['type'];
				$fullstory['raw_data'] = $myrow;

				$topic['fullstories'][] = $fullstory;

			}
		}

		if( $display_count - $show_body > 0 ){

//ver2.0	$sql  = sprintf('SELECT s.storyid, s.title, s.published, s.expired, s.counter, s.uid FROM %s s WHERE %s %s', $table_stories, $where, $order);

			$result3 = $xoopsDB->query($sql,$display_count-$show_body,$show_body);

			while ( $myrow = $xoopsDB->fetchArray($result3) ) {

				// Also supports multi-byte
				$story['title']    = $myts->makeTboxData4Show(xoops_substr($myrow['title'], 0 ,intval($Length_title) + 3, '...'));
				$story['id']       = $myrow['storyid'];
				$story['date']     = formatTimestamp($myrow['published'], $bulletin_date_format);
				$story['published'] = intval($myrow['published']);
				$story['hits']     = $myrow['counter'];
				$story['uid']      = $myrow['uid'];
				$story['uname']    = XoopsUser::getUnameFromId($myrow['uid']);
				$story['realname'] = XoopsUser::getUnameFromId($myrow['uid'], 1);

//ver3.0
				$topic_perm = $gperm->get_viewtopic_perm_of_current_user($myrow['topicid'] , $myrow['uid']);
				$story = array_merge($story,$topic_perm);
				$story['type']     = $myrow['type'];
				$story['raw_data'] = $myrow;

				$topic['stories'][] = $story;
			}

		}

		$block['topics'][] = $topic;
	}

	if( ! empty( $block ) ) {
		$block['mod_config'] = @$bulletin_configs ;
		$block['lang_postedby'] = _POSTEDBY;
		$block['lang_on']       = _ON;
		$block['lang_reads']    = _READS;
		$block['lang_readmore'] = _MB_BULLETIN_READMORE;
		$block['type']  = $selected_order;
		$block['mydirurl'] = XOOPS_URL.'/modules/'.$mydirname;;
		$block['mydirname'] = $mydirname;
	}

	return $block;
}
Ejemplo n.º 15
0
<?php

require_once dirname(dirname(__FILE__)) . '/class/bulletin.php';
require_once dirname(dirname(__FILE__)) . '/class/bulletingp.php';
require_once dirname(dirname(__FILE__)) . '/class/bulletinTopic.php';
require_once dirname(dirname(__FILE__)) . '/include/configs.inc.php';
require_once dirname(dirname(__FILE__)) . '/include/common_functions.php';
$assing_array = array('disp_rss_link' => $bulletin_disp_rss_link, 'mydirurl' => $mydirurl, 'mydirname' => $mydirname);
//権限クラス
$gperm = new BulletinGP();
// User has the right to post.
if ($gperm->group_perm(1)) {
    $assing_array['can_post'] = 1;
}
// RSS Feed in <header>
$rss_feed = '<link rel="alternate" type="application/rss+xml" title="RSS2.0" href="' . $mydirurl . '/index.php?page=rss" />';