Page 2 of 3

Re: Tab based Latest News Block - advance skills needed!

Posted: 15. June 2008 19:36
by frold
Kevin wrote:Better to make it work for anyone, rather than locking this thread!?
I dont have the time to give further help sry....

Re: Tab based Latest News Block - advance skills needed!

Posted: 17. June 2008 23:25
by CocoVFR
frold wrote:
CocoVFR wrote:UP :D
?

Did it work for you...?

Doesnt it work for any one? If so, then feel free to lock this post.....
No, it doesn't work for me.

not working

Posted: 23. June 2008 18:31
by liquidspark
So apparently this mod doesn't work for anyone except frold. What did you do to make it work, frold?

Re: not working

Posted: 23. June 2008 18:57
by frold
liquidspark wrote:So apparently this mod doesn't work for anyone except frold. What did you do to make it work, frold?
Well I think I did what I wrote in the first post... why it will not work for you I cant say.... If I could help I would gladly do so.....

Re: Tab based Latest News Block - advance skills needed!

Posted: 27. June 2008 15:04
by Onetimer
Wow that's a neat idea. Kudos for sharing!

Re: Tab based Latest News Block - advance skills needed!

Posted: 27. June 2008 15:22
by frold
Onetimer wrote:Wow that's a neat idea. Kudos for sharing!
Thanks!

I hope it will work for you!

Re: Tab based Latest News Block - advance skills needed!

Posted: 7. October 2008 21:20
by dimasik
CocoVFR wrote:Hello Frold. I've the same error than above:

Code: Select all

[phpBB Debug] PHP Notice: in file /portal/includes/functions.php on line 74: Missing argument 6 for phpbb_fetch_posts()

Retourner à l’index du forum 
Erreur générale
SQL ERROR [ mysql4 ]

Erreur de syntaxe pr?s de 'JOIN phpbb_forums as f ON t.forum_id=f.forum_id ' ? la ligne 33 [1064]

SQL

SELECT t.forum_id, t.topic_id, t.topic_last_post_id, t.topic_last_post_time, t.topic_time, t.topic_title, t.topic_attachment, t.topic_views, t.poll_title, t.topic_replies, t.topic_poster, u.username, u.user_id, u.user_type, u.user_colour, p.post_id, p.post_time, p.post_text, p.post_attachment, p.enable_smilies, p.enable_bbcode, p.enable_magic_url, p.bbcode_bitfield, p.bbcode_uid, f.forum_name FROM phpbb_topics AS t LEFT JOIN phpbb_users as u ON LEFT JOIN phpbb_forums as f ON t.forum_id=f.forum_id LEFT JOIN phpbb_posts as p ON WHERE AND t.topic_status <> 2 AND t.topic_approved = 1 AND t.topic_moved_id = 0 ORDER BY LIMIT 250

BACKTRACE


FILE: includes/db/mysql.php
LINE: 158
CALL: dbal_mysql->sql_error()

FILE: includes/db/mysql.php
LINE: 205
CALL: dbal_mysql->sql_query()

FILE: includes/db/dbal.php
LINE: 159
CALL: dbal_mysql->_sql_query_limit()

FILE: portal/includes/functions.php
LINE: 228
CALL: dbal_mysql->sql_query_limit()

FILE: portal/block/tabnews.php
LINE: 36
CALL: phpbb_fetch_posts()

FILE: portal.php
LINE: 223
CALL: include('portal/block/tabnews.php')
But for me, it's on my dev environment...

Beside me too such problems! Can be who will help? Please!


Many thanks

Re: Tab based Latest News Block - advance skills needed!

Posted: 7. October 2008 22:11
by frold
This is mine:
/portal/includes/functions.php

Code: Select all

<?php

/**
*
* @package - Board3portal
* @version $Id: functions.php 94 2008-02-04 13:54:48Z IcedCold $
* @copyright (c) kevin / saint ( http://www.board3.de/ ), (c) Ice, (c) nickvergessen ( http://www.flying-bits.org/ ), (c) redbull254 ( http://www.digitalfotografie-foren.de )
* @based on: phpBB3 Portal by Sevdin Filiz, www.phpbb3portal.com
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/


if (!defined('IN_PHPBB'))
{
   exit;
}

// Get portal config
function obtain_portal_config()
{
	global $db, $cache;

	if (($portal_config = $cache->get('portal_config')) !== true)
	{
		$portal_config = $cached_portal_config = array();

		$sql = 'SELECT config_name, config_value
			FROM ' . PORTAL_CONFIG_TABLE;
		$result = $db->sql_query($sql);

		while ($row = $db->sql_fetchrow($result))
		{
			$cached_portal_config[$row['config_name']] = $row['config_value'];
			$portal_config[$row['config_name']] = $row['config_value'];
		}
		$db->sql_freeresult($result);

		$cache->put('portal_config', $cached_portal_config);
	}

	return $portal_config;
}

/**
* Set config value. Creates missing config entry.
*/
function set_portal_config($config_name, $config_value)
{
	global $db, $cache, $portal_config;

	$sql = 'UPDATE ' . PORTAL_CONFIG_TABLE . "
		SET config_value = '" . $db->sql_escape($config_value) . "'
		WHERE config_name = '" . $db->sql_escape($config_name) . "'";
	$db->sql_query($sql);

	if (!$db->sql_affectedrows() && !isset($portal_config[$config_name]))
	{
		$sql = 'INSERT INTO ' . PORTAL_CONFIG_TABLE . ' ' . $db->sql_build_array('INSERT', array(
			'config_name'	=> $config_name,
			'config_value'	=> $config_value));
		$db->sql_query($sql);
	}

	$portal_config[$config_name] = $config_value;
}

// 
include($phpbb_root_path . 'includes/message_parser.'.$phpEx);

// fetch post for news & announce
function phpbb_fetch_posts($forum_from, $number_of_posts, $text_length, $time, $type)
{
	global $db, $phpbb_root_path, $auth, $user, $bbcode_bitfield;
	
	$posts = array();

	$post_time = ($time == 0) ? '' : 'AND t.topic_last_post_time > ' . (time() - $time * 86400);

	$forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());

	$str_where = '';

	$allow_access = array_unique(array_keys($auth->acl_getf('f_read', true)));

	if( sizeof($allow_access) ){

		if( sizeof($forum_from) )
		{
			foreach( $allow_access as $acc_id )
			{
				if( in_array($acc_id, $forum_from ) )
				{
					$str_where .= "t.forum_id = $acc_id OR ";
					if( !isset($gobal_f) )
					{				
						$global_f = $acc_id;
					}
				}
			}
		}
		else
		{
			foreach( $allow_access as $acc_id )
			{
				
				$str_where .= "t.forum_id = $acc_id OR ";
				if( !isset($gobal_f) )
				{				
					$global_f = $acc_id;
				}
			}
		}

		if( strlen($str_where) > 0 )
		{

			switch( $type )
			{
				case "announcements":

					$topic_type = '(( t.topic_type = ' . POST_ANNOUNCE . ') OR ( t.topic_type = ' . POST_GLOBAL . '))';
					$str_where = ( strlen($str_where) > 0 ) ? 'AND (t.forum_id = 0 OR ' . substr($str_where, 0, -4) . ')' : '';
					$user_link = 't.topic_poster = u.user_id';
					$post_link = 't.topic_first_post_id = p.post_id';
					$topic_order = 't.topic_time DESC';

				break;
				case "news":

					$topic_type = 't.topic_type = ' . POST_NORMAL;
					$str_where = 'AND (' . substr($str_where, 0, -4) . ')';
					$user_link = 't.topic_last_poster_id = u.user_id';
					$post_link = 't.topic_last_post_id = p.post_id';
					$topic_order = 't.topic_last_post_time DESC';

				break;
				case "news_all":

					$topic_type = '( t.topic_type != ' . POST_ANNOUNCE . ' ) AND ( t.topic_type != ' . POST_GLOBAL . ')';
					$str_where = 'AND (' . substr($str_where, 0, -4) . ')';
					$user_link = 't.topic_last_poster_id = u.user_id';
					$post_link = 't.topic_last_post_id = p.post_id';
					$topic_order = 't.topic_last_post_time DESC';

				break;
			}

			$sql = 'SELECT
						t.forum_id,
						t.topic_id,
						t.topic_last_post_id,
						t.topic_last_post_time,
						t.topic_time,
						t.topic_title,
						t.topic_attachment,
						t.topic_views,
						t.poll_title,
						t.topic_replies,
						t.topic_poster,
						u.username,
						u.user_id,
						u.user_type,
						u.user_colour,
						p.post_id,
						p.post_time,
						p.post_text,
						p.post_attachment,
						p.enable_smilies,
						p.enable_bbcode,
						p.enable_magic_url,
						p.bbcode_bitfield,
						p.bbcode_uid,
						f.forum_name
					FROM
						' . TOPICS_TABLE . ' AS t
					LEFT JOIN
						' . USERS_TABLE . ' as u
					ON
						' . $user_link . '
					LEFT JOIN
						' . FORUMS_TABLE . ' as f
					ON
						t.forum_id=f.forum_id
					LEFT JOIN
						' . POSTS_TABLE . ' as p
					ON
						' . $post_link . '
					WHERE
						' . $topic_type . '
						' . $post_time . '
						AND t.topic_status <> 2
						AND t.topic_approved = 1
						AND t.topic_moved_id = 0
						' . $str_where .'
					ORDER BY
						' . $topic_order;

			if( $number_of_posts == '' OR $number_of_posts == 0)
			{
				$result = $db->sql_query($sql);
			}
			else
			{
				$result = $db->sql_query_limit($sql, $number_of_posts);
			}

			// Instantiate BBCode if need be
			if ($bbcode_bitfield !== '')
			{
				$phpEx = substr(strrchr(__FILE__, '.'), 1);
				include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
				$bbcode = new bbcode(base64_encode($bbcode_bitfield));
			}
	
			$i = 0;

			while ( $row = $db->sql_fetchrow($result) )
			{
				if ($row['user_id'] != ANONYMOUS && $row['user_colour'])
				{
					$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
				}

				$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
				$len_check = $row['post_text'];
				$maxlen = $text_length;

				if (($text_length != 0) && (strlen($len_check) > $text_length))
				{
					$message = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
					$posts[$i]['striped'] = true;
				}
				else 
				{
					$message = censor_text( str_replace("\n", '<br/> ', $row['post_text']) );
				}

				if ($auth->acl_get('f_html', $row['forum_id'])) 
				{
					$message = preg_replace('#<!\-\-(.*?)\-\->#is', '', $message); // Remove Comments from post content
				}

				// Second parse bbcode here
				if ($row['bbcode_bitfield'])
				{
					$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
				}
				$message = smiley_text($message); // Always process smilies after parsing bbcodes

				$posts[$i]['post_text']				= ap_validate($message);
				$posts[$i]['topic_id']				= $row['topic_id'];
				$posts[$i]['topic_last_post_id']	= $row['topic_last_post_id'];
				$posts[$i]['forum_id']				= $row['forum_id'];
				$posts[$i]['topic_replies'] 		= $row['topic_replies'];
				$posts[$i]['topic_time']			= $user->format_date($row['post_time']);
				$posts[$i]['topic_last_post_time']	= $row['topic_last_post_time'];
				$posts[$i]['topic_title']			= $row['topic_title'];
				$posts[$i]['username']				= $row['username'];
				$posts[$i]['user_id']				= $row['user_id'];
				$posts[$i]['user_type']				= $row['user_type'];
				$posts[$i]['user_user_colour']		= $row['user_colour'];
				$posts[$i]['poll']					= ($row['poll_title']) ? true : false;
				$posts[$i]['attachment']			= ($row['topic_attachment']) ? true : false;
				$posts[$i]['topic_views']			= $row['topic_views'];
				$posts[$i]['forum_name']			= $row['forum_name'];
				$posts[$i]['global_id']				= $global_f;
										
				$i++;
			}
		}
	}

	return $posts;
}

/**
* Censor title, return short title
*
* @param $title string title to censor
* @param $limit int short title character limit
*
*/
function character_limit(&$title, $limit = 0)
{
   $title = censor_text($title);
   if ($limit > 0)
   {
	  return (strlen(utf8_decode($title)) > $limit + 3) ? truncate_string($title, $limit) . '...' : $title;
   }
   else
   {
	  return $title;
   }
}

/**
* Get user avatar  / barroved from RC4
*
* @param string $avatar Users assigned avatar name
* @param int $avatar_type Type of avatar
* @param string $avatar_width Width of users avatar
* @param string $avatar_height Height of users avatar
* @param string $alt Optional language string for alt tag within image, can be a language key or text
*
* @return string Avatar image
*/
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR')
{
	global $user, $portal_config, $config, $phpbb_root_path, $phpEx;

	if (empty($avatar) || !$avatar_type)
	{
		return '';
	}

	$avatar_img = '';

	switch ($avatar_type)
	{
		case AVATAR_UPLOAD:
			$avatar_img = $phpbb_root_path . "download/file.$phpEx?avatar=";
		break;

		case AVATAR_GALLERY:
			$avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
		break;
	}

	$avatar_img .= $avatar;
	return '<img src="' . $avatar_img . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}

/**
* Get user rank title and image  / barroved from RC4
*
* @param int $user_rank the current stored users rank id
* @param int $user_posts the users number of posts
* @param string &$rank_title the rank title will be stored here after execution
* @param string &$rank_img the rank image as full img tag is stored here after execution
* @param string &$rank_img_src the rank image source is stored here after execution
*
*/
function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank_img_src)
{
	global $ranks, $config;

	if (empty($ranks))
	{
		global $cache;
		$ranks = $cache->obtain_ranks();
	}

	if (!empty($user_rank))
	{
		$rank_title = (isset($ranks['special'][$user_rank]['rank_title'])) ? $ranks['special'][$user_rank]['rank_title'] : '';
		$rank_img = (!empty($ranks['special'][$user_rank]['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] . '" alt="' . $ranks['special'][$user_rank]['rank_title'] . '" title="' . $ranks['special'][$user_rank]['rank_title'] . '" />' : '';
		$rank_img_src = (!empty($ranks['special'][$user_rank]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$user_rank]['rank_image'] : '';
	}
	else
	{
		if (!empty($ranks['normal']))
		{
			foreach ($ranks['normal'] as $rank)
			{
				if ($user_posts >= $rank['rank_min'])
				{
					$rank_title = $rank['rank_title'];
					$rank_img = (!empty($rank['rank_image'])) ? '<img src="' . $config['ranks_path'] . '/' . $rank['rank_image'] . '" alt="' . $rank['rank_title'] . '" title="' . $rank['rank_title'] . '" />' : '';
					$rank_img_src = (!empty($rank['rank_image'])) ? $config['ranks_path'] . '/' . $rank['rank_image'] : '';
					break;
				}
			}
		}
	}
}


// Don't let them mess up the complete portal layout in cut messages and do some real AP magic

function is_valid_bbtag($str, $bbuid) {
  return (substr($str,0,1) == '[') && (strpos($str, ':'.$bbuid.']') > 0);
}

function get_end_bbtag($tag, $bbuid) {
  $etag = '';
  for($i=0;$i<strlen($tag);$i++) {
    if ($tag[$i] == '[') $etag .= $tag[$i] . '/';
    else if (($tag[$i] == '=') || ($tag[$i] == ':')) {
      if ($tag[1] == '*') $etag .= ':m:'.$bbuid.']';
      else if (strpos($tag, 'list')) $etag .= ':u:'.$bbuid.']';
      else $etag .= ':'.$bbuid.']';
      break;
    } else $etag .= $tag[$i];
  }

  return $etag;
}

function get_next_word($str) {
  $ret = '';
  for($i=0;$i<strlen($str);$i++) {
    switch ($str[$i]) {
      case ' ': //$ret .= ' '; break; break;
                return $ret . ' ';
      case '\\': 
        if ($str[$i+1] == 'n') return $ret . '\n';
      case '[': if ($i != 0) return $ret;
      default: $ret .= $str[$i];
    }    
  }
  return $ret;
}

function get_sub_taged_string($str, $bbuid, $maxlen) {
  $sl = $str;
  $ret = '';
  $ntext = '';
  $lret = '';
  $i = 0;
  $cnt = $maxlen;
  $last = '';
  $arr = array();

  while((strlen($ntext) < $cnt) && (strlen($sl) > 0)) {
    $sr = '';
    if (substr($sl, 0, 1) == '[') $sr = substr($sl,0,strpos($sl,']')+1);
    /* GESCHLOSSENE HTML-TAGS BEACHTEN */
    if (substr($sl, 0, 1) == '<') {
      $sr = substr($sl,0,strpos($sl,'>')+1);
      $ret .= $sr;
    } else if (is_valid_bbtag($sr, $bbuid)) {
      if ($sr[1] == '/') {
        /* entfernt das endtag aus dem tag array */
        $tarr = array();
        $j = 0;
        foreach ($arr as $elem) {
          if (strcmp($elem[1],$sr) != 0) $tarr[$j++] = $elem;
        }
        $arr = $tarr;
      } else {
        $arr[$i][0] = $sr;
        $arr[$i++][1] = get_end_bbtag($sr, $bbuid);
      } 
      $ret .= $sr;
    } else {
      $sr = get_next_word($sl);
      $ret .= $sr;
      $ntext .= $sr;
      $last = $sr;
    }
    $sl = substr($sl, strlen($sr), strlen($sl)-strlen($sr));
  }

  $ret = trim($ret) . '...';

  $ap = '';
  foreach ($arr as $elem) {
     $ap = $elem[1] . $ap;
  }
  $ret .= $ap;

  return $ret;
}

function ap_validate($str) {
  $s = str_replace('<br />', '<br/>', $str);
  return str_replace('</li><br/>', '</li>', $s);
}

?>

Re: Tab based Latest News Block - advance skills needed!

Posted: 7. October 2008 22:28
by Kevin
Uh - this is pretty outdated:
$Id: functions.php 94 2008-02-04

Re: Tab based Latest News Block - advance skills needed!

Posted: 7. October 2008 22:45
by frold
Kevin wrote:Uh - this is pretty outdated:
$Id: functions.php 94 2008-02-04
Yes I know - I doesnt use a updated portal version - I use my own modified one.

I just pasted the code and I hope that the user in this way maybe could solve the problem by himself.

This topic starts with: Advance skills needed, so I guess the user have that :D

Re: Tab based Latest News Block - advance skills needed!

Posted: 8. October 2008 07:55
by Kevin
Yes, i know - just wanted to remark this for other users. ;)

Re: Tab based Latest News Block - advance skills needed!

Posted: 8. October 2008 20:39
by dimasik
Miserable, as well as has not earned. The problem in
[phpBB Debug] PHP Notice: in file /portal/includes/functions.php on line 75: Missing argument 6 for phpbb_fetch_posts(), called in /portal/block/tabnews.php on line 36 and defined
If who will solve a problem, with me tasty beer!! ;)

Re: Tab based Latest News Block - advance skills needed!

Posted: 7. December 2008 10:01
by derkubi
Hello

Whats about subsilver based styles ?

I have 4 styles , prosilver and 3 subsilverbased styles ( aerobluex , bf-vista , x-static ) . think that i cant modify all 4 styles at the same time , what happens when i try to install it under prosilver , are the other styles still working ?

Re: Tab based Latest News Block - advance skills needed!

Posted: 7. December 2008 14:53
by Dyo
@derkubi

na da haste das MOD ja schneller gefunden wie gedacht. ;)
Nur wie immer wo es doch am nächsten liegt schaut man als letztes, geht mir auch oft so.

Wenn du das Ding unter Prosilver machst, sollten die anderen Styles bedingt noch laufen, bis auf eben diesen Teil und alle Seiten die das verwenden. Also die Portalseite die den Mittelblock nutzt wird wohl entweder missgestaltet oder ganz streiken.

Als Workarround, generiere doch DummyDateien der fehlende Templates für die anderen Styles, damit es nicht zu Fehlern kommt wegen fehlender Dateien. Wenn in diesen Dummies nix drin ist, wird eben kein Code/Templatecode geparst und die Stelle bleibt unter dem betreffenden Style leer.

Während der Arbeit an einem Style kannst du ja dann in dem Block oben immer als erstes eine Warnung einbauen, dass wegen Programmierarbeiten in diesem Block zeitweise Bullshit erscheinen könnte. So wissen die User Bescheid und alles ist fein beim Arbeiten.

Re: Tab based Latest News Block - advance skills needed!

Posted: 7. December 2008 17:34
by derkubi
Dyo wrote:@derkubi

na da haste das MOD ja schneller gefunden wie gedacht. ;)
Nicht gesucht , PN an frold geschrieben :D
Dyo wrote:

