Add Homepage link in header

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
Locked
blombardo
Registered User
Posts: 24
Joined: Mon Sep 07, 2009 10:21 pm

Re: Add Homepage link in header

Post by blombardo » Wed Sep 09, 2009 10:31 am

IT WORKS!!!

but all I can keep thinking -- is OMG... why are there SO MANY steps - SO Many different files to edit - in so many different locations - that require me to use multiple different software programs to perform - and multiple login/passwords...

WHY does this have to be so complicated?

Though I'm very happy it works - I'm still totally in the dark on WHY it FAILED to work with the 'auto mod' program...

I'm guessing the #1 reason is that Automod cant run a SQL query?
the #2 reason could be that I'm using a custom style that was not compatible without special code...

I would feel much better knowing WHAT I did wrong -- otherwise I'll be expecting to spend another 8 hours for the next "5 minute mod " I install...

Thanks again for your help ; it would not have happened without all of it.

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: Add Homepage link in header

Post by ChriZathens » Wed Sep 09, 2009 10:52 am

AFAIK Automod handles SQL commands perfectly..So, I wouldn't know why it failed (perhaps it did not fail, it just uninstalled the sql changes if you have tried to uninstall the mod)
The thing with your styles is a different matter. Your style actually was exactly the same as subsilver2 (at least at the part where the edits should be applied). the new version of Automod has the ability to install changes for different styles - so I've heard - but I have not seen it with my own eyes working so I should have no opinion about what should be done in the first place in order to have the subsilver2 edits in your style. Perhaps you should ask in the Automod topic.
I can't think of anything else regarding why you had no luck in installing with Automod...

P.S.: I think, though, that you should consider trying to install a few simple mods the manual way. Get a copy of phpbb 3.0.5, install it on localhost using Xampp and experiment a bit. Try to install simple mods, just to see how it is done. The manual installation helps you understand how exactly things work and in the future you will be able to easily understand what to fix if things go wrong (or simply what file to restore)
Good luck in your future attempts..
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

domestictuner
Registered User
Posts: 8
Joined: Thu Sep 03, 2009 4:38 am

Re: Add Homepage link in header

Post by domestictuner » Thu Sep 10, 2009 12:56 am

ChriZathens,
SQL Queries
Error:Duplicate entry 'show_homepage' for key 1
INSERT INTO phpbb3config (config_name, config_value) VALUES ('show_homepage', '0')
Error:Duplicate entry 'show_homepage_in_new' for key 1
INSERT INTO phpbb3config (config_name, config_value) VALUES ('show_homepage_in_new', '0')
Error:Duplicate entry 'homepage_url' for key 1
INSERT INTO phpbb3config (config_name, config_value) VALUES ('homepage_url', 'http://www.your_own_site.com')
Error:Duplicate entry 'homepage_title' for key 1
INSERT INTO phpbb3config (config_name, config_value) VALUES ('homepage_title', 'Your homepage title')


This has happened because the sql has already run and running it again would cause duplicate entries. Bottom line is that as far as the database is concerned, all needed is done
this wasn't my post, but it looks like you thought it was based on your instructions, i have made all of the changes listed in the automod to uninstall, but it is still showing as the mod being installed... can i manually edit the changes back in (reverse the steps) and with adding your template change to getaway expect it to work?

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: Add Homepage link in header

Post by ChriZathens » Thu Sep 10, 2009 7:20 am

Pardon me but I got a bit confused... :?
You finally want to install the mod, or uninstall it?
Anyways, to get rid of the SQL entries you can enter something like this in phpmyadmin:

Code: Select all

DELETE FROM phpbb_config WHERE config_name = 'show_homepage';
DELETE FROM phpbb_config WHERE config_name = 'show_homepage_in_new';
DELETE FROM phpbb_config WHERE config_name = 'homepage_url';
DELETE FROM phpbb_config WHERE config_name = 'homepage_title';
If you want to finally install it, I suggest you go the manual way. Leave the database as is (since it reports it is already installed) and dedicate 5 minutes to edit the files.
Or you can give it a try again with Automod, although since I cannot possibly know what the status of your files are right now, I cannot recommend it....
About your template: If it is gataway, then yes, use those changes: http://www.phpbb.com/community/viewtopi ... #p10703245
If you face any problems post here.. ;)
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

domestictuner
Registered User
Posts: 8
Joined: Thu Sep 03, 2009 4:38 am

Re: Add Homepage link in header

Post by domestictuner » Thu Sep 10, 2009 4:20 pm

