f-engine /application/admin/public_data/compact.php

Language PHP Lines 57
MD5 Hash 7cc24c1ebb02d4493ed62fa584b59ef8 Estimated Cost $728 (why?)
Repository http://f-engine.googlecode.com/svn/trunk/ View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
	/***
	 * This script combines and compacts css and javascript files
	 * to reduce the number of HTTP requests and speed up 
	 * web page load time
	 */
	define('BASEPATH',realpath(dirname(__FILE__))."/../../");
	include(realpath(dirname(__FILE__))."/../config/config.php");

	$options = $config["compact"];

	if($options["compress"] and extension_loaded('zlib')) {
			ob_start('ob_gzhandler');
	}

	header ("content-type: text/css; charset: UTF-8");
	header ("cache-control: must-revalidate");

	$offset = 60 * 60 * $options["cachetime"];
	$expire = "expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
	header ($expire);

	if(isset($_GET["css"])) {

		$files = $_GET["css"];
		$prefix = "css/";

	} elseif(isset($_GET["js"])) {

		$files = $_GET["js"];
		$prefix = "js/";		

	} else {

		return;
	}

	$files = explode(",",$files);

	foreach($files as $file) {

		$filename = realpath(dirname(__FILE__)."/".$prefix.$file);

		if(file_exists($filename) and strstr($filename, realpath(dirname(__FILE__)))) {

			include($filename);

		} else {

			echo "\n/* file not found: ".$filename." */\n";
		}
	}

	if($options["compress"] and extension_loaded('zlib')){
		ob_end_flush();
	}
Back to Top