Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Restrict internet access with .htm file  (Read 7775 times)

0 Members and 1 Guest are viewing this topic.

Kyle

  • Guest
Restrict internet access with .htm file
« on: June 26, 2004, 03:39:25 PM »
I typed in a little code that some of you might like. It is used so that people must enter in a password using a script prompt, and then it redirects them in a few seconds. I typed in the code below. copy it and save it into your comp as "something.htm" and then  copy its location as your home page. To make it redirect to your homepage and make your password, type them in where I put "ENTER PASSWORD" or "ENTER HOME PAGE HERE" . (NOTE: It also prevents right click during the r seconds where you are redirecting so it takes more time to view source, so others probably won't edit it.)

Code: [Select]
<HTML>
<HEAD>
<TITLE>Log Onto The Internet</TITLE>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
body {
  color: black;
  background: white;
  font: bold 18pt Verdana, Arial, Helvetica, sans-serif;
  text-align: center;
}

div.counter {
  margin-top: 20px;
  color: blue;
  font-size: 60pt;
  cursor: default;
}

div.info {
  margin: 0 auto;
  text-align: left;
  font-size: smaller;
  width: 80%;
  margin-top: 2em;
}
</style>


<script language="JavaScript">

function coolRedirect(url, msg)
{
  var TARG_ID = "COOL_REDIRECT";
  var DEF_MSG = "Redirecting...";

  if( ! msg )
  {
     msg = DEF_MSG;
  }

  if( ! url )
  {
     throw new Error('You didn\'t include the "url" parameter');
  }


  var e = document.getElementById(TARG_ID);

  if( ! e )
  {
     throw new Error('"COOL_REDIRECT" element id not found');
  }

  var cTicks = parseInt(e.innerHTML);

  var timer = setInterval(function()
  {
     if( cTicks )
     {
        e.innerHTML = --cTicks;
     }
     else
     {
        clearInterval(timer);
        document.body.innerHTML = msg;
        location = url;        
     }

  }, 1000);
}
</script>

<script language="JavaScript">
<!-- Hide

var message = "No right click!";

function clickIE(){
if (event.button == 2){
alert (message);
return false;
}
} function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which == 2 || e.which == 3){
alert (message);
return false;
}
}
}
if (document.layers){
document.captureEvents (Event.ONMOUSEDOWN);
document.onmousedown = clickNS4;
}
else if (document.all){
document.onmousedown=clickIE;
}
document.oncontextmenu = new Function("alert(message); return false;");


//-->
</script>


<script language="JavaScript">
var password = "ENTER THE PASSWORD IN HERE BETWEEN THE QUOTES!";
var answer;
while (answer != password){
answer = prompt("Enter the password to run the Internet.", "");
}
</script>


</HEAD>
<BODY onload='coolRedirect("ENTER YOUR HOME PAGE HERE BETWEEN THE DOUBLE QUOTES!")'>
 
 
<div class="info"> You will be redirected in...</div>  
   
<div class="counter" id="COOL_REDIRECT">2</div>
</BODY>
</HTML>




Joleen

  • Guest
Re: Restrict internet access with .htm file
« Reply #1 on: June 28, 2004, 07:12:43 AM »
Great post but you might want it in the Website Design forum where it'll be of the most use to coders.  Just a thought.

JBravo

  • Guest
Re: Restrict internet access with .htm file
« Reply #2 on: June 30, 2004, 12:59:49 PM »
This is a nice script and it's the best one I've run across that's useable on servers without cgi or php support.
I've used it on my own webpage (ftp server) and with my IE 6.0 SP1 (fully updated - JVM v.5.00.3810 - Winme) it stops when the redirect begins and that's as far as it will go. Locally, on my computer, it works fine.
Using Firefox 0.8 (javascript enabled - SunJava not installed) it works perfectly both locally and on the server.
Another difference between the two browsers is that with IE the page from which I link to the password page turns blank when the password box pops up and with Firefox it doesn't.
I tried putting the domain of my webpage in IE's Trusted Sites Zone so all java is enabled and I also tried changing the value for the time of the redirect (I know very little of scripting) to "0" and removing it completely - same results.
No error messages or other apparent problems..
I wanted to let you know my experience - for whatever it's worth - and, who knows, perhaps someone will come along with a clue for me. I'd love to use it with IE.
Thanks for the script.

JBravo

  • Guest
Re: Restrict internet access with .htm file
« Reply #3 on: June 30, 2004, 01:30:08 PM »
Well, I found the problem. I needed to disable Adshield. I should have thought of that right away.
Glad I signed up anyway and thanks again to Kyle.

merlin

  • Guest
Re: Restrict internet access with .htm file
« Reply #4 on: July 01, 2004, 05:08:55 PM »
and there is this>http://www.snapfiles.com/freeware/security/fwaccess.html   peopel are lazy kyle but its a good code maybe you should convert it to a software download zip file..food for thought..