time condition in asp - respect time zone

hey,

i want, that invitations are send between 8 oclock in the morning, and 5 oclock afternoon.

if the thime, is not between these two hours, we don't send a mail

UTC (+1:00) belgium

we don't want, that, hackers, send mails in the night, so, is there a solution, to have a contition, respectiong our time zone?

thx for help, asp or other script, thx

kristof
fedkrisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
just to make sure I understand, you want to send out emails between 8am and 5pm of the users time zone, correct? to do that, you're going to need to know what time zone they reside in and then calculate whether or not they're in the right time frame by using the Now() function to get the current time.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
First, I assume you have an ASP page that is set up for sending mail.  If that is the case you will first want to set up an event in your server's task scheduler to run the page every x minutes or hours between the time frame.  That is if you need it done automatically.

What I do is have a vbs script outside of the public website that gets hit from my task scheduler.  That vbs script does a post to the ASP page and posts some security info.  Then my ASP page looks for the security info before it accepts any input.  

I could  just as easily do all the mail in my vbs script, the reason I don't is I use the ASP page for multiple other public pages.

You can also look for the time in your ASP page and if it is not in the time frame, skip any sending.

<%
if hour(now()) >= 8 and hour(now()) <=17 then
' run my code

end if
%> 

Open in new window

0
fedkrisAuthor Commented:
hey,

the idea is, my question is:

a few days ago, we were hacked, a nights, and we sended empty mails tou people in our database. An idea was, we work from 8 till 17 (afternoon), is there a solution, we can work with timetable (UTC (+1:00) belgium ), if we are not open, anyone that will activate a send command in our sendpage, will refuse the send.

so our members will not receive those fake mails at night anymore.

thx
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
If you are hacked it is not going to matter what time of day, it can be any.  So you want to send some type of password to your mail script.  However, I have given you the script to allow  mail to only be sent during a certain time.  I will paste it again here.
<%
if hour(now()) >= 8 and hour(now()) <=17 then
' run my code

end if
%> 

Open in new window

Note, the now() function is the server time.  If your server time is already set to belgium, then you don't need to do any adjustments. If you need to make an adjustment, you will use the dateadd function.
<%
dim currentTime
' assume you need to add 1 hour to your server time
currentTime=dateadd("h",1,now)

if hour(cdate(currentTime)) >= 8 and hour(cdate(currentTime)) <=17 then
' run my code

end if
%> 

Open in new window

In addition, you can use some type of passcode.  You would use request.form if you submit  a form or request.querystring if you are using a querysting in the url like page.asp?pass=123
<%
if request.querystring("passcode")="abc123" then ' run your code
     dim currentTime
     ' assume you need to add 1 hour to your server time
     currentTime=dateadd("h",1,now)

     if hour(cdate(currentTime)) >= 8 and hour(cdate(currentTime)) <=17 then
         ' run my code

     end if
end if
%> 

Open in new window

A thread on security http://www.experts-exchange.com/Web_Development/Miscellaneous/Q_28214535.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.