Core
3.2
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
pack.php
Go to the documentation of this file.
1
<?php
2
/*
3
* pack js or css files
4
* @author Anakeen
5
* @package FDL
6
*/
7
/**
8
*/
9
10
include_once (
"config/sessionHandler.php"
);
11
function
setHeaderCache
(
$type
)
12
{
13
$mime =
"text/plain"
;
14
if
(
$type
==
'css'
) {
15
$mime =
'text/css'
;
16
} elseif (
$type
==
'js'
) {
17
$mime =
'text/javascript'
;
18
}
19
ini_set(
'session.cache_limiter'
,
'none'
);
20
$duration
= 24 * 3600;
21
header(
"Cache-Control: private, max-age=$duration"
);
// use cache client (one day) for speed optimsation
22
header(
"Expires: "
. gmdate(
"D, d M Y H:i:s T\n"
, time() +
$duration
));
// for mozilla
23
header(
"Pragma: none"
);
// HTTP 1.0
24
header(
"Content-Disposition: inline;"
);
25
header(
"Content-type: $mime"
);
26
}
27
28
function
exitError
($text)
29
{
30
header(
'HTTP/1.0 503 '
. $text);
31
exit
;
32
}
33
34
function
requestPath
()
35
{
36
$path
=
'/'
;
37
$turl = parse_url(
$_SERVER
[
"REQUEST_URI"
]);
38
if
(isset($turl[
'path'
])) {
39
if
(substr($turl[
'path'
], -1) !=
'/'
) {
40
$path
= dirname($turl[
'path'
]) .
'/'
;
41
}
else
{
42
$path
= $turl[
'path'
];
43
}
44
$path
= preg_replace(
':/+:'
,
'/'
,
$path
);
45
}
46
return
$path
;
47
}
48
49
$cookName
=
'dcpsession'
;
// see Session::PARAMNAME .. not included here to be independant
50
if
(!isset($_COOKIE[
$cookName
]))
exitError
(
'Not connected'
);
51
$sessid
= $_COOKIE[
$cookName
];
52
53
if
(!isset(
$_GET
[
"pack"
]))
exitError
(
'No pack set'
);
54
if
(!isset(
$_GET
[
"type"
]))
exitError
(
'No type set'
);
55
if
(
$_GET
[
"type"
] !=
"js"
&&
$_GET
[
"type"
] !=
"css"
)
exitError
(
'No compatible type'
);
56
$packName
=
$_GET
[
"pack"
];
57
$type
=
$_GET
[
"type"
];
58
ini_set(
'session.cookie_path'
,
requestPath
());
59
session_name($cookName);
60
session_id(
$sessid
);
61
session_start();
62
63
if
(!isset($_SESSION[
'RSPACK_'
.
$packName
]))
exitError
(
'No pack reference found'
);
64
$packDef
= $_SESSION[
'RSPACK_'
.
$packName
];
65
66
setHeaderCache
(
$type
);
67
foreach
(
$packDef
as $fileRef) {
68
$path
= $fileRef[
"ref"
];
69
printf(
"\n/*include : %s */\n"
,
$path
);
70
if
(!file_exists(
$path
))
exitError
(sprintf(
'File %s not found'
,
$path
));
71
print
file_get_contents(
$path
);
72
}
$duration
if($dbaccess=="") $duration
Definition:
cleanContext.php:36
$cookName
$cookName
Definition:
pack.php:49
exitError
exitError($text)
Definition:
pack.php:28
$path
$path
Definition:
dav.php:39
$_GET
global $_GET
Definition:
wsh.php:37
requestPath
requestPath()
Definition:
pack.php:34
print
print
Definition:
checklist.php:49
$_SERVER
global $_SERVER
Definition:
cleanContext.php:41
exit
switch($command) exit
Definition:
checkVault.php:46
$sessid
$sessid
Definition:
pack.php:51
$packDef
$packDef
Definition:
pack.php:64
$packName
$packName
Definition:
pack.php:56
setHeaderCache
setHeaderCache($type)
Definition:
pack.php:11
$type
$type
Definition:
pack.php:57
← centre documentaire
© anakeen