http.so loaded but http_get undefined - php

I have LAMP installed on my linux distribution:
///
PHP 5.4.9-4ubuntu2.4 (cli) (built: Dec 12 2013 04:29:20)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
///
In order to use http_get from pecl_http php extension I have explicitly installed it and added the http.so extension to php.ini.
Now I am in the following scenario. Using the simple php code below:
echo var_dump(extension_loaded("http"));
echo var_dump(extension_loaded("raphf"));
echo var_dump(extension_loaded("propro"));
echo var_dump(function_exists("http_get"));
$response = http_get("www.google.com");
echo $response;
I got the following results:
///
boolean true
boolean true
boolean true
**boolean false**
I am not sure why extension_loaded("http") returns true but function_exists("http_get") returns false, so I cannot use the function http_get without getting the following in the Apache log file
"[Tue Dec 31 12:32:26 2013] [error] [client 127.0.0.1] PHP Fatal error: Call to undefined function http_get() in /home/user/main.php on line 32"
Could you please help me troubleshooting this?
(same issue using the console interactive mode php -a)
phpinfo() shows:
///
http
HTTP Support enabled
Extension Version 2.0.3
Used Library Compiled Linked
libz 1.2.7 1.2.7
libcurl 7.29.0 7.29.0
libevent disabled disabled
Directive Local Value Master Value
http.etag.mode crc32b crc32b
///
Thanks

As Michael Berkowski says, the 2.x branch is totally new and it works with a different API.
You can go with the 1.x branch and use the old functions this way:
pecl uninstal pecl_http
pecl install pecl_http-1.7.6
Then you can use http_get
Anyway, if this is a fresh new project, it is recommended to go with the newest API.

Just to elaborate slightly on Alex's answer, unless I missed something, the Php Manuel doesn't really reflect how this extension has changed. And the link in the comment on your question doesn't seem to work anymore. I think what you want now, to get that same behavior, is http\Client::send().

Related

PHP: shell_exec is neither Defined nor disabled

