Førstesiden Informasjon Kalender NUUG/HIO prisen Vedtekter Dokumenter Innmelding Ressurser Kontakt Linker Om medlemsmøter Om de aktive webmaster@nuug.no |
//=========================================
// Configuration options
$db_host = "localhost";
$db_user = "tfheen";
include "/home/tfheen/.mysql.pwd";
$db_pass = $mysql_pass;
$db_name = "sommerfest";
$db_table = "sommerfest_2003_reg";
$PHP_SELF = "http://www.nuug.no/aktiviteter/20030717-sommerfest/paamelding.php";
$mailfrom = "aktive@nuug.no";
$limit = 200;
//=========================================
//=========================================
$conn = mysql_connect("$db_host","$db_user","$db_pass") or die(mysql_error());
mysql_select_db("$db_name") or die(mysql_error());
//============================================================================
// Document the database table format. I'm not sure about the data
// types yet.
function CreateTable() {
$sql = "
CREATE TABLE $db_table (
Serial int(11) NOT NULL auto_increment,
TimeStamp timestamp(14) NOT NULL,
IpAddress text NOT NULL,
Name text NOT NULL,
Email text NOT NULL,
organisation text NOT NULL,
comment text NOT NULL,
password varchar(14) NOT NULL default '',
PRIMARY KEY (Serial)
) TYPE=MyISAM;
";
}
//============================================================================
function RandomPassword( $passwordLength ) {
$password = "";
for ($index = 1; $index <= $passwordLength; $index++) {
// Pick random number between 1 and 62
$randomNumber = rand(1, 62);
// Select random character based on mapping.
if ($randomNumber < 11)
$password .= Chr($randomNumber + 48 - 1); // [ 1,10] => [0,9]
else if ($randomNumber < 37)
$password .= Chr($randomNumber + 65 - 10); // [11,36] => [A,Z]
else
$password .= Chr($randomNumber + 97 - 36); // [37,62] => [a,z]
}
return $password;
}
//=========================================
function regform($name,$email,$organisation,$comment)
{
echo "
Wrong password\n"; echo "It seems like you entered the wrong password, please log \n"; echo "in again and try again, or you have tried to register \n"; echo "multiple times with the same address. Please \n"; echo "log in instead.\n"; exit(); } } else { if ($count > $limit) { echo "We have reached the registration limit of $limit people.\n"; echo "The registration is now closed. \n"; return; } // just save $sql = "INSERT INTO $db_table (IpAddress,Name,Email,organisation, comment, password) VALUES ('$ipaddress','$name','$email', '$organisation', '$comment', '$password')"; mysql_query("$sql"); mail("$email", "NUUG Summer Party registration", " Thanks for your registration for the NUUG Summer Party! Just to give you a reminder, the party will be held on... Thursday, July 17th 2003, from 18:30 in the Chemistry Building Atrium, Blindern See the map at
NUUG Summer Party registrationWe need to know how many people will attend to know how much food we need to buy. The registration will be closed 2003-07-15 16:00 +0200 or when we reach $limit registrations, whichever comes first. NUUG will provide marinated chicken, chops, potato salad, baguettes, mixed salad, butter, mayonnaise and dressing. We will also provide something to drink. If you want something else, you will have to bring your own. The barbecue will be available if you want to grill some of the things you bring. Currently there are $count (out of max $limit) registered partygoers. "; if ($count > $limit) { echo "We have reached the registration limit of $limit people.\n"; echo "The registration is now closed. \n"; return; } echo "\n"; echo "Change information | \n"; echo "Lost password\n"; } //========================================= function do_login($email,$password) { global $PHP_SELF; global $db_table; $sql = "SELECT * from $db_table where email = '$email' and password = '$password'"; $res = mysql_query("$sql"); $arr = mysql_fetch_array($res); if ($arr == FALSE) { // Login failed echo "Login failed\n"; echo "Either the email or the password was wrong, please log in again or have it mailed to you. "; } else { echo "NUUG Summer Party registration"; echo "\n"; } } //========================================= function show_login_form($email,$password) { echo "NUUG Summer Party registration"; echo "Please log in using the email and password mailed to you" . " earlier "; echo "\n"; } //========================================= function confirm_form($name,$email,$organisation,$comment) { echo "Please confirm that these details are correct:\n"; echo ""; } //========================================= function show_lostpasswd_form() { global $PHP_SELF; echo "Please enter the email address you used when registering for the NUUG Summer Party:\n"; echo ""; } //========================================= function mail_lostpasswd($email) { $ipaddress = $_SERVER[REMOTE_ADDR]; global $PHP_SELF; global $mailfrom; global $db_table; $sql = "SELECT * from $db_table where email = '$email'"; $res = mysql_query("$sql"); $arr = mysql_fetch_array($res); if ($arr == FALSE) { // No such mail echo "No such emailSorry, but it seems like $email has not signed up for the NUUG Summer Party. Perhaps you used a different mail address? "; } else { $password = $arr["password"]; mail("$email", "NUUG Summer Party lost password reminder", " Your password on the NUUG Summer Party site is $password . Please go to $PHP_SELF?command=login to change your information. (This subscription request was recieved from IP address $ipaddress) -- The NUUG Summer Party Committee ","From: \"The NUUG Summer Party Committee\" <$mailfrom>"); echo "Password mailedYour password has been mailed to you. "; } } //========================================= //echo "co: $command"; if($command == "check_details") { confirm_form($name,$email,$organisation,$comment,$password); } elseif($command == "confirm") { save_details($name,$email,$organisation,$comment,$password); } elseif($command == "login") { show_login_form($email,$password); } elseif($command == "do_login") { do_login($email,$password); } elseif($command == "lostpasswd") { show_lostpasswd_form(); } elseif($command == "mail_lostpasswd") { mail_lostpasswd($email); } else { show_form($name,$email,$organisation,$comment,$password); } ?> |