All pastes #457199 Raw Edit

Stuff

public text v1 · immutable
#457199 ·published 2007-04-25 08:01 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'])){

	   // --- Start Checking to see if a cookie is present
       
	   if(!isset($_COOKIE['id'])){

		   echo '<p class="notice">' . 'You have a tag link! Click a tag to vote' . '</p>';

	   }

	   if(isset($_COOKIE['id'])){

		   echo '<p class="notice">' . 'You have used up your tag vote, please come back tomorrow' . '</p>';

	   }

	   // --- End

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

         echo '<li>' . '<a href="?link=' . $row['id'] . '">' . $row['link'] . '(' . $row['clicks'] . ')' . '</a>' . '</li>';
		
		 
		 } // Close While Loop

    } // Close !isset

   if(isset($_GET['link'])){
   
      $link = mysql_escape_string($_GET['link']);

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

	  if($row = mysql_fetch_array($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);

			   $plus = $row['clicks']+1;

			   $sql = "UPDATE `tagcloud` SET `clicks` = $plus WHERE `id` = $link";
			   mysql_query($sql);

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

			}

		 // End

		   if(isset($_COOKIE['id'])){
               
              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';

}

?>