Nicholas Cheek

LITTLE ROCK WEB DEVELOPER

I used a cookie to generate and store a random hash on the visitors computer, then used that hash to query the database.  When the visitor clicked a button in the sidebar, the page url was stored in the database with the cookie hash as the id. The link was then called in to a dropdown menu, creating a "favorites" link menu. *note - this was an expression engine site so you may see some ee code.

<?php
			function redirectAdd($url) {
				if(!headers_sent()) {
				    //If headers not sent yet... then do php redirect
				    header('Location: '.$url);
				    exit;
				} else {
				    //If headers are sent... do javascript redirect... if javascript disabled, do html redirect.
				    echo '<script type="text/javascript">';
				    echo 'window.location.href="'.$url.'";';
				    echo '</script>';
				    echo '<noscript>';
				    echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
				    echo '</noscript>';
				    exit;
				}
			    }	
		 function addPage() {
					  $EE =& get_instance();  
					$userid = $_COOKIE["asubeebe-test"];
					$string = $_SERVER['REQUEST_URI'];
					$plorp = substr(strrchr($string,'?'), 0);
					$string = substr($string, 0, - strlen($plorp));
					$data = array('id' => $userid, 'link' => $string, 'pagetitle' => "{title}");
					$sql = $EE->db->insert_string('exp_cookie_links', $data);
					$rowcheck = $EE->db->query("SELECT * FROM exp_cookie_links WHERE id='{$userid}' AND link='$string'");
					 if ($rowcheck->num_rows == 0){
					$EE->db->query($sql);
					 }
					 
		
					 }
					 
					if(isset($_GET['action']))
					{
					  switch($_GET['action'])
					{
					  case 'addPage': 
					    addPage();
					     $EE =& get_instance();
					     $this->EE->session->set_flashdata('message', 'This page has been added to your Quicklinks!');
					     $string = $_SERVER['REQUEST_URI'];
					$plorp = substr(strrchr($string,'?'), 0);
					$string = substr($string, 0, - strlen($plorp));
					redirectAdd('http://www.mysite.com'.$string);
					//header('location:http://mysite.com'.$string);
					exit;
					    break;
				         
					}
					}
					
					
					?>

LITTLE ROCK WEB DEVELOPER

Living the dream.

nick@nicholascheek.com