Jump to content

Recommended Posts

Posted (edited)

hope someone can help me out here,

 

i run a website that is based on my companys intronet,

i need to restrict access to the site by all staff untill 6pm on weekdays only,

does anyone know if this is possible? if so is there a script out there?

Edited by ukspooner
Posted

Is the site an active one that uses some form of programable language like ASP.NET or PHP and does it require a logon. You could probably alter the internal code to check the time and allow or disallow which would be the cleanest solution.

 

Alternativly you could schedule a task to disable that particular site in IIS at 6 then another task to switch it back on again when required:

 

http://dirkvandenberghe.com/archive/2008/07/28/iis-management-commandline-tools.aspx

%SystemRoot%\System32\IIsWeb.vbs

IIsWeb.vbs is used to stop, start, pause, delete, or query the Web service, or create a Web site.This tool uses WMI. It can be run remotely on any machine that supports WMI, but it must be passed the name of a server running IIS 6.0 or later.

(applies to IIS 6.0)

I finally stopped the website with the following command: cscript.exe iisweb.vbs /stop Probe (where Probe is the name of my website to stop).

 

Using IIS Command-Line Utilities to Manage IIS

To start, stop, delete, or pause a Web site, use:

 

iisweb[.vbs] {/delete | /start | /stop | /pause} WebSite [WebSite...] [/s Computer [/u [Domain\]User [/p Password]]]

WebSite, the name of the Web site which should be deleted, started, stopped, or paused.

/s Computer, used to indicate that the script should run on this remote computer. The local computer is used by default.

/u [Domain\]User, the account credentials that must be used to delete, start, stop, or pause the Web site on the remote computer.

/p Password, the password of the account credentials (above).

 

To query Web sites on your IIS servers, use

 

iisweb[.vbs] /query [WebSite [WebSite...]] [/s Computer [/u [Domain\]User [/p Password]]]

Posted

the site is active throughout the company, and was completely designed using frontpage.

 

staff do not require a logon to access the site,

the company is very strict with its access to servers,

what i need is something i can simply slip in to the html .

Posted (edited)

the company is very strict with its access to servers,

what i need is something i can simply slip in to the html .

 

Not likely, html is not an active programable language and so the best you could do would be a javascript that runs on the clients browser that refreshes the page to something different if the local time is outside your range. This requires the user to have javascript enabled, the right time on their local computers clock and no extra security or block on the browsers security which would likely prevent this kind of script from working by default.

 

Surely if you have the rights to alter the site you would be able to ask the administrators of your servers to add in the required scheduled task. The javascript may work but is easily bypassable and is really a flawed solution.

 

Re-writing is ASP, as long as it is enabled on the server would not be to tricky, merely adding the time restriction code to each page and renaming it to a .ASP file. Frontpage can edit them as well, but the scheduled task would be way quicker if you want to keep the site exactly as is.

 

Edit: Here is some javascript that would do it:

http://board.flashkit.com/board/archive/index.php/t-37673.html

 

 

Insert in the

tag, so it'll look like this:

 

I haven't tested it, but in theory it should work.

Change the am.html and pm.html to the pages you want it to be redricted...

Edited by SYNACK
Posted

getting permission from admin can take some time,

do you know where i can get a javascript for the time being, to be honest im not to worried about how easy it is to bypass as the staff veiwing this website will have praticlly no knowledge of html ,java,or anything they probably dont even know how to view source code ;)

 

re-writing in asp will be the preferred choice in the end i think but a quick solution is desperatly needed.

Posted (edited)
sorry my mistake, i need the site to be accessable all weekend and between 6pm and 8am monday to friday.

 

Slight code change as below should do the trick:

 

<br />
function initArray() {<br />
	this.length = initArray.arguments.length;<br />
	for (var i = 0; i < this.length; i++)<br />
	this[i+1] = initArray.arguments[i];<br />
}<br />
<br />
function am-pm() {<br />
var weekDayArray = new;<br />
initArray("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");<br />
var today = new Date();<br />
var day = weekDayArray[today.getDay()+1];<br />
hr = today.getHours();<br />
if ((hr > 18) || (hr < 8) || (day == "Saturday") || (day == "Sunday")) { <br />
location.href="rightpage.html"<br />
}<br />
else { <br />
location.href="blockedpage.html"<br />
}}<br />

 

Insert in the

tag, so it'll look like this:

 

I have not tested it but it should do the trick

 

Edit: Misred, have edited to be correct. THought you wanted it from 8am till 6pm rather than excluding it

Edited by SYNACK
Posted

not working im afraid,

keep getting a couple of script errors

"am is undefined"

and "{" is expected on line 14 which is for (var i = 0; i < this.length; i++)

any ideas

Posted
Not sure to be honest, personally I hate javascript as debugging it is absolutely retarded and dependent on the browser. Someone else should be able to clean up my code tommorow when the rest of the forum members wake up though.
  • Thanks 1
Posted

Strike that, I have cleaned up the code and tested it in IE and Opera, It does require the user to accept to run it in IE7 as I expected but it does work:

 


<br />
function checktime() {<br />
today = new Date();<br />
hr = today.getHours();<br />
day = today.getDay();<br />
if ((hr >= 18) || (hr <= 8) || (day == 0) || (day == 6)) { <br />
location.href="rightpage.html"<br />
}<br />
else { <br />
location.href="blockedpage.html"<br />
}}<br />




Posted

thats certainly is cleaned up lol

ill be finishing my shift soon so will put it to the test tommorow evening.

will let you know how i get on

Posted

hiya mate, i just tried the the new script out and its now working at all, it just redirects to 404 page.

i have had a look to see if there is anything obvious that stands out to me but cant see anything,

Posted

Sorry if this is obvious, but have you created a couple of new pages called blockedpage.html and rightpage.html?

 

Looks like the code redirects to them, you will be getting the 404 error if it can't find the pages.

Posted

Yeap I had it setup as a gateway page that directed to either rightpage or blocked page depending on the time. I had a better look at it and what you want to do is have this at the top of every restricted page:

 


<br />
function checktime() {<br />
today = new Date();<br />
hr = today.getHours();<br />
day = today.getDay();<br />
if (!((hr >= 18) || (hr <= 8) || (day == 0) || (day == 6))) { <br />
location.href="blockedpage.html"<br />
}}<br />




 

Then if it is outside the hours that you want it is redirected to blockedpage.html, if not it lets the page load normaly.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...