0

Is it possible to call URL localy with CURL on apache server?

I have an apache server with limited access to public. I have set the following line in it to avoid user call file directly:

<Directory /var/www/test>
Order deny,allow
Deny from all
<Files t.php>
Order allow,deny
Allow from all
</Files>
<Files test.wsgi>
Order allow,deny
Allow from "server ip"
</Files>
</Directory>

Now I just want to call the wsgi within server with my PHP file and avoid the user to call in directly.

I tried this code in my t.php but it returns nothing (white screen with test title):

<html><head><title>test</title></head>
<body>
<script language="php">
$ch = curl_init("server ip/test.wsgi/route");
ob_start();
curl_exec($ch);
curl_close($ch);
$retrievedhtml = ob_get_contents();
ob_end_clean();  
$bodyandend = stristr($retrievedhtml,"<body");
$positionendstartbodytag = strpos($bodyandend,">") + 1;
$temptofindposition=strtolower($bodyandend);
$positionendendbodytag=strpos($temptofindposition,"</body");
$grabbedbody=substr($bodyandend,
$positionendstartbodytag,
 $positionendendbodytag);
print("$grabbedbody");
</script>
</body></html> 
Ahad Porkar
  • 1,666
  • 2
  • 33
  • 68
  • 1
    what does `s.e.r.v.e.r.` stand for? is that 733t5p34k for something? – akira Aug 20 '13 at 11:51
  • If you call the python WSGI app from a browser or similar and it works then this is not a python question. – javex Aug 20 '13 at 12:25
  • @akira sorry for that , the Firewall (another department) change that word automatically on the fly.im fixing it. – Ahad Porkar Aug 20 '13 at 15:32
  • @javex its kinda python question too becuse im looking for all solution . like finding another python function to encrypt the original one and hide it from public user view. the php and curl is one solution i find out atm. – Ahad Porkar Aug 20 '13 at 15:33
  • @noob: just to clarify: you are aware that inside `t.php` you should enclose the php-part with something like ``? – akira Aug 20 '13 at 15:51
  • I think " – Ahad Porkar Aug 20 '13 at 15:59
  • @noob: That php tag is deprecated, as that link states. Doesn't hurt to use the recommended ``, this may be not working in your server. – Marcelo Assis Oct 18 '13 at 14:07

0 Answers0