| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
class m_mem { |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
var $olduid=0; |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
* Ce tableau est utilisable globalement par toutes les classes filles. |
|---|
| 38 |
*/ |
|---|
| 39 |
var $user; |
|---|
| 40 |
|
|---|
| 41 |
* Ce tableau est utilisable globalement par toutes les classes filles. |
|---|
| 42 |
* Note : les champs de "local" sont spécifiques à l'hébergeur. |
|---|
| 43 |
*/ |
|---|
| 44 |
var $local; |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
/** |
|---|
| 48 |
* Constructeur |
|---|
| 49 |
*/ |
|---|
| 50 |
function m_mem() { |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
/** Check that the current user is an admnistrator. |
|---|
| 55 |
* @return boolean TRUE if we are super user, or FALSE if we are not. |
|---|
| 56 |
*/ |
|---|
| 57 |
function checkright() { |
|---|
| 58 |
return ($this->user["su"]=="1"); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
/** Start a session in the web desktop. Check username and password. |
|---|
| 63 |
* <b>Note : </b>If the user entered a bas password, the failure will be logged |
|---|
| 64 |
* and told to the corresponding user on next successfull login. |
|---|
| 65 |
* @param $username string Username that want to get connected. |
|---|
| 66 |
* @param $password string User Password. |
|---|
| 67 |
* @return boolean TRUE if the user has been successfully connected, or FALSE if an error occured. |
|---|
| 68 |
*/ |
|---|
| 69 |
function login($username,$password,$restrictip=0) { |
|---|
| 70 |
global $db,$session,$err,$cuid; |
|---|
| 71 |
$err->log("mem","login",$username); |
|---|
| 72 |
|
|---|
| 73 |
// $password=addslashes($password); |
|---|
| 74 |
$db->query("select * from membres where login='$username';"); |
|---|
| 75 |
if ($db->num_rows()==0) { |
|---|
| 76 |
$err->raise("mem",1); |
|---|
| 77 |
return false; |
|---|
| 78 |
} |
|---|
| 79 |
$db->next_record(); |
|---|
| 80 |
if (_md5cr($password,$db->f("pass"))!=$db->f("pass")) { |
|---|
| 81 |
$db->query("UPDATE membres SET lastfail=lastfail+1 WHERE uid='".$db->f("uid")."';"); |
|---|
| 82 |
$err->raise("mem",1); |
|---|
| 83 |
return false; |
|---|
| 84 |
} |
|---|
| 85 |
if (!$db->f("enabled")) { |
|---|
| 86 |
$err->raise("mem",2); |
|---|
| 87 |
return false; |
|---|
| 88 |
} |
|---|
| 89 |
$this->user=$db->Record; |
|---|
| 90 |
$cuid=$db->f("uid"); |
|---|
| 91 |
if ($restrictip) { |
|---|
| 92 |
$ip="INET_ATON('".getenv("REMOTE_ADDR")."')"; |
|---|
| 93 |
} else $ip="0"; |
|---|
| 94 |
|
|---|
| 95 |
$db->query("DELETE FROM sessions WHERE DATE_ADD(ts,INTERVAL 2 DAY)<NOW();"); |
|---|
| 96 |
|
|---|
| 97 |
$session=md5(uniqid(mt_rand())); |
|---|
| 98 |
$db->query("insert into sessions (sid,ip,uid) values ('$session',$ip,'$cuid');"); |
|---|
| 99 |
setcookie("session",$session,0,"/"); |
|---|
| 100 |
$err->error=0; |
|---|
| 101 |
|
|---|
| 102 |
$db->query("SELECT * FROM local WHERE uid='$cuid';"); |
|---|
| 103 |
if ($db->num_rows()) { |
|---|
| 104 |
$db->next_record(); |
|---|
| 105 |
$this->local=$db->Record; |
|---|
| 106 |
} |
|---|
| 107 |
return true; |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
/** Start a session as another user from an administrator account. |
|---|
| 112 |
* This function is not the same as su. setid connect the current user in the destination |
|---|
| 113 |
* account (for good), and su allow any user to become another account for some commands only. |
|---|
| 114 |
* (del_user, add_user ...) and allow to bring back admin rights with unsu |
|---|
| 115 |
* |
|---|
| 116 |
* @param $id integer User id where we will connect to. |
|---|
| 117 |
* @return boolean TRUE if the user has been successfully connected, FALSE else. |
|---|
| 118 |
*/ |
|---|
| 119 |
function setid($id) { |
|---|
| 120 |
global $db,$session,$err,$cuid; |
|---|
| 121 |
$err->log("mem","setid",$username); |
|---|
| 122 |
$db->query("select * from membres where uid='$id';"); |
|---|
| 123 |
if ($db->num_rows()==0) { |
|---|
| 124 |
$err->raise("mem",1); |
|---|
| 125 |
return false; |
|---|
| 126 |
} |
|---|
| 127 |
$db->next_record(); |
|---|
| 128 |
$this->user=$db->Record; |
|---|
| 129 |
$cuid=$db->f("uid"); |
|---|
| 130 |
$ip=getenv("REMOTE_ADDR"); |
|---|
| 131 |
$session=md5(uniqid(mt_rand())); |
|---|
| 132 |
$db->query("insert into sessions (sid,ip,uid) values ('$session',INET_ATON('$ip'),'$cuid');"); |
|---|
| 133 |
setcookie("session",$session,0,"/"); |
|---|
| 134 |
$err->error=0; |
|---|
| 135 |
|
|---|
| 136 |
$db->query("SELECT * FROM local WHERE uid='$cuid';"); |
|---|
| 137 |
if ($db->num_rows()) { |
|---|
| 138 |
$db->next_record(); |
|---|
| 139 |
$this->local=$db->Record; |
|---|
| 140 |
} |
|---|
| 141 |
return true; |
|---|
| 142 |
} |
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
/** Suite à la connexion de l'utilisateur, réinitialise ses paramètres de dernière connexion |
|---|
| 146 |
*/ |
|---|
| 147 |
function resetlast() { |
|---|
| 148 |
global $db,$cuid; |
|---|
| 149 |
$ip=addslashes(getenv("REMOTE_HOST")); |
|---|
| 150 |
if (!$ip) $ip=addslashes(getenv("REMOTE_ADDR")); |
|---|
| 151 |
$db->query("UPDATE membres SET lastlogin=NOW(), lastfail=0, lastip='$ip' WHERE uid='$cuid';"); |
|---|
| 152 |
} |
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 |
/** Vérifie que la session courante est correcte (cookie ok et ip valide). |
|---|
| 156 |
* Si besoin, et si réception des champs username & password, crée une nouvelle |
|---|
| 157 |
* session pour l'utilisateur annoncé. |
|---|
| 158 |
* Cette fonction doit être appellée à chaque page devant être authentifiée. |
|---|
| 159 |
* et AVANT d'émettre des données. (un cookie peut être envoyé) |
|---|
| 160 |
* @global string $session Le cookie de session eventuel |
|---|
| 161 |
* @global string $username/password le login/pass de l'utilisateur |
|---|
| 162 |
* @return TRUE si la session est correcte, FALSE sinon. |
|---|
| 163 |
*/ |
|---|
| 164 |
function checkid() { |
|---|
| 165 |
global $db,$err,$session,$username,$password,$cuid,$restrictip; |
|---|
| 166 |
if ($username && $password) { |
|---|
| 167 |
return $this->login($username,$password,$restrictip); |
|---|
| 168 |
} |
|---|
| 169 |
$session=addslashes($session); |
|---|
| 170 |
if (strlen($session)!=32) { |
|---|
| 171 |
$err->raise("mem",3); |
|---|
| 172 |
return false; |
|---|
| 173 |
} |
|---|
| 174 |
$ip=getenv("REMOTE_ADDR"); |
|---|
| 175 |
$db->query("select uid,INET_ATON('$ip') as me,ip from sessions where sid='$session'"); |
|---|
| 176 |
if ($db->num_rows()==0) { |
|---|
| 177 |
$err->raise("mem",4); |
|---|
| 178 |
return false; |
|---|
| 179 |
} |
|---|
| 180 |
$db->next_record(); |
|---|
| 181 |
if ($db->f("ip")) { |
|---|
| 182 |
if ($db->f("me")!=$db->f("ip")) { |
|---|
| 183 |
$err->raise("mem",5); |
|---|
| 184 |
return false; |
|---|
| 185 |
} |
|---|
| 186 |
} |
|---|
| 187 |
$cuid=$db->f("uid"); |
|---|
| 188 |
$db->query("select * from membres where uid='$cuid';"); |
|---|
| 189 |
$db->next_record(); |
|---|
| 190 |
$this->user=$db->Record; |
|---|
| 191 |
$err->error=0; |
|---|
| 192 |
|
|---|
| 193 |
$db->query("SELECT * FROM local WHERE uid='$cuid';"); |
|---|
| 194 |
if ($db->num_rows()) { |
|---|
| 195 |
$db->next_record(); |
|---|
| 196 |
$this->local=$db->Record; |
|---|
| 197 |
} |
|---|
| 198 |
return true; |
|---|
| 199 |
} |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
/** Change l'identité d'un utilisateur temporairement. |
|---|
| 203 |
* @global string $uid Utilisateur dont on prends l'identité |
|---|
| 204 |
* @return TRUE si la session est correcte, FALSE sinon. |
|---|
| 205 |
*/ |
|---|
| 206 |
function su($uid) { |
|---|
| 207 |
global $cuid,$db,$err; |
|---|
| 208 |
if (!$this->olduid) |
|---|
| 209 |
$this->olduid=$cuid; |
|---|
| 210 |
$db->query("select * from membres where uid='$uid';"); |
|---|
| 211 |
if ($db->num_rows()==0) { |
|---|
| 212 |
$err->raise("mem",1); |
|---|
| 213 |
return false; |
|---|
| 214 |
} |
|---|
| 215 |
$db->next_record(); |
|---|
| 216 |
$this->user=$db->Record; |
|---|
| 217 |
$cuid=$db->f("uid"); |
|---|
| 218 |
return true; |
|---|
| 219 |
} |
|---|
| 220 |
|
|---|
| 221 |
|
|---|
| 222 |
/** Retourne a l'identite d'origine de l'utilisateur apres su. |
|---|
| 223 |
* @return TRUE si la session est correcte, FALSE sinon. |
|---|
| 224 |
*/ |
|---|
| 225 |
function unsu() { |
|---|
| 226 |
global $cuid; |
|---|
| 227 |
if (!$this->olduid) |
|---|
| 228 |
return false; |
|---|
| 229 |
$this->su($this->olduid); |
|---|
| 230 |
$this->olduid=0; |
|---|
| 231 |
return true; |
|---|
| 232 |
} |
|---|
| 233 |
|
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 |
/** Termine une session du bureau virtuel (logout) |
|---|
| 237 |
* @return boolean TRUE si la session a bien été détruite, FALSE sinon. |
|---|
| 238 |
*/ |
|---|
| 239 |
function del_session() { |
|---|
| 240 |
global $db,$session,$user,$err,$cuid; |
|---|
| 241 |
$err->log("mem","del_session"); |
|---|
| 242 |
$session=addslashes($session); |
|---|
| 243 |
setcookie("session","",0,"/"); |
|---|
| 244 |
if ($session=="") { |
|---|
| 245 |
$err->error=0; |
|---|
| 246 |
return true; |
|---|
| 247 |
} |
|---|
| 248 |
if (strlen($session)!=32) { |
|---|
| 249 |
$err->raise("mem",3); |
|---|
| 250 |
return false; |
|---|
| 251 |
} |
|---|
| 252 |
$ip=getenv("REMOTE_ADDR"); |
|---|
| 253 |
$db->query("select uid,INET_ATON('$ip') as me,ip from sessions where sid='$session'"); |
|---|
| 254 |
if ($db->num_rows()==0) { |
|---|
| 255 |
$err->raise("mem",4); |
|---|
| 256 |
return false; |
|---|
| 257 |
} |
|---|
| 258 |
$db->next_record(); |
|---|
| 259 |
if ($db->f("me")!=$db->f("ip")) { |
|---|
| 260 |
$err->raise("mem",5); |
|---|
| 261 |
return false; |
|---|
| 262 |
} |
|---|
| 263 |
$cuid=$db->f("uid"); |
|---|
| 264 |
$db->query("delete from sessions where sid='$session';"); |
|---|
| 265 |
$err->error=0; |
|---|
| 266 |
return true; |
|---|
| 267 |
} |
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
/** Change le mot de passe de l'utilisateur courant. |
|---|
| 271 |
* @param string $oldpass Ancien mot de passe. |
|---|
| 272 |
* @param string $newpass Nouveau mot de passe |
|---|
| 273 |
* @param string $newpass2 Nouveau mot de passe (à nouveau) |
|---|
| 274 |
* @return boolean TRUE si le mot de passe a été changé, FALSE sinon. |
|---|
| 275 |
*/ |
|---|
| 276 |
function passwd($oldpass,$newpass,$newpass2) { |
|---|
| 277 |
global $db,$err,$cuid; |
|---|
| 278 |
$err->log("mem","passwd"); |
|---|
| 279 |
$oldpass=stripslashes($oldpass); |
|---|
| 280 |
$newpass=stripslashes($newpass); |
|---|
| 281 |
$newpass2=stripslashes($newpass2); |
|---|
| 282 |
if (!$this->user["canpass"]) { |
|---|
| 283 |
$err->raise("mem",11); |
|---|
| 284 |
return false; |
|---|
| 285 |
} |
|---|
| 286 |
if ($this->user["pass"]!=_md5cr($oldpass,$this->user["pass"])) { |
|---|
| 287 |
$err->raise("mem",6); |
|---|
| 288 |
return false; |
|---|
| 289 |
} |
|---|
| 290 |
if ($newpass!=$newpass2) { |
|---|
| 291 |
$err->raise("mem",7); |
|---|
| 292 |
return false; |
|---|
| 293 |
} |
|---|
| 294 |
if (strlen($newpass)<3) { |
|---|
| 295 |
$err->raise("mem",8); |
|---|
| 296 |
return false; |
|---|
| 297 |
} |
|---|
| 298 |
$newpass=_md5cr($newpass); |
|---|
| 299 |
$db->query("UPDATE membres SET pass='$newpass' WHERE uid='$cuid';"); |
|---|
| 300 |
$err->error=0; |
|---|
| 301 |
return true; |
|---|
| 302 |
} |
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
/** Change les préférences administrateur d'un compte |
|---|
| 306 |
* @param integer $admlist Mode de visualisation des membres (0=large 1=courte) |
|---|
| 307 |
* @return boolean TRUE si les préférences ont été changées, FALSE sinon. |
|---|
| 308 |
*/ |
|---|
| 309 |
function adminpref($admlist) { |
|---|
| 310 |
global $db,$err,$cuid; |
|---|
| 311 |
$err->log("mem","admlist"); |
|---|
| 312 |
if (!$this->user["su"]) { |
|---|
| 313 |
$err->raise("mem",12); |
|---|
| 314 |
return false; |
|---|
| 315 |
} |
|---|
| 316 |
$db->query("UPDATE membres SET admlist='$admlist' WHERE uid='$cuid';"); |
|---|
| 317 |
$err->error=0; |
|---|
| 318 |
return true; |
|---|
| 319 |
} |
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 |
/** Envoie en mail le mot de passe d'un compte. |
|---|
| 323 |
* <b>Note : </b>On ne peut demander le mot de passe qu'une seule fois par jour. |
|---|
| 324 |
* TODO : Translate this mail into the localization program. |
|---|
| 325 |
* TODO : Check this function's ! |
|---|
| 326 |
* @return boolean TRUE si le mot de passe a été envoyé avec succès, FALSE sinon. |
|---|
| 327 |
*/ |
|---|
| 328 |
function send_pass($login) { |
|---|
| 329 |
global $err,$db,$L_HOSTING,$L_FQDN; |
|---|
| 330 |
$err->log("mem","send_pass"); |
|---|
| 331 |
$db->query("SELECT * FROM membres WHERE login='$login';"); |
|---|
| 332 |
if (!$db->num_rows()) { |
|---|
| 333 |
$err->raise("mem",2); |
|---|
| 334 |
return false; |
|---|
| 335 |
} |
|---|
| 336 |
$db->next_record(); |
|---|
| 337 |
if (time()-$db->f("lastaskpass")<86400) { |
|---|
| 338 |
$err->raise("mem",7); |
|---|
| 339 |
return false; |
|---|
| 340 |
} |
|---|
| 341 |
$txt="Bonjour, |
|---|
| 342 |
Il semblerait que vous ayez demandé à recevoir le mot de passe du |
|---|
| 343 |
compte ".$login." sur $L_HOSTING |
|---|
| 344 |
Voici donc le nom d'utilisateur et le mot de passe qui vous |
|---|
| 345 |
permettront de rentrer sur le bureau virtuel : |
|---|
| 346 |
|
|---|
| 347 |
-------------------------------------- |
|---|
| 348 |
|
|---|
| 349 |
Nom d'utilisateur : ".$db->f("login")." |
|---|
| 350 |
|
|---|
| 351 |
Mot de passe : ".$db->f("pass")." |
|---|
| 352 |
|
|---|
| 353 |
-------------------------------------- |
|---|
| 354 |
|
|---|
| 355 |
Note : si vous n'avez pas fait cette demande, cela signifie que |
|---|
| 356 |
quelqu'un l'a faite pour vous. Vous pouvez donc ignorer ce message. |
|---|
| 357 |
Si cela se reproduit, n'hésitez pas à contacter l'administrateur |
|---|
| 358 |
de votre serveur. |
|---|
| 359 |
|
|---|
| 360 |
Cordialement. |
|---|
| 361 |
"; |
|---|
| 362 |
mail($db->f("mail"),"Votre mot de passe sur $L_HOSTING",$txt,"From: postmaster@$L_FQDN\nReply-to: postmaster@$L_FQDN"); |
|---|
| 363 |
$db->query("UPDATE membres SET lastaskpass=".time()." WHERE login='$login';"); |
|---|
| 364 |
return true; |
|---|
| 365 |
} |
|---|
| 366 |
|
|---|
| 367 |
|
|---|
| 368 |
/** Change le mail d'un membre (première etape, envoi du CookiE) |
|---|
| 369 |
* TODO : insert this mail string into the localization system |
|---|
| 370 |
* @param string $newmail Nouveau mail souhaité pour le membre. |
|---|
| 371 |
* @return string le cookie si le mail a bien été envoyé, FALSE sinon |
|---|
| 372 |
*/ |
|---|
| 373 |
function ChangeMail1($newmail) { |
|---|
| 374 |
global $err,$db,$L_HOSTING,$L_FQDN,$cuid; |
|---|
| 375 |
$err->log("mem","changemail1",$newmail); |
|---|
| 376 |
$db->query("SELECT * FROM membres WHERE uid='$cuid';"); |
|---|
| 377 |
if (!$db->num_rows()) { |
|---|
| 378 |
$err->raise("mem",2); |
|---|
| 379 |
return false; |
|---|
| 380 |
} |
|---|
| 381 |
$db->next_record(); |
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
$COOKIE=substr(md5(uniqid(rand(),1)),0,20); |
|---|
| 385 |
|
|---|
| 386 |
$KEY=substr(md5(uniqid(rand(),1)),0,6); |
|---|
| 387 |
|
|---|
| 388 |
$txt="Bonjour, |
|---|
| 389 |
Quelqu'un (peut-etre vous) a demandé le changement de l'email du compte |
|---|
| 390 |
".$db->f("login")." sur $L_HOSTING |
|---|
| 391 |
Afin de confirmer que cet email est valide, merci de vous rendre à l'adresse |
|---|
| 392 |
ci-dessous : |
|---|
| 393 |
|
|---|
| 394 |
https://$L_FQDN/admin/mem_cm.php?usr=$cuid&cookie=$COOKIE |
|---|
| 395 |
|
|---|
| 396 |
(attention : si cette adresse est coupée sur 2 lignes, ne pas oublier de |
|---|
| 397 |
reconstituer sur une seule ligne). Le bureau vous demandera la clé qui vous |
|---|
| 398 |
a été donnée lors de la demande de changement d'email. |
|---|
| 399 |
|
|---|
| 400 |
Note : si vous n'avez pas fait cette demande, cela signifie que quelqu'un |
|---|
| 401 |
l'a faite pour vous. Vous pouvez donc ignorer ce message. Si cela se |
|---|
| 402 |
reproduit, n'hésitez pas à contacter l'administrateur de votre serveur. |
|---|
| 403 |
|
|---|
| 404 |
Cordialement. |
|---|
| 405 |
"; |
|---|
| 406 |
mail($newmail,"Changement d'email sur $L_HOSTING",$txt,"From: postmaster@$L_FQDN\nReply-to: postmaster@$L_FQDN"); |
|---|
| 407 |
|
|---|
| 408 |
$db->query("DELETE FROM chgmail WHERE uid='$cuid';"); |
|---|
| 409 |
$db->query("INSERT INTO chgmail (cookie,ckey,uid,mail,ts) VALUES ('$COOKIE','$KEY','$cuid','$newmail',".time().");"); |
|---|
| 410 |
|
|---|
| 411 |
$lts=time()-86400; |
|---|
| 412 |
$db->query("DELETE FROM chgmail WHERE ts<'$lts';"); |
|---|
| 413 |
return $KEY; |
|---|
| 414 |
} |
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 |
/** Change le mail d'un membre (seconde etape, CookiE+clé = application) |
|---|
| 418 |
* @param string $COOKIE Cookie envoyé par mail |
|---|
| 419 |
* @param string $KEY clé affichée à l'écran |
|---|
| 420 |
* @param integer $uid Utilisateur concerné (on est hors session) |
|---|
| 421 |
* @return TRUE si le mail a bien été modifié, FALSE sinon |
|---|
| 422 |
*/ |
|---|
| 423 |
function ChangeMail2($COOKIE,$KEY,$uid) { |
|---|
| 424 |
global $err,$db,$L_HOSTING,$L_FQDN; |
|---|
| 425 |
$err->log("mem","changemail2",$uid); |
|---|
| 426 |
$db->query("SELECT * FROM chgmail WHERE cookie='$COOKIE' and ckey='$KEY' and uid='$uid';"); |
|---|
| 427 |
if (!$db->num_rows()) { |
|---|
| 428 |
$err->raise("mem",9); |
|---|
| 429 |
return false; |
|---|
| 430 |
} |
|---|
| 431 |
$db->next_record(); |
|---|
| 432 |
|
|---|
| 433 |
|
|---|
| 434 |
$db->query("UPDATE membres SET mail='".$db->f("mail")."' WHERE uid='$uid';"); |
|---|
| 435 |
|
|---|
| 436 |
$db->query("DELETE FROM chgmail WHERE uid='$uid';"); |
|---|
| 437 |
|
|---|
| 438 |
$lts=time()-86400; |
|---|
| 439 |
$db->query("DELETE FROM chgmail WHERE ts<'$lts';"); |
|---|
| 440 |
return true; |
|---|
| 441 |
} |
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 |
/** Modifie le paramètre d'aide en ligne (1/0) |
|---|
| 445 |
* @param integer $show Faut-il (1) ou non (0) afficher l'aide en ligne |
|---|
| 446 |
*/ |
|---|
| 447 |
function set_help_param($show) { |
|---|
| 448 |
global $db,$err,$cuid; |
|---|
| 449 |
$err->log("mem","set_help_param",$show); |
|---|
| 450 |
$db->query("UPDATE membres SET show_help='$show' WHERE uid='$cuid';"); |
|---|
| 451 |
} |
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 |
/** Dit si l'aide en ligne est demandée |
|---|
| 455 |
* @return boolean TRUE si l'aide en ligne est demandée, FALSE sinon. |
|---|
| 456 |
*/ |
|---|
| 457 |
function get_help_param() { |
|---|
| 458 |
return $this->user["show_help"]; |
|---|
| 459 |
} |
|---|
| 460 |
|
|---|
| 461 |
|
|---|
| 462 |
/** Affiche (echo) l'aide contextuelle |
|---|
| 463 |
* @param integer $file Numéro de fichier d'aide à afficher. |
|---|
| 464 |
* @return TRUE si l'aide contextuelle a été trouvée, FALSE sinon |
|---|
| 465 |
*/ |
|---|
| 466 |
function show_help($file) { |
|---|
| 467 |
global $err; |
|---|
| 468 |
$err->log("mem","show_help",$show); |
|---|
| 469 |
if ($this->user["show_help"]) { |
|---|
| 470 |
$hlp=_("hlp_$file"); |
|---|
| 471 |
if ($hlp!="hlp_$file") { |
|---|
| 472 |
$hlp=ereg_replace( |
|---|
| 473 |
"HELPID_([0-9]*)", |
|---|
| 474 |
"<a href=\"javascript:help(\\1);\"><img src=\"/admin/aide/help.png\" width=\"17\" height=\"17\" style=\"vertical-align: middle;\" alt=\""._("Help")."\" /></a>",$hlp); |
|---|
| 475 |
echo "<p class=\"hlp\">".$hlp."</p>"; |
|---|
| 476 |
return true; |
|---|
| 477 |
} |
|---|
| 478 |
return false; |
|---|
| 479 |
} else { |
|---|
| 480 |
return true; |
|---|
| 481 |
} |
|---|
| 482 |
} |
|---|
| 483 |
|
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
/** |
|---|
| 487 |
* Exports all the personnal user related information for an account. |
|---|
| 488 |
* @access private |
|---|
| 489 |
* EXPERIMENTAL 'sid' function ;) |
|---|
| 490 |
*/ |
|---|
| 491 |
function alternc_export($tmpdir) { |
|---|
| 492 |
global $db,$err; |
|---|
| 493 |
$err->log("mem","export"); |
|---|
| 494 |
$str="<mem>\n"; |
|---|
| 495 |
|
|---|
| 496 |
foreach ($this->user as $k=>$v) { |
|---|
| 497 |
$str.=" <$k>".xml_entities($v)."</$k>\n"; |
|---|
| 498 |
} |
|---|
| 499 |
$str.="</mem>\n"; |
|---|
| 500 |
return $str; |
|---|
| 501 |
} |
|---|
| 502 |
|
|---|
| 503 |
|
|---|
| 504 |
|
|---|
| 505 |
|
|---|
| 506 |
} |
|---|
| 507 |
|
|---|
| 508 |
?> |
|---|
| 509 |
|
|---|