Source codes, small scripts...

Started on the old forum in June 2006 · view the original in the archive · old links redirect here

124 replies · 52,842 views · started 20 years ago · 1 min read

TL;DR · summary of 124 replies
  • - The scripts and codes related to redirection, user online status, image resizer, PHP file upload script, and environment variables were discussed.
  • - No specific fix or code approach was provided for the Wap Useronline Sql tables script or the randomize banners script.
  • - The existence of a function to detect spammer emails was mentioned but no detailed code approach was given.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

24 participants
something else Fellow · 2,296 posts #61

slight spelling errors in the strings names:

function GetCountry($IpAddr){

change to:

function GetCountry($$IpAdds){

It is a long way to go about getting countrys lol but if anyones intrested in doing it this way heres some country codes:

AD   Andorra
AE   United Arab Emirates
AF   Afghanistan
AG   Antigua and Barbuda
AI   Anguilla
AL   Albania
AM   Armenia
AN   Netherlands Antilles
AO   Angola
AQ   Antarctica
AR   Argentina
AS   American Samoa
AT   Austria
AU   Australia
AW   Aruba
AZ   Azerbaijan
BA   Bosnia and Herzegovina
BB   Barbados
BD   Bangladesh
BE   Belgium
BF   Burkina Faso
BG   Bulgaria
BH   Bahrain
BI   Burundi
BJ   Benin
BM   Bermuda
BN   Brunei Darussalam
BO   Bolivia
BR   Brazil
BS   Bahamas
BT   Bhutan
BV   Bouvet Island
BW   Botswana
BY   Belarus
BZ   Belize
CA   Canada
CC   Cocos (Keeling) Islands
CF   Central African Republic
CG   Congo
CH   Switzerland
CI   Cote D'Ivoire (Ivory Coast)
CK   Cook Islands
CL   Chile
CM   Cameroon
CN   China
CO   Colombia
CR   Costa Rica
CS   Czechoslovakia (former)
CU   Cuba
CV   Cape Verde
CX   Christmas Island
CY   Cyprus
CZ   Czech Republic
DE   Germany
DJ   Djibouti
DK   Denmark
DM   Dominica
DO   Dominican Republic
DZ   Algeria
EC   Ecuador
EE   Estonia
EG   Egypt
EH   Western Sahara
ER   Eritrea
ES   Spain
ET   Ethiopia
FI   Finland
FJ   Fiji
FK   Falkland Islands (Malvinas)
FM   Micronesia
FO   Faroe Islands
FR   France
FX   France, Metropolitan
GA   Gabon
GB   Great Britain (UK)
GD   Grenada
GE   Georgia
GF   French Guiana
GH   Ghana
GI   Gibraltar
GL   Greenland
GM   Gambia
GN   Guinea
GP   Guadeloupe
GQ   Equatorial Guinea
GR   Greece
GS   S. Georgia and S. Sandwich Isls.
GT   Guatemala
GU   Guam
GW   Guinea-Bissau
GY   Guyana
HK   Hong Kong
HM   Heard and McDonald Islands
HN   Honduras
HR   Croatia (Hrvatska)
HT   Haiti
HU   Hungary
ID   Indonesia
IE   Ireland
IL   Israel
IN   India
IO   British Indian Ocean Territory
IQ   Iraq
IR   Iran
IS   Iceland
IT   Italy
JM   Jamaica
JO   Jordan
JP   Japan
KE   Kenya
KG   Kyrgyzstan
KH   Cambodia
KI   Kiribati
KM   Comoros
KN   Saint Kitts and Nevis
KP   Korea (North)
KR   Korea (South)
KW   Kuwait
KY   Cayman Islands
KZ   Kazakhstan
LA   Laos
LB   Lebanon
LC   Saint Lucia
LI   Liechtenstein
LK   Sri Lanka
LR   Liberia
LS   Lesotho
LT   Lithuania
LU   Luxembourg
LV   Latvia
LY   Libya
MA   Morocco
MC   Monaco
MD   Moldova
MG   Madagascar
MH   Marshall Islands
MK   Macedonia
ML   Mali
MM   Myanmar
MN   Mongolia
MO   Macau
MP   Northern Mariana Islands
MQ   Martinique
MR   Mauritania
MS   Montserrat
MT   Malta
MU   Mauritius
MV   Maldives
MW   Malawi
MX   Mexico
MY   Malaysia
MZ   Mozambique
NA   Namibia
NC   New Caledonia
NE   Niger
NF   Norfolk Island
NG   Nigeria
NI   Nicaragua
NL   Netherlands
NO   Norway
NP   Nepal
NR   Nauru
NT   Neutral Zone
NU   Niue
NZ   New Zealand (Aotearoa)
OM   Oman
PA   Panama
PE   Peru
PF   French Polynesia
PG   Papua New Guinea
PH   Philippines
PK   Pakistan
PL   Poland
PM   St. Pierre and Miquelon
PN   Pitcairn
PR   Puerto Rico
PT   Portugal
PW   Palau
PY   Paraguay
QA   Qatar
RE   Reunion
RO   Romania
RU   Russian Federation
RW   Rwanda
SA   Saudi Arabia
Sb   Solomon Islands
SC   Seychelles
SD   Sudan
SE   Sweden
SG   Singapore
SH   St. Helena
SI   Slovenia
SJ   Svalbard and Jan Mayen Islands
SK   Slovak Republic
SL   Sierra Leone
SM   San Marino
SN   Senegal
SO   Somalia
SR   Suriname
ST   Sao Tome and Principe
SU   USSR (former)
SV   El Salvador
SY   Syria
SZ   Swaziland
TC   Turks and Caicos Islands
TD   Chad
TF   French Southern Territories
TG   Togo
TH   Thailand
TJ   Tajikistan
TK   Tokelau
TM   Turkmenistan
TN   Tunisia
TO   Tonga
TP   East Timor
TR   Turkey
TT   Trinidad and Tobago
TV   Tuvalu
TW   Taiwan
TZ   Tanzania
UA   Ukraine
UG   Uganda
UK   United Kingdom
UM   US Minor Outlying Islands
US   United States
UY   Uruguay
UZ   Uzbekistan
VA   Vatican City State (Holy See)
VC   Saint Vincent and the Grenadines
VE   Venezuela
VG   Virgin Islands (British)
VI   Virgin Islands (U.S.)
VN   Viet Nam
VU   Vanuatu
WF   Wallis and Futuna Islands
WS   Samoa
YE   Yemen
YT   Mayotte
YU   Yugoslavia
ZA   South Africa
ZM   Zambia
ZR   Zaire
ZW   Zimbabwe
GumSlone Administrator Principal · 1,690 posts #62

Change database collation.

<?
#########################################################################
#########################################################################
##																	 ##
## Script coded by Eric Reiche										 ##
##																	 ##
## Version: 0.2 / 2006-08-16 17:35 GMT + 100						   ##
## Version 0.2 contains bugfixes									   ##
##																	 ##
## Inspired by serversupportforum.de user monotek					  ##
## ( [url="http://www.serversupportforum.de/forum/sql/"]http://www.serversupportforum.de/forum/sql/[/url]		\			  ##
## 9279-kollation-von-tabellen-aendern.html#post67293 )				##
## [Check link  for bashscript]										##
##																	 ##
## Web: [url="http://www.ericreiche.net"]http://www.ericreiche.net[/url]  ||  Mail: [email]webmaster@ericreiche.net[/email]  ##
##																	 ##
## You can spread this script, until you don't touch this copymark	 ##
##																	 ##
#########################################################################
#########################################################################

//Config:
  $mysqlserver = 'localhost';	//Host
  $mysqluser = 'root';		   //User [It's recomment to use root]
  $mysqlpw = 'passwort';				 //Password
  $mysqldb = 'datenbank';	   //Database
  $stepping = 100;			   //Queries per Page
  $tabletoskip = 'really_big_table'; //If you have a really big table, you can enter it here,
								 //it will be skipped, to prevent a script abort
							   
  $collation = 'latin1_german2_ci';
  $character_set = 'latin1';
//End Config

#######################################################################
# Do not change anything from here, until you know what you're doing  #
#######################################################################
  
if(isset($_GET['start']) && is_numeric($_GET['start'])){
  $start = $_GET['start'];
  if($start > 0){
	$start = $start * $stepping;
  }
}else{
  $start = 0;
}
//mysql connect
@mysql_connect($mysqlserver, $mysqluser, $mysqlpw) OR die("No Conncection to Server. Report: :".mysql_error());
mysql_select_db($mysqldb) OR die("couldn't select database, Report: ".mysql_error());
unset($mysqlserver);
unset($mysqluser);
unset($mysqlpw);

$i = 0;
print('<pre>');
if($start == 0){
  $sql = 'ALTER DATABASE '.$mysqldb.' DEFAULT CHARACTER SET '.$character_set.' COLLATE '.$collation.";\r\n";
  mysql_query($sql);
  print($sql);
}

$sql = 'Show tables;';
$result1 = mysql_query($sql);
while($tables = mysql_fetch_assoc($result1)){
	if($start == 0){
	$sql = 'ALTER TABLE '.$tables['Tables_in_'.$mysqldb].' DEFAULT CHARACTER SET '.$character_set.' COLLATE '.$collation.";\r\n";
	mysql_query($sql);
	print(''.$sql);
  }
  
  $sql = 'Show columns FROM '.$tables['Tables_in_'.$mysqldb];
  $result2 = mysql_query($sql);
  
  while($columns = mysql_fetch_assoc($result2)){
	
	if(substr_count($columns['Type'], 'varchar') || substr_count($columns['Type'], 'text')){
	  $i++;
	  if($i >= $start && $i < ($start + $stepping)){
		$sql = 'ALTER TABLE '.$tables['Tables_in_'.$mysqldb].' CHANGE '.$columns['Field'].' '.$columns['Field'].' '.$columns['Type'].' CHARACTER SET '.$character_set.' COLLATE '.$collation.';';
		if($tabletoskip != $tables['Tables_in_'.$mysqldb]){
		  mysql_query($sql);
		  print(''.$i.'. '.$sql."\r\n");
		}else{
		  print(''.$i.'. SKIPPED: '.$sql."\r\n");
		}
	  }
	}
  }

}
print('</pre>');

  print('<a href="'.$_SERVER['PHP_SELF'].'?start='.($_GET['start'] + 1).'">Weiter...</a>');

?>

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

djdeny Junior · 12 posts #63

create image via php, with referer, browser and ip info 😉

<?php
header("Content-type: image/png");

$im = ImageCreateFromgif("default.gif");
ImageString ($im, 2, 10, 36, i,2);
imagepng($im);

$ref = $_SERVER['HTTP_REFERER'];
$ip = $_SERVER['REMOTE_ADDR'];
$vrijeme = date("H:i:s d/m/Y");
$browser = $_SERVER['HTTP_USER_AGENT'];
$file = "info.txt";
$fp = fopen($file, "a");

$sve = "IP:$ip \r\n Bro: $browser \r\n Link: $ref \r\n Time: $vrijeme \r\n \r\n\r\n";
fwrite($fp,$sve);
fclose($fp);
?>
something else Fellow · 2,296 posts #64

Fake referer

<?php
$host = 'www.mydomainname.com ';
$service_uri = '/index.php';
$vars ='additional_option1=yes&additional_option2=un';
$header = "Host: $host\r\n";
$header .= "Referer: http://www.xxxxx.com\r\n";
$header .= "accept-language: en\r\n";
$header .= "User-Agent: vvvvv\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($vars)."\r\n";
$header .= "Connection: close\r\n\r\n";
$fp = fsockopen("".$host,80, $errno, $errstr);
if (!$fp) {
$errstr ($errno);
$fp;
}
 else {
 fputs($fp, "POST $service_uri HTTP/1.1\r\n");
fputs($fp, $header.$vars);
fwrite($fp, $out);
while (!feof($fp)) {
fgets($fp, 12;
}
fclose($fp);
}
 ?>
GumSlone Administrator Principal · 1,690 posts #65

Get useragent eg googlebot, or NokiaN95 istead of mozilla or opera mini, this function i have developed with alesh's help

function get_mob_browser($_mob_browser)
{

if(preg_match('/(google|bot)/i',strtolower($_mob_browser)))
{
$position = strpos(strtolower($_mob_browser),"bot");
$_mob_browser = substr($_mob_browser, $position-30, $position+2);
$_browser = explode (" ", $_mob_browser);
 $_browser = array_reverse($_browser); 
}
else if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])) 
{
$_mob_browser = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
$_position=strpos(strtolower($_mob_browser),"nokia");
if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
$_browser = explode ("/", $_mob_browser);
}
else 
{
$_position=strpos(strtolower($_mob_browser),"nokia");
if($_position)$_mob_browser = substr($_mob_browser, $_position,25);
$_browser = explode ("/", $_mob_browser);
}

return $_browser[0];
 }

