$value){
if(strlen($value)>=3){
$user_arr[] = $value;
}
}
$str_arr = $user_arr;
}elseif($chk == 'int'){
$id_arr = array();
foreach($str_arr as $key => $value){
if(is_numeric($value)){
$id_arr[] = $value;
}
}
$str_arr = $id_arr;
}
return $str_arr;
}
function mc_read_txt($file){
$pathfile=$file;
if (!file_exists($pathfile)) {
return false;
}
$fs = fopen($pathfile,"r+");
$content = fread($fs,filesize($pathfile));//读文件
fclose($fs);
if(!$content) return false;
return $content;
}
function uploadfile($upfile,$upload_path,$redirect,$f_size="102400",$f_type="txt,jpg|jpeg|gif|png"){
if(!file_exists($upload_path)){mkdir($upload_path,0777);chmod($upload_path,0777);}//检测文件夹是否存,不存在则创建;
$file_name=$_FILES[$upfile]['name'];
if(empty($file_name))return false;
$file_type=$_FILES[$upfile]['type'];
$file_size=$_FILES[$upfile]['size'];
$file_tmp=$_FILES[$upfile]['tmp_name'];
$upload_dir=$upload_path;
$ext=explode(".",$file_name);
$sub=count($ext)-1;
$ext_type=strtolower($ext[$sub]);//转换成小写
$up_type=explode("|",$f_type);
if(!in_array($ext_type,$up_type)){
die("
");
}
$file_names=time().rand(1,9999).".".$ext[$sub];
$upload_file_name=$upload_dir.$file_names;
$chk_file=move_uploaded_file($file_tmp,$upload_file_name);
if($chk_file){ //判断文件上传是否成功
chmod($upload_file_name,0777);//设置上传文件的权限
unset($ext[$sub]);$file_name=implode(".",$ext);//先去除扩展名,后获取文件名
return array($file_names,$file_size,$ext_type,$file_name);
}else{
return false;
}
}
//ecmoban模板堂 --zhuo start
function get_str_trim($str, $type = ','){
$str = explode($type,$str);
$str2 = '';
for($i=0; $itable($table). " where " . $where;
if($type == 1){
return $GLOBALS['db']->getOne($sql);
}else{
return $GLOBALS['db']->getRow($sql);
}
}
//获取随机数组值
function get_array_rand_return($arr){
if(count($arr) < 1){
$arrNum = 1;
}else{
$arrNum = count($arr);
}
$rand_num = rand(1, $arrNum);
$rand_key = array_rand($arr, $rand_num);
$key = count($rand_key);
if($key == 1){
$newArr[] = $arr[rand(0, count($arr) - 1)];
}else{
$newArr = array();
for($i = 0; $i<$key; $i++){
$newArr[$i] = $arr[$rand_key[$i]];
}
}
return $newArr;
}
//ecmoban模板堂 --zhuo end
?>