Whether you're using
sebflipper's MF script or
amfr service's MF script, here is a basic way to allow your forum users to have their own custom logo/banners on their phpBB forums.
PLEASE NOTE THAT I DO NOT MAKE ANY GUARANTEES THAT THIS WILL WORK FOR ANYONE, AND YOU SHOULD USE THIS AS-IS AND AT YOUR OWN RISK.
This mod replaces the site_description with a URL to the image, and checks to make sure the file being linked to is an image.
Features
- Displays just the image URL on the configuration page to help prevent any malicious HTML from being entered.
- Checks the URL input and removes bad commands like cmd, wget, ?exe, and anything else you define.
- It will also check the initial http for common mistypings such as htp httpp, and so on, and replace it with http
-Checks to see if the custom URL field is left blank and if so, will use the site name as the header
- Uses a small javascript to ensure something is entered in the site name field for the above reason
Files to edit
admin/admin_board.php
languages/*/lang_admin.php
templates/*/admin/board_config_body.tpl
templates/*/overall_header.tpl
OPEN admin/admin_board.php
find (around line 56):
PHP Code:
if ($config_name == 'cookie_name')
{
$cookie_name = str_replace('.', '_', $new['cookie_name']);
}
if( isset($HTTP_POST_VARS['submit']) )
{
add after:
PHP Code:
//Custom Header URL //
if (preg_match("/.png|.gif|.jpg|.jpeg/i", $HTTP_POST_VARS['site_desc'])) {
$badboy = array("cmd=", "wget", "exe", ".exe", "?cmd=", "?wget", "?wget=", "?");
$safeurl = str_replace($badboy, '', $HTTP_POST_VARS['site_desc']);
$httpchk = array("htp", "httpp", "htttp", "hhttpp", "htpp");
$goodurl = str_replace($httpchk, 'http', $safeurl);
$new['site_desc'] = '<img src='.$goodurl.'>';
} elseif ($HTTP_POST_VARS['site_desc'] == '') {
$new['site_desc'] = $HTTP_POST_VARS['sitename'];
} else {
echo '<b>Header Images should be in PNG, GIF, or JPG format.</b><br><br>Please press the back button to correct';
exit;
}
//Custom Header URL End
find (around line 156):
PHP Code:
//
// Escape any quotes in the site description for proper display in the text
// box on the admin page
//
$new['site_desc'] = str_replace('"', '"', $new['site_desc']);
add after:
PHP Code:
//Custom Header URL //
$new['site_desc'] = str_replace('<img src=', '', $new['site_desc']);
$new['site_desc'] = str_replace('>','', $new['site_desc']);
//Custom Header URL End
SAVE admin_board.php
OPEN languages/*/lang_admin.php
find
PHP Code:
$lang['Site_desc'] = 'Site description';
replace with
PHP Code:
$lang['Site_desc'] = 'Custom Header Image URL';
You will need to do this for each lang_admin.php file you have in your languages/ folder.
OPEN templates/admin/*/board_config_body.tpl
At the top of the file, paste the following javascript
:
Code:
<script language="JavaScript" type="text/javascript">
<!--
function checkform ( form )
{
// ** START **
if (form.sitename.value == "") {
alert( "Please Enter a Name For Your Board!" );
form.sitename.focus();
return false ;
}
// ** END **
return true ;
}
//-->
</script>
find
PHP Code:
<form action="{S_CONFIG_ACTION}" method="post">
replace with
PHP Code:
<form action="{S_CONFIG_ACTION}" method="post" onsubmit="return checkform(this);">
SAVE board_config_body.tpl
You will need to do this for each board_config_body.tpl. I personally have implemented a hack that uses just the subSilver templates for the admin area, and a quick and easy hack for that can be found here.
OPEN templates/*/overall_header.tpl
Edit the HTML to suit your user's needs. In subSilver, for example, I removed the default phpBB logo and removed the first column to allow for headers that could comfortably stretch across the screen without ruining the board layout.
You will need to do this for each overall_header in the templates/ folder.
Upload all files and test it out!
This is my first attempt at something like this, so if any of the PHP experts can find ways to improve on it, please feel free. I'm hoping at some point to figure out how to enable users to upload their own header images instead of remotely linking, but for now this will do the job for me.
Also, I am not a representative of either SebFlipper or AMFR Services. This is something I wrote that I thought those running MF sites could use.
