forked from sauruscms/Saurus-CMS-Community-Edition
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathredirect.php
More file actions
111 lines (94 loc) · 3.47 KB
/
Copy pathredirect.php
File metadata and controls
111 lines (94 loc) · 3.47 KB
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
<?php
/**
* This source file is is part of Saurus CMS content management software.
* It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php).
* Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/).
* Redistribution of this file must retain the above copyright notice.
*
* Please note that the original authors never thought this would turn out
* such a great piece of software when the work started using Perl in year 2000.
* Due to organic growth, you may find parts of the software being
* a bit (well maybe more than a bit) old fashioned and here's where you can help.
* Good luck and keep your open source minds open!
*
* @package SaurusCMS
* @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/)
* @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php)
*
*/
/**
* redirect foreign urls, for statistic purposes
*
* @param url the URL to redirect
*
*/
####################
# Stuff copied from index.php
preg_match('/\/(admin|editor)\//i', $_SERVER['REQUEST_URI'], $matches);
if ($matches[1]=='editor'){
$class_path = '../classes/';
$CMS_SETTINGS['cache_enabled'] = 0; # Cache: deny cache using for editor-area
} else {
$class_path = './classes/';
$CMS_SETTINGS['cache_enabled'] = 1; # Cache: allow using cache for user-area
$CMS_SETTINGS['switch_lang_enabled'] = 1;
}
$debug = $_COOKIE['debug'] ? 1 : 0;
#####################
# Classes include, only some necessary classes:
include_once($class_path."timer.class.php");
if ($debug) {
include_once($class_path.'debug.inc.php');
} else {
include_once($class_path.'nodebug.inc.php');
}
include_once($class_path.'config.class.php');
$absolute_path = getcwd().'/';
# strip /admin|editor|classes/ from the end
if (preg_match("/(.*)\/(admin|editor|classes|temp|test)\/$/", $absolute_path, $matches) || preg_match("/(.*)\\\(admin|editor|classes|temp|test)\/$/", $absolute_path, $matches)) {
$absolute_path = $matches[1];
}
# add slash to the end
if (!preg_match("/\/$/",$absolute_path)) $absolute_path .= "/";
####### read config.php
$file = $absolute_path.'config.php';
# check if file config.php exists at all
if(!file_exists($file)) {
echo '<font color="red">Error: file '.$file.' not found!</font>';
exit;
}
$fp = fopen($file, 'r');
$config = new CONFIG(fread($fp, 1024*1024));
fclose($fp);
$dbconf = $config->CONF;
#############################################
# include database independent API functions:
include_once($class_path.$dbconf['dbtype'].'.inc.php');
$DB = new DB(array(
'host' => $dbconf['dbhost'],
'port' => $dbconf['dbport'],
'dbname'=> $dbconf['db'],
'user' => $dbconf['user'],
'pass' => $dbconf['passwd'],
'mysql_set_names' => $dbconf["mysql_set_names"],
s));
$sql = "SELECT nimi, sisu FROM config WHERE nimi IN ('cache_expired','dont_cache_objects','kasuta_ip_filter','display_errors_ip','save_error_log','hostname','wwwroot')";
$sth = new SQL($sql);
while ($tmpconf = $sth->fetch()){
$CMS_SETTINGS[$tmpconf['nimi']] = $tmpconf['sisu'];
}
define('DISPLAY_ERRORS_IP', $CMS_SETTINGS['display_errors_ip']);
define('SAVE_ERROR_LOG', $CMS_SETTINGS['save_error_log']);
# / stuff copied from index.php
##############################
if($_GET['url'])
{
$url = urldecode($_GET['url']);
//prevent Response Splitting attack
$url = preg_replace("!\r|\n.*!s", "", $url);
header('Location: '.$_GET['url']);
}
else
{
header('Location: index.php');
}