OCC registration script

2003-12-08
2013-04-06
  • Devon Holcombe
    Devon Holcombe
    2003-12-08

    I have created a registration.php for occ so that users can register themselves, it also stores the passwords encrypted instead of plaintext as the current client does. At this time it requires a few minor changes to the index.php and splitting the accounts.php into accounts.php and accountrestrictions.php. It currently does not restrict users in any way allowing them to challenge any existing users once they have registered. It is quite simple in its setup. It just asks for their desired username and 2 password fields to verify the password is typed correctly and they are done. No email or other information required, no verification email.

    In order to use this you will need to set up all your users again because it uses encrypted passwords instead of plaintext. Maybe if there are enough users of OCC I could make a migration script to automatically go through the old accounts.php and encrypt all the passwords. Dunno how many people are using this already since its only about a month old.

     
    • Where can we get this script?

       
      • I need to update it for 1.0.7 since I modified some of the actual game files. Email me and I'll make sure you get it.

         
      • Devon Holcombe
        Devon Holcombe
        2003-12-28

        Email me...heh, made that last post anonymous on accident...so yeah.

         
    • Where can we get this script?

      Thanks

       
    • This is the script I wrote for version 1.2.6 and I use on my site: http://sandj.users.sonic.net/Games/occ/index.php

      <head>

      <?php
      include "accounts.php";

      function open_file($n)
      {
      $fd=fopen($n,"r") or die('...');
      $fs=fread($fd,filesize($n));
      fclose($fd);
      return $fs;
      }

      function save_file($m,$n,$o)
      {

          $n=trim($n);
          if($n=='')
          {
              $n=' ';
          }
          $n=str_replace("\n\n","\n",$n);
          $p=0;
          do
          {
              $fd=fopen($m,"w+") or die($o);
              $fout=fwrite($fd,$n);
              fclose($fd);
              $p++;
          }while(filesize($m)<5&&$p<5);

      }

      function AddUser($name, $password, $email)
      {
          $file = open_file("accounts.php");
          $search = "/* Add Users Here */";
          $file = preg_replace("$/\* Add Users Here \*/$", ", \&quot;$name\&quot; => \&quot;$password\&quot; $search ", $file);
          if ($email != '')
          {
              $search = "/* Add Emails Here */";
              $file = preg_replace("$/\* Add Emails Here \*/$", ", \&quot;$name\&quot; => \&quot;$email\&quot; $search ", $file);
          }
          save_file("accounts.php", $file, 0);
      }

      if(isset( $_POST ))
      {
      $new_name = $_POST["new_name"];
      $new_pass = $_POST["new_pass"];
      $new_email = $_POST["new_email"];
      if($new_name!='' && $new_pass!='')
      {
          $new_name = trim($new_name);
          $new_pass = trim($new_pass);
          $new_email = trim($new_email);
          /* First make sure the username is not already taken */
          /* If everything is ok, then add the user and redirect to index.php */
          if(!isset($passwords[$new_name]))
          {
              Adduser($new_name, $new_pass, $new_email);
              die("<title>Adding User</title><meta http-equiv=\&quot;Refresh\&quot; content=\&quot;2;url=index.php\&quot; /></head><body><div style=\&quot;color:black;background-color: white\&quot;>Adding User...</div></body></html>");
          }
          else
          {
              die("<title>Adding User</title><meta http-equiv=\&quot;Refresh\&quot; content=\&quot;30;url=index.php\&quot; /></head><body><div style=\&quot;color:black;background-color: white\&quot;>Adding User...<br /><bigger><bigger><b>Username is already taken!</b></bigger></bigger></div></body></html>");
          }
      }
      }
      ?>

      <title>Register</title>
        <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
      </head>
      <body>
      <h1>Online Chess Club Registration</h1>
      <form name="y" action="register.php" method="post">
      <table>
      <tr><td>Username</td><td><input type="text" size="30" name="new_name" /></td></tr>
      <tr><td>Password</td><td><input type="password" size="30" name="new_pass" /></td></tr>
      <tr><td>Email<small><em>(optional)</em></small></td><td><input type="text" size="50" name="new_email" /></td></tr>
      <tr><td> </td><td><input type="submit" name="submit" value="Register" /></td></tr>
      </table>
      <p><em>Please note that this regisration is only for access to the OCC games.  The forums require a seperate registration.  It is strongly suggested to fill out both forms, preferably with the same username.</em></p>
      </form>
      </body>
      </html>

       
    • The register.php works but the accounts.php don´t save the new user. (accounts.php=777)

      What can I do?