<?php
/**
* 文件操作类
*/
class FileModel{
/**
* 写文件
*
* @param string $filename
* @param string $data
* @param string $method
* @param int $iflock
* @param int $check
* @param int $chmod
* @return boolean
*/
public static function write($filename, $data, $method = 'wb+', $iflock = 1, $check = 1, $chmod = 1){
return false;
}
if($check && strpos($filename,'..') !== false){
return false;
}
return false;
}
if(false == ($handle = fopen($filename,$method))){
return false;
}
if($iflock){
}
if($method == "wb+"){
}
$chmod && @chmod($filename,0777);
return true;
}
/**
* 读文件
*
* @param string $filename
* @param string $method
* @return string
*/
public static function read($filename, $method = "rb"){
if(strpos($filename,'..') !== false){
return false;
}
if($handle = @fopen($filename,$method)){
return $filedata;
}else{
return false;
}
}
/**
* 删除文件
*
* @param string $filename
* @return boolean
*/
public static function rm($filename){
if(strpos($filename,'..') !== false){
return false;
}
}
/**
* 用递归方式创建目录
*
* @param string $pathname
* @param $mode
* @return boolean
*/
public static function mkdir_recursive($pathname, $mode){
if(strpos($pathname,'..') !== false){
return false;
}
'/\\{1,}/',
'/\/{2,}/'
),'/',$pathname),'/');
return true;
}
}
/**
* 用递归方式删除目录
*
* @param string $file
* @return boolean
*/
public static function rm_recurse($file){
if(strpos($file,'..') !== false){
return false;
}
if($sf === '..' || $sf === '.'){
continue;
}
if(!self::rm_recurse($file . '/' . $sf)){
return false;
}
}
}else{
}
}
/**
* 引用文件安全检查
*
* @param string $filename
* @param int $ifcheck
* @return boolean
*/
public static function check_security($filename, $ifcheck = 1){
if(strpos($filename,'http://') !== false) return false;
if(strpos($filename,'https://') !== false) return false;
if(strpos($filename,'ftp://') !== false) return false;
if(strpos($filename,'ftps://') !== false) return false;
if(strpos($filename,'php://') !== false) return false;
if(strpos($filename,'..') !== false) return false;
return $filename;
}
/**
* 文件列表
*
* @param string $path //路径
* @param string $type[optional] //类型:file 文件,dir 目录, 缺省 file+dir
* @return array
*/
public static function ls($path, $type = ''){
return false;
}
'file',
'dir'
))){
$func = "is_" . $type;
foreach($files as $k => $cur_file){
if(!$func($path . '/' . $cur_file) || $cur_file == '.svn'){
}
}
}
return $files;
}
}