php防止快速刷新的方法
作者:admin 日期:2010-08-30
今天在鼓捣fetion api的时候网上找到的,感觉挺好用。tie贴出来分享。
<?php
session_start();
$allow_sep = "20";
if (isset($_SESSION["post_sep"]))
{
if (time() - $_SESSION["post_sep"] < $allow_sep)
{
exit("你的速度是否似乎超出我的处理能力了^_^!");
}
else
{
$_SESSION["post_sep"] = time();
}
}
else
{
$_SESSION["post_sep"] = time();
}
?>
如何让php,asp页面自动运行?
作者:admin 日期:2010-08-30
最近迷上fetion API,想通过fetion API让电脑自动给自己及好友发天气预报,网上鼓捣了很久,终于实现php给自己发天气预报了,可是如何才能使php页面自动运行呢?很多说用windows的任务计划,添加php.exe和文件路径的方式能运行php程序,我试了n遍,发现没有一种方法php页面还是不能运行,后再想到能否采用客服端自动申请php、asp页面,让服务器自动解析php、asp页面呢?鼓捣了半天,终于实现了。虽然办法貌似有点老土,不过还是挺管用的。
方法如下:
1、先建一个如下的vbs脚本文件:
Dim IE
Set IE = CreateObject("InternetExplorer.Application")
e.navigate("http://url.com/auto.php")
ie.visible=1
Set IE = Nothing
2、在上述auto.php文件中加入自动关闭ie的js程序,如下:
<script language=javascript>
window.opener=null
window.open("","_self")
window.close();
</script>
3、用windows的任务计划定时执行1中vbs文件,程序自动打开ie访问http://url.com/auto.php页面,服务器解析后返回浏览器,再自动运行2中js关闭ie程序,达到自动运行php的目的。
只有自动运行asp文件,呵呵,不用我多说,应该会了吧。
php判断远程文件是否存在
作者:admin 日期:2010-08-30
<?php
function check_file($host,$file)
{
$fp = fsockopen($host, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "HEAD /$file HTTP/1.1\r\n";// or $out = "HEAD /index.xxx HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
$response = explode(" ",fgets($fp, 128));
fclose($fp);
return $response[2];
}
}
echo check_file('huikon.cn','index.php');
?>
本函数用于判断远程文件是否存在。
广告位