Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    Member
    Join Date
    Mar 2003
    Posts
    153

    Default CPanel and php

    Hi,
    you can use CPanel and php together:

    PHP Code:
    $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 Code:
    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. #2
    Member
    Join Date
    Sep 2001
    Location
    Spain
    Posts
    779

    Default

    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/
    Last edited by Juanra; 06-14-2003 at 07:55 PM.

  3. #3
    Member
    Join Date
    Mar 2003
    Posts
    153

    Default

    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. #4
    Member
    Join Date
    Sep 2001
    Location
    Spain
    Posts
    779

    Default

    There is a complete example here:

    http://faq.cpanel.net/show.cgi?qa=105008912701656

    cPanel.net Support Ticket Number:

  5. #5
    Member
    Join Date
    Mar 2003
    Posts
    153

    Default

    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 Thumbnails Attached Thumbnails CPanel and php-screenshot.gif  

  6. #6
    Member
    Join Date
    Oct 2002
    Posts
    216

    Default

    I would suggest making an API if you want to use perl. Just follow example_module

    cPanel.net Support Ticket Number:

  7. #7
    Member
    Join Date
    Mar 2003
    Posts
    153

    Default

    I'm just creating my own module but how can I use it if cgi is not interpreted?????

    cPanel.net Support Ticket Number:

  8. #8
    Member
    Join Date
    Mar 2003
    Posts
    153

    Default

    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??
    Last edited by strauberry; 06-15-2003 at 01:16 PM.

  9. #9
    Member
    Join Date
    Oct 2002
    Posts
    216

    Default

    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. #10
    Member
    Join Date
    Mar 2003
    Posts
    153

    Default

    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. #11
    Member
    Join Date
    Sep 2001
    Location
    Spain
    Posts
    779

    Default

    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/...omain.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

    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. #12
    Member
    Join Date
    Mar 2003
    Posts
    153

    Default

    Hi,
    thank you so much for your help!!!!!!!!!

    The mistake was that I wrote CPanel instead of Cpanel

    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:

Similar Threads & Tags
Similar threads

  1. Replies: 15
    Last Post: 08-15-2011, 01:27 PM
  2. bytesCode PHP Encoder next request for cPanel PHP extension build in
    By RodrigoGregorio in forum Feature Requests for cPanel/WHM
    Replies: 0
    Last Post: 11-12-2010, 04:30 PM
  3. Updating cpanel PHP changed main server php.ini
    By 4u123 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-06-2009, 02:46 PM
  4. /usr/local/cpanel/php/cpanel.php error
    By bsolano in forum cPanel Developers
    Replies: 5
    Last Post: 10-17-2008, 03:30 PM
  5. Replies: 4
    Last Post: 11-30-2004, 06:28 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube