All pastes #457562 Raw Edit

Someone

public text v1 · immutable
#457562 ·published 2007-04-25 13:49 UTC
rendered paste body
<?php

#####################################################################
# PHPTagCloud Script was created by ClearVue Media, Birmingham (UK) #
#                                                                   #
# Contact: cascadingstylez@googlemail.com                           #
#                                                                   #
#####################################################################

include 'inc/dbc.php'; // Make a DB Connection

if($dbc){ // DB Connection Worked

   if(!isset($_GET['link']) OR intval($_GET['link'] < 1)){

	   // --- Start Checking to see if a cookie is present and display results
       
		   echo '<p class="notice">' . (!isset($_COOKIE['id']) ? 'You have a tag link! Click a tag to vote' : 'You have used up your tag vote, please come back tomorrow') . '</p>';

      // --- End

	   $result = mysql_query("SELECT * FROM `tagcloud`");
	   
	     while($row = mysql_fetch_assoc($result)){

         $fontsize = array(11, 15, 20, 30, 50);
        
		 switch ($fontsize){
			 case ($row['clicks'] >= 1 AND $row['clicks'] <= 20):
             echo "<li><a style=\"font-size: $fontsize[1]px;\" href=\"?link=$row[id]\">$row[link]($row[clicks])</a></li>\n";
             break;
			 case ($row['clicks'] >= 21 AND $row['clicks'] <= 35):
             echo "<li><a style=\"font-size: $fontsize[2]px;\" href=\"?link=$row[id]\">$row[link]($row[clicks])</a></li>\n";
             break;
			 case ($row['clicks'] >= 36 AND $row['clicks'] <= 50):
             echo "<li><a style=\"font-size: $fontsize[3]px;\" href=\"?link=$row[id]\">$row[link]($row[clicks])</a></li>\n";
             break;
			 }

        
		 } // Close While Loop

    } // Close !isset

   else{
   
      $link = intval($_GET['link']);

	  $result = mysql_query("SELECT * FROM `tagcloud` WHERE id=$link");

	  if($row = mysql_fetch_assoc($result)){

         // Check for cookie, if non present create one
		 // otherwise leave as standard but dont update the database.

            if(!isset($_COOKIE['id'])){
               
			   setcookie('id','voter',time()+25,'/','',0);

			   mysql_query("UPDATE `tagcloud` SET `clicks` = `clicks` + 1 WHERE `id` = $link");

			   echo '<p>' . 'Your tag has been logged!' . '</p>';

			}

		 // End

		   else{
               
              echo '<p>' . 'You can view the site but your tag has not been logged' . '</p>';

			}
	  
	     echo $row['link'];
		 echo "<p><a href=\"index.php\">Go Back</a>";
	  
	  }

	  else {
	  
	     echo 'Nothing was found, please press back on your browser!';

	  }

   }

} // Close if($dbc)

else { // DB Connection Failed
	
	echo 'Ooops Theres A Problem. Please contact the' . ' ' . "<a href='mailto:$admin'>" . 'admin';

}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>PHPTagCloud</title>
<link href="style.css" rel="stylesheet" type="text/css">
</script>
<style type="text/css">

* {margin: 0; padding: 0;}

ul {list-style: none; margin: 0 auto;}
li {display:inline; padding: 0 5px;}

a {text-decoration: none;}

</style>
</head>
<body>

</body>
</html>