Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- User-agent: Mediapartners-Google
- Disallow:
- User-agent: Googlebot
- Disallow:
- User-agent: Adsbot-Google
- Disallow:
- User-agent: Googlebot-Image
- Disallow:
- User-agent: Googlebot-Mobile
- Disallow:
- User-agent: MSNBot
- Disallow:
- User-agent: bingbot
- Disallow:
- User-agent: Slurp
- Disallow:
- User-Agent: Yahoo! Slurp
- Disallow:
- # Directories
- User-agent: *
- Disallow: /
- Disallow: /cgi-bin/
- Disallow: /ads/
- Disallow: /assets/
- Disallow: /cgi-bin/
- Disallow: /phone/
- Disallow: /scripts/
- # Files
- Disallow: /ads/random_ads.php
- Disallow: /scripts/rss2html.php
- Disallow: /scripts/search_terms.php
- Disallow: /scripts/template.html
- Disallow: /scripts/template_mobile.html
- ErrorDocument 400 http://english-1329329990.spampoison.com
- ErrorDocument 401 http://english-1329329990.spampoison.com
- ErrorDocument 403 http://english-1329329990.spampoison.com
- ErrorDocument 404 /index.php
- SetEnvIfNoCase User-Agent "^Yandex*" bad_bot
- SetEnvIfNoCase User-Agent "^baidu*" bad_bot
- Order Deny,Allow
- Deny from env=bad_bot
- RewriteEngine on
- RewriteCond %{HTTP_user_agent} bot* [OR]
- RewriteCond %{HTTP_user_agent} *bot
- RewriteRule ^.*$ http://english-1329329990.spampoison.com [R,L]
- RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [OR]
- # Block out any script trying to base64_encode crap to send via URL
- RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]
- # Block out any script that includes a <script> tag in URL
- RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
- # Block out any script trying to set a PHP GLOBALS variable via URL
- RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
- # Block out any script trying to modify a _REQUEST variable via URL
- RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
- # Send all blocked request to homepage with 403 Forbidden error!
- RewriteRule ^(.*)$ index.php [F,L]
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteCond %{REQUEST_URI} !^/index.php
- RewriteCond %{REQUEST_URI} (/|.php|.html|.htm|.feed|.pdf|.raw|/[^.]*)$ [NC]
- RewriteRule (.*) index.php
- RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
- # Don't show directory listings for directories that do not contain an index file (index.php, default.asp etc.)
- Options -Indexes
- <Files http://english-1329329990.spampoison.com>
- order allow,deny
- allow from all
- </Files>
- deny from 108.
- deny from 123.
- deny from 180.
- deny from 100.43.83.132
- <?php
- function botcheck(){
- $spiders = array(
- array('AdsBot-Google','google.com'),
- array('Googlebot','google.com'),
- array('Googlebot-Image','google.com'),
- array('Googlebot-Mobile','google.com'),
- array('Mediapartners','google.com'),
- array('Mediapartners-Google','google.com'),
- array('msnbot','search.msn.com'),
- array('bingbot','bing.com'),
- array('Slurp','help.yahoo.com'),
- array('Yahoo! Slurp','help.yahoo.com')
- );
- $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
- foreach($spiders as $bot) {
- if(preg_match("/$bot[0]/i",$useragent)){
- $ipaddress = $_SERVER['REMOTE_ADDR'];
- $hostname = gethostbyaddr($ipaddress);
- $iphostname = gethostbyname($hostname);
- if (preg_match("/$bot[1]/i",$hostname) && $ipaddress == $iphostname){return true;}
- }
- }
- }
- if(botcheck() == false) {
- // User Login - Read Cookie values
- $username = $_COOKIE['username'];
- $password = $_COOKIE['password'];
- $radio_1 = $_COOKIE['radio_1'];
- $radio_2 = $_COOKIE['radio_2'];
- if (($username == 'm3s36G6S9v' && $password == 'S4er5h8QN2') || ($radio_1 == '2' && $radio_2 == '5')) {
- } else {
- $selected_username = $_POST['username'];
- $selected_password = $_POST['password'];
- $selected_radio_1 = $_POST['group1'];
- $selected_radio_2 = $_POST['group2'];
- if (($selected_username == 'm3s36G6S9v' && $selected_password == 'S4er5h8QN2') || ($selected_radio_1 == '2' && $selected_radio_2 == '5')) {
- setcookie("username", $selected_username, time()+3600, "/");
- setcookie("password", $selected_password, time()+3600, "/");
- setcookie("radio_1", $selected_radio_1, time()+3600, "/");
- setcookie("radio_2", $selected_radio_2, time()+3600, "/");
- } else {
- header("Location: login.html");
- }
- }
- }
- ?>
- // Checks to see if this script was called by the main site pages, (i.e. index.php or mobile.php) and if not, then sends to main page
- session_start();
- if(isset($_SESSION['views'])){$_SESSION['views'] = $_SESSION['views']+ 1;} else {$_SESSION['views'] = 1;}
- if($_SESSION['views'] > 1) {header("Location: http://website.com/index.php");}
- if(isset($_SERVER['HTTP_USER_AGENT'])){
- $agent = $_SERVER['HTTP_USER_AGENT'];
- }
- if(preg_match('/^Googlebot/i',$agent)){
- http_response_code(301);
- header("HTTP/1.1 301 Moved Permanently");
- header("Location: http://www.google.com/");
- exit;
- }
- if (preg_match("/$bot[1]/i",$hostname) && $ipaddress == $iphostname)
- /* Function which can Block unwanted Requests
- * @return boolean/array status
- */
- function requestBlocker()
- {
- /*
- Version 1.0 11 Jan 2013
- Author: Szczepan K
- http://www.szczepan.info
- me[@] szczepan [dot] info
- ###Description###
- A PHP function which can Block unwanted Requests to reduce your Website-Traffic.
- God for Spiders, Bots and annoying Clients.
- */
- $dir = 'requestBlocker/'; ## Create & set directory writeable!!!!
- $rules = array(
- #You can add multiple Rules in a array like this one here
- #Notice that large "sec definitions" (like 60*60*60) will blow up your client File
- array(
- //if >5 requests in 5 Seconds then Block client 15 Seconds
- 'requests' => 5, //5 requests
- 'sek' => 5, //5 requests in 5 Seconds
- 'blockTime' => 15 // Block client 15 Seconds
- ),
- array(
- //if >10 requests in 30 Seconds then Block client 20 Seconds
- 'requests' => 10, //10 requests
- 'sek' => 30, //10 requests in 30 Seconds
- 'blockTime' => 20 // Block client 20 Seconds
- ),
- array(
- //if >200 requests in 1 Hour then Block client 10 Minutes
- 'requests' => 200, //200 requests
- 'sek' => 60 * 60, //200 requests in 1 Hour
- 'blockTime' => 60 * 10 // Block client 10 Minutes
- )
- );
- $time = time();
- $blockIt = array();
- $user = array();
- #Set Unique Name for each Client-File
- $user[] = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'IP_unknown';
- $user[] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
- $user[] = strtolower(gethostbyaddr($user[0]));
- # Notice that i use files because bots does not accept Sessions
- $botFile = $dir . substr($user[0], 0, 8) . '_' . substr(md5(join('', $user)), 0, 5) . '.txt';
- if (file_exists($botFile)) {
- $file = file_get_contents($botFile);
- $client = unserialize($file);
- } else {
- $client = array();
- $client['time'][$time] = 0;
- }
- # Set/Unset Blocktime for blocked Clients
- if (isset($client['block'])) {
- foreach ($client['block'] as $ruleNr => $timestampPast) {
- $left = $time - $timestampPast;
- if (($left) > $rules[$ruleNr]['blockTime']) {
- unset($client['block'][$ruleNr]);
- continue;
- }
- $blockIt[] = 'Block active for Rule: ' . $ruleNr . ' - unlock in ' . ($left - $rules[$ruleNr]['blockTime']) . ' Sec.';
- }
- if (!empty($blockIt)) {
- return $blockIt;
- }
- }
- # log/count each access
- if (!isset($client['time'][$time])) {
- $client['time'][$time] = 1;
- } else {
- $client['time'][$time]++;
- }
- #check the Rules for Client
- $min = array(
- 0
- );
- foreach ($rules as $ruleNr => $v) {
- $i = 0;
- $tr = false;
- $sum[$ruleNr] = '';
- $requests = $v['requests'];
- $sek = $v['sek'];
- foreach ($client['time'] as $timestampPast => $count) {
- if (($time - $timestampPast) < $sek) {
- $sum[$ruleNr] += $count;
- if ($tr == false) {
- #register non-use Timestamps for File
- $min[] = $i;
- unset($min[0]);
- $tr = true;
- }
- }
- $i++;
- }
- if ($sum[$ruleNr] > $requests) {
- $blockIt[] = 'Limit : ' . $ruleNr . '=' . $requests . ' requests in ' . $sek . ' seconds!';
- $client['block'][$ruleNr] = $time;
- }
- }
- $min = min($min) - 1;
- #drop non-use Timestamps in File
- foreach ($client['time'] as $k => $v) {
- if (!($min <= $i)) {
- unset($client['time'][$k]);
- }
- }
- $file = file_put_contents($botFile, serialize($client));
- return $blockIt;
- }
- if ($t = requestBlocker()) {
- echo 'dont pass here!';
- print_R($t);
- } else {
- echo "go on!";
- }
- RewriteCond %{HTTP_USER_AGENT} ^GoogleBot [OR]
- RewriteCond %{HTTP_USER_AGENT} ^OtherAbusiveBot
- RewriteRule ^/$ /static_page_for_bots.html [L]
- RewriteCond %{HTTP_USER_AGENT} ^GoogleBot [OR]
- RewriteCond %{HTTP_USER_AGENT} ^OtherAbusiveBot
- RewriteRule ^rss2html.php$ /static.html [L]
- // Checks to see if this script was called by the main site pages,
- // (i.e. index.php or mobile.php) and if not, then sends to main page
- session_start();
- if (isset($_SESSION['views'])) {$_SESSION['views'] = $_SESSION['views']+ 1;} else {$_SESSION['views'] = 1;}
- if ($_SESSION['views'] > 1) {header("Location: http://website.com/index.php");}
Add Comment
Please, Sign In to add comment