-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify.php
160 lines (135 loc) · 5.8 KB
/
verify.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
<?php
/************************************************************************/
/* FlatNuke - Flat Text Based Content Management System */
/* ============================================ */
/* */
/* Copyright (c) 2003-2006 by Simone Vellei */
/* http://www.flatnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
// include le librerie di Flatnuke necessarie
include ("config.php");
include ("functions.php");
include ("header.php");
include_once ("themes/$theme/theme.php");
if (!defined("_FN_MOD"))
create_fn_constants();
//controllo che l'ip di provenienza non sia vietato
$ip = strip_tags(getparam("REMOTE_ADDR", PAR_SERVER, SAN_NULL));
if (is_blocked_ip($ip)){
fnlog("Security", "$ip||Access denied to IP address $ip.");
// have fun ;)
header("Location: http://www.spam.com/");
exit;
}
// deny remote cross access to this file
//if( !eregi( $_SERVER['HTTP_HOST'],$_SERVER['HTTP_REFERER'] ) ){
if( !preg_match("/".$_SERVER['HTTP_HOST']."/", $_SERVER['HTTP_REFERER'] ) ){
//fnlog("Security", "$ip||Blocked unauthorized remote access to verify.php. URL=".$_SERVER['HTTP_REFERER']); // uncomment if interested on lamers' access
// have fun ;)
echo "<b>Error</b>: blocked unauthorized remote access to verify.php";
// header("Location: http://en.wikipedia.org/wiki/Lamer");
exit;
}
// if no active session we start a new one + check session id
if (session_id() == "") session_start();
if (isset($_SESSION['fn_session']) AND $_SESSION['fn_session']!= session_id() ) {
unset($_SESSION['fn_session']);
//fnlog("Security", "$ip||Blocked, tried to breaks session rules. URL=".$_SERVER['HTTP_REFERER']); // uncomment if interested on lamers' access
header("Location: index.php");
exit;
} elseif(!isset($_SESSION['fn_session'])) {
$_SESSION['fn_session'] = session_id();
//fnlog("Security", "$ip||Blocked, no valid fn_session. URL=".$_SERVER['HTTP_REFERER']); // uncomment if interested on lamers' access
header("Location: index.php");
exit;
}
// opzioni di sicurezza!
$myforum = get_username();
$req = getparam("REQUEST_URI", PAR_SERVER, SAN_FLAT);
if(strstr($req,"myforum=")) {
// have fun ;)
header("Location: http://en.wikipedia.org/wiki/Lamer");
exit;
}
/*
* Parametro $mod da POST
*/
$mod=getparam("mod",PAR_POST,SAN_FLAT);
switch($mod){
// Modifica del livello di una sezione
case "modlevel":
$section = getparam("section", PAR_POST, SAN_FLAT);
$level = getparam("level", PAR_POST, SAN_FLAT);
if(is_admin() and is_writeable("sections/$section")) {
if($level!=-1) {
fnwrite("sections/$section/level.php", $level, "w", array("nonull"));
//ora proteggi il file section.php per evitare accessi diretti alla sezione senza passare da index.php
protect_file(get_fn_dir("sections")."/$section/section.php");
fnlog("Site maintenance", $ip."||".$myforum."||Level of the section $section modified to $level.");
} else {
unlink("sections/$section/level.php");
fnlog("Site maintenance", $ip."||".$myforum."||Section $section with no more level restrictions.");
}
}
?><script language="javascript">window.location='index.php?mod=<?php echo $section?>';</script><?php
break;
// Modifica di un file
case "modcont":
$from=getparam("from", PAR_POST, SAN_FLAT);
$file=stripslashes(getparam("file", PAR_POST, SAN_FLAT));
if(isset($_POST['body']))
$body=$_POST['body'];
else
$body="";
//gestisco l'attivazione di magic quotes
if (get_magic_quotes_gpc()){
$mybody=stripslashes($body);
}
else {
$mybody= $body;
}
if(is_admin() and file_exists($file)) {
if(stristr($file,"..")) {
?><script language="javascript">window.location='index.php';</script><?php
}
fnwrite($file, $mybody, "w", array());
fnlog("Site maintenance", $ip."||".$myforum."||File ".$file." modified.");
if (file_exists(dirname($file)."/level.php") or file_exists(dirname($file)."/view.php") or file_exists(dirname($file)."/edit.php")){
if (basename($file)=="section.php")
protect_file($file);
}
}
?><script language="javascript">window.location='<?php echo $from?>';</script><?php
break;
// Modifica di un file
case "usermodcont":
$from = getparam("from", PAR_POST, SAN_FLAT);
$file = stripslashes(getparam("file", PAR_POST, SAN_FLAT));
$username = get_username();
$sectmod = preg_replace("/sections\//","",dirname($file));
$text = getparam("body",PAR_POST,SAN_FLAT);
if (preg_match("/\<\?|\?\>/",$text)) fn_die("USERMODCONT","Error, user".strip_tags($username)." cannot add php code in the section ".strip_tags($sectmod)." addr: $ip",__FILE__,__LINE__);
if (!check_path($file,"sections/","true")) fn_die("USERMODCONT","Error, file ".strip_tags($file)." is not valid! user: $username addr: $ip",__FILE__,__LINE__);
//gestisco l'attivazione di magic quotes
if (get_magic_quotes_gpc()){
$text=stripslashes($text);
}
//strippo tutto quello che non e' consentito
$text = fn_purge_html_string($text);
if(user_can_edit_section($sectmod,$username) and user_can_view_section($sectmod,$username) and file_exists($file)) {
fnwrite($file, $text, "w", array());
fnlog("USERMODCONT", $ip."||$username||File ".$file." modified.");
if (file_exists(dirname($file)."/level.php") or file_exists(dirname($file)."/view.php") or file_exists(dirname($file)."/edit.php")){
if (basename($file)=="section.php")
protect_file($file);
}
}
?><script language="javascript">window.location='<?php echo $from?>';</script><?php
break;
}
?></body>
</html>