Code: Select all
# variables for step 4
$conf=$_POST['conf']; # confirmation code, uploaded files dealt with in processing
# error logging
$err=NULL; $errs=array(); $warn=NULL; $warns[]=array();
# check for errors/add to db
if((isset($step))&&($step>1)){
/* checks on steps 1 2 3 and 4 */
elseif($step==5){ # make sure the validation code is correct and "pictures" are pictures
$validate=$_COOKIE['confcode'];
if($conf!==$validate){
$err=TRUE; $step=4;
$errs[]='Your Confirmation Code did not match. Your e-mail MUST be validated to proceed.<br> You will need to resubmit your pictures as well.<br />';
}
else{ #only bother if the confcode is right
# process the uploaded files (if any)
if($_FILES['main']['name']){ # if they uploaded a file
if(153600<$_FILES['main']['size']){ # make sure it isn't over 150 KB
$err=TRUE; $step=4; $merr=TRUE;
$errs[]='Your Main picture was too large. You may not upload a file over 153600 Bytes (150 KB)';
}
if('image/jpeg'!==$_FILES['main']['type']){ # only accept jpegs
$err=TRUE; $step=4; $merr=TRUE;
$errs[]='Your Main picture was not a JPEG. JPEG encoded files traditionally end with .jpe, .jpg, and .jpeg on windows.';
}
if($_FILES['main']['error'] !== (0 || 'UPLOAD_ERR_OK')){ # if there was an error
$err=TRUE; $step=4; $error=$_FILES['main']['error']; $merr=TRUE;
$errs[]='Uploading your Main Picture caused an error: '.$error;
}
if(!($merr)){ # if there wasn't an issue, move to the awaiting approval bin -- humans will check it's ok
$un=$_COOKIE['un']; $to='/var/www/html/findyourdesire/unapproved/'.$un.'.jpg';
move_uploaded_file($_FILES['main']['tmp'], $to);
$errs[]='main was uploaded sucessfully'; # incase something else went wrong
}
}
if($_FILES['t1']['name']){ # if they uploaded a file
if(153600<$_FILES['t1']['size']){ # make sure it isn't over 150 KB
$err=TRUE; $step=4; $t1err=TRUE;
$errs[]='Your 1st thumb was too large. You may not upload a file over 153600 Bytes (150 KB)';
}
if('image/jpeg'!==$_FILES['t1']['type']){ # only accept jpegs
$err=TRUE; $step=4; $t1err=TRUE;
$errs[]='Your 1st thumb was not a JPEG. JPEG encoded files traditionally end with .jpe, .jpg, and .jpeg on windows.';
}
if($_FILES['t1']['error'] !== (0 || 'UPLOAD_ERR_OK')){ # if there was an error
$err=TRUE; $step=4; $error=$_FILES['t1']['error']; $t1err=TRUE;
$errs[]='Uploading your 1st thumb caused an error: '.$error;
}
if(!($t1err)){ # if there wasn't an issue, move to the awaiting approval bin -- humans will check it's ok
$un=$_COOKIE['un']; $to='/var/www/html/findyourdesire/unapproved/t1.'.$un.'.jpg';
move_uploaded_file($_FILES['t1']['tmp'], $to);
$errs[]='thumb 1 was uploaded sucessfully'; # incase something else went wrong
}
}
if($_FILES['t2']['name']){ # if they uploaded a file
if(153600<$_FILES['t2']['size']){ # make sure it isn't over 150 KB
$err=TRUE; $step=4; $t2err=TRUE;
$errs[]='Your 2nd thumb was too large. You may not upload a file over 153600 Bytes (150 KB)';
}
if('image/jpeg'!==$_FILES['t2']['type']){ # only accept jpegs
$err=TRUE; $step=4; $t2err=TRUE;
$errs[]='Your 2nd thumb was not a JPEG. JPEG encoded files traditionally end with .jpe, .jpg, and .jpeg on windows.';
}
if($_FILES['t2']['error'] !== (0 || 'UPLOAD_ERR_OK')){ # if there was an error
$err=TRUE; $step=4; $error=$_FILES['t2']['error']; $t2err=TRUE;
$errs[]='Uploading your 2nd thumb caused an error: '.$error;
}
if(!($t2err)){ # if there wasn't an issue, move to the awaiting approval bin -- humans will check it's ok
$un=$_COOKIE['un']; $to='/var/www/html/findyourdesire/unapproved/t2.'.$un.'.jpg';
move_uploaded_file($_FILES['t2']['tmp'], $to);
$errs[]='thumb 2 was uploaded sucessfully'; # incase something else went wrong
}
}
if($_FILES['t3']['name']){ # if they uploaded a file
if(153600<$_FILES['t3']['size']){ # make sure it isn't over 150 KB
$err=TRUE; $step=4; $t3err=TRUE;
$errs[]='Your 3rd thumb was too large. You may not upload a file over 153600 Bytes (150 KB)';
}
if('image/jpeg'!==$_FILES['t3']['type']){ # only accept jpegs
$err=TRUE; $step=4; $t3err=TRUE;
$errs[]='Your 3rd thumb was not a JPEG. JPEG encoded files traditionally end with .jpe, .jpg, and .jpeg on windows.';
}
if($_FILES['t3']['error'] !== (0 || 'UPLOAD_ERR_OK')){ # if there was an error
$err=TRUE; $step=4; $error=$_FILES['t3']['error']; $t3err=TRUE;
$errs[]='Uploading your 3rd thumb caused an error: '.$error;
}
if(!($t3err)){ # if there wasn't an issue, move to the awaiting approval bin -- humans will check it's ok
$un=$_COOKIE['un']; $to='/var/www/html/findyourdesire/unapproved/t3.'.$un.'.jpg';
move_uploaded_file($_FILES['t3']['tmp'], $to);
$errs[]='thumb 3 was uploaded sucessfully'; # incase something else went wrong
}
}
if($_FILES['t4']['name']){ # if they uploaded a file
if(153600<$_FILES['t4']['size']){ # make sure it isn't over 150 KB
$err=TRUE; $step=4; $t4err=TRUE;
$errs[]='Your 4th thumb was too large. You may not upload a file over 153600 Bytes (150 KB)';
}
if('image/jpeg'!==$_FILES['t4']['type']){ # only accept jpegs
$err=TRUE; $step=4; $t4err=TRUE;
$errs[]='Your 4th thumb was not a JPEG. JPEG encoded files traditionally end with .jpe, .jpg, and .jpeg on windows.';
}
if($_FILES['t4']['error'] !== (0 || 'UPLOAD_ERR_OK')){ # if there was an error
$err=TRUE; $step=4; $error=$_FILES['t4']['error']; $t4err=TRUE;
$errs[]='Uploading your 4th thumb caused an error: '.$error;
}
if(!($t4err)){ # if there wasn't an issue, move to the awaiting approval bin -- humans will check it's ok
$un=$_COOKIE['un']; $to='/var/www/html/findyourdesire/unapproved/t4.'.$un.'.jpg';
move_uploaded_file($_FILES['t4']['tmp'], $to);
$errs[]='thumb 4 was uploaded sucessfully'; # incase something else went wrong
}
}
if($_FILES['salute']['name']){ # if they uploaded a file
if(153600<$_FILES['salute']['size']){ # make sure it isn't over 150 KB
$err=TRUE; $step=4; $serr=TRUE;
$errs[]='Your Salute picture was too large. You may not upload a file over 153600 Bytes (150 KB)';
}
if('image/jpeg'!==$_FILES['salute']['type']){ # only accept jpegs
$err=TRUE; $step=4; $serr=TRUE;
$errs[]='Your Salute picture was not a JPEG. JPEG encoded files traditionally end with .jpe, .jpg, and .jpeg on windows.';
}
if($_FILES['salute']['error'] !== (0 || 'UPLOAD_ERR_OK')){ # if there was an error
$err=TRUE; $step=4; $error=$_FILES['salute']['error']; $serr=TRUE;
$errs[]='Uploading your Salute caused an error: '.$error;
}
if(!($serr)){ # if there wasn't an issue, move to the awaiting approval bin -- humans will check it's ok
$un=$_COOKIE['un']; $to='/var/www/html/findyourdesire/unapproved/s.'.$un.'.jpg';
move_uploaded_file($_FILES['s']['tmp'], $to);
$errs[]='salute was uploaded sucessfully'; # incase something else went wrong
}
}
}
}
}
# find where we are
if(isset($step)){
if(($step==1)&&($err)){ # an error was found in step 1
bgnpg('no', $step); errreport($step, $errs); s1();
}elseif($step==1){ # signup hasn't started yet
bgnpg('yes', $step); s1();
}elseif(($step==2)&&($err)){ # an error was found in step 2
bgnpg('no', $step); errreport($step, $errs); s2();
}elseif($step==2){ # we need a username, pw, and e-mail
bgnpg('no', $step); s2();
}elseif($step==3){ # see if they want a bio/misc interests
bgnpg('no', $step); s3($un, $pw, $email);
}elseif(($step==4)&&($err)){ # an error was found in step4
bgnpg('no', $step); errreport($step, $errs); s4();
}elseif($step==4){ # get the validation code and let them upload pics
bgnpg('no', $step); s4();
}elseif($step==5){ # thank them for joining
bgnpg('no', $step); s5();
}
}else{ # they are starting signup
bgnpg('yes', '1'); s1();
}
#functions that make the pages
function bgnpg($cookie, $step){
if($cookie=='yes'){ # set the cookie with the validation code
$conf=md5(uniqid(microtime(),1)); # make unique id
$expire=time()+60*60; # set expiration an hour from now
setcookie(confcode, $conf, $expire); #create cookie
}
if($step==3){
$un=md5($_POST['un']);
$expire=time()+60*60; # set expiration an hour from now
setcookie(un, $un, $expire);
}
?><html>
<head>
<title>FindYourDesire.com Signup page -- <? echo $step; ?></title>
<meta name="Author" content="coded by: Josh Perlmutter; images by Morgan O'Brien-Bledsow & Tamara Collette all rights reserved">
<style type="text/css">
<!-- this comment is for non-css compliant browsers
{text-decoration=none}
end of css -->
</style>
</head>
<body bgcolor="#000000" text="#c8c8c8" alink="#fc00ff" vlink="#00e0c4" link="#ffffff">
<center><p> </p>
<!-- banner goes here -->
<!-- ad bar goes here -->
<?php
}
function errreport($step, $errs){
if($step==1){ # report errors in step1
foreach($errs as $err){
echo " <h1><font color="#ff0000">YOU MUST AGREE TO THE $err!</font></h1>";
}
}elseif($step==2){ # report errors in step2
foreach($errs as $err){
echo " <h1><font color="#ff0000">$err</font></h1>";
}
}else{ # report errors of step4
foreach($errs as $err){
$val=$_POST['conf'];
echo "<h1>debug line: validation code submitted: $val</h1>";
echo " <h1><font color="#ff0000">$err</font></h1>";
}
}
}
function s4(){
?> <h1>THIS IS A TEST. IT DOES NOT HAVE A DATABASE CONNECTION NOR DOES IT CHECK USERNAMES. THIS LINE WILL BE REMOVED IN THE REAL ONE </h1>
<p>Thank you for your interest in joining FindYourDesire.com. We need to know some things about you in order to make your profile here. Any feild in <font color="#ff0000">RED</font> is required. Any feild marked with an * is confidential and will NOT show up in your user stats. Any feild with a ° will not show up in your user stats, but is collected for future features. You will be notified before they are used.</p>
<h2>NOTE: MAXIMUM PICTURE SIZE IS 150 KB</h2>
<form enctype="multipart/form-data" action="<?php echo $_SERVER[PHP_SELF]; ?>" method="POST">
<input type="hidden" name="step" value="5"><input type="hidden" name="MAX_FILE_SIZE" value="153600">
<table frame="void" bgcolor="#000000" border="0" cellpadding="0" cellspacing="0" text="#c8c8c8">
<tr><td>Your <a name="#confcode" href="#confcode" onClick="window.open('faq.php?seek=confcode', 'faq', 'width=500,height=250,scrollbars=yes');">Confirmation Code</a></td><td><input type="text" name="conf" size="25"></td></tr>
<tr><td>Upload your main picture</td><td><input type="file" accept="image/jpeg" name="main" size="25"></td></tr>
<tr><td>Upload Thumb 1</td><td><input type="file" accept="image/jpeg" name="t1" size="25"></td></tr>
<tr><td>Upload Thumb 2</td><td><input type="file" accept="image/jpeg" name="t2" size="25"></td></tr>
<tr><td>Upload Thumb 3</td><td><input type="file" accept="image/jpeg" name="t3" size="25"></td></tr>
<tr><td>Upload Thumb 4</td><td><input type="file" accept="image/jpeg" name="t4" size="25"></td></tr>
<tr><td>Upload your <a name="#salute" href="#salute" onClick="window.open('faq.php?seek=salute', 'faq', 'width=500,height=250,scrollbars=yes');">salute</a></td><td><input type="file" accept="image/jpeg" name="salute" size="25"></td></tr>
<tr><td><input type="submit" value="Go To The Next Step"></td><td><input type="reset" value="Restart This Step"></td></tr>
</table>
</center>
</body>
</html>
<?php
}also, i want to mask the cookies somehow so people can't rip it from the cookie files. i'm wondering if anyone has any suggestions of how to do that. i'm thinking of using crypt() on anything (and if possible md5) before placing it in the cookie, then calling crypt on the arguments to see if they are the same, but figure it's worth it to find out what those that have more experience think.
it's not like thisis going to be overly sensitive data or anything since it's just goingto be a rateme site, but i want to make it diffcult to try to be a different user.
-Josh
code updated 6-27