ThunderAI Posted June 15, 2008 Share Posted June 15, 2008 in the php help section there is a topic about preventing direct access to a php file unless it is in an iframe. in order to tell this i used this function. <script> var youraterrorist if (top.location == self.location) { alert('your bad'); document.write('your bad'); youraterrorist = 1; } else { alert('your good'); youraterrorist = 0; } </script> is it possible for the javascript to actally terminate the rest of the file if this test fails? Link to comment https://forums.phpfreaks.com/topic/110298-can-a-javacript-function-terminate-a-php-script/ Share on other sites More sharing options...
bearruler Posted June 15, 2008 Share Posted June 15, 2008 JavaScript is executed by the web browser after the entire page has loaded. You could just send them to a different location, but they could easily get around it by disabling JavaScript. If you want to keep someone out of somewhere, use server-side authentication. Bruce Link to comment https://forums.phpfreaks.com/topic/110298-can-a-javacript-function-terminate-a-php-script/#findComment-565968 Share on other sites More sharing options...
ThunderAI Posted June 15, 2008 Author Share Posted June 15, 2008 JavaScript is executed by the web browser after the entire page has loaded. You could just send them to a different location, but they could easily get around it by disabling JavaScript. If you want to keep someone out of somewhere, use server-side authentication. Bruce Is just checking the value in a session user id ok. I was able to do that and everything works how i want it to; however, would there be a better way? Link to comment https://forums.phpfreaks.com/topic/110298-can-a-javacript-function-terminate-a-php-script/#findComment-566006 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.