Exemple #1
0
$PHPSelf = addslashes(htmlspecialchars($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']));
$UrlPath = $Config['WebsitePath'] ? str_ireplace($Config['WebsitePath'] . '/', '', substr($PHPSelf, 0, -4)) : substr($PHPSelf, 1, -4);
//For IIS ISAPI_Rewrite
$RequestURI = isset($_SERVER['HTTP_X_REWRITE_URL']) ? $_SERVER['HTTP_X_REWRITE_URL'] : $_SERVER['REQUEST_URI'];
$IsAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
$CurProtocol = IsSSL() ? 'https://' : 'http://';
//消除低版本中魔术引号的影响
if (version_compare(PHP_VERSION, '5.4.0') < 0 && get_magic_quotes_gpc()) {
    function StripslashesDeep($var)
    {
        return is_array($var) ? array_map('StripslashesDeep', $var) : stripslashes($var);
    }
    $_GET = StripslashesDeep($_GET);
    $_POST = StripslashesDeep($_POST);
    $_COOKIE = StripslashesDeep($_COOKIE);
    $_REQUEST = StripslashesDeep($_REQUEST);
}
// At某人并提醒他,使用时常在其前后加空格或回车,如 “@admin ”
function AddingNotifications($Content, $TopicID, $PostID, $FilterUser = '')
{
    /*
    Type:
    1:新回复
    2:@ 到我的
    */
    global $Prefix, $DB, $MCache, $TimeStamp, $CurUserName;
    //例外列表
    $ExceptionUser = array($CurUserName);
    if ($FilterUser != $CurUserName) {
        $ExceptionUser[] = $FilterUser;
    }
    // E_STRICT
    StrikeError('Error ' . $code . ' (' . $message . ') occured in ' . $filename . ' at ' . $linenumber . '');
}
// -----------------------------------------------------
set_error_handler('OnPHPError');
if (!isset($_SESSION)) {
    @session_start();
}
function StripslashesDeep($value)
{
    $value = is_array($value) ? array_map("StripslashesDeep", $value) : stripslashes($value);
    return $value;
}
if (ini_get("magic_quotes_gpc")) {
    $_GET = StripslashesDeep($_GET);
    $_POST = StripslashesDeep($_POST);
    // cookie ?
}
$GLOBALS['tpl.time.parse'] = 0;
// -----------------------------------------------------
function GetMicroTime()
{
    list($usec, $sec) = explode(" ", microtime());
    return $usec + $sec;
}
function MicroTimeToStr($tm)
{
    $str = (string) ($tm - floor($tm));
    $ls = substr($str, 2);
    while (strlen($ls) < 15) {
        $ls = $ls . '0';