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
getsessionid.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
* Get DAV session
9
*
10
* @author Anakeen 2006
11
* @version $Id: getsessionid.php,v 1.4 2007/03/08 16:35:35 eric Exp $
12
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13
* @package FDL
14
* @subpackage DAV
15
*/
16
/**
17
*/
18
19
include_once (
"FDL/Class.Doc.php"
);
20
include_once (
"DAV/Class.FdlDav.php"
);
21
/**
22
* Get DAV session id for current user
23
* @param Action &$action current action
24
* @param string $vid identificator for file <vaultid>-<docid>
25
*/
26
function
getsessionid
(&
$action
)
27
{
28
header(
'Content-type: text/xml; charset=utf-8'
);
29
30
$mb = microtime();
31
$vid =
GetHttpVars
(
"vid"
);
32
$docid
=
GetHttpVars
(
"docid"
);
33
34
$dbaccess
=
$action
->GetParam(
"FREEDOM_DB"
);
35
36
$action
->lay->set(
"warning"
,
""
);
37
$action
->lay->set(
"CODE"
,
"OK"
);
38
$sessid =
dav_sessionid
(
$docid
, $vid);
39
$action
->lay->set(
"sessid"
, $sessid);
40
$action
->lay->set(
"count"
, 1);
41
$action
->lay->set(
"delay"
,
microtime_diff
(microtime() , $mb));
42
}
43
44
function
dav_sessionid
(
$docid
, $vid)
45
{
46
global
$action
;
47
$s
=
new
HTTP_WebDAV_Server_Freedom
(
getParam
(
"WEBDAV_DB"
));
48
$s
->setFolderMaxItem(
getParam
(
'WEBDAV_FOLDERMAXITEM'
));
49
$sid =
$s
->getSession(
$docid
, $vid, $action->user->login);
50
if
(!$sid) {
51
$sid = md5(uniqid($vid));
52
$s
->addsession($sid, $vid,
$docid
, $action->user->login, time() + 3600);
53
if
(!
$s
) $action->lay->set(
"CODE"
,
"KO"
);
54
}
55
return
"$docid-$vid-$sid"
;
56
}
57
function
dav_getdavurl
(
$docid
, $vid)
58
{
59
$dbaccess
=
getParam
(
"FREEDOM_DB"
);
60
$vf
=
newFreeVaultFile
(
$dbaccess
);
61
$sdav =
getParam
(
"FREEDAV_SERVEUR"
,
false
);
62
if
($sdav &&
$vf
->Show($vid, $info) ==
""
) {
63
return
sprintf(
"asdav://%s/freedav/vid-%s/%s"
, $sdav,
dav_sessionid
(
$docid
, $vid) , $info->name);
64
}
65
}
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase