Author |
Message |
DakotaSurfer Board Member
Joined: 07 May 2012
Posts: 6
|
Posted: Mon May 07, 2012 11:02 am Post subject: admin panel error |
|
|
Recently our server told us they were removing all past version of PHP up to the current version of PHP 5.3.10 After changing over to the newest version I came across an error in my phpBB2 Admin Panel under the "User Admin" Section are called "Disallowed Names". This is the error message I receive: (all previously stated disallowed names are gone)
Warning: trim() expects parameter 1 to be string, array given in /nfs/c05/h01/mnt/19433/domains/xxxxxxxxx.com/html/board/admin/admin_disallow.php on line 107
When I bring up the file admin_disallow.php shown below, this is line 107 and the info following it:
Line 107: if( trim($disallowed) == "" )
Code: | <?php
/***************************************************************************
* admin_disallow.php
* -------------------
* begin : Tuesday, Oct 05, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: admin_disallow.php,v 1.9.2.4 2005/12/18 13:57:50 grahamje 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.
*
***************************************************************************/
define('IN_PHPBB', 1);
if( !empty($setmodules) )
{
$filename = basename(__FILE__);
$module['Users']['Disallow'] = $filename;
return;
}
//
// Include required files, get $phpEx and check permissions
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
if( isset($HTTP_POST_VARS['add_name']) )
{
include($phpbb_root_path . 'includes/functions_validate.'.$phpEx);
$disallowed_user = ( isset($HTTP_POST_VARS['disallowed_user']) ) ? trim($HTTP_POST_VARS['disallowed_user']) : trim($HTTP_GET_VARS['disallowed_user']);
if ($disallowed_user == '')
{
message_die(GENERAL_MESSAGE, $lang['Fields_empty']);
}
if( !validate_username($disallowed_user) )
{
$message = $lang['Disallowed_already'];
}
else
{
$sql = "INSERT INTO " . DISALLOW_TABLE . " (disallow_username)
VALUES('" . str_replace("\'", "''", $disallowed_user) . "')";
$result = $db->sql_query( $sql );
if ( !$result )
{
message_die(GENERAL_ERROR, "Could not add disallowed user.", "",__LINE__, __FILE__, $sql);
}
$message = $lang['Disallow_successful'];
}
$message .= "<br /><br />" . sprintf($lang['Click_return_disallowadmin'], "<a href=\"" . append_sid("admin_disallow.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
message_die(GENERAL_MESSAGE, $message);
}
else if( isset($HTTP_POST_VARS['delete_name']) )
{
$disallowed_id = ( isset($HTTP_POST_VARS['disallowed_id']) ) ? intval( $HTTP_POST_VARS['disallowed_id'] ) : intval( $HTTP_GET_VARS['disallowed_id'] );
$sql = "DELETE FROM " . DISALLOW_TABLE . "
WHERE disallow_id = $disallowed_id";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't removed disallowed user.", "",__LINE__, __FILE__, $sql);
}
$message .= $lang['Disallowed_deleted'] . "<br /><br />" . sprintf($lang['Click_return_disallowadmin'], "<a href=\"" . append_sid("admin_disallow.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
message_die(GENERAL_MESSAGE, $message);
}
//
// Grab the current list of disallowed usernames...
//
$sql = "SELECT *
FROM " . DISALLOW_TABLE;
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't get disallowed users.", "", __LINE__, __FILE__, $sql );
}
$disallowed = $db->sql_fetchrowset($result);
//
// Ok now generate the info for the template, which will be put out no matter
// what mode we are in.
//
$disallow_select = '<select name="disallowed_id">';
if( trim($disallowed) == "" )
{
$disallow_select .= '<option value="">' . $lang['no_disallowed'] . '</option>';
}
else
{
$user = array();
for( $i = 0; $i < count($disallowed); $i++ )
{
$disallow_select .= '<option value="' . $disallowed[$i]['disallow_id'] . '">' . $disallowed[$i]['disallow_username'] . '</option>';
}
}
$disallow_select .= '</select>';
$template->set_filenames(array(
"body" => "admin/disallow_body.tpl")
);
$template->assign_vars(array(
"S_DISALLOW_SELECT" => $disallow_select,
"S_FORM_ACTION" => append_sid("admin_disallow.$phpEx"),
"L_INFO" => $output_info,
"L_DISALLOW_TITLE" => $lang['Disallow_control'],
"L_DISALLOW_EXPLAIN" => $lang['Disallow_explain'],
"L_DELETE" => $lang['Delete_disallow'],
"L_DELETE_DISALLOW" => $lang['Delete_disallow_title'],
"L_DELETE_EXPLAIN" => $lang['Delete_disallow_explain'],
"L_ADD" => $lang['Add_disallow'],
"L_ADD_DISALLOW" => $lang['Add_disallow_title'],
"L_ADD_EXPLAIN" => $lang['Add_disallow_explain'],
"L_USERNAME" => $lang['Username'])
);
$template->pparse("body");
include('./page_footer_admin.'.$phpEx);
?> |
Is there a way to fix this or am I just going to lose disallowed names? What happened in PHP 5.3.10 that screwed this up? It still worked in PHP 5.2.17 so any help would be appreciated.
DS |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Mon May 07, 2012 12:51 pm Post subject: Re: admin panel error |
|
|
I found this function in the PHP manual:
Code: | function trimArray($array){
$newArr = array();
$data = each($array);
while( $data ){
$key = $data['key'];
$value = $data['value'];
if( is_array($value) ){
$value = trimArray($value);
}else{
$value = trim($value);
}
$newArr[$key] = $value;
$data = each($array);
}
return $newArr;
} |
You could try putting it right before line 107 (preferably with a comment to point out the change) and replace
if( trim($disallowed) == "" )
with
if( trimArray($disallowed) == "" )
I'm not entirely sure it will work, but it seems to be achieving the same result. I'm just not sure why they trim and compare an array with "" to begin with, to be honest. |
|
Back to top |
|
|
DakotaSurfer Board Member
Joined: 07 May 2012
Posts: 6
|
Posted: Mon May 07, 2012 1:43 pm Post subject: Re: admin panel error |
|
|
Thanks, I'll try that and see what happens. I've been PO'd since they dumped support for us lowly phpBB2 users and now my server wants to dump PHP4 so now that gets to mess with my forum. What next?
EDIT: Give that man a cupie doll... it worked, the Disallow Names still works and no error message with the current version of PHP.
I've been out of this way to long. Now I need to find command lines for SSH. Yuck! |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Mon May 07, 2012 8:19 pm Post subject: Re: admin panel error |
|
|
I'm afraid I can't help you with that. Glad to hear this worked, though. Let us know if anything else needs to be fixed, you might not be the last person to need it |
|
Back to top |
|
|
DakotaSurfer Board Member
Joined: 07 May 2012
Posts: 6
|
Posted: Mon May 07, 2012 10:02 pm Post subject: Re: admin panel error |
|
|
What am I the last of the refugees? I'm being abandoned again??? I've seen other forums that are still using phpBB2. They might just be living with the problems. |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Tue May 08, 2012 11:44 am Post subject: Re: admin panel error |
|
|
No, I meant you're the first person to point out the problem, but if it stems from a PHP update we're all bound to go through it. |
|
Back to top |
|
|
DakotaSurfer Board Member
Joined: 07 May 2012
Posts: 6
|
Posted: Tue May 08, 2012 2:01 pm Post subject: Re: admin panel error |
|
|
Misunderstood... yeah, you're right and the funny thing is I had left the forum using PHP4 for ages until this notice I received from my ISP. If they'd leave PHP 5.2.17 I'd be okay it's just when I went to PHP 5.3.10 when I received the error message. I have a lot of mods installed too but this was the only thing so far to trigger an error. |
|
Back to top |
|
|
Jim_UK Board Member
Joined: 19 Nov 2008
Posts: 656 Location: North West UK
|
Posted: Thu May 10, 2012 9:11 am Post subject: Re: admin panel error |
|
|
Made a note of the fix ready for when it happens. Sometimes an "upgrade" of PHP causes the Admin CP not to load. If that is the case it can be a long job removing all the mod files to discover which mod has caused the problem.
Should it happen to anyone then they should remove the Admin CP files and replace them with the standard install ones. Then replace the mod files until the Admin CP fails to load. That will identify the file at fault. Whether it can be edited to make it work is another problem.
I had a spell checker that caused this problem and my only course of action was to disable the mod.
Jim |
|
Back to top |
|
|
nars Board Member
Joined: 17 Jun 2012
Posts: 1
|
Posted: Sun Jun 17, 2012 11:02 pm Post subject: Re: admin panel error |
|
|
Noticed same error (and no disallowed usernames being listed...) after moving an old forum to a php5 server... anyway, as Salvatos also said, can't see why trim an array and compare with ""... :S makes no sense to me... I did ended changing it to if( count($disallowed) == 0 ) then it prints the $lang['No_disallowed'] text as an option when no disallowed usernames on db... another mistake is the $lang['no_disallowed'] should be in fact $lang['No_disallowed'] |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Mon Jun 18, 2012 9:40 am Post subject: Re: admin panel error |
|
|
We just upgraded to php 5.3 but I haven't tested much of the admin stuff yet. I did get a "depreciated" notice on a couple of pages that use the split() command. php.net suggests replacing split() with either preg_split() or if pattern matching is not required the more basic explode() command instead. The search program (search.php) had a couple of occurrences of the split() command, at least in my modified version. I have not checked the standard phpBB2 search code to see if it's there or not. _________________ phpBBDoctor Blog |
|
Back to top |
|
|
Dog Cow Board Member
Joined: 18 Nov 2008
Posts: 378
|
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Thu Jun 21, 2012 4:22 pm Post subject: Re: admin panel error |
|
|
Good to know.
It seems to be an easy fix, as the explode() function takes the same arguments and apparently has not been depreciated and works exactly the same way. _________________ phpBBDoctor Blog |
|
Back to top |
|
|
dondino Board Member
Joined: 09 Dec 2008
Posts: 144
|
Posted: Fri Jun 22, 2012 5:06 pm Post subject: Re: admin panel error |
|
|
what about mysql?
is anyone using already mysql 5.5 without problems with phpbb2 forum system?
i'm actually using 5.0 without problems, but I am scared to even attempt an upgrade |
|
Back to top |
|
|
drathbun Board Member
Joined: 24 Jul 2008
Posts: 729 Location: Texas
|
Posted: Sat Jun 23, 2012 4:22 pm Post subject: Re: admin panel error |
|
|
Upgrading MySQL was the reason I upgraded php; it came as a package. MySQL 5.0 has a fairly severe password vulnerability, so anyone on 5.0 - especially if your database is exposed to external logins - should update immediately. That being said, we only updated to 5.1 rather than all the way to 5.5 on this last round. _________________ phpBBDoctor Blog |
|
Back to top |
|
|
dondino Board Member
Joined: 09 Dec 2008
Posts: 144
|
Posted: Mon Jun 25, 2012 4:42 pm Post subject: Re: admin panel error |
|
|
drathbun wrote: | Upgrading MySQL was the reason I upgraded php; it came as a package. MySQL 5.0 has a fairly severe password vulnerability, so anyone on 5.0 - especially if your database is exposed to external logins - should update immediately. That being said, we only updated to 5.1 rather than all the way to 5.5 on this last round. |
Thanks drathbun,
I have upgraded mySQL to version 5.1.63 and I didn't notice any problem so far after the auto conversion
it seems to me that the board loads even a little faster than before |
|
Back to top |
|
|
|