That didnt helped. I activated php 5.3 and I get many errors again. This part of the codes doesnt change into brown. it stays black. Any other suggestion? Thanks in advance Nuken. How are you doing with your site and your beautiful work.
no I am doing online. Thanks for replying but I cant find a solution. On the server I have php 5.2 and 5.3 and when I chose 5.3 I get so many deprecated errors.
Joined: Aug 28, 2003 Posts: 6373 Location: Vsetin, Czech Republic
Posted:
Tue Jan 26, 2010 4:22 am
If this is a production site, you should have errors turned off any way as they can reveal sensitive information.
I think E_DEPRECATED is actually under E_ALL in PHP 5.3.x but I could be wrong.
Try
$error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
Joined: Aug 29, 2004 Posts: 9136 Location: Arizona
Posted:
Sat Oct 09, 2010 12:41 pm
Oh, and by the way, if using preg_match, since you're against symbols rather than alphabetic characters, no need to use the "i" option for case insensitive (slower).
Joined: Aug 29, 2004 Posts: 9136 Location: Arizona
Posted:
Sat Oct 09, 2010 1:32 pm
Palbin, I mentioned strpos() in my post, as in this case, I think its slightly better as you really aren't wanting to bring back elements of the string, just trying to determine if the "needle" exists within the string, but either should work in this case.
Joined: Aug 29, 2004 Posts: 9136 Location: Arizona
Posted:
Sun Oct 10, 2010 3:47 pm
Sorry, don't have that kind of time to rewrite this. The first three lines are definitely preg_match() candidates, the fourth strpos() or strstr(), and actually the last two could also be strpos() or strstr().
I already did the whole file and if someone has the time to check it will be nice. Many thanks for all people who participate on this deprecated issues. Let me know if the whole file is correct. I didn't get any error but who knows.
Code:
// NEW Disable Switch
if(@$ab_config['disable_switch'] > 0) { return; }
// Load constant vars
$nsnst_const['server_ip'] = get_server_ip();
if(!preg_match(REGEX_IPV4, $nsnst_const['server_ip'])) { $nsnst_const['server_ip'] = "none"; }
$nsnst_const['client_ip'] = get_client_ip();
if(!preg_match(REGEX_IPV4, $nsnst_const['client_ip'])) { $nsnst_const['client_ip'] = "none"; }
$nsnst_const['forward_ip'] = get_x_forwarded();
if(!preg_match(REGEX_IPV4, $nsnst_const['forward_ip'])) { $nsnst_const['forward_ip'] = "none"; }
$nsnst_const['remote_addr'] = get_remote_addr();
if(!preg_match(REGEX_IPV4, $nsnst_const['remote_addr'])) { $nsnst_const['remote_addr'] = "none"; }
$nsnst_const['remote_ip'] = get_ip();
if(!preg_match(REGEX_IPV4, $nsnst_const['remote_ip'])) { $nsnst_const['remote_ip'] = "none"; }
$nsnst_const['remote_long'] = sprintf("%u", ip2long($nsnst_const['remote_ip']));
$nsnst_const['remote_port'] = get_remote_port();
$nsnst_const['request_method'] = get_request_method();
$nsnst_const['script_name'] = get_script_name();
$nsnst_const['http_host'] = get_http_host();
$nsnst_const['query_string'] = st_clean_string(get_query_string());
$nsnst_const['get_string'] = st_clean_string(get_get_string());
$nsnst_const['post_string'] = st_clean_string(get_post_string());
$nsnst_const['query_string_base64'] = st_clean_string(base64_decode($nsnst_const['query_string']));
$nsnst_const['get_string_base64'] = st_clean_string(base64_decode($nsnst_const['get_string']));
$nsnst_const['post_string_base64'] = st_clean_string(base64_decode($nsnst_const['post_string']));
$nsnst_const['user_agent'] = get_user_agent();
$nsnst_const['referer'] = get_referer();
$nsnst_const['ban_time'] = time();
$nsnst_const['ban_ip'] = "";
if (isset($_COOKIE['user'])) $uinfo = getusrinfo($_COOKIE['user']); else $uinfo = getusrinfo('');
if($uinfo['user_id'] > 1 && !empty($uinfo['username'])) {
$nsnst_const['ban_user_id'] = $uinfo['user_id'];
$nsnst_const['ban_username'] = $uinfo['username'];
} else {
$nsnst_const['ban_user_id'] = 1;
$nsnst_const['ban_username'] = $nuke_config['anonymous'];
}
// Load Blocker Arrays
$result = $db->sql_query("SELECT * FROM `".$prefix."_nsnst_blockers` ORDER BY `blocker`");
$num_rows = $db->sql_numrows($result);
for ($i = 0; $i < $num_rows; $i++) { $blocker_array[$i] = $db->sql_fetchrow($result); }
$db->sql_freeresult($result);
// Check for Flood Attack
// CAUTION: This function sometimes can slow your sites load time
$blocker_row = @$blocker_array[11];
if($blocker_row['activate'] > 0) {
session_start();
//session_name("NSNST_Flood");
if(!isset($_SESSION['NSNST_Flood'])){
$_SESSION['NSNST_Flood'] = time();
ab_flood($blocker_row);
}else{
ab_flood($blocker_row);
$_SESSION['NSNST_Flood'] = time();
}
//session_write_close();
}
// Invalid admin check
if(isset($aid) AND (!isset($_COOKIE['admin']) OR empty($_COOKIE['admin'])) AND $op!='login') { die(_AB_FALSEADMIN); }
if((isset($aid) AND !empty($aid)) AND (!isset($_COOKIE['admin']) OR empty($_COOKIE['admin'])) AND $op!='login') { die(_AB_FALSEADMIN); }
// Stop Santy Worm
if(@$ab_config['santy_protection'] == 1) {
$bad_uri_content=array("rush", "highlight=%", "perl", "chr(", "pillar", "visualcoder", "sess_");
while(list($stid,$uri_content)=each($bad_uri_content)) { if(stristr($_SERVER['REQUEST_URI'], $uri_content)) { die(_AB_SANTY); } }
}
// Invalid ip check
if (@$ab_config['test_switch'] == 1) {;} //Site is in TEST Mode so skip the ipCheck
elseif (isset($bypassNukeSentinelInvalidIPCheck) AND $bypassNukeSentinelInvalidIPCheck===true) {;} //Site is NOT in TEST mode but $bypassNukeSentinelInvalidIPCheck is set to TRUE so skip the ipCheck
else { //Site is NOT in TEST Mode and $bypassNukeSentinelInvalidIPCheck is either not set or it is set to FALSE so do the ipCheck
if($nsnst_const['remote_ip']=="none") {
echo abget_template("abuse_invalid.tpl");
die();
}
}
// Invalid user agent
if((@$nsnst_const['user_agent']=="none" AND !stristr($_SERVER['PHP_SELF'], "backend.php") AND ($nsnst_const['remote_ip'] != $nsnst_const['server_ip'])) || $nsnst_const['user_agent']=="-") {
echo abget_template("abuse_invalid2.tpl");
die();
}
// Invalid request method check
if(strtolower(@$nsnst_const['request_method'])!="get" AND strtolower(@$nsnst_const['request_method'])!="head" AND strtolower(@$nsnst_const['request_method'])!="post" AND strtolower(@$nsnst_const['request_method'])!="put") { die(_AB_INVALIDMETHOD); }
// DOS Attack Blocker
if(@$ab_config['prevent_dos'] == 1 AND !stristr($_SERVER['PHP_SELF'], "backend.php") AND !stristr(@$nuke_config['nukeurl'], $_SERVER['SERVER_NAME'])) {
if(@empty($nsnst_const['user_agent']) || $nsnst_const['user_agent'] == "-" || @!isset($nsnst_const['user_agent'])) { die(_AB_GETOUT); }
}
// Site Switch Check
if(@$ab_config['site_switch'] == 1 AND !stristr($_SERVER['PHP_SELF'], "".$admin_file.".php") AND !is_admin($_COOKIE['admin'])) {
$display_page = abget_template($ab_config['site_reason']);
$display_page = preg_replace("/</body>/i", "<hr noshade='noshade' />\n<div align='right'>"._AB_NUKESENTINEL."</div>\n</body>", $display_page);
die($display_page);
}
// Clearing of expired blocks
// CAUTION: This function can slow your sites load time
$clearedtime = strtotime(date("Y-m-d 23:59:59", $nsnst_const['ban_time']));
$cleartime = strtotime(date("Y-m-d 23:59:59", $nsnst_const['ban_time'])) - 86400;
if(@$ab_config['self_expire'] == 1 AND @$ab_config['blocked_clear'] < $cleartime) {
$clearresult = $db->sql_query("SELECT * FROM `".$prefix."_nsnst_blocked_ips` WHERE (`expires`<'$clearedtime' AND `expires`!='0')");
while($clearblock = $db->sql_fetchrow($clearresult)) {
if(!empty($ab_config['htaccess_path'])) {
$ipfile = file($ab_config['htaccess_path']);
$ipfile = implode("", $ipfile);
$i = 1;
while ($i <= 3) {
$tip = substr($clearblock['ip_addr'], -2);
if($tip == ".*") { $clearblock['ip_addr'] = substr($clearblock['ip_addr'], 0, -2); }
$i++;
}
$testip = "deny from ".$clearblock['ip_addr']."\n";
$ipfile = str_replace($testip, "", $ipfile);
$doit = @fopen($ab_config['htaccess_path'], "w");
@fwrite($doit, $ipfile);
@fclose($doit);
}
$db->sql_query("DELETE FROM `".$prefix."_nsnst_blocked_ips` WHERE `ip_addr`='".$clearblock['ip_addr']."'");
$db->sql_query("OPTIMIZE TABLE `".$prefix."_nsnst_blocked_ips`");
}
$clearresult = $db->sql_query("SELECT * FROM `".$prefix."_nsnst_blocked_ranges` WHERE (`expires`<'$clearedtime' AND `expires`!='0')");
while($clearblock = $db->sql_fetchrow($clearresult)) {
$old_masscidr = ABGetCIDRs($clearblock['ip_lo'], $clearblock['ip_hi']);
if(!empty($ab_config['htaccess_path'])) {
$old_masscidr = explode("||", $old_masscidr);
for ($i=0, $maxi=sizeof($old_masscidr); $i < $maxi; $i++) {
if(!empty($old_masscidr[$i])) {
$old_masscidr[$i] = "deny from ".$old_masscidr[$i]."\n";
}
}
$ipfile = file($ab_config['htaccess_path']);
$ipfile = implode("", $ipfile);
$ipfile = str_replace($old_masscidr, "", $ipfile);
$ipfile = $ipfile;
$doit = @fopen($ab_config['htaccess_path'], "w");
@fwrite($doit, $ipfile);
@fclose($doit);
}
$db->sql_query("DELETE FROM `".$prefix."_nsnst_blocked_ranges` WHERE `ip_lo`='".$clearblock['ip_lo']."' AND `ip_hi`='".$clearblock['ip_hi']."'");
$db->sql_query("OPTIMIZE TABLE `".$prefix."_nsnst_blocked_ranges`");
}
$db->sql_query("UPDATE `".$prefix."_nsnst_config` SET `config_value`='$clearedtime' WHERE `config_name`='blocked_clear'");
}
// Proxy Blocker
if(@$ab_config['proxy_switch'] == 1) {
$proxy0 = $nsnst_const['remote_ip'];
$proxy1 = $nsnst_const['client_ip'];
$proxy2 = $nsnst_const['forward_ip'];
$proxy_host = @getHostByAddr($proxy0);
//Lite:
if($ab_config['proxy_switch'] == 1 AND ($proxy1 != "none" OR $proxy2 != "none")) {
$display_page = abget_template($ab_config['proxy_reason']);
$display_page = preg_replace("/</body>/i", "<hr noshade='noshade' />\n<div align='right'>"._AB_NUKESENTINEL." ".$ab_config['version_number']." "._AB_BYNSN."</div>\n</body>", $display_page);
die($display_page);
}
//Mild:
if($ab_config['proxy_switch'] == 2 AND ($proxy1 != "none" OR $proxy2 != "none" OR stristr($proxy_host,"proxy"))) {
$display_page = abget_template($ab_config['proxy_reason']);
$display_page = preg_replace("/</body>/i", "<hr noshade='noshade' />\n<div align='right'>"._AB_NUKESENTINEL." ".$ab_config['version_number']." "._AB_BYNSN."</div>\n</body>", $display_page);
die($display_page);
}
//Strong:
if($ab_config['proxy_switch'] == 3 AND ($proxy1 != "none" OR $proxy2 != "none" OR stristr($proxy_host,"proxy") OR $proxy0 == $proxy_host)) {
$display_page = abget_template($ab_config['proxy_reason']);
$display_page = preg_replace("/</body>/i", "<hr noshade='noshade' />\n<div align='right'>"._AB_NUKESENTINEL." ".$ab_config['version_number']." "._AB_BYNSN."</div>\n</body>", $display_page);
die($display_page);
}
}
// Check if ip is blocked
$blocked_row = abget_blocked($nsnst_const['remote_ip']);
if($blocked_row) { blocked($blocked_row); }
// Check if range is blocked
$blockedrange_row = abget_blockedrange($nsnst_const['remote_ip']);
if($blockedrange_row) { blockedrange($blockedrange_row); }
// AUTHOR Protection
$blocker_row = @$blocker_array[5];
if($blocker_row['activate'] > 0) {
if(isset($op) AND ($op=="mod_authors" OR $op=="modifyadmin" OR $op=="UpdateAuthor" OR $op=="AddAuthor" OR $op=="deladmin2" OR $op=="deladmin" OR $op=="assignstories" OR $op=="deladminconf") AND !is_god($_COOKIE['admin'])) {
block_ip($blocker_row);
}
}
// ADMIN protection
$blocker_row = @$blocker_array[10];
if($blocker_row['activate'] > 0) {
if(stristr($_SERVER['PHP_SELF'],"".$admin_file.".php") AND (isset($op) AND $op!="login" AND $op!="adminMain" AND $op!="gfx") AND @!is_admin($_COOKIE['admin'])) {
block_ip($blocker_row);
}
}
// Check for UNION attack
// Copyright 2004(c) Raven PHP Scripts
$blocker_row = @$blocker_array[1];
if($blocker_row['activate'] > 0 AND (!isset($_COOKIE['admin']) OR !is_admin($_COOKIE['admin']))) {
if(stristr($nsnst_const['query_string'],'+or+')
OR stristr($nsnst_const['query_string'],'*/or/*')
OR stristr($nsnst_const['query_string_base64'],'+or+')
OR stristr($nsnst_const['query_string_base64'],'*/or/*')) {
block_ip($blocker_row);
}
//TECHNOCRAT
if(preg_match(REGEX_UNION, $nsnst_const['query_string'])) {
block_ip($blocker_row);
}
}
// Check for CLIKE attack
// Copyright 2004(c) Raven PHP Scripts
$blocker_row = @$blocker_array[2];
if($blocker_row['activate'] > 0) {
if(stristr($nsnst_const['query_string'],'/*')
OR stristr($nsnst_const['query_string_base64'],'/*')
OR stristr($nsnst_const['query_string'],'*/')
OR stristr($nsnst_const['query_string_base64'],'*/')) {
block_ip($blocker_row);
}
}
// Check Filters
$blocker_row = @$blocker_array[7];
if($blocker_row['activate'] > 0) {
// Check for Forum attack
// Copyright 2004(c) GanjaUK & ChatServ
if(!stristr($nsnst_const['query_string'],'&file=nickpage')
AND stristr($nsnst_const['query_string'],'&user=')
AND ($name=="Private_Messages" || $name=="Forums" || $name=="Members_List")) {
block_ip($blocker_row);
}
// Check for News attack
// Copyright 2004(c) ChatServ
if(stristr($nsnst_const['query_string'],'%25') AND ($name=="News" || $name=="Reviews")) {
block_ip($blocker_row);
}
// Check for XSS attack
if(!stristr($nsnst_const['query_string'], "index.php?url=") AND (!isset($_COOKIE['admin']) OR !is_admin($_COOKIE['admin']))) {
if( (isset($name) AND (preg_match("/http\:\/\//i", $name) OR preg_match("/https\:\/\//i", $name)))
OR (isset($file) AND (preg_match("/http\:\/\//i", $file) OR preg_match("/https\:\/\//i", $file)))
OR (isset($libpath) AND (preg_match("/http\:\/\//i", $libpath) OR preg_match("/https\:\/\//i", $libpath)))
OR stristr($nsnst_const['query_string'], "http://") OR stristr($nsnst_const['query_string'], "https://")
OR stristr($nsnst_const['query_string'], "_SERVER=") OR stristr($nsnst_const['query_string'], "_COOKIE=")
OR ( stristr($nsnst_const['query_string'], "cmd=") AND !stristr($nsnst_const['query_string'], "&cmd") )
OR ( stristr($nsnst_const['query_string'], "exec") AND !stristr($nsnst_const['query_string'], "execu") )
OR stristr($nsnst_const['query_string'],"concat") AND !stristr($nsnst_const['query_string'], "../") ) {
block_ip($blocker_row);
}
}
}
// if (!isset($_COOKIE['admin']) AND !is_admin($_COOKIE['admin'])) {
if (@is_admin($_COOKIE['admin'])==false) {
// Check for SCRIPTING attack
// Copyright 2004(c) ChatServ
$blocker_row = @$blocker_array[4];
if($blocker_row['activate'] > 0) {
foreach($_GET as $sec_key => $secvalue) {
if((preg_match("/<[^>]script*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*object*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*iframe*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*applet*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*meta*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]style*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*form*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*img*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]*onmouseover*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/<[^>]body*\"?[^>]*>/i", $secvalue) && !preg_match("/<[^>]tbody*\"?[^>]*>/i", $secvalue)) ||
(preg_match("/\([^>]*\"?[^)]*\)/i", $secvalue)) ||
(strpos("/\"", $secvalue)) ||
(strpos("forum_admin", $sec_key)) ||
(strpos("inside_mod", $sec_key))) {
block_ip($blocker_row);
}
}
// BEGIN - Added by Raven 11/19/2007 to exclude Forums and Private_Message Posting blocks
$qs = $nsnst_const['query_string'];
$qsName = explode('name=', $qs);
$qsName = @explode('&',$qsName[1]);
if (stristr($qs,'name=Forums')!==false && stristr($qs,'file=posting')!==false && (strtolower($qsName[0])=="private_messages" || strtolower($qsName[0])=="forums")) {
// The following code is strictly for testing purposes.
// Uncomment the lines and change the 2 email address calls (you@your_domain.xxx) in the mail function call to your address to see the posts that are being allowed.
// Otherwise this code should not be used.
//$psValue = empty($nsnst_const['post_string']) ? 'None' : htmlentities($nsnst_const['post_string']);
//if ($psValue!=='None' && stristr($psValue,'&post=Submit')!==false) @mail('you@your_domain.xxx','NS Script Blocker Activated - Trapped',"name = $name \n module_name = $module_name \n qs = $qs \n qsName[0] = ".$qsName[0]."\n qsName[1] = ".$qsName[1]."\n\n psValue = $psValue \n","From:
Only registered users can see links on this board! Get registered or login to the forums!
function abget_blockedrange($remoteip){
global $prefix, $db;
$longip = sprintf("%u", ip2long($remoteip));
$blockedrange_result = $db->sql_query("SELECT * FROM `".$prefix."_nsnst_blocked_ranges` WHERE `ip_lo`<='$longip' AND `ip_hi`>='$longip'");
$blockedrange_row = $db->sql_fetchrow($blockedrange_result);
return $blockedrange_row;
}
function abget_blocker($blocker_name){
global $prefix, $db;
$blockerresult = $db->sql_query("SELECT * FROM `".$prefix."_nsnst_blockers` WHERE `block_name`='$blocker_name'");
$blocker_row = $db->sql_fetchrow($blockerresult);
return $blocker_row;
}
function abget_blockerrow($reason){
global $prefix, $db;
$blockerresult = $db->sql_query("SELECT * FROM `".$prefix."_nsnst_blockers` WHERE `blocker`='$reason'");
$blocker_row = $db->sql_fetchrow($blockerresult);
return $blocker_row;
}
function abget_admin($author){
global $prefix, $db;
$adminresult = $db->sql_query("SELECT * FROM `".$prefix."_nsnst_admins` WHERE `aid`='$author'");
$admin_row = $db->sql_fetchrow($adminresult);
return $admin_row;
}
function abget_configs(){
global $prefix, $db, $config;
$configresult = $db->sql_query("SELECT `config_name`, `config_value` FROM `".$prefix."_nsnst_config`");
while (list($config_name, $config_value) = $db->sql_fetchrow($configresult)) {
$config[$config_name] = $config_value;
}
return $config;
}
function abget_reason($reason_id){
global $prefix, $db;
$reasonresult = $db->sql_query("SELECT `reason` FROM `".$prefix."_nsnst_blockers` WHERE `blocker`='$reason_id'");
list($title_long) = $db->sql_fetchrow($reasonresult);
$reason_value = $title_long;
return $reason_value;
}
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum