This repository has been archived by the owner on Aug 21, 2020. It is now read-only.
forked from myYearbook/Puree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·89 lines (72 loc) · 1.99 KB
/
index.php
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Handle delegation of tasks for Puree requests
*
* @author Dallas Gutauckis <[email protected]>
* @since 2008-11-13 23:40:51
*/
/*
* Configuration parameter that defines the root of your assets URL.
* This is used for replacing relative URLs with the full URL for the
* sake of exactness and potential drop-in capabilities
*/
define( 'ASSETS_URL', 'http://assets.devk.it/' );
/*
* The path that Puree has been installed to
*/
define( 'INSTALL_PATH', '/proj/puree/' );
/*
* Path prefixes for each content type
*/
define( 'PATH_PREFIX_CSS', '../puree-assets/CSS/' );
define( 'PATH_PREFIX_JS', '../puree-assets/JS/' );
/*
* Add body to this function to log errors if desired
*
* @param string $error Error message
* @return void
*/
function logError( $error )
{
}
// No configuration beyond this point
header( 'Pragma: cache' );
header( 'Cache-control: public' );
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s \G\M\T', time() + 2592000 ) );
$validTypes = array( 'css', 'js' );
// Remove the install path from the request uri
$uri = ltrim( $_SERVER['REQUEST_URI'], INSTALL_PATH );
if ( ! $uri )
{
// Invalid uri
logError( 'Invalid uri requested' );
exit;
}
list( $type, $params ) = explode( '/', $uri, 2 );
if ( ! in_array( $type, $validTypes ) )
{
// Invalid type
logError( 'Invalid type ("' . $type . '") requested' );
exit;
}
$params = explode( ';', $params );
$files = array();
// Iterate over the files+cachebuster requested and remove the cachebuster and build the file list
foreach ( $params as $file )
{
if ( false !== strpos( $file, ':' ) )
{
// Strip the cachebuster off of the end of the file requested
list( $file, $ignore ) = explode( ':', $file, 2 );
// Add the file name to the file array
}
if ( false !== strpos( $file, '..' ) )
{
continue;
}
$files[] = $file;
}
// Bring in the code related to handling this type
require( $type . '.php' );
// Call our type handler function
call_user_func( 'handle' . strtoupper( $type ), $files );