The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WHM - php error handling of remote access functions

Discussion in 'General Discussion' started by jimcarter, Jul 26, 2002.

  1. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    Hi,
    Im trying to make a PHP script to create user accounts as soon as their payment has been authorized with paypal,
    it works fine at the moment, but there is no way to check if there has been any errors creating the account, like if the username has been taken,
    is there anyway to echo an error if a problem occurs when creating accounts?
    thanks
     
  2. jsteel

    jsteel Well-Known Member

    Joined:
    Jul 4, 2002
    Messages:
    646
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Atlanta, GA
    just echo out the variable you assigned to the createacct function. Here's an example.

    ------------
    $mycreateaccount = createacct($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);

    echo $mycreateaccount;
    ------------

    If it errors out, the first four characters returned are 'Ouch', if it successful, the first four characters are 'WWWA' (without the quotes in both cases).

    I simply trap an error condition only and assume successful otherwise.
     
  3. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    thanks,
    ive managed to do full error checking now though with a few functions
     
  4. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    someone asked me on the forum how I do my error checking when creating accounts through PHP,
    this might not be the best way to do it, but it works fine for me:

    $length = strlen($acctuser);
    if ($length&8){ echo &your username is longer than 8 characters, please change it!&; die; }
    else {
    if (is_dir(&/home/$acctuser&)){ echo &username taken, please try again&; die; }

    im not sure what other errors you can have when creating accounts, I have not yet come across any,
    im going to put all of my scripts for download sometime soon when I have added a few extra features, the only problem is that because I dont have 2checkout or authorize.net accounts i cannot test payment gateways with the script, except with paypal which works fine
     
  5. TheVoice

    TheVoice Well-Known Member

    Joined:
    Feb 7, 2002
    Messages:
    105
    Likes Received:
    0
    Trophy Points:
    16
    usernames with numbers arn't allowed anymore
     
  6. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    oh right, didnt know that one :p

    if (eregi(&[0-9]&, $acctuser)){
    echo &usernames with numbers arent allowed anymore!&;
    }
     
  7. jsteel

    jsteel Well-Known Member

    Joined:
    Jul 4, 2002
    Messages:
    646
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Atlanta, GA
    I have a number of users with numbers in their username. No problems at all.

    Jaz
     
  8. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    [quote:9d0fcf2de1][i:9d0fcf2de1]Originally posted by jimcarter[/i:9d0fcf2de1]
    if (is_dir(&/home/$acctuser&)){ echo &username taken, please try again&; die; }
    [/quote:9d0fcf2de1]

    wwwacct checks against /etc/passwd to reject repeated usernames. Also rejects usernames greater than 8 characters long, and usernames beginning with a number or a dash.
     
  9. jimcarter

    jimcarter Well-Known Member

    Joined:
    Jun 30, 2002
    Messages:
    152
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    it doesnt return the errors though, and you could still end up charging someones credit card thinking that the account has been created when in fact it hasnt
     
  10. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    Ok, I thougt you'd want to make the same checks wwwacct does :)
     
Loading...

Share This Page