Skip to content

Commit 5bfc08b

Browse files
committed
Issue 2499: Some php improvements
1 parent 6b2c176 commit 5bfc08b

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

combine.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
<?php
2-
3-
if ( ! isset($type) || ! isset($elements) )
2+
// Get the filetype and array of files
3+
if ( ! isset($type) || ! isset($files) )
44
{
5-
echo '$type and $elements must be specified!';
5+
echo '$type and $files must be specified!';
66
exit;
77
}
88

99
$contents = '';
1010

11-
foreach ( $elements as $file ) {
11+
// Loop through the files adding them to a string
12+
foreach ( $files as $file ) {
1213
$contents .= file_get_contents($file). "\n\n";
1314
}
1415

16+
// If gzip is supported, send the file gzipped
17+
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
18+
ob_start("ob_gzhandler");
19+
}
20+
21+
// Set the content type, filesize and an expiration so its not cached
1522
header('Content-Type: ' . $type);
1623
header('Content-Length: ' . strlen($contents));
17-
echo $contents;
24+
header('Expires: Fri, 01 Jan 2010 05:00:00 GMT');
25+
26+
// Deliver the file
27+
echo $contents;

js/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
$type = "text/javascript";
3-
$elements = array(
2+
$type = 'text/javascript';
3+
$files = array(
44
'jquery.ui.widget.js',
55
'jquery.mobile.widget.js',
66
'jquery.mobile.media.js',
@@ -38,4 +38,4 @@
3838
'jquery.mobile.init.js'
3939
);
4040

41-
include('../combine.php');
41+
require_once('../combine.php');

themes/default/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
$type = "text/css";
3-
$elements = array(
2+
$type = 'text/css';
3+
$files = array(
44
'jquery.mobile.theme.css',
55
'jquery.mobile.core.css',
66
'jquery.mobile.transitions.css',
@@ -19,4 +19,4 @@
1919
'jquery.mobile.forms.slider.css'
2020
);
2121

22-
include('../../combine.php');
22+
require_once('../../combine.php');

themes/valencia/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
$type = "text/css";
3-
$elements = array(
2+
$type = 'text/css';
3+
$files = array(
44
'jquery.mobile.theme.css',
55
'../default/jquery.mobile.core.css',
66
'../default/jquery.mobile.transitions.css',
@@ -19,4 +19,4 @@
1919
'../default/jquery.mobile.forms.slider.css'
2020
);
2121

22-
include('../../combine.php');
22+
require_once('../../combine.php');

0 commit comments

Comments
 (0)