i have made the changes to the files, leaving the database alone as far as i know, after i added the change to the style i clicked on board settings in thew acp and got this error
'DISABLE_BOARD' => 'Disable board', 'HOMEPAGE_URL' => 'Homepage url', 'HOMEPAGE_URL_EXPLAIN' => 'Enter here your homepage’s URL. You can either use something like "../site", if your homepage is at the same domain, or use the absolute path for other domains.. ', 'HOMEPAGE_TITLE' => 'Homepage title', 'HOMEPAGE_TITLE_EXPLAIN' => 'This title will show when you have your mouse over your homepage link. If you don´t want to show a title, just leave this field blank.',[phpBB Debug] PHP Notice: in file /adm/index.php on line 150: Cannot modify header information - headers already sent by (output started at /language/en/acp/board.php:488)
[phpBB Debug] PHP Notice: in file /adm/index.php on line 152: Cannot modify header information - headers already sent by (output started at /language/en/acp/board.php:488)
[phpBB Debug] PHP Notice: in file /adm/index.php on line 153: Cannot modify header information - headers already sent by (output started at /language/en/acp/board.php:488)
[phpBB Debug] PHP Notice: in file /adm/index.php on line 154: Cannot modify header information - headers already sent by (output started at /language/en/acp/board.php:488)

w0rld_life
Registered User
Posts: 59
Joined: Wed Jul 02, 2008 4:24 pm
Contact:

Re: Add Homepage link in header

Post by w0rld_life » Thu Sep 10, 2009 4:31 pm

/* Some examples to help you understand what you should put here:
1. If your forum home is http://www.yoursite.com/forum and your homepage is at http://www.yoursite.com/site, you could simply put ../site in the following line
2. If your forum home is http://www.yoursite.com/forum and your homepage is at http://www.yoursite.com/, you could simply put ../ in the following line
3. If your forum home is http://www.yoursite.com/forum and your homepage is at http://www.yourothersite.com/, you could directly add the address (http://www.yourothersite.com/) in the following line
For this mod let's presume we have example 1 */

'U_HOMEPAGE' => "../site",

Coudnt find this in the functions.php :|

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: Add Homepage link in header

Post by ChriZathens » Thu Sep 10, 2009 5:00 pm

w0rld_life wrote:/* Some examples to help you understand what you should put here:
1. If your forum home is http://www.yoursite.com/forum and your homepage is at http://www.yoursite.com/site, you could simply put ../site in the following line
2. If your forum home is http://www.yoursite.com/forum and your homepage is at http://www.yoursite.com/, you could simply put ../ in the following line
3. If your forum home is http://www.yoursite.com/forum and your homepage is at http://www.yourothersite.com/, you could directly add the address (http://www.yourothersite.com/) in the following line
For this mod let's presume we have example 1 */

'U_HOMEPAGE' => "../site",

Coudnt find this in the functions.php :|
What exactly can't you find? And besides this, you don't seem to have downloaded the latest version of this mod... Please download it again, these instruction are from an older version...

@domestictuner : make sure that you have saved your language files as UTF8 without BOM
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

domestictuner
Registered User
Posts: 8
Joined: Thu Sep 03, 2009 4:38 am

Re: Add Homepage link in header

Post by domestictuner » Thu Sep 10, 2009 11:03 pm

ChriZathens wrote:
@domestictuner : make sure that you have saved your language files as UTF8 without BOM
even easier then that, for some reason my coal fired computer put the change at the end, after the >?

one more question, i asked before if i can add another link up there changeable from the acp. Can i duplicate just the file changes or would i have to make changes in the sql also? I need to add a link to a gallery. Thank you for your help and patience.

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: Add Homepage link in header

Post by ChriZathens » Thu Sep 10, 2009 11:28 pm

You will also need to duplicate the sql changes.
Since you want this ACP configurable, the easiest thing I can thing of, to avoid mistakes, is to change all instances of "homepage" to "gallery" in your duplicate edits. :)
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

domestictuner
Registered User
Posts: 8
Joined: Thu Sep 03, 2009 4:38 am

Re: Add Homepage link in header

Post by domestictuner » Fri Sep 11, 2009 4:11 am

i have got the gallery configurable in the acp, but i have a issue with the navrow, it will only display one or the other, i have to delete either the gallery or the homepage for the other to show, I am not sure what to change in the overall_header to display another link.

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: Add Homepage link in header

Post by ChriZathens » Fri Sep 11, 2009 7:35 am

Assuming that all the other edits are correct, in overall_header.html find:

Code: Select all

<div class="navrow">
Add, after:

