From 5611ba16b9bf3ccc8e0cf40e3d22b5b1967e5862 Mon Sep 17 00:00:00 2001 From: Arctic Code Date: Wed, 24 Jul 2013 20:41:13 -0500 Subject: [PATCH] Add register new API user Remove addslashes for name cleaning - That's something that should be done at the endpoint Coder's Note: Sometimes I wish it was easier to write commit messages from the commandline... Now I have a messy commit history x.x --- api.backend.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api.backend.php b/api.backend.php index 19e00c4..b4adafe 100644 --- a/api.backend.php +++ b/api.backend.php @@ -15,6 +15,18 @@ function checkRemoteFile($link){ endif; } +function genApiKey(){ // Randomly generate a new api key or something + $time = mt_rand(17, 33); + $key = substr(number_format(time() * mt_rand(),0,'',''),0,10); + $key = base_convert($key, 10, 36); + for($i=0, $i<$time, $i++){ + $key .= substr(number_format(time() * mt_rand(),0,'',''),0,10); + $key = base_convert($key, 10, 36); + } + $key = hash("sha256", $key); + return $key; +} + include('hashpass.php'); class api{ @@ -278,7 +290,6 @@ class api{ } return "Registered $username."; } -<<<<<<< HEAD function regAPI($apidb, $apikey, $name, $email, $perms){ $apisql = "SELECT * FROM `users` WHERE `key` = '$apikey' LIMIT 1;"; @@ -318,8 +329,6 @@ class api{ if(!$result = $apidb->query($apisql)) return 'ERROR: ['.$apidb->error.']'; return "Registered $name for API use. Key: $key"; } -======= ->>>>>>> parent of 6d43aa8... Add register new API user\n\nRemove addslashes for name cleaning\n - That's something that should be done at the endpoint } ?> \ No newline at end of file