-
您的位置:首页 → 精文荟萃 → 软件资讯 → 跟我学小偷程序之几个基本函数(第二天)
跟我学小偷程序之几个基本函数(第二天)
时间:2004/10/7 18:29:00来源:本站整理作者:蓝点我要评论(0)
-
第一天的教程连接地址
http://www.vipcn.com/infoview/Article_3751.html
今天教第二天.
有个朋友说的好,其实教功夫也是变相的教你怎么杀人,可是不说出来.
所以这个教程从下一篇开始就改个名字
叫<远程操作对方数据程序>有点土比小偷好听
第二天.
教几个函数给大家.
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
为了以后频繁的操作简单话,把固定的操作写进一个函数.
切割字符.
一般切割就是 从第一个位置 切割到第二个位置 然后取中间部分
比如:
演示站点
从
开始切割到
那切割出来的 就是 "演示站点"4个字
如果说,可以找到 几个 怎么办?程序会从第一处开始切割<BR>到这里构思差不多..<BR>程序要干净明了才行,不要这一个文件不知道什么,那一个文件不知道哪来.<BR>所以,如果你以后有做大站的机会的话,文件夹,文件一定要写的清楚,分的清楚.<BR>既然明白了构思,我们就开始动手做了.<BR>建立我们第一个PHP文件:<BR>你可以用记事本,可以用Dreamweaver也可以用专用PHP编辑软件<BR>取名字为 commom.php<BR>内容为<BR>------------------------<BR><FONT color=red><?php<BR>include './config.php';<BR>include './global.php';<BR>?></FONT>-----------------------<BR>这个文件有什么用?就是在以后操作中直接 inclue 这个文件就可以用到所有的函数啊什么的<BR>然后config.php是设置 URL 刷新时间 等等<BR>global.php是 所有函数的文件 <BR>也就是今天要给教给大家的!<BR>第一个个函数 open<BR>-------------<BR><FONT color=#ff0000>function open($file,$type=''){<BR> global $fromurl,$referer;<BR> $cachename=$file;<BR> if($type){<BR> $file=$fromurl.'/'.$type.'/'.$file;<BR> }else{<BR> $file=$fromurl.$file;<BR> }<BR><BR> <BR> <BR> <BR> if($open=file($file)){<BR> $count=count($open);<BR> for($i=0;$i<$count;$i++){<BR> $theget.=$open[$i];<BR><BR> }<BR> <BR> }else{<BR> die('请求过多,超时,请刷新');<BR> }<BR> <BR> <BR> return $theget;<BR><BR>}</FONT><BR>----------------<BR><FONT color=blue>解释过了,连接地址就2中请求,根目录,和 文件夹/名字</FONT><BR>函数怎么用法等等,不多说了.建议大家下载译本PHP中文手册看看.<BR>第二个函数<BR>根据设置时间更新cache目录文件函数 update<BR>---------------<BR><FONT color=red>function update($file,$type=''){<BR> global $timestamp,$flush;<BR> if(!file_exists("cache/$file")){<BR> if($type){<BR> $data=open($file,$type);<BR> }else{<BR> $data=open($file);<BR> }<BR> <BR> writetofile("cache/$file",$data);<BR> }else{<BR> $lastflesh=@filemtime("cache/$file");<BR> <BR> <BR> <BR> if($lastflesh + ($flush * 60) < $timestamp ){<BR> if($type){<BR> $data=open($file,$type);<BR> }else{<BR> $data=open($file);<BR> }<BR> writetofile("cache/$file",$data);<BR> }<BR> }<BR><BR>}</FONT><BR>--------<BR>简单解释<BR><FONT color=blue>$data=open($file,$type);</FONT>就是用到上面的 open函数了<BR>如果我们用 udate("index.htm");<BR>那不就是用到了 update函数吗? 明白吗?<BR>上面出现了writetofile函数 下面是代码<BR>------------------------------<BR><FONT color=red>function writetofile($file_name,$data,$method="w") {<BR> if($filenum=fopen($file_name,$method)){<BR> flock($filenum,LOCK_EX);<BR> $file_data=fwrite($filenum,$data);<BR> fclose($filenum);<BR> return $file_data;<BR> }else{<BR> return false;<BR> }<BR>}</FONT>---------------------------------<BR>切割字符函数<BR>------------------------<BR><FONT color=#ff0000>function cut($file,$from,$end){<BR><BR> $message=explode($from,$file);<BR> $message=explode($end,$message[1]);<BR>return $message[0];<BR>}</FONT><BR>----------------------------<BR>读取函数<BR>---------------------<BR><FONT color=red>function readfromfile($file_name) {<BR> if($filenum=fopen($file_name,"r")){<BR> flock($filenum,LOCK_SH);<BR> $file_data=fread($filenum,filesize($file_name));<BR> fclose($filenum);<BR> return $file_data;<BR> }else{<BR> return false;<BR> }<BR> <BR>}</FONT><BR>-------------------------------------<BR>把所有函数写成一个文件 保存起来 取名字叫 global.php<BR>内容如下:<BR>------------------------------------------------------------------------------------------------<BR><FONT color=blue><?php<BR>function open($file,$type=''){<BR> global $fromurl,$referer;<BR> $cachename=$file;<BR> if($type){<BR> $file=$fromurl.'/'.$type.'/'.$file;<BR> }else{<BR> $file=$fromurl.$file;<BR> }<BR><BR> <BR> <BR> <BR> if($open=file($file)){<BR> $count=count($open);<BR> for($i=0;$i<$count;$i++){<BR> $theget.=$open[$i];<BR><BR> }<BR> <BR> }else{<BR> die('请求过多,超时,请刷新');<BR> }<BR> <BR> <BR> return $theget;<BR><BR>}<BR><BR>function update($file,$type=''){<BR>//更新cache中的文件<BR> global $timestamp,$flush;<BR> if(!file_exists("cache/$file")){<BR> if($type){<BR> $data=open($file,$type);<BR> }else{<BR> $data=open($file);<BR> }<BR> <BR> writetofile("cache/$file",$data);<BR> }else{<BR> $lastflesh=@filemtime("cache/$file");<BR> <BR> <BR> <BR> if($lastflesh + ($flush * 60) < $timestamp ){<BR> if($type){<BR> $data=open($file,$type);<BR> }else{<BR> $data=open($file);<BR> }<BR> writetofile("cache/$file",$data);<BR> }<BR> }<BR><BR>}<BR>function readfromfile($file_name) {<BR> if($filenum=fopen($file_name,"r")){<BR> flock($filenum,LOCK_SH);<BR> $file_data=fread($filenum,filesize($file_name));<BR> fclose($filenum);<BR> return $file_data;<BR> }else{<BR> return false;<BR> }<BR> <BR>}<BR><BR><BR>function writetofile($file_name,$data,$method="w") {<BR> if($filenum=fopen($file_name,$method)){<BR> flock($filenum,LOCK_EX);<BR> $file_data=fwrite($filenum,$data);<BR> fclose($filenum);<BR> return $file_data;<BR> }else{<BR> return false;<BR> }<BR>}<BR>function cut($file,$from,$end){<BR><BR> $message=explode($from,$file);<BR> $message=explode($end,$message[1]);<BR>return $message[0];<BR>}<BR>function updatecache($file,$cache=''){<BR> global $timestamp,$flush;<BR> if(!file_exists($file)){<BR> writetofile($file,$cache);<BR> $return=$cache;<BR> }elseif(@filemtime($file) < $timestamp - ($flush * 60)){<BR> writetofile($file,$cache);<BR> $return=$cache;<BR> }else{<BR> $return=readfromfile($file); <BR> }<BR> return $return;<BR>}<BR>?></FONT><BR>-----------------------------------------------------------------------------------------------------<BR>其中有几个变量在config.php中设置一下<BR>我们建立config.php文件 内容如下:<BR><?php<BR>$fromurl = "http://www.onlinedown.net/";<BR>$flush="120";//update函数中自动同步更新时间<BR>?><BR>------------------------<BR>现在位置我们有了3个文件了 commom.php config.php global.php<BR>有了3个文件 程序总体完成了.接下来如何去偷呢?<BR>心急的人可以先试试<BR>建立一个index.php文件 就是首页<BR>你先做好模板 的样子<BR>HTML先做好.<BR>然后在<BR><html><BR>........ <BR>........<BR></html><BR>的上方插入PHP代码<BR>如下:<BR><?php<BR>require './commom.php';<BR>update("index.htm");<BR>$file=readfromfile("cache/index.htm");<BR>$gwrj = cut($file,"<TD width=\"307\" height=\"118\">","</TD>");<BR>?><BR><html><BR>.......<BR>......<BR>.......<BR></html><BR>在你想要插入的地方插入<FONT color=red><?php echo $gwrj; ?></FONT><BR>就是从首页中切割出来的国外软件 <BR>自己试试<BR>今天就到这里!<BR><FONT size=4><FONT color=#ff0000>下一个接教如何读取分类页面.和简单介绍PHP模板技术的原理.再下节讲模板,不需要HTML中出现PHP代码了.分离开来</FONT></FONT><BR></P>
</dd>
</dl>
<div id="xgsp"><p class="tit"><em>相关视频</em></p>
<div class="sp-wrap">
<ul class="clearfix">
<li><a href="/video/35627.html" target="_blank"><img src="https://thumb.hzozg.com/n131f33y14414/7ef6220197161773.jpeg"><span>windows10自带扫雷游戏在哪</span></a></li><li><a href="/video/35608.html" target="_blank"><img src="https://thumb12.hzozg.com/n331r1933t6b14n1e13/7ef621f2e386e59b.jpeg"><span>windows11专业版和家庭版的区别</span></a></li><li><a href="/video/35609.html" target="_blank"><img src="https://thumb.hzozg.com/n3319v533e4014eln13/7ef621f2ef964d53.jpeg"><span>windows11家庭版和专业版有什么区别</span></a></li><li><a href="/video/35470.html" target="_blank"><img src="https://thumb2.hzozg.com/n3315vb331dh13emv38/7ef621b17fd6b5e5.jpeg"><span>windows11我的电脑在哪里打开</span></a></li><li><a href="/video/35469.html" target="_blank"><img src="https://thumb12.hzozg.com/n3313eu3330g1365f38/7ef621b16c26f688.jpeg"><span>windows11我的电脑在哪</span></a></li><li><a href="/video/35466.html" target="_blank"><img src="https://thumb10.hzozg.com/n331xf6331dy13drs38/7ef621b10e146fcf.jpeg"><span>win11系统怎么退出微软账号</span></a></li><li><a href="/video/35091.html" target="_blank"><img src="https://thumb10.hzozg.com/n231sp33cd134j22/7ef62061e5f02b61.jpeg"><span>win10ie打开变成edge</span></a></li><li><a href="/video/34798.html" target="_blank"><img src="https://thumb10.hzozg.com/n331zf433u2x1212t36/7ef61efa5c1e0e6e.jpeg"><span>win11怎么设置默认浏览器</span></a></li><li><a href="/video/34683.html" target="_blank"><img src="https://thumb11.hzozg.com/n2317533wl12ji32/7ef61ea73b416974.jpeg"><span>win11 ie浏览器在哪里</span></a></li><li><a href="/video/34071.html" target="_blank"><img src="https://thumb10.hzozg.com/n131032w23h42/7ef61ce5b1bddfd3.jpeg"><span>windows11怎么连接wifi</span></a></li><li><a href="/video/34070.html" target="_blank"><img src="https://thumb10.hzozg.com/n131q32823t42/7ef61ce5a5e38c81.jpeg"><span>windows11有必要升级吗</span></a></li><li><a href="/video/34069.html" target="_blank"><img src="https://thumb10.hzozg.com/n131632l23o42/7ef61ce59b2d938d.jpeg"><span>windows11怎么把我的电脑放在桌面上</span></a></li><li><a href="/video/33644.html" target="_blank"><img src="https://thumb1.hzozg.com/n331j1l32yg223ums26/7ef61b9add7dbd37.jpeg"><span>win10怎么隐藏任务栏</span></a></li><li><a href="/video/33524.html" target="_blank"><img src="https://thumb2.hzozg.com/n331g1e3240e23utf23/7ef61b5b9fbe02f8.jpeg"><span>win10任务栏颜色怎么改</span></a></li><li><a href="/video/33520.html" target="_blank"><img src="https://thumb11.hzozg.com/n331n4m32waz23w6023/7ef61b5b5c19d8a4.jpeg"><span>win10已禁用输入法怎么解决</span></a></li>
</ul>
</div>
</div>
<p id="lread">
<b class="tit"><em>相关阅读</em></b>
<span>
<i><a href="/infoview/Article_181275.html">Windows错误代码大全 Windows错误代码查询</a></i><i><a href="/edu/180591.html">激活windows有什么用</a></i><i><a href="/edu/142370.html">Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录</a></i><i><a href="/infoview/Article_140347.html">Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新</a></i><i><a href="/infoview/Article_136060.html">windows 10 rs4快速预览版17017下载错误问题</a></i><i><a href="/infoview/Article_133896.html">Win10秋季创意者更新16291更新了什么 win10 16291更新内容</a></i><i><a href="/infoview/Article_131339.html">windows10秋季创意者更新时间 windows10秋季创意者更新内容</a></i><i><a href="/infoview/Article_118674.html">kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么</a></i>
</span>
</p>
<dl id="commentBox"><dt class="tit"><i>文章评论</i></dt>
<dd id="comment">
<div id="comment-list">
<div id="hotCmt">
</div>
<dl>
</dl>
<p id="cmtNum-wrap"><a href="/comment_995_1.html">查看所有<span id="cmtNum">0</span>条评论>></a></p>
</div>
<div id="comment-form">
<form action="/ajax.asp" method="post" id="cmtForm">
<fieldset>
<legend>发表评论</legend>
<input name="SoftID" type="hidden" id="softID" value="995" />
<input name="CommentTpye" type="hidden" value="1" />
<input name="Action" type="hidden" value="2" />
<p id="userName-wrap"><input name="UserName" type="text" id="userName" class="input-bg grey9" maxLength="10" value="PC6网友" /></p>
<p><textarea name="content" id="cmtMsg" class="input-bor">我来说两句...</textarea></p>
<p><button type="submit" class="btn-submit button btnOrg fr" id="subCmt">提交评论</button></p>
</fieldset>
</form>
</div>
</dd><!-- #comment end -->
</dl>
</dt>
<dd id="cside">
<div class="adr"></div>
<p id="rpj">
<b class="tit"><em>热门文章</em></b>
<span>
<a href="/infoview/Article_118995.html"><img src="https://thumb10.hzozg.com/up/2017-6/201761414444617963387.jpg" /><b>360快剪辑怎么使用 36</b></a><a href="/infoview/Article_68410.html"><img src="https://thumb10.hzozg.com/up/2014-9/201491212754.jpg" /><b>金山词霸如何屏幕取词</b></a><a href="/infoview/Article_61812.html"><img src="https://thumb10.hzozg.com/up/2013-4/20134425250931094380.jpg" /><b>百度收购PPS已敲定!3</b></a>
</span>
</p>
<p id="wj">
<b class="tit"><em>最新文章</em></b>
<span>
<i><a href="/infoview/Article_196027.html"><img src="https://thumb1.hzozg.com/n3319rg33iv414xe425/7ef622e99bb116ed.jpeg" /><b>微信3.6.0测试版更新了</b></a></i><i><a href="/infoview/Article_162802.html"><img src="https://thumb10.hzozg.com/2018-07/bce5b3c5a7fae33f.jpeg" /><b>微信支付漏洞会造成哪</b></a></i>
</span>
<s>
<a href="/infoview/Article_118995.html" target="_blank">360快剪辑怎么使用 360快剪辑软件使用方法介</a><a href="/infoview/Article_107082.html" target="_blank">酷骑单车是什么 酷骑单车有什么用</a><a href="/infoview/Article_90143.html" target="_blank">Apple pay与支付宝有什么区别 Apple pay与</a><a href="/infoview/Article_90129.html" target="_blank">贝贝特卖是正品吗 贝贝特卖网可靠吗</a>
</s>
</p>
<p id="rwz">
<b class="tit"><em>人气排行</em></b>
<span>
<i><a href="/infoview/Article_65172.html" target="_blank">xp系统停止服务怎么办?xp系统升级win7系统方</a></i><i><a href="/infoview/Article_67898.html" target="_blank">电脑闹钟怎么设置 win7电脑闹钟怎么设置</a></i><i><a href="/infoview/Article_58963.html" target="_blank">office2013安装教程图解:手把手教你安装与</a></i><i><a href="/infoview/Article_368.html" target="_blank">qq影音闪退怎么办 QQ影音闪退解决方法</a></i><i><a href="/infoview/Article_50553.html" target="_blank">VeryCD镜像网站逐个数,电驴资料库全集</a></i><i><a href="/infoview/Article_56293.html" target="_blank">同步推是什么?同步推使用方法介绍</a></i><i><a href="/infoview/Article_54150.html" target="_blank">QQ2012什么时候出 最新版下载</a></i><i><a href="/infoview/Article_52591.html" target="_blank">EDiary——一款好用的电子日记本</a></i>
</span>
</p>
</dd>
</dl>
<!--#include virtual="/include/footer/news_footer.html"-->
<script type="text/javascript"> var _webInfo = {};_webInfo={Username:"网络虫虫",Type:"1",DateTime:"2004/10/7 18:29:00",Id:"995"};</script>
<script type="text/javascript" src="https://www.pc6.com/inc/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="https://www.pc6.com/js/nwz.js"></script>
<script type="text/javascript">
var pageClass=7;
//读取文章人气
ViewCmsHits('hits',995);
$("#comment-list > dl > dd > p a:last-child").addClass("glBtn");
BindDing("#comment-list > dl > dd > p",995,1);//顶
</script>
<script type="application/ld+json">
{
"@context": "https://zhanzhang.baidu.com/contexts/cambrian.jsonld",
"@id": "http://www.pc6.com/infoview/Article_995.html",
"title": "跟我学小偷程序之几个基本函数(第二天) _pc6资讯",
"description": ",跟我学小偷程序之几个基本函数(第二天)",
"pubDate": "2004-10-07T18:29:00",
"upDate": "2004-10-07T18:29:00",
"data":{
"WebPage":{
"pcUrl":"http://www.pc6.com/infoview/Article_995.html",
"wapUrl":"https://m.pc6.com/n/995",
"fromSrc":"pc6下载站"
}
}
}
</script>
</body>
</html>