Well, I know there are already lots of related questions but non of them address my issue.
In my case, I want to use the shell_exec function but, I see that the shell_exec function is not defined and not even mentioned in the disable_functions list in php.ini.
here is the php.ini snippet
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names.
; http://php.net/disable-functions
disable_functions =
; This directive allows you to disable certain classes for security reasons.
; It receives a comma-delimited list of class names.
; http://php.net/disable-classes
disable_classes =
and here is how I'm using the function
if(!function_exists('shell_exec')) {
die("shell_exec is not found");
}
NOTE: I'm using Linux version CentOS release 6.9 (Final) and php -v outputs as follow
ea-php-cli Copyright 2017 cPanel, Inc.
PHP 7.0.28 (cli) (built: Mar 6 2018 09:27:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.28, Copyright (c) 1999-2017, by Zend Technologies
Your help is highly appreciated.
Ok, I was using PHP-FPM that added the following line to the configuration of each domain at /opt/cpanel/ea-php70/root/etc/php-fpm.d/
php_admin_value[disable_functions] = exec,passthru,shell_exec,system
So, this is what I did to make the shell_exec function available to use
mkdir /var/cpanel/ApachePHPFPM
echo "php_admin_value_disable_functions : exec,passthru,system">/var/cpanel/ApachePHPFPM/system_pool_defaults.yaml
/scripts/php_fpm_config --rebuild
and at the end restarted the PHP-FPM from WHM, and that's it.

Fatal error: Class 'COM' not found PHP. Win7 - Apache - PHP

$myapp = new COM("word.application");
// returns a fatal error: "Class 'COM' not found in c:/www/comConnector.php"
shell_exec("whoami");
//returns "NT authority/system"
My system setup
Win7 Pro
Apache Server version: Apache/2.2.23 (Win32)
PHP
PHP 5.3.16 (cli) (built: Aug 15 2012 20:06:57)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
Add COM support in php.ini:
[COM_DOT_NET]
extension=php_com_dotnet.dll
Since you are using PHP 5.3.16, make sure that you are pointing to the global namespace:
$myapp = new \COM("word.application");
Even though your PHP file might be in global namespace already, but it's a good practice.

Apache segfault by cakePHP website

Without any -apparent- reasons, one of my cakePHP websites (v1.3.11) has stopped working (showing a "no data received" page in chrome - error 324) but the other is still fine -for the moment at least-.
/var/log/apache2/error.log shows a [notice] child pid 8502 exit signal Segmentation fault (11)
and /var/log/messages shows kernel: [15482058.932226] apache2[8502]: segfault at 7fff7f14fb58 ip 7f1b9d886e55 sp 7fff7f14fb60 error 6 in libphp5.so[7f1b9d576000+588000]
Here's my php -v
PHP 5.2.6-1+lenny13 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 1 2011 16:01:01)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
I absolutely have no idea on what heppened, so any idea is welcome.
EDIT:
It looks like the render() function in the /cake/libs/controller/controller.php is doing an infinite loop. Any ideas why this is happening? (it's happening on all the pages of the website and no code has changed lately...)
I had the same issue with cakephp 2.2.1.
I've resolved the issue by adding flush() in App.php's load function.
public static function load($className) {
if (!isset(self::$_classMap[$className])) {
return false;
}
flush();
...
I just downgraded my framework to what it was before thanks to a backup of those files I've done just before the updated and everything's fine now again.
Maybe something was wrong during the upload or something is not compatible with the latest version of the framework. I'll do some tests later about it and I'll comment on this "solution".
on core.php
Configure::write('debug',0);
I wonder if this might be regression in the last security update of Debian. I get very similar errors as you have, but we are not running cake. If we can confirm this, we should file a bug at Debian.
/var/log/messages[39144630.700032] apache2[13693]: segfault at 7fffff7fdfb8 ip 7f5195606a6a sp 7fffff7fdf50 error 6 in libphp5.so[7f519535c000+588000]
/var/log/apache2/error.log[error] child died with signal 11
$ php -v
PHP 5.2.6-1+lenny13 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 1 2011 16:01:01)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
FYI I had the same problem today. Turning off debug kit solved it for me
I suddenly got this problem after I added post editing to the blog tutorial on a local virtual host.
For me, this problem went away when I went back through my files and found a syntax mistake. Once I fixed the syntax, it worked just fine.
For what it's worth, turning off DebugKit solved this problem for me in CakePHP 2.3.5. Except for adding DebugKit, the CakePHP installation is completely fresh. I got the same error 324 in Chrome as mentioned in the original post.

Segmentation Fault error in PHP, using SOAP to connect to SalesForce

I'm integrating my software (PHP) with SalesForce, using the SalesForce PHP Toolkit.
So far, everything's worked great, but when I started writing the code to call convertLead(), I got a "Segmentation Fault" error.
This is the code I'm running:
require_once('../salesforce/SforceEnterpriseClient.php');
ini_set('soap.wsdl_cache_enabled', 0);
$SForce = new SforceEnterpriseClient();
$result = $SForce->createConnection('../salesforce/enterprise.wsdl.xml');
$result = $SForce->login('user', 'pass+token');
echo "Logged In!";
$data = array(
'convertedStatus' => 'Converted',
'leadId' => '00QC000000mDcmJMAS'
);
$result = $SForce->convertLead(array($data));
That's it. And i'm getting a Segmentation Fault. I tried using StdClass instead of a keyed array, same thing. The convertLead method in the SF toolkit is really simple, it just calls the same method into a SoapClient instance...
NOTE: I'm running this script from the CLI, not through Apache.
UPDATE: Just tried running "strace" with my script. The last lines of it are:
close(4) = 0
write(1, "Logged IN!", 10Logged IN!) = 10
open("error_log", O_WRONLY|O_CREAT|O_APPEND, 0644) = 4
--- SIGSEGV (Segmentation fault) # 0 (0) ---
+++ killed by SIGSEGV +++
Also, in case it's relevant:
php --version
PHP 5.2.13 (cli) (built: Jul 17 2010 22:01:13)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with the ionCube PHP Loader v3.3.20, Copyright (c) 2002-2010, by ionCube Ltd., and
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies
This also happens in my dev machine (Windows), so I doubt it's the Accelerators or anything like that:
php --version
PHP 5.2.13 (cli) (built: Feb 24 2010 14:37:44)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
This may or may not be specific to SalesForce. Probably not, seems like a bug in the SOAP PHP library. Maybe the request/response are broken, but I can't see those because they're HTTPS.
Any ideas how I can go about diagnosing (or more importantly, working around) this issue?
Thank!
Daniel
There is a bug (still after 4 years) in the PHP soap extension. It has to do with how it handles WSDL caching. Disabling caching with ini_set() does not work. You also need to turn off caching for your particular client instance.
return new SforceEnterpriseClient('../salesforce/enterprise.wsdl.xml', array(
'cache_wsdl' => WSDL_CACHE_NONE
));
This is true even when using the native PHP SoapClient class.
Ok, this doesn't solve the underlying issue, but, in case someone got this same problem with SalesForce and PHP...
Despite what the documentation implies, fields SendNotificationEmail and OverwriteLeadSource ARE MANDATORY, you MUST specify them in the call.
Not doing so should give you a nice error, not a SegFault, but still, that solves it.

strange behaviour of php session

im using php a server, that uses ubuntu 8.04 :
PHP 5.2.4-2ubuntu5.12 with Suhosin-Patch 0.9.6.2 (cli) (built: Sep 20 2010 13:33:05)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
i found a strange behaviour:
<?php
session_name('session');
session_start();
$_SESSION['username']='realName';
$username='otherName';
?>
this leads to, that php saves in the session variable 'otherName' (instead of 'realName'). why is php saving the $username into the session variables? How can i disable this?
thanks in advance for any help... :)
It looks like you have register_globals = on in your php.ini. This option has been deprecated as of PHP 5.3 and you should turn it off. More information can be found here: http://www.php.net/manual/en/security.globals.php

Categories