Code: Select all

		<!-- IF S_SHOW_GALLERY and U_GALLERY --><a href="{U_GALLERY}" <!-- IF U_GALLERY_TITLE -->title="{U_GALLERY_TITLE}"<!-- ENDIF --><!-- IF S_SHOW_GALLERY_IN_NEW -->onclick="window.open(this.href); return false;"<!-- ENDIF -->>{L_GALLERY}</a> &#8226; <!-- ENDIF -->
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

domestictuner
Registered User
Posts: 8
Joined: Thu Sep 03, 2009 4:38 am

Re: Add Homepage link in header

Post by domestictuner » Sat Sep 12, 2009 12:24 am

Thanks for the help chrizathens it works like a champ

extramsg
Registered User
Posts: 7
Joined: Tue Jan 18, 2005 5:31 am

Re: Add Homepage link in header

Post by extramsg » Sat Sep 12, 2009 7:47 am

I've had several problems with this. I'm using 3.0.5 with only two mods installed via AutoMod: anti-bot question and prime-login return. I'm using Prosilver, also.

The file provided after running AutoMod doesn't seem to have any files for uploading. It has some xml and xsl pages, plus some images. Are the images supposed to be uploaded and the xsl document pasted into the theme?

But none of the files that are said to need file edits after the "install" are provided. So I went in to edit and the lines to find in the functions.php don't appear to be there. eg, it says to find this:

Code: Select all

'SITE_LOGO_IMG'			=> $user->img('site_logo'),
In this:

Code: Select all

<?php
/***************************************************************************
 *                               functions.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: functions.php,v 1.133.2.32 2004/07/17 13:48:31 acydburn Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *
 ***************************************************************************/
if ( !defined('IN_PHPBB') )
{
        die("Hacking attempt");
        exit;
}

function get_db_stat($mode)
{
	global $db;

	switch( $mode )
	{
		case 'usercount':
			$sql = "SELECT COUNT(user_id) AS total
				FROM " . USERS_TABLE . "
				WHERE user_id <> " . ANONYMOUS;
			break;

		case 'newestuser':
			$sql = "SELECT user_id, username
				FROM " . USERS_TABLE . "
				WHERE user_id <> " . ANONYMOUS . "
				ORDER BY user_id DESC
				LIMIT 1";
			break;

		case 'postcount':
		case 'topiccount':
			$sql = "SELECT SUM(forum_topics) AS topic_total, SUM(forum_posts) AS post_total
				FROM " . FORUMS_TABLE;
			break;
	}

	if ( !($result = $db->sql_query($sql)) )
	{
		return false;
	}

	$row = $db->sql_fetchrow($result);

	switch ( $mode )
	{
		case 'usercount':
			return $row['total'];
			break;
		case 'newestuser':
			return $row;
			break;
		case 'postcount':
			return $row['post_total'];
			break;
		case 'topiccount':
			return $row['topic_total'];
			break;
	}

	return false;
}

//
// Get Userdata, $user can be username or user_id. If force_str is true, the username will be forced.
//
function get_userdata($user, $force_str = false)
{
	global $db;

	if (intval($user) == 0 || $force_str)
	{
		$user = trim(htmlspecialchars($user));
		$user = substr(str_replace("\\'", "'", $user), 0, 25);
		$user = str_replace("'", "\\'", $user);
	}
	else
	{
		$user = intval($user);
	}

	$sql = "SELECT *
                FROM " . USERS_TABLE . "
		WHERE ";
	$sql .= ( ( is_integer($user) ) ? "user_id = $user" : "username = '" .  $user . "'" ) . " AND user_id <> " . ANONYMOUS;
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql);
	}

	return ( $row = $db->sql_fetchrow($result) ) ? $row : false;
}

