Created
April 3, 2013 11:13
-
-
Save femmerling/5300312 to your computer and use it in GitHub Desktop.
Put this file in your OwnCloud root folder to have a create new user API. All you need to do is have a POST request to <host>/owncloud/owncloudUserCreateHack.php with username and password parameters and your user is created. Remember that this works under SQLite3. Adjust to MySQL or PostgreSQL or whatever engine query you're using.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once '3rdparty/phpass/PasswordHash.php'; | |
class MyDB extends SQLite3 | |
{ | |
function __construct() | |
{ | |
$this->open('data/owncloud.db'); | |
} | |
} | |
$salt = 'put the salt here'; | |
$forcePortable = (CRYPT_BLOWFISH!=1); | |
$hasher = new PasswordHash(8, $forcePortable); | |
$user = $_POST['username']; | |
$pass = $_POST['password']; | |
$hash = $hasher->HashPassword($pass.$salt); | |
$db = new MyDB(); | |
$db->query("INSERT INTO oc_users (uid,displayname,password) VALUES ('$user','$user','$hash')"); | |
echo "User created"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment