fetch template function not handling httpuser httppass

From: Date: Thu, 08 Jan 2004 02:25:22 +0000
Subject: fetch template function not handling httpuser httppass
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10780@lists.php.net to get a copy of this message
Hi smarty-listers, I am trying to use the fetch template function plugin to access a Filemaker Pro database. The url format for a request to find a random record is like this: http://user:pass@domain:port/FMPro?-db=dbname&-format=-dso_xml&-findany When I drop this into the file param in the fetch template function I always get a "password invalid" error from Filemaker. {*fetch file="http://user:pass@domain:port/FMPro?-db=dbname&-format=-dso_xml&-findan y"*} However, I am able to get data using this format in a direct URL (in the address window of a browser) and also when I put the php code in a php block (via curl) like so: ____________________________________________________ {php} echo get_a_curl_page("http://domain:port/FMPro?-format=-dso_xml&-db=dbname.fp5&-f indany", "user", "pass"); function get_a_curl_page ($url, $user, $pass){ //make sure the curl function is available if(function_exists('curl_init')){ //set some variables to make curl //behave the way we need it to $agent = "pagecacher"; $referrer = "pagecacher_crawler_db_source"; //structure the userpass like curl wants it $userpass = $user . ":" . $pass; //initialize the curl connection $ch = curl_init($url); // tell curl how to process the forthcoming request // return the data instead of printing it to browser curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // tell the webserver what browser we are using curl_setopt($ch, CURLOPT_USERAGENT, $agent); // tell the webserver who referred this page curl_setopt($ch, CURLOPT_REFERER, $referrer); // set the user and password for realm (.htaccess) curl_setopt($ch, CURLOPT_USERPWD, $userpass); // follow redirects recursively, otherwise you // end up with a 301 error (at least on our server) curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); // store the returned data in a variable $tmp = curl_exec ($ch); // shut the connection curl_close ($ch); $ret = $tmp; }else{ // return message here $ret = "WARNING! curl not installed on this system. No page was retrieved from:" . $url; } return $ret; } {/php} ____________________________________________________ Is it possible that the socket code in the fetch plugin is confusing FMPro's authetication? I looked at it a bit but was unable to conclude anything because I have not used sockets in php before. When I try to access an unprotected database the fetch code works just fine! It is only when I ask it to access protected resources that it fails. Could it be that the authentication needs a "redirect" and fetch plugin doesn't do redirects? Any insight appreciated. Ideally, I'd like to be able to use the fetch plugin as it streamlines the code and makes it so I don't have to use the php block in a template that designers will see. I am happy to test out some patches to the fetch plugin if someone could give me a quick headstart as to what I should try to do to get it to work with my FMPro server. Thanks! dan

« previous php.smarty.general (#10780) next »