]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - scripts/registeruser.php
Make attachment fit better in notice: drop text and link
[quix0rs-gnu-social.git] / scripts / registeruser.php
old mode 100644 (file)
new mode 100755 (executable)
index 8aab325..b90f361
@@ -18,7 +18,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+define('INSTALLDIR', dirname(__DIR__));
+define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
 
 $shortoptions = 'n:w:f:e:';
 $longoptions = array('nickname=', 'password=', 'fullname=', 'email=');
@@ -49,7 +50,7 @@ if (empty($nickname) || empty($password)) {
 
 try {
 
-    $user = User::staticGet('nickname', $nickname);
+    $user = User::getKV('nickname', $nickname);
 
     if (!empty($user)) {
         throw new Exception("A user named '$nickname' already exists.");
@@ -60,7 +61,7 @@ try {
                                  'fullname' => $fullname));
 
     if (empty($user)) {
-        throw new Exception("Cannot register user '$nickname' with password '$password' and fullname '$fullname'.");
+        throw new Exception("Can't register user '$nickname' with password '$password' and fullname '$fullname'.");
     }
 
     if (!empty($email)) {
@@ -69,10 +70,8 @@ try {
 
         $user->email = $email;
 
-        if (!$user->updateKeys($orig)) {
-            print "Failed!\n";
-            throw new Exception("Cannot update email address.");
-        }
+        // Throws exception on failure.
+        $user->updateWithKeys($orig);
     }
 
 } catch (Exception $e) {