STRING, 'uid' => INT, 'age' => STRING, 'knum' => STRING, 'agree' => STRING,
'invite' => STRING));
typecast($_POST, array('pick_username' => STRING, 'email' => STRING,
'password' => STRING, 'passwordconfirm' => STRING, 'homepage' => STRING, 'cap' => INT,
'icq' => STRING, 'aim' => STRING, 'yahoo' => STRING, 'year' => STRING, 'mature' => STRING,
'hobbies' => STRING, 'occupation' => STRING, 'location' => STRING, 'bio' => STRING, 'rpass' => STRING,
'year' => INT, 'month' => INT, 'day' => INT, ', link' => INT, 'realname' => STRING));
authenticate();
topmenu();
if ( $Globals['ppboards'] == "closed" && $User['adminedit'] != 1 )
{
diewell( $Globals['closedmsg'] );
}
if ($Globals['allowregs'] == "no" )
{
diewell( $Globals['pp_lang']['nonew'] );
}
if ($gologin != 1)
{
if ($ppaction != "vfy")
{
diewell( "{$Globals['pp_lang']['loggedin']}
{$Globals['pp_lang']['retfront']} {$Globals['galleryname']}." );
}
}
if ( $invite )
{
$q = ppmysql_query( "SELECT name,email,referer FROM {$Globals['pp_db_prefix']}invites WHERE code='$invite' AND status < 9 LIMIT 1", $link );
list( $iname, $iemail, $ireferer ) = mysql_fetch_row($q);
if ( !$iemail )
{
diewell( $Globals['pp_lang']['invalidcode'] );
}
}
// If using Coppa, spit out the Coppa form
$gocoppa = 0;
$months = array($Globals['pp_lang']['month1'],$Globals['pp_lang']['month2'],$Globals['pp_lang']['month3'],$Globals['pp_lang']['month4'],
$Globals['pp_lang']['month5'],$Globals['pp_lang']['month6'],$Globals['pp_lang']['month7'],$Globals['pp_lang']['month8'],
$Globals['pp_lang']['month9'],$Globals['pp_lang']['month10'],$Globals['pp_lang']['month11'],$Globals['pp_lang']['month12']);
// Some inits
if ( !isset($ppaction) )
{
$ppaction = "register";
}
if ( $ppaction == "register" )
{
if ( $age == "" )
{
if ( $Globals['coppa'] == "yes" )
{
$age = "coppa";
$gocoppa = 1;
}
else
{
$age="adult";
}
}
else
{
if ( $age != "coppa" && $age != "adult" )
{
$age = "coppa";
}
if ( $Globals['coppa'] == "yes" )
{
$gocoppa=2;
}
}
if ( $gocoppa == 1 )
{
printheader( 0, "COPPA Form" );
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/menubar.tmpl" );
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/coppa.tmpl" );
printfooter();
exit;
}
$coppavar = $coppa;
// First see if they agree to the rules
printheader( 0, "Registration" );
if ($agree == "")
{
if ($age == "adult")
{
$ruleshtml = trim($Globals['rules']);
if ( $ruleshtml == "" || !file_exists($ruleshtml) )
{
$rulestext = $Globals['pp_lang']['reginstruct'];
}
else
{
$filearray = file($ruleshtml);
$rules = implode( " ", $filearray );
$rulestext = $rules;
}
}
if ($age == "coppa")
{
$coppahtml = trim($Globals['copparules']);
if ( empty($coppahtml) || !file_exists($coppahtml) )
{
$rulestext = "{$Globals['pp_lang']['coppaform']} {$Globals['pp_lang']['permformlower']}.
{$Globals['pp_lang']['formore']} {$Globals['adminemail']}";
}
else
{
$filearray = file($coppahtml);
$rulestext = implode( " ", $filearray );
}
}
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/menubar.tmpl" );
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/reg_agree.tmpl" );
printfooter();
exit;
}
// If they agreed to the rules, spit out the reg form
if ($agree == "yes")
{
$julian = time();
$cclock = formatpptime( $julian );
$ppdate = formatppdate( $julian );
$thetime = "$ppdate $cclock";
$newid = 0;
if ( $Globals['usecaptcha'] == "yes" )
{
// Let's generate a totally random string using md5
$md5 = md5(rand(0,999));
// We don't need a 32 character long string so we trim it down to 5
$pass = substr($md5, 10, 5);
$r = ppmysql_query( "INSERT INTO {$Globals['pp_db_prefix']}captcha (id,code) VALUES (NULL,'$pass')", $link );
$newid = mysql_insert_id($link);
if ( !$newid )
{
diewell( $Globals['pp_lang']['caperror'] );
}
}
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/menubar.tmpl" );
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/register.tmpl" );
printfooter();
exit;
}
}
// Process registration input, send verify email or enable acct
if ($ppaction == "submit")
{
if ( $Globals['usecaptcha'] == "yes" )
{
if ( $cap )
{
$q = ppmysql_query( "SELECT code FROM {$Globals['pp_db_prefix']}captcha WHERE id=$cap LIMIT 1", $link );
list( $pass ) = mysql_fetch_row($q);
if ( strtolower($rpass) != $pass )
{
diewell( $Globals['pp_lang']['keyinvalid'] );
}
}
else
{
diewell( $Globals['pp_lang']['noverif'] );
}
}
$reason = null;
if ($pick_username == "")
{
$reason .= "
{$Globals['pp_lang']['retfront']} {$Globals['galleryname']}" );
}
diewell("{$Globals['pp_lang']['thanks']}
{$Globals['pp_lang']['retfront']} {$Globals['galleryname']}");
}
// Verify a user's email, change status from unregistered to registered
if ($ppaction == "vfy")
{
$resulta = ppmysql_query("SELECT joindate,usergroupid FROM {$Globals['pp_db_prefix']}users WHERE userid=$uid LIMIT 1", $link);
if ( $resulta )
{
list( $joindate, $ugid ) = mysql_fetch_row($resulta);
if ($joindate == $knum && ($ugid == 3 || $ugid == 4))
{
$resulta = ppmysql_query("UPDATE {$Globals['pp_db_prefix']}users SET usergroupid=4,invites=15 WHERE userid=$uid", $link);
diewell("{$Globals['pp_lang']['thanks']}!
{$Globals['pp_lang']['retfront']} {$Globals['galleryname']}.");
}
else
{
diewell($Globals['pp_lang']['notabverify']);
}
}
else
{
diewell( $Globals['pp_lang']['nonum'] );
}
exit;
}
if ($ppaction == "cform")
{
topmenu();
printheader( 0, $Globals['pp_lang']['submitreg'] );
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/menubar.tmpl" );
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/coppa_form.tmpl" );
printfooter();
}
?>