Usage:

echo get_mob_browser($_SERVER['HTTP_USER_AGENT']);

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

something else Fellow · 2,296 posts #66

nice function gum 🙂 does HTTP_X_OPERAMINI_PHONE_UA work better than HTTP_X_OPERAMINI_PHONE ? also it still wont work against n95 hidden behind opera 8.65 maybee an added option of $n95 = explode ("/", $_mob_browser); $opera = explode ("Opera", $_mob_browser); if(($n95[1]=="4.0 (compatible; MSIE 6.0; Symbian OS; Series 60)")&&($opera[1]==" 8.65 [en]"){ $_browser[0] = "Nokia N95 (opera 8.65)"; } or is there other s60v3 phones that show the same on opera?

GumSlone Administrator Principal · 1,690 posts #67

ban ip range or ip

$getip = $_SERVER["REMOTE_ADDR"];
$banned_ip = array();

$banned_ip[] = '194.9.94.*';
$banned_ip[] = '77.105.2.*';

foreach($banned_ip as $banned)
{
$blacked=str_replace('*', '', $banned);
$len=strlen($blacked);
if ($getip==$blacked || substr($getip, 0, $len)==$blacked)
{
$_banned_ip=true;
}
}

if($_banned_ip==true){ 
echo 'THIS IP IS BANNED!';
exit; 
}

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

metulj Super moderator Principal · 1,726 posts #69

QUOTE (sweetangel @ Mar 7 2009, 10:33 AM) <{POST_SNAPBACK}>

boss is good ban range like this :

77...*

it would be just

77.*

and you do unerstand that will ban any one who's IP starts with 77 ?

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

rukiya Lead · 569 posts #70

That is the wildcard character which may be substituted for any of a defined subset of all possible characters

This will ban 77...* the 3 subnos and the range is 77.0.0.0- 77.255.255.255 which will ban 256x256x256=16777216 ips. But 77.105.2.* will ban just a subno and the range is 77.105.2.0- 77.105.2.255 which will ban only 256 ips.

Moreover it can be done with htaccess using <deny>

subzero Super moderator Fellow · 3,954 posts #71

Like

deny from <USER IP>

Not always need

<Files 404.shtml>
order allow,deny
allow from all
</Files>

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

Anshul Senior · 296 posts #72

gzcompress

<?php

function miscGzHandler($buf) {
    $zipRatio = 5;
    $zipDebug = 1;

    if(empty($buf) || !function_exists('gzcompress') || !isset($_SERVER['HTTP_ACCEPT_ENCODING'])) return $buf;
    $enc_ar = explode(',', $_SERVER['HTTP_ACCEPT_ENCODING']);
    $mayZip = false; $encoding = '';
    foreach($enc_ar as $enc) {
        $enc = trim($enc);
        if('gzip' == $enc || 'x-gzip' == $enc) {
            $mayZip = true;
            $encoding = $enc;
            break;
        }
    }
    if(!$mayZip) return $buf;

    $bufZiped = gzcompress($buf, $zipRatio);
    if($zipDebug) {
        $bufLen = strlen($buf);
        $bufZipedLen= strlen($bufZiped);
        $buf .= (2 == $zipDebug) ? "\n\n<!"."--\n" : "\n
<pre style='width:15%; border:3px ridge; background-color:white; color:gray; font:xx-small Lucida Console, Courier New; padding:3px; margin:10px;'>\n";
        $buf .= "HTML content    : ".$bufLen." bytes\n";
        $buf .= "Compressed      : ".$bufZipedLen." bytes\n";
        $buf .= "GZip level      : ".$zipRatio."\n";
        $buf .= "Size difference : ".sprintf("%.1f%%", $bufZipedLen*100/$bufLen)."\n";
        $buf .= "Size ratio      : ".sprintf("%.1f", $bufLen/$bufZipedLen)." times\n";
        $buf .= (2 == $zipDebug) ? "--".">\n" : "</pre>\n";
        $bufZiped = gzcompress($buf, $zipRatio);
    }
    $bufZiped = pack('cccccccc',0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00)
        .substr($bufZiped, 0, -4)
        .pack('V',crc32($buf))
        .pack('V',strlen($buf));
    header('Content-encoding: '.$encoding);
    header('Content-length: '.strlen($bufZiped));
    return $bufZiped;
}

ob_start('miscGzHandler');

?>
Anshul Senior · 296 posts #73
function delhtml($str) 
{
return mysql_real_escape_string(htmlspecialchars($str));
}

if(isset($_GET)){foreach($_GET as $key=>$value){$_GET[$key]=delhtml($value);}}
if(isset($_POST)){foreach($_POST as $key=>$value){$_POST[$key]=delhtml($value);}}
if(isset($_SESSION)){foreach($_SESSION as $key=>$value){$_SESSION[$key]=delhtml($value);}}
if(isset($_COOKIE)){foreach($_COOKIE as $key=>$value){$_COOKIE[$key]=delhtml($value);}}
subzero Super moderator Fellow · 3,954 posts #74

I got a better way for that code

use $_REQUEST

One line do all lmao

if(isset($_REQUEST)){foreach($_REQUEST as $key=>$value){$_REQUEST[$key]=delhtml($value);}}
function delhtml($str) {
return mysql_real_escape_string(htmlspecialchars($str));
}

if(isset($_GET)){foreach($_GET as $key=>$value){$_GET[$key]=delhtml($value);}}
if(isset($_POST)){foreach($_POST as $key=>$value){$_POST[$key]=delhtml($value);}}
if(isset($_SESSION)){foreach($_SESSION as $key=>$value){$_SESSION[$key]=delhtml($value);}}
if(isset($_COOKIE)){foreach($_COOKIE as $key=>$value){$_COOKIE[$key]=delhtml($value);}}

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

subzero Super moderator Fellow · 3,954 posts #75

It gets cookies

it do all in one 🙂

Works on my site

The $_REQUEST Variable

The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.

The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

GumSlone Administrator Principal · 1,690 posts #76

Anti sql injection

ANTI SQL INJECTION Function

function check_injection()
  {
    $badchars = array("DROP", "SELECT", "UPDATE", "DELETE", "DELETE" , "UNION", "WHERE", "FROM");
  
    foreach($_REQUEST  as $value)
    {
      if(in_array(strtoupper($value), $badchars))
      {
      $logfile= 'log/log.txt'; //chmod 777
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].' target=_blank>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "r+");
fwrite($fp, $logdetails, strlen($logdetails));
fclose($fp);

       header('Location:http://go-to-hell.com');

      }
      else
      {
        $check = preg_split("//", $value, -1, PREG_SPLIT_OFFSET_CAPTURE);
        foreach($check as $char)
        {
         if(in_array(strtoupper($char), $badchars))
          {
      $logfile= 'log/log.txt';
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].' target=_blank>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "r+");
fwrite($fp, $logdetails, strlen($logdetails));
fclose($fp);

            header('Location:http://go-to-hell.com');
     }
    }
   }
  }
  }

