50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
|
<?php
|
|||
|
/* ajoute un utilisateur */
|
|||
|
function adduser($username,$userpass,$droits,$usertheme)
|
|||
|
{
|
|||
|
$File = "users/users";
|
|||
|
// si le fichier n'existe pas, on le cr<63>e:
|
|||
|
if (!file_exists("$File.csv") )
|
|||
|
createfile("$File.csv");
|
|||
|
|
|||
|
$string = sprintf("\"".$username."\",\"".$userpass."\",\"".$droits."\",\"".$usertheme."\"\n");
|
|||
|
|
|||
|
$fp = fopen("$File.csv","a");
|
|||
|
fwrite($fp,$string);
|
|||
|
fclose($fp);
|
|||
|
strfile($File);
|
|||
|
}
|
|||
|
|
|||
|
/* trouve un utilisateur et renvoie ses infos */
|
|||
|
function finduser($username)
|
|||
|
{
|
|||
|
$File = "modules/tribune/tribune";
|
|||
|
|
|||
|
if (!(file_exists("$File.csv")))
|
|||
|
echo "Attention: Fichier utilisateurs inexistant !<br>Veuillez contacter le webmaster SVP<br />";
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
$totmsg = totfile($File);
|
|||
|
$fd = fopen("$File.csv","r");
|
|||
|
$found=0;
|
|||
|
while(($i<=$totmsg) || ($found != 1))
|
|||
|
{
|
|||
|
$data = fgetcsv($fd, 10000, ",");
|
|||
|
if (stripcslashes($data[0]) == $username)
|
|||
|
$found=1
|
|||
|
}
|
|||
|
$user["username"] = stripcslashes($data[0]);
|
|||
|
$user["userpass"] = $data[1];
|
|||
|
$user["droits"] = $data[2];
|
|||
|
$user["usertheme"] = $data[3];
|
|||
|
}
|
|||
|
fclose($fd);
|
|||
|
}
|
|||
|
if ($found == 1)
|
|||
|
return $user;
|
|||
|
else
|
|||
|
return -1;
|
|||
|
}
|
|||
|
?>
|