i have a big problem in my project. i developed project into PYROCMS and PYROCMS developed into Codeigniter. but PYROCMS required "Mcrypt extension".
i have a ssh detail of server but i don't have permission to install anything into server.
i need a solution for "Mcrypt extension" how to working without install or Download from anywhere and upload it in project root directory if it is possible?.
i need a solution like this it is possible in laravel using this packed to working project without install Mcrypt extension please give a any solution like that for PYROCMS.
today is last day of project i need to upload today whatever happen otherwise i lose this project and also my work. please help.
Thanks
You can override default library with your own library. You can try below code:
P.S.: I have not tested this code :)
Create a file:
/codeigniter/application/libraries/MY_Encrypt.php
And have below code to get started:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Encrypt extends CI_Encrypt {
public function __construct()
{
//parent::__construct();
}
/*
Create your custom encryption and decryption logic by
overriding function
*/
}
Reference: https://ellislab.com/codeigniter/user-guide/general/creating_libraries.html
Open, system/libraries/Encrpyte.php
goto line 47 and change that
$this->_mcrypt_exists = TRUE;
goto line 290 add symbol @
$init_size = @mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
go to line 299 and add symbol @
return rtrim(@mcrypt_decrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), "\0");
This is trick, but works fine with Pyrocms
Basically pyrocms, using encrypt library by default in below modules
akshay@db-3325:/var/www/html/pyrocms/system/cms$ grep -R encrypt . | awk '!/_lang|config/'
./libraries/MY_Encrypt.php: return call_user_func_array(array($this->instance, "encrypt"), func_get_args());
./libraries/Streams/drivers/Streams_cp.php: // As an added measure of obsurity, we are going to encrypt the
./libraries/Streams/drivers/Streams_cp.php: $CI->load->library('encrypt');
./libraries/Streams/drivers/Streams_cp.php: $CI->template->append_metadata('<script type="text/javascript" language="javascript">var stream_id='.$stream->id.'; var stream_offset='.$offset.'; var streams_module="'.$CI->encrypt->encode($CI->module_details['slug']).'";
./modules/comments/libraries/Comments.php: return ci()->encrypt->encode(serialize(array(
./modules/comments/controllers/comments.php: $entry = unserialize($this->encrypt->decode($this->input->post('entry')));
./modules/files/libraries/Files.php: // if we want to replace a file, the file name should already be encrypted, the option was true then
./modules/streams_core/field_types/encrypt/field.encrypt.php:class Field_encrypt
./modules/streams_core/field_types/encrypt/field.encrypt.php: public $field_type_slug = 'encrypt';
./modules/streams_core/field_types/encrypt/field.encrypt.php: $this->CI->load->library('encrypt');
./modules/streams_core/field_types/encrypt/field.encrypt.php: return $this->CI->encrypt->encode($input);
./modules/streams_core/field_types/encrypt/field.encrypt.php: $this->CI->load->library('encrypt');
./modules/streams_core/field_types/encrypt/field.encrypt.php: $out = $this->CI->encrypt->decode($input);
./modules/streams_core/field_types/encrypt/field.encrypt.php: $this->CI->load->library('encrypt');
./modules/streams_core/field_types/encrypt/field.encrypt.php: $options['value'] = ($_POST) ? $params['value'] : $this->CI->encrypt->decode($params['value']);
./modules/streams_core/controllers/ajax.php: $this->load->library('encrypt');
./modules/streams_core/controllers/ajax.php: $module = $this->encrypt->decode($module);
You got few solutions
Use encryption
library with openssl
instead of encrypt
library (which uses mcrypt
extension), replace it in these modules.
OR Download https://raw.githubusercontent.com/bcit-ci/CodeIgniter/develop/system/libraries/Encryption.php and place in system/codeigniter/libraries
and create MY_Encrypt.php
in system/cms/libraries
with below code, which override original CI_Encrypt
library, for encode
and decode
we just calling encrypt
and decrypt
of new encryption class.
.
akshay@db-3325:/var/www/html/pyrocms/system/cms/libraries$ cat MY_Encrypt.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once BASEPATH.'libraries/Encryption.php';
class MY_Encrypt extends CI_Encrypt {
protected $instance;
public function __construct(){
$this->instance = new CI_Encryption();
}
public function encode($data, $params = NULL){
return call_user_func_array(array($this->instance, "encrypt"), func_get_args());
}
public function decode($data, $params = NULL){
return call_user_func_array(array($this->instance, "decrypt"), func_get_args());
}
}
3. OR you create your own function and just load before
.
akshay@db-3325:/var/www/html/pyrocms$ pwd
/var/www/html/pyrocms
# from index.php
require_once FCPATH.'compatibility.php';
require_once BASEPATH.'core/CodeIgniter'.EXT;
/* End of file index.php */
which is something like below
<?php
/* File : compatibility.php
Example : If PHP Greater than 7, then lets create these function as it depreceated
http://php.net/manual/en/migration71.deprecated.php
*/
if(version_compare(PHP_VERSION,7,">"))
{
function mcrypt_encrypt(){
}
function mcrypt_decrypt(){
}
function mcrypt_encode(){
}
function mcrypt_decode(){
}
// Do something with these constants
//MCRYPT_MODE_ECB
//MCRYPT_MODE_CBC
//MCRYPT_RAND
//MCRYPT_RIJNDAEL_256
function mcrypt_get_iv_size(){
}
function mcrypt_create_iv(){
}
}