Suppress those warning and errors!




Tagged Under : , , ,

Version: 11.1
Revision: 23.3 Build 6

Suppress those warning and errors!

php_logo_v2Introduction:
This problem is getting on my nerves and I don’t really like it! It normally triggers when your server is loading a page. But, to clarify this issues, the server must first send the ‘HTTP headers’, before the ‘HTML’ sections and the body tags. So, without the buffer commands, you’ll get something that looks like this: “Cannot modify header information – headers already sent by (output started at ……….)”

Example: “Warning: Cannot modify header information – headers already sent by (output started at /root/file.php:16) in /root/file.php on line 54″

This errors happens a lot on Wordpress & Drupal. But, there is a way to suppress this problem.
We just add this bit of code – straight into the top of the page!

<?php  // Enable output buffering
ob_start(); ?>

For Wordpress users, you’ll need to add this script into your ‘header.php’ file.
After that, just save your changes and the errors should be suppressed!

What is “ob_start” and what is this little function?

ob_start() is an output function that holds back any ‘output’ from the script until everything is ready to go. After that, it sends the headers and HTML.

Copyrighted By Lair360




Scrap your post revision with SQL shredder!




Tagged Under : , , , ,

Version: 15.1
Revision: 45 Build 13

Scrap your post revision with SQL shredder!

phpmyadmin_logoIntroduction:
On Halloween day, I was bored as hell! I am too old for these “Trick ‘N’ Treat” sort of things.
But, I did have a good time writing my own article and give the other children and the others candies, chocolate and sweets. So, what about my readers? Don’t worry! Here is a mini – tutorial for you to learn and enjoy.

This tutorial is about controlling your “WP – post revision” with a little help from “phpMyAdmin – Query and by editing your wp-config.php file.” However, please be careful when you’re modifying your “wp-config.php” file.

Notes: The “config” file is the hearth of your Wordpress database. So, in my own judgment, just make a backup of your “wp-config.php” file.
It’s not that hard – for crying out loud…

1.] Login to your Cpanel and navigate to your blog’s directory. After that, you’ll need to edit your ‘wp-config.php’ file and add these lines into the top of your file.

define ('WP_POST_REVISIONS', 6); //Defines a maximum of 6 different revisions per post.
define ('AUTOSAVE_INTERVAL', 3600); // Auto-saves on 1 hour interval.

2.] Save your changes and exit your ‘config’ file.

3.] In your Cpanel directory [Home], please scroll down and look for “phpMyAdmin” and select it.

4.] Wait for the control panel to load its settings and click on your “SQL” icon.

Facts: this icon is called: SQL query command. It is located on the top – left – corner, which is next to a little house icon (Home).

5.] Copy this code and paste the following code into the “SQL command” window.

DELETE FROM wp_posts WHERE post_type = "revision";

6.] Execute the script and let it erase all of your previous “post – revision”.

7.] You’re Done!

Alternative for “WP – AUTOSAVE_INTERVAL”.

- There is another way to change your “Wordpress autosave interval.”
But, you’ll need to look for this file: “wp-settings.php” and edit these parts which is shown below.

Notes: The actual lines is around 522 – 528. Just scroll down or search for the lines with this phrase: “AUTOSAVE_INTERVAL.”

/**
 * It is possible to define this in wp-config.php
 * @since 2.5.0
 */
if ( !defined( 'AUTOSAVE_INTERVAL' ) )
	define( 'AUTOSAVE_INTERVAL', 60 );

— Times —
60 sec = 1 minutes
1800 sec = 30 minutes
1980 sec = 33 minutes
3000 sec = 50 minutes
3600 sec = 60 minutes

Copyrighted By Lair360




Kiss those Spammers GoodBye!




Tagged Under : , , ,

Version: 12
Revision: 32 Build 11a

Kiss those Spammers GoodBye!


Introduction: When I was reading my favorite book, my “Compaq PDA” notified me for new readers who is / are commenting on my blog. But, what is annoying, most of these spammers are just a pain in the neck! They don’t know where to stop and they never gave other readers and myself any good comments or advice. All I’ve seen is rubbish comments that contains dangerous links and contents that are ridiculously useless!

So, from now on, if you want to be block these idiots, than look no further! Just add all of your nightmares into a text file and let the script block the numskull!
Also, if you are not a whiz in HTA script, you can use this as an alternative. No messing around with php, either!

Notes: this tutorial is only for Wordpress publisher and php user. Any other platforms that uses HTML, it will not work, unless, you made your server run like a hybrid engine.
To do this, you must consult this situation with your hosting provider.

1.] Copy this script and put it to your “header.php” file. However, it must be placed in – between your ‘header’ tags. Just choose one of these script and enjoy yourself…

Notes: the first script will “print” a notice for your Spammers.
Although, it’s a little funny when they see that.

The second script will redirect all spammers to Google!
Happy spamming…

<?php
$deny_ips = file('ip.txt',FILE_IGNORE_NEW_LINES);
$ip = isset($_SERVER['REMOTE_ADDR']) ? trim($_SERVER['REMOTE_ADDR']) : '';
if (($i = array_search($ip, $deny_ips)) !== FALSE){
print "Your IP address ('$ip') was blocked!";
exit;
}
?>
<?php
$deny_ips = file('ip.txt',FILE_IGNORE_NEW_LINES);
$ip = isset($_SERVER['REMOTE_ADDR']) ? trim($_SERVER['REMOTE_ADDR']) : '';
if (($i = array_search($ip, $deny_ips)) !== FALSE){
header("Location: http://google.com");
exit;
}
?>

2.] Save your progress and upload a text file with the correspondent IP addresses.
It must be written like this without white spaces.

321.21.1.1
23.122.12.2
91.214.45.89
77.222.131.40


Notes: you will only need to write one IP addresses – per line. Also, the file must be uploaded as: “ip.txt”. If not, just change your file-name from the php script and make it synchronize!

3.] Next, you will need to block hackers and spammers from looking at your text file.
All you need to do is add this script – straight into your HTA file. After that, just save it and upload it to your server.

Notes: you must delete your old “htaccess” file, just before uploading your new version.

<Files ip.txt>
  order allow,deny
  deny from all
</Files>

4.] Done!

When you have a new spammer / hacker, you can add your offender into a text file.
Easy as a cow, flying over a fence!

Copyrighted By Lair360




PHP Script – IP Banned




Tagged Under : , , , ,

Version: 13.2
Revision: 39 Build 16

PHP Script – IP Banned

Introduction:
last night, I was repairing my “HTA” files, it was a little messed up, so I have to re-write parts of the codes and scribble it down into smaller bits. However, it was boring as hell!

Here is my little “IP-Ban.php” script. I designed this script from scratch. But, I don’t know if I want to use it.
Don’t get me wrong…I did test the script, It works…

1.] Download notepad++ from the original author or from a mirror and install the software.
——————————-

http://sourceforge.net/projects/notepad-plus/

http://filehippo.com/download_notepad/

——————————-

2.] Copy this “PHP Script” and save it as a “ban-ip.php” extension.

3.] Select one of these “IP script” and replace the default IP address with your own address.
After that, just add this “include” string, straight into your wordpress files.

—Copy Source Code—

<?php
include("ip-ban.php");
?>

—End Source Code—

Special Notice: by following the rules and regulations, these scripts was created / written by me from scratch. They are also revised for stability and bugs free. However, please use these script at your own risk!

Method One – Blacklist Host Style
—Copy Source Code—

<?php
$blackList = array();
$blackList[] = "192.168.1.1";
$blackList[] = "192.168.2.*";

if(in_array($_SERVER['REMOTE_ADDR'], $blackList))  {
	die("You have been banned!");
}  else  {
	foreach($blackList as $blackIP) {
		if(eregi($blackIP,$_SERVER['REMOTE_ADDR']))  {
			die("You have been banned!"); 	}
	}
} ?>

—End Source Code—

Method Two – Blacklist Simplified Style
—Copy Source Code—

