  
- UID
- 1
- 威望
- 1240 点
- 金钱
- 24019 金币
- 点卡
- 317 点
|
6#
发表于 2003-12-29 14:26
| 只看该作者
[转帖]冰冰通用函数整理主题(updata 12/29/2003)
- // +-----------------------------------------------------------------------
- // | iZz :: File
- // +-----------------------------------------------------------------------
- // | Copyright © 2000-2002 iZz Studio
- // +-----------------------------------------------------------------------
- // | This source file is created by iZz Studio. And this file is not
- // | public and not a open source file. If you get this file, and not
- // | , please contact us by emailing to [EMAIL=justdn@justdn.com]justdn@justdn.com[/EMAIL].
- // |
- // |
- // |
- // |
- // |
- // +-----------------------------------------------------------------------
- // | Author(s):
- // |
- // |
- // +-----------------------------------------------------------------------
- //
- // $Id: iZzFile.php,v 1.1 2002/10/31 11:16:21 Beijing Time Zone $
- //-------------------------------------------------------------------------
- //
- //使用方法:
- //只读:$ifile = new iFile('test.txt','r');
- //读写:$ifile = new iFile('test.txt','w');
- //快读:$ifile = new iFile('test.txt','dr');
- //快写:$ifile = new iFile('test.txt','w','测试一下咯');
- //读取文件内容:$ifile->getFileData();
- //显示读取/快读数据:echo $ifile->Data;
- //写入文件内容:$ifile->WriteFile('测试一下咯',3);
- //关闭文件句柄:$ifile->ColseFile();
- //
- //注意:写入/快写后自动关闭文件句柄.
- //-------------------------------------------------------------------------
- class iFile {
- var $Fp;
- var $Pipe; //(fopen,popen)(f,p)
- var $File;
- var $OpenMode; //(r,r+,w,w+,a,a+,B)
- var $Data;
- function iFile($File,$Mode = 'r',$Data4Write='',$Pipe = 'f'){
- $this -> File = $File;
- $this -> Pipe = $Pipe;
- if($Mode == 'dr'){
- $this -> OpenMode = 'r';
- $this -> OpenFile();
- $this -> getFileData();
- }else{
- $this -> OpenMode = $Mode;
- $this -> OpenFile();
- }
- if($this->OpenMode=='w'&&$Data4Write!=''){
- $this -> WriteFile($Data4Write,$Mode = 3);
- }
- }
- function OpenFile(){
- if ($this -> OpenMode == 'r'||$this -> OpenMode == 'r+'){
- if($this->CheckFile()){
- if ($this -> Pipe == 'f') {
- $this->Fp = fopen($this -> File, $this -> OpenMode);
- } elseif ($Pipe == 'p') {
- $this->Fp = popen($this -> File, $this -> OpenMode);
- }else{
- Die("Check The OpenFile Pipe,It can be 'f' or 'p'./请检查文件打开参数3,f:fopen(),p:poen().");
- }
- } else {
- Die("Access Error: Check $File is exist./文件访问错误,请检查文件是否存在!");
- }
- } else {
- if ($this -> Pipe == 'f') {
- $this->Fp = fopen($this -> File, $this -> OpenMode);
- } elseif ($Pipe == 'p') {
- $this->Fp = popen($this -> File, $this -> OpenMode);
- } else {
- Die("Check The OpenFile Pipe,It can be 'f' or 'p'./请检查文件打开参数3,f:fopen(),p:poen().");
- }
- }
- }
- function CloseFile(){
- if ($this->Pipe == 'f'){
- @fclose($this->Fp);
- } else {
- @pclose($this->Fp);
- }
- }
- function getFileData(){
- @flock($this->Fp, 1);
- $Content = fread($this->Fp, filesize($this->File));
- $this->Data = $Content;
- }
- function CheckFile(){
- if (file_exists($this -> File)) { return true; } else { return false; }
- }
- function WriteFile($Data4Write,$Mode = 3){
- @flock($this->Fp,$Mode);
- fwrite($this->Fp,$Data4Write);
- $this->CloseFile();
- return true;
- }
- }
复制代码 |
我是一个呼吸着现在的空气而生活在过去的人
这样的注定孤独,孤独的身处闹市却犹如置身于荒漠
我已习惯了孤独,爱上孤独
他让我看清了自我,还原了自我
让我再静静的沉思中得到快乐和满足
再孤独的世界里我一遍又一遍
不厌其烦的改写着自己的过去
延伸到现在与未来
然而那只是泡沫般的美梦
产生的时刻又伴随着破灭的到来
在灰飞烟灭的瞬间我看到的是过程的美丽
而不是结果的悲哀。。。
|
|