LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   need help with fixing php script (http://www.linuxquestions.org/questions/programming-9/need-help-with-fixing-php-script-614060/)

frieza 01-16-2008 02:22 PM

need help with fixing php script
 
here is a script that is part of a mod for phpbb2
http://hoppernet.newsit.es/fixme.zip
it is broken somehow i think or pehaps just not php5 compliant causing the phpbb admin panel to break when it attempts to load
if someone can fix and post a fixed copy or tell me how to fix it (by posting a, find 'section of code' replace with 'new code' type of deal)
any help would be appreciated
edit: the full version of the mod is here
http://hoppernet.newsit.es/pafiledb_mod_2.0.1.zip

duryodhan 01-17-2008 11:05 PM

show the error and show the code .. I am not downloading some random zip file that you point out (no offense)

frieza 01-18-2008 02:13 PM

kk sorry
the file is the pafiledb mod for phpBB2
after a little research (the most recent information is still about 4 years old so there might be a fix for it somewhere but understandably alot of links given are broken)
the problem is apparantly one of the functions in the file admin_pa_ug_auth.php
Code:

//function admin_display_cat_auth( $cat_parent = 0, $depth = 0 )

{
        global $pafiledb, $phpbb_root_path, $pafiledb_template, $phpEx;
        global $cat_auth_fields, $optionlist_mod, $optionlist_acl_adv;
        $pre = str_repeat( '        ', $depth );
        if ( isset( $pafiledb->subcat_rowset[$cat_parent] ) )
        {
                foreach( $pafiledb->subcat_rowset[$cat_parent] as $sub_cat_id => $cat_data )
                {
                        $pafiledb_template->assign_block_vars( 'cat_row', array( 'CAT_NAME' => $cat_data['cat_name'],
                                        'IS_HIGHER_CAT' => ( $cat_data['cat_allow_file'] ) ? false : true,
                                        'PRE' => $pre,

                                        'U_CAT' => append_sid( "admin_pa_catauth.$phpEx?cat_id=$sub_cat_id" ),

                                        'S_MOD_SELECT' => $optionlist_mod[$sub_cat_id] )
                                );

                        for( $j = 0; $j < count( $cat_auth_fields ); $j++ )
                        {
                                $pafiledb_template->assign_block_vars( 'cat_row.aclvalues', array( 'S_ACL_SELECT' => $optionlist_acl_adv[$sub_cat_id][$j] )
                                        );
                        }
                        admin_display_cat_auth( $sub_cat_id, $depth + 1 );
                }
                return;
        }
        return;
}

is a double declaration of
Code:

function admin_display_cat_auth( $cat_parent = 0, $depth = 0 )
{
        global $pafiledb, $phpbb_root_path, $pafiledb_template, $phpEx;
        global $cat_auth_fields, $cat_auth_const, $cat_auth_levels, $lang;
        $pre = str_repeat( '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;', $depth );
        if ( isset( $pafiledb->subcat_rowset[$cat_parent] ) )
        {
                foreach( $pafiledb->subcat_rowset[$cat_parent] as $sub_cat_id => $cat_data )
                {
                        $pafiledb_template->assign_block_vars( 'cat_row', array( 'CATEGORY_NAME' => $cat_data['cat_name'],
                                        'IS_HIGHER_CAT' => ( $cat_data['cat_allow_file'] ) ? false : true,
                                        'PRE' => $pre,
                                        'U_CAT' => append_sid( "admin_pa_catauth.$phpEx?cat_parent=$sub_cat_id" ) )
                                );

                        for( $j = 0; $j < count( $cat_auth_fields ); $j++ )
                        {
                                $custom_auth[$j] = '&nbsp;<select name="' . $cat_auth_fields[$j] . '[' . $sub_cat_id . ']' . '">';

                                for( $k = 0; $k < count( $cat_auth_levels ); $k++ )
                                {
                                        $selected = ( $cat_data[$cat_auth_fields[$j]] == $cat_auth_const[$k] ) ? ' selected="selected"' : '';
                                        $custom_auth[$j] .= '<option value="' . $cat_auth_const[$k] . '"' . $selected . '>' . $lang['Category_' . $cat_auth_levels[$k]] . '</option>';
                                }
                                $custom_auth[$j] .= '</select>&nbsp;';

                                $pafiledb_template->assign_block_vars( 'cat_row.cat_auth_data', array( 'S_AUTH_LEVELS_SELECT' => $custom_auth[$j] )
                                        );
                        }
                        admin_display_cat_auth( $sub_cat_id, $depth + 1 );
                }
                return;
        }
        return;
}

but they arent the same code
commenting out the function allows MOST of the program to work
the question i think is how to get the function to work without making too much change to the code.
there is no error message
the left pane of the admin cp simply fails to load
like this
http://hoppernet.newsit.es/broken.html

frieza 01-27-2008 06:15 PM

nvm i fixed it
here's how
Code:

[open]
admin/admin_pa_catauth.php
[find]
function admin_display_cat_auth
[replace x3]
function admin_pa_display_cat_auth
[open]
admin/admin_pa_ug_auth.php
[find]
function admin_display_cat_auth
[replace x3]
function admin_ug_display_cat_auth
[save and close files]



All times are GMT -5. The time now is 01:27 AM.