View Single Post
  #1  
Old 07-06-2006, 09:22 PM
heathriel heathriel is offline
 
Join Date: Jun 2006
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default register_verify_age.php cookie drop - I can't make this work

I was trying to make a cookie drop when people enter their age so that they can't go back and change it to be older than 13 (as my boards are locked to under 13) but no matter what I do, I just can't get this to work.

Is there anyone who can figure out where I'm going wrong?

Code:
<script type="text/javascript">
<!--
if(document.cookie.indexOf("underage")>=0){location.href="http://www.mysite.com";}

function checkform(formobj)
{

var dob=new Date();
var date=dob.getDate();
var varmonth=dob.getMonth()+1;
var varyear=dob.getYear();
year+=(year<2006)?1900:0;

var month=parseInt(document.TermsandConditions.month.options[document.TermsandConditions.month.selectedIndex].value);
var day=parseInt(document.TermsandConditions.day.options[document.TermsandConditions.day.selectedIndex].value);
var year=parseInt(document.TermsandConditions.year.options[document.TermsandConditions.year.selectedIndex].value);

age=year-cmbyear;

if(month>varmonth){age--;}
else if(month==varmonth && day>date){age--;}

if(month==0){alert("You must enter the month you were born in.");return false;}
else if(day==0){alert("You must enter the date you were born on.");return false;}
else if((day>29 && month==2) || (day>30 && month==4) || (day>30 && month==6) || (day>30 && month==9) || (day>30 && month==11)){alert("That is an invalid date.");return false;}
else if(year==2006){alert("You must enter the year you were born in.");return false;}
else if(day>28 && month==2 && year/4==Math.round(cmbyear/4)){alert("That is an invalid date.");return false;}
else if(age<13){
alert("You are too young to enter these forums."+age);
document.cookie="underage=yes;expires="+new Date(new Date().getTime() + 4320*3600).toGMTString();
location.replace("http://www.mysite.com/");
return false;}
else if(!document.TermsandConditions.agree.checked){alert('Check the Proceed box to enter this site.');return false;}
else{return true;}

}
// -->
</script>
</head>
<body>
$header

<br />
<br />

<form method="post" action="register.php" onsubmit="return checkform(this)">
<input type="hidden" name="do" value="checkdate" />
<input type="hidden" name="s" value="$session[sessionhash]" />
<input type="hidden" name="url" value="$url" />

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="70%" align="center">
<tr>
	<td class="tcat"><phrase 1="$vboptions[bbtitle]">$vbphrase[register_at_x]</phrase></td>
</tr>
<tr>
	<td class="panelsurround" align="center">
	<div class="panel">
		<div style="width:70%" align="$stylevar[left]">
			
			<fieldset class="fieldset">
				<legend>$vbphrase[please_enter_your_date_of_birth]</legend>
				<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" align="center" width="100%">
				<tr>
					<td>
						$vbphrase[month]:<br />
						<select name="month">
							<option value="" selected="selected">-</option>
							<option value="01">$vbphrase[january]</option>
							<option value="02">$vbphrase[february]</option>
							<option value="03">$vbphrase[march]</option>
							<option value="04">$vbphrase[april]</option>
							<option value="05">$vbphrase[may]</option>
							<option value="06">$vbphrase[june]</option>
							<option value="07">$vbphrase[july]</option>
							<option value="08">$vbphrase[august]</option>
							<option value="09">$vbphrase[september]</option>
							<option value="10">$vbphrase[october]</option>
							<option value="11">$vbphrase[november]</option>
							<option value="12">$vbphrase[december]</option>
						</select>					
					</td>
					<td>
						$vbphrase[day]:<br />
						<select name="day">
							<option value="" selected="selected">-</option>
							<option value="01">1</option>
							<option value="02">2</option>
							<option value="03">3</option>
							<option value="04">4</option>
							<option value="05">5</option>
							<option value="06">6</option>
							<option value="07">7</option>
							<option value="08">8</option>
							<option value="09">9</option>
							<option value="10">10</option>
							<option value="11">11</option>
							<option value="12">12</option>
							<option value="13">13</option>
							<option value="14">14</option>
							<option value="15">15</option>
							<option value="16">16</option>
							<option value="17">17</option>
							<option value="18">18</option>
							<option value="19">19</option>
							<option value="20">20</option>
							<option value="21">21</option>
							<option value="22">22</option>
							<option value="23">23</option>
							<option value="24">24</option>
							<option value="25">25</option>
							<option value="26">26</option>
							<option value="27">27</option>
							<option value="28">28</option>
							<option value="29">29</option>
							<option value="30">30</option>
							<option value="31">31</option>
						</select>
					</td>
					<td>
						$vbphrase[year]:<br />
						<input type="text" class="bginput" name="year" size="10" maxlength="4" value="" />
					</td>
				</tr>
				</table>
			</fieldset>
			
		</div>
	</div>
	
	<div style="margin-top:$stylevar[cellpadding]px">
		<input type="submit" class="button" value="$vbphrase[proceed]" accesskey="s" />
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01106 seconds
  • Memory Usage 1,799KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete