| [ PHPXref.com ] | [ Generated: Sun Jul 20 17:01:00 2008 ] | [ CMS Made Simple 0.12.1 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: stylesheet.php 2657 2006-03-16 01:00:05Z wishy $ 20 21 require_once(dirname(__FILE__)."/include.php"); 22 23 if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) 24 { 25 @ini_set( 'zlib.output_compression','Off' ); 26 } 27 28 $templateid = ""; 29 $mediatype = ''; 30 $name = ''; 31 $css = ''; 32 $nostylesheet = false; 33 $stripbackground = false; 34 if (isset($_GET["templateid"])) $templateid = $_GET["templateid"]; 35 if (isset($_GET["mediatype"])) $mediatype = $_GET["mediatype"]; 36 if (isset($_GET['name'])) $name = $_GET['name']; 37 if (isset($_GET["stripbackground"])) $stripbackground = true; 38 39 if ($name != '') 40 { 41 //TODO: Make stylesheet handling OOP 42 global $gCms; 43 $db =& $gCms->GetDb(); 44 $cssquery = "SELECT css_text FROM ".cms_db_prefix()."css WHERE css_name = ?"; 45 $cssresult = &$db->Execute($cssquery, $name); 46 47 while ($cssresult && !$cssresult->EOF) 48 { 49 $css .= "\n".$cssresult->fields['css_text']."\n"; 50 $cssresult->MoveNext(); 51 } 52 } 53 else 54 { 55 $result = get_stylesheet($templateid, $mediatype); 56 $css = $result['stylesheet']; 57 if (!isset($result['nostylesheet'])) 58 { 59 #$nostylesheet = true; 60 #Perform the content stylesheet callback 61 #if ($nostylesheet == false) 62 #{ 63 reset($gCms->modules); 64 while (list($key) = each($gCms->modules)) 65 { 66 $value =& $gCms->modules[$key]; 67 if ($gCms->modules[$key]['installed'] == true && 68 $gCms->modules[$key]['active'] == true) 69 { 70 $gCms->modules[$key]['object']->ContentStylesheet($css); 71 } 72 } 73 #} 74 } 75 } 76 77 #header("Content-Language: " . $current_language); 78 header("Content-Type: text/css; charset=" . (isset($result['encoding'])?$result['encoding']:'UTF-8')); 79 80 if ($stripbackground) 81 { 82 #$css = preg_replace('/(\w*?background-color.*?\:\w*?).*?(;.*?)/', '', $css); 83 $css = preg_replace('/(\w*?background-color.*?\:\w*?).*?(;.*?)/', '\\1transparent\\2', $css); 84 $css = preg_replace('/(\w*?background-image.*?\:\w*?).*?(;.*?)/', '', $css); 85 } 86 87 #Do cache-control stuff but only if we are running Apache 88 if(function_exists('getallheaders')) 89 { 90 $headers = getallheaders(); 91 $hash = md5($css); 92 93 #if browser sent etag and it is the same then reply with 304 94 if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == '"'.$hash.'"') 95 { 96 header('HTTP/1.1 304 Not Modified'); 97 exit; 98 } 99 else { 100 header('ETag: "'.$hash.'"'); 101 #header("Cache-Control: maxage=".(60*60*24)); 102 } 103 } 104 105 #sending content length allows HTTP/1.0 persistent connections 106 #(and also breaks if gzip is on) 107 //header("Content-Length: ".strlen($css)); 108 109 echo $css; 110 111 # vim:ts=4 sw=4 noet 112 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |