在使用Dedecms CMS的过程中,部分用户可能会遇到系统基本参数空白或显示“Call to undefined function make_hash()”的错误提示。这一问题主要出现在2018-01-09版本更新后的Dedecms中,具体原因与/include/common.func.php文件的改动有关。


Dedecms最新版本对include文件夹中的common.func.php进行了修改,新增了两个函数:make_hash和dede_random_bytes。如果下载的模板文件夹中提供的common.func.php文件未包含这两个函数,则会导致上述错误。


为了解决这一问题,您需要手动将以下代码添加到/include/common.func.php文件中:


function make_hash() {
    $rand = dede_random_bytes(16);
    $_SESSION['token'] = ($rand === FALSE)
        ? md5(uniqid(mt_rand(), TRUE))
        : bin2hex($rand);
    return $_SESSION['token'];
}

function dede_random_bytes($length) {
    if (empty($length) OR ! ctype_digit((string) $length)) {
        return FALSE;
    }
    if (function_exists('random_bytes')) {
        try {
            return random_bytes((int) $length);
        } catch (Exception $e) {
            return FALSE;
        }
    }
    if (defined('MCRYPT_DEV_URANDOM') && ($output = mcrypt_create_iv($length, MCRYPT_DEV_URANDOM)) !== FALSE) {
        return $output;
    }
    if (is_readable('/dev/urandom') && ($fp = fopen('/dev/urandom', 'rb')) !== FALSE) {
        is_php('5.4') && stream_set_chunk_size($fp, $length);
        $output = fread($fp, $length);
        fclose($fp);
        if ($output !== FALSE) {
            return $output;
        }
    }
    if (function_exists('openssl_random_pseudo_bytes')) {
        return openssl_random_pseudo_bytes($length);
    }
    return FALSE;
}
    

请将上述代码粘贴到common.func.php文件中/** * 载入小助手,系统默认载入小助手**/这段注释的上方。完成操作后保存文件并刷新后台页面,即可解决“Call to undefined function make_hash()”的问题。


此外,建议定期检查Dedecms官方发布的更新日志,确保您的网站始终使用最新版本的程序文件。这不仅有助于避免类似的功能性问题,还能提升网站的安全性和稳定性。


通过以上方法,您可以轻松修复Dedecms系统基本参数空白或出现“Call to undefined function make_hash()”错误的问题,从而保障网站正常运行。