|
Source Code for Link Exchange
All the below files must be saved in the same folder. Then a link
needs to be placed on one or more of your site pages to the below
index.php file. That's it.
Make sure you copy all the code for each file and paste it into a
file with the same name I've provided.
This is the source of: config.php
This is the only file you'll need to edit to make your page unique.
<?php
//Used for META TAG AUTHOR
$authorName = "Leif Gregory";
//Used for the beginning of the TITLE TAG with the following text:
//"TB Member Directory"
$siteName = "DevTek Link Exchange";
?>
This is the source of: site.css
You don't need to edit this page, but if you'd like to change the colors
and such, you're more than welcome.
body {
background: #FFFFFF;
color: Black;
font-family: Tahoma, Arial, sans-serif;
font-size: 12px;
}
h2 { border-bottom: 3px solid red; }
table { border: 3px outset #ffcc00; }
p.pagetitle {
color: #483D8B;
font-size: xx-large;
background: #ffcc00;
font-weight: bold;
}
p.pagetitle2 {
color: #FFFFFF;
font-size: xx-large;
background: slategray;
font-weight: bold;
}
p.pagesubtitle {
color: #7B68EE;
font-size: x-large;
}
td.main {
border: 3px green;
font-size: small;
background-color: #7B68EE;
}
p.nav {
font-size: small;
background-color: #FFFFFF;
border: 2px Black;
}
td.nav {
font-size: small;
background-color: #FFFFFF;
border: 5px Green;
}
p.inset {
border-style: inset;
padding: 10px;
}
This is the source of: link_exchange.php
You shouldn't have to change this at all.
<?php
/*
Title: DevTek Link Exchange v0.10
Filename: index.php
Function: Fully randomized and centralized link exchange system
Date last modified: 29 Dec 04
Coder: Leif Gregory
Website: http://www.devtek.org/link_exchange
E-mail: leif@devtek.org
Copyright (C) 2004 Leif Gregory
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//Sanitize the string to get rid of common words (the, and, is etc.) and
//punctuation and special characters
function sanitize($str)
{
$str = strtolower($str);
$notallowed = array(" some "," all "," homepage "," website "," of "," in "," is "," it's "," it "," my "," she "," he ","the "," the "," or "," and ","\"", "\'", ".", "`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "+", "=", "{", "}", "[", "]", "|", "\\", ";", "<", ">", ",", "?", "/");
$sanitized = str_replace($notallowed, " ", "$str");
return $sanitized;
}
//Define variables for the database and connect to the database
$dbserver="DBSERVER1"; # Primary DB Server
$dbserver2="DBSERVER2"; # Secondary DB Server
$dbserver3="DBSERVER3"; # Tertiary DB Server
$dbuser="DBUSER";
$dbpassword="PASSWORD";
$dbname="DBNAME";
$tblname="TABLENAME";
//Setting up the DB connection (fallthrough to redundant servers)
if (@$conn=mysql_connect($dbserver1,$dbuser,$dbpassword))
$select=mysql_select_db($dbname, $conn) or die(mysql_error());
elseif (@$conn=mysql_connect($dbserver2,$dbuser,$dbpassword))
$select=mysql_select_db($dbname, $conn) or die(mysql_error());
elseif (@$conn=mysql_connect($dbserver3,$dbuser,$dbpassword))
$select=mysql_select_db($dbname, $conn) or die(mysql_error());
else
{
echo "Unable to connect to a DB server at this time. Try again later.";
exit;
}
//Grabbing all the DB reccords for each link site
$sqlview="SELECT * FROM " . $tblname;
$result=mysql_query($sqlview);
//Including the file to make your site unique
include('config.php');
//Counter for the array of website links
$i = 0;
//Building page data
while ($r=mysql_fetch_assoc($result))
{
$metaKeyword .= $r['siteTitle'] . " ";
$metaDescription .= $r['siteDescription'] . " ";
$allRecords[$i] .= '<TABLE width="100%" cellpadding="0" cellspacing="0">' . "\r\n";
$allRecords[$i] .= '<TR><TD align="center"><p class="pagetitle">' . $r['siteTitle'] . '</p></TD></TR>' . "\r\n";
$allRecords[$i] .= '<TR><TD> URL: <a href="' . $r['siteUrl'] . '">' . $r['siteUrl'] . '</a></TD></TR>' . "\r\n";
$allRecords[$i] .= '<TR><TD> Owned By: ' . $r['owner'] . '</TD></TR>' . "\r\n";
$allRecords[$i] .= '<TR><TD> Description: ' . $r['siteDescription'] . '</TD></TR>' . "\r\n";
$allRecords[$i] .= '</TABLE>' . "\r\n";
$i++;
}
//Cleaning up and randomizing META DESCRIPTIONS
$metaDescription = sanitize($metaDescription);
$metaDescriptionExploded = explode(" ", $metaDescription);
shuffle($metaDescriptionExploded);
foreach($metaDescriptionExploded as $metaDescription)
{
$temp = trim($metaDescription);
if (strlen($metaDescription) > 2)
$metaDescriptions .= $temp . " ";
}
//Cleaning up and randomizing META KEYWORDS
$metaKeyword = sanitize($metaKeyword);
$metaKeywordExploded = explode(" ", $metaKeyword);
shuffle($metaKeywordExploded);
foreach($metaKeywordExploded as $metaKeyword)
{
$temp = trim($metaKeyword);
if (strlen($metaKeyword) > 2)
$metaKeywords .= $temp . " ";
}
//Randomizing the displayed website links
shuffle($allRecords);
?>
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="site.css"/>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<meta name="Author" content="<?php echo $authorName; ?>">
<meta name="Keywords" content="<?php echo trim($metaKeywords); ?>">
<meta name="Description" content="<?php echo trim($metaDescriptions); ?>">
<meta name="ROBOTS" content="INDEX,FOLLOW">
<title><?php echo $siteName ?> Member Directory</title>
</HEAD>
<BODY>
<TABLE align="center" width="600" cellpadding="0" cellspacing="0">
<TR>
<TD>
<?php
//Displaying the actual page content of the sites
for($j=0; $j <= $i; $j++)
{
echo $allRecords[$j];
}
?>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
|