Htaccess beshermt forum...
Geplaatst: 22 feb 2005, 20:26
Hallo zou iemand me mischien kennen helpen met een stukje code om te buigen van VBBB naar PHPBB....
Ik heb een forum met allemaal kids en moeders erop, nu wil ik om grapjassen en nog erger pedo's uit te sluiten, hem helemaal dicht gaan timmeren....
Ik heb een stuk code wat perfect werkt hiervoor.
maar aangezien ik nieuw ben met phpbb weet ik niet welke files ik moet aanpassen
code staat hieronder...
Als iemand een idee heeft thanks a billion alvast!!
Ik heb een forum met allemaal kids en moeders erop, nu wil ik om grapjassen en nog erger pedo's uit te sluiten, hem helemaal dicht gaan timmeren....
Ik heb een stuk code wat perfect werkt hiervoor.
maar aangezien ik nieuw ben met phpbb weet ik niet welke files ik moet aanpassen
code staat hieronder...
Als iemand een idee heeft thanks a billion alvast!!
Code: Selecteer alles
//##############################################################
//## HTACCESS + IP RESTRICTION CREATED BY MROIZO004 ##
//##############################################################
//##############################################################
// run this db query
PHP Code:
ALTER TABLE user ADD ipmasks varchar(250) NOT NULL default '';
// open the file admincp/user.php
find :
PHP Code:
print_input_row($vbphrase['email'], 'user[email]', $user['email'], 0);
below it add :
PHP Code:
print_input_row('ip masks', 'user[ipmasks]', $user['ipmasks'], 0);
save the file and upload it back to your server
ok, now u got 2 options :
option1 - put it only in root dir
option2 - put itin root and on admincp/modcp dir
ok
if option 1 then
// open root/global.php
find :
PHP Code:
require_once('./includes/init.php');
Below it add :
PHP Code:
//HTACCESS Hack + IP restriction
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="Restricted area"');
header("HTTP/1.0 401 Unauthorized");
echo "Unauthorized login attempts are logged.\n";
echo "bla";
exit;
} else {
//checking database
$userinf=$DB_site->query_first("SELECT user.password,user.userid,user.salt FROM user WHERE username='$_SERVER[PHP_AUTH_USER]'");
$isvalidip=0;
if($userinf['userid']){
// if user exists check if ip is valid $REMOTE_ADDR
$validip=$DB_site->query_first("SELECT ipmasks FROM user WHERE userid='$userinf[userid]'");
$validip=explode(" ",$validip['ipmasks']);
foreach($validip as $testip){
if ($testip=='') { continue; }
if (strstr($REMOTE_ADDR,$testip)==$REMOTE_ADDR || stristr(gethostbyaddr($REMOTE_ADDR),$testip)==$testip){
$isvalidip=1;
break;
}
}
}
//checking if the user login is ok & that he connects from a valid ip
$salt = $userinf['salt'];
$pass = $userinf['password'];
$userp = md5(md5($_SERVER['PHP_AUTH_PW']) . $salt);
if ($pass != $userp) {
//we have a looser:)
header('WWW-Authenticate: Basic realm="Restricted area"');
header('HTTP/1.0 401 Unauthorized');
echo "Unauthorized login attempts are logged.\n";
exit;
}elseif(!$isvalidip){
header('HTTP/1.0 401 Unauthorized');
echo "Your Ip is not allowed here...Unauthorized login attempts are logged.\n";
exit;
}
}
//HTACCESS Hack + IP restriction (end)
save the file and upload it back to your server
now if u want option 2 then :
open includes/init.php
find :
PHP Code:
$DB_site->connect($servername, $dbusername, $dbpassword, $usepconnect);
Below it add :
PHP Code:
//HTACCESS Hack + IP restriction
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="Restricted area"');
header("HTTP/1.0 401 Unauthorized");
echo "Unauthorized login attempts are logged.\n";
echo "bla";
exit;
} else {
//checking database
$userinf=$DB_site->query_first("SELECT user.password,user.userid,user.salt FROM user WHERE username='$_SERVER[PHP_AUTH_USER]'");
$isvalidip=0;
if($userinf['userid']){
// if user exists check if ip is valid $REMOTE_ADDR
$validip=$DB_site->query_first("SELECT ipmasks FROM user WHERE userid='$userinf[userid]'");
$validip=explode(" ",$validip['ipmasks']);
foreach($validip as $testip){
if ($testip=='') { continue; }
if (strstr($REMOTE_ADDR,$testip)==$REMOTE_ADDR || stristr(gethostbyaddr($REMOTE_ADDR),$testip)==$testip){
$isvalidip=1;
break;
}
}
}
//checking if the user login is ok & that he connects from a valid ip
$salt = $userinf['salt'];
$pass = $userinf['password'];
$userp = md5(md5($_SERVER['PHP_AUTH_PW']) . $salt);
if ($pass != $userp) {
//we have a looser:)
header('WWW-Authenticate: Basic realm="Restricted area"');
header('HTTP/1.0 401 Unauthorized');
echo "Unauthorized login attempts are logged.\n";
exit;
}elseif(!$isvalidip){
header('HTTP/1.0 401 Unauthorized');
echo "Your Ip is not allowed here...Unauthorized login attempts are logged.\n";
exit;
}
}
//HTACCESS Hack + IP restriction (end)