Post by sealvideo » Thu Mar 28, 2019 4:56 am

Currently working with php 5.6 using opencart 1.5.6.4 But I NEED TO CHANGE TO PHP 7.2 OR 7.3 but keep getting blank screen when I change my opencart 1.5.6.4 to either PHP 7.2 or 7.3.

I have tried various Changes to encryption.php codes as follows:

<?php
final class Encryption {

private $cipher = 'aes-256-ctr';
private $digest = 'sha256';
private $key;

public function __construct($key) {
$this->key = $key;
}

public function encrypt($value) {
$key = openssl_digest($this->key, $this->digest, true);
$iv_length = openssl_cipher_iv_length($this->cipher);
$iv = openssl_random_pseudo_bytes($iv_length);
return base64_encode($iv . openssl_encrypt($value, $this->cipher, $key, OPENSSL_RAW_DATA, $iv));
}

public function decrypt($value) {
$key = openssl_digest($this->key, $this->digest, true);
$iv_length = openssl_cipher_iv_length($this->cipher);
$value = base64_decode($value);
$iv = substr($value, 0, $iv_length);
$value = substr($value, $iv_length);
return openssl_decrypt($value, $this->cipher, $key, OPENSSL_RAW_DATA, $iv);
}
}


Also ----------------------------------------------------------------------------------------------------------------------------------------------------------

<?php
final class Encryption {
private $key;

public function __construct($key) {
$this->key = $key;
}

public function encrypt($value) {
if (function_exists('sodium_crypto_secretbox')) {
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);

return strtr(base64_encode($nonce . sodium_crypto_secretbox($value, $nonce, hash('sha256', $this->key, true))), '+/=', '-_,');
} else {
return strtr(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, hash('sha256', $this->key, true), $value, MCRYPT_MODE_ECB)), '+/=', '-_,');
}
}

public function decrypt($value) {
if (function_exists('sodium_crypto_secretbox')) {
$raw_value = base64_decode(strtr($value, '-_,', '+/='));

$nonce = substr($raw_value, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);

return trim(sodium_crypto_secretbox_open(substr($raw_value, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES), $nonce, hash('sha256', $this->key, true)));
} else {
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, hash('sha256', $this->key, true), base64_decode(strtr($value, '-_,', '+/=')), MCRYPT_MODE_ECB));
}
}
}
?>

But no joy, can anyone help, it would be appreciated !! Am I missing something else I need to do?
Last edited by sealvideo on Thu Mar 28, 2019 11:25 am, edited 1 time in total.

Newbie

Posts

Joined
Sat Sep 06, 2014 4:07 am

Post by IP_CAM » Thu Mar 28, 2019 8:12 am

Did you switch to mysqli already ?
And try this one:

Code: Select all

<?php
final class Encryption {
	public function encrypt($key, $value) {
		// Remove the base64 encoding from our key
		$encryption_key = base64_decode($value);
		
		// Generate an initialization vector		
		$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-gcm'));
		
		// Encrypt the data using AES 256 encryption in GCM mode using our encryption key and initialization vector.
		if (in_array('aes-256-gcm', openssl_get_cipher_methods())) {
		    $tag = base64_encode($iv);
		    
		    $encrypted = openssl_encrypt($key, 'aes-256-gcm', $encryption_key, 0, $iv, $tag);		   
		    
		    // The $iv is just as important as the key for decrypting, so save it with our encrypted data using a unique separator (::)		
		    return base64_encode($encrypted . '::' . $iv);
		}
	}
	
	public function decrypt($key, $value) {
	       if (in_array('aes-256-gcm', openssl_get_cipher_methods())) {
		    // Remove the base64 encoding from our key
		    $encryption_key = base64_decode($value);
		
  		    // To decrypt, split the encrypted data from our IV - our unique separator used was "::"
		    list($encrypted_data, $iv) = explode('::', base64_decode($key), 2);
		    
		    $tag = base64_decode($iv);
		    
		    return openssl_decrypt($encrypted_data, 'aes-256-gcm', $encryption_key, 0, $iv, $tag);
	      }
       }
}
?>

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by sealvideo » Thu Mar 28, 2019 9:09 am

Hi thanks for your reply:

How do I switch from mysql to mysqli in opencart?
Do I need to change to mysqli?
My Server Database Type MySQL (Standard)
Plus tried your code and the same result, just blank white screen for website ON PHP 7.2

Regards

Newbie

Posts

Joined
Sat Sep 06, 2014 4:07 am

Post by IP_CAM » Thu Mar 28, 2019 10:26 am

Do I need to change to mysqli?
Yes, mysql is no longer existing + valid on modern Servers.
In both config.php Files, change:

Code: Select all

// DB
define('DB_DRIVER', 'mysql');
TO:

Code: Select all

// DB
define('DB_DRIVER', 'mysqli');
and that's it.
And if it still does not work, you have to remove your VqMods,
except for the vqmod_opencart.xml itself, to find out,
if one of them plays some role, to eventually keep your Site
from working.
HOWEVER, better download the latest v.1.5.6.5_rc Version first,
and use this one instead of yours, it only contains about 25 fixes,
to fix problems, found after the v.1.5.6.4 was released, but everything
else is still the same Code as 1.5.6.4 !Just overwrite all existing OC Files
on the Server with the new Code, exept for the Shop config.php
files, it should not do any harm. (If you never manually modified OC Source! :crazy: )

