C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$R4JXGWR\include\compat.inc.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php # $Id: compat.inc.php 448 2005-09-05 21:14:49Z garvinhicking $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved.  See LICENSE file for licensing details

$serendipity = array();
@
ini_set('magic_quotes_runtime''off');

if (!
defined('PATH_SEPARATOR')) {
    if (
strtoupper(substr(PHP_OS03)) === 'WIN') {
        
define('PATH_SEPARATOR'';');
    } else {
        
define('PATH_SEPARATOR'':');
    }
}

if (!
defined('DIRECTORY_SEPARATOR')) {
    if (
strtoupper(substr(PHP_OS03)) === 'WIN') {
        
define('DIRECTORY_SEPARATOR''\\');
    } else {
        
define('DIRECTORY_SEPARATOR''/');
    }
}

/* Function to get a snapshot uf used memory */
function memSnap($tshow '') {
    static 
$avail    null;
    static 
$show     true;
    static 
$memUsage 0;
    
    if (!
$show) {
        return 
false;
    }
    
    if (
$avail === false) {
        return 
true;
    } elseif (
$avail === null) {
        if (
function_exists('memory_get_usage')) {
            
$avail memory_get_usage();
        } else {
            
$avail false;
            return 
false;
        }
    }
    
    if (
$memUsage === 0) {
        
$memUsage $avail;
    }
    
    
$current memory_get_usage();
    echo 
'[' date('d.m.Y H:i') . '] ' number_format($current $memUsage2',''.') . ' label "' $tshow '", totalling ' number_format($current2',''.') . '<br />' "\n";
    
$memUsage $current;
}

if (!
function_exists('file_get_contents')) {
    function 
file_get_contents($filename$use_include_path 0) {
        
$file fopen($filename'rb'$use_include_path);
        
$data '';
        if (
$file) {
            while (!
feof($file)) {
                
$data .= fread($file4096);
            }
            
fclose($file);
        }

        return 
$data;
    }
}

if (!isset(
$_REQUEST)) {
    
$_REQUEST = &$HTTP_REQUEST_VARS;
}
if (!isset(
$_POST)) {
    
$_POST = &$HTTP_POST_VARS;
}

if (!isset(
$_GET)) {
    
$_GET = &$HTTP_GET_VARS;
}

if (!isset(
$_SESSION)) {
    
$_SESSION = &$HTTP_SESSION_VARS;
}

if (!isset(
$_COOKIE)) {
    
$_COOKIE = &$HTTP_COOKIE_VARS;
}

if (!isset(
$_SERVER)) {
    
$_SERVER = &$HTTP_SERVER_VARS;
}

/*
 *  Avoid magic_quotes_gpc issues
 *  courtesy of iliaa@php.net
 */
function serendipity_strip_quotes(&$var)
{
    if (
is_array($var)) {
        foreach (
$var as $k => $v) {
            if (
is_array($v)) {
                
array_walk($var[$k], 'serendipity_strip_quotes');
            } else {
                
$var[$k] = stripslashes($v);
            }
        }
    } else {
        
$var stripslashes($var);
    }
}

if (
ini_get('magic_quotes_gpc')) {
    if (@
count($_REQUEST)) {
        
array_walk($_REQUEST'serendipity_strip_quotes');
    }

    if (@
count($_GET)) {
        
array_walk($_GET,     'serendipity_strip_quotes');
    }

    if (@
count($_POST)) {
        
array_walk($_POST,    'serendipity_strip_quotes');
    }

    if (@
count($_COOKIE)) {
        
array_walk($_COOKIE'serendipity_strip_quotes');
    }

    if (@
count($_FILES) && strtoupper(substr(PHP_OS03)) !== 'WIN') {
        
array_walk($_FILES,   'serendipity_strip_quotes');
    }
}


// Merge get and post into the serendipity array
$serendipity['GET']    = &$_GET['serendipity'];
$serendipity['POST']   = &$_POST['serendipity'];
$serendipity['COOKIE'] = &$_COOKIE['serendipity'];

// Attempt to fix IIS compatibility
if (empty($_SERVER['REQUEST_URI'])) {
    
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . (!empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');
}

// Some security issues
if (isset($serendipity['GET']['searchTerm'])) {
    
$serendipity['GET']['searchTerm'] = htmlspecialchars(strip_tags($serendipity['GET']['searchTerm']));
}

function 
serendipity_get_bool($item) {
    static 
$translation = array('true'  => true,
                                
'false' => false);

    if (isset(
$translation[$item])) {
        return 
$translation[$item];
    } else {
        return 
$item;
    }
}

// Needs to be included here so that it's globally available also when installing
function serendipity_detectLang($use_include false) {
    global 
$serendipity;

    
$supported_languages array_keys($serendipity['languages']);
    
$possible_languages explode(',', (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : ''));
    if (
is_array($possible_languages)) {
        foreach(
$possible_languages as $index => $lang) {
            
$preferred_language strtolower(preg_replace('@^([^\-_;]*)_?.*$@''\1'$lang));
            if (
in_array($preferred_language$supported_languages)) {
                if (
$use_include) {
                    @include_once(
S9Y_INCLUDE_PATH 'lang/serendipity_lang_' $preferred_language '.inc.php');
                    
$serendipity['autolang'] = $preferred_language;
                }
                return 
$preferred_language;
            } 
// endif
        
// endforeach
    
// endif

    
return $serendipity['lang'];
}

function 
serendipity_getCoreVersion($version) {
    return 
preg_replace('@^([0-9\.]+).*$@''\1'$version);
}

function 
serendipity_die($html) {
    die(
        
'<html>
            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=' 
LANG_CHARSET '">
            </head>
            <body>' 
$html '</body>
        </html>'
);
}

/*
 *  Some defaults for our config vars.
 *  They are likely to be overwritten later in the code
 */
$serendipity['templatePath'] = 'templates/';
if (!isset(
$serendipity['serendipityPath'])) {
    
$serendipity['serendipityPath'] = (defined('S9Y_INCLUDE_PATH') ? S9Y_INCLUDE_PATH './');
}

$serendipity['indexFile'] = 'index.php';

/* vim: set sts=4 ts=4 expandtab : */
?>