Mcrypt issue with PHP, Nginix, Ubuntu - php

I am working on an app where we are sharing login/session across the sub domains. To do this, we are generating some encrypted information but we are facing issue with mcrypt. Our code stuck on a point and never comes back unless the time out occurs.
To encrypt data we use following function
$cipher = new Cipher(env('CYPHER_KEY'));
return $cipher->encrypt($str);
And on encrypt function of Cipher class, the very first line is creating problem that is:
$iv = mcrypt_create_iv($this->iv_size);
This is a php function of mcrypt library. $this->iv_size contains 16. When execution comes to this line, it never comes back and it doesn't throw any error, exception in any log. It just stuck here unless ngnix throws time out error.
I am using Laravel 5.2 (Php5, php-fpm), ngnix and Ubuntu 14.04. I have already installed and enable mcrypt extension and I can see it when I do php -m.
Can any body please guide me what I am doing wrong here or how can I even get some error string to debug/fix.

Related

Some PHP Function Flagged as Error in VSCode

I am a beginner and am developing a specific web system using PHP 8.2, Codeigniter 4 and XAMPP in VSCode. However, in my Controller, some PHP functions are marked as errors, such as password_verify(), strpos() etc. After I run it, the program runs fine. Where is the error? Is it in the VS Code program?
The problem is:
Expected type 'string'. Found 'array|null'.intelephense(1006)
For additional information, I am using Intelephense PHP extension 1.9.2. I also opened the code in PHPStorm and the error is not there. Thank you for any provided information.
When I uninstalled / disabled the Intelephense PHP, of course the error was not found. Whe I use PHP IntelliSense, it's did not even mark the function as an error. However, when Intelephense was re-enabled the PHP function was still marked as an error.
I see that $request->getPost() has a signature of mixed|null.
And password_verify a a signature of string.
You can cast it to string and the warning will dissapear.
$password = (string) $this->request->getPost('password')

Javascript call to in-house PHP API returns error - net::ERR_CERT_DATE_INVALID

We have a PHP API that returns formatted postcodes from a (in this case) Ajax call from javascript.
We are running a windows 2019 server and did an upgrade to PHP8 and are now getting the error net::ERR_CERT_DATE_INVALID whenever we try to make the call to the API.
I have downloaded the latest cacert.pem file and added the following two lines to the php.ini:
curl.cainfo ="C:\Program Files\PHP\v8.0\ext\cacert.pem"
openssl.cafile="C:\Program Files\PHP\v8.0\ext\cacert.pem"
Now I am assuming that it is a PHP issue (as we upgraded to PHP8 over the weekend) but it could be something else and just a coincidence.
The issue can bee seen here: www.postcodetools.co.uk. Just attempt to use any of the examples and the console shows the error.
Any advice would be appreciated.
Revoked and re-issued and re-installed the certificate for the API domain and all now works.

Error Logging Into Magento 2: Open Source admin panel

SO I followed instructions here:
https://www.thecoachsmb.com/6-steps-to-install-magento2-4-2-on-xampp-windows-using-composer/
to install Magento 2 into a fresh install of xammppv3.3.0 running Php7. Once its time to get into the Admin account, It first said the information was incorrect or locked. I ran the commands
(php bin/magento admin:user:unlock <username>)
and
SET #salt = MD5(UNIX_TIMESTAMP());
UPDATE admin_user SET password = CONCAT(SHA2(CONCAT(#salt, 'NewP#ssword'), 256), ':', #salt, ':1') WHERE username = 'adminusername';
all commands came back successful. The I recieve the following:
Error processing your request
So i look into the log and see the following message:
main.CRITICAL: This is not implemented, as it is not possible to
implement Argon2i with acceptable performance in pure-PHP
{"report_id":"33485650bd9de85e8178e26a25bd0f1347c7c9d625b14c2b7167b732b909c9b0","exception":"[object]
(SodiumException(code: 0): This is not implemented, as it is not
possible to implement Argon2i with acceptable performance in pure-PHP
at
D:\xammp\htdocs\magento\vendor\paragonie\sodium_compat\src\Compat.php:1939)"}
[]
According to all searches ive done, this is due to sodium not being used in my PHP, but it is:
the ';' in front of sodium in my php.ini is removed, but I still cant get into magento admin. Any help?
If you are using PHP version 7.4 please switch to PHP version 7.3. For version 7.3 the stability will be higher with the versions of Magento (it is true for the current latest Magento versions)
Are you running php 7.4?
Also, you've removed the ";" from sodium in your php.ini, but have you got the extension installed in XAMPP?
Edit: apologies I've just spotted you have checked the extension is installed. Are you running PHP 7.4 or later?

CakePHP Migration Errors

I'm migrating my CakePHP site from a local Xampp installation to an EC2 ubuntu environment. I moved over the DB, and copied the web directory files over to the EC2 instance, but upon accessing the site I get this error:
Fatal error: Class 'AppController' not found in /var/www/cakephp/lib/Cake/Controller/CakeErrorController.php on line 31
I looked into the Apache error log and found that the piece it wasn't liking was this:
$this->Auth->user()['role']
The error said the PHP parser wasn't expecting the '['. This all worked fine in the default local Xampp install, so I'm assuming this is a PHP difference between the two installs?
Xampp: PHP 5.4.7
EC2: PHP 5.3.10
Any idea of any settings or anything that could cause this behavior?
That is a new feature in php 5.4 see http://docs.php.net/manual/en/migration54.new-features.php the third bullet item.
For php 5.3 you will need to assign it to a variable
$user = $this->Auth->user()
$role = $user['role'];

How to do a PHP Recompile? Imagecreatetruecolor error

As this is a new question I assume it's fine to create a new fresh question?
My previous question is here:
imageantialias call to undefined function error with GD installed
Markus helped me figure out the problem, I have since contacted the clients and set up a VPS for them, I have transferred the files and database and everything is running fine. Apart from the same error, only this time, I'm getting a different error;
Fatal error: Call to undefined function imagecreatetruecolor() in /home/public_html/admin/library/functions.php on line 232
I assume this is relating to the same thing and it required a php recompile? Could someone please give me some instructions on how to do a php recompile on Mac OS X, I tried the PHP docs but I can't seem to understand how it works.
Many Thanks!
Make sure you have the correct version of PHP and GD installed. From the PHP manual:
Depending on your PHP and GD versions
this function is defined or not. With
PHP 4.0.6 through 4.1.x this function
always exists if the GD module is
loaded, but calling it without GD2
being installed PHP will issue a fatal
error and exit. With PHP 4.2.x this
behaviour is different in issuing a
warning instead of an error. Other
versions only define this function, if
the correct GD version is installed.

Categories