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.

unable to execute php under cpanel themes

Discussion in 'General Discussion' started by tinboye22, Dec 12, 2009.

  1. tinboye22

    tinboye22 Active Member

    Joined:
    Sep 16, 2004
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    1
    recently i noticed that since the server updated a user is unable to execute php files from under a cpanel page. when it executes all a person sees is
    something like this

    Code:
    ‹������ÿ“ïæ`�f®sç}uOž8ã~B'LCÿÔyïðŽž¾:~¡^¾Ú^ºç*¼ÄµET–-uSETóÅíÂÊgSUŸ¥,Ó¨x">]£by˜ÖqÇ}Œóì€þÿÏÌP¥Rd�Ĉf���
    
    though when i go to edit the file via ssh, it shows as normal php code, if i change the permissions to the file to say 666, the code changes slightly, but is still gibberish.
    I have tried uploading the files via binary and ascii, and no change. before the updates the files could execute fine.

    has anyone else experienced this issue?
     
  2. rachelm

    rachelm Well-Known Member

    Joined:
    Jan 26, 2005
    Messages:
    94
    Likes Received:
    1
    Trophy Points:
    8
    this can happen depending on what you have in the php file, try changing the extension from php to phpcp and that will tell cpanel to load the php first and should fix your issue
     
  3. tinboye22

    tinboye22 Active Member

    Joined:
    Sep 16, 2004
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    1
    I though that might have been the answer too, i tried both phpcp and cpphp both still output the samething, i didnt have any problem with running these php files under cpanel before. It has only been in the past month or so when i tested them that i noticed the issue, so my thinking is that cpanel updated and changed something.

    The 1 script is a bridge between cpanel and whmcs, the other is the api for cpanel from simplescripts.com to offer my customers auto script installs.

    PHP:
    <?php
    /* 
    Client Login API
    Documentation: https://www.simplescripts.com/articles/client_login

    This file should be used to pre-authenticate users and redirect them to the main account page of SimpleScripts, where all installations are displayed and users will have single click Install Now buttons.  If you only want to send users to a login page, please review https://www.simplescripts.com/host/integration.
    */

    /* EDIT THE FOLLOWING VALUES WITH YOUR OWN CLIENT INFORMATION (ALL VALUES REQUIRED)
    (Existing values are for cpanel, minus the user and password. Values should be initialized in the header template file) 
    */
    $my_request = array(
        
    //available at simplescripts.com/host/integrate
        
    "host_key" => 'YOUR HOST KEY'
        
    //available at simplescripts.com/host/integrate
        
    "host_api_key" => 'YOUR HOST API KEY'
        
    //we need something that won't change to keep account continuity, such as the account username, or an account id if the username changes constantly.
        
    "user_unique" => '<cpanel print="$CPDATA{'USER'}">'
        
    //main domain name, minus www.
        
    "user_domain" => '<cpanel print="$CPDATA{'DNS'}">'
        
    //ftp ip address (can be different than the domain/box ip)
        
    "user_ip" => '<cpanel print="$CPDATA{'IP'}">'
        
    "user_email" => '<cpanel print="$CPDATA{'CONTACTEMAIL'}">'
        
    "user_username" => '<cpanel print="$CPDATA{'USER'}">',
        
    "user_password" => '<cpanel print="$password">',
    );

    /* STOP EDITING HERE */

    if ($my_request['host_key'] == "YOUR HOST KEY") { die("SimpleScripts is Coming Soon!"); }

    $my_request_str "";
    foreach (
    $my_request as $key => $value) { $my_request_str.= $key."=".urlencode($value)."&"; }

    ob_start(); 
    passthru('curl -k https://www.simplescripts.com/api/client_login.php --data "'.rtrim($my_request_str,"& ").'" --max-time 60'); 
    $response ob_get_contents(); 
    ob_end_clean();

    $parts explode("|",$response);
    if (
    $parts[0] != "1") { die("Something is wrong! Please refresh this page.<br />\n".$parts[1]); }
    else {
        print 
    '<meta http-equiv="refresh" content="0;url='.$parts[1].'"/>';
        print 
    'Redirecting to <a href="'.$parts[1].'">SimpleScripts</a>.';
    }
    ?>
    the other script is:
    PHP:
    <?php
    /////////CONFIGURING YOUR WHMCS DATABASE SETTINGS///////////////
    $db_usermysql 'whmcs_db_user'//Your WHMCS DB Username
    $db_passmysql 'whmcs_db_pwd'//Your WHMCS DB Password
    $db_hostmysql 'whmcs_db_hostname'//Your WHMCS DB Hostname
    $db_dbmysql'whmcs_db_name'//Your WHMCS DB Name

    //Your WHMCS URL - DO NOT include trailing slash, you can use SSL if you want using your https:// WHMCS URL
    $whmcs_url 'http://yourdomain.com/whmcs';

    //////////////MAIN CODE BELOW THIS LINE - DO NOT CHANGE ANYTHING ////////////////////////////
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    $cpusername '<cpanel print="$user">';
    $area $_REQUEST['goto'];

    $agent_conn_string=mysql_connect($db_hostmysql,$db_usermysql,$db_passmysql);
    $agent_dbconn=mysql_select_db($db_dbmysql,$agent_conn_string);

    $agent_getemail "select id,email,password from tblclients where id = (select userid from tblhosting where username = '$cpusername')";
    $rs_getemail mysql_query($agent_getemail);

    while(
    $row mysql_fetch_array($rs_getemailMYSQL_ASSOC))
    {
    $client_email $row['email'];
    $client_id $row['id'];
    $client_pwd $row['password'];
    }

    $agent_getpid "select id from tblhosting where username = '$cpusername'";
    $rs_getpid mysql_query($agent_getpid);

    while(
    $row mysql_fetch_array($rs_getpidMYSQL_ASSOC))
    {
    $productid $row['id'];
    }

    //PARSING ALL REQUEST VARIABLES
    foreach ($_GET as $var_req => $value_req) {
        if (
    $var_req=='whostmgrrelogin' or $var_req=='whostmgrsession' or $var_req=='cprelogin' or $var_req=='cpsession' or $var_req=='logintheme' or $var_req=='langedit'){}
        else {
    $goto $goto.$var_req.'='.$value_req.'&';}

    print 
    "Authenticating...";


    //GETTING CPANEL SERVER LOCATION
    function getCpanelLoc() {
     
    $pageURL 'http';
     if (
    $_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
     
    $pageURL .= "://";
     if (
    $_SERVER["SERVER_PORT"] != "80") {
      
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
     } else {
      
    $pageURL .= $_SERVER["SERVER_NAME"];
     }
     return 
    $pageURL;
    }

    $cpanel_location getCpanelLoc();

    print 
    "
    <body onLoad=\"document.frmlogin.submit()\">
    <form action=\"
    $whmcs_url/cpbridge.php?$goto\" method=\"post\" name=\"frmlogin\">
    <input type=\"hidden\" name=\"cpanel_location\" size=\"40\" value=\"
    $cpanel_location\" />
    <input type=\"hidden\" name=\"productid\" size=\"40\" value=\"
    $productid\" />
    <input type=\"hidden\" name=\"uid\" size=\"40\" value=\"
    $client_id\" />
    <input type=\"hidden\" name=\"upw\" size=\"25\" value=\"
    $client_pwd\" />";

    //ADDING ALL POST VARIABLES
    foreach ($_POST as $var => $value) {
    print 
    "<input type=\"hidden\" name=\"$var\" size=\"25\" value=\"$value\" />";


    print 
    "</form></body>";

    ?>
    any help would be appreciated

    thanks
     
  4. tinboye22

    tinboye22 Active Member

    Joined:
    Sep 16, 2004
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    1
    well i had this issue resolved, ended up contacting cpanel and they figured out the problem:

    Here is what he explained he did:

    logged in to the server via ssh as root and issued the command.

    /scripts/makecpphp

    This can also be done in EasyApache on the last option in step #6
    of the "Exhaustive Options List".

    The exact text will read.

    Save my profile with appropriate PHP 5 options set so that it is compatible with cpphp
    This option will make the following changes to your profile prior to the build:

    Enables:
    CurlSSL
    FTP
    GD
    Gettext
    Iconv
    Imap
    Mbregex
    Mbstring
    Mysql
    Mysql of the system
    PGsql
    Sockets
    Zlib


    After compile cpphp
     
Loading...

Share This Page