and add in the begining of your script:

check_injection();

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Anshul Senior · 296 posts #77
if ($register_glob == 1){
if (!ini_get('register_globals')) {
  $superglobals = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET);

  if (isset($_SESSION)) {
    array_unshift($superglobals, $_SESSION);
  }

  foreach ($superglobals as $superglobal) {
    extract($superglobal, EXTR_SKIP);
  }
}
}

usage

$register_glob = 1; //register_globals 1=on 0=off
sweetangel Lead · 885 posts #78

GumSlone wrote: ANTI SQL INJECTION Function

function check_injection()
  {
    $badchars = array("DROP", "SELECT", "UPDATE", "DELETE", "DELETE" , "UNION", "WHERE", "FROM");
  
    foreach($_REQUEST  as $value)
    {
      if(in_array(strtoupper($value), $badchars))
      {
      $logfile= 'log/log.txt'; //chmod 777
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].' target=_blank>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "r+");
fwrite($fp, $logdetails, strlen($logdetails));
fclose($fp);

       header('Location:http://go-to-hell.com');

      }
      else
      {
        $check = preg_split("//", $value, -1, PREG_SPLIT_OFFSET_CAPTURE);
        foreach($check as $char)
        {
         if(in_array(strtoupper($value), $badchars))
          {
      $logfile= 'log/log.txt';
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].' target=_blank>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "r+");
fwrite($fp, $logdetails, strlen($logdetails));
fclose($fp);

            header('Location:http://go-to-hell.com');
     }
    }
   }
  }
  }

