Location: PHPKode > scripts > NBSCaptcha > NBSCaptcha/index.php
<?php

	//Start session only if it is not started.
	if (!isset ($_COOKIE[ini_get('session.name')])) {
		session_start();
	}
	
	include("settings.php");

/*
PHP CSS Browser Selector v0.0.1
Bastian Allgeier (http://bastian-allgeier.de)
http://bastian-allgeier.de/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Credits: This is a php port from Rafael Lima's original Javascript CSS Browser Selector: http://rafael.adm.br/css_browser_selector
*/

function css_browser_selector($ua=null) {
		$ua = ($ua) ? strtolower($ua) : strtolower($_SERVER['HTTP_USER_AGENT']);		

		$g = 'gecko';
		$w = 'webkit';
		$s = 'safari';
		$b = array();
		
		// browser
		if(!preg_match('/opera|webtv/i', $ua) && preg_match('/msie\s(\d)/', $ua, $array)) {
				$b[] = 'ie ie' . $array[1];
		}	else if(strstr($ua, 'firefox/2')) {
				$b[] = $g . ' ff2';		
		}	else if(strstr($ua, 'firefox/3.5')) {
				$b[] = $g . ' ff3 ff3_5';
		}	else if(strstr($ua, 'firefox/3')) {
				$b[] = $g . ' ff3';
		} else if(strstr($ua, 'gecko/')) {
				$b[] = $g;
		} else if(preg_match('/opera(\s|\/)(\d+)/', $ua, $array)) {
				$b[] = 'opera opera' . $array[2];
		} else if(strstr($ua, 'konqueror')) {
				$b[] = 'konqueror';
		} else if(strstr($ua, 'chrome')) {
				$b[] = $w . ' ' . $s . ' chrome';
		} else if(strstr($ua, 'iron')) {
				$b[] = $w . ' ' . $s . ' iron';
		} else if(strstr($ua, 'applewebkit/')) {
				$b[] = (preg_match('/version\/(\d+)/i', $ua, $array)) ? $w . ' ' . $s . ' ' . $s . $array[1] : $w . ' ' . $s;
		} else if(strstr($ua, 'mozilla/')) {
				$b[] = $g;
		}

		// platform				
		if(strstr($ua, 'j2me')) {
				$b[] = 'mobile';
		} else if(strstr($ua, 'iphone')) {
				$b[] = 'iphone';		
		} else if(strstr($ua, 'ipod')) {
				$b[] = 'ipod';		
		} else if(strstr($ua, 'mac')) {
				$b[] = 'mac';		
		} else if(strstr($ua, 'darwin')) {
				$b[] = 'mac';		
		} else if(strstr($ua, 'webtv')) {
				$b[] = 'webtv';		
		} else if(strstr($ua, 'win')) {
				$b[] = 'win';		
		} else if(strstr($ua, 'freebsd')) {
				$b[] = 'freebsd';		
		} else if(strstr($ua, 'x11') || strstr($ua, 'linux')) {
				$b[] = 'linux';		
		}
				
		return join(' ', $b);
		
}

?>

<html>
	<head>
		<title>Captcha Script by NetBizSolutions</title>
		<?php if(preg_match("/ie/", css_browser_selector())){ ?>
			<link rel="stylesheet" type="text/css" href="./css/captcha_ie.css" />
		<?php } else if(preg_match("/gecko/", css_browser_selector())){ ?>
			<link rel="stylesheet" type="text/css" href="./css/captcha.css" />
		<?php } else if(preg_match("/webkit/", css_browser_selector())){ ?>
			<link rel="stylesheet" type="text/css" href="./css/captcha.css" />
		<?php } ?>
		<script src="jquery.js"></script>
	</head>	
	<body>
	
<?php
	if(isset($background_color)){
?>
<script>
	$(function(){
		$("#captchaWrapper").css("background-color", "<?php echo $background_color; ?>");
	});
</script>
<?php } ?>
	
	<table width="98%" cellpadding="5" cellspacing="0" border="0">
	
		<tr>
			<!--<td>Captcha:</td>-->
			<td>
				<div id="captchaWrapper">
					<div id="uppercontent">
						<?php echo "<img id='captcha_img' src=\"./securimage.php?sid=".time()."\" />"; ?>
						<a href="javascript:void(0);" onClick='return ResetQuestion();' id="btnReset"><img src="./images/iconRefresh.png" border="0" /></a>
					</div>
					
					<div id="lowercontent">
						<div id="leftPanel">
							<img src="./images/logo.gif" alt="Captcha Stop Spam - Web Design Tool" title="Captcha Stop Spam - Web Design Tool" border="0" />
							<div id="slogan">Captcha Stop Spam<br /><a target="_BLANK" href='http://www.netbizsolutions.com' style="color: black; text-decoration: none;">Web Design</a> Tool</div>
						</div>
						<div id="rightPanel">
							TYPE ANSWER<br />
							<input type="text" name="captcha_result" id="captcha_result" value="" onKeyPress="return isNumberKey(event)" /><div style="font-size: 2px;">&nbsp;</div>
							<input style="inherit: none; font-size: 12px; width: 85px; cursor: pointer;" type="button" name="btnCheckAns" id="btnCheckAns" value="CHECK" onClick="return captchaCheck('captcha_result');" />
							<div style="height: 5px; width: 100%;">&nbsp;</div>
							<div id="captchStatus" style="font-size: 10px;" >&nbsp;</div>											
						</div>
					</div>

				</div>
				
				<script>
					function ResetQuestion(){
						$("#captcha_img").attr("src", "./securimage.php?sid=" + Math.random());
					}
					
					//initialize captcha script
					$(function(){
					
						//alert("aaa");					
						//alert(parent.document.getElementsByTagName('form')[0].innerHTML);
						var counter = 1;
								
						$('form', window.parent.document).each(function(){								
						//parent.$("form").each(function(){
						
							var formHTML = $(this).html();
							//alert(formHTML);
							if(/nbs/.test(formHTML)){
								var formid = $(this).attr("id");
								if(formid == "" || formid == "undefined"){
									$(this).attr('id', 'captcha_form' + counter);
									counter++;
								}
							}
						});
						
						//Disable all submit button
						$('input[type=submit]', window.parent.document).each(function(){																	
							$(this).attr("disabled", "disabled");
						});
						
																		
					});
					
					  function isNumberKey(evt)
					  {
						 var charCode = (evt.which) ? evt.which : event.keyCode
						 if (charCode > 31 && (charCode < 48 || charCode > 57))
							return false;

						 return true;
					  }
					  
					  function captchaCheck(objid){
					  
						$("#captchStatus").empty();
					  
						var value = $("#" + objid).val();
						$.ajax({    
							type: "POST",    
							url: "./checkCaptcha.php",    
							data: "value=" + escape(value),    
							success: function(msg){
								$("#captchStatus").html(msg);
								if(/INCORRECT/.test(msg)){
									//Disable all submit button
									$('input[type=submit]', window.parent.document).each(function(){																	
										$(this).attr("disabled", "disabled");
									});
									
									$("#captcha_result").val('');

									ResetQuestion();
								} else {
									$('input[type=submit]', window.parent.document).each(function(){																	
										$(this).removeAttr("disabled");
									});									
								}
							}  
						});	
						
					  
					  }
					
				</script>
				
			</td>
		</tr>

	</table>
	</body>
</html>	
Return current item: NBSCaptcha