Alternc  latest
Alternc logiel libre pour l'hébergement
 All Classes Namespaces Files Functions Variables Pages
m_mem Class Reference

This class manage user sessions in the web desktop. More...

Public Member Functions

 m_mem ()
 Constructeur. More...
 
 alternc_password_policy ()
 Password kind used in this class (hook for admin class) More...
 
 hook_menu ()
 
 checkright ()
 Check that the current user is an admnistrator. More...
 
 login ($username, $password, $restrictip=0, $authip_token=false)
 Start a session in the web desktop. More...
 
 setid ($id)
 Start a session as another user from an administrator account. More...
 
 resetlast ()
 Suite � la connexion de l'utilisateur, r�initialise ses param�tres de derni�re connexion. More...
 
 authip_token ($bis=false)
 
 authip_tokencheck ($t)
 
 checkid ()
 Verifie que la session courante est correcte (cookie ok et ip valide). More...
 
 su ($uid)
 Change l'identite d'un utilisateur temporairement. More...
 
 unsu ()
 Retourne a l'identite d'origine de l'utilisateur apres su. More...
 
 del_session ()
 Termine une session du bureau virtuel (logout) More...
 
 passwd ($oldpass, $newpass, $newpass2)
 Change le mot de passe de l'utilisateur courant. More...
 
 adminpref ($admlist)
 Change les preferences administrateur d'un compte. More...
 
 send_pass ($login)
 Envoie en mail le mot de passe d'un compte. More...
 
 ChangeMail1 ($newmail)
 Change le mail d'un membre (premiere etape, envoi du CookiE) TODO : insert this mail string into the localization system. More...
 
 ChangeMail2 ($COOKIE, $KEY, $uid)
 Change le mail d'un membre (seconde etape, CookiE+cle = application) More...
 
 set_help_param ($show)
 Modifie le parametre d'aide en ligne (1/0) More...
 
 get_help_param ()
 Dit si l'aide en ligne est demandee. More...
 
 show_help ($file, $force=false)
 Affiche (echo) l'aide contextuelle. More...
 
 get_creator_by_uid ($uid)
 
 alternc_export_conf ()
 Exports all the personal user related information for an account. More...
 
 session_tempo_params_get ($v)
 
 session_tempo_params_set ($k, $v, $ecrase=false)
 

Public Attributes

 $olduid = 0
 Original uid for the temporary uid swapping (for administrators) More...
 
 $user
 This array contains the Tableau contenant les champs de la table "membres" du membre courant Ce tableau est utilisable globalement par toutes les classes filles. More...
 
 $local
 Tableau contenant les champs de la table "local" du membre courant Ce tableau est utilisable globalement par toutes les classes filles. More...
 

Detailed Description

This class manage user sessions in the web desktop.

This class manage user sessions and administration in AlternC.

Definition at line 33 of file m_mem.php.

Member Function Documentation

m_mem::adminpref (   $admlist)

Change les preferences administrateur d'un compte.

Parameters
integer$admlistMode de visualisation des membres (0=large 1=courte)
Returns
boolean TRUE si les preferences ont ete changees, FALSE sinon.

Definition at line 439 of file m_mem.php.

References $cuid, $db, and $err.

