thaond / magento-openerp-smile-synchro

Automatically exported from code.google.com/p/magento-openerp-smile-synchro
0 stars 0 forks source link

getallheaders() function #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I try to run the php in the browser and i get

Fatal error: Call to undefined function getallheaders() 
in /public_html/magento/app/code/community/Smile_OpenERP_Synchro/openerp-
synchro.php on line 220

getallheaders() function is not in the php file at all..

Original issue reported on code.google.com by twa8...@yahoo.com on 18 Sep 2008 at 8:39

GoogleCodeExporter commented 8 years ago
getallheaders is a php builtin and it works fine here. What version of php are 
you
running? It looks like you might need php4.3 or newer for it.

Original comment by nip...@gmail.com on 18 Sep 2008 at 1:50

GoogleCodeExporter commented 8 years ago
Im running PHP5 (FastCGI)....

Original comment by twa8...@yahoo.com on 18 Sep 2008 at 6:50

GoogleCodeExporter commented 8 years ago
sorry, no idea about that for now, will eventually ask to some PHP specialist at
Smile as soon as I can. Anyone?

Original comment by rva...@gmail.com on 18 Sep 2008 at 8:12

GoogleCodeExporter commented 8 years ago
The only thing I can suggest is post the output of phpinfo(). You must have some
difference in your configuration, possibly due to using fastcgi

Original comment by nip...@gmail.com on 19 Sep 2008 at 1:45

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
FOUND MY ANSWER:

According to the PHP documentation, when PHP is running as a CGI, the function 
getallheaders() is not available.

You can still get almost all server and environmental variables with the CGI 
version 
though. See phpinfo() to see which vars PHP has access to. Also see the list of 
predefined variables that PHP has access to. 

Original comment by twa8...@yahoo.com on 19 Sep 2008 at 8:10

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
And i found a fix. Just add this code right before the call to getallheaders

if (!function_exists('getallheaders')) {
function getallheaders() {
   foreach($_SERVER as $name => $value)
       if(substr($name, 0, 5) == 'HTTP_')
           $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', 
substr($name, 5)))))] = $value;
   return $headers;
}
}

This is probably something that could be added the code incase anyone else is 
running CGI???

Original comment by twa8...@yahoo.com on 19 Sep 2008 at 8:17

GoogleCodeExporter commented 8 years ago
Hi, thank you for the fix, I'll commit that patch, it sounds very reasonnable.
Actually, that getallheaders is just a dirty test to have the same PHP page be 
able
to either deal with an XML/RPC request or with a regular browser HTTP GET 
method so
anyone can ensure the connector as been installed at the right place, with the 
proper
PHP version and we can bootstrap Magento. So thank you.

Original comment by rva...@gmail.com on 19 Sep 2008 at 9:22

GoogleCodeExporter commented 8 years ago

Original comment by rva...@gmail.com on 19 Sep 2008 at 9:30

GoogleCodeExporter commented 8 years ago

Original comment by GrouhPamart on 26 Sep 2008 at 5:40