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.

Can't get remote access to work

Discussion in 'General Discussion' started by moonwalking, Mar 21, 2005.

  1. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    I want to do this to automate the account creation on my server:

    require 'Accounting.php.inc';

    if(createacct ($host,$user,$accesshash,0,$acctdomain,$acctuser,$acctpass,$acctplan)) {
    print "Success" ;
    } else {
    print "Failure" ;
    }

    But I can never get this script to work. I copy & pasted the access hash from WHM... filled in all the details, and instead of working, the script shows either a blank page or some strange login page to WHM with all the images broken.
     
  2. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    bumping bumping
     
  3. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    more bump bump
     
  4. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Bumpbumpbump
     
  5. RAIS2

    RAIS2 Well-Known Member

    Joined:
    Jul 16, 2004
    Messages:
    186
    Likes Received:
    0
    Trophy Points:
    16
    I do believe that you are calling it incorrectly.

    You are currently calling it as an if statement.

    Should be something like this:
    PHP:
    include("Accounting.php.inc");
    $user='root'// WHM username
    $accesshash='Your remote access key'// Remote Access Key
    $host='111.222.333.444'// IP of the WHM server
    $acctdomain='domain.com'// Domain to Install
    $acctuser='username'// Username to create
    $acctpass='securepass'// Password for the new account
    $acctplan='mypackage'// Package Name (must exist within WHM)

    createacct ($host,$user,$accesshash,0,$acctdomain,$acctuser,$acctpass,$acctplan);
    Hope That Helps
     
  6. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    It should work, just like copy() would for instance... and it doesn't matter anyway. If I assign it to a variable and use the variable in the if statement, the outcome is the same.
     
  7. RAIS2

    RAIS2 Well-Known Member

    Joined:
    Jul 16, 2004
    Messages:
    186
    Likes Received:
    0
    Trophy Points:
    16
    Well I think that is because the way you are using the if statement.

    Heres a more detailed suggestion, using an if statement.

    Filename: foo.php
    PHP:
    <?
    include(
    "Accounting.php.inc");
    $user='root'// WHM username
    $accesshash='Your remote access key'// Remote Access Key
    $host='111.222.333.444'// IP of the WHM server

    if ($createnow==true
         {
         
    createacct ($host,$user,$accesshash,0,$acctdomain,$acctuser,$acctpass,$acctplan);
         echo (
    "Account Created"); } 

    if (!isset(
    $createnow)) { echo ("Do something else"); }
    ?>
    Upload and call the script.

    http://yoursite.com/foo.php?createnow=true acctdomain=domain.com acctuser=username acctpass=securepass acctplan=mypackage ( Replace the spaces with `&` )

    I have not tested the above, but in theory it should work.

    <Side Note> I thought about this while doing the above. Does your server have curl? This I do beleive can cause a blank screen.

    HTH
     
    #7 RAIS2, Mar 27, 2005
    Last edited: Mar 27, 2005
  8. dead6re

    dead6re Registered

    Joined:
    Apr 22, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    It should work. Could be some other mod.

    At the moment its trying to create the account, and waits for cPanel to return 1. When it does, it echos Success, if not then False. I havent tried this in php before, but i dont know what happens if a nil value is returned. I would have though it would say False.
     
  9. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1

    That is the exact same thing as I did! It makes no difference whatsoever, I asure you!

    Just to make sure that I don't crash and burn in shame I tried it... it the outcome is the same.
     
  10. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    BTW, I tried both 'localhost' and the ip for WHM... does it make any difference?
     
  11. RAIS2

    RAIS2 Well-Known Member

    Joined:
    Jul 16, 2004
    Messages:
    186
    Likes Received:
    0
    Trophy Points:
    16
    Does your server have curl installed? I do believe it is a requirement for this script to work.
     
  12. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Yes it's installed.
     
  13. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Bumpbumpbyump
     
  14. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
  15. RAIS2

    RAIS2 Well-Known Member

    Joined:
    Jul 16, 2004
    Messages:
    186
    Likes Received:
    0
    Trophy Points:
    16
    Perfect Example

    Ok, so I got around to testing what I posted above. It did not install when copied exactly. The $acctpass portion has a few spaces ( I didnot post spaces // The same is happening with the $acctuser now :confused: appearing as $acct user Remove all spaces before saving), and the $usessl value was not available. After correcting that I was able to create an account. I have added a form that will show when not creating an account.

    Save the following as a new file ( createaccount.php ) Upload to your site, run the script and fill out the form.
    PHP:
    <?
    include(
    "Accounting.php.inc");
    $user='root'// WHM username
    $accesshash='Your Remote KEY'// Remote Access Key
    $host='111.222.333.444'// IP of the WHM server
    $usessl='0';
    if (
    $createnow=='true')
         {
         
    createacct ($host,$user,$accesshash,$usessl,$acctdomain,$acctuser,$acctpass,$acctplan);
         echo (
    "Account Created"); }

    if (!isset(
    $createnow)) { echo ("<form name='newaccount' method='post' action='".$PHP_SELF."'>
      <table width='100%'  border='0' cellspacing='0' cellpadding='1'>
        <tr>
          <td colspan='2'>Create An Account </td>
        </tr>
        <tr>
          <td width='40%' align='right'>Domain:</td>
          <td width='60%'>http://
            <input name='acctdomain' type='text' id='acctdomain'> 
          ( Do <strong>not</strong> include <strong>www</strong> ) </td>
        </tr>
        <tr>
          <td align='right'>Username:</td>
          <td><input name='acctuser' type='text' id='acctuser'> 
          (User name <strong>TEST</strong> in anyway, shape, or form, will <strong>NOT</strong> create ) </td>
        </tr>
        <tr>
          <td align='right'>Password:</td>
          <td><input name='acctpass' type='text' id='acctpass'></td>
        </tr>
        <tr>
          <td align='right'>Package Name: </td>
          <td><input name='acctplan' type='text' id='acctplan'> 
            ( Must Appear <strong>Exactly</strong> as in WHM ) </td>
        </tr>
        <tr align='center'>
          <td colspan='2'><input name='createnow' type='hidden' id='createnow' value='true'>
          <input type='submit' name='Submit' value='Create Now'></td>
        </tr>
      </table>
    </form>"
    ); }
    ?>
    This is as much help as your going to get. If this doesnot work, then look into setting the server up proper.
     
    #15 RAIS2, Mar 29, 2005
    Last edited: Mar 29, 2005
  16. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    That does not work on my server (not to mention it's the same code).
     
  17. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1
    Alright,


    After a few agonizing hours I finally got the thing to work (it was a major configuration problem and had very little to do with the actual script).

    Here is a question though... where are the directories of the created accounts held?
     
  18. RAIS2

    RAIS2 Well-Known Member

    Joined:
    Jul 16, 2004
    Messages:
    186
    Likes Received:
    0
    Trophy Points:
    16
    See It was not the script at all, I knew that.

    But to answer your next question. Accounts that get installed, their files that are available through their domain name go in the /home/username/public_html/ directory. while some other configuration files are below the public_html folder and are inaccessible to the immeadiate internet.
     
  19. moonwalking

    moonwalking Member

    Joined:
    Mar 21, 2005
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    1

    Understood.

    So let's say that if I am the admin, and therefore located in /home/admin/public_html/, then johnsmith is located in /home/johnsmith/public_html/, correct?

    How do I access that person's root directory using PHP scripting (or any language for that matter)? I know that I can connect to his/her FTP using hostname: johnsmith.mydomain.com. But how do I access that person's actual files, if I need to write a PHP script that can list them (for instance)? I need only the files that are accessible to the internet (the ones in the public_html directory).
     
    #19 moonwalking, Apr 3, 2005
    Last edited: Apr 3, 2005
  20. RAIS2

    RAIS2 Well-Known Member

    Joined:
    Jul 16, 2004
    Messages:
    186
    Likes Received:
    0
    Trophy Points:
    16
    What is it your trying to accomlish ?

    I would reccomend doing some coding research, or hire a coder. To me, it seems you do not know alot about programming.
     
Loading...

Share This Page