Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Pages
docpdf.php
Go to the documentation of this file.
1
<?php
2
/*
3
* @author Anakeen
4
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5
* @package FDL
6
*/
7
/**
8
* View PDF document manuals
9
*
10
* @author Anakeen 2004
11
* @version $Id: docpdf.php,v 1.3 2005/12/12 09:23:42 eric Exp $
12
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13
* @package FDL
14
* @subpackage CORE
15
*/
16
/**
17
*/
18
// -----------------------------------
19
function
docpdf
(&
$action
)
20
{
21
// -----------------------------------
22
$pubdir
=
$action
->GetParam(
"CORE_PUBDIR"
);
23
$pubdir
.=
"/Docs/"
;
24
25
if
($handle = opendir(
$pubdir
)) {
26
/* Ceci est la façon correcte de traverser un dossier. */
27
$tpdfdoc = array();
28
while
(
false
!== (
$file
= readdir($handle))) {
29
if
((
$file
!=
""
) && (
$file
[0] !=
"."
)) {
30
// HERE HERE HERE
31
$info = shell_exec(sprintf(
'strings %s | grep -A 10 "/Title"'
, escapeshellarg(
"$pubdir/$file"
)));
32
33
$title
=
$file
;
34
$subject
=
""
;
35
$cdate =
""
;
36
if
(preg_match(
"|<< /Title <([^>]*)>|"
, $info, $reg)) {
37
$title
=
String2utf8
($reg[1]);
38
}
39
if
(preg_match(
"|/Subject <([^>]*)>|"
, $info, $reg)) {
40
$subject
=
String2utf8
($reg[1]);
41
}
42
43
if
(preg_match(
"|/CreationDate \(([^\)]*)\)|"
, $info, $reg)) {
44
// like D:20040824122100
45
$cdate = strftime(
"%d/%m/%Y"
, mktime(0, 0, 0, substr($reg[1], 6, 2) , substr($reg[1], 8, 2) , substr($reg[1], 2, 4)));
46
}
47
$tpdfdoc[] = array(
48
"url"
=>
"Docs/$file"
,
49
"filename"
=>
$file
,
50
"subject"
=>
$subject
,
51
"cdate"
=> $cdate,
52
"title"
=>
$title
53
);
54
}
55
}
56
57
closedir($handle);
58
}
59
$action
->lay->setBlockData(
"PDFDOC"
, $tpdfdoc);
60
}
61
62
function
String2utf8
(
$s
)
63
{
64
$r
=
""
;
65
for
($i = 4; $i < strlen(
$s
); $i+= 2) {
66
67
if
(
$s
[$i] .
$s
[$i + 1] !=
"00"
)
$r
.= chr(hexdec(
$s
[$i] .
$s
[$i + 1]));
68
}
69
return
(
$r
);
70
return
utf8_decode(
$r
);
71
}
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase