C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$R2H5R6F\includes\sef.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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<?php
/**
* @version $Id: sef.php 2546 2006-02-22 23:25:28Z stingrey $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined'_VALID_MOS' ) or die( 'Restricted access' );

if (
$mosConfig_sef) {
    
$url_array explode('/'$_SERVER['REQUEST_URI']);

    if (
in_array('content'$url_array)) {

        
/**
        * Content
        * http://www.domain.com/$option/$task/$sectionid/$id/$Itemid/$limit/$limitstart
        */

        
$uri                 explode('content/'$_SERVER['REQUEST_URI']);
        
$option             'com_content';
        
$_GET['option']     = $option;
        
$_REQUEST['option'] = $option;
        
$pos                 array_search ('content'$url_array);

        
// language hook for content
        
$lang '';
        foreach(
$url_array as $key=>$value) {
            if ( !
strcasecmp(substr($value,0,5),'lang,') ) {
                
$temp explode(','$value);
                if (isset(
$temp[0]) && $temp[0]!='' && isset($temp[1]) && $temp[1]!='') {
                    
$_GET['lang']         = $temp[1];
                    
$_REQUEST['lang']     = $temp[1];
                    
$lang                 $temp[1];
                }
                unset(
$url_array[$key]);
            }
        }

        if (isset(
$url_array[$pos+6]) && $url_array[$pos+6]!='') {
        
// $option/$task/$sectionid/$id/$Itemid/$limit/$limitstart
            
$task                     $url_array[$pos+1];
            
$sectionid                $url_array[$pos+2];
            
$id                     $url_array[$pos+3];
            
$Itemid                 $url_array[$pos+4];
            
$limit                     $url_array[$pos+5];
            
$limitstart             $url_array[$pos+6];

            
// pass data onto global variables
            
$_GET['task']             = $task;
            
$_REQUEST['task']         = $task;
            
$_GET['sectionid']         = $sectionid;
            
$_REQUEST['sectionid']     = $sectionid;
            
$_GET['id']             = $id;
            
$_REQUEST['id']         = $id;
            
$_GET['Itemid']         = $Itemid;
            
$_REQUEST['Itemid']     = $Itemid;
            
$_GET['limit']             = $limit;
            
$_REQUEST['limit']         = $limit;
            
$_GET['limitstart']     = $limitstart;
            
$_REQUEST['limitstart'] = $limitstart;

            
$QUERY_STRING "option=com_content&task=$task&sectionid=$sectionid&id=$id&Itemid=$Itemid&limit=$limit&limitstart=$limitstart";
        } else if (isset(
$url_array[$pos+5]) && $url_array[$pos+5]!='') {
        
// $option/$task/$id/$Itemid/$limit/$limitstart
            
$task                     $url_array[$pos+1];
            
$id                     $url_array[$pos+2];
            
$Itemid                 $url_array[$pos+3];
            
$limit                     $url_array[$pos+4];
            
$limitstart             $url_array[$pos+5];

            
// pass data onto global variables
            
$_GET['task']             = $task;
            
$_REQUEST['task']         = $task;
            
$_GET['id']             = $id;
            
$_REQUEST['id']         = $id;
            
$_GET['Itemid']         = $Itemid;
            
$_REQUEST['Itemid']     = $Itemid;
            
$_GET['limit']             = $limit;
            
$_REQUEST['limit']         = $limit;
            
$_GET['limitstart']     = $limitstart;
            
$_REQUEST['limitstart'] = $limitstart;

            
$QUERY_STRING "option=com_content&task=$task&id=$id&Itemid=$Itemid&limit=$limit&limitstart=$limitstart";
        } else if (isset(
$url_array[$pos+4]) && $url_array[$pos+4]!='' && ( in_array('archivecategory'$url_array) || in_array('archivesection'$url_array) )) {
            
// $option/$task/$Itemid/$year/$month/$module
            
$task                     $url_array[$pos+1];
            
$year                     $url_array[$pos+2];
            
$month                     $url_array[$pos+3];
            
$module                 $url_array[$pos+4];
            
            
// pass data onto global variables
            
$_GET['task']             = $task;
            
$_REQUEST['task']         = $task;
            
$_GET['year']             = $year;
            
$_REQUEST['year']         = $year;
            
$_GET['month']             = $month;
            
$_REQUEST['month']         = $month;
            
$_GET['module']         = $module;
            
$_REQUEST['module']        = $module;
            
            
$QUERY_STRING "option=com_content&task=$task&year=$year&month=$month&module=$module";
        } else if (!(isset(
$url_array[$pos+5]) && $url_array[$pos+5]!='') && isset($url_array[$pos+4]) && $url_array[$pos+4]!='') {
        
// $option/$task/$sectionid/$id/$Itemid
            
$task                     $url_array[$pos+1];
            
$sectionid                 $url_array[$pos+2];
            
$id                     $url_array[$pos+3];
            
$Itemid                 $url_array[$pos+4];

            
// pass data onto global variables
            
$_GET['task']             = $task;
            
$_REQUEST['task']         = $task;
            
$_GET['sectionid']         = $sectionid;
            
$_REQUEST['sectionid']     = $sectionid;
            
$_GET['id']             = $id;
            
$_REQUEST['id']         = $id;
            
$_GET['Itemid']         = $Itemid;
            
$_REQUEST['Itemid']     = $Itemid;

            
$QUERY_STRING "option=com_content&task=$task&sectionid=$sectionid&id=$id&Itemid=$Itemid";
        } else if (!(isset(
$url_array[$pos+4]) && $url_array[$pos+4]!='') && (isset($url_array[$pos+3]) && $url_array[$pos+3]!='')) {
        
// $option/$task/$id/$Itemid
            
$task                     $url_array[$pos+1];
            
$id                     $url_array[$pos+2];
            
$Itemid                 $url_array[$pos+3];

            
// pass data onto global variables
            
$_GET['task']             = $task;
            
$_REQUEST['task']         = $task;
            
$_GET['id']             = $id;
            
$_REQUEST['id']         = $id;
            
$_GET['Itemid']         = $Itemid;
            
$_REQUEST['Itemid']     = $Itemid;

            
$QUERY_STRING "option=com_content&task=$task&id=$id&Itemid=$Itemid";
        } else if (!(isset(
$url_array[$pos+3]) && $url_array[$pos+3]!='') && (isset($url_array[$pos+2]) && $url_array[$pos+2]!='')) {
        
// $option/$task/$id
            
$task                     $url_array[$pos+1];
            
$id                     $url_array[$pos+2];

            
// pass data onto global variables
            
$_GET['task']             = $task;
            
$_REQUEST['task']         = $task;
            
$_GET['id']             = $id;
            
$_REQUEST['id']         = $id;

            
$QUERY_STRING "option=com_content&task=$task&id=$id";
        } else if (!(isset(
$url_array[$pos+2]) && $url_array[$pos+2]!='') && (isset($url_array[$pos+1]) && $url_array[$pos+1]!='')) {
        
// $option/$task
            
$task $url_array[$pos+1];

            
$_GET['task']             = $task;
            
$_REQUEST['task']         = $task;

            
$QUERY_STRING 'option=com_content&task='$task;
        }

        if (
$lang!='') {
            
$QUERY_STRING .= '&lang='$lang;
        }

        
$_SERVER['QUERY_STRING']     = $QUERY_STRING;
        
$REQUEST_URI                 $uri[0].'index.php?'.$QUERY_STRING;
        
$_SERVER['REQUEST_URI']     = $REQUEST_URI;

    } else if (
in_array('component'$url_array)) {

        
/*
        Components
        http://www.domain.com/component/$name,$value
        */
        
$uri explode('component/'$_SERVER['REQUEST_URI']);
        
$uri_array explode('/'$uri[1]);
        
$QUERY_STRING '';
        
        
// needed for check if component exists
        
$path         $mosConfig_absolute_path .'/components';
        
$dirlist     = array();
        if ( 
is_dir$path ) ) {
            
$base opendir$path );    
            while (
false !== ( $dir readdir($base) ) ) {
                if (
is_dir($path .'/'$dir) && $dir !== '.' && $dir !== '..' && strtolower($dir) !== 'cvs' && strtolower($dir) !== '.svn') {
                    
$dirlist[] = $dir;
                }
            }
            
closedir($base);
        }

        foreach(
$uri_array as $value) {
            
$temp explode(','$value);
            if (isset(
$temp[0]) && $temp[0]!='' && isset($temp[1]) && $temp[1]!='') {
                
$_GET[$temp[0]]     = $temp[1];
                
$_REQUEST[$temp[0]] = $temp[1];
                
                
// check to ensure component actually exists
                
if ( $temp[0] == 'option' ) {
                    
$check '';
                    if (
count$dirlist )) {
                        foreach ( 
$dirlist as $dir ) {
                            if ( 
$temp[1] == $dir ) {
                                
$check 1;
                                break;
                            }
                        }
                    }
                    
// redirect to 404 page if no component found to match url
                    
if ( !$check ) {
                        
header'HTTP/1.0 404 Not Found' );
                        require_once( 
$mosConfig_absolute_path '/templates/404.php' );
                        exit( 
404 );
                    }
                }
                
                if ( 
$QUERY_STRING == '' ) {
                    
$QUERY_STRING .= "$temp[0]=$temp[1]";
                } else {
                    
$QUERY_STRING .= "&$temp[0]=$temp[1]";
                }
            }
        }
        
        
$_SERVER['QUERY_STRING']     = $QUERY_STRING;
        
$REQUEST_URI                 $uri[0].'index.php?'.$QUERY_STRING;
        
$_SERVER['REQUEST_URI']     = $REQUEST_URI;

        if (
defined('RG_EMULATION') && RG_EMULATION == 1) {
            
// Extract to globals
            
while(list($key,$value)=each($_GET)) {
                if (
$key!="GLOBALS") {
                    
$GLOBALS[$key]=$value;
                }
            }
            
// Don't allow config vars to be passed as global
            
include( 'configuration.php' );
        }

    } else {

        
/*
        Unknown content
        http://www.domain.com/unknown
        */
        
$jdir str_replace'index.php'''$_SERVER['PHP_SELF'] );
        
$juri str_replace$jdir''$_SERVER['REQUEST_URI'] );
        
        if (
$juri != '' && $juri != '/' && !eregi"index\.php"$_SERVER['REQUEST_URI'] ) && !eregi"index2\.php"$_SERVER['REQUEST_URI'] ) && !eregi"/\?"$_SERVER['REQUEST_URI'] ) && $_SERVER['QUERY_STRING'] == '' ) {
            
header'HTTP/1.0 404 Not Found' );
            require_once( 
$mosConfig_absolute_path '/templates/404.php' );
            exit( 
404 );
        }
    }
}

/**
 * Converts an absolute URL to SEF format
 * @param string The URL
 * @return string
 */
function sefRelToAbs$string ) {
    global 
$mosConfig_live_site$mosConfig_sef$mosConfig_mbf_content;
    global 
$iso_client_lang;

    
//multilingual code url support
    
if( $mosConfig_mbf_content && $string!='index.php' && !eregi("^(([^:/?#]+):)",$string) && !strcasecmp(substr($string,0,9),'index.php') && !eregi('lang='$string) ) {
        
$string .= '&lang='$iso_client_lang;
    }

    
// SEF URL Handling
    
if ($mosConfig_sef && !eregi("^(([^:/?#]+):)",$string) && !strcasecmp(substr($string,0,9),'index.php')) {
        
// Replace all &amp; with &
        
$string str_replace'&amp;''&'$string );

        
/*
        Home
        index.php
        */
        
if ($string=='index.php') {
            
$string='';
        }

        
$sefstring '';
        if ( (
eregi('option=com_content',$string) || eregi('option=content',$string) ) && !eregi('task=new',$string) && !eregi('task=edit',$string) ) {
            
// Handle fragment identifiers (ex. #foo)
            
$fragment '';
            if (
eregi('#'$string)) {
                
$temp split('#'$string2);
                
$string $temp[0];
                
// ensure fragment identifiers are compatible with HTML4
                
if (preg_match('@^[A-Za-z][A-Za-z0-9:_.-]*$@'$temp[1])) {
                    
$fragment '#'$temp[1];
                }
            }
            
            
/*
            Content
            index.php?option=com_content&task=$task&sectionid=$sectionid&id=$id&Itemid=$Itemid&limit=$limit&limitstart=$limitstart&year=$year&month=$month&module=$module
            */
            
$sefstring .= 'content/';
            if (
eregi('&task=',$string)) {
                
$temp split('&task='$string);
                
$temp split('&'$temp[1]);

                
$sefstring .= $temp[0].'/';
            }
            if (
eregi('&sectionid=',$string)) {
                
$temp split('&sectionid='$string);
                
$temp split('&'$temp[1]);

                
$sefstring .= $temp[0].'/';
            }
            if (
eregi('&id=',$string)) {
                
$temp split('&id='$string);
                
$temp split('&'$temp[1]);

                
$sefstring .= $temp[0].'/';
            }
            if (
eregi('&Itemid=',$string)) {
                
$temp split('&Itemid='$string);
                
$temp split('&'$temp[1]);

                if ( 
$temp[0] !=  99999999 ) {
                    
$sefstring .= $temp[0].'/';
                }
            }
            if (
eregi('&limit=',$string)) {
                
$temp split('&limit='$string);
                
$temp split('&'$temp[1]);

                
$sefstring .= $temp[0].'/';
            }
            if (
eregi('&limitstart=',$string)) {
                
$temp split('&limitstart='$string);
                
$temp split('&'$temp[1]);

                
$sefstring .= $temp[0].'/';
            }
            if (
eregi('&lang=',$string)) {
                
$temp split('&lang='$string);
                
$temp split('&'$temp[1]);

                
$sefstring .= 'lang,'.$temp[0].'/';
            }
            if (
eregi('&year=',$string)) {
                
$temp split('&year='$string);
                
$temp split('&'$temp[1]);
                
                
$sefstring .= $temp[0].'/';
            }
            if (
eregi('&month=',$string)) {
                
$temp split('&month='$string);
                
$temp split('&'$temp[1]);
                
                
$sefstring .= $temp[0].'/';
            }
            if (
eregi('&module=',$string)) {
                
$temp split('&module='$string);
                
$temp split('&'$temp[1]);
                
                
$sefstring .= $temp[0].'/';
            }
            
            
$string $sefstring $fragment;
        } else if (
eregi('option=com_',$string) && !eregi('task=new',$string) && !eregi('task=edit',$string)) {
            
/*
            Components
            index.php?option=com_xxxx&...
            */
            
$sefstring     'component/';
            
$temp         split("\?"$string);
            
$temp         split('&'$temp[1]);

            foreach(
$temp as $key => $value) {
                
$sefstring .= $value.'/';
            }
            
$string str_replace'='','$sefstring );
        }

        
// comment line below if you dont have mod_rewrite
        
return $mosConfig_live_site .'/'$string;

        
// allows SEF without mod_rewrite
        // uncomment Line 348 and comment out Line 354    
    
        // uncomment line below if you dont have mod_rewrite
        // return $mosConfig_live_site.'/index.php/'.$string;
        // If the above doesnt work - try uncommenting this line instead
        // return $mosConfig_live_site.'/index.php?/'.$string;
    
} else {
    
// Handling for when SEF is not activated
        // Relative link handling
        
if ( !(strpos$string$mosConfig_live_site ) === 0) ) {
            
// if URI starts with a "/", means URL is at the root of the host...
            
if (strncmp($string'/'1) == 0) {
                
// splits http(s)://xx.xx/yy/zz..." into [1]="htpp(s)://xx.xx" and [2]="/yy/zz...":
                
$live_site_parts = array();
                
eregi("^(https?:[\/]+[^\/]+)(.*$)"$mosConfig_live_site$live_site_parts);
                
                
$string $live_site_parts[1] . $string;
            } else {
                
// URI doesn't start with a "/" so relative to the page (live-site):
                
$string $mosConfig_live_site .'/'$string;
            }
        }
        
        return 
$string;
    }
}
?>