And you also need to use the PHP-7 encryption.php file, as placed
above, to make it work with PHP7.2x at least. (I don't know about PHP 7.3 ,
since it is not available yet on my Server! But PHP 7.2x will stay for a while,
so, I would not care about 7.3 too much already anyway ! ;) )

Ernie
https://github.com/IP-CAM/Opencart-1.5. ... .x-Release

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by sealvideo » Thu Mar 28, 2019 11:32 am

WOW Thank you so much, took over a week of trying everything.

I changed my config file to define('DB_DRIVER', 'mysqli');
I Changes to encryption.php code to the one you gave me!

But I still got the same plain white web page!

So I uninstalled all my VqMods, except for the vqmod_opencart.xml itself.

WORKS PERFECT on PHP 7.2!!!!!!!!

Thank you so much Ernie!

Newbie

Posts

Joined
Sat Sep 06, 2014 4:07 am

Post by IP_CAM » Thu Mar 28, 2019 11:43 am

Good for you! Just find out now, which-one it was, and tell us about it,
I so far only found a 'file-manager' tool, able to 'handle' file and pics,
but unable to further work with php7, but it's always good to know, if
other Mods might keep the Baby from doing it's Job.
Ernie

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by sethioz » Wed Nov 10, 2021 12:45 am

Hey, I want to do same thing, but I have OC 1.5.2.1. I followed all the steps and I no longer get ERROR 500 on PHP7, but instead I get white page with message saying "Error: Could not load database file mysqli!"
any ideas?
Just to make it clear what I've done:
I have OC 1.5.2.1 on PHP5
I moved it to new server with PHP7
I edited encryption.php in /system/library folder (copied the code from above)
Then I edited /admin/config.php and config.php (in shop root) and added the "i" at end of "mysql"
I tried removing vqmods too, but no luck.

EDIT: I figured it's because i'm missing the actual mysqli.php file as OC 1.5.2.1 doesn't even have it, I tried copying it from OC2 and renaming mysql.php to mysqli.php, but both result in either error 500 or just white blank page. I tried loading both /store/ and /store/admin. With one combination I get error 500 on front and blank page on admin. I really want to get my current one working. I already tried upgrading and it gives error 500 after upgrade.

Any ideas? thanks.
Last edited by sethioz on Wed Nov 10, 2021 1:15 am, edited 1 time in total.

Newbie

Posts

Joined
Thu Dec 11, 2014 2:18 am

Post by xxvirusxx » Wed Nov 10, 2021 12:54 am

sethioz wrote:
Wed Nov 10, 2021 12:45 am
I get white page with message saying "Error: Could not load database file mysqli!"
100$ :laugh: :laugh:

Copy mysqli.php (system/database) from 1.5.6.4 to your 1.5.2.1 (same path)

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by sethioz » Wed Nov 10, 2021 1:22 am

xxvirusxx wrote:
Wed Nov 10, 2021 12:54 am
sethioz wrote:
Wed Nov 10, 2021 12:45 am
I get white page with message saying "Error: Could not load database file mysqli!"
100$ :laugh: :laugh:

Copy mysqli.php (system/database) from 1.5.6.4 to your 1.5.2.1 (same path)
yeah I tried that, error 500 on shop front and blank page on /admin/
EDIT: I tried upgrading to 1.5.6.4, but it gives me ERROR 500 on admin panel after trying to login.
I suspect some extensions are giving me issues, but I can't exactly disable them if I can't even login.

EDIT2: has anyone tried installing 1.5.6.4 on PHP7 with the encryption.php mod? It's not working for me, I get the first license page (which seems bit broken) and when I click "continue" at bottom, then nothing happens. It seem to be just "refreshing" the page and nothing else happens.
I assume it's not possible to install one using this method?
I'm 99% sure that my old site's database has some entries that are causing the issue, I found some, but it's impossible to tell if it doesn't give me specific errors. I had some permission issues too, but again it's impossible to fix if I can't even see the errors.

Newbie

Posts

Joined
Thu Dec 11, 2014 2:18 am

Post by johnp » Wed Nov 10, 2021 2:11 am

I've done it a few times successfully. Most of that was probably down to luck. :)

Opencart 1.5.6.5/OC Bootstrap Pro/VQMOD lover, user and geek.
Affordable Service £££ - Opencart Installs, Fixing, Development and Upgrades
Plus Ecommerce, Marketing, Mailing List Management and More
FREE Guidance and Advice at https://www.ecommerce-help.co.uk


User avatar
Active Member

Posts

Joined
Fri Mar 25, 2011 10:25 am
Location - Surrey, UK

Post by xxvirusxx » Wed Nov 10, 2021 2:27 am

sethioz wrote:
Wed Nov 10, 2021 1:22 am
I get the first license page (which seems bit broken)
Because you need to replace this code from install/index.php

Code: Select all

// HTTP
define('HTTP_SERVER', 'http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/.\\') . '/');
define('HTTP_OPENCART', 'http://' . $_SERVER['HTTP_HOST'] . rtrim(rtrim(dirname($_SERVER['SCRIPT_NAME']), 'install'), '/.\\'). '/');
With a new one

Code: Select all

// Check if SSL
if ((isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) || $_SERVER['SERVER_PORT'] == 443) {
	$protocol = 'https://';
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
	$protocol = 'https://';
} else {
	$protocol = 'http://';
}
And for debug, I gave already an url on your other topic. To add this code in index.php after <?php

Code: Select all

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
Also you don't need admin acces to disable extensions/modules. You can do that from database.

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România
Who is online

Users browsing this forum: No registered users and 12 guests