function make_jumpbox($action, $match_forum_id = 0)
{
	global $template, $userdata, $lang, $db, $nav_links, $phpEx, $SID;

//	$is_auth = auth(AUTH_VIEW, AUTH_LIST_ALL, $userdata);

	$sql = "SELECT c.cat_id, c.cat_title, c.cat_order
		FROM " . CATEGORIES_TABLE . " c, " . FORUMS_TABLE . " f
		WHERE f.cat_id = c.cat_id
		GROUP BY c.cat_id, c.cat_title, c.cat_order
		ORDER BY c.cat_order";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Couldn't obtain category list.", "", __LINE__, __FILE__, $sql);
	}
	
	$category_rows = array();
	while ( $row = $db->sql_fetchrow($result) )
	{
		$category_rows[] = $row;
	}

	if ( $total_categories = count($category_rows) )
	{
		$sql = "SELECT *
			FROM " . FORUMS_TABLE . "
			ORDER BY cat_id, forum_order";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
		}

		$boxstring = '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"><option value="-1">' . $lang['Select_forum'] . '</option>';

		$forum_rows = array();
		while ( $row = $db->sql_fetchrow($result) )
		{
			$forum_rows[] = $row;
		}

		if ( $total_forums = count($forum_rows) )
		{
			for($i = 0; $i < $total_categories; $i++)
			{
				$boxstring_forums = '';
				for($j = 0; $j < $total_forums; $j++)
				{
					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $forum_rows[$j]['auth_view'] <= AUTH_REG )
					{

//					if ( $forum_rows[$j]['cat_id'] == $category_rows[$i]['cat_id'] && $is_auth[$forum_rows[$j]['forum_id']]['auth_view'] )
//					{
						$selected = ( $forum_rows[$j]['forum_id'] == $match_forum_id ) ? 'selected="selected"' : '';
						$boxstring_forums .=  '<option value="' . $forum_rows[$j]['forum_id'] . '"' . $selected . '>' . $forum_rows[$j]['forum_name'] . '</option>';

						//
						// Add an array to $nav_links for the Mozilla navigation bar.
						// 'chapter' and 'forum' can create multiple items, therefore we are using a nested array.
						//
						$nav_links['chapter forum'][$forum_rows[$j]['forum_id']] = array (
							'url' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_rows[$j]['forum_id']),
							'title' => $forum_rows[$j]['forum_name']
						);

					}
				}

				if ( $boxstring_forums != '' )
				{
					$boxstring .= '<option value="-1">&nbsp;</option>';
					$boxstring .= '<option value="-1">' . $category_rows[$i]['cat_title'] . '</option>';
					$boxstring .= '<option value="-1">----------------</option>';
					$boxstring .= $boxstring_forums;
				}
			}
		}

		$boxstring .= '</select>';
	}
	else
	{
		$boxstring .= '<select name="' . POST_FORUM_URL . '" onchange="if(this.options[this.selectedIndex].value != -1){ forms[\'jumpbox\'].submit() }"></select>';
	}

	// Let the jumpbox work again in sites having additional session id checks.
//	if ( !empty($SID) )
//	{
                $boxstring .= '<input type="hidden" name="sid" value="' . $SID . '" />';
//	}

	$template->set_filenames(array(
		'jumpbox' => 'jumpbox.tpl')
	);
	$template->assign_vars(array(
		'L_GO' => $lang['Go'],
		'L_JUMP_TO' => $lang['Jump_to'],
		'L_SELECT_FORUM' => $lang['Select_forum'],

		'S_JUMPBOX_SELECT' => $boxstring,
		'S_JUMPBOX_ACTION' => append_sid($action))
	);
	$template->assign_var_from_handle('JUMPBOX', 'jumpbox');

	return;
}

//
// Initialise user settings on page load
function init_userprefs($userdata)
{
	global $board_config, $theme, $images;
	global $template, $lang, $phpEx, $phpbb_root_path;
	global $nav_links;

	if ( $userdata['user_id'] != ANONYMOUS )
	{
		if ( !empty($userdata['user_lang']))
		{
			$board_config['default_lang'] = $userdata['user_lang'];
		}

		if ( !empty($userdata['user_dateformat']) )
		{
			$board_config['default_dateformat'] = $userdata['user_dateformat'];
		}

		if ( isset($userdata['user_timezone']) )
		{
			$board_config['board_timezone'] = $userdata['user_timezone'];
		}
	}

	if ( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx)) )
	{
		$board_config['default_lang'] = 'english';
	}

	include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx);

	if ( defined('IN_ADMIN') )
	{
		if( !file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.'.$phpEx)) )
		{
			$board_config['default_lang'] = 'english';
		}

		include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);
	}

	//
	// Set up style
	//
	if ( !$board_config['override_user_style'] )
	{
		if ( $userdata['user_id'] != ANONYMOUS && $userdata['user_style'] > 0 )
		{
			if ( $theme = setup_style($userdata['user_style']) )
			{
				return;
			}
		}
	}

	$theme = setup_style($board_config['default_style']);

	//
	// Mozilla navigation bar
	// Default items that should be valid on all pages.
	// Defined here to correctly assign the Language Variables
	// and be able to change the variables within code.
	//
        $nav_links['top'] = array (
		'url' => append_sid($phpbb_root_path . 'index.' . $phpEx),
		'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
	);
        $nav_links['search'] = array (
		'url' => append_sid($phpbb_root_path . 'search.' . $phpEx),
		'title' => $lang['Search']
	);
        $nav_links['help'] = array (
		'url' => append_sid($phpbb_root_path . 'faq.' . $phpEx),
		'title' => $lang['FAQ']
	);
        $nav_links['author'] = array (
		'url' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx),
		'title' => $lang['Memberlist']
	);

	return;
}

