Ajax software
Free javascripts
↑
Main Page
else
{
return preg_replace(‘#<a#i’, ‘<a rel=”nofollow”‘, $input);
}
}
?>
2.
Edit your existing
include/config.inc.php
file by adding the whitelist definition, as high-
lighted in the following code snippet. If you don’t have this file from previous exercises, create
it and write the necessary code. (Only the definition for
$GLOBALS[‘whitelist’]
is required
for this exercise.)
<?php
// site domain; no trailing ‘/‘ !
define(‘SITE_DOMAIN’, ‘http://seophp.example.com’);
// create a fictional database with products and categories
$GLOBALS[‘products’] = array
(“45” => “Belt Sander”,
“31” => “Link Juice”,
“42” => “AJAX PHP Book”);
$GLOBALS[‘categories’] = array
(“12” => “Carpenter’s Tools”,
“6” => “SEO Toolbox”,
“2” => “Friend’s Shed”);
// define array of accepted links
$GLOBALS[‘whitelist’] = array(‘seophp.example.com’, ‘www.seoegghead.com’);
?>
3.
Create a file named
comments.php
in the
seophp
folder, with this code:
<?php
// load the nofollow library
require_once ‘include/nofollow.inc.php’;
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
<html>
<head>
<title>: Comments</title>
</head>
<body>
<h1>Old comments:</h1>
<?php
// display first comment
echo noFollowLinks(‘<p>Hello! Take a look at <a
href=”http://too.much.spam”>cool@@ta
182
Chapter 8: Black Hat SEO
c08.qxd:c08 10:59 182
Ajax software
Free javascripts
→