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.

PHP in cPanel skin

Discussion in 'User Experience' started by jprl12, Jul 6, 2007.

  1. jprl12

    jprl12 Member

    Joined:
    Sep 7, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Hi!

    I need to use some PHP code in my cPanel skin. So, I will begin a new skin with only PHP files. This work fine.

    But, how can I use cPanel variable in my code? In the normal HTML skin, this line : <cpanel print="$CPDATA{'DNS'}"> will show the domain of the account. I need to use these variables for do some search in MySQL database.

    For example, I tried this :
    <?php

    echo $CPDATA{'DNS'};

    ?>

    OR

    <?php

    echo $CPDATA['DNS'];

    ?>

    But, no result ... Can you help me?

    Regards,
    Jean-Philippe Rivard Lauzier
     
  2. kosmo

    kosmo Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    403
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    All over Europe
    CPanel will first parse its own tags, then will reparse the file, parsing any php tags. So, it should look like:

    <?php
    echo "<cpanel print="$CPDATA{'DNS'}">";
    ?>


    First parsing will result to:

    <?php
    echo "mydomain.com";
    ?>

    which will then lead to the desired result.

    kosmo
     
  3. jprl12

    jprl12 Member

    Joined:
    Sep 7, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Thanks!! This code work correctly!
     
  4. kosmo

    kosmo Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    403
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    All over Europe
    Glad to have been of some help (which has been rare lately :D)

    kosmo
     
  5. jprl12

    jprl12 Member

    Joined:
    Sep 7, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    I have a new question about PHP and a cPanel skin ...

    This line, it's for list the MX entry : <?cp Email::listmxs(% ,mx) ?>

    We can use this line : <?cp Email::listmxs(% ,mx) domain=mydomain.com ?> for list MX entry for a specific domain.

    This code, will put the cPanel tag information in a PHP variable :
    HTML:
    <?php
    $myVar = '<?cp Email::listmxs(% ,mx) domain=mydomain.com ?>';
    echo $myVar;
    ?>
    Now, my question, how I can write PHP in the cPanel tag? By example, for have a dynamic selection for the domain :
    HTML:
    <?php
    $myDomain = 'mydomain.com';
    $myVar = '<?cp Email::listmxs(% ,mx) domain='.$myDomain.' ?>';
    echo $myVar;
    ?>
    For sure, this code doesn't work ... Somebody have a solution for that?
     
  6. jprl12

    jprl12 Member

    Joined:
    Sep 7, 2004
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Nobody could help me?
     
  7. activa

    activa Well-Known Member

    Joined:
    May 23, 2006
    Messages:
    204
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Morocco
    cPanel Access Level:
    Root Administrator
    myDomain has been declared in php tag and you have included it in cpanel tag , i think the rl code must be something lik this :

    Code:
    <?php
    $myDomain = 'mydomain.com';
    $myVar = '<?cp Email::listmxs(% ,mx) domain= ?>'$myDomain'<?cp ?>';
    echo $myVar;
    ?>
     
Loading...

Share This Page