Welcome! Log In Create A New Profile

Advanced

[ Mod ] ... Add-On: Last 10 added websites

Posted by PiOnEeRReSeArCH 
[ Mod ] ... Add-On: Last 10 added websites
May 26, 2010 05:14PM
Hello,

this Mod/Add-on is based on the "Search Clod", posted here a long time ago. It shows you the last
10 added websites and you can click on it, to open it in a new window/tab.

Put this code into sites.php :

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Sites</title>
<style>
#tags {
float: none;
width: 220px;
margin: 10px 0px;
padding: 10px;
background:#ececec;
color:#333;
border: 1px dashed #cccccc;
text-align: justify;
}
#tags .title {
font-family:arial;
font-size:16px;
font-weight:bold;
background-color: transparent;
padding: 4px 4px;
color:#808080;
}
#tags a {
color:#39c;
background-color: transparent;
padding: 2px 4px;
white-space: nowrap;
text-decoration: none;
font-family:arial;
}
#tags a:hover {
color:#39c;
background: silver;
text-decoration: none;
}
</style>

</head>

<body>
<div id="tags">
<div class="title">New Sites</div>
<?php
$include_dir = "./include";
$template_dir = "./templates";
$settings_dir = "./settings";
$language_dir = "./languages";

require_once("$settings_dir/database.php" ) ;
require_once("$language_dir/en-language.php" ) ;
require_once("$include_dir/searchfuncs.php" ) ;
require_once("$include_dir/categoryfuncs.php" ) ;

include "$settings_dir/conf.php";

// Snippet taken from [prism-perfect.net]

// include "/path/to/public_html/search/settings/database.php";
// include "/path/to/public_html/search/settings/conf.php";

// In the SQL below, change these three things:
// thing is the column name that you are making a tag cloud for
// id is the primary key
// my_table is the name of the database table

// added by essexboyracer:
// dont return zero result words and limit the cloud to 10 phrases

$query = "SELECT url AS tag, COUNT(*) AS quantity
FROM ".$mysql_table_prefix."sites
WHERE site_id > 0
GROUP BY url
ORDER BY indexdate ASC
LIMIT 10";

$result = mysql_query($query) or die(mysql_error());

// here we loop through the results and put them into a simple array:
// $tag['thing1'] = 12;
// $tag['thing2'] = 25;
// etc. so we can use all the nifty array functions
// to calculate the font-size of each tag
while ($row = mysql_fetch_array($result)) {

$tags[$row['tag']] = $row['quantity'];
}

// change these font sizes if you will
$max_size = 30; // max font size in %
$min_size = 11; // min font size in %

// get the largest and smallest array values
$max_qty = max(array_values($tags));
$min_qty = min(array_values($tags));

// find the range of values
$spread = $max_qty - $min_qty;
if (0 == $spread) { // we don't want to divide by zero
$spread = 1;
}

// determine the font-size increment
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);

// loop through our tag array
foreach ($tags as $key => $value) {

// calculate CSS font-size
// find the $value in excess of $min_qty
// multiply by the font-size increment ($size)
// and add the $min_size set above
$size = $min_size + (($value - $min_qty) * $step);
// uncomment if you want sizes in whole %:
// $size = ceil($size);

// you'll need to put the link destination in place of the #
// (assuming your tag links to some sort of details page)
echo '<a href="'.$key.'"target="_blank" style="font-size: '.$size.'px"';
// perhaps adjust this title attribute for the things that are tagged
echo ' title="'.$value.' things tagged with '.$key.'"';
echo '>'.$key.'</a> ';
// notice the space at the end of the link
}

?>
</div>
</body>
</html>
Sorry, only registered users may post in this forum.

Click here to login