function setup_style($style)
{
	global $db, $board_config, $template, $images, $phpbb_root_path;
        if($name == "Forums"){
                cookiedecode($user);
            $info=sql_query("select * from ".$prefix."_bbconfig where config_name='default_style'", $dbi);
            $get_info=mysql_fetch_array($info);
            $default_style=$get_info[config_value];
            if($cookie[1] == "" AND $style != "$default_style") {
                $style = "$default_style";
            }
        }

	$sql = "SELECT *
		FROM " . THEMES_TABLE . "
                WHERE themes_id = '$style'";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(CRITICAL_ERROR, 'Could not query database for theme info');
	}

	if ( !($row = $db->sql_fetchrow($result)) )
	{
		message_die(CRITICAL_ERROR, "Could not get theme data for themes_id [$style]");
	}

        $ThemeSel = get_theme();
        if (file_exists("themes/$ThemeSel/forums/index_body.tpl")) {
                $template_path = "themes/$ThemeSel/";
            $template_name = "forums";
            $template = new Template($template_path . $template_name, $board_config, $db);
        } else {
	$template_path = 'templates/' ;
	$template_name = $row['template_name'] ;
            $template = new Template($phpbb_root_path . $template_path . $template_name, $board_config, $db);
        }



	if ( $template )
	{
		$current_template_path = $template_path . $template_name;
                $ThemeSel = get_theme();
                if (file_exists("themes/$ThemeSel/$template_name/index_body.tpl")) {
                    @include($template_path . $template_name . '/' . $template_name . '.cfg');
                } else {
		@include($phpbb_root_path . $template_path . $template_name . '/' . $template_name . '.cfg');
                }
		if ( !defined('TEMPLATE_CONFIG') )
		{
			message_die(CRITICAL_ERROR, "Could not open $template_name template config file", '', __LINE__, __FILE__);
		}

		$img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';

		while( list($key, $value) = @each($images) )
		{
			if ( !is_array($value) )
			{
				$images[$key] = str_replace('{LANG}', 'lang_' . $img_lang, $value);
			}
		}
	}

	return $row;
}

function encode_ip($dotquad_ip)
{
	$ip_sep = explode('.', $dotquad_ip);
	return sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]);
}

function decode_ip($int_ip)
{
	$hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
	return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
}

//
// Create date/time from format and timezone
//
function create_date($format, $gmepoch, $tz)
{
	global $board_config, $lang;
	static $translate;

	if ( empty($translate) && $board_config['default_lang'] != 'english' )
	{
		@reset($lang['datetime']);
		while ( list($match, $replace) = @each($lang['datetime']) )
		{
			$translate[$match] = $replace;
		}
	}

	return ( !empty($translate) ) ? strtr(@gmdate($format, $gmepoch + (3600 * $tz)), $translate) : @gmdate($format, $gmepoch + (3600 * $tz));
}

//
// Pagination routine, generates
// page number sequence
//
function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE)
{
	global $lang;

	$total_pages = ceil($num_items/$per_page);

	if ( $total_pages == 1 )
	{
		return '';
	}

	$on_page = floor($start_item / $per_page) + 1;

	$page_string = '';
	if ( $total_pages > 10 )
	{
		$init_page_max = ( $total_pages > 3 ) ? 3 : $total_pages;

		for($i = 1; $i < $init_page_max + 1; $i++)
		{
			$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
			if ( $i <  $init_page_max )
			{
				$page_string .= ", ";
			}
		}

		if ( $total_pages > 3 )
		{
			if ( $on_page > 1  && $on_page < $total_pages )
			{
				$page_string .= ( $on_page > 5 ) ? ' ... ' : ', ';

				$init_page_min = ( $on_page > 4 ) ? $on_page : 5;
				$init_page_max = ( $on_page < $total_pages - 4 ) ? $on_page : $total_pages - 4;

				for($i = $init_page_min - 1; $i < $init_page_max + 2; $i++)
				{
					$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
					if ( $i <  $init_page_max + 1 )
					{
						$page_string .= ', ';
					}
				}

				$page_string .= ( $on_page < $total_pages - 4 ) ? ' ... ' : ', ';
			}
			else
			{
				$page_string .= ' ... ';
			}

			for($i = $total_pages - 2; $i < $total_pages + 1; $i++)
			{
				$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>'  : '<a href="' . append_sid($base_url . "&start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
				if( $i <  $total_pages )
				{
					$page_string .= ", ";
				}
			}
		}
	}
	else
	{
		for($i = 1; $i < $total_pages + 1; $i++)
		{
			$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . append_sid($base_url . "&start=" . ( ( $i - 1 ) * $per_page ) ) . '">' . $i . '</a>';
			if ( $i <  $total_pages )
			{
				$page_string .= ', ';
			}
		}
	}

	if ( $add_prevnext_text )
	{
		if ( $on_page > 1 )
		{
			$page_string = ' <a href="' . append_sid($base_url . "&start=" . ( ( $on_page - 2 ) * $per_page ) ) . '">' . $lang['Previous'] . '</a>&nbsp;&nbsp;' . $page_string;
		}

		if ( $on_page < $total_pages )
		{
			$page_string .= '&nbsp;&nbsp;<a href="' . append_sid($base_url . "&start=" . ( $on_page * $per_page ) ) . '">' . $lang['Next'] . '</a>';
		}

	}

	$page_string = $lang['Goto_page'] . ' ' . $page_string;

	return $page_string;
}

