Call to undefined function filter_var() - php

After transfering my site to another hosting i got this error:
Fatal error: Call to undefined function filter_var() in
/home/ultrastep/ultrastep.ru/docs/sites/all/modules/q_cart/q_cart.module on line 410
PHP version on server is 5.2.10.
Any ideas whats wrong?

You need to have the php module "Filter" installed

In case someone else stumbles upon this like I did, here is the solution I found for Redhat/CentOS:
http://www.cyberciti.biz/faq/rhel-cento-linux-install-php-pecl-filter/
Install php-devel
You need to install php-devel to compile php extensions:
yum install php-devel
Download php source code
php_pcre.h header file is not includes with php source code 5.1.6, so you need php source code as well. Visit php.net to grab latest version and store to /opt directory. Use lynx and elinks:
cd /opt
elinks http://www.php.net/get/php-5.2.6.tar.bz2/from/a/mirror
Save php source to code to disk. Next, extract source code:
tar -jxvf php-5.2.6.tar.bz2
Download filter extension
Visit pecl extension to grab latest source code for filter:
cd /opt
wget http://pecl.php.net/get/filter-0.11.0.tgz
Install filter extension
Unrar file:
tar -jxvf filter-0.11.0.tgz
cd filter-0.11.0
Open logical_filters.c file:
vi logical_filters.c
Find line that read as follows:
include "ext/pcre/php_pcre.h"
Change to (the absolute path of php_pcre.h is required):
include "/opt/php-5.2.6/ext/pcre/php_pcre.h"
Save and close the file. Finally, type the following commands to compile extension:
phpize
./configure
make install
Configure Filter Extension
Type the following command:
echo 'extension=filter.so' > /etc/php.d/filter.ini
Restart httpd:
service httpd restart

Related

Failed-loading xdebug installation - xdebug.so, 9 no suitable image found

After installing xdebug extentions as follows
Download xdebug-2.6.0alpha1.tgz
Unpack the downloaded file
Run: cd xdebug-2.6.0alpha1
Run: phpize
Run: ./configure
Run: make
Run: cp modules/xdebug.so
/usr/local/Cellar/php70/7.0.26_18/lib/php/extensions/no-debug-non-zts-20151012
Edit /usr/local/etc/php/7.0/php.ini and add the line zend_extension =
/usr/local/Cellar/php70/7.0.26_18/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so
I get the error when run php -v
Failed loading /usr/local/Cellar/php70/7.0.26_18/lib/php/extensions
/no-debug-non-zts-20151012/xdebug.so:
dlopen(/usr/local/Cellar/php70/7.0.26_18/lib/php/extensions
/no-debug-non-zts-20151012/xdebug.so, 9): no suitable image found.
Did find:
/usr/local/Cellar/php70/7.0.26_18/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so:
stat() failed with errno=20
When I use the service of Xdebug analyse popinfo() output, it will ask the exactly the same steps to do.
It am not sure what no suitable image found means. The path exists. Could anyone have any ideas how to fix it?
I sorted the problem out by adding
export PATH="$(brew --prefix homebrew/php/php70)/bin:$PATH"
on .bash_profile.
PHP 7.1 came with OSX 10.13.2, so default path was set to the pre-packed php, which shows the error on phpinfo.

PHP openssl in Ubuntu

I have created a web app which uses PHPMailer for mailing and its working properly on my local server(Windows OS). However, when I uploaded it to the production server(Ubuntu 14.04.4) it returned an error which says “Message could not be sent.Mailer Error: Extension missing: openssl”.I tried looking for solution but nothing works. Anyway I'm using PHP5.3.6. I hope you guys can help me.
You can compile the openssl extension.
first step :
download the php source in the version you are using .
then run command:
tar zxvf php-yourphpversion.tar.gz
cd php-yourphpversion/ext/openssl/
#notice if you have error "cannot find config.m4" when run phpize , you
#should rename the file "config0.m4" to "config.m4" by command
#"mv config0.m4 config.m4"
/usr/local/php/bin/phpize #here is your php location have install
#in my computer ,the php is location in
# /usr/local/php/ so the phpize is in
# /usr/local/php/bin/phpize
#(your php location)/bin/php-config
./configure --with-openssl --with-php-config=/usr/local/php/bin/php-config
make
sudo make install
then the openssl will install and return a path
in my computer it return /usr/local/php/lib/php/extensions/debug-zts-20160303/
finally modify php.ini and restart php-fpm :
extension_dir = "the path return after install" #you should add the return path here
extension=openssl.so

PHP unable to load dynamic library

