【发布时间】:2016-01-12 11:13:02
【问题描述】:
我想在 codeigniter 中加密 url,我在 helper 和 decode_url() 中创建了一个函数 encode_url() 用于使用 codeigniter 加密库进行解码,我将链接添加为 encode_url("home") 并希望将此 url 路由到 home控制器,但我无法访问路由文件中的辅助功能。
有什么方法可以使用解码功能路由 url,否则我将不得不在控制器中创建新功能并在那里解码。
助手中的编码函数
function encode_url($string, $key="", $url_safe=TRUE)
{
if($key==null || $key=="")
{
$key="sh_hebrewurlencryption";
}
$CI =& get_instance();
$ret = $CI->encrypt->encode($string, $key);
if ($url_safe)
{
$ret = strtr(
$ret,
array(
'+' => '.',
'=' => '-',
'/' => '~'
)
);
}
return $ret;
}
帮助程序中的解码功能
function encode_url($string, $key="", $url_safe=TRUE)
{
if($key==null || $key=="")
{
$key="sh_hebrewurlencryption";
}
$CI =& get_instance();
$ret = $CI->encrypt->encode($string, $key);
if ($url_safe)
{
$ret = strtr(
$ret,
array(
'+' => '.',
'=' => '-',
'/' => '~'
)
);
}
return $ret;
}
菜单中的网址如
<?php echo site_url();?>he/<?php echo encode_url('checkMemberStatus'); ?>
【问题讨论】:
-
看来你发布了相同的功能。
标签: php codeigniter