PHP Fatal Error Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blackbox2342
Forum Newbie
Posts: 5
Joined: Thu Jun 04, 2009 2:48 pm

PHP Fatal Error Help

Post by blackbox2342 »

This is the error I'm getting

Code: Select all

 
Fatal error: Cannot redeclare get_userdatabylogin() (previously declared in /home/content/07/4395607/html/wp-includes/pluggable.php:166) in /home/content/07/4395607/html/wp-content/plugins/functions_vbbridge.php on line 33
from this:

Code: Select all

<?php
 
function get_userdatabylogin($user_login) {
    global $wpdb, $vbulletin;
    $user_login = sanitize_user( $user_login );
 
    if ( empty( $user_login ) )
        return false;
 
    $user_id = wp_cache_get($user_login, 'userlogins');
 
    $user = false;
    if ( false !== $user_id )
        $user = wp_cache_get($user_id, 'users');
 
    if ( false !== $user )
        return $user;
 
    if ( !$user_a = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string($user_login) . "'") )
        return false;
    foreach ($user_a as $key => $value) {
 
        $user->$key = $value;
 
    }
 
    $user->user_login = $user->username;
    
    
    # _fill_user($user);
 
    return $user;
}
 
 
function wp_authenticate($username, $password) {
    $username = sanitize_user($username);
 
    if ( '' == $username )
        return new WP_Error('empty_username', __('<strong>ERROR</strong>: The username field is empty.'));
 
    if ( '' == $password )
        return new WP_Error('empty_password', __('<strong>ERROR</strong>: The password field is empty.'));
 
    $user = get_userdatabylogin($username);
 
 
    if ( !$user || (strtolower($user->user_login) != strtolower($username)) ) {
        do_action( 'wp_login_failed', $username );
        return new WP_Error('invalid_username', __('<strong>ERROR</strong>: Invalid username.'));
    }
 
    $user = apply_filters('wp_authenticate_user', $user, $password);
    if ( is_wp_error($user) ) {
        do_action( 'wp_login_failed', $username );
        return $user;
    }
 
    if ( !wp_check_password($password, $user->user_login) ) {
        do_action( 'wp_login_failed', $username );
        return new WP_Error('incorrect_password', __('<strong>ERROR</strong>: Incorrect password.'));
    }
 
    return new WP_User($user->ID);
}
 
 
function wp_check_password($password, $user_name = '') {
    global $vbulletin;
    require_once(DIR . '/includes/functions_login.php');
    
    return verify_authentication($user_name,$password,'','',true,true);
 
    
}
 
function wp_validate_auth_cookie($cookie = '', $scheme = '') {
 
    global $vbulletin;
 
    return $vbulletin->userinfo['userid'];
 
}
 
function wp_set_current_user($id, $name = '') {
    global $current_user;
 
    if ( isset($current_user) && ($id == $current_user->ID) )
        return $current_user;
 
    $current_user = new WP_User($id, $name);
 
    setup_userdata($current_user->ID);
 
    do_action('set_current_user');
 
    return $current_user;
}
 
 
function get_userdata( $user_id ) {
    global $wpdb, $vbulletin;
 
    $user_id = absint($user_id);
    if ( $user_id == 0 )
        return false;
 
    $user = wp_cache_get($user_id, 'users');
 
    if ( $user )
        return $user;
 
    if ( !$user_a = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = '" . $vbulletin->db->escape_string($user_id) . "'") )
        return false;
    foreach ($user_a as $key => $value) {
 
        $user->$key = $value;
 
    }
 
    $user->user_login = $user->username;
 
    $user->wp_capabilities = array(strtolower(get_option('vbb_vbugroup_' . $vbulletin->userinfo[usergroupid])) => 1);
 
    $user->rich_editing = true;
 
    $user->ID = $user->userid;
 
    $user->display_name = $user->username;
 
    $user->user_nicename = sanitize_title($user->username);
 
    # _fill_user($user);
 
    return $user;
}
 
function auth_redirect() {
 
    global $vbulletin;
 
    if ($vbulletin->userinfo['userid'] <= 0) { 
 
        $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( $redirect ), 'login' );
 
        wp_redirect($login_url);
        
        exit;
    }
 
    return;
 
}
 
function check_admin_referer($action = -1, $query_arg = '_wpnonce') {
    global $vbulletin;
 
    if ($vbulletin->userinfo['userid'] <= 0) { 
 
        $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( $redirect ), 'login' );
 
        wp_redirect($login_url);
        
        exit;
    }
 
    return;
 
}
 
add_filter('user_has_cap', 'ff_give_user', 10, 3);
 