I'm trying to install libinjection from here
I'm trying to install the PHP module but I'm getting this error after make, make install, make test:
2/libinjection.so - /usr/lib/php5/20121212/libinjection.so: cannot
open shared object file: No such file or directory in Unknown on line
0 PHP Notice: Use of undefined constant LIBINJECTION_VERSION -
assumed 'LIBINJECTION_VERSION' in
/home/mohammed/libinjection/php/example.php on line 6
Using libinjection LIBINJECTION_VERSION PHP Fatal error: Call to undefined function new_libinjection_sqli_state() in
/home/mohammed/libinjection/php/example.php on line 9
In php.ini I added
extension=libinjection.so but I'm still getting the error.
Any advice?
Based on the error message
/usr/lib/php5/20121212/libinjection.so: cannot open shared object
file: No such file or directory
When you ran make install it did not install the extension to the path where PHP is looking for it.
Find where it installed the extension to, and copy libinjection.so to /usr/lib/php5/20121212 and then restart the web server (Apache, nginx etc) and try running your code again.
To build an extension in PHP,
you first need to run scripts/phpize in the PHP folder,
and ./configure with a prefix to find the correct folder.
Simply using ./configure && make && make install is not enough.
chmod +x /usr/local/src/php-5.6.9/scripts/phpize
/usr/local/src/php-5.6.9/scripts/phpize
./configure --prefix /usr/local/src/php-5.6.9 \
--with-libdir=/lib/x86_64-linux-gnu \
Use ./configure --help to get available options.

"Cannot find config.m4." while running phpize in the installation of apd using pecl

I'm trying to get access to rename_function in PHP, and for that I need PECL APD. I'm running Ubuntu 14.04 LTS.
I'm trying to run sudo pecl install apd, but I'm getting:
downloading apd-1.0.1.tgz ...
Starting to download apd-1.0.1.tgz (36,643 bytes)
..........done: 36,643 bytes
15 source files, building
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of
the module
If the command failed with 'phpize: not found' then you need to install php5-dev package. You can do it by running 'apt-get install php5-dev' as a root userERROR: `phpize' failed
Should I be running this command from a certain directory?
This time I tried it with verbose options turned on, in case there is a clue in the logs:
sudo /usr/bin/pecl -vvvvv install apd
Warning: file_exists(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1518
Warning: is_file(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1528
Warning: is_file(): Unable to find the wrapper "channel" - did you forget to enable it when you configured PHP? in PEAR/Downloader/Package.php on line 1528
Downloading "http://pecl.php.net/get/apd-1.0.1.tgz"
downloading apd-1.0.1.tgz ...
Starting to download apd-1.0.1.tgz (36,643 bytes)
..........done: 36,643 bytes
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/LICENSE /usr/share/php/doc/apd/.tmpLICENSE
adding to transaction: chmod 664 /usr/share/php/doc/apd/.tmpLICENSE
adding to transaction: rename /usr/share/php/doc/apd/.tmpLICENSE /usr/share/php/doc/apd/LICENSE
adding to transaction: installed_as LICENSE /usr/share/php/doc/apd/LICENSE /usr/share/php/doc /apd
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/README /usr/share/php/doc/apd/.tmpREADME
adding to transaction: chmod 664 /usr/share/php/doc/apd/.tmpREADME
adding to transaction: rename /usr/share/php/doc/apd/.tmpREADME /usr/share/php/doc/apd/README
adding to transaction: installed_as README /usr/share/php/doc/apd/README /usr/share/php/doc /apd
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/pprofp /usr/bin/.tmppprofp
+ chmod +x /usr/bin/.tmppprofp
adding to transaction: chmod 775 /usr/bin/.tmppprofp
adding to transaction: rename /usr/bin/.tmppprofp /usr/bin/pprofp
adding to transaction: installed_as pprofp /usr/bin/pprofp /usr/bin /
+ cp /tmp/pear/temp/tmpNUpEpz/apd-1.0.1/pprof2calltree /usr/bin/.tmppprof2calltree
+ chmod +x /usr/bin/.tmppprof2calltree
adding to transaction: chmod 775 /usr/bin/.tmppprof2calltree
adding to transaction: rename /usr/bin/.tmppprof2calltree /usr/bin/pprof2calltree
adding to transaction: installed_as pprof2calltree /usr/bin/pprof2calltree /usr/bin /
15 source files, building
building in /tmp/pear/temp/pearf7LGca
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module
If the command failed with 'phpize: not found' then you need to install php5-dev packageYou can do it by running 'apt-get install php5-dev' as a root userrolling back 12 file operations
+ rm /usr/share/php/doc/apd/.tmpLICENSE
+ rm /usr/share/php/doc/apd/.tmpREADME
+ rm /usr/bin/.tmppprofp
+ rm /usr/bin/.tmppprof2calltree
ERROR: `phpize' failed
Warning: unlink(/tmp/glibctestRdKE0K): No such file or directory in System.php on line 214
Warning: unlink(/tmp/pear/temp/pearf7LGca): No such file or directory in System.php on line 214
This will be a short summary of everything to is a precondition to run APD as a PHP profiler, I hope it will help your needs. This summary applies for PHP 5.6.2 APD 1.0.1 and might be incorrect for other versions.
First of all do not start it if you didn't ensure these two:
Deactivate Zend platform or any other PHP optimizer. In general you need to disable all Zend extensions.
Install a debugging enabled version of PHP (--enable-debug)
If you have a working PEAR setup you need to setup APD like in this article. Don't forget to try out distribution packages either. Otherwise APD's build as following:
Extract tarball.
Change directory in tarball.
Run <apache root>/bin/phpsize
Run ./configure (Add --with-php-config=<apache root>/bin/php-config if configure fails.)
Compile and install everything using
make
make install
Edit php.ini and add at least
zend_extension=/apd.so
apd.statement=1
apd.tracedir=/tmp/apd-traces
Create the output directory specified in php.ini
Now you'll need to restart Apache but before you do, check that the APD extension works fine. To do simply run PHP
/bin/php
No warning should be given if extension is loaded properly. If you get error message something like the "apd.so" extension couldn't be loaded there is a problem. Check if you compiled against the correct Apache/PHP version and using the same right now.
If PHP doesn't complain about anything enter:
<?php phpinfo(); ?>
and check for some lines about APD. If you find them you are done.
You'll also need some traces so to start tracing you need to your Apache to allow the PHP module to load APD. Next you'll need to identify the script to trace. Add the APD call at the top of the script:
apd_set_pprof_trace();
Then make some requests and remove the statement again to avoid causing further harm.
Now have a look at the trace directory. You should find files with a naming scheme of pprof[0-9]*.[0-9] here. Decode them using the pprofp tool from your APD source tarball. Example:
/bin/php /pprofp -u
Redirect stdout if necessary. Use -t instead of -u (summary output) to get calling trees. When you create traces with -t you get a summary output too, but it doesn't contain the per-call durations. I suggest to always create both a call tree and a summary trace.
Hope that helps, I recommend you hardly to read the link mentioned above.
EDIT:
The phpize command is meant to be run at the top level of an extension source dir (this source dir should contain a file name config.m4). See this for more info.
As per error:
If the command failed with phpize: not found then you need to install php5-dev package.
You can do it by running apt-get install php5-dev as a root user
I think you should install module development for PHP via:
sudo apt-get install php5-dev
This should provide you with phpize binary necessary to compile the Pecl extension sources. And make sure it's in your PATH.

