Get support from Xavier Media
It is currently Sun Dec 08, 2013 6:52 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Changing Style Sheets
PostPosted: Sun Nov 19, 2006 12:00 am 

Points:
Ok, so not everyone has the same monitor and not everyone has 20-20 vision. So, since the "Ctrl++" trick is not well known you have to make a font size chooser for your site. So here is what I have done:


[php]<?php

if ((isset($_GET['stylesheet'])) && (strlen($_GET['stylesheet']) <= 25)) {
$stylesheet = mysql_real_escape_string(strip_tags($_GET['stylesheet']));
setcookie("stylesheet", $stylesheet, time()+31536000);
header("Location: http://" . $_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF'])
. "/");
}

if (!isset($_COOKIE["stylesheet"])) {
$stylesheet = 'white';
} else if ((isset($_COOKIE["stylesheet"])) && (strlen($_COOKIE["stylesheet"]) <= 25)) {
$stylesheet = mysql_real_escape_string(strip_tags($_COOKIE["stylesheet"]));
}

$form = ' <a href="?stylesheet=white">White</a> - <a href="?stylesheet=blue">Blue</a> ';

?>[/php]

then echo the $form variable and this below:

[php]<link rel="stylesheet" type="text/css" href="/themes/code2design/<?php echo $stylesheet; ?>.css" media="screen,projection" />[/php]

The only problem is that for some reason TWO cookies called "stylesheet" are made.

So then I looked into a JavaScript method:
http://www.alistapart.com/articles/relafont/

So has anyone else done this yet? I think that if I can just figure out how to make the first code only make one cookie it would be better. So any thoughts?


Report this post
Top
  
Reply with quote  
 Post subject: Fixed
PostPosted: Tue Nov 21, 2006 6:59 pm 

Points:
Ok this works:


Top of each page:

[php]<?php

if ((isset($_COOKIE["stylesheet"])) && ((strlen($_COOKIE["stylesheet"]) < 20)) ) {
$stylesheet = strip_tags($_COOKIE["stylesheet"]);
} else {
$stylesheet = 'white';
}

if ((isset($_COOKIE["fontsize"])) && ((strlen($_COOKIE["fontsize"]) < 20)) ) {
$fontsize = strip_tags($_COOKIE["fontsize"]);
} else {
$fontsize = 'normal';
}


$form = ' <a href="/stylesheets.php?stylesheet=white">White</a> - '
.'<a href="/stylesheets.php?stylesheet=blue">Blue</a> - '
.'<a href="/stylesheets.php?stylesheet=green">Green</a> || '
.'<a href="/stylesheets.php?fontsize=big" title="Increase Font Size">A+</a> &nbsp;&nbsp;'
.'<a href="/stylesheets.php?fontsize=normal" title="Normal Font Size">A</a> &nbsp;&nbsp;'
.'<a href="/stylesheets.php?fontsize=small" title="Decrease Font Size">A-</a>';

?>

...
....

...


<link rel="stylesheet" type="text/css" href="/themes/code2design/<?php echo $stylesheet; ?>.css" media="screen,projection" />
<link rel="stylesheet" type="text/css" href="/themes/code2design/<?php echo $fontsize; ?>.css" media="screen, print, projection" />



[/php]

Then the stylesheets.php:


[php]<?php
$ref = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : "http://{$_SERVER['SERVER_NAME']}/";

if ( (isset($_GET['stylesheet'])) || (isset($_GET['fontsize'])) ) {

if ((isset($_GET['stylesheet'])) && (strlen($_GET['stylesheet']) < 20)) {
$stylesheet = $_GET['stylesheet'];
$stylesheet = strip_tags($stylesheet);
if (!setcookie("stylesheet", $stylesheet, time()+(7 * 24 * 60 * 60), '/', ".code2design.com", '0') ) die ("could not set style cookie!");
}

if ((isset($_GET['fontsize'])) && (strlen($_GET['fontsize']) < 20)) {
$fontsize = $_GET['fontsize'];
$fontsize = strip_tags($fontsize);
if (!setcookie("fontsize", $fontsize, time()+(7 * 24 * 60 * 60), '/', ".code2design.com", '0') ) die ("could not set font cookie!");
}

header("Location: $ref");


} else {
header("Location: $ref");
}

?>[/php]


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Registered users: AGolditaut


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Portal » Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[
SEO MOD © 2007 StarTrekGuide ]