Während der Arbeit an einem Style kannst du ja dann in dem Block oben immer als erstes eine Warnung einbauen, dass wegen Programmierarbeiten in diesem Block zeitweise Bullshit erscheinen könnte. So wissen die User Bescheid und alles ist fein beim Arbeiten.
Ich sehe schon , das wird wieder Nachtarbeit :(

@frold

Code: Select all

SQL ERROR [ mysql4 ]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN phpbb_forums as f ON t.forum_id=f.forum_id LEFT JOIN phpb' at line 33 [1064]

SQL

SELECT t.forum_id, t.topic_id, t.topic_last_post_id, t.topic_last_post_time, t.topic_time, t.topic_title, t.topic_attachment, t.topic_views, t.poll_title, t.topic_replies, t.topic_poster, u.username, u.user_id, u.user_type, u.user_colour, p.post_id, p.post_time, p.post_text, p.post_attachment, p.enable_smilies, p.enable_bbcode, p.enable_magic_url, p.bbcode_bitfield, p.bbcode_uid, f.forum_name FROM phpbb_topics AS t LEFT JOIN phpbb_users as u ON LEFT JOIN phpbb_forums as f ON t.forum_id=f.forum_id LEFT JOIN phpbb_posts as p ON WHERE AND t.topic_status <> 2 AND t.topic_approved = 1 AND t.topic_moved_id = 0 ORDER BY LIMIT 100

BACKTRACE

FILE: includes/db/mysql.php
LINE: 158
CALL: dbal->sql_error()

FILE: includes/db/mysql.php
LINE: 205
CALL: dbal_mysql->sql_query()

FILE: includes/db/dbal.php
LINE: 157
CALL: dbal_mysql->_sql_query_limit()

FILE: portal/includes/functions.php
LINE: 228
CALL: dbal->sql_query_limit()

FILE: portal/block/tabnews.php
LINE: 36
CALL: phpbb_fetch_posts()

FILE: portal2.php
LINE: 221
CALL: include('portal/block/tabnews.php')