<?php $banned = array (
//Add your own IP address under this line
'122.2.13.1',
'144.2.76.6',
'166.2.76.6',
// IP Address Ends Here
);
$ip = GetHostByName($REMOTE_ADDR);
if (in_array($ip,$banned)
{
echo 'You are banned from this site!';
exit();
} ?>

—End Source Code—

Method Three – Blacklist Intermediate Style
—Copy Source Code—

<?php
// IP in the form of "127.0.0.1" in a host form
$banned[0]="xxx.xxx.xxx.xxx";
$banned[1]="xxx.xxx.xxx.xxx";
$banned[2]="xxx.xxx.xxx.xxx";
// Ban IPs Ends

if (in_array($_SERVER['REMOTE_ADDR'],$banned))
{
header("location: http://www.google.com/");
exit();
} ?>

—End Source Code—

Method Four – Blacklist Text File

Notes: make a text file in the same folder, and give it permmission: 755.
—Copy Source Code—

<?php
error_reporting(0);
// Look for the "ip-ban.txt" and replace it with your file.
// The files contains IP addresses.
if ($handle = fopen("ip-ban.txt", "r+")) {
    $ip = explode("
", fread($handle, filesize("ip-ban.txt")));
    for ($i = 0; $i < count($ip); $i++) {
        $ip[$i] = str_replace("*", "(.*)", $ip[$i]);
// Change the link here. But, don't remove "Location" from the header!
        if (ereg($ip[$i], $_SERVER['REMOTE_ADDR'])) {
            header("Location: http://google.com/");
        }
    } fclose($handle);
} ?>

—End Source Code—

Method Five – Blacklist & Redirection
—Copy Source Code—

<?php
$block_ips = array("000.000.000.000", "000.000.000.000");
$ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
foreach ($block_ips as $block_ip) {
if ($ip == $block_ip) {
die(header("Location: anypage.php"));
	}
} ?>

—End Source Code—

Method Six – Blacklist portable v3
—Copy Source Code—

<?php
$deny = array(
// Add your offending IP adress here
"111.111.111",
"222.222.222",
"333.333.333"
);
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
   header("location: http://www.google.com/");
   exit();
} ?>

—End Source Code—

Method Seven – Blacklist Multifunctional
—Copy Source Code—

<?php
// Denied IP's.
//Comment these lines if you're using "$deny_ips = file".
$deny_ips = array(
        '209.240.206.199',
        '209.240.206.200',
        '209.240.206.201',
        '209.240.206.202',
    );

// Create a txt file and use instead.
//Remove the comments bellow this line.
// $deny_ips = file('blocked_ips.txt');

// read user ip address:
$ip = isset($_SERVER['REMOTE_ADDR']) ? trim($_SERVER['REMOTE_ADDR']) : '';

// search current IP in $deny_ips array
if (($i = array_search($ip, $deny_ips)) !== FALSE){

// user is blocked:
echo "Your IP address ('$ip') was blocked!";
exit;
}

// End of Blocking

?>

—End Source Code—

Method Eight – Blacklist Multifunctional v2
—Copy Source Code—

<?php
$ip = $_SERVER['REMOTE_ADDR'];
$ipArray = preg_replace("#\r\n?|\n#","",file('IP-Ban.txt'));  // read the file into an array
foreach ($ipArray as $ipTest) {
  if (substr_count($ip, $ipTest) != "0") {
    die(header("Location: anypage.php"));
  }
} ?>

—End Source Code—

4.] Finally, you’ll need to upload one of these files and use the codes to import this script.

5.] Done!

Copyrighted By Lair360




Wordpress – increase memory and performance




Tagged Under : , , , ,

Version: 32.1
Revision: 23 Build 11

Wordpress – increase memory and performance

Introduction:
when I was reading “Wordpress for Dummies”, I coudn’t believe the titles! It’s utlerly crazy and diabolical. But, on the other hands, I don’t really care…

Anyway, just unfasten your seat-belt and take a look at this article: how to fix the dreaded “white screen of death” syndrome.

This tutorial involves: ‘increasing’ the amount of PHP memory available to WordPress. However, on some server, you might want to consult this with your host – provider, concerning current available memory and overall compatibility. After that, just follow the instruction!

1.] Check your hosting provider and your Wordpress website for PHP-related and/or PHP memory issues associated with any of the followings…

Inability to open various WP Admin screens (e.g., Themes, Plugins)
Inability to leave comments or no returned page upon leaving a comment
Inability to search or send feedback via various comment forms
Broken plugins (e.g., XML Sitemap Generator, DD Sitemap Generator)
Experiencing various timeouts (e.g. file uploads, page loads)
Unexpected downloading of PHP files via Firefox
Explicit PHP memory errors


Notes: If you are experiencing any one (or more) of these issues, increasing your blog’s PHP memory – limit may be the solution. However, you must consult this with for hosting provider, first!

2.] First, you must backup your “wp-config.php” file, which is located in the “WordPress” root directory or the root – sub directory.

Notes: the “wp-config.php” file is located in these default directory.

Single directory: /public_html/*
Sub directory: /public_html/blog/*

3.] Open your “wp-config.php” file and place the following code directly after the opening PHP element as follows. This source code can be place / alter inside your ‘configuration’ file, with Cpanel or by editing outside the server (downloading and uploading through FTP programs)

—Copy Source Code—

ini_set("memory_limit","64M");

—End Source Code—

4.] Finally, just save your “wp-config.php” file, logout of your Cpanel / FTP software and clear your system cache. However, if things are still acting sluggish, you may try ‘incrementally’ increasing the amount of available PHP memory. Depending on your current settings…

—Copy Source Code—

ini_set("memory_limit","12M");
ini_set("memory_limit","16M");
ini_set("memory_limit","32M");
ini_set("memory_limit","64M");

—End Source Code—

FAQ – To check your available PHP memory, just upload a “phpinfo.php” file containing…

—Copy Source Code—

<?php phpinfo(); ?>

—End Source Code—

After that, you’ll need to call it in a browser. Scroll down about one screen and locate the line that says, “memory_limit” — the value given represents your server’s current PHP memory limit.

Copyrighted By Lair360