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.

CPanel and php

Discussion in 'General Discussion' started by strauberry, Jun 14, 2003.

  1. strauberry

    strauberry Well-Known Member

    Joined:
    Mar 25, 2003
    Messages:
    150
    Likes Received:
    0
    Trophy Points:
    16
    Hi,
    you can use CPanel and php together:

    PHP:
    $var '<cpanel Subdomains="">';
    CPanel code is interpreted before the php code.

    Now my question: I want to use cpanel-vars in a php loop:

    PHP:
    if("<cpanel SubDomain="subdomainurl($element)">" != "http://") {
     echo 
    "<cpanel SubDomain="subdomainurl($element)">";
    }
    This loop isn't correct, so how to do this job??

    THANK YOU!
    strauberry

    cPanel.net Support Ticket Number:
     
  2. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    I've tried to do things with PHP in Cpanel in the past, and unless you want to do simple things, it's really a PITA IMHO ;)

    I recommend you write your own custom modules (in Perl). What you want to do here would be fairly easy to achieve with a custom module.

    Example:

    Code:
    sub MySubDomain_listredirections {
    
        my @subdomains = ::listsubdomains();
    
        foreach my $subd (@subdomains) {
            my $redir = ::subdomainurl($subd);
            if ($redir ne "http://") {
                $subd  =~ s/_/./g;
                print "<b>$subd</b>: $redir<br>\n";
            }
        }
    
    }
    
    The are samples at /usr/local/cpanel/CPanel/
     
    #2 Juanra, Jun 14, 2003
    Last edited: Jun 14, 2003
  3. strauberry

    strauberry Well-Known Member

    Joined:
    Mar 25, 2003
    Messages:
    150
    Likes Received:
    0
    Trophy Points:
    16
    Hi,
    thank you for your great answer, it looks very useful :)

    BUt I can not execute cgi-files in my folder /frontend/theme/subdomain/test.cgi

    I can see the source code. The same with a file without extension. The file is chmod to 755.

    thank you again :)

    strauberry

    cPanel.net Support Ticket Number:
     
  4. Juanra

    Juanra Well-Known Member

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

    strauberry Well-Known Member

    Joined:
    Mar 25, 2003
    Messages:
    150
    Likes Received:
    0
    Trophy Points:
    16
    Hi Juanra,

    thank you again great stuff :)

    But this page doesn't help me with my other problem: cgi code is not executed. php code can be used without any problems but cgi code is not possible.

    View -> View source code (in my browser) shows me the file just like in an editor. The screenshot will explain it :)

    thank you
    strauberry

    cPanel.net Support Ticket Number:
     

    Attached Files:

  6. rbmatt

    rbmatt Well-Known Member

    Joined:
    Oct 21, 2002
    Messages:
    212
    Likes Received:
    0
    Trophy Points:
    16
    I would suggest making an API if you want to use perl. Just follow example_module

    cPanel.net Support Ticket Number:
     
  7. strauberry

    strauberry Well-Known Member

    Joined:
    Mar 25, 2003
    Messages:
    150
    Likes Received:
    0
    Trophy Points:
    16
    I'm just creating my own module but how can I use it if cgi is not interpreted????? :rolleyes:

    cPanel.net Support Ticket Number:
     
  8. strauberry

    strauberry Well-Known Member

    Joined:
    Mar 25, 2003
    Messages:
    150
    Likes Received:
    0
    Trophy Points:
    16
    please do not misunderstand my question: I want to use that script in my cleint area and not in the WHM area!!

    How to call my module??
     
    #8 strauberry, Jun 15, 2003
    Last edited: Jun 15, 2003
  9. rbmatt

    rbmatt Well-Known Member

    Joined:
    Oct 21, 2002
    Messages:
    212
    Likes Received:
    0
    Trophy Points:
    16
    Take a look at /usr/local/cpanel/Cpanel/ExampleModule.pm
    Then in the panel, it is called by <cpanel ExampleModule="function()">
    A little harder to do, but a possibility.

    cPanel.net Support Ticket Number:
     
  10. strauberry

    strauberry Well-Known Member

    Joined:
    Mar 25, 2003
    Messages:
    150
    Likes Received:
    0
    Trophy Points:
    16
    Hi,
    do I have to recompile anything? I did it like you said but nothing. I put a print "test"; into my sub listsubdomains but it is not displayed :(

    THANK YOU!

    cPanel.net Support Ticket Number:
     
  11. Juanra

    Juanra Well-Known Member

    Joined:
    Sep 22, 2001
    Messages:
    777
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Spain
    No, just create a module with the same structure as the ExampleModule.pm and define your own functions. You may give it any name you want as long as it doesn't exist yet. For example MySubDomain.pm.

    See here: http://html.conclase.net/cp/scripts/MySubDomain.perl.txt

    That's a working module which implements the listredirections() call I posted above. Just copy it to /usr/local/cpanel/Cpanel and rename it to MySubDomain.pm and that's it. You now have a new <cpanel MySubDomain="listredirections()"> API call of your own :D

    The functions are run as the user logged in Cpanel, so be careful with what you do, especially if you do file operations.

    cPanel.net Support Ticket Number:
     
  12. strauberry

    strauberry Well-Known Member

    Joined:
    Mar 25, 2003
    Messages:
    150
    Likes Received:
    0
    Trophy Points:
    16
    Hi,
    thank you so much for your help!!!!!!!!!

    The mistake was that I wrote CPanel instead of Cpanel :rolleyes:

    One last question: where can I find a summary of all available functions? You use listsubdomains but how can you know that this function exists??

    Thank you one million times
    strauberry

    cPanel.net Support Ticket Number:
     
Loading...

Share This Page