439  {
440  global $db, $err, $cuid;
441  $err->log("mem", "admlist");
442  if (!$this->user["su"]) {
443  $err->raise("mem", _("You must be a system administrator to do this."));
444  return false;
445  }
446  $db->query("UPDATE membres SET admlist= ? WHERE uid= ?;", array($admlist, $cuid));
447  $err->error = 0;
448  return true;
449  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_mem::alternc_export_conf ( )

Exports all the personal user related information for an account.

private

Definition at line 635 of file m_mem.php.

References $db, $err, and $user.

635  {
636  global $db, $err;
637  $err->log("mem", "export");
638  $str = " <member>\n";
639  $users = $this->user;
640  $str.=" <uid>" . $users["uid"] . "</uid>\n";
641  $str.=" <login>" . $users["login"] . "</login>\n";
642  $str.=" <enabled>" . $users["enabled"] . "</enabled>\n";
643  $str.=" <su>" . $users["su"] . "</su>\n";
644  $str.=" <password>" . $users["pass"] . "</password>\n";
645  $str.=" <mail>" . $users["mail"] . "</mail>\n";
646  $str.=" <created>" . $users["created"] . "</created>\n";
647  $str.=" <lastip>" . $users["lastip"] . "</lastip>\n";
648  $str.=" <lastlogin>" . $users["lastlogin"] . "</lastlogin>\n";
649  $str.=" <lastfail>" . $users["lastfail"] . "</lastfail>\n";
650  $str.=" </member>\n";
651  return $str;
652  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$user
This array contains the Tableau contenant les champs de la table "membres" du membre courant Ce table...
Definition: m_mem.php:41
m_mem::alternc_password_policy ( )

Password kind used in this class (hook for admin class)

Definition at line 63 of file m_mem.php.

63  {
64  return array("mem" => "AlternC's account password");
65  }
m_mem::authip_token (   $bis = false)

Definition at line 224 of file m_mem.php.

References $cuid, $db, and $i.

Referenced by authip_tokencheck().

224  {
225  global $db, $cuid;
226  $db->query("select pass from membres where uid= ?;", array($cuid));
227  $db->next_record();
228  $i = intval(time() / 3600);
229  if ($bis) {
230  ++$i;
231  }
232  return md5("$i--" . $db->f('pass'));
233  }
global $db
Definition: bootstrap.php:22
$cuid
Definition: bootstrap.php:43
m_mem::authip_tokencheck (   $t)
Parameters
boolean$t

Definition at line 238 of file m_mem.php.

References $t, and authip_token().

Referenced by login().

238  {
239  return ($t == $this->authip_token() || $t == $this->authip_token(true));
240  }
$t
Definition: dom_editdns.php:58
authip_token($bis=false)
Definition: m_mem.php:224
m_mem::ChangeMail1 (   $newmail)

Change le mail d'un membre (premiere etape, envoi du CookiE) TODO : insert this mail string into the localization system.

Parameters
string$newmailNouveau mail souhaite pour le membre.
Returns
string le cookie si le mail a bien ete envoye, FALSE sinon

Definition at line 503 of file m_mem.php.

References $cuid, $db, $err, and $link.

503  {
504  global $err, $db, $L_HOSTING, $L_FQDN, $cuid;
505  $err->log("mem", "changemail1", $newmail);
506  $db->query("SELECT * FROM membres WHERE uid= ? ;", array($cuid));
507  if (!$db->num_rows()) {
508  $err->raise("mem", _("This account is locked, contact the administrator."));
509  return false;
510  }
511  $db->next_record();
512 
513  // un cookie de 20 caract�res pour le mail
514  $COOKIE = substr(md5(mt_rand().mt_rand()), 0, 20);
515  // et de 6 pour la cl� � entrer. ca me semble suffisant...
516  $KEY = substr(md5(mt_rand().mt_rand()), 0, 6);
517  $link = "https://$L_FQDN/mem_cm.php?usr=$cuid&cookie=$COOKIE";
518  $txt = sprintf(_("Hello,
519 
520 Someone (maybe you) requested an email's address modification of the account
521 %s on %s
522 To confirm your request, go to this url :
523 
524 %s
525 
526 (Warning : if this address is displayed on 2 lines, don't forgot to
527 take it on one line).
528 The panel will ask you the key given when the email address
529 modification was requested.
530 
531 If you didn't asked for this modification, it means that someone
532 did it instead of you. You can choose to ignore this message. If it happens
533 again, please contact your server's administrator.
534 
535 Cordially.
536 "), $db->f("login"), $L_HOSTING, $link);
537  mail($newmail, "Email modification request on $L_HOSTING", $txt, "From: postmaster@$L_FQDN\nReply-to: postmaster@$L_FQDN");
538  // Supprime les demandes pr�c�dentes de ce compte !
539  $db->query("DELETE FROM chgmail WHERE uid= ? ;", array($cuid));
540  $db->query("INSERT INTO chgmail (cookie,ckey,uid,mail,ts) VALUES ( ?, ?, ?, ?, ?);", array($COOKIE, $KEY, $cuid, $newmail, time()));
541  // Supprime les cookies de la veille :)
542  $lts = time() - 86400;
543  $db->query("DELETE FROM chgmail WHERE ts< ? ;", array($lts));
544  return $KEY;
545  }
$link
Definition: change.php:31
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_mem::ChangeMail2 (   $COOKIE,
  $KEY,
  $uid 
)

Change le mail d'un membre (seconde etape, CookiE+cle = application)

Parameters
string$COOKIECookie envoye par mail
string$KEYcle affichee a l'ecran
integer$uidUtilisateur concerne (on est hors session)
Returns
boolean TRUE si le mail a bien ete modifie, FALSE sinon

Definition at line 555 of file m_mem.php.

References $db, $err, and $uid.

555  {
556  global $err, $db;
557  $err->log("mem", "changemail2", $uid);
558  $db->query("SELECT * FROM chgmail WHERE cookie= ? and ckey= ? and uid= ?;", array($COOKIE, $KEY, $uid));
559  if (!$db->num_rows()) {
560  $err->raise("mem", _("The information you entered is incorrect."));
561  return false;
562  }
563  $db->next_record();
564 
565  // met a jour le compte :
566  $db->query("UPDATE membres SET mail= ? WHERE uid = ? ;", array($db->f("mail"), $uid));
567 
568  $db->query("DELETE FROM chgmail WHERE uid= ? ;", array($uid));
569  // Supprime les cookies de la veille :)
570  $lts = time() - 86400;
571  $db->query("DELETE FROM chgmail WHERE ts< ? ;", array($lts));
572  return true;
573  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_mem::checkid ( )

Verifie que la session courante est correcte (cookie ok et ip valide).

Si besoin, et si reception des champs username & password, cree une nouvelle session pour l'utilisateur annonce. Cette fonction doit etre appellee a chaque page devant etre authentifiee. et AVANT d'emettre des donnees. (un cookie peut etre envoye)

Parameters
globalstring $session Le cookie de session eventuel
globalstring $username/password le login/pass de l'utilisateur
Returns
boolean TRUE si la session est correcte, FALSE sinon.

Definition at line 265 of file m_mem.php.

References $_COOKIE, $_REQUEST, $cuid, $db, $err, get_remote_ip(), login(), and panel_islocked().

265  {
266  global $db, $err, $cuid;
267  if (isset($_REQUEST["username"])) {
268  if (empty($_REQUEST['password'])) {
269  $err->raise("mem", _("Missing password"));
270  return false;
271  }
272  if ($_REQUEST["username"] && $_REQUEST["password"]) {
273  return $this->login($_REQUEST["username"], $_REQUEST["password"], (isset($_REQUEST["restrictip"]) ? $_REQUEST["restrictip"] : 0));
274  }
275  } // end isset
276  $_COOKIE["session"] = isset($_COOKIE["session"]) ? $_COOKIE["session"] : "";
277  if (strlen($_COOKIE["session"]) != 32) {
278  $err->raise("mem", _("Identity lost or unknown, please login"));
279  return false;
280  }
281  $ip = get_remote_ip();
282  $db->query("select uid, ? as me,ip from sessions where sid= ?;", array($ip, $_COOKIE["session"]));
283  if ($db->num_rows() == 0) {
284  $err->raise("mem", _("Session unknown, contact the administrator"));
285  return false;
286  }
287  $db->next_record();
288  $cuid = $db->f("uid");
289 
290  if (panel_islocked() && $cuid != 2000) {
291  $err->raise("mem", _("This website is currently under maintenance, login is currently disabled."));
292  return false;
293  }
294 
295  $db->query("select * from membres where uid= ? ;", array($cuid));
296  $db->next_record();
297  $this->user = $db->Record;
298  $err->error = 0;
299  /* Remplissage de $local */
300  $db->query("SELECT * FROM local WHERE uid= ? ;", array($cuid));
301  if ($db->num_rows()) {
302  $db->next_record();
303  $this->local = $db->Record;
304  }
305  return true;
306  }
if(!$error||!trim($error,"<br />")) $_REQUEST["domain_id"]
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
$_COOKIE['oldid']
Definition: adm_login.php:95
get_remote_ip()
Return the remote IP.
Definition: functions.php:133
login($username, $password, $restrictip=0, $authip_token=false)
Start a session in the web desktop.
Definition: m_mem.php:96
panel_islocked()
Definition: functions.php:1092
m_mem::checkright ( )

Check that the current user is an admnistrator.

Returns
boolean TRUE if we are super user, or FALSE if we are not.

Definition at line 83 of file m_mem.php.

83  {
84  return ($this->user["su"] == "1");
85  }
m_mem::del_session ( )

Termine une session du bureau virtuel (logout)

Returns
boolean TRUE si la session a bien ete detruite, FALSE sinon.

Definition at line 355 of file m_mem.php.

References $_COOKIE, $cuid, $db, $err, $hooks, $user, and get_remote_ip().

355  {
356  global $db, $user, $err, $cuid, $hooks;
357  $_COOKIE["session"] = isset($_COOKIE["session"]) ? $_COOKIE["session"] : '';
358  setcookie("session", "", 0, "/");
359  setcookie("oldid", "", 0, "/");
360  if ($_COOKIE["session"] == "") {
361  $err->error = 0;
362  return true;
363  }
364  if (strlen($_COOKIE["session"]) != 32) {
365  $err->raise("mem", _("Cookie incorrect, please accept the session cookie"));
366  return false;
367  }
368  $ip = get_remote_ip();
369  $db->query("select uid, ? as me,ip from sessions where sid= ? ;", array($ip, $_COOKIE["session"]));
370  if ($db->num_rows() == 0) {
371  $err->raise("mem", _("Session unknown, contact the administrator"));
372  return false;
373  }
374  $db->next_record();
375  if ($db->f("me") != $db->f("ip")) {
376  $err->raise("mem", _("IP address incorrect, please contact the administrator"));
377  return false;
378  }
379  $cuid = $db->f("uid");
380  $db->query("delete from sessions where sid= ? ;", array($_COOKIE["session"]));
381  $err->error = 0;
382 
383  # Invoker le logout dans toutes les autres classes
384  /*
385  foreach($classes as $c) {
386  if (method_exists($GLOBALS[$c],"alternc_del_session")) {
387  $GLOBALS[$c]->alternc_del_session();
388  }
389  }
390  */
391  $hooks->invoke("alternc_del_session");
392 
393  session_unset();
394  @session_destroy();
395  return true;
396  }
$hooks
Definition: bootstrap.php:74
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$user
This array contains the Tableau contenant les champs de la table "membres" du membre courant Ce table...
Definition: m_mem.php:41
$cuid
Definition: bootstrap.php:43
$_COOKIE['oldid']
Definition: adm_login.php:95
get_remote_ip()
Return the remote IP.
Definition: functions.php:133
m_mem::get_creator_by_uid (   $uid)
Parameters
integer$uid

Definition at line 619 of file m_mem.php.

References $db, $err, and $uid.

619  {
620  global $db, $err;
621  $err->log("dom", "get_creator_by_uid");
622  $db->query("select creator from membres where uid = ? ;", array($uid));
623  if (!$db->next_record()) {
624  return false;
625  }
626  return intval($db->f('creator'));
627  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_mem::get_help_param ( )

Dit si l'aide en ligne est demandee.

Returns
boolean TRUE si l'aide en ligne est demandee, FALSE sinon.

Definition at line 591 of file m_mem.php.

591  {
592  return $this->user["show_help"];
593  }
m_mem::hook_menu ( )

Definition at line 67 of file m_mem.php.

67  {
68  $obj = array(
69  'title' => _("Settings"),
70  'ico' => 'images/settings.png',
71  'link' => 'mem_param.php',
72  'pos' => 160,
73  );
74 
75  return $obj;
76  }
m_mem::login (   $username,
  $password,
  $restrictip = 0,
  $authip_token = false 
)

Start a session in the web desktop.

Check username and password. Note : If the user entered a bas password, the failure will be logged and told to the corresponding user on next successfull login.

Parameters
$usernamestring Username that want to get connected.
$passwordstring User Password.
Returns
boolean TRUE if the user has been successfully connected, or FALSE if an error occured.

Definition at line 96 of file m_mem.php.

References $_COOKIE, $_REQUEST, $authip, $cuid, $db, $err, $password, $username, _md5cr(), authip_tokencheck(), get_remote_ip(), panel_islocked(), and resetlast().

Referenced by checkid().

96  {
97  global $db, $err, $cuid, $authip;
98  $err->log("mem", "login", $username);
99  // $username=addslashes($username);
100  // $password=addslashes($password);
101  $db->query("select * from membres where login= ? ;", array($username));
102  if ($db->num_rows() == 0) {
103  $err->raise("mem", _("User or password incorrect"));
104  return false;
105  }
106  $db->next_record();
107  if (_md5cr($password, $db->f("pass")) != $db->f("pass")) {
108  $db->query("UPDATE membres SET lastfail=lastfail+1 WHERE uid= ? ;", array($db->f("uid")));
109  $err->raise("mem", _("User or password incorrect"));
110  return false;
111  }
112  if (!$db->f("enabled")) {
113  $err->raise("mem", _("This account is locked, contact the administrator."));
114  return false;
115  }
116  $this->user = $db->Record;
117  $cuid = $db->f("uid");
118 
119  if (panel_islocked() && $cuid != 2000) {
120  $err->raise("mem", _("This website is currently under maintenance, login is currently disabled."));
121  return false;
122  }
123 
124  // AuthIP
125  $allowed_ip = false;
126  if ($authip_token) {
127  $allowed_ip = $this->authip_tokencheck($authip_token);
128  }
129 
130  $aga = $authip->get_allowed('panel');
131  foreach ($aga as $k => $v) {
132  if ($authip->is_in_subnet(get_remote_ip(), $v['ip'], $v['subnet'])) {
133  $allowed = true;
134  }
135  }
136 
137  // Error if there is rules, the IP is not allowed and it's not in the whitelisted IP
138  if (sizeof($aga) > 1 && !$allowed_ip && !$authip->is_wl(get_remote_ip())) {
139  $err->raise("mem", _("Your IP isn't allowed to connect"));
140  return false;
141  }
142  // End AuthIP
143 
144  if ($restrictip) {
145  $ip = get_remote_ip();
146  } else {
147  $ip = "";
148  }
149  /* Close sessions that are more than 2 days old. */
150  $db->query("DELETE FROM sessions WHERE DATE_ADD(ts,INTERVAL 2 DAY)<NOW();");
151  /* Delete old impersonation */
152  if (isset($_COOKIE["oldid"])) {
153  setcookie('oldid', '', 0, '/');
154  }
155  /* Open the session : */
156  $sess = md5(mt_rand().mt_rand().mt_rand());
157  $_REQUEST["session"] = $sess;
158  $db->query("insert into sessions (sid,ip,uid) values (?, ?, ?);", array($sess, $ip, $cuid));
159  setcookie("session", $sess, 0, "/");
160  $err->error = 0;
161  /* Fill in $local */
162  $db->query("SELECT * FROM local WHERE uid= ? ;", array($cuid));
163  if ($db->num_rows()) {
164  $db->next_record();
165  $this->local = $db->Record;
166  }
167  $this->resetlast();
168  return true;
169  }
authip_tokencheck($t)
Definition: m_mem.php:238
if(!$error||!trim($error,"<br />")) $_REQUEST["domain_id"]
resetlast()
Suite � la connexion de l'utilisateur, r�initialise ses param�tres de derni�re connexion...
Definition: m_mem.php:215
global $db
Definition: bootstrap.php:22
_md5cr($pass, $salt="")
Hashe un mot de passe en clair en MD5 avec un salt al�atoire.
Definition: functions.php:513
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
$_COOKIE['oldid']
Definition: adm_login.php:95
$authip
Definition: bootstrap.php:73
$password
Definition: bootstrap.php:85
global $username
Definition: change.php:59
get_remote_ip()
Return the remote IP.
Definition: functions.php:133
panel_islocked()
Definition: functions.php:1092
m_mem::m_mem ( )

Constructeur.

Definition at line 54 of file m_mem.php.

54  {
55 
56  }
m_mem::passwd (   $oldpass,
  $newpass,
  $newpass2 
)

Change le mot de passe de l'utilisateur courant.

Parameters
string$oldpassAncien mot de passe.
string$newpassNouveau mot de passe
string$newpass2Nouveau mot de passe (a nouveau)
Returns
boolean TRUE si le mot de passe a ete change, FALSE sinon.

Definition at line 406 of file m_mem.php.

References $cuid, $db, $err, and _md5cr().

406  {
407  global $db, $err, $cuid, $admin;
408  $err->log("mem", "passwd");
409  if (!$this->user["canpass"]) {
410  $err->raise("mem", _("You are not allowed to change your password."));
411  return false;
412  }
413  if ($this->user["pass"] != _md5cr($oldpass, $this->user["pass"])) {
414  $err->raise("mem", _("The old password is incorrect"));
415  return false;
416  }
417  if ($newpass != $newpass2) {
418  $err->raise("mem", _("The new passwords are differents, please retry"));
419  return false;
420  }
421  $db->query("SELECT login FROM membres WHERE uid= ? ;", array($cuid));
422  $db->next_record();
423  $login = $db->Record["login"];
424  if (!$admin->checkPolicy("mem", $login, $newpass)) {
425  return false; // The error has been raised by checkPolicy()
426  }
427  $newpass = _md5cr($newpass);
428  $db->query("UPDATE membres SET pass= ? WHERE uid= ?;", array($newpass, $cuid));
429  $err->error = 0;
430  return true;
431  }
global $db
Definition: bootstrap.php:22
_md5cr($pass, $salt="")
Hashe un mot de passe en clair en MD5 avec un salt al�atoire.
Definition: functions.php:513
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_mem::resetlast ( )

Suite � la connexion de l'utilisateur, r�initialise ses param�tres de derni�re connexion.

Definition at line 215 of file m_mem.php.

References $cuid, $db, and get_remote_ip().

Referenced by login().

215  {
216  global $db, $cuid;
217  $ip = getenv("REMOTE_HOST");
218  if (!$ip) {
219  $ip = get_remote_ip();
220  }
221  $db->query("UPDATE membres SET lastlogin=NOW(), lastfail=0, lastip= ? WHERE uid= ?;", array($ip, $cuid));
222  }
global $db
Definition: bootstrap.php:22
$cuid
Definition: bootstrap.php:43
get_remote_ip()
Return the remote IP.
Definition: functions.php:133
m_mem::send_pass (   $login)

Envoie en mail le mot de passe d'un compte.

Note : On ne peut demander le mot de passe qu'une seule fois par jour. TODO : Translate this mail into the localization program. TODO : Check this function's !

Returns
boolean TRUE si le mot de passe a ete envoye avec succes, FALSE sinon.

Definition at line 459 of file m_mem.php.

References $db, and $err.

459  {
460  global $err, $db, $L_HOSTING, $L_FQDN;
461  $err->log("mem", "send_pass");
462  $db->query("SELECT * FROM membres WHERE login= ? ;", array($login));
463  if (!$db->num_rows()) {
464  $err->raise("mem", _("This account is locked, contact the administrator."));
465  return false;
466  }
467  $db->next_record();
468  if (time() - $db->f("lastaskpass") < 86400) {
469  $err->raise("mem", _("The new passwords are differents, please retry"));
470  return false;
471  }
472  $txt = sprintf(_("Hello,
473 
474 You requested the modification of your password for your
475 account %s on %s
476 Here are your username and password to access the panel :
477 
478 --------------------------------------
479 
480 Username : %s
481 Password : %s
482 
483 --------------------------------------
484 
485 Note : if you didn't requested that modification, it means that
486 someone did it instead of you. You can choose to ignore this message.
487 If it happens again, please contact your server's Administrator.
488 
489 Cordially.
490 "), $login, $L_HOSTING, $db->f("login"), $db->f("pass"));
491  mail($db->f("mail"), "Your password on $L_HOSTING", $txt, "From: postmaster@$L_FQDN\nReply-to: postmaster@$L_FQDN");
492  $db->query("UPDATE membres SET lastaskpass= ? WHERE login= ? ;", array(time(), $login));
493  return true;
494  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
m_mem::session_tempo_params_get (   $v)

Definition at line 654 of file m_mem.php.

References $_COOKIE, $_SESSION, and $uid.

654  {
655  global $uid;
656  if (empty($_COOKIE['session'])) {
657  return false;
658  }
659  $sid = $_COOKIE['session'];
660  if (empty($_SESSION[$sid . '-' . $uid])) { // si pas de session de params tempo
661  return false;
662  }
663  $j = $_SESSION[$sid . '-' . $uid];
664  $j = json_decode($j, true);
665  if (!empty($j[$v])) { // si on a bien qque chose a retourner :)
666  return $j[$v];
667  }
668  return false;
669  }
$uid
$_COOKIE['oldid']
Definition: adm_login.php:95
$_SESSION['PMA_single_signon_password']
Definition: sql_pma_sso.php:37
m_mem::session_tempo_params_set (   $k,
  $v,
  $ecrase = false 
)

Definition at line 671 of file m_mem.php.

References $_COOKIE, $_SESSION, $p, and $uid.

671  {
672  global $uid;
673  if (empty($_COOKIE['session'])) {
674  return false;
675  }
676  $sid = $_COOKIE['session'];
677  $p = Array();
678  if (!empty($_SESSION[$sid . '-' . $uid])) {
679  $p = json_decode($_SESSION[$sid . '-' . $uid], true);
680  }
681  if (!$ecrase && (isset($p[$k]) && is_array($p[$k])) && is_array($v)) {
682  $v = array_merge($p[$k], $v); // overwrite entry with the same name
683  }
684 
685  $p[$k] = $v;
686  $_SESSION[$sid . '-' . $uid] = json_encode($p);
687  return true;
688  }
$uid
$_COOKIE['oldid']
Definition: adm_login.php:95
$p
Definition: bro_editor.php:50
$_SESSION['PMA_single_signon_password']
Definition: sql_pma_sso.php:37
m_mem::set_help_param (   $show)

Modifie le parametre d'aide en ligne (1/0)

Parameters
integer$showFaut-il (1) ou non (0) afficher l'aide en ligne

Definition at line 580 of file m_mem.php.

References $cuid, $db, and $err.

580  {
581  global $db, $err, $cuid;
582  $err->log("mem", "set_help_param", $show);
583  $db->query("UPDATE membres SET show_help= ? WHERE uid= ? ;", array($show, $cuid));
584  }
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_mem::setid (   $id)

Start a session as another user from an administrator account.

This function is not the same as su. setid connect the current user in the destination account (for good), and su allow any user to become another account for some commands only. (del_user, add_user ...) and allow to bring back admin rights with unsu

Parameters
$idinteger User id where we will connect to.
Returns
boolean TRUE if the user has been successfully connected, FALSE else.

Definition at line 181 of file m_mem.php.

References $_REQUEST, $cuid, $db, $err, $id, and get_remote_ip().

181  {
182  global $db, $err, $cuid, $mysql, $quota;
183  $err->log("mem", "setid", $id);
184  $db->query("select * from membres where uid= ? ;", array($id));
185  if ($db->num_rows() == 0) {
186  $err->raise("mem", _("User or password incorrect"));
187  return false;
188  }
189  $db->next_record();
190  $this->user = $db->Record;
191  $cuid = $db->f("uid");
192  // And recreate the $db->dbus
193  $mysql->reload_dbus();
194 
195  $ip = get_remote_ip();
196  $sess = md5(mt_rand().mt_rand().mt_rand());
197  $_REQUEST["session"] = $sess;
198  $db->query("insert into sessions (sid,ip,uid) values (?, ?, ?);", array($sess, $ip, $cuid));
199  setcookie("session", $sess, 0, "/");
200  $err->error = 0;
201  /* Fill in $local */
202  $db->query("SELECT * FROM local WHERE uid= ? ;", array($cuid));
203  if ($db->num_rows()) {
204  $db->next_record();
205  $this->local = $db->Record;
206  }
207  $quota->getquota('', true);
208  return true;
209  }
if(!$error||!trim($error,"<br />")) $_REQUEST["domain_id"]
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
if(!isset($is_include)) if(!$key &&!$crt) $id
get_remote_ip()
Return the remote IP.
Definition: functions.php:133
m_mem::show_help (   $file,
  $force = false 
)

Affiche (echo) l'aide contextuelle.

Parameters
integer$fileNumero de fichier d'aide a afficher.
Returns
boolean TRUE si l'aide contextuelle a ete trouvee, FALSE sinon

Definition at line 601 of file m_mem.php.

References $force.

601  {
602  if ($this->user["show_help"] || $force) {
603  $hlp = _("hlp_$file");
604  if ($hlp != "hlp_$file") {
605  $hlp = preg_replace(
606  "#HELPID_([0-9]*)#", "<a href=\"javascript:help(\\1);\"><img src=\"/aide/help.png\" width=\"17\" height=\"17\" style=\"vertical-align: middle;\" alt=\"" . _("Help") . "\" /></a>", $hlp);
607  echo "<p class=\"hlp\">" . $hlp . "</p>";
608  return true;
609  }
610  return false;
611  } else {
612  return true;
613  }
614  }
m_mem::su (   $uid)

Change l'identite d'un utilisateur temporairement.

Parameters
globalstring $uid Utilisateur dont on prends l'identite
Returns
TRUE si la session est correcte, FALSE sinon.

Definition at line 314 of file m_mem.php.

References $cuid, $db, $err, and $uid.

Referenced by unsu().

314  {
315  global $cuid, $db, $err, $mysql;
316  if (!$this->olduid) {
317  $this->olduid = $cuid;
318  }
319  $db->query("select * from membres where uid= ? ;", array($uid));
320  if ($db->num_rows() == 0) {
321  $err->raise("mem", _("User or password incorrect"));
322  return false;
323  }
324  $db->next_record();
325  $this->user = $db->Record;
326  $cuid = $db->f("uid");
327 
328  // And recreate the $db->dbus
329  $mysql->reload_dbus();
330  return true;
331  }
$uid
global $db
Definition: bootstrap.php:22
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
m_mem::unsu ( )

Retourne a l'identite d'origine de l'utilisateur apres su.

Returns
boolean TRUE si la session est correcte, FALSE sinon.

Definition at line 338 of file m_mem.php.

References su().

338  {
339  global $mysql;
340  if (!$this->olduid) {
341  return false;
342  }
343  $this->su($this->olduid);
344  $this->olduid = 0;
345  // And recreate the $db->dbus
346  $mysql->reload_dbus();
347  return true;
348  }
su($uid)
Change l'identite d'un utilisateur temporairement.
Definition: m_mem.php:314

Member Data Documentation

m_mem::$local

Tableau contenant les champs de la table "local" du membre courant Ce tableau est utilisable globalement par toutes les classes filles.

Note : les champs de "local" sont specifiques a l'hebergeur.

Definition at line 47 of file m_mem.php.

m_mem::$olduid = 0

Original uid for the temporary uid swapping (for administrators)

Definition at line 36 of file m_mem.php.

m_mem::$user

This array contains the Tableau contenant les champs de la table "membres" du membre courant Ce tableau est utilisable globalement par toutes les classes filles.

Definition at line 41 of file m_mem.php.

Referenced by alternc_export_conf(), and del_session().


The documentation for this class was generated from the following file: