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
changeicon.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
* Change icon of a document
9
*
10
* @author Anakeen 2000
11
* @version $Id: changeicon.php,v 1.8 2006/11/16 16:41:19 eric Exp $
12
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13
* @package FDL
14
* @subpackage GED
15
*/
16
/**
17
*/
18
19
include_once (
"FDL/Class.Doc.php"
);
20
include_once (
"FDL/Class.DocAttr.php"
);
21
include_once (
"FREEDOM/freedom_mod.php"
);
22
include_once (
"VAULT/Class.VaultFile.php"
);
23
24
function
changeicon
(&
$action
)
25
{
26
global $_FILES;
27
28
$destdir =
"./"
.
GetHttpVars
(
"app"
) .
"/Upload/"
;
29
30
$dbaccess
=
$action
->GetParam(
"FREEDOM_DB"
);
31
$docid
=
GetHttpVars
(
"id"
, 0);
32
33
$action
->lay->Set(
"docid"
,
$docid
);
34
35
$doc
=
new_Doc
(
$dbaccess
,
$docid
);
36
$err
=
$doc
->canEdit();
37
if
(
$err
!=
""
)
$action
->AddWarningMsg(
$err
);
38
else
{
39
//print_r($_FILES);
40
$fileinfo = $_FILES[
"ifile"
];
41
if
(is_array($fileinfo)) {
42
// if no file specified, keep current file
43
if
(($fileinfo[
'tmp_name'
] ==
"none"
) || ($fileinfo[
'tmp_name'
] ==
""
) || ($fileinfo[
'size'
] == 0)) {
44
$vid = getHttpVars(
"vid"
);
45
if
($vid > 0) {
46
$doc
->ChangeIcon(
"image|"
. $vid);
47
}
else
{
48
$action
->addWarningMsg(_(
"no file specified : change icon aborted"
));
49
}
50
}
else
{
51
if
(!is_uploaded_file($fileinfo[
'tmp_name'
]))
$action
->ExitError(_(
"file not expected : possible attack : update aborted"
));
52
53
preg_match(
"/(.*)\.(.*)$/"
, $fileinfo[
'name'
], $reg);
54
$ext = $reg[2];
55
// move to add extension
56
$destfile = str_replace(
" "
,
"_"
,
getTmpDir
() .
"/"
. $fileinfo[
'name'
]);
57
move_uploaded_file($fileinfo[
'tmp_name'
], $destfile);
58
59
$vf
=
newFreeVaultFile
(
$dbaccess
);
60
61
$err
=
$vf
->Store($destfile,
true
, $vid);
62
if
(
$err
!=
""
)
$action
->ExitError(
$err
);
63
64
$doc
->ChangeIcon($fileinfo[
'type'
] .
"|"
. $vid);
65
66
unlink($destfile);
67
}
68
}
69
}
70
71
redirect(
$action
,
"FDL"
,
"FDL_CARD&sole=Y&id="
.
$doc
->id);
72
}
73
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase