<?

  
#  
  #  Copyright (C) 2006 Borgar Žorsteinsson <borgar@undraland.com>.
  #  All rights reserved.
  #  
  #  This program is free software; you can redistribute it and/or modify it 
  #  under the terms of the GNU General Public License as published by the 
  #  Free Software Foundation; either version 2 of the License, or (at your 
  #  option) any later version.
  #  
  #  This program is distributed in the hope that it will be useful, but 
  #  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  #  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
  #  for more details.
  #  
  #  http://www.gnu.org/licenses/gpl.html
  #

  
header('Content-type: text/css');

?>
/*

  This is a dynamic CSS file generated by a Wordpress plugin.

*/
  
html, body {
  height : 100%;
}
<?php

  $darks 
= array(
    
'bw'     => '#000000',
    
'grey'   => '#5b5b5b'
    
'blue'   => '#223388',
    
'cyan'   => '#007080',
    
'green'  => '#007000',
    
'yellow' => '#777700',
    
'orange' => '#995500',
    
'red'    => '#88000b',
    
'purple' => '#660077');
    
  
$lights = array(
    
'bw'     => '#ffffff',
    
'grey'   => '#cccccc'
    
'blue'   => '#aabbff',
    
'cyan'   => '#8fe9ee',
    
'green'  => '#88ff88',
    
'yellow' => '#eeee66',
    
'orange' => '#ffbb66',
    
'red'    => '#ff8890',
    
'purple' => '#ee99ff');

  
$font_family = array(
    
'arial'      => 'Helvetica, Arial, sans-serif',
    
'verdana'    => 'Verdana, sans-serif',
    
'trebuchet'  => '"Trebuchet MS", sans-serif',
    
'courier'    => '"Courier New", "Courier", monospace',
    
'comicsans'  => '"Comic Sans MS", sans-serif',
    
'georgia'    => '"Georgia", serif',
    
'times'      => '"Times New Roman", "Times Roman", Times, serif');


  function 
getColor($colorName$inverted false) {
    global 
$darks$lights;
    
$colorName strtolower($colorName);
    if (
$inverted) {
      return (isset(
$darks[$colorName])) ? $darks[$colorName] : false;
    } else {
      return (isset(
$lights[$colorName])) ? $lights[$colorName] : false;
    }
  }
  

  function 
makeCssRule($selector$arr) {
    foreach (
$arr as $key => $val) {
      
$prop[] = "  {$key} : {$val} !important;";
    }
    if (
$prop) {
      return 
"{$selector} {\n" 
              
implode("\n"$prop) .
              
"\n}\n\n";
    } else {
      return 
"{$selector} {\n}\n\n";
    }
  }
  
  
// Font size 
  
if (isset($_REQUEST['font-size'])) {
    
$body['font-size'] = $_REQUEST['font-size'];
  }

  
// Font family 
  
if (isset($_REQUEST['font-family'])) {
    
$font strtolower($_REQUEST['font-family']);
    if (isset(
$font_family[$font])) {
      
$body['font-family'] = $font_family[$font];
    } 
  }

  
// Leading 
  
if (isset($_REQUEST['line-height'])) {
    
$body['line-height'] = ($_REQUEST['line-height'] / 100);
  }

  
// Letter spacing 
  
if (isset($_REQUEST['letter-spacing'])) {
    
$body['letter-spacing'] = $_REQUEST['letter-spacing'] / 100 'em';
  }

  
// Word spacing 
  
if (isset($_REQUEST['word-spacing'])) {
    
$body['word-spacing'] = $_REQUEST['word-spacing'] / 100 'em';
  }

  
// Capitalization 
  
if (isset($_REQUEST['text-transform'])) {
    
$body['text-transform'] = $_REQUEST['text-transform'];
  }

  
// Italics
  
if (isset($_REQUEST['font-style'])) {
    
$all['font-style'] = $_REQUEST['font-style'];
  }

  
// Invert colors
  
$invert = (isset($_REQUEST['invert']) && $_REQUEST['invert'] == 'on');

  
// Background color
  
if (isset($_REQUEST['background'])) { 
    
$bg getColor($_REQUEST['background'], $invert);
    
$tc getColor($_REQUEST['background'], !$invert);
    if (
$bg) {
      
$body['background'] = $bg;
      
$body['color'] = $tc;         // try to prevent prevent color lock-in
    
}
    if (
$tc) { // unused -- colors tables
      
$table['border'] = "2px solid {$tc}";
    }
  }

  
/* --- Text color --- */
  
if (isset($_REQUEST['color'])) {
    
$bg getColor($_REQUEST['color'], !$invert);
    if (
$bg) {
      
$body['color'] = $bg;
    }
  }

  
/* --- Linkalitur --- */
  
if (isset($_REQUEST['linkcolor'])) {
    
$bg getColor($_REQUEST['linkcolor'], !$invert);
    if (
$bg) {
      
$a['color'] = $bg;
    }
  }

  
/* --- Vowel color --- */
  
if (isset($_REQUEST['vowelcolor'])) {
    
$bg getColor($_REQUEST['vowelcolor'], !$invert);
    if (
$bg) {
      
$vowel['color'] = $bg;
    }    
  }

  
/* --- Print main rules  --- */
  
echo isset($body) ? makeCssRule('body'$body)  : '';
  echo isset(
$all)  ? makeCssRule('body *'$all) : '';
  if (isset(
$a)) {
    echo 
makeCssRule('a, a:hover, a:focus'$a);
    echo 
makeCssRule('a img, a:hover img, a:focus img'$a);
  }
  echo isset(
$vowel) ? makeCssRule('span.vowel'$vowel) : '';

// unused -- colors tables
//  echo isset($table) ? makeCssRule('table td', $table) : '';  

?>


/* some more basic things */

textarea { width : 99% }

table,
table td { 
  border : 1px solid;
}
table th,
table td {
  padding : .2em;
  vertical-align : top;
}

body,
body * {
  background-image : none !important;
}

/* things that you probably weren't meant to see */

.print { display : none; }
.stream, .hide, .hidden, .spacer {
  position : absolute;
  right : 9999px;
}

/* rules that add basic layout to common themes */

#pagehead,
#pageheader,
#header {
  padding : 0 1%;
  border-bottom : 2px solid;
}
#pagebody,
#page div#content,
#rap div#content { 
  width : 68%; 
  padding : 0 1%; 
  float : left; 
}
#pageextra1,
#page div#sidebar,
#rap div#menu { 
  width : 25%;
  padding : 0 1%; 
  float : right;
}
#pageextra5,
#page div#footer,
p.credit {
  padding-top : 3em; 
  clear : both;
}
#pageextra2 {
  padding-top : 3em; 
  clear : both;
}


/* pull our buttons to the top for easy access */

#userstylebuttons {
  padding : 1%;
  position : absolute;
  top : 1%;
  right : 20px;
  float : right;
  width : 50%;
  text-align : right;
}