Results 1 to 6 of 6

Thread: Script no longer works

  1. #1
    Member Data 1's Avatar
    Join Date
    May 2008
    Posts
    106

    Default Script no longer works

    Hi all, I don't usually dump problems on people but you might be able to save me hours of research in 10 seconds, so here goes.

    I run a small hosting company, 3 dedicated servers so far, cpanel on all of them. Very easy to manage, incredible product you have at any price.

    I had a PHP script running on a server with php4 and mysql4, moved the entire site to php5 Mysql5. Script worked fine before, it's obviously not connecting to the cpanel now. Basically it creates a MySQL db, creates a user, and adds the user to the database. I'm open to any alternate method of doing this. Thank you!

    Pertinent portions:
    Code:
    function execCommand($command) {
      global $curl_path;
    
      if (!empty($curl_path)) {
        return exec("$curl_path '$command'");
      }
      else {
        return file_get_contents($command);
      }
    }
    And the previously working portion:
    Code:
    if(isset($board_name) && !empty($board_name)) {
      $db_name = strtolower($board_name);
      $result = execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name");
      }
    
      if(isset($board_name) && !empty($board_name)) {
        $db_username = substr($db_name, 0, 7);
        $db_userpass = $_GET['pass'];
        $user_name   = $_GET['user'];
        $user_email  = $_GET['email'];
      }
    
      if (!empty($db_username)) {
        $result .= execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adduser.html?user=$db_username&pass=$db_userpass");
        $result .= execCommand("http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/addusertodb.html?user=wowultra_$db_username&db=wowultra_$db_name&ALL=ALL");
            }

  2. #2
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    Looking at this, a couple of things jump out:

    1. exec(), commonly this function is disabled for security reasons. Is this your own server or is this a shared hosting server?

    2. Curl. It seems you are calling Curl directly rather than compiling it into PHP. Try to run the command manually via shell and see if it works or not. May not be a coding issue so much as a configuration issue. Personally, I prefer to just compile Curl support into PHP (it's very easy using WHM -> Software -> Apache Update) and call Curl that way.

    One thing you may consider long-term, especially if this is your own server, is just to call the cPanel APIs directly rather than doing some kludges with the GUI. Look at the source code of /usr/local/cpanel/base/frontend/x3 (the x3 theme), look at the APIs it calls for certain functions and call those yourself from your PHP scripts via our XML-API. There's some posts around here covering that stuff, but if you need help with that, just ask .

  3. #3
    Member Data 1's Avatar
    Join Date
    May 2008
    Posts
    106

    Default

    Thank you for the response.

    It is my server and if there is a way to do it directly I would rather.

    I'll look at the x3 routines but I am using X as the default theme (branded) for customers. I saw a post about looking there but assumed that since I was using x I should look in that folder instead shame on me.

    Thank you

  4. #4
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by Data 1 View Post
    Thank you for the response.

    It is my server and if there is a way to do it directly I would rather.

    I'll look at the x3 routines but I am using X as the default theme (branded) for customers. I saw a post about looking there but assumed that since I was using x I should look in that folder instead shame on me.

    Thank you
    The APIs will work regardless of which theme you use. I recommend X3 just because it's actively maintained and its codebase was designed to make use of the newer APIs. Also, you'll never need to force a specific theme just to ensure your scripts work if you call the APIs directly .

    X3 also has some really nifty branding capabilities that can be employed without customizing the theme's code itself. This has the benefit of a customized appearance while the underlying code is up-to-date.

    There was a brief overview of this in last year's Customizing cPanel(pdf) presentation. However, we are covering it in further depth with a couple of presentations at this year's conference. You can find more information about the conference on our website at: http://conference.cPanel.net
    Last edited by cPanelDavidG; 05-26-2008 at 10:49 AM. Reason: Emphasizing that X3 uses newer (better) APIs

  5. #5
    Member Data 1's Avatar
    Join Date
    May 2008
    Posts
    106

    Default

    It's sad as much html and php as I have done that I can't figure this out. I don't quite understand the format or what the variables are looking for as far as input.

    While I study it I will need to enable curl so I can get the thing going again. I have done the easyapache thing but only in the beginning when there isn't anyone on the server. Now with 50 plus customers what happens to their access while cpanel is kerchunking apache and php to include curl?

  6. #6
    Technical Product Specialist cPanelDavidG's Avatar
    Join Date
    Nov 2006
    Location
    Houston, TX
    Posts
    11,307
    cPanel/WHM Access Level

    Root Administrator

    Default

    Quote Originally Posted by Data 1 View Post
    It's sad as much html and php as I have done that I can't figure this out. I don't quite understand the format or what the variables are looking for as far as input.

    While I study it I will need to enable curl so I can get the thing going again. I have done the easyapache thing but only in the beginning when there isn't anyone on the server. Now with 50 plus customers what happens to their access while cpanel is kerchunking apache and php to include curl?
    With EasyApache, we keep downtime to an absolute minimum. I would say that a general rule of thumb would be that 30 seconds of downtime would be considered abnormally long.

    As for the APIs, I'll be happy to take time to slowly walk you through everything if you just drop me an email to sales@cpanel.net. Tickets tend to get my attention before forum posts, so I'll be able to more consistently assist you there than I would be able to assist you via this forum.

Similar Threads

  1. /scripts/ensure_vhost_includes no longer works?
    By jols in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 06-15-2010, 09:02 PM
  2. cpanel login no longer works
    By CunningStunt in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 01-17-2006, 01:03 PM
  3. gcc - no longer works?
    By aquagerbil in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 11-30-2005, 12:57 PM
  4. cron jobs no longer works
    By pmayo in forum cPanel & WHM Discussions
    Replies: 2
    Last Post: 09-27-2004, 11:36 AM
  5. suspend page no longer works
    By simplybe in forum cPanel & WHM Discussions
    Replies: 1
    Last Post: 10-05-2003, 07:59 AM