Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Another error

  1. #1
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Another error

    I'm getting the following error in my error logs

    Undefined variable: username in xxx on line 106

    Line 106 shows

    $ret = $user->create($username);

    What I am trying to do is ldap software called Gallery2. There seem to be many attempts to try and do this. Sadly most suggestions do not work for me. I've got to the stage where I try and login and I get a database error - "An error has occurred while interacting with the database"

    I assume this error will be down to the error highlighted in line 106? That is the only error I am getting in my error logs. The full code for this is at http://codex.gallery2.org/LDAP_authentication under Gallery 2.3 if you need to see how this code works.

    Thank you for your help,

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Looks like the creator of that script made the classic mistake of assuming register_globals would be turned on. You may be able to correct the error by replacing $username with $_POST['username'], but to complicate matters, in other functions the programmer uses the variable $username within different scopes so you have to be careful not to change EVERY occurance of $username.

    Bad naming practices imo. Register_globals is so 2004. Biggest mistake of PHP's life.

  • #3
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    So if it is being caused by register_globals being turned off, then would turning it on fix the problem? I've just read somewhere that you can turn it on using a .htaccess file. Though it does say it's a security risk so maybe not...

    I suppose its always going to be a problem using other peoples code. Everyone seems to tackle the problem a different way. I did think about writing it from scratch, but I'm not really any good with php.

    Anyway thanks for your help, I shall have a go at changing the code.

    Edit: So the line should now read

    $ret = $user->create ($_POST['username']);

    Correct?
    Last edited by Silverflames; 10-14-2009 at 10:54 PM.

  • #4
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    When I change it to this

    $ret = $user->create ($_POST['username']);


    I get

    Notice: Undefined index: username in /var/www/html/techservices/modules/core/UserLogin.inc on line 106


  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by Fumigator View Post
    Looks like the creator of that script made the classic mistake of assuming register_globals would be turned on. You may be able to correct the error by replacing $username with $_POST['username'], but to complicate matters, in other functions the programmer uses the variable $username within different scopes so you have to be careful not to change EVERY occurance of $username.

    Bad naming practices imo. Register_globals is so 2004. Biggest mistake of PHP's life.
    Close, its 2002 when 4.2 was release

    Where are you expecting that $username is being set? The problem is simple, its just that there is no $username (and in this example, $_POST['username'] too) set. The solution will be more difficult to determine since it will be dependent entirely on what you have and what you're doing.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    New to the CF scene
    Join Date
    Oct 2009
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Im not entirely sure. Where would it need to be set in the file?

    The person who modified the original code only added in the ldap authentication, you can see where it begins and ends in the file. Outside of that is the original code from the developers.

    Am i meant to be using isset or putting $username=$POST['username']

    Or am I talking rubbish?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •