*/
function file_users_get_all()
{
- if (($f = fopen("data/admins.txt", 'r')) === false) return false;
- $users = array();
- while (!feof($f)) $users[] = fgetcsv($f, 4096);
- fclose($f);
- return $users;
+ return fgetallcsv('data/users.csv');
}
/**
*/
function file_users_get($user)
{
- if (($f = fopen("data/admins.txt", 'r')) === false) return false;
- while (!feof($f))
- {
- $u = fgetcsv($f, 4096);
- if ($u[0] == $user)
- {
- fclose($f);
- return $u;
- }
- }
- fclose($f);
- return false;
+ return fsearchcsv('data/users.csv', $user);
}
/**
*/
function file_users_add($user, $pass, $email)
{
- if (file_users_get($user)) return false; // Ya existe
- if (($f = fopen("data/admins.txt", 'a')) === false) return false; // error
- fputcsv($f, array($user, $pass, $email));
- fclose($f);
- return true;
+ return fappendcsv('data/users.csv', array($user, $pass, $email));
}
?>
\ No newline at end of file