473,811 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Batch php to loggoff web site

gf
I need to have a batch job, from windows (using AT command) to run
once per night to ensure that admins have logged off/out of the web
site admin panel. If I were logged in, I would issue a url similar to
this

http://mysite.com/cntl.php?action=logout

It's not the AT command that's the issue; it's the php code to do this
from command line php. I would expect to have a php program like this
(called logoff.php)

<?
header("Locatio n: http://mysite.com/cntl.php?action =logout");
?>

and issue a command like
php logoff.php

However, that code does not work from batch, although it does work
from a browser url. Any suggestions to accomplish this? If sockets
are required, please post the method. I have tried that way too but
can't seem to figure it out.

Thanks.
Jul 17 '05 #1
10 3545
On 3 Nov 2003 05:29:58 -0800, gf******@earthl ink.net (gf) wrote:
I need to have a batch job, from windows (using AT command) to run
once per night to ensure that admins have logged off/out of the web
site admin panel. If I were logged in, I would issue a url similar to
this

http://mysite.com/cntl.php?action=logout

It's not the AT command that's the issue; it's the php code to do this
from command line php. I would expect to have a php program like this
(called logoff.php)

<?
header("Locati on: http://mysite.com/cntl.php?action =logout");
?>

and issue a command like
php logoff.php


The header() function simply issues an HTTP header and so will only
work with an HTTP client (like a browser). It is the browser that
interprets and acts upon the Location header, not PHP.

You'll need to look at a command-line HTTP client. A windows version
of lynx may be suitable.

--
David ( @priz.co.uk )
The Internet Prisoner Database: http://www.priz.co.uk/ipdb/
The Tarbrax Chronicle: http://www.tarbraxchronicle.com/
Jul 17 '05 #2
I may be misunderstandin g you, so if I'm off in the wrong direction, I
apologize.
I'm not that knowledgeable about sockets, but I believe that the web server
may or may not have kept its connection to the browser, so trying to
directly issue that URL to the browser can be difficult or impossible. As I
see it, you're going to have a very hard time forcing client browsers to
receive the logoff URL unless:
a) the script they originally hit is still running, via sleep or some such
process idling mechanism
b) the page that's generated contains a REFRESH tag forcing them to hit the
server again.

a) seems like a bad idea because you leave a lot of processes running
needlessly
b) if the page autorefreshes, then you can just have them logout after a
certain time reloading the same page (i.e., an indication of inactivity), or
after a certain time of day or both.

Hope that helps,

Eric
"gf" <gf******@earth link.net> wrote in message
news:2e******** *************** ***@posting.goo gle.com...
I need to have a batch job, from windows (using AT command) to run
once per night to ensure that admins have logged off/out of the web
site admin panel. If I were logged in, I would issue a url similar to
this

http://mysite.com/cntl.php?action=logout

It's not the AT command that's the issue; it's the php code to do this
from command line php. I would expect to have a php program like this
(called logoff.php)

<?
header("Locatio n: http://mysite.com/cntl.php?action =logout");
?>

and issue a command like
php logoff.php

However, that code does not work from batch, although it does work
from a browser url. Any suggestions to accomplish this? If sockets
are required, please post the method. I have tried that way too but
can't seem to figure it out.

Thanks.

Jul 17 '05 #3
"gf" <gf******@earth link.net> wrote in message
news:2e******** *************** ***@posting.goo gle.com...
I need to have a batch job, from windows (using AT command) to run
once per night to ensure that admins have logged off/out of the web
site admin panel. If I were logged in, I would issue a url similar to
this

http://mysite.com/cntl.php?action=logout

It's not the AT command that's the issue; it's the php code to do this
from command line php. I would expect to have a php program like this
(called logoff.php)

<?
header("Locatio n: http://mysite.com/cntl.php?action =logout");
?>

and issue a command like
php logoff.php

However, that code does not work from batch, although it does work
from a browser url. Any suggestions to accomplish this? If sockets
are required, please post the method. I have tried that way too but
can't seem to figure it out.

Thanks.


You are going about it the wrong way. Forget trying to send a HEADER from
the command line... there's no browser to receive it. You need to simply
write a php program that will do what you want and only output to the
command line.

Try this:

1) create a new function in your cntl.php script called 'forcelogout'
2) in this function output only to a logfile or with echo/print (no html)
3) call the function as normal -
http://mysite.com/cntl.php?action=forcelogout

