n/oldblog
Archived
1
0
Fork 0
This repository has been archived on 2024-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
oldblog/modules/include/users.inc.php

50 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2023-04-30 21:28:42 +02:00
<?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;
}
?>