2006-10-16 作者:佚名 来源:清风网络学院 点击:1444
今天教第二天.
有个朋友说的好‚其实教功夫也是变相的教你怎么杀人‚可是不说出来.
所以这个教程从下一篇开始就改个名字
叫<远程操作对方数据程序>有点土比小偷好听
第二天.
教几个函数给大家.
1 读取判断函数
2 更新cache函数
3 写入文件函数
4 切割字符函数
5 读取字符函数
---------------------------------------------------
在我们想写之前我们先要做好准备‚构思一下怎么去写.
制作前构思1
我们打开华军首页
http://www.onlinedown.net/
经过我们统计‚是不是发现它的连接有个很相同的规则?
1 根目录的index.htm文件
2 soft文件夹的 1.htm .......30000.htm
3 sort文件夹的 1_1.htm 200_1.htm
4 a-z文件夹 1.htm ....200.htm
到此我们可以想好一个打开函数‚不是根目录 就是文件夹/名字
只有2中可能.
制作前构思2
为了让速度更快‚我们最好把内容读过来存储起来.
1 减少了对对方站点的请求.
2 提供了速度.
这里我们判断这个文件写入的时间为准 我们自己设置一个时间
当写入时间 和现在的时间比一下‚如果在我们的设置时间内的话.就是可以.
如果不在比如
文件写入时间 2004年5月18好 06:00 我们现在时间是2004年5月19号 18:00
我们设置时间是1个小时
当再次请求这个文件的时候 他发现已经过期了.就会重新向对方请求一次并且存入.
制作前构思3
为了以后频繁的操作简单话‚把固定的操作写进一个函数.
切割字符.
一般切割就是 从第一个位置 切割到第二个位置 然后取中间部分
比如:
<html>
<head>
<title>演示站点</title>
</head>
<body>
</body>
</html>
从<title>开始切割到</title>
那切割出来的 就是 "演示站点"4个字
如果说‚可以找到 几个 <title>怎么办?程序会从第一处开始切割
到这里构思差不多..
程序要干净明了才行‚不要这一个文件不知道什么‚那一个文件不知道哪来.
所以‚如果你以后有做大站的机会的话‚文件夹‚文件一定要写的清楚‚分的清楚.
既然明白了构思‚我们就开始动手做了.
建立我们第一个PHP文件:
你可以用记事本‚可以用Dreamweaver也可以用专用PHP编辑软件
取名字为 commom.php
内容为
------------------------
<?php
include './config.php';
include './global.php';
?>-----------------------
这个文件有什么用?就是在以后操作中直接 inclue 这个文件就可以用到所有的函数啊什么的
然后config.php是设置 URL 刷新时间 等等
global.php是 所有函数的文件
也就是今天要给教给大家的!
第一个个函数 open
-------------
function open($file‚$type=''){
global $fromurl‚$referer;
$cachename=$file;
if($type){
$file=$fromurl.'/'.$type.'/'.$file;
}else{
$file=$fromurl.$file;
}
if($open=file($file)){
$count=count($open);
for($i=0;$i<$count;$i++){
$theget.=$open[$i];
}
}else{
die('请求过多,超时,请刷新');
}
return $theget;
}
----------------
解释过了‚连接地址就2中请求‚根目录‚和 文件夹/名字
函数怎么用法等等‚不多说了.建议大家下载译本PHP中文手册看看.
第二个函数
根据设置时间更新cache目录文件函数 update
---------------
function update($file‚$type=''){
global $timestamp‚$flush;
if(!file_exists("cache/$file")){
if($type){
$data=open($file‚$type);
}else{
$data=open($file);
}
writetofile("cache/$file"‚$data);
}else{
$lastflesh=@filemtime("cache/$file");
if($lastflesh + ($flush * 60) < $timestamp ){
if($type){
$data=open($file‚$type);
}else{
$data=open($file);
}
writetofile("cache/$file"‚$data);
}
}
}
--------
简单解释
$data=open($file‚$type);就是用到上面的 open函数了
如果我们用 udate("index.htm");
那不就是用到了 update函数吗? 明白吗?
上面出现了writetofile函数 下面是代码
------------------------------
function writetofile($file_name‚$data‚$method="w") {
if($filenum=fopen($file_name‚$method)){
flock($filenum‚LOCK_EX);
$file_data=fwrite($filenum‚$data);
fclose($filenum);
return $file_data;
}else{
return false;
}
}--------------------------------
切割字符函数
------------------------
function cut($file‚$from‚$end){
$message=explode($from‚$file);
$message=explode($end‚$message[1]);
return $message[0];
}
----------------------------
读取函数
---------------------
function readfromfile($file_name) {
if($filenum=fopen($file_name‚"r")){
flock($filenum‚LOCK_SH);
$file_data=fread($filenum‚filesize($file_name));
fclose($filenum);
return $file_data;
}else{
return false;
}
}
-------------------------------------
把所有函数写成一个文件 保存起来 取名字叫 global.php
内容如下:
------------------------------------------------------------------------------------------------
<?php
function open($file‚$type=''){
global $fromurl‚$referer;
$cachename=$file;
if($type){
$file=$fromurl.'/'.$type.'/'.$file;
}else{
$file=$fromurl.$file;
}
if($open=file($file)){
$count=count($open);
for($i=0;$i<$count;$i++){
$theget.=$open[$i];
}
}else{
die('请求过多,超时,请刷新');
}
return $theget;
}
function update($file‚$type=''){
//更新cache中的文件
global $timestamp‚$flush;
if(!file_exists("cache/$file")){
if($type){
$data=open($file‚$type);
}else{
$data=open($file);
}
writetofile("cache/$file"‚$data);
}else{
$lastflesh=@filemtime("cache/$file");
if($lastflesh + ($flush * 60) < $timestamp ){
if($type){
$data=open($file‚$type);
}else{
$data=open($file);
}
writetofile("cache/$file"‚$data);
}
}
}
function readfromfile($file_name) {
if($filenum=fopen($file_name‚"r")){
flock($filenum‚LOCK_SH);
$file_data=fread($filenum‚filesize($file_name));
fclose($filenum);
return $file_data;
}else{
return false;
}
}
function writetofile($file_name‚$data‚$method="w") {
if($filenum=fopen($file_name‚$method)){
flock($filenum‚LOCK_EX);
$file_data=fwrite($filenum‚$data);
fclose($filenum);
return $file_data;
}else{
return false;
}
}
function cut($file‚$from‚$end){
$message=explode($from‚$file);
$message=explode($end‚$message[1]);
return $message[0];
}
function updatecache($file‚$cache=''){
global $timestamp‚$flush;
if(!file_exists($file)){
writetofile($file‚$cache);
$return=$cache;
}elseif(@filemtime($file) < $timestamp - ($flush * 60)){
writetofile($file‚$cache);
$return=$cache;
}else{
$return=readfromfile($file);
}
return $return;
}
?>
-----------------------------------------------------------------------------------------------------
其中有几个变量在config.php中设置一下
我们建立config.php文件 内容如下:
<?php
$fromurl = "http://www.onlinedown.net/";
$flush="120";//update函数中自动同步更新时间
?>
------------------------
现在位置我们有了3个文件了 commom.php config.php global.php
有了3个文件 程序总体完成了.接下来如何去偷呢?
心急的人可以先试试
建立一个index.php文件 就是首页
你先做好模板 的样子
HTML先做好.
然后在
<html>
........
........
</html>
的上方插入PHP代码
如下:
<?php
require './commom.php';
update("index.htm");
$file=readfromfile("cache/index.htm");
$gwrj = cut($file‚"<TD width=\"307\" height=\"118\">"‚"</TD>");
?>
<html>
.......
......
.......
</html>
在你想要插入的地方插入<?php echo $gwrj; ?>
就是从首页中切割出来的国外软件
自己试试
今天就到这里!
下一个接教如何读取分类页面.和简单介绍PHP模板技术的原理.再下节讲模板‚不需要HTML中出现PHP代码了.分离开来
有个朋友说的好‚其实教功夫也是变相的教你怎么杀人‚可是不说出来.
所以这个教程从下一篇开始就改个名字
叫<远程操作对方数据程序>有点土比小偷好听
第二天.
教几个函数给大家.
1 读取判断函数
2 更新cache函数
3 写入文件函数
4 切割字符函数
5 读取字符函数
---------------------------------------------------
在我们想写之前我们先要做好准备‚构思一下怎么去写.
制作前构思1
我们打开华军首页
http://www.onlinedown.net/
经过我们统计‚是不是发现它的连接有个很相同的规则?
1 根目录的index.htm文件
2 soft文件夹的 1.htm .......30000.htm
3 sort文件夹的 1_1.htm 200_1.htm
4 a-z文件夹 1.htm ....200.htm
到此我们可以想好一个打开函数‚不是根目录 就是文件夹/名字
只有2中可能.
制作前构思2
为了让速度更快‚我们最好把内容读过来存储起来.
1 减少了对对方站点的请求.
2 提供了速度.
这里我们判断这个文件写入的时间为准 我们自己设置一个时间
当写入时间 和现在的时间比一下‚如果在我们的设置时间内的话.就是可以.
如果不在比如
文件写入时间 2004年5月18好 06:00 我们现在时间是2004年5月19号 18:00
我们设置时间是1个小时
当再次请求这个文件的时候 他发现已经过期了.就会重新向对方请求一次并且存入.
制作前构思3
为了以后频繁的操作简单话‚把固定的操作写进一个函数.
切割字符.
一般切割就是 从第一个位置 切割到第二个位置 然后取中间部分
比如:
<html>
<head>
<title>演示站点</title>
</head>
<body>
</body>
</html>
从<title>开始切割到</title>
那切割出来的 就是 "演示站点"4个字
如果说‚可以找到 几个 <title>怎么办?程序会从第一处开始切割
到这里构思差不多..
程序要干净明了才行‚不要这一个文件不知道什么‚那一个文件不知道哪来.
所以‚如果你以后有做大站的机会的话‚文件夹‚文件一定要写的清楚‚分的清楚.
既然明白了构思‚我们就开始动手做了.
建立我们第一个PHP文件:
你可以用记事本‚可以用Dreamweaver也可以用专用PHP编辑软件
取名字为 commom.php
内容为
------------------------
<?php
include './config.php';
include './global.php';
?>-----------------------
这个文件有什么用?就是在以后操作中直接 inclue 这个文件就可以用到所有的函数啊什么的
然后config.php是设置 URL 刷新时间 等等
global.php是 所有函数的文件
也就是今天要给教给大家的!
第一个个函数 open
-------------
function open($file‚$type=''){
global $fromurl‚$referer;
$cachename=$file;
if($type){
$file=$fromurl.'/'.$type.'/'.$file;
}else{
$file=$fromurl.$file;
}
if($open=file($file)){
$count=count($open);
for($i=0;$i<$count;$i++){
$theget.=$open[$i];
}
}else{
die('请求过多,超时,请刷新');
}
return $theget;
}
解释过了‚连接地址就2中请求‚根目录‚和 文件夹/名字
函数怎么用法等等‚不多说了.建议大家下载译本PHP中文手册看看.
第二个函数
根据设置时间更新cache目录文件函数 update
---------------
function update($file‚$type=''){
global $timestamp‚$flush;
if(!file_exists("cache/$file")){
if($type){
$data=open($file‚$type);
}else{
$data=open($file);
}
writetofile("cache/$file"‚$data);
}else{
$lastflesh=@filemtime("cache/$file");
if($lastflesh + ($flush * 60) < $timestamp ){
if($type){
$data=open($file‚$type);
}else{
$data=open($file);
}
writetofile("cache/$file"‚$data);
}
}
}
简单解释
$data=open($file‚$type);就是用到上面的 open函数了
如果我们用 udate("index.htm");
那不就是用到了 update函数吗? 明白吗?
上面出现了writetofile函数 下面是代码
------------------------------
function writetofile($file_name‚$data‚$method="w") {
if($filenum=fopen($file_name‚$method)){
flock($filenum‚LOCK_EX);
$file_data=fwrite($filenum‚$data);
fclose($filenum);
return $file_data;
}else{
return false;
}
}
切割字符函数
------------------------
function cut($file‚$from‚$end){
$message=explode($from‚$file);
$message=explode($end‚$message[1]);
return $message[0];
}
读取函数
---------------------
function readfromfile($file_name) {
if($filenum=fopen($file_name‚"r")){
flock($filenum‚LOCK_SH);
$file_data=fread($filenum‚filesize($file_name));
fclose($filenum);
return $file_data;
}else{
return false;
}
}
把所有函数写成一个文件 保存起来 取名字叫 global.php
内容如下:
------------------------------------------------------------------------------------------------
<?php
function open($file‚$type=''){
global $fromurl‚$referer;
$cachename=$file;
if($type){
$file=$fromurl.'/'.$type.'/'.$file;
}else{
$file=$fromurl.$file;
}
if($open=file($file)){
$count=count($open);
for($i=0;$i<$count;$i++){
$theget.=$open[$i];
}
}else{
die('请求过多,超时,请刷新');
}
return $theget;
}
function update($file‚$type=''){
//更新cache中的文件
global $timestamp‚$flush;
if(!file_exists("cache/$file")){
if($type){
$data=open($file‚$type);
}else{
$data=open($file);
}
writetofile("cache/$file"‚$data);
}else{
$lastflesh=@filemtime("cache/$file");
if($lastflesh + ($flush * 60) < $timestamp ){
if($type){
$data=open($file‚$type);
}else{
$data=open($file);
}
writetofile("cache/$file"‚$data);
}
}
}
function readfromfile($file_name) {
if($filenum=fopen($file_name‚"r")){
flock($filenum‚LOCK_SH);
$file_data=fread($filenum‚filesize($file_name));
fclose($filenum);
return $file_data;
}else{
return false;
}
}
function writetofile($file_name‚$data‚$method="w") {
if($filenum=fopen($file_name‚$method)){
flock($filenum‚LOCK_EX);
$file_data=fwrite($filenum‚$data);
fclose($filenum);
return $file_data;
}else{
return false;
}
}
function cut($file‚$from‚$end){
$message=explode($from‚$file);
$message=explode($end‚$message[1]);
return $message[0];
}
function updatecache($file‚$cache=''){
global $timestamp‚$flush;
if(!file_exists($file)){
writetofile($file‚$cache);
$return=$cache;
}elseif(@filemtime($file) < $timestamp - ($flush * 60)){
writetofile($file‚$cache);
$return=$cache;
}else{
$return=readfromfile($file);
}
return $return;
}
?>
其中有几个变量在config.php中设置一下
我们建立config.php文件 内容如下:
<?php
$fromurl = "http://www.onlinedown.net/";
$flush="120";//update函数中自动同步更新时间
?>
------------------------
现在位置我们有了3个文件了 commom.php config.php global.php
有了3个文件 程序总体完成了.接下来如何去偷呢?
心急的人可以先试试
建立一个index.php文件 就是首页
你先做好模板 的样子
HTML先做好.
然后在
<html>
........
........
</html>
的上方插入PHP代码
如下:
<?php
require './commom.php';
update("index.htm");
$file=readfromfile("cache/index.htm");
$gwrj = cut($file‚"<TD width=\"307\" height=\"118\">"‚"</TD>");
?>
<html>
.......
......
.......
</html>
在你想要插入的地方插入<?php echo $gwrj; ?>
就是从首页中切割出来的国外软件
自己试试
今天就到这里!
下一个接教如何读取分类页面.和简单介绍PHP模板技术的原理.再下节讲模板‚不需要HTML中出现PHP代码了.分离开来
google搜索:小偷程序
声明:本站刊载此文不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。如有疑问请与站长联系。
相关链接更多...
- 跟我学小偷程序之成功偷取首页(第三天)2006-10-16
- 跟我学小偷程序之几个基本函数(第二天)2006-10-16
- 跟我学小偷程序教程之小偷原理(第一天)2006-10-16
- SHTML 教程2006-10-16
- SHTML 教程2006-10-16
- 用ASPJPEG组件制作图片的缩略图和加水印2006-10-16
网友评论
全站精华
图文精彩
![韩国CG天后李素雅作品[图]--CG插画](http://www.fansart.com/uploadfile/200682543923453.jpg)
【2006-8-25 12:09:00】
韩国CG天后李素雅作品
韩国CG天后李素雅作品
![2006夏装搭配的美丽之最,美女+靓衣[图]--时装魅影](http://www.fansart.com/uploadfile/200672243703881.jpg)
【2006-7-22 11:21:40】
2006夏装搭配的美丽之最,美女+靓衣
2006夏装搭配的美丽之最,美女+靓衣
![韩国室内设计效果图欣赏[图]--环境艺术](http://www.fansart.com/uploadfile/200671964096361.jpg)
【2006-7-19 15:11:59】
韩国室内设计效果图欣赏
韩国室内设计效果图欣赏
![2006夏装搭配的美丽之最,美女+靓衣[图]--时装魅影](http://www.fansart.com/uploadfile/200671463233205.jpg)
【2006-7-14 17:09:53】
2006夏装搭配的美丽之最,美女+靓衣
2006夏装搭配的美丽之最,美女+靓衣
![瓷砖画册设计[图]--平面广告](http://www.fansart.com/uploadfile/200662167119201.gif)
【2006-6-21 18:36:45】
瓷砖画册设计
瓷砖画册设计
![韩国知名三维制作者李素雅cg作品欣赏[图]--CG插画](http://www.fansart.com/uploadfile/20066967597489.gif)
【2006-6-9 18:40:03】
韩国知名三维制作者李素雅cg作品欣赏
韩国知名三维制作者李素雅cg作品欣赏
![王开立的象素画-"华容点翠"系列1[图]--网页设计](http://www.fansart.com/uploadfile/20066967740609.gif)
【2006-6-8 17:40:50】
王开立的象素画-"华容点翠"系列1
王开立的象素画-"华容点翠"系列1

【2006-5-10 18:31:05】
风景摄影欣赏molnies 1
风景摄影欣赏molnies 1
![人像摄影:《炫影》(1)[图]--摄影艺术](http://www.fansart.com/uploadfile/20065966294533.gif)
【2006-5-9 18:18:49】
人像摄影:《炫影》(1)
人像摄影:《炫影》(1)

【2006-5-8 11:37:48】
韩国品牌YSB夏装 冷艳美人异国风情(3)
韩国品牌YSB夏装 冷艳美人异国风情(3)

【2006-5-8 9:52:42】
MIKE H的CG插画作品欣赏(1)
MIKE H的CG插画作品欣赏(1)
![经典样本设计欣赏(国人作品)1[图]--平面广告](http://www.fansart.com/uploadfile/200642664631465.jpg)
【2006-4-26 17:57:18】
经典样本设计欣赏(国人作品)1
经典样本设计欣赏(国人作品)1

【2006-4-26 14:27:13】
新锐CG插画 Monday to Friday
新锐CG插画 Monday to Friday

【2006-4-26 13:34:46】
Natascha Roeoesli的人物CG插画作品欣赏(1)
Natascha Roeoesli的人物CG插画作品欣赏(1)
![水木清华地产广告欣赏[图]--平面广告](http://www.fansart.com/uploadfile/200642634295921.jpg)
【2006-4-26 9:31:54】
水木清华地产广告欣赏
水木清华地产广告欣赏
![2006夏日流行时尚,创意无限街头华丽[图]--时装魅影](http://www.fansart.com/uploadfile/200642261089093.jpg)
【2006-4-22 16:46:51】
2006夏日流行时尚,创意无限街头华丽
2006夏日流行时尚,创意无限街头华丽
![万科西山庭院.格.沉.尊[图]--平面广告](http://www.fansart.com/uploadfile/200642133015939.jpg)
【2006-4-21 9:08:35】
万科西山庭院.格.沉.尊
万科西山庭院.格.沉.尊
![泊林花园推广故事绘本(2)[图]--CG插画](http://www.fansart.com/uploadfile/200642042197577.jpg)
【2006-4-20 11:43:23】
泊林花园推广故事绘本(2)
泊林花园推广故事绘本(2)
![泊林花园推广故事绘本(1)[图]--CG插画](http://www.fansart.com/uploadfile/200642041664949.jpg)
【2006-4-20 11:34:33】
泊林花园推广故事绘本(1)
泊林花园推广故事绘本(1)
![房地产广告设计-之水墨风格1[图]--平面广告](http://www.fansart.com/uploadfile/200641457308753.jpg)
【2006-4-14 15:56:06】
房地产广告设计-之水墨风格1
房地产广告设计-之水墨风格1

RE:跟我学小偷程序之几个基本函数(第二天)
回复者:匿名 时间:2007-12-6