批量php到loggoff网站 [英] Batch php to loggoff web site

查看:70
本文介绍了批量php到loggoff网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有一个批处理作业,从windows(使用AT命令)每晚运行一次

,以确保管理员已注销/退出网页

网站管理员面板。如果我登录了,我会发一个类似于

的网址

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


这不是AT命令那就是问题;从命令行php执行此操作的php代码是

。我希望有一个这样的php程序

(称为logoff.php)


< ;?

header(" ;位置:http://mysite.com/cntl.php?action = logout");

?>


并发出如< br $> b $ b php logoff.php

但是,该代码不能从批处理中运行,尽管它可以从浏览器URL中运行

。有什么建议可以实现吗?如果需要套接字

,请发布方法。我也尝试过这种方式但是

似乎无法弄明白。


谢谢。

解决方案

2003年11月3日05:29:58 -0800, gf ****** @ earthlink.net (gf)写道:

我需要一个批处理作业,从windows(使用AT命令)每晚运行一次
以确保管理员已注销/退出网站管理员面板。如果我登录了,我会发一个类似于
的网址

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

这不是AT命令的问题;这是从命令行php执行此操作的PHP代码。我希望有一个像这样的php程序
(名为logoff.php)

<?
标题(" Location:http://mysite.com/cntl .php?action = logout");
?>

并发出命令,如
php logoff.php




header()函数只是发出一个HTTP头,所以只有
才能使用HTTP客户端(比如浏览器)。这是浏览器

解释并处理Location头,而不是PHP。


你需要查看命令行HTTP客户端。一个Windows版本

的lynx可能是合适的。


-

David(@ priz.co.uk)

互联网囚犯数据库: http://www.priz。 co.uk/ipdb/

Tarbrax Chronicle: http ://www.tarbraxchronicle.com/


我可能会误解你,所以如果我走错了方向,我
道歉。

我不太了解套接字,但我相信网络服务器

可能会也可能不会保持与sockets的连接浏览器,所以试图直接向浏览器发出这个URL很难或不可能。当我看到它时,你将很难迫使客户端浏览器接收注销URL,除非:

a )他们最初点击的脚本仍在运行,通过睡眠或其他一些这样的过程空闲机制

b)生成的页面包含一个REFRESH标记,强制它们命中

服务器再次。


a)似乎是一个坏主意,因为你让很多进程运行

不必要
b)如果页面自动刷新,那么你可以让他们在

重新加载同一页面后退出(即表示不活动),或者
$ b一天中的某个时段或两者之后$ b。


希望有所帮助,


Eric

" GF" < GF ****** @ earthlink.net>在留言中写道

新闻:2e ************************** @ posting.google.c om ...

我需要有一个批处理作业,从windows(使用AT命令)每晚运行一次
以确保管理员已经注销/退出网站
网站管理员面板。如果我登录了,我会发一个类似于
的网址

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

这不是AT命令的问题;这是从命令行php执行此操作的PHP代码。我希望有一个像这样的php程序
(名为logoff.php)

<?
标题(" Location:http://mysite.com/cntl .php?action = logout");
?>

并发出命令,比如
php logoff.php

然而,该代码确实如此不是批量工作,虽然它确实可以从浏览器URL工作。有什么建议可以实现吗?如果需要套接字
,请发布方法。我也尝试过这种方式,但似乎无法弄明白。

谢谢。



" GF" < GF ****** @ earthlink.net>在留言中写道

新闻:2e ************************** @ posting.google.c om ...

我需要有一个批处理作业,从windows(使用AT命令)每晚运行一次
以确保管理员已经注销/退出网站
网站管理员面板。如果我登录了,我会发一个类似于
的网址

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

这不是AT命令的问题;这是从命令行php执行此操作的PHP代码。我希望有一个像这样的php程序
(名为logoff.php)

<?
标题(" Location:http://mysite.com/cntl .php?action = logout");
?>

并发出命令,比如
php logoff.php

然而,该代码确实如此不是批量工作,虽然它确实可以从浏览器URL工作。有什么建议可以实现吗?如果需要套接字
,请发布方法。我也尝试过这种方式,但似乎无法弄明白。

谢谢。




你要去关于它是错误的方式。忘记尝试从命令行发送一个HEADER ......没有浏览器可以接收它。你需要简单地用
编写一个可以做你想做的php程序,只输出到

命令行。


试试这个:


1)在你的cntl.php脚本中创建一个名为''forcelogout'的新函数''

2)在这个函数中只输出一个logfile或echo / print(没有html)

3)正常调用函数 -
http://mysite.com/cntl.php?action=forcelogout


swisscheese


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("Location: 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.

解决方案

On 3 Nov 2003 05:29:58 -0800, gf******@earthlink.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("Location: 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/


I may be misunderstanding 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******@earthlink.net> wrote in message
news:2e**************************@posting.google.c om...

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("Location: 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.



"gf" <gf******@earthlink.net> wrote in message
news:2e**************************@posting.google.c om...

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("Location: 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


这篇关于批量php到loggoff网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