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

mean

Verified User
Joined
Feb 14, 2007
Messages
103
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.
 
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.
 
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:
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.
 
Dear zEitEr
Thank you very very much for you share this.

:)

Regards.
mean
 
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");
 

Attachments

  • 2011-01-08_023155.gif
    2011-01-08_023155.gif
    62 KB · Views: 176
Last edited:
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?
 
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
 

Attachments

  • mytest.zip
    5.2 KB · Views: 160
  • 2011-01-09_025237.gif
    2011-01-09_025237.gif
    65.6 KB · Views: 160
Last edited:
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:
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.
 
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
 
Back
Top