switch to fixed passwords (based on month/year)
authorJeremy Tan <[email protected]>
Tue, 29 Oct 2013 06:12:29 +0000 (14:12 +0800)
committerJeremy Tan <[email protected]>
Tue, 29 Oct 2013 06:12:29 +0000 (14:12 +0800)
hey, adrian wanted it

testing/MCTXWeb/public_html/users/admin_upload_users.php

index 60b4c27..05ba0c7 100644 (file)
@@ -28,20 +28,20 @@ if (!empty($_POST))
   }
   else if ($_POST['action'] === "Upload") // Upload users in the text area
   {
-\r
-    if ($_POST['upload_mode'] === "purge")\r
-    {\r
-      $to_delete = fetchAllUsersWithoutPerm("Administrator");\r
-      if (count($to_delete) > 0)\r
-      {\r
-        if ($deletion_count = deleteUsers($to_delete)) {\r
-          $successes[] = lang("ACCOUNT_DELETIONS_SUCCESSFUL", array($deletion_count));\r
-        }\r
-        else {\r
-          $errors[] = lang("SQL_ERROR");\r
-        }\r
-      }\r
-    }\r
+
+    if ($_POST['upload_mode'] === "purge")
+    {
+      $to_delete = fetchAllUsersWithoutPerm("Administrator");
+      if (count($to_delete) > 0)
+      {
+        if ($deletion_count = deleteUsers($to_delete)) {
+          $successes[] = lang("ACCOUNT_DELETIONS_SUCCESSFUL", array($deletion_count));
+        }
+        else {
+          $errors[] = lang("SQL_ERROR");
+        }
+      }
+    }
   
     $text_area = $_POST['userUpload'];
 
@@ -53,26 +53,29 @@ if (!empty($_POST))
       if (empty($row) or $row[0] === '#')
         continue;
 
-      $fields = preg_split("/,/",  $row);\r
-      if(count($fields) < 3)\r
-      {\r
-        $errors[] = "Warning: Ignoring row not in correct format: ".htmlspecialchars($row);\r
-        continue;\r
-      }\r
+      $fields = preg_split("/,/",  $row);
+      if(count($fields) < 3)
+      {
+        $errors[] = "Warning: Ignoring row not in correct format: ".htmlspecialchars($row);
+        continue;
+      }
       
       $username = trim($fields[0]);
       $displayname = trim($fields[1]);
-      $email = trim($fields[2]);\r
-      $title = trim($fields[3]);\r
-      \r
-      if(!isValidEmail($email))\r
-      {\r
-        $errors[] = "Enter a valid email for row: ".htmlspecialchars($row);\r
-        continue;\r
-      }\r
+      $email = trim($fields[2]);
+      $title = trim($fields[3]);
+      
+      if(!isValidEmail($email))
+      {
+        $errors[] = "Enter a valid email for row: ".htmlspecialchars($row);
+        continue;
+      }
       
       // generate the temporary password
-      $password = generatePassword();
+      //$password = generatePassword();
+
+      // hey, adrian suggested it
+      $password = "mctx".date("MY");
 
       //Construct a user object
       $user = new User($username,$displayname,$password,$email);
@@ -91,52 +94,54 @@ if (!empty($_POST))
         
         if($user->mail_failure) $localerrors[] = lang("MAIL_ERROR");
         if($user->sql_failure)  $localerrors[] = lang("SQL_ERROR");
-        \r
-        if(strlen($title) >= 50)\r
-        {\r
-          $localerrors[] = "Warning: User".$username." added but failed to set title: ".lang("ACCOUNT_TITLE_CHAR_LIMIT",array(1,50));\r
-        }\r
-        else if (count($localerrors) == 0 && strlen($title) > 0)\r
-        {\r
-          $user_id = fetchUserId($username); //So stupid, when you create a user, it doesn't return the user id\r
-          if (!updateTitle($user_id, $title))\r
-          {\r
-            $localerrors[] = "Warning: User ".$username." added but failed to set title: ". lang("SQL_ERROR");\r
-          }\r
+        
+        if(strlen($title) >= 50)
+        {
+          $localerrors[] = "Warning: User".$username." added but failed to set title: ".lang("ACCOUNT_TITLE_CHAR_LIMIT",array(1,50));
+        }
+        else if (count($localerrors) == 0 && strlen($title) > 0)
+        {
+          $user_id = fetchUserId($username); //So stupid, when you create a user, it doesn't return the user id
+          if (!updateTitle($user_id, $title))
+          {
+            $localerrors[] = "Warning: User ".$username." added but failed to set title: ". lang("SQL_ERROR");
+          }
         }
       }
 
       if(count($localerrors) == 0)
-      {\r
+      {
         $users[] = [$username, $password]; //Push user onto array
                //$successes[] = ($user->success);
-      }\r
-      else\r
-      {\r
-        $errors = array_merge($errors, $localerrors);\r
+      }
+      else
+      {
+        $errors = array_merge($errors, $localerrors);
       }
 
     }
\r
-    if(count($users) > 0)\r
-    {\r
-      $successes[] = (count($users)." users created.");\r
-      $successes[] = ("The list of usernames and passwords follow. You must save this!");\r
-      foreach($users as $user)\r
-      {\r
-        $successes[] = $user[0].",".$user[1];\r
-      }\r
+    if(count($users) > 0)
+    {
+      $successes[] = (count($users)." users created.");
+      $successes[] = "The temporary password is: "."mctx".date("MY");
+      $successes[] = "Please change this as soon as possible.";
+//      $successes[] = ("The list of usernames and passwords follow. You must save this!");
+//      foreach($users as $user)
+//      {
+//        $successes[] = $user[0].",".$user[1];
+//      }
     }
   }
 
 
-}\r
-\r
-require_once("models/header.php");\r
-startPage();\r
-\r
-echo notificationBlock($errors,$successes);\r
-\r
+}
+
+require_once("models/header.php");
+startPage();
+
+echo notificationBlock($errors,$successes);
+
 echo '<div class="widget"><div class="title">Upload users</div>';
 
 if ($show_form)
@@ -164,9 +169,9 @@ if ($show_form)
   <textarea name=\"userUpload\" rows=\"50\" cols=\"100\" style=\"width: 100%\">".$text_area."</textarea> </p>
 
   </form>";
-}\r
-\r
-echo '</div>';\r
+}
+
+echo '</div>';
 finishPage();
   
 ?> 

UCC git Repository :: git.ucc.asn.au