+ Post New Thread
Results 1 to 14 of 14
Internet Related/Filtering/Firewall Thread, block access to single site at certain times in Technical; hope someone can help me out here, i run a website that is based on my companys intronet, i need ...
  1. #1

    Join Date
    Mar 2009
    Location
    gloucester
    Posts
    7
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Unhappy block access to single site at certain times

    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?
    Last edited by ukspooner; 5th March 2009 at 02:12 AM.

  2. #2

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,268
    Thank Post
    884
    Thanked 2,747 Times in 2,321 Posts
    Blog Entries
    11
    Rep Power
    785
    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/...ine-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]]]

  3. #3

    Join Date
    Mar 2009
    Location
    gloucester
    Posts
    7
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    no logons needed

    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 .

  4. #4

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,268
    Thank Post
    884
    Thanked 2,747 Times in 2,321 Posts
    Blog Entries
    11
    Rep Power
    785
    Quote Originally Posted by ukspooner View Post
    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/arch...p/t-37673.html
    <SCRIPT LANGUAGE="JavaScript">
    //Created by MasterShin
    //This is not for commercial use unless I agree
    //To email me on questions or commercial use:
    //shin@mycell.org - Have Fun!
    function am-pm() {
    today = new Date();
    hr = today.getHours();
    if (hr < 12) {
    location.href="am.html"
    }
    else {
    location.href="pm.html"
    }}
    </script>


    Insert in the <body> tag, so it'll look like this:
    <body ... onLoad="am-pm()">

    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...
    Last edited by SYNACK; 5th March 2009 at 02:48 AM.

  5. #5

    Join Date
    Mar 2009
    Location
    gloucester
    Posts
    7
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    permissions for change

    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.

  6. #6

    Join Date
    Mar 2009
    Location
    gloucester
    Posts
    7
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    perfect

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

  7. #7

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,268
    Thank Post
    884
    Thanked 2,747 Times in 2,321 Posts
    Blog Entries
    11
    Rep Power
    785
    Quote Originally Posted by ukspooner View Post
    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:

    Code:
    <SCRIPT TYPE="text/javascript">
    function initArray() {
    	this.length = initArray.arguments.length;
    	for (var i = 0; i < this.length; i++)
    	this[i+1] = initArray.arguments[i];
    }
    
    function am-pm() {
    var weekDayArray = new;
    initArray("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
    var today = new Date();
    var day = weekDayArray[today.getDay()+1];
    hr = today.getHours();
    if ((hr > 18) || (hr < 8) || (day == "Saturday") || (day == "Sunday")) { 
    location.href="rightpage.html"
    }
    else { 
    location.href="blockedpage.html"
    }}
    </SCRIPT>
    Insert in the <body> tag, so it'll look like this:
    <body ... onLoad="am-pm()">

    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
    Last edited by SYNACK; 5th March 2009 at 04:21 AM.

  8. #8

    Join Date
    Mar 2009
    Location
    gloucester
    Posts
    7
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    slight error

    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

  9. #9

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,268
    Thank Post
    884
    Thanked 2,747 Times in 2,321 Posts
    Blog Entries
    11
    Rep Power
    785
    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.

  10. Thanks to SYNACK from:

    ukspooner (5th March 2009)

  11. #10

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,268
    Thank Post
    884
    Thanked 2,747 Times in 2,321 Posts
    Blog Entries
    11
    Rep Power
    785
    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:

    Code:
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    function checktime() {
    today = new Date();
    hr = today.getHours();
    day = today.getDay();
    if ((hr >= 18) || (hr <= 8) || (day == 0) || (day == 6)) { 
    location.href="rightpage.html"
    }
    else { 
    location.href="blockedpage.html"
    }}
    </script>
    </head>
    <body onload="checktime()">
    </body>
    </html>

  12. #11

    Join Date
    Mar 2009
    Location
    gloucester
    Posts
    7
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    wow

    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

  13. #12

    Join Date
    Mar 2009
    Location
    gloucester
    Posts
    7
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Unhappy evening

    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,

  14. #13
    teddybear's Avatar
    Join Date
    Jan 2009
    Location
    Scotland
    Posts
    179
    Thank Post
    48
    Thanked 39 Times in 30 Posts
    Rep Power
    18
    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.

  15. #14

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,268
    Thank Post
    884
    Thanked 2,747 Times in 2,321 Posts
    Blog Entries
    11
    Rep Power
    785
    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:

    Code:
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    function checktime() {
    today = new Date();
    hr = today.getHours();
    day = today.getDay();
    if (!((hr >= 18) || (hr <= 8) || (day == 0) || (day == 6))) { 
    location.href="blockedpage.html"
    }}
    </script>
    </head>
    <body onload="checktime()">
    </body>
    </html>
    Then if it is outside the hours that you want it is redirected to blockedpage.html, if not it lets the page load normaly.



SHARE:
+ Post New Thread

Similar Threads

  1. site to block
    By davyboi in forum General Chat
    Replies: 8
    Last Post: 8th October 2008, 01:23 PM
  2. Online Messanger site to block
    By here_hare_here in forum Network and Classroom Management
    Replies: 1
    Last Post: 21st February 2007, 10:27 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •