Google Answers Logo
View Question
 
Q: Need a cookie script that supports non-standardized file names ( No Answer,   0 Comments )
Question  
Subject: Need a cookie script that supports non-standardized file names
Category: Computers > Internet
Asked by: trimidium-ga
List Price: $5.00
Posted: 22 Oct 2004 08:52 PDT
Expires: 21 Nov 2004 07:52 PST
Question ID: 418546
I currently have a cookie script that allowes me to set a background
on my website, assuming that all my file names look like this:
image1.jpg image2.jpg etc..  and you load them by going
index.php?setArt=1 . However I want to have different file names like
Hi-thisis_fun.gif HoWare-you-bob.jpg, etc... I basically just need a
setcookie script that lets me say setArt=iambob.jpg (i would actually
prefer that the .jpg part was not on the line but if that is what is
needed to allow different file extensions I understand.

I am currently using this script twice on my website to set different
images, I would like to use it another time to set css files, but I
would actually prefer to have 1 script that let me set 4 or 5
different things, so setArt, setCss, setBG, setColor, setOther....
This is not a requirement, but if you can do that to the script AND
get it to let me use any file names on the set line, I will give a
bonus on the answer.

I will include my current script, but feel free to paste your own if
you have one that works better as I am in no way attached to the
script, so long as I have a way to define the path to each variable in
the script, it will do the trick.

<?php 
 
if (!empty($setart)) { 
 $art = $setart; 
 setArt(); 
} elseif (!empty($_COOKIE['art'])) { 
 $art = $_COOKIE['art']; 
} elseif (!empty($diecookie)) { 
 dieCookie(); 
} 
 
 
function setArt() { 
 global $art; 
 setcookie('art',$art,time()+2678500,'/','thesmartass.info'); 
} 
 
function getArt() { 
 global $art; 
  
 $default_art = "random.php?pic=random1"; 
 
 $image_dir = "./images/artwork/"; // trailing slash is important. 
 $image_path = "images/artwork/"; // here too. 
 $image_prefix = "image"; 
 $image_suffix = ".jpg";
  
 if (!empty($art)) { 
  $imagefile = $image_prefix.$art.$image_suffix; 
  if (!file_exists($image_dir.$imagefile)) { 
   $imagefile = $default_art; 
  } 
 } else { 
  $imagefile = $default_art; 
 } 
  
 return $image_path.$imagefile; 
} 
 
function dieCookie() { 
 setcookie('art','',time()-2678500); 
} 

?>
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy