Php Mcrypt扩展的Codeigniter临时解决方案
我的项目有一个大问题。我将项目开发成PYROCMS,PYROCMS开发成Codeigniter。但PYROCMS需要“Mcrypt扩展” 我有服务器的ssh详细信息,但我没有将任何内容安装到服务器的权限 我需要一个解决方案来解决“Mcrypt extension”如何在不从任何地方安装或下载的情况下工作,并在可能的情况下将其上载到项目根目录 我需要一个解决方案,就像在laravel中使用此打包到工作项目一样,无需安装Mcrypt扩展请为PYROCMS提供任何类似的解决方案 今天是最后一天的项目,我需要上传今天无论发生什么,否则我会失去这个项目,也我的工作。请帮忙Php Mcrypt扩展的Codeigniter临时解决方案,php,codeigniter,pyrocms,Php,Codeigniter,Pyrocms,我的项目有一个大问题。我将项目开发成PYROCMS,PYROCMS开发成Codeigniter。但PYROCMS需要“Mcrypt扩展” 我有服务器的ssh详细信息,但我没有将任何内容安装到服务器的权限 我需要一个解决方案来解决“Mcrypt extension”如何在不从任何地方安装或下载的情况下工作,并在可能的情况下将其上载到项目根目录 我需要一个解决方案,就像在laravel中使用此打包到工作项目一样,无需安装Mcrypt扩展请为PYROCMS提供任何类似的解决方案 今天是最后一天的项目,
谢谢您可以用自己的库覆盖默认库。您可以尝试以下代码: 注意:我还没有测试过这个代码:) 创建一个文件: /codeigniter/application/libraries/MY_Encrypt.php 并有以下代码开始:
<?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
*/
}
转到system/libraries/Encrypt.php
在构造函数内部,对第页上回显错误的行进行注释
打开,系统/库/Encrpyte.php
转到47号线,换一下
$this->_mcrypt_exists = TRUE;
转到第290行添加符号@
$init_size = @mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
转到第299行并添加符号@
return rtrim(@mcrypt_decrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), "\0");
这是一个技巧,但在Pyrocms中效果很好
基本上是pyrocms,在下面的模块中默认使用加密库
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);
3。或者您创建自己的函数并在加载之前加载
下面是什么
<?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(){
}
}
查看此文件以获取帮助我从这里获取了所有代码。。。
我用这个解决了这个问题。。在CI->system->libraries->encrypt.php文件中
代替
if (($this->_mcrypt_exists = function_exists('mcrypt_encrypt')) === FALSE)
{
show_error('The Encrypt library requires the Mcrypt extension.');
}
我检查了mcrypt_加密函数
$this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
并基于在如下所示的编码函数中使用的函数,如下所示
function encode($string, $key = '')
{
$key = $this->get_key($key);
if ($this->_mcrypt_exists === TRUE)
{
$enc = $this->mcrypt_encode($string, $key);
}
else
{
$enc = $this->_xor_encode($string, $key);
}
return base64_encode($enc);
}
这里是xor_encode函数
function _xor_encode($string, $key)
{
$rand = '';
while (strlen($rand) < 32)
{
$rand .= mt_rand(0, mt_getrandmax());
}
$rand = $this->hash($rand);
$enc = '';
for ($i = 0; $i < strlen($string); $i++)
{
$enc .= substr($rand, ($i % strlen($rand)), 1).(substr($rand, ($i % strlen($rand)), 1) ^ substr($string, $i, 1));
}
return $this->_xor_merge($enc, $key);
}
function\u xor\u encode($string,$key)
{
$rand='';
而(斯特伦($rand)<32)
{
$rand.=mt_rand(0,mt_getrandmax());
}
$rand=$this->hash($rand);
$enc='';
对于($i=0;$i\uxor\umerge($enc,$key);
}
and xor merge函数
function _xor_merge($string, $key)
{
$hash = $this->hash($key);
$str = '';
for ($i = 0; $i < strlen($string); $i++)
{
$str .= substr($string, $i, 1) ^ substr($hash, ($i % strlen($hash)), 1);
}
return $str;
}
function\uxor\umerge($string,$key)
{
$hash=$this->hash($key);
$str='';
对于($i=0;$i
您是否尝试将laravel mcrypt faker添加到composer.json中?lavarel没有直接的依赖关系,因此可能是这项工作。不,实际上我没有尝试与Codeigniter集成。看起来像是重复的线程..供参考,您可以在这里查看:感谢重播,但无法工作我无法覆盖此错误CI_Encrypt将Mcrypt代码写入_u构造()我无法覆盖父类_construct()。@renishkhunt在这种情况下,请不要调用父构造函数。我已更新代码不工作,因为错误:未找到会话cookie。
function _xor_encode($string, $key)
{
$rand = '';
while (strlen($rand) < 32)
{
$rand .= mt_rand(0, mt_getrandmax());
}
$rand = $this->hash($rand);
$enc = '';
for ($i = 0; $i < strlen($string); $i++)
{
$enc .= substr($rand, ($i % strlen($rand)), 1).(substr($rand, ($i % strlen($rand)), 1) ^ substr($string, $i, 1));
}
return $this->_xor_merge($enc, $key);
}
function _xor_merge($string, $key)
{
$hash = $this->hash($key);
$str = '';
for ($i = 0; $i < strlen($string); $i++)
{
$str .= substr($string, $i, 1) ^ substr($hash, ($i % strlen($hash)), 1);
}
return $str;
}