后台key值至关重要,关系着是否能够访问后台页面
获取到key值:Mage::getSingleton('adminhtml/url')->getSecretKey();
其实是$controller . $action. $salt拼接后获取到hash值
public function getSecretKey($controller =null, $action = null)
{
$salt = Mage::getSingleton('core/session')->getFormKey();
$p = explode('/', trim($this->getRequest()->getOriginalPathInfo(),'/'));
if (!$controller) {
$controller = !empty($p[1]) ? $p[1] :$this->getRequest()->getControllerName();
}
if (!$action) {
$action = !empty($p[2]) ? $p[2] :$this->getRequest()->getActionName();
}
$secret = $controller . $action . $salt;
return Mage::helper('core')->getHash($secret);
}
自定义的函数:
public function getSecretKey($controller,$action)
{
$salt = Mage::getSingleton('core/session')->getFormKey();
$secret = $controller . $action . $salt;
return Mage::helper('core')->getHash($secret);
}