Enter Your Information.
Name: (First Last)
Email Address: (This will be your username)
Password: (255 char. max)
 
EOD; return $content; } # Performs registration function function register($name,$email,$passwd) { global $site_url,$administrator; # Trim whitespace $email = trim($email); $name = trim($name); # Check to see if email address syntax is valid if (validate_email($email) == false) { return "The email address " . $email . " is not valid."; } # Check to see if this email already exists as a user if (is_current_user($email) == true) { $msg = "The email address you have entered already belongs to a user."; $msg .= "\nIf you are this user and have forgotten your password click "; $msg .= "here to generate a new one."; return $msg; } $sql = "INSERT INTO users (username,passwd,name) VALUES('" . $email . "','" . md5($passwd) . "','" . $name . "')"; db_connect($sql); $adminBody = "There has been a new user registration on the site. Please go here to approve or decline this new user."; $userBody = "Thank You for registering on with the Oklahoma Reading Association website. You will recieve notice shortly (usually within 24-48 hrs) to let you know if you've been\n"; $userBody .= "approved or declined. Once approved you may return and contribute to the site.\n\n"; $userBody .= "The Username and Password (once approved) that you will use to log in to the site is:\n"; $userBody .= "User: " . $email . "\nPassword: " . $passwd ."\n\nThanks,\nWebmaster"; send_mail('','',$administrator,"New user registration -- Pending.",$adminBody,"From: " . $administrator); send_mail('','',$email,"Your registration is pending approval.",$userBody,"From: " . $administrator); return "Thank you for registering you should recieve an email shortly with your information. After that you should recieve an email from the administration letting you know if you've been approved or declined."; } # Admin Functions - Provides admins with ability to approve or deny registration to this site. function admin_functions($usr,$pass) { if ( validate($usr,$pass) != 2 ) { $content = "This area is for administrators only.\n"; } else { $content = list_users($usr,$pass); } return $content; } function list_users($user,$pass) { $content = "Here you may utilize five functions. Approve, Decline, Remove, Make Admin, and Revoke Admin.
\n"; # List unverified users $result = db_connect("SELECT username,admin,name,verified FROM users WHERE verified='N' ORDER BY username"); if ( mysql_num_rows($result) > 0 ) { $content .= "\nUnapproved Users:
\n"; while ($row = mysql_fetch_assoc($result)) { $content .= "
\n"; $content .= "\n"; $content .= "\n"; $content .= "\n"; $content .= $row['name'] . "  (" . $row['username'] . ") -- \n"; $content .= "\n"; $content .= "
"; } } else $content .= "There are no unapproved users at this time.\n"; free_result($result); # List Verified users $result = db_connect("SELECT username,admin,name,verified FROM users WHERE ((verified='Y') AND (username <> 'garret06@nsuok.edu')) ORDER BY username"); if ( mysql_num_rows($result) > 0 ) { $content .= "\nApproved Users:
\n"; while ($row = mysql_fetch_assoc($result)) { $content .= "
\n"; $content .= "\n"; $content .= "\n"; $content .= "\n"; if ( $row['admin'] == 'Y' ) $content .= "Admin\n"; $content .= $row['name'] . "  (" . $row['username'] . ") -- \n"; $content .= "\n"; if ( $row['admin'] == 'N' ) $content .= "\n"; if ( $row['admin'] == 'Y' ) $content .= "\n"; $content .= "
"; } } else $content .= "No Approved Users Found."; free_result($result); return $content; } function make_admin($user,$pass,$appUser) { if ( validate($user,$pass) == 2 ) { $sql = "UPDATE users SET admin='Y' WHERE username='" . $appUser . "'"; db_connect($sql); $content = $appUser . " has been upgraded to an Administrator.\n"; } else $content = "Only Admins are able to upgrade users.\n"; return $content; } function revoke_admin($user,$pass,$appUser) { if ( validate($user,$pass) == 2 ) { $sql = "UPDATE users SET admin='N' WHERE username='" . $appUser . "'"; db_connect($sql); $content = $appUser . " has been downgraded to a regular user.\n"; } else $content = "Only Admins are able to downgrade users.\n"; return $content; } function approve_user($user,$pass,$appUser) { global $administrator; if ( validate($user,$pass) == 2 ) { $sql = "UPDATE users SET verified='Y' WHERE username='" . $appUser . "'"; db_connect($sql); $content = $appUser . " has been approved as a user.\n"; $optBody = "You may now return and contribute to the site."; send_mail('','',$appUser,"Your registration has been approved.",$optBody,"From: " . $administrator); } else $content = "Only Admins are able to approve users.\n"; return $content; } function decline_user($user,$pass,$appUser) { global $administrator; if ( validate($user,$pass) == 2 ) { $sql = "DELETE FROM users WHERE username='" . $appUser . "'"; db_connect($sql); $content = $appUser . " has been removed from the system, please fill in the reason this user has been declined below and click send.\n"; $content .=<<
Reason for being declined:
EOD; } else $content = "Only Admins are able to decline users.\n"; return $content; } function remove_user($user,$pass,$appUser) { if ( validate($user,$pass) == 2 ) { $sql = "DELETE FROM users WHERE username='" . $appUser . "'"; db_connect($sql); $content = $appUser . " has been removed from the system.\n"; } else $content = "Only Admins are able to remove users.\n"; return $content; } function generate_new_pass($user) { global $administrator; // ************************* // Random Password Generator // ************************* $totalChar = 7; // number of chars in the password $salt = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789!@#$%^&*()"; // salt to select chars from srand((double)microtime()*1000000); // start the random generator $password=""; // set the inital variable for ($i=0;$i<$totalChar;$i++) // loop and create password $password = $password . substr ($salt, rand() % strlen($salt), 1); // ************************* // Write password to database // and email to user. // ************************* $sql = "UPDATE users SET passwd='" . md5($password) . "' WHERE username='" . $user . "'"; db_connect($sql); $optBody = "Your user id for the site is: " . $user . "\nYour new password is: " . $password; send_mail('','',$user,"Password successfully changed for the Oklahoma Reading Association's website.",$optBody,"From: " . $administrator); return "Your new password has been updated in the database and emailed to the email address we have for you."; } ?> Oklahoma Reading Association : User Registration
User Registration











     Copyright 2005 Oklahoma Reading Association