//
// This does exactly what preg_quote() does in PHP 4-ish
// If you just need the 1-parameter preg_quote call, then don't bother using this.
//
function phpbb_preg_quote($str, $delimiter)
{
	$text = preg_quote($str);
	$text = str_replace($delimiter, '\\' . $delimiter, $text);

	return $text;
}

//
// Obtain list of naughty words and build preg style replacement arrays for use by the
// calling script, note that the vars are passed as references this just makes it easier
// to return both sets of arrays
//
function obtain_word_list(&$orig_word, &$replacement_word)
{
	global $db;

	//
	// Define censored word matches
	//
	$sql = "SELECT word, replacement
		FROM  " . WORDS_TABLE;
	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get censored words from database', '', __LINE__, __FILE__, $sql);
	}

	if ( $row = $db->sql_fetchrow($result) )
	{
                do
		{
			$orig_word[] = '#\b(' . str_replace('\*', '\w*?', phpbb_preg_quote($row['word'], '#')) . ')\b#i';
			$replacement_word[] = $row['replacement'];
		}
		while ( $row = $db->sql_fetchrow($result) );
	}

	return true;
}

//
// This is general replacement for die(), allows templated
// output in users (or default) language, etc.
//
// $msg_code can be one of these constants:
//
// GENERAL_MESSAGE : Use for any simple text message, eg. results
// of an operation, authorisation failures, etc.
//
// GENERAL ERROR : Use for any error which occurs _AFTER_ the
// common.php include and session code, ie. most errors in
// pages/functions
//
// CRITICAL_MESSAGE : Used when basic config data is available but
// a session may not exist, eg. banned users
//
// CRITICAL_ERROR : Used when config data cannot be obtained, eg
// no database connection. Should _not_ be used in 99.5% of cases
//
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '')
{
	global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images;
	global $userdata, $user_ip, $session_length;
	global $starttime;

	if(defined('HAS_DIED'))
	{
		die("message_die() was called multiple times. This isn't supposed to happen. Was message_die() used in page_tail.php?");
	}

	define(HAS_DIED, 1);


	$sql_store = $sql;

	//
        // Get SQL error if we are debugging. Do this as soon as possible to prevent
	// subsequent queries from overwriting the status of sql_error()
	//
	if ( DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) )
	{
		$sql_error = $db->sql_error();

		$debug_text = '';

		if ( $sql_error['message'] != '' )
		{
			$debug_text .= '<br /><br />SQL Error : ' . $sql_error['code'] . ' ' . $sql_error['message'];
		}

		if ( $sql_store != '' )
		{
			$debug_text .= "<br /><br />$sql_store";
		}

		if ( $err_line != '' && $err_file != '' )
		{
			$debug_text .= '</br /><br />Line : ' . $err_line . '<br />File : ' . $err_file;
		}
	}

	if( empty($userdata) && ( $msg_code == GENERAL_MESSAGE || $msg_code == GENERAL_ERROR ) )
	{
                $userdata = session_pagestart($user_ip, PAGE_INDEX, $nukeuser);
		init_userprefs($userdata);
	}

	//
	// If the header hasn't been output then do it
	//
	if ( !defined('HEADER_INC') && $msg_code != CRITICAL_ERROR )
	{
		if ( empty($lang) )
		{
			if ( !empty($board_config['default_lang']) )
			{
				include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.'.$phpEx);
			}
			else
			{
				include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);
			}
		}

		if ( empty($template) )
		{
                        $ThemeSel = get_theme();
                        if (file_exists("themes/$ThemeSel/forums/".$board_config['board_template']."/index_body.tpl")) {
                            $template = new Template("themes/$ThemeSel/forums/".$board_config['board_template']."");
                        } else {
                            $template = new Template($phpbb_root_path . 'templates/' . $board_config['board_template']);
                        }
		}
		if ( empty($theme) )
		{
			$theme = setup_style($board_config['default_style']);
		}

		//
		// Load the Page Header
		//
		if ( !defined('IN_ADMIN') )
		{
                        include("includes/page_header.php");
		}
		else
		{
			include($phpbb_root_path . 'admin/page_header_admin.'.$phpEx);
		}
	}

	switch($msg_code)
	{
		case GENERAL_MESSAGE:
			if ( $msg_title == '' )
			{
				$msg_title = $lang['Information'];
			}
			break;

		case CRITICAL_MESSAGE:
			if ( $msg_title == '' )
			{
				$msg_title = $lang['Critical_Information'];
			}
			break;

		case GENERAL_ERROR:
			if ( $msg_text == '' )
			{
				$msg_text = $lang['An_error_occured'];
			}

			if ( $msg_title == '' )
			{
				$msg_title = $lang['General_Error'];
			}
			break;

		case CRITICAL_ERROR:
			//
			// Critical errors mean we cannot rely on _ANY_ DB information being
			// available so we're going to dump out a simple echo'd statement
			//
			include($phpbb_root_path . 'language/lang_english/lang_main.'.$phpEx);

			if ( $msg_text == '' )
			{
				$msg_text = $lang['A_critical_error'];
			}

			if ( $msg_title == '' )
			{
				$msg_title = 'phpBB : <b>' . $lang['Critical_Error'] . '</b>';
			}
			break;
	}

	//
	// Add on DEBUG info if we've enabled debug mode and this is an error. This
	// prevents debug info being output for general messages should DEBUG be
	// set TRUE by accident (preventing confusion for the end user!)
	//
	if ( DEBUG && ( $msg_code == GENERAL_ERROR || $msg_code == CRITICAL_ERROR ) )
	{
		if ( $debug_text != '' )
		{
			$msg_text = $msg_text . '<br /><br /><b><u>DEBUG MODE</u></b>' . $debug_text;
		}
	}

	if ( $msg_code != CRITICAL_ERROR )
	{
		if ( !empty($lang[$msg_text]) )
		{
			$msg_text = $lang[$msg_text];
		}

		if ( !defined('IN_ADMIN') )
		{
			$template->set_filenames(array(
				'message_body' => 'message_body.tpl')
			);
		}
		else
		{
			$template->set_filenames(array(
				'message_body' => 'admin/admin_message_body.tpl')
			);
		}

		$template->assign_vars(array(
			'MESSAGE_TITLE' => $msg_title,
			'MESSAGE_TEXT' => $msg_text)
		);
		$template->pparse('message_body');

		if ( !defined('IN_ADMIN') )
		{
                        include("includes/page_tail.php");
		}
		else
		{
			include($phpbb_root_path . 'admin/page_footer_admin.'.$phpEx);
		}
	}
	else
	{
		echo "<html>\n<body>\n" . $msg_title . "\n<br /><br />\n" . $msg_text . "</body>\n</html>";
	}

	exit;
}

