forked from science-ation/science-ation
participant registration authentication
This commit is contained in:
parent
86bad4961b
commit
404157df30
@ -60,7 +60,7 @@ if($_GET['switchlanguage'])
|
||||
}
|
||||
|
||||
|
||||
function i18n($str)
|
||||
function i18n($str,$args=array())
|
||||
{
|
||||
if(!$str)
|
||||
return "";
|
||||
@ -68,16 +68,34 @@ function i18n($str)
|
||||
if($_SESSION['lang'])
|
||||
{
|
||||
if($_SESSION['lang']=="en")
|
||||
{
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
$str=str_replace("%$x",$args[$x-1],$str);
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
else
|
||||
{
|
||||
$q=mysql_query("SELECT * FROM translations WHERE lang='".$_SESSION['lang']."' AND strmd5='".md5($str)."'");
|
||||
if($r=@mysql_fetch_object($q))
|
||||
{
|
||||
if($r->val)
|
||||
return $r->val;
|
||||
{
|
||||
$ret=$r->val;
|
||||
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
$ret=str_replace("%$x",$args[$x-1],$ret);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
$str=str_replace("%$x",$args[$x-1],$str);
|
||||
}
|
||||
return "<font color=red>($str)</font>";
|
||||
}
|
||||
|
||||
@ -85,7 +103,10 @@ function i18n($str)
|
||||
else
|
||||
{
|
||||
mysql_query("INSERT INTO translations (lang,strmd5,str) VALUES ('".$_SESSION['lang']."','".md5($str)."','".mysql_escape_string($str)."')");
|
||||
echo mysql_error();
|
||||
for($x=1;$x<=count($args);$x++)
|
||||
{
|
||||
$str=str_replace("%$x",$args[$x-1],$str);
|
||||
}
|
||||
return "<font color=red>($str)</font>";
|
||||
}
|
||||
}
|
||||
@ -97,15 +118,31 @@ function i18n($str)
|
||||
}
|
||||
}
|
||||
|
||||
function error($str)
|
||||
{
|
||||
return $str."<br />";
|
||||
|
||||
}
|
||||
|
||||
function notice($str)
|
||||
{
|
||||
return $str."<br />";
|
||||
}
|
||||
|
||||
$HEADER_SENT=false;
|
||||
function send_header($title="")
|
||||
{
|
||||
global $HEADER_SENT;
|
||||
global $config;
|
||||
|
||||
//do this so we can use send_header() a little more loosly and not worry about it being sent more than once.
|
||||
if($HEADER_SENT) return;
|
||||
else $HEADER_SENT=true;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
|
||||
<head><title><?=$title?></title>
|
||||
<head><title><?=i18n($title)?></title>
|
||||
<link rel="stylesheet" href="<?=$config['SFIABDIRECTORY']?>/sfiab.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
@ -157,7 +194,7 @@ if(count($config['languages'])>1)
|
||||
<div id="main">
|
||||
<?
|
||||
if($title)
|
||||
echo "<h2>$title</h2>";
|
||||
echo "<h2>".i18n($title)."</h2>";
|
||||
}
|
||||
|
||||
function send_footer()
|
||||
@ -165,6 +202,7 @@ function send_footer()
|
||||
?>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<? print_r($_SESSION); ?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
@ -1,6 +1,127 @@
|
||||
<?
|
||||
require("common.inc.php");
|
||||
send_header("Participant Registration");
|
||||
|
||||
if($_POST['action']=="new")
|
||||
{
|
||||
$q=mysql_query("SELECT email,num,id FROM registrations WHERE email='".$_SESSION['email']."' AND num='".$_POST['regnum']."' AND year=".$config['FAIRYEAR']);
|
||||
if(mysql_num_rows($q))
|
||||
{
|
||||
$r=mysql_fetch_object($q);
|
||||
$_SESSION['registration_number']=$r->num;
|
||||
$_SESSION['registration_id']=$r->id;
|
||||
header("Location: register_participants_main.php");
|
||||
exit;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
send_header("Participant Registration");
|
||||
echo error(i18n("Invalid registration number (%1) for email address %2",array($_POST['regnum'],$_SESSION['email'])));
|
||||
$_POST['action']="login";
|
||||
}
|
||||
|
||||
}
|
||||
else if($_POST['action']=="continue")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
send_header("Participant Registration");
|
||||
|
||||
if($_POST['action']=="login" && ( $_POST['email'] || $_SESSION['email']) )
|
||||
{
|
||||
if($_POST['email'])
|
||||
$_SESSION['email']=$_POST['email'];
|
||||
|
||||
echo "<form method=\"post\" action=\"register_participants.php\">";
|
||||
|
||||
$allownew=true;
|
||||
//first, check if they have any registrations waiting to be opened
|
||||
$q=mysql_query("SELECT * FROM registrations WHERE email='".$_SESSION['email']."' AND status='new' AND year=".$config['FAIRYEAR']);
|
||||
if(mysql_num_rows($q)>0)
|
||||
{
|
||||
echo i18n("Please enter the <b>registration number</b> you received in your email, in order to begin your new registration");
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"new\">";
|
||||
$allownew=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$q=mysql_query("SELECT students.email,
|
||||
registrations.status
|
||||
FROM students,
|
||||
registrations
|
||||
WHERE
|
||||
students.email='".$_SESSION['email']."'
|
||||
AND students.year=".$config['FAIRYEAR']."
|
||||
AND registrations.year=".$config['FAIRYEAR']."
|
||||
AND registrations.status='open'");
|
||||
if(mysql_num_rows($q)>0)
|
||||
{
|
||||
echo i18n("Please enter the <b>registration number</b> in order to continue your registration");
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"continue\">";
|
||||
$allownew=false;
|
||||
}
|
||||
}
|
||||
|
||||
if($allownew)
|
||||
{
|
||||
$regnum=0;
|
||||
//now create the new registration record, and assign a random/unique registration number to then.
|
||||
do
|
||||
{
|
||||
//random number between
|
||||
//100000 and 999999 (six digit integer)
|
||||
$regnum=rand(100000,999999);
|
||||
$q=mysql_query("SELECT * FROM registrations WHERE num='$regnum' AND year=".$config['FAIRYEAR']);
|
||||
}while(mysql_num_rows($q)>0);
|
||||
|
||||
//actually insert it
|
||||
mysql_query("INSERT INTO registrations (num,email,start,status,year) VALUES (".
|
||||
"'$regnum',".
|
||||
"'".$_SESSION['email']."',".
|
||||
"NOW(),".
|
||||
"'new',".
|
||||
$config['FAIRYEAR'].
|
||||
")");
|
||||
|
||||
|
||||
$mailbody= "A new registration account has been created for you.\n".
|
||||
"To access your registration account, please enter\n".
|
||||
"enter the following registration number into the\n".
|
||||
"registration website:\n".
|
||||
"\n".
|
||||
"Registration Number: $regnum\n".
|
||||
"\n";
|
||||
mail($_SESSION['email'],i18n("Registration for %1",array(i18n($config['fairname']))),$mailbody);
|
||||
|
||||
echo i18n("You have been identified as a new registrant. An email has been sent to <b>%1</b> which contains your new <b>registration number</b>. Please check your email to obtain your <b>registration number</b> and then enter it below:",array($_SESSION['email']));
|
||||
echo "<input type=\"hidden\" name=\"action\" value=\"new\">";
|
||||
|
||||
}
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
echo i18n("Registration Number:");
|
||||
echo "<input type=\"text\" size=\"10\" name=\"regnum\">";
|
||||
echo "<input type=\"submit\" value=\"Submit\">";
|
||||
echo "</form>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
echo i18n("Please enter your email address to :");
|
||||
echo "<ul>";
|
||||
echo "<li>".i18n("Begin a new registration")."</li>";
|
||||
echo "<li>".i18n("Continue a previously started registration")."</li>";
|
||||
echo "<li>".i18n("Modify an existing registration")."</li>";
|
||||
echo "</ul>";
|
||||
|
||||
?>
|
||||
<form method="post" action="register_participants.php">
|
||||
<input type="hidden" name="action" value="login" />
|
||||
<?=i18n("Email")?>: <input type="text" name="email" size="30" />
|
||||
<input type="submit" value="Begin" />
|
||||
</form>
|
||||
<?
|
||||
}
|
||||
send_footer();
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user