getting Error "undefined function mcrypt_create_iv()" in php 7.2 In Codeigniter - codeigniter-3

I am getting below error
ERROR - 2018-10-01 12:05:23 --> Severity: error --> Exception: Call to undefined function mcrypt_create_iv() /var/www/html/application/controllers/api.php 331
deploying app on AWS EC2 ubuntu 16( Php 7.2, Nginx, codeigniter 3.1.9)

mcrypt is removed from php7.2. can not use in PHP 7.2. i have created new function and added in common helper.
if (!function_exists('mcrypt_create_iv')) {
function mcrypt_create_iv($length) {
return openssl_random_pseudo_bytes($length, NULL);
}
}
might be helpful to other users.

install mcrypt
sudo apt-get install php7.2-mcrypt
sudo systemctl restart nginx.service

This polyfill is useful for backwards compatibility w/ mcrypt on PHP 7.3:
https://github.com/phpseclib/mcrypt_compat

Related

undefined symbol: GTIFGetGCSInfoEx

In Progress 11 When I am trying to create a Postgis extension I encounter this error.
My environment is CentOS 8, with Postgress11-server, postgis25_11 and gdal-3.0.4-5.el8.x86_64
ERROR: could not load library "/usr/pgsql-11/lib/rtpostgis-2.5.so": /usr/gdal31/lib/libgdal.so.27: undefined symbol: GTIFGetGCSInfoEx
Any idea what might cause this error?
FYI, both of the library libgdal.so.27 and rtpostgis-2.5.so exist in the path above.
By default Centos 8 will install libgeotiff15, which doesn't expose that symbol - You need to use libgeotiff16.
update to 1.6.0:
Add support for OGC GeoTIFF 1.1
Expose GTIFGetPCSInfoEx(), GTIFGetProjTRFInfoEx(), GTIFGetGCSInfoEx(), GTIFGetDatumInfoEx(), GTIFGetEllipsoidInfoEx(), GTIFGetPMInfoEx(), GTIFGetUOMLengthInfoEx() and GTIFGetUOMAngleInfoEx() so that users can specify their own PROJ context
Just spent a whole day on this same ordeal. Hope you manage!
Quick and dirty:
sudo dnf --enablerepo=PowerTools install -y postgresql11-server postgresql11-contrib postgresql11-devel libgeotiff16 postgis25_11

undefined function TYPO3\CMS\IndexedSearch\mb_strcut()

I'm trying to create a webpage using TYPO3 8.7, but when i go to Localhost/index.php it says "Oops an error has occured".
The only way i can see my webpage, is through the TYPO3 backend login apperently.
This is the error that it logs in the backend of TYPO3:
>
Core: Exception handler (WEB): Uncaught TYPO3 Exception: Call to undefined >function TYPO3\CMS\IndexedSearch\mb_strcut() | Error thrown in file >/var/www/html/typo3_src-8.7.0/typo3/sysext/indexed_search/Classes/Indexer.php in >line 1314. Requested URL: Localhost/index.php
And my line 1314 is this:
$bodyDescription = mb_strcut($bodyDescription, 0, $maxL, 'utf-8');
I'm very new to this. So far i've been able to sort all bugs with the help from these forums and others, but unfortunately I can't find any solution to this one.
Any help is greatly appreciated.
Let me know if i need to provide some additionel information.
This error means that mbstring php extension is not enabled. You should install it, if you have Ubuntu you should execute
sudo apt-get install php-mbstring
Read more about installation of this PHP extension here

Problems importing with Mongodb: fatal error: MSpanList_Insert

I'm running into a fatal error when I'm trying to import using Mongodb 3.3.9. My script has worked before, but when I upgraded my Mac os to Sierra, I'm running into what looks like a Go language problem.
Error received :
fatal error: MSpanList_Insert
runtime stack: runtime.MSpanList_Insert(0x491d30, 0x54daf0)
/usr/local/go/src/runtime/mheap.c:692 +0x8f
runtime.MHeap_Alloc(0x491cc0, 0x2, 0x10000000026, 0xdbc9)
/usr/local/go/src/runtime/mheap.c:240 +0x66
runtime.MCentral_CacheSpan(0x49b0b8, 0x34872)
/usr/local/go/src/runtime/mcentral.c:85 +0x167
runtime.MCache_Refill(0x527c20, 0xc200000026, 0x5550b8)
/usr/local/go/src/runtime/mcache.c:90 +0xa0
Others have noted a similar problem that was supposed to be resolved in an earlier version (mongorestore random crash (fatal error)), but my problem persists.
As the comments suggested, it's solved reinstalling mongo. If you install it using brew execute: brew uninstall mongo.
If you just followed the steps in their tutorial, just delete the executable. If you don't know how, follow this:
which mongo
#now you have a path
rm -rf yourMongoPath
sudo launchctl unload /System/Library/LaunchDaemons/org.ntp.ntpd.plist
worked for me

PDOException' with message 'could not find driver'

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in /home/kholifah/htdocs/cechcalk.ck/userAuth.php:22 Stack trace: #0 /home/kholifah/htdocs/cechcalk.ck/userAuth.php(22): PDO->__construct('?????pgsql:dbna...') #1 {main} thrown in /home/kholifah/htdocs/cechcalk.ck/userAuth.php on line 22
It looks like you are missing module called pdo_pgsql.
Look in your php.ini for a line extension=php_pdo_pgsql.dll. It should be uncommented.
On Ubuntu or other linux distribution you can install PDO driver with something like
apt-get install php5-pgsql.
I was also facing this problem into xampp now its works for me, May be it will helpful to you also in linux platform lamp or latest version of Php 5.6 - 7.
Just uncomment these lines from php.ini file
extension=pdo_pgsql
extension=pgsql
Example from my php.ini file
The earliest answers forgot to mention that you need to restart some services after enabling the following in php.ini file:
extension=pdo_pgsql
extension=pgsql
You need to restart your web server, in my case my using nginx, so I do
sudo systemctl restart nginx.service
After that I restart php-fpm using:
sudo systemctl restart php-fpm.service
Thats All...cheers

PHP Fatal error: Class 'MongoDate' not found

I use lithium console (lithium/console/li3) to run some command and I get this error:
PHP Fatal error: Class 'MongoDate' not found
My system details:
mongodb server: 2.6.1
php mongodb client: 1.5.2
apache 2.4.7
php 5.5.9-1ubuntu4
$Requests = Requests::find('all', array('conditions'=>array(
'expired'=>array('<'=>new \MongoDate(time())),
'processed'=>0
)));
I don't have this error while running this code in older version system
PHP Version 5.3.10-1ubuntu3.11
Apache/2.2.22 (Ubuntu) Server
mongodb client: 1.4.5
mongodb server: 2.4.10
Thank you.
One more thing: I try to create just a simple script
$date = new MongoDate();
it runs without problem via webserver (browser) but if I use php command to run this file, I get the same error: Class 'MongoDate' not found
So I believe that it's php command problem.
For people that have come here using PHP7, the classs has been renamed:
MongoDate is now MongoDB\BSON\UTCDateTime
Also I've found that this now wants miliseconds instead of seconds, so make sure you multiple your input by 1000, for example:
$date = new \MongoDB\BSON\UTCDateTime(strtotime('yesterday') * 1000);
Make sure your mongodb extension is loaded.
var_dump(extension_loaded('mongodb'));
If not, you must load it in php.ini.