swisscheese
Jul 17 '05 #4
gf
Thanks for the replies thus far. A clarification though. I understand that
that the header() function does not work in batch. I only used that to
indicate the TYPE of thing I am after.
Jul 17 '05 #5
gf wrote:
I need to have a batch job, from windows (using AT command) to run
once per night to ensure that admins have logged off/out of the web
site admin panel. If I were logged in, I would issue a url similar to
this

http://mysite.com/cntl.php?action=logout

It's not the AT command that's the issue; it's the php code to do this
from command line php. I would expect to have a php program like this
(called logoff.php)

<?
header("Locatio n: http://mysite.com/cntl.php?action =logout");
?>

and issue a command like
php logoff.php

However, that code does not work from batch, although it does work
from a browser url. Any suggestions to accomplish this? If sockets
are required, please post the method. I have tried that way too but
can't seem to figure it out.


What you want to do isn't really possible. As I understand it you don't
want admins walking away from their pcs leaving an admin webpage up for
other people to mess about with. In reality there's nothing you can do
about the workstation/web browser, the server has no control over that
end. What you will have to do is implement some form of timeout at the
server end to re-request the admin password before performing any action.

If you use sessions or cookies to identify logged in users then you
should be able to do this by manipulating the expiry times. I use
cookies to identify users. Ordinary users get a fresh 30 day cookie with
every page. The administrator logon only gets a 10 minute one.

Jul 17 '05 #6


What you want to do isn't really possible. As I understand it you don't
want admins walking away from their pcs leaving an admin webpage up for
other people to mess about with. In reality there's nothing you can do
about the workstation/web browser, the server has no control over that
end. What you will have to do is implement some form of timeout at the
server end to re-request the admin password before performing any
action.

If you use sessions or cookies to identify logged in users then you
should be able to do this by manipulating the expiry times. I use
cookies to identify users. Ordinary users get a fresh 30 day cookie with
every page. The administrator logon only gets a 10 minute one.


Enable session management for a short period of time, e.g. 10 minutes, and
insert into the <head> section of your HTML an HTTP-equiv refresh:

<meta http-equiv="REFRESH" content="605; URL=/" />

i.e. the page will refresh itself 10 minutes plus 5 seconds after first
loading. Given that the session will have expired 5 seconds beforehand, it
will therefore log you out.

Martin Lucas-Smith www.geog.cam.ac.uk/~mvl22
www.lucas-smith.co.uk
Jul 17 '05 #7
gf
Martin Lucas-Smith <mv***@cam.ac.u k> wrote in message news:<Pi******* *************** *************** @red.csi.cam.ac .uk>...
What you want to do isn't really possible. As I understand it you don't
want admins walking away from their pcs leaving an admin webpage up for
other people to mess about with. In reality there's nothing you can do
about the workstation/web browser, the server has no control over that
end. What you will have to do is implement some form of timeout at the
server end to re-request the admin password before performing any
action.

If you use sessions or cookies to identify logged in users then you
should be able to do this by manipulating the expiry times. I use
cookies to identify users. Ordinary users get a fresh 30 day cookie with
every page. The administrator logon only gets a 10 minute one.


Enable session management for a short period of time, e.g. 10 minutes, and
insert into the <head> section of your HTML an HTTP-equiv refresh:

<meta http-equiv="REFRESH" content="605; URL=/" />

i.e. the page will refresh itself 10 minutes plus 5 seconds after first
loading. Given that the session will have expired 5 seconds beforehand, it
will therefore log you out.


Thanks Martin (and others). This will work in the event they leave
the browser open. However, I never stated that. My issue is that the
cookie is left on their machine and regardless of whether they leave
their browser open or closed the cookie allows them to stay logged in.
I know I can alter the cookie expire time and that is an option.
However, I don't want it expiring while they are in the middle of
something, so I avoid that. What I want is a way to automatically
schedule an offline job that will expire the cookie, log off the
browser, do whatever is necessary so that at 21:00 hours, as an
example, ALL sessions are timed out.
Jul 17 '05 #8
> Thanks Martin (and others). This will work in the event they leave
the browser open. However, I never stated that. My issue is that the
cookie is left on their machine and regardless of whether they leave
their browser open or closed the cookie allows them to stay logged in.
I know I can alter the cookie expire time and that is an option.
However, I don't want it expiring while they are in the middle of
something, so I avoid that. What I want is a way to automatically
schedule an offline job that will expire the cookie, log off the
browser, do whatever is necessary so that at 21:00 hours, as an
example, ALL sessions are timed out.


