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 and Cpanel Tags???

Discussion in 'User Experience' started by lammadog, Jan 10, 2003.

  1. lammadog

    lammadog Member

    Joined:
    Dec 21, 2002
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    I've tried so many different syntax variations trying to build my &cpanel& tags with php


    eg. echo '&cpanel include=&$path&&';


    anyone got this worked out and working?
    or is it just that Cpanel parses it's tags before it parses PHP and it won't work right???
     
  2. rbmatt

    rbmatt Well-Known Member

    Joined:
    Oct 21, 2002
    Messages:
    212
    Likes Received:
    0
    Trophy Points:
    16
    Well, that seems ok. Does everything else php work? Some boxes have trouble with php in that directory.

    http://www.gwsa.net/skinny/vars.phps
     
  3. lammadog

    lammadog Member

    Joined:
    Dec 21, 2002
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    yeah, everything else in php is working fine,

    if your looking at my source, on the very bottom I'm trying make an inc() function, that will build the &cpanel includes& for me.

    But when I try to call it, I just get a blank screen where the included stuff should be displayed
     
  4. lammadog

    lammadog Member

    Joined:
    Dec 21, 2002
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    naw, it's looking like it's not gonna work, even using a regular &cpanel include=&&& and adding a variable to the URL breaks it too. Now, that's easy enough to work around by just using session variables, but it looks like I'm just gonna have to hard code the includes.

    for the first level I'll just work them into the .conf file for the icon engine, but I forsee myself spenting bucko hours writing if statments :p
     
  5. lammadog

    lammadog Member

    Joined:
    Dec 21, 2002
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    I $*@#( HATE CPANEL HAHA



    this works...
    &cpanel include=&mini.php&&

    this don't work...
    &?
    echo '&cpanel include=&mini.php&&';
    ?&


    I don't really have to hardcode all the navigation do I?????


    this works....
    &?
    if ( $mylink == &mini& )
    { ?& &cpanel include=&mini.php&& &? }
    ?&

    ... but that kinda defeats the whole purpose :p




    HELP... ANYONE... ?
    hehe
     
  6. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    It's cpanel first and PHP later. Look at /usr/local/cpanel/cpanelphp to see how the PHP wrapper works. Also the PHP version compiled into Cpanel seems to be quite restricted, but still it allows you to do very interesting things.

    The main problem I've found with it is that GET parameters are lost because of a bug in cpanelphp. I posted a patch in bugzilla, but it's not available now, and it was a shabby patch anyway. If anyone has come up with something to solve this problem without using another intermediate file, please post it here, thanks.
     
  7. lammadog

    lammadog Member

    Joined:
    Dec 21, 2002
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    cool thanks Juanra,

    I did briefly glance at the cpanelphp file, but I gave it a better look and that answered me alot of questions ;)

    I also slept on the problem, and I think I got it figured out, it's kinda a drag that I can't use my php variables in the &cpanel include=&, so I'll have to write a vary long switch statement, but oh well...

    And everyone, please forgive last nights rant, I'm sure you've all been there when you got started with Cpanel
     
  8. uch-alex

    uch-alex Registered

    Joined:
    Oct 24, 2002
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I'm having a different problem. When I renamed changepass.html to changepass.php, it stopped working. Here is the part that worked before:

    <cpanel Passwd="change_password($FORM{'oldpass'},$FORM{'newpass'})">

    When called from a php file, it no longer sees $FORM{'oldpass'} or $FORM{'newpass'} (or any such variable). I can use $oldpass and $newpass from PHP, but not from a chapel tag.

    Any suggestions?
     
    #8 uch-alex, Mar 16, 2003
    Last edited: Mar 16, 2003
  9. rvskin

    rvskin Well-Known Member
    PartnerNOC

    Joined:
    Feb 19, 2003
    Messages:
    400
    Likes Received:
    1
    Trophy Points:
    18

    should not have space between =" change


    To develope skin using php, don't think you develop php, you have to think you are develop under cpanel-php wrapper as Juanra mention before.
     
  10. uch-alex

    uch-alex Registered

    Joined:
    Oct 24, 2002
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    I don't have the space there. This forum is evil and for some reason put it there. It also wrapped that line somewhat.

    Let me try a shorter example:

    <cpanel print="$FORM{'domain'}">

    This works from an .html file but fails from within a .php file, however the $domain PHP variable does work in that case.

    Basically something is preventing cpanel from reading form variables and I suspect cpanelphp to be the problem. Someone mentioned it losing GET variables, but I am using POST. is this also true for POST? Is a patch available?
     
    #10 uch-alex, Mar 17, 2003
    Last edited: Mar 17, 2003
  11. Faldran

    Faldran Well-Known Member

    Joined:
    May 28, 2002
    Messages:
    136
    Likes Received:
    0
    Trophy Points:
    16
    Yeah, I have to... encountered the same problem!

    Still waiting on a fix for it!
     
  12. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    I have put the cpanelphp file I use here:

    http://html.conclase.net/cp/scripts/cpanelphp.txt

    Unfortunately I haven't found the way to redirect the cpanel parser output to a variable instead of to a file. I'm pretty sure it can be done (we're talking about Perl here) - it's just that I don't know how to do it :(
     
    #12 Juanra, Mar 18, 2003
    Last edited: Mar 18, 2003
  13. Faldran

    Faldran Well-Known Member

    Joined:
    May 28, 2002
    Messages:
    136
    Likes Received:
    0
    Trophy Points:
    16
    So has anyone found a complete fix for this yet?

    Or even a good work around?
     
  14. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    I have written a new cpanelphp wrapper which only uses one intermediate file (like the original wrapper does) and makes POST and GET vars available to both CPanel and PHP (except that CPanel ignores GET vars when POST vars are passed):

    http://html.conclase.net/cp/scripts/cpanelphp.txt

    cPanel.net Support Ticket Number: 24008
     
  15. cyon

    cyon Well-Known Member
    PartnerNOC

    Joined:
    Jan 15, 2003
    Messages:
    320
    Likes Received:
    0
    Trophy Points:
    16
    hi,

    Juanra, thx for your big work.
    Your php wrapper is working on my first box without any problems.

    Now i have installed a second box with the same skin and use your wrapper again, but it wont work any more..

    this is the code wich causes the problem:
    <?php
    $pw=<cpanel print="$password">;
    ?>

    its working perfect on server1, but on server2 i get this:

    Parse error: parse error in /usr/local/cpanel/base/tmp/username-1069815840-16991 on line 11

    any ideas?

    thank you very much in advance.
     
    #15 cyon, Nov 25, 2003
    Last edited: Feb 18, 2005
  16. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    The password might contain a character like ; or a " for example, which would cause a syntax error in the resulting PHP file.
     
  17. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
  18. equens

    equens Well-Known Member

    Joined:
    Feb 8, 2002
    Messages:
    270
    Likes Received:
    0
    Trophy Points:
    16
    Php functions in cpanel

    How can I use a php function with cpanel tags? Why this does not work?


    conf.php:
    PHP:
    function ChangePass($email,$password,$quota,$domain) {?>
    <cpanel Email="passwdpop($email,$password,$quota,$domain)">
    <? } ?>
     
    dopasswdpop.php:
    PHP:
    <cpanel include="../conf.php">
    <? ChangePass(); ?>
     
  19. kosmo

    kosmo Well-Known Member

    Joined:
    Aug 12, 2001
    Messages:
    403
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    All over Europe
    This will produce mismatch and unwanted results. Making PHP and cpanel working together means understanding following:

    - CPanel tags will be parsed only when the files are included using cpanel include (not php include) which in your case is true.
    - CPanel include work only in one level. A file that is already included can not include more files (parser exits if this is the case)
    - CPanel tags will run on file load independent of php statements. Example:

    if ($blue) {
    <cpanel Email="passwdpop($email,$password,$quota,$domain)">
    }

    The password will be changed on file load, no matter if blue is true or not. The cpanel parser will then deliver to the PHP parser following code:
    if ($blue) {
    Password successfully changed!
    }

    (or similar)

    PHP will display a syntax error.

    Actually the only way to work around it is: Make a page for new password submission. On "Submit", load a separate file with the proper cpanel commands to modify the password.

    kosmo
     
  20. equens

    equens Well-Known Member

    Joined:
    Feb 8, 2002
    Messages:
    270
    Likes Received:
    0
    Trophy Points:
    16
    Hello Kosmo and thank you for your reply. Instead of this, I want to change files to php to add custom functions like header(), footer() or menu. I have a conf.php with my functions and I put this code ej:

    PHP:
    <cpanel include="../conf.php">
    <? Header(); Menu(); ?>
    html here
    <? Footer(); ?>
    It works fine but I would to know if this is the correct way to do this.

    And about the php functions and who CPanel tags works I think would have to offer support to php functions to do the same with php. Ej. Instead of setdef.html, def.html and dosetdef.html to set default addres, we would only need one def.php file.
    Thanks again!
     
Loading...

Share This Page