<?php
echo $_SERVER['DOCUMENT_ROOT']."\web\home\security\security.php";
//including files
//--------------------------------------------------------------
include_once "home/database_handler.php";
require_once $_SERVER['DOCUMENT_ROOT']."\web\home\security\security.php";
include_once "home/session/session_handler.php";
//check session and assign if there ain't any nonce_key
//--------------------------------------------------------------
if (!session_check("nonce_key"))
{
// generate the key
$key=generate_rand_key("str");
$set = set_to_session($key, "nonce_key");
if ($set)
echo "successfully set the session";
else
echo "session set failed!";
}
//check if any session is already set & POST supplied
//--------------------------------------------------------------
hasher("str", "salt");
?>
这是reg.php的代码片段
对于security.php:
<?php
include_once("/../config/security_config.php");
// functions start here XD
//Generate a new key each time (to be used as nonce/rand key)
//------------------------------------------------------------------
function generate_rand_key($str) {
$time = time();
$key = md5($time);
return $key;
}
function filter_user_input($input) {
// INJECTION
$input = mysql_real_escape_string($input);
// XSS
$input = htmlentities( htmlspecialchars($input));
return $input;
}
function hasher($string, $salt) {
// first md5 with salt
$input = md5("$string.$salt");
//$input = crypt($input);
//using crypt function
$input = crypt($input, $salt);
return $input;
}
?>
我收到此错误:
PHP Fatal error: Uncaught Error: Call to undefined function generate_rand_key() in C:\inetpub\wwwroot\web\reg.php:20
有趣的是,即使我在上面删除了几行,函数hasher仍未收到此错误,但是函数generate_rand_key却收到此错误。
对于上述require,没有任何类型的错误。
这是什么问题?是一个错误吗?