Simply set the cookie expire time so that it expires at 21:00 hours. It
takes a little calculation but entirely possible.

In my case with 10 min cookies I reissue another 10 min cookie on each
request. That only catches people who walk away from their pc (and lazy
bastards!).

Jul 17 '05 #9
On 4 Nov 2003 06:41:46 -0800, gf******@earthl ink.net (gf) wrote:
Martin Lucas-Smith <mv***@cam.ac.u k> wrote in message news:<Pi******* *************** *************** @red.csi.cam.ac .uk>... I know I can alter the cookie expire time and that is an option.
However, I don't want it expiring while they are in the middle of
something, so I avoid that. What I want is a way to automatically
schedule an offline job that will expire the cookie, log off the
browser, do whatever is necessary so that at 21:00 hours, as an
example, ALL sessions are timed out.


In your scripts, check if the time is between, say 08:00 and 21:00. If
so, allow the script to continue as normal, otherwise display an
appropriate message and run your logoff function.

If the user has closed their browser or does not refresh the page, you
can't remove the cookie.

Controlling users' login status will be flimsy at best as they're not
actually logged into anything. You only know if the user is "still
there" when they request a new page from the server. They could have
closed their browser, switched off their machine and gone home for the
night and you'll never know about it.

I think the best you can do is the time check above, and setting the
cookie to expire ten minutes ahead. As long as the user is active, the
cookie will keep getting reset. After ten minutes of inactivity the
user will need to log in again. Many sites work like this. And after
9pm the system can't be used anyway.

--
David ( @priz.co.uk )
The Internet Prisoner Database: http://www.priz.co.uk/ipdb/
The Tarbrax Chronicle: http://www.tarbraxchronicle.com/
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
47549
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup) 4) Once the copy is complete, the batch file opens the Access database again 5) EXIT should close out the cmd window but it does not execute that line
3
1247
by: Oscar Thornell | last post by:
Hi, Any suggestions on best practices on implementing batch process functionality in a web app? The idea is to run a batch of order processing at night when the site load is low. I would like to contain the logic within the web application for deployment reasons.. An event has to be fired at a specific time or other threeshold.
6
11240
by: Charles Neitzel | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS batch files, the batch files in turn run program installers (specifically windows update runtime .exe...
1
3208
by: Charles | last post by:
I'm trying to write a windows application in C# (Using Microsoft Visual C# 2005 Express) that is nothing more than a simple UI with buttons on it. The buttons do various things like running programs and executing registry entries. The majority of my buttons work however, I have come upon a problem. I need a few of the buttons to run DOS batch files, the batch files in turn run program installers (specifically windows update runtime .exe...
13
5445
by: MLH | last post by:
I have a batch file named GetConf.bat. It contains a line like this: ipconfig /all >c:\MyAppDir\IPdata.txt I believe I could run the line with something like ShellWait by Terry Kreft. Any reason I should run the procedure via a batch file call as opposed to launching the command string directly?
7
7901
by: mark.a.lemoine | last post by:
Our application currently interfaces to SQL Server and Oracle, we're implementing it into DB2 currently and I have a question to ask. First a little background - We're interfacing into DB2 v8 on zOS (I hope the terminology is right - ours is a Windows client app, and the DB2 is at a customer site and they are taking care of the server), using ADO with the IBM OLE Db Provider (IBMDADB2). We don't use any vendor specific APIs, instead we...
1
3856
benchpolo
by: benchpolo | last post by:
I'm not sure if this is the right section to post my question regarding FTP Batch scripting. Question? I have multiple textfiles where the filename is dynamically changing daily. For example, Member_20071014.txt, Member_20071015.txt, Member_20071016.txt. These files are produced daily, how do I write a batch script that will pick-up the current date text file to upload on an FTP site. I tried to research windows batch file scripting,...
7
1456
by: googletired | last post by:
Hello, I have a content site. On this site a user can select a peice of content then have it e-mailed to there e-mail address. Then they continue the process for each item they wish to have e-maile dto them. My question is. If i want them to be able to batch select the items they want to recieve instead of 1 at a time, would I have to go about this with a shopping cart routine? or is there a simpler way that I am just over looking? ...
14
12835
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in case it's a question, i want to popup a messageBox or something, and bring back to the batch file the result (Yes\No question). I know how to excute the batch file and get all the Standard output at the end, but i don't know who can i read it line by...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10393
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.