//
// This function is for compatibility with PHP 4.x's realpath()
// function.  In later versions of PHP, it needs to be called
// to do checks with some functions.  Older versions of PHP don't
// seem to need this, so we'll just return the original value.
// dougk_ff7 <October 5, 2002>
function phpbb_realpath($path)
{
	global $phpbb_root_path, $phpEx;

	return (!@function_exists('realpath') || !@realpath($phpbb_root_path . 'includes/functions.'.$phpEx)) ? $path : @realpath($path);
}

function redirect($url)
{
	global $db, $board_config;

	if (!empty($db))
	{
		$db->sql_close();
	}

	if (strstr(urldecode($url), "\n") || strstr(urldecode($url), "\r"))
	{
		message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.');
	}

	$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
	$server_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['server_name']));
	$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) : '';
	$script_name = preg_replace('#^\/?(.*?)\/?$#', '\1', trim($board_config['script_path']));
	$script_name = ($script_name == '') ? $script_name : '/' . $script_name;
	$url = preg_replace('#^\/?(.*?)\/?$#', '/\1', trim($url));

	// Redirect via an HTML form for PITA webservers
	if (@preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')))
	{
		header('Refresh: 0; URL=' . $server_protocol . $server_name . $server_port . $script_name . $url);
		echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="refresh" content="0; url=' . $server_protocol . $server_name . $server_port . $script_name . $url . '"><title>Redirect</title></head><body><div align="center">If your browser does not support meta redirection please click <a href="' . $server_protocol . $server_name . $server_port . $script_name . $url . '">HERE</a> to be redirected</div></body></html>';
		exit;
	}

	// Behave as per HTTP/1.1 spec for others
	header('Location: ' . $server_protocol . $server_name . $server_port . $script_name . $url);
	exit;
}
function bblogin($nukeuser, $session_id) {
        global $nukeuser, $userdata, $user_ip, $session_length, $session_id, $db, $nuke_file_path;
        define("IN_LOGIN", true);
        $cookie = explode(":", $nukeuser);
        $nuid = $cookie[0];
        $sql = "SELECT s.*
                FROM " . SESSIONS_TABLE . " s
                WHERE s.session_id = '$session_id'
                AND s.session_ip = '$user_ip'";
        if ( !($result = $db->sql_query($sql)) )
        {
                message_die(CRITICAL_ERROR, 'Error doing DB query userdata row fetch : session_pagestar');
        }
        $logindata = $db->sql_fetchrow($result);
        if( $nuid != $logindata['session_user_id'] ) {
            $nusername = $cookie[1];
            $sql = "SELECT user_id, username, user_password, user_active, user_level
                    FROM ".USERS_TABLE."
                    WHERE username = '" . str_replace("\'", "''", $nusername) . "'";
            $result = $db->sql_query($sql);
            if(!$result) {
                message_die(GENERAL_ERROR, "Error in obtaining userdata : login", "", __LINE__, __FILE__, $sql);
            }
            $rowresult = $db->sql_fetchrow($result);
            $password = $cookie[2];
            if(count($rowresult) ) {
                if( $rowresult['user_level'] != ADMIN && $board_config['board_disable'] ) {
                    header("Location: " . append_sid("index.php", true));
                } else {
                    if( $password == $rowresult['user_password'] && $rowresult['user_active'] ) {
                        $autologin = 0;
                        $userdata = session_begin($rowresult['user_id'], $user_ip, PAGE_INDEX, $session_length, FALSE, $autologin);
                        $session_id = $userdata['session_id'];
                        if(!$session_id ) {
                            message_die(CRITICAL_ERROR, "Couldn't start session : login", "", __LINE__, __FILE__);
                        } else {
                        }
                    } else {
                        $message = $lang['Error_login'] . "<br /><br />" . sprintf($lang['Click_return_login'], "<a href=\"" . append_sid("modules.php?name=Forums&file=login&$redirect") . "\">", "</a> ") . "<br /><br />" .  sprintf($lang['Click_return_index'], "<a href=\"" . append_sid("index.php") . "\">", "</a> ");
                        message_die(GENERAL_MESSAGE, $message);
                    }
                }
            } else {
                $message = $lang['Error_login'] . "<br /><br />" . sprintf($lang['Click_return_login'], "<a href=\"" . append_sid("modules.php?name=Forums&file=login&$redirect") . "\">", "</a> ") . "<br /><br />" .  sprintf($lang['Click_return_index'], "<a href=\"" . append_sid("index.php") . "\">", "</a> ");
                message_die(GENERAL_MESSAGE, $message);
            }
        }

}
?>
I haven't even checked the other files or looked to see if the inserts worked yet.

