分类为‘PHP’的日志
日期 : 2012年01月6日分类 : PHP作者 : ZZ
通常在LINUX下可以用CRON来完成这项任务,那么在WINDOWS平台可以使用系统自带的任务计划来完成。
WINDOWS的任务计划有一个可视化的管理器,具体位置是“控制面板” - ”任务计划“ (WIN7则是在”控制面板“ – ”管理工具“中)。可视化的管理器使用非常简单,网上也有大堆的教程介绍,我就不细说了。
这里稍微提一下在命令行下的操作,以及如何使用PHP来对其进行操作。
任务计划在命行下的名字为schtasks,其实也就是windows/system32下的一个程序。
创建任务 schtasks /Create /TR taskname /TR taskrun /st starttime /sd startdate
更多的参数和解释可以参照 schtasks /Create /?
修改任务 schtasks /Change /TR taskname …
更多的参数和解释可以参照 schtasks /Change/?
另外还有查询、删除、终止等功能,就不一一列了,运行schtasks /? 会有很详细的帮助,而且都是中文的(当然用英文系统的童鞋就不是了 )
用PHP操作命令行其实非常简单,只需要用到exec函数,那么我们只需要把创建(或改,删)的命令使用exec来执行就OK了。
说到这里,先不要急,事情还没完。当你试图用exec去执行schtasks的时候,发现啥都不会返回,同时也没有按照你的意愿成功的执行任何东西。
我也为这个问题稍稍苦恼了一下,但很快在PHP documentation的评论里找到了答案:
via http://www.php.net/manual/en/ref.exec.php#74897
Scheduling WinXP tasks with schtasks.exe and using PHP to execute the command, may sometime fail to work.
This is because, Apache does not have the privilege to access some of the System Files when placing the scheduling. The way I’d do: is by creating a normal user account and assign Apache service to logon as that account.
Open the ‘services.msc’ in the ‘Run’ window, look for Apache in the listing, right click and get to ‘Properties’. Click at the second tab ‘Log On’ and fill in the ‘This account’ fields.
Of course, Apache needs to be installed as Service during its first setup.
Hope this helps anyone.
Fendy Ahmad
看到这里我想大部分人已经明了了。是因为Apache权限不够的问题,只需要在services.msc里面找到apache服务,然后赋予有对应权限的用户即可。
日期 : 2011年08月1日分类 : PHP作者 : ZZ
这个玩意,用来采集挺好的。别的就不废话了。
项目地址:http://simplehtmldom.sourceforge.net/
简介
- 使用PHP5实现的HTML DOM解析器。让你能够使用PHP5轻松操纵HTML DOM。
- 支持PHP5及以上版本。
- 像jQuery一样使用选择器获取HTML标签。
- 一行代码获取HTML中的内容。
快速入门
1、如何获取HTML节点?
// Create DOM from URL or file $html = file_get_html('http://www.google.com/'); // Find all images foreach($html->find('img') as $element) echo $element->src . '<br />'; // Find all links foreach($html->find('a') as $element) echo $element->href . '<br />';
继续阅读 »
Tags : html dom, php
日期 : 2010年08月16日分类 : PHP, 计算机相关作者 : ZZ
在推上跟mg12大神交流,说到非IE浏览器下面的页面变灰的方法,开始我还以为有类似IE下的滤镜的简单方法实现,没想到居然是改图片改CSS。。。ORZ
于是就写了这个批量转换的脚本,支持GIF动画。大致的原理是将图片逐帧逐像素的读出来,取到RGB色值,然后将当前的色值改成r*0.5+g*0.3+b*0.2,最后替换之即可。需要PHP 5.1.3和PECL Imagick 2.0.0或更高版本。WIN下的Imagick安装可以参照下这儿。 继续阅读 »
Tags : imagick, php
日期 : 2008年06月8日分类 : PHP作者 : ZZ
<?php function genRandomString($len) { $chars = array( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ); $charsLen = count($chars) - 1; shuffle($chars); // 将数组打乱 $output = ""; for ($i=0; $i<$len; $i++) { $output .= $chars[mt_rand(0, $charsLen)]; } return $output; } ?>
Tags : 随机字符串
日期 : 2008年04月3日分类 : PHP作者 : ZZ
//===================================
// 功能:IP地址获取真实地址函数
// 参数:$ip – IP地址
// 作者:[Discuz!] (C) Comsenz Inc.
//===================================
继续阅读 »
Tags : php
|
|