• 17-03-2013, 16:26:46
    #1
    Merhabalar,

    Php ile aram pek iyi değil maalesef. Aşağıdaki yazıda karakter sınırlama mevcut, ben bunu karakter değil de 3 kelime ile sınırlamak istiyorum. Aşağıda 550 karakter ile sınırlanmış. Kodları aşağıda veriyorum. Yardımcı olana çok minnettar olurum.

    <?php
    // ####################### SET PHP ENVIRONMENT ###########################
    error_reporting(E_ALL & ~E_NOTICE);
    
    // #################### DEFINE IMPORTANT CONSTANTS #######################
    define('NO_REGISTER_GLOBALS', 1);
    define('THIS_SCRIPT', 'tab_news'); // change this depending on your filename
    
    // ################### PRE-CACHE TEMPLATES AND DATA ######################
    // get special phrase groups
    $phrasegroups = array('calendar', 'adv_portal', 'postbit');
    
    // get special data templates from the datastore
    $specialtemplates = array('smiliecache', 'bbcodecache',);
    
    // pre-cache templates used by all actions
    
    $globaltemplates = array('adv_portal_newsbits');
    
    // pre-cache templates used by specific actions
    $actiontemplates = array();
    
    // ######################### REQUIRE BACK-END ############################
    require_once('./global.php');
    require_once('./includes/class_bbcode_blog.php');
    require_once('./includes/functions_user.php');
    
    // #######################################################################
    // ######################## START MAIN SCRIPT ############################
    // #######################################################################
    
    $bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
    
    $mod_options['news_cutoffdate'] = 365;
    $mod_options['news_threads_forumid'] = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18';	 // Add the forumid(s) you would like to display threads from in your news module. Seperate each with a comma.
    $charlimit	=	550;
    $newslimit	=	5;
    $titlelen	=	60;
    
    $forumids = array($mod_options['news_threads_forumid']);
    
    $getnews = $db->query_read(" 
    	SELECT t.threadid, t.title, t.lastpost, t.forumid, t.open, t.replycount, t.postusername, t.postuserid, t.lastposter, t.dateline, t.views, t.visible, t.firstpostid, f.title AS forumtitle, post.pagetext AS preview 
    	FROM " . TABLE_PREFIX . "forum f 
    	INNER JOIN " . TABLE_PREFIX . "thread t ON t.forumid = f.forumid
    	LEFT OUTER JOIN " . TABLE_PREFIX . "post AS post ON post.postid = t.firstpostid 
    	WHERE t.forumid IN(" . implode(',', $forumids) . ")
    	" . iif($mod_options['news_cutoffdate'], 'AND t.dateline > ' . (TIMENOW - ($mod_options['news_cutoffdate'] * 86400))) . "
    	ORDER BY dateline DESC 
    	LIMIT " . $newslimit . " 
    ");
    
    	while($news = $db->fetch_array($getnews))
    	{
    		$news['title']			=	preg_replace('/\<[a-zA-Z0-9 \&lt;\<\>\&gt;\:\;\"\'\,\.\?\/\~\`\!\@\#\$\%\^\&\*\(\)\_\-\+\=]*\>/', '', $news['title']);
    		$news['title']			=	fetch_trimmed_title(fetch_censored_text(unhtmlspecialchars($news['title'])), $titlelen);
    		$news['forumtitle']		=	stripslashes($news['forumtitle']);
    		$news['date']			=	vbdate($vbulletin->options['dateformat'], $news['dateline']);
    		$news['time']			=	vbdate($vbulletin->options['timeformat'], $news['dateline']);
    		$news['replycount']		=	vb_number_format($news['replycount']);
    		$news['views']			=	vb_number_format($news['views']);
    		$news['postusername']	=	$news['postusername'];
    		$news['lastposter']		=	$news['lastposter'];
    		$news['preview']		=	preg_replace('/\<[a-zA-Z0-9 \&lt;\<\>\&gt;\:\;\"\'\,\.\?\/\~\`\!\@\#\$\%\^\&\*\(\)\_\-\+\=]*\>/', '', $news['preview']);
    		$news['pagetext'] 		=	$bbcode_parser->do_parse($news['preview'], 1, 1, 1, 1);
    		$news['pagetext']		=	substr($news['pagetext'], 0, $charlimit);
    		$endoftext				=	' &nbsp;<span class="smallfont">...[<a href="showthread.php?t='. $news['threadid'] .'" >Read More</strong></a>]</span>';
    
    //Get Avatar
    	$avatarurl = fetch_avatar_url($news[postuserid]);
    		if ($avatarurl[0])
    		{
    			$avatarurl = $vbulletin->options['bburl'] . '/' . $avatarurl[0];
    		}
    		else 
    		{
    			$avatarurl = "/forums/images/misc/noavatar.gif"; // ADD PATH TO THE LOCATION OF YOUR NO AVATAR IMAGE
    		}		
    			
    		echo '<div style="padding:0px 0px 10px 0px">';
    		echo '<table class="tborder" cellspacing="1" cellpadding="6" border="0"  width="100%">';
    		echo '<tr>';
    		echo '<td class="tcat smallfont"><a href="showthread.php?t=' . $news[threadid] . '" title="' . $news[title] . '" target="blank"><strong>' . $news[title] . '</strong></a></td>';
    		echo '</tr>';
    				
    		echo '<tr>';
    		echo '<td class="thead">' . $news[date] . ' - ' . $news[time] . ' - by: <a href="member.php?u=' . $news[postuserid] . '" title="' . $news[postusername] . '">' . $news[postusername] . '</a></td>';
    		echo '</tr>';
    				
    		echo '<tr>';
    		echo '<td class="alt1" valign="top" align="left"><img src="' . $avatarurl . '" border="0" align="left" style="padding:6px;" />' . $news[pagetext] . $endoftext . '</td>';
    		echo '</tr>';
    								
    		echo '<tr class="alt2" valign="middle">';
    		echo '<td valign="middle"><span style="float: right;"><a href="newreply.php?do=newreply&amp;t=' . $news[threadid] . '" ><img border="0" src="' . $stylevar[imgdir_button] . '/reply_small.gif" title="Reply to this post" alt="Reply to this post" /></a> <a href="sendmessage.php?do=sendtofriend&amp;t=' . $news[threadid] . '" target="blank"><img border="0" src="' . $stylevar[imgdir_button] . '/sendtofriend.gif" title="Send this to your friend" alt="Send this to your friend" /></a> <a href="printthread.php?t=' . $news[threadid] . '" target="blank"><img border="0" src="' . $stylevar[imgdir_button] . '/printer.gif" title="Display a printable version of this news story" alt="Display a printable version of this news story" /></a></span> <span class="smallfont">' . $news[replycount] . ' Replies | ' .  $news[views] . ' Views</span></td>';
    		echo '</tr>';
    
    		echo '</table>';
    		echo '</div>';
    
    
    	}
    
    
    ?>
  • 17-03-2013, 20:40:03
    #2
    Neyse sorunumu başka yoldan çözdüm.