X-Git-Url: https://git.llucax.com/z.facultad/75.43/tp1.git/blobdiff_plain/a148fa868c1bbf6e3f16130f019cd2e49e18cc8f..3eb3afc220c0dfafe0f06657373009228fd92a9f:/src/lib/file.users.php?ds=sidebyside diff --git a/src/lib/file.users.php b/src/lib/file.users.php index d874638..7e010d6 100644 --- a/src/lib/file.users.php +++ b/src/lib/file.users.php @@ -17,11 +17,7 @@ require_once 'lib/file.php'; */ 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'); } /** @@ -31,18 +27,7 @@ function file_users_get_all() */ 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); } /** @@ -52,11 +37,7 @@ function file_users_get($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