Source for file prime-check.php

Documentation is available at prime-check.php

  1. <?php
  2. ################################################################
  3. # This file is part of SlidingDoors #
  4. # Copyright 2001-2005. Eric D. Nielsen, All rights reserverd #
  5. # SlidingDoors is availible for license under the GPL, see #
  6. # the COPYING file in the root directory of the install for #
  7. # the full terms of the GPL. #
  8. # #
  9. # File: prime-check.inc #
  10. # Author: Eric D. Nielsen #
  11. # Description: An interstitial page that handles the form data #
  12. # passed from prime.php. This page will validate #
  13. # the data, check for name collisions, insert the #
  14. # new person into the database and pass the PID #
  15. # to the partners page if all goes well. In case #
  16. # of error it passed control back to prime.php to #
  17. # handle missing/invalid data and to #
  18. # prime-collision.php to handle close matches. #
  19. # Internal Links: prime.php #
  20. # prime-collision.php #
  21. # partners.php #
  22. # External Links: SlidingDoors information page (footer) #
  23. # Comp-in-a-box information page (footer) #
  24. # OpenImpetus information page (footer) #
  25. # Change Log: 6/12/01 -- created -- edn #
  26. # 2/14/02 -- prepped for PrepStep -- edn #
  27. # 7/02/02 -- new validation system -- edn #
  28. # 10/30/04 -- temporalization -- edn #
  29. # 7/03/05 -- Passwords -- edn #
  30. ################################################################
  31.  
  32.  
  33.  
  34. include "include_others.inc";
  35. unset($formVars);
  36.  
  37. $includeEmail = (isset($_POST["ignoreEmail"]) && $_POST["ignoreEmail"]!="on");
  38. if (!$includeEmail)
  39. {
  40. $propagateEnteredEmail=$_POST["Email"];
  41. $_SESSION["propagateEnteredEmail"]=$propagateEnteredEmail;
  42. }
  43. $formVars=array();
  44. $person = new Person($db);
  45.  
  46. $validated = $person->validateInputs($formVars,"PRIME");
  47. if (!$validated)
  48. {
  49. $_SESSION["formVars"]=$formVars;
  50. localRedirect("Location: $baseURL/prime.php"); # Branch Works
  51. exit;
  52. }
  53.  
  54. $person->populateFromFormVars($formVars);
  55. if ($conflicts = $db->personConflicts($person,$includeEmail))
  56. {
  57. if (count($conflicts)!=0)
  58. {
  59. $_SESSION["conflicts"]=$conflicts;
  60. $_SESSION["formVars"]=$formVars;
  61. localRedirect("Location: $baseURL/prime-collision.php"); # Branch works
  62. exit;
  63. }
  64. }
  65.  
  66. if (in_array("Affiliation", $SD_elements))
  67. {
  68. $newAffil = isset($_POST["NewAffil"]) ? $_POST["NewAffil"] : "";
  69. $affilShort = isset($_POST["AffilShort"]) ? $_POST["AffilShort"] : "";
  70. $affilID = isset($_POST["AffilID"]) ? $_POST["AffilID"] : "";
  71. if ($affilID=="" && $affilShort!="")
  72. {
  73. $affiliation = new RegOrg($db);
  74. $affiliation->setName($newAffil);
  75. $affiliation->setOrgPays($SD_default_org_pays);
  76. $affiliation->setAbbrev($affilShort);
  77. $affiliation->postToDB();
  78. $affilID = $affiliation->getID();
  79. if (!$affilID)
  80. {
  81. errorPage($PHP_SELF, "root","Database Inaccessible", "Organization::postToDB unable to access database",TRUE); #TODO, make prettier
  82. exit;
  83. }
  84. }
  85. if ($affilID!=-1)
  86. $person->setAffilID($affilID);
  87. else
  88. $person->setOrgPays(FALSE);
  89. }
  90. $person->postToDB();
  91. $primeID=$person->getID();
  92.  
  93. // NEW Password Section -- Will probably need to be cleaned-up
  94. $email = $formVars["Email"];
  95. $firstname= $formVars["FirstName"];
  96. $lastname=$formVars["LastName"];
  97. $db->startTransaction();
  98. $query = "SELECT DISTINCT password FROM people_passwords NATURAL JOIN
  99. people_contact WHERE emailday='$email';";
  100. $result=$db->query($query);
  101. if ($result->numrows()==0)
  102. {
  103. $newPassword = generatePassword();
  104. $query="INSERT INTO people_passwords (peopleid,password) VALUES ($primeID,'$newPassword');";
  105. $db->query($query);
  106. $body=<<<END_BODY
  107. Somebody, presumably the holder of this email address, just
  108. created an entry $firstname $lastname for the $SD_compname.
  109.  
  110. This entry is protected by the following password:
  111. $newPassword
  112. All subsequent registrations sharing this email address will use the
  113. same password. If you are registering your entire team (often
  114. Captain or Registration Coordinator), you might want to register
  115. for an account on the CompInaBox Server to use the Team Management tools
  116. there. They give a more streamlined registration process and allow you to use
  117. a single password for all competitions.
  118.  
  119. -- CompInaBox Automated Mailor
  120.  
  121. END_BODY; $subject="[CompInaBox] Registration Password";
  122. $to=$email;
  123. $headers="From: auto-mail@$CIB_HOSTNAME{$CIB_DOMAIN}\r\nReply-To: $CIB_SERVER_ADMIN_EMAIL\r\nX-mailer: CompInaBox via PHP";
  124. mail($to,$subject,$body,$headers);
  125. }
  126. else if ($result->numrows()==1)
  127. {
  128. list($newPassword)=$result->getRowAt(0);
  129. $query="INSERT INTO people_passwords (peopleid,password) VALUES ($primeID,'$newPassword');";
  130. $db->query($query);
  131. }
  132. else
  133. {
  134. $db->rollback();
  135. errorPage($PHP_SELF,"root","Password Corruption","Multiple Passwords found for same email. Please Contact the site administrator, $CIB_SERVER_ADMIN_NAME,
  136. $CIB_SERVER_ADMIN_EMAIL immediately.");
  137. exit();
  138. }
  139. $db->commit();
  140. // END NEW Password Section
  141.  
  142.  
  143. if (!$primeID)
  144. {
  145. errorPage($PHP_SELF, "root","Database Inaccessible", "Person::PostToDB unable to access database",TRUE);
  146. exit; #TODO, make prettier
  147. }
  148. $_SESSION["primeID"]=$primeID;
  149. $_SESSION["includeEmail"]=$includeEmail;
  150. localRedirect("Location: $baseURL/partners.php"); #branch works
  151. exit;
  152. ?>

Documentation generated on Tue, 25 Apr 2006 13:07:51 -0400 by phpDocumentor 1.3.0RC3