aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authormarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-09-24 14:27:18 +0000
committermarcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-09-24 14:27:18 +0000
commit6acda82bb3c881f9b44e6236912aefe8cc68543f (patch)
tree3b72ea9d797123d970a9b33d08ad648aedc97457 /engine
parent40108e73df02d828d85cf4c90202277e400f550b (diff)
downloadelgg-6acda82bb3c881f9b44e6236912aefe8cc68543f.tar.gz
elgg-6acda82bb3c881f9b44e6236912aefe8cc68543f.tar.bz2
Added create_api_user
git-svn-id: https://code.elgg.org/elgg/trunk@2112 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/api.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/engine/lib/api.php b/engine/lib/api.php
index ac4e5edbd..04a1a971f 100644
--- a/engine/lib/api.php
+++ b/engine/lib/api.php
@@ -681,6 +681,26 @@
}
/**
+ * Generate a new API user for a site, returning a new keypair on success.
+ *
+ * @param int $site_guid The GUID of the site.
+ */
+ function create_api_user($site_guid)
+ {
+ global $CONFIG;
+
+ $site_guid = (int)$site_guid;
+
+ $public = sha1(rand().$site_guid.microtime());
+ $secret = sha1(rand().$site_guid.microtime().$public);
+
+ if (insert_data("INSERT into {$CONFIG->dbprefix}api_users (site_guid, api_key, secret) values ($site_guid, '$public', '$private')"))
+ return get_api_user($site_guid, $public);
+
+ return false;
+ }
+
+ /**
* This function looks at the super-global variable $_SERVER and extracts the various
* header variables needed to pass to the validation functions after performing basic validation.
*