function ff_give_user($stuff, $caps, $a)
{
 
    global $vbulletin,$wp_roles,$wpdb;
 
    $role_key = $wpdb->prefix . 'user_roles';
 
    $roles = get_option( $role_key );
 
    $group = strtolower(get_option('vbb_vbugroup_' . $vbulletin->userinfo[usergroupid]));
 
    $stuff = $roles[$group]['capabilities'];
 
    return $stuff;
 
 
}
?>
Can anyone see what could be causing the problem because I'm really stuck with this!

Thanks in advance for your help.

What it is a bridge between vbulletin and wordpress and I'm trying to use the resetvbbridge.php file to clear the settings so I can re-enter them. (I reconfigured Vbulletin and forgot that the db's were linked and now the plugin refuses to work).

I just need to clear the settings so I can get the plug-in reconfigured to work.

This is the code designed to clear the settings:

Code: Select all

<?php
require_once( dirname(__FILE__) . '/wp-load.php' );
 
    update_option('vbb_VBION, 0);
 
echo "Vbbridge integration disabled!";
 
 
 
?>
blackbox2342
Forum Newbie
Posts: 5
Joined: Thu Jun 04, 2009 2:48 pm

Re: PHP Fatal Error Help

Post by blackbox2342 »

here is the plugabble.php it mentions
Attachments
pluggable.zip
Pluggable.php
(14.68 KiB) Downloaded 24 times
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Fatal Error Help

Post by mikemike »

Well the function is being declared twice, hence the error. This probably isn't caused by you having two functions called the same, rather the same file being included twice.

It's quite easy to test which, comment out the function out of the file but leave the other functions in there, then try again. If you get the same error but with a different funciton being redeclared then you know you're including the file twice.
blackbox2342
Forum Newbie
Posts: 5
Joined: Thu Jun 04, 2009 2:48 pm

Re: PHP Fatal Error Help

Post by blackbox2342 »

mikemike wrote:Well the function is being declared twice, hence the error. This probably isn't caused by you having two functions called the same, rather the same file being included twice.

It's quite easy to test which, comment out the function out of the file but leave the other functions in there, then try again. If you get the same error but with a different funciton being redeclared then you know you're including the file twice.
Right I commented out line 32/33

Code: Select all

#  return $user;
# }
Am I right in doing that?

in my php plugin and I'm getting these fresh errors but line 188 doesn't exsist!

Code: Select all

Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/content/07/4395607/html/resetvbbridge.php on line 4
 
Parse error: syntax error, unexpected $end in /home/content/07/4395607/html/wp-content/plugins/functions_vbbridge.php on line 188
Any ideas for how to fix this?

Also the plugin worked until I moved my forum directory so I tried moving the forum directory back but the error message remained.
Last edited by blackbox2342 on Thu Jun 04, 2009 3:44 pm, edited 1 time in total.
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Fatal Error Help

Post by mikemike »

No... you need to comment out the whole of the function, not jsut the last two lines...

You're getting that error because the script goes to the end looking for the brace you've just commented out
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Fatal Error Help

Post by mikemike »

And can you keep posts to the forum and not private message me a copy of every reply please. It's just going to annoy people doing that and then you'll never get a reply.
blackbox2342
Forum Newbie
Posts: 5
Joined: Thu Jun 04, 2009 2:48 pm

Re: PHP Fatal Error Help

Post by blackbox2342 »

mikemike wrote:No... you need to comment out the whole of the function, not jsut the last two lines...

You're getting that error because the script goes to the end looking for the brace you've just commented out
sorry I'm new to php as you can tell, so what line numbers am I looking to remove?
blackbox2342
Forum Newbie
Posts: 5
Joined: Thu Jun 04, 2009 2:48 pm

Re: PHP Fatal Error Help

Post by blackbox2342 »

mikemike wrote:And can you keep posts to the forum and not private message me a copy of every reply please. It's just going to annoy people doing that and then you'll never get a reply.
sorry, won't do that again, I'm just really confused with this, would I be right in saying I need to remove lines 3-33?

Right have commented out the whole function and it seems you're correct!

Code: Select all

Fatal error: Cannot redeclare wp_authenticate() (previously declared in /home/content/07/4395607/html/wp-includes/pluggable.php:438) in /home/content/07/4395607/html/wp-content/plugins/functions_vbbridge.php on line 34
I got I reparsed some stuff and it worked! so going to try redefine my variables : )

thank you for your help!
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: PHP Fatal Error Help

Post by mikemike »

The whole function. Lines 3-33
Post Reply