User avatar
ChriZathens
Registered User
Posts: 1477
Joined: Tue Apr 18, 2006 9:11 pm
Location: Athens, Greece
Name: Chris

Re: Add Homepage link in header

Post by ChriZathens » Sat Sep 12, 2009 3:38 pm

This functions.php file is not the phpbb3 /includes/functions.php file...
I would say that this file is from a version 2.x.x of phpbb. What are you trying to do? Install a phpbb3 mod in a phpbb2 version? :?
Are you sure you are using phpbb 3.0.5 ? Have you done a conversion to phpbb3 and still have perhaps left your phpbb2 version forum in your server, too, and by accident opened those files?
As of Automod, this mod is tested and works fine (all validated phpbb3 mods do - it is a requirement, otherwise they don't get validated). In order for Automod to install it, you need to place the mod's folder in your /store folder in your phpbb3 directory on your server.
Post if you need further assistance...
My mods in MODDB:
Add Homepage link in header - Change user activity post limit - Post number in viewtopic
If you need support click on the support tab there and post your question.
Do not PM me - chances of viewing my PMs are way thinner than viewing the support question in the customization DB...

extramsg
Registered User
Posts: 7
Joined: Tue Jan 18, 2005 5:31 am

Re: Add Homepage link in header

Post by extramsg » Sun Sep 13, 2009 9:18 pm

Looks like a symbolic link was pointing to the old version. Woops.

However, the automod install did occur as I explained with the odd download that didn't include any of the recreated files.

Is there something I need to do when I do the manual edits to be able to "uninstall" at some point if I wish?

Locked

Return to “[3.0.x] MOD Database Releases”