X-Git-Url: https://git.llucax.com/z.facultad/75.43/tp1.git/blobdiff_plain/c80e6612e26340b7542e0ae010e208966dff8d59..0087aa5491d545397b9437790cf2178b511faee1:/src/lib/file.users.php?ds=sidebyside diff --git a/src/lib/file.users.php b/src/lib/file.users.php index 3e1c835..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/users.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/users.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,10 +37,7 @@ function file_users_get($user) */ function file_users_add($user, $pass, $email) { - if (($f = fopen("data/users.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