Need help on php Scripts

hey guys ive been trying to research about a php scripts that disables “alt tabbing” when you open the web page. Weve been trying to create an Online Examinaion System using php script, and for our security, disabling alt tab to prevent Users to “google” the answers… Any help? Also new opinion on its security is also welcome and appreciated… thanks :slight_smile:

It probably won’t work unless you’re in control of the computers that are being used for an exam, if two different browsers are available, eg IE and FF then the other one could be used to google the answer. Also with the way that chrome opens a new process for each window that might make it harder to stop

You cannot control the browser in this way but you may use some javascript.
Here it is a copy-paste example.
However, you also need a protection for the javascript-disabled action (an ajax request each X seconds to check that the javascript is still on. If not, set test as failed)


<html>
<head>
	<title>Exam</title>
	<style type="text/css">
		html { background:#fff }
		body { background:#eee; }
	</style>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>

<body>
<p id="hei" style="display:none">Get back to the page! Remained: <span id="rem"></span></p>
<br /><br /><br /><br /><br /><br /><br />The test here<br /><br /><br /><br /><br /><br /><br />

<script>
	var intv = 0;
	var counter = 0;
	var maxAllowedSeconds = 10;
	function startCounter() {
		$('#hei').show();
		counter = 0;
		$('#rem').html(maxAllowedSeconds);
		intv = setInterval(function(){
			counter++;
			$('#rem').html( parseInt(maxAllowedSeconds) - parseInt(counter) );
			if( counter > maxAllowedSeconds ) {
				location.href = 'http://www.google.com';
			}
		}, 1000);
	}
	function resetCounter() {
		$('#hei').hide();
		clearInterval(intv);
		counter = 0;
	}

	$('body')
		.mouseenter(function(){ resetCounter(); })
		.mouseleave(function(){ startCounter(); })
	;
</script>

</body>

</html>

@victorial:thanks man… ill try this one… do i still need to download something?i got notepad[i dont really use other ones], phpmyadmin for database, and xamp…
@spacephoenix: how can they open new browsers if they cant alt tab when they start the script xD
if you guys know a better security for this system. please pm me. this is for our thesis :)) and we got a defense on it next week…

Windows and Tabs are in the control of the user not the website. for security reasons.

IMHO the best solution is probably doing something like odesk does for it’s online proficiency tests. i.e.

The user is sequentially presented a number of random questions from a larger pool of questions.
The test session is time limited

The user could approach it as an “open book” test - but - since there is no foreknowledge of what the questions will be they can’t be researched beforehand. and time taken to do research will result in later questions going unanswered and considered “wrong”.

thats our other option in mind… could it be possible to time limit each question in a php script?..can you send me a sample script? im kinda new to php, so , i only know the basics…

I don’t have a sample script, I’d need to write it, which I don’t have time for now.

You could have one or more SESSION variables, eg. one for each question, one for the overall test.

I would store the SESSION variable in a database that has a “time” field. checked on the subsequent page and compared with “now”. If “less than X” OK, else “too long”.

thanks… btw is this online examination is existing already?.. i see many online exams but no databases…
need also some unqie features…

Even if you could fully lock down the user’s computer, how will you stop students from alt-tabbing to their iPhones. :wink:

I think Mittineague’s alternative approach is the only approach that will do any good.

It’s true that “time limited tests” is the safest method but you must design your questions in this way
so on a simple google search you will not get relevant results.

What are your questions about?

However, the javascript needs protection (it can be disabled) and a complex development.
The session timed development is way simpler to develop.