phpize reports "Cannot find config.m4"

I am trying to run the 'phpize' command on MacOSx Mountain Lion, but this is what I get:
Cannot find config.m4.
Make sure that you run '/opt/local/bin/phpize' in the top level source directory of the module
How do I resolve this error ?
The phpize command is meant to be run at the top level of an extension source dir (this source dir should contain a file name config.m4).
See http://php.net/manual/en/install.pecl.phpize.php for more information.
In plain English, it means you're running the command from the wrong directory. You need to be in the directory that contains the source for the extension you're trying to install.
For example, if you're trying to install mcrypt, like I was when I came across this stack overflow page, you need to be in php-5.6.24/ext/mcrypt and then run the command.
My problem was that I was trying to execute the command just to see if I had it installed.
Trying to execute the command alone gives you that error, only use it inside the directory (most likely you downloaded) that contains the extension that you're trying to install.
Here some instructions to install Xdebug for php7.2 for example.
Take special care in step 3 and 4, first you change dir to the unpacked downloaded extension and then you run phpize.
http://qiita.com/MasatoYoshioka#github/items/e542f39a6f1a3bc1f71e
In terminal
ls config.m4
ls config*
config.w32 config0.m4
cp config0.m4 config.m4
cd /usr/local/src/php-5.3.29/ext/zlib
phpize
./configure
make clean && make && make install
nano php.ini
add extension=zlib.so
got inside the xdebug folder than try to run the phpize
Sometimes, using the pecl installer is not an option. This could be because you're behind a firewall, or it could be because the extension you want to install is not available as a PECL compatible package, such as unreleased extensions from git. If you need to build such an extension, you can use the lower-level build tools to perform the build manually.
The phpize command is used to prepare the build environment for a PHP extension. In the following sample, the sources for an extension are in a directory named extname:
$ cd extname
$ phpize
$ ./configure
$ make
# make install
first run ./configure it will create config.m4 file, rest the steps are same

Categories