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.

Loading PHP variables 64-bit

Discussion in 'General Discussion' started by sparek-3, Oct 13, 2008.

  1. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    I work on some slightly customized themes. Today I noticed that the 64-bit of cPanel does not load the $_CPANEL array like the 32-bit counterpart does.

    In the cPanel theme directory I created a test file with the code:

    PHP:
    <?php
    <cpanel PHP="loadvars()">
    print(
    "<pre>\n");
    print_r($_CPANEL);
    print(
    "</pre>\n");
    ?>
    I did this on two servers. One is 64-bit the other is 32-bit. On the 32-bit machine this loads fine. The dump of the $_CPANEL array is given as expected. On the 64-bit machine this results in an error.

    Code:
    Parse error: syntax error, unexpected T_STRING, expecting ')' in /tmp/cpanel_phpengine.1223927273.29233AzvrEnL6b2 on line 2
    I believe the problem is related to the line:

    PHP:
    <cpanel PHP="loadvars()">
    because if I remove that line, then the script executes (though nothing is displayed, which is expected).

    Am I loading the $_CPANEL array incorrectly? Why does it work on the 32-bit system but not on the 64-bit system?

    Both of the servers are running cPanel version 11.23.6-RELEASE_27698

    The 32-bit and 64-bit differences are the only differences that I am aware of, but it may be something else. I may be populating the $_CPANEL array incorrectly. Is there another way to populate this array?
     
  2. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Testing this on a FreeBSD 7 64 bit system results in success ( i.e. the array is properly populated in and no error occurs).

    What is your PHP version used by cPanel?

    Are you using the PHP binary:
    1. that ships with cPanel; or
    2. is built by /scripts/makecpphp; or
    3. that is in /usr/bin (or /usr/local/bin)?
     
  3. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    This is using the php that comes with cPanel. I also tried the system PHP, and it resulted in the same thing.

    I'm using CentOS 4.7 in my test. The one that isn't working is CentOS 4.7 64 bit. CentOS 4.7 32 bit is working.

    PHP is version 5.2.6.

    It may not be a problem with 64-bit, but that's the only difference between the two systems that I can really put my finger on.
     
  4. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Testing the same on CentOS 4.7 64 bit using PHP 5.2.6 results in the variables being properly populated.

    Are both systems using a similar or same php.ini file?

    The only other thing that comes to mind is to have one of our techs look at the problem server.
     
  5. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Don't you just hate it when you have a problem like this and the answer comes about to be something very simple.

    The cause of the problem was the package name that the account was using had an apostrophe (') in it. I am assuming that this somehow did not allow <cpanel PHP="loadvars()"> to parse correctly resulting in the error.

    I was also able to verify that this behavior was the same on both 32-bit and 64-bit systems, so this really has nothing to do with 64-bit systems.

    Just wanted to say that I appreciate you taking the time to test this on your systems. It gave me an idea that the problem was somewhere else. I was finally able to isolate it after I tried changing the control panel theme and saw the apostrophe in the package name. It actually looks like apostrophe's are no longer allowed in package names. I'm guess that this reseller's package was created some time ago when this was allowed.

    Once again, I appreciate all of your help with this.
     
  6. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    That is rather interesting. I'm not certain how the interaction there works, but it seems like the problem should be easily reproducible.
     
  7. cPanelNick

    cPanelNick Administrator
    Staff Member

    Joined:
    Mar 9, 2015
    Messages:
    3,426
    Likes Received:
    2
    Trophy Points:
    38
    cPanel Access Level:
    DataCenter Provider
  8. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,381
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    The PHP.pm file seems to be the same one that is already there.

    I really don't think this is much of an issue. The issue was that there was an apostrophe in the package name, but when you go to create a package in the WHM, if you use an apostrophe in the package name it is removed when the package is actually created. I suspect that this account (a reseller's account) was using an old package, one created several versions ago where apostrophes were allowed in the package name. On the account in question, I simply renamed the package to one without an apostrophe and changed the account to use the new package. This fully resolved the issue.

    In order to create a package with an apostrophe to test this, I had to manually create a package in /var/cpanel/packages with an apostrophe. Unless there is something else loaded into the $_CPANEL array that can have an apostrophe I would consider this matter closed.

    If anyone else runs into a similar issue like this, I would recommend checking the package name to see if it has an apostrophe in it. Or if any other values that are returned in the $_CPANEL array have an apostrophe or other special character in it.
     
  9. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,458
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    The changes in our BETA branch resolve this issue by ensuring the ' is properly escaped before we push the data to the PHP process. Thanks for pointing this out to us.
     
Loading...

Share This Page