Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
user.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  * User api access
9  *
10  * @author Anakeen 2009
11  * @version $Id: $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("DATA/Class.User.php");
20 /**
21  * Display info before download
22  * @param Action &$action current action
23  * @global id Http var : document for file to edit (SIMPLEFILE family)
24  */
25 function user(&$action)
26 {
27  $id = getHttpVars("id");
28  $method = getHttpVars("method");
29  $err = "";
30 
31  $out = false;
32  switch (strtolower($method)) {
33  case '':
34  $ou = new Fdl_User($action->user);
35  $out = $ou->getUser();
36  break;
37 
38  case 'ping':
39  $out->status = 'ok';
40  $out->time = time();
41  break;
42 
43  case 'authent':
44  $login = getHttpVars("login");
45  $password = getHttpVars("password");
46  $u = new User();
47  if ($u->setLoginname($login)) {
48  include_once ('WHAT/Class.htmlAuthenticator.php');
49 
50  $authProviderList = getAuthProviderList();
51  foreach ($authProviderList as $provider) {
52  $auth = new htmlAuthenticator(getAuthType() , $provider);
53  $_POST[$auth->parms{'username'}] = $login;
54  $_POST[$auth->parms{'password'}] = $password;
55  if ($auth->checkAuthentication() != Authenticator::AUTH_OK) {
56  $out->error = sprintf(_("authentication failed for %s") , $login);
57  } else {
58  $ou = new Fdl_User($u);
59  $out = $ou->getUser();
60  break;
61  }
62  }
63  } else {
64  $out->error = sprintf(_("user %s not found") , $login);
65  }
66  break;
67 
68  default:
69  $out->error = sprintf(_("method %s not defined") , $method);
70  }
71 
72  $action->lay->template = json_encode($out);
73 }
74 ?>
← centre documentaire © anakeen - published under CC License - Dynacase