Results 1 to 13 of 13

Thread: plugin/Browser show html code(text/plain) if run plugin from mod_proxy/DA on port 80

  1. #1
    Join Date
    Feb 2007
    Posts
    34

    plugin/Browser show html code(text/plain) if run plugin from mod_proxy/DA on port 80

    Can you help me please.
    i'm compiled C program for index.raw
    /usr/local/directadmin/plugins/mytest/user/index.raw

    when i use directadmin from mod_proxy
    directadmin in port 80 have been
    set check_referer=0 in directadmin.conf

    when execute from :2222
    http://domain.com:2222/CMD_PLUGINS/mytest/index.raw
    browser show normal web page

    but if run from mod_proxy
    http://cp.domain.com/CMD_PLUGINS/mytest/index.raw
    browser show html code (text/plain)

    ---------------------------------
    code before complied for index.raw
    ---------------------------------

    system("/usr/bin/php /usr/local/directadmin/plugins/mytest/images/scripts/inc.php");
    or
    execl("/usr/bin/php", "php",
    "-c", "/var/mytest/etc/php.ini",
    "-q", "/usr/local/directadmin/plugins/mytest/images/scripts/inc.php",
    (char *) NULL);

    if you can help, tell me please.
    Thank you so much
    Regards
    mean.

  2. #2
    Join Date
    Feb 2007
    Posts
    34
    it work for me!

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <unistd.h>

    system("/bin/sh /usr/local/directadmin/plugins/mytest/admin/index.sh");
    ------
    #!/bin/sh
    echo "HTTP/1.1 200 OK";
    echo "Content-Type: text/html";
    echo "";


    system("/usr/bin/php /usr/local/directadmin/plugins/mytest/scripts/inc.php");
    -------
    <?
    echo 'Hello';
    ?>


    ------------
    my plugin can be show content on web browser
    i don't know why can't notice html header
    when compiled c on .raw file

    thank so.
    Thailand Linux Web hosting and Domain name registration.
    IREALLYHOST.com

  3. #3
    Join Date
    Feb 2007
    Posts
    34
    If you want complied c++/gcc for your plugin (.raw file)
    -----------------------------
    when run .raw file from mod_proxy
    ex. cp.your-domain.com instead :2222
    HTTP Response Headers return Content-Type : text/plain
    when execute php from execl,system,execv

    but run DA from :2222 browse show normal webpage
    HTTP Response Headers return Content-Type : text/html
    -----------------------------


    solve, it work for me.

    i think popen may be slow than
    execl,system,execv

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <unistd.h>
    
    printf ("HTTP/1.1 200 OK\n");
    printf ("Content-type: text/html\n");
    printf ("\n");
    
    FILE *fp;
    char line[4096];
    
    if((fp = popen("/usr/bin/php /usr/local/directadmin/plugins/mytest/scripts/inc.php", "r")) == NULL) {
    	return(1);
    }
    
    while(fgets(line, sizeof(line), fp)) {
    	printf("%s", line);
    }
    Last edited by mean; 01-06-2011 at 08:32 PM.
    Thailand Linux Web hosting and Domain name registration.
    IREALLYHOST.com

  4. #4
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,380
    Try this:

    Code:
    #include <stdio.h>
    #include <unistd.h>
    #include <string.h>
    #include <sys/types.h>
    
    int main(int argc, char *argv[], char *envp[]){
        setenv("SCRIPT_FILENAME","/usr/local/directadmin/plugins/pluginname/libs/admin.php",1);
        return execve("/usr/local/directadmin/plugins/pluginname/libs/admin.php",argv,envp);
        return 1;
    }
    That's working for us.

  5. #5
    Join Date
    Feb 2007
    Posts
    34

    Thumbs up

    Dear zEitEr
    Thank you very very much for you share this.



    Regards.
    mean
    Thailand Linux Web hosting and Domain name registration.
    IREALLYHOST.com

  6. #6
    Join Date
    Feb 2007
    Posts
    34
    dear zEitEr

    when run directadmin (port 80) from http mod_proxy
    and execute php from function execve,execl,system
    browser show html code (text/plain)

    but run from port 2222 browser show normal webpage(text/html)

    file -> inc.php
    Code:
    #!/usr/local/bin/php
    <?PHP
    
    header('HTTP/1.1 200 OK');
    header('Content-Type: text/html');
    echo '
    <html><b>Test Webpage</b></html>
    ';
    ?>
    my test not work.
    --------------------

    Code:
    char *arg[]={ 
    	"/usr/bin/php",
    	"-q","/usr/local/directadmin/plugins/mytest/images/scripts/inc.php"
    , NULL };
    execv(*arg, arg);
    Code:
    execl("/usr/bin/php", "php", 
    "-q", "/usr/local/directadmin/plugins/mytest/images/scripts/inc.php",
    (char *) NULL);
    Code:
    return execve("/usr/local/directadmin/plugins/mytest/images/scripts/inc.php",argv,envp);
     return 1;
    system("/usr/bin/php /usr/local/directadmin/plugins/mytest/images/scripts/inc.php");
    Attached Images Attached Images
    Last edited by mean; 01-07-2011 at 12:46 PM.
    Thailand Linux Web hosting and Domain name registration.
    IREALLYHOST.com

  7. #7
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,380
    Hello,

    Perhaps, something is miss-configured on your server. I've checked ours, still that's working for us. With the instruction http://help.directadmin.com/item.php?id=84 we've got correct MIME type in output (on every page of directadmin including pages with plugin):

    Code:
    ---request begin---
    GET / HTTP/1.0
    User-Agent: Wget/1.11.4 Red Hat modified
    Accept: */*
    Host: ********.ru:8000
    Connection: Keep-Alive
    
    ---request end---
    
    
    
    ---response begin---
    HTTP/1.1 200 OK
    Date: Sat, 08 Jan 2011 09:32:34 GMT
    Server: DirectAdmin Daemon v1.36.2 Registered to ********
    Cache-Control: no-cache
    Pragma: no-cache
    X-DirectAdmin: unauthorized
    Content-Type: text/html
    Set-Cookie: session=; path=/; HttpOnly
    Vary: Accept-Encoding,User-Agent
    Connection: close
    
    ---response end---
    200 OK
    Did you try other browsers? And check your apache's config.

    P.S. Your test plugin page is out of Directadmin's template. Is it ok for you?

  8. #8
    Join Date
    Feb 2007
    Posts
    34
    directadmin can run normal on port 80 and port 2222
    but not work only for (plugin) on port 80

    I attach mytest.zip
    with .c file for compile

    thank zEitEr for help
    mean



    ---
    last 01:23 PM. mytest.zip
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by mean; 01-08-2011 at 01:29 PM.
    Thailand Linux Web hosting and Domain name registration.
    IREALLYHOST.com

  9. #9
    Join Date
    Feb 2007
    Posts
    34
    I test, create img.raw file
    in /usr/local/directadmin/plugins/mytest/user/img.raw

    Example 1
    ---------------------------------------------
    Code:
    #!/usr/bin/php
    <?php 
    	header ("HTTP/1.1 200 OK\r\n");
    	header ("Content-type: text/html\r\n");
    	header ("\r\n");
    
    	print_r($_GET);
    ?>
    when request on port 80
    response html code / header is Content-Type text/plain

    when request on port 2222
    show normal webpage

    Example 2
    ---------------------------------------------
    Code:
    #!/bin/sh
    echo "HTTP/1.1 200 OK";
    echo "Content-Type: text/html";
    echo "";
    echo "Welcome webpage";
    request on port 80/2222
    browser show normal webpage
    Response header
    Content-Type : text/html

    ---------------------------------------------
    i think, inapposite with compile c
    Last edited by mean; 01-08-2011 at 11:21 PM.
    Thailand Linux Web hosting and Domain name registration.
    IREALLYHOST.com

  10. #10
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,380
    Why do you send headers in your script? I've never done it. In php there's no need to do manually for text/html, it's not PERL.

  11. #11
    Join Date
    Jul 2011
    Posts
    3
    directadmin can run normal on port 80 and port 2222??? Is it????

  12. #12
    Join Date
    Apr 2005
    Location
    GMT +7.00
    Posts
    12,380
    Yes, it is. Why are you asking?

  13. #13
    Join Date
    Jun 2003
    Location
    California
    Posts
    26,122
    DirectAdmin can run on port 80, but only through a serverside proxy based on a specific domain name (for example admin.example.com). Search the DirectAdmin knowledgebase.

    Jeff
    +1 951 643-5345
    Third-Party DirectAdmin administration and support
    Dedicated Servers, Dedicated Reseller Accounts
    NoBaloney Internet Services div. Qnito Incorporated
    848 North Rainbow Blvd., Suite #3789
    Las Vegas, NV 89107-1103

Similar Threads

  1. nginx set flv Content-Type as plain/text
    By BestBoard in forum Apache (WWW)
    Replies: 3
    Last Post: 04-25-2011, 06:07 AM
  2. mysql root password plain text setup.txt
    By cyberneticos in forum System-Level Technical Discussion
    Replies: 3
    Last Post: 11-05-2009, 11:16 AM
  3. Plugin user_img.html bug
    By hehachris in forum Feedback & Feature Requests
    Replies: 1
    Last Post: 02-03-2007, 02:01 AM
  4. help! Instead of a form I see HTML-code in browser!
    By LostAngel in forum Installation / System Requirements
    Replies: 2
    Last Post: 03-08-2005, 05:30 AM
  5. Replies: 1
    Last Post: 07-30-2003, 02:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •