]> andersk Git - sql-web.git/blobdiff - batch/signup.php
lighttpd remote signups
[sql-web.git] / batch / signup.php
index 1bb7cd86e851ba9f416f094ac97ae5fd6e7491b8..20175b97dfdfc7ac28a242af27095208aeb1447e 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/php -q
 <?php
 
 require_once(dirname(__FILE__).'/../mitsql.cfg.php');
@@ -6,8 +6,17 @@ require_once('mitsql.lib.php');
 
 require_once('batch.inc.php');
 
-$myUsername = $argv[1];
-$myUID = $argv[3];
+if (isset($argv) && count($argv)>=4) {
+    $myUsername = $argv[1];
+    $myUID = $argv[3];
+    if ($myUID<100) exit('bad UID');
+} elseif (defined('SIGNUP_PW') && strlen(SIGNUP_PW) && (isset($_SERVER['HTTP_AUTHORIZATION']) || isset($_SERVER['PHP_AUTH_PW'])) && SIGNUP_PW == $_SERVER['PHP_AUTH_PW']) {
+    $myUsername = $i_u;
+} else {
+    exit;
+}
+
+if (empty($myUsername)) exit('bad User');
 $hescmd = "hesinfo $myUsername passwd";
 $hesinfo = explode(':', trim(exec($hescmd)));
 if (count($hesinfo)>=4) {
@@ -17,9 +26,8 @@ if (count($hesinfo)>=4) {
        $myName = $myUsername;
 }
 $myEmail = $myUsername.'@mit.edu';
-$myPassword = substr(uniqid(),0,7);
-
-if ($myUID<1000) exit('bad UID');
+$myPassword = trim(exec(dirname(__FILE__).'/../bin/nicepass.py'));
+if (empty($myPassword)) exit('bad Password');
 
 $Login = new Login($myUsername);
 if (!$Login->exists() && !empty($myUsername)) {
@@ -29,7 +37,7 @@ if (!$Login->exists() && !empty($myUsername)) {
 if ($Login->canSignup()) {
        $User = new User($Login->getUserId());
        $User->signup($myPassword);
-       die($myPassword);
+       exit($myPassword);
 }
 
 ?>
This page took 0.030134 seconds and 4 git commands to generate.