and add in the begining of your script:

check_injection();

this is very good code buddy 🙂

if like my post click:

External image (may be gone)

Anshul Senior · 296 posts #79

real IP address

function getIpAddress() {
return (empty($_SERVER['HTTP_CLIENT_IP'])?(empty($_SERVER['HTTP_X_FORWARDED_FOR'])?
$_SERVER['REMOTE_ADDR']:$_SERVER['HTTP_X_FORWARDED_FOR']):$_SERVER['HTTP_CLIENT_IP']);
}

usage

$ip=getIpAddress();
GumSlone Administrator Principal · 1,690 posts #80

php header();

Here are some usefull headers,

// See related links for more status codes

// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');

// Page was not found:
header('HTTP/1.1 404 Not Found');

// Access forbidden:
header('HTTP/1.1 403 Forbidden');

// The page moved permanently should be used for
// all redrictions, because search engines know
// what's going on and can easily update their urls.
header('HTTP/1.1 301 Moved Permanently');

// Server error
header('HTTP/1.1 500 Internal Server Error');

// Redirect to a new location:
header('Location: http://www.example.org/');

// Redriect with a delay:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';

// you can also use the HTML syntax:
// <meta http-equiv="refresh" content="10;http://www.example.org/ />

// override X-Powered-By value
header('X-Powered-By: PHP/4.4.0');
header('X-Powered-By: Brain/0.6b');

// content language (en = English)
header('Content-language: en');

// last modified (good for caching)
$time = time() - 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');

// header for telling the browser that the content
// did not get changed
header('HTTP/1.1 304 Not Modified');

// set content length (good for caching):
header('Content-Length: 1234');

// Headers for an download:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"'); 
header('Content-Transfer-Encoding: binary');
// load the file to send:
readfile('example.zip');

// Disable caching of the current document:
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');

// set content type:
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); // plain text file
header('Content-Type: image/jpeg'); // JPG picture
header('Content-Type: application/zip'); // ZIP file
header('Content-Type: application/pdf'); // PDF file
header('Content-Type: audio/mpeg'); // Audio MPEG (MP3,...) file
header('Content-Type: application/x-shockwave-flash'); // Flash animation

// show sign in box
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';

this is a copy and paste code from http://www.jonasjohn.de/snippets/php/headers.htm

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close