CLEANUP: moved register.php to the include directory
authorArun Persaud <arun@nubati.net>
Sat, 26 Apr 2008 20:16:24 +0000 (13:16 -0700)
committerArun Persaud <arun@nubati.net>
Sat, 26 Apr 2008 20:16:24 +0000 (13:16 -0700)
new users are now also automatically logged in.

Signed-off-by: Arun Persaud <arun@nubati.net>
include/output.php
include/register.php [moved from register.php with 73% similarity]
index.php

index b22b6efd577f4304882da686fb3d8fe9bcac4ad7..4f4a5b6ff3c493053b4e8a61338c19ab8995a320 100644 (file)
@@ -275,7 +275,7 @@ function output_home_page($pre,$game,$done,$avgtime)
     echo "$done games have been completed on this server. Average time of a game: $avgtime days</p>";
 ?>
 
-    <p> Please <a href="./register.php">register</a>, in case you have not done that yet  <br />
+    <p> Please <a href="index.php?action=register">register</a>, in case you have not done that yet  <br />
         or login with you email-address or name and password here:
     </p>
         <form action="index.php?action=login" method="post">
similarity index 73%
rename from register.php
rename to include/register.php
index 9f4cf0e49690c383dbc55d352ca3c03b91440e81..88b13a235e967ffc64992d81b749702444707d5c 100644 (file)
@@ -1,25 +1,9 @@
 <?php
-error_reporting(E_ALL);
-
-include_once("config.php");      
-include_once("./include/output.php");      /* html output only */
-include_once("./include/db.php");          /* database only */
-include_once("./include/functions.php");   /* the rest */
-
-config_check();
-
-if(DB_open()<0)
-  {
-    output_header();
-    echo "Database error, can't connect... Please wait a while and try again. ".
-      "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
-    output_footer(); 
-    exit(); 
-  }
-
-
-/* done major error checking, output header of HTML page */
-output_header();
+/* make sure that we are not called from outside the scripts, 
+ * use a variable defined in config.php to check this
+ */
+if(!isset($HOST))
+  exit;
 
 /* new user wants to register */
 if(myisset("Rfullname","Remail","Rpassword","Rtimezone") )
@@ -44,8 +28,16 @@ if(myisset("Rfullname","Remail","Rpassword","Rtimezone") )
                       ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)"); 
        
        if($r)
-         echo " Welcome to e-DoKo, you are now registered, please visit the".
-           " <a href=\"".$HOST.$INDEX."\">homepage</a> to continue.";
+         {
+           /* Set session, so that new user doesn't need to log in */
+           $myname = DB_get_name('email',$_REQUEST['Remail']);
+           $_SESSION["name"] = $myname;
+           
+           echo "myname $myname --";
+           
+           echo " Welcome to e-DoKo, you are now registered, please visit the".
+             " <a href=\"".$HOST.$INDEX."\">homepage</a> to continue.";
+         }
        else
          echo " something went wrong, couldn't add you to the database, please contact $ADMIN_NAME at $ADMIN_EMAIL.";
       }
@@ -55,7 +47,7 @@ if(myisset("Rfullname","Remail","Rpassword","Rtimezone") )
    {
      echo "IMPORTANT: passwords are going over the net as clear text, so pick an easy password. No need to pick anything complicated here ;)<br /><br />";
      ?>
-        <form action="register.php" method="post">
+        <form action="index.php?action=register" method="post">
           <fieldset>
             <legend>Register</legend>
              <table>
@@ -87,14 +79,5 @@ if(myisset("Rfullname","Remail","Rpassword","Rtimezone") )
 <?php
    }
 
-output_footer();
 
-DB_close();
-
-/*
- *Local Variables: 
- *mode: php
- *mode: hs-minor
- *End:
- */
-?>
+?>
\ No newline at end of file
index 31c497a74515f7e3ef7c4d89f6786f67cf69f17b..d1d2926f15271ab80566a4d252ee86c20317ac36 100644 (file)
--- a/index.php
+++ b/index.php
@@ -57,6 +57,9 @@ switch($action)
     require './include/login.php'; 
     require './include/user.php';
     break;
+  case 'register':
+    require './include/register.php';
+    break;
   case 'game':
     require './include/game.php';
     break;