本文整理汇总了PHP中front::checkstr方法的典型用法代码示例。如果您正苦于以下问题:PHP front::checkstr方法的具体用法?PHP front::checkstr怎么用?PHP front::checkstr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类front
的用法示例。
在下文中一共展示了front::checkstr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: swfsave_action
function swfsave_action(){
if (is_array($_FILES['Filedata'])) {
$upload = new upload();
$upload->dir = 'images';
$upload->max_size = 2048000;
$attachment = new attachment();
$_file_type = str_replace(',','|',config::get('upload_filetype'));
$file = $_FILES['Filedata'];
$file['name'] = strtolower($file['name']);
if ($file['size'] > $upload->max_size) {
echo "附件超过上限(".ceil($upload->max_size / 1024)."K)!');";
exit;
}
if (!front::checkstr(file_get_contents($file['tmp_name']))) {
echo '上传失败!请将图片保存为WEB格式!';
exit;
}
if (!$file['name'] || !preg_match('/\.('.$_file_type.')$/',$file['name'])){
echo '上传失败!不允许的文件类型!';
exit;
}
$filename = $upload->run($file);
if(config::get('watermark_open')) {
include_once ROOT.'/lib/plugins/watermark.php';
imageWaterMark($filename,config::get('watermark_pos'),config::get('watermark_path'),null,5,"#FF0000",config::get('watermark_ts'),config::get('watermark_qs'));
}
if (!$filename) {
echo "附件保存失败!";
exit;
}
echo 'ok_'.$filename;
exit;
}else{
exit('请添加文件');
}
}
示例2: run
function run($attachment) {
$this->max_size=config::get('upload_max_filesize') * 1024000;
if (!isset($this->url_pre))
$this->url_pre='upload/'.$this->dir.'/'.date('Ym');
$this->path=ROOT.'/'.$this->url_pre;
tool::mkdir($this->path);
if (!$attachment['name']) {
return false;
}
$new_name=$new_name_gbk=str_replace('.','',Time::getMicrotime()).'.'.end(explode('.',$attachment['name']));
$content=file_get_contents($attachment['tmp_name']);
if (!front::checkstr($content)) {
return false;
}
if (strlen($content) >$this->max_size) {
return false;
}
if(!in_array(end(explode('.',$attachment['name'])), $this->type)){
return false;
}
move_uploaded_file($attachment['tmp_name'],$this->path.'/'.$new_name_gbk);
$this->save_path=$this->path.'/'.$new_name_gbk;
if ($_GET['site'] != 'default') {
$ftp=new nobftp();
$ftpconfig=config::get('website');
$ftp->connect($ftpconfig['ftpip'],$ftpconfig['ftpuser'],$ftpconfig['ftppwd'],$ftpconfig['ftpport']);
$ftperror=$ftp->returnerror();
if ($ftperror) {
exit($ftperror);
}
else {
$ftp->nobchdir($ftpconfig['ftppath']);
$ftp->nobput($ftpconfig['ftppath'].'/'.$this->url_pre.'/'.$new_name,$this->save_path);
}
}
return $this->url_pre.'/'.$new_name;
}
示例3: uploadimage_action
function uploadimage_action() {
$res=array();
$uploads=array();
if (is_array($_FILES)) {
$upload=new upload();
$upload->dir='images';
$upload->max_size=config::get('upload_max_filesize')*1024*1024;
$attachment=new attachment();
$_file_type=str_replace(',','|',config::get('upload_filetype'));
foreach ($_FILES as $name=>$file) {
$res[$name]['size']=ceil($file['size'] / 1024);
if ($file['size'] >$upload->max_size) {
$res[$name]['code']="alert('附件超过上限(".ceil($upload->max_size / 1024)."K)!');";
break;
}
if (!front::checkstr(file_get_contents($file['tmp_name']))) {
$res[$name]['code']=lang('上传失败!附件没有通过验证!');
break;
}
if (!$file['name'] ||!preg_match('/\.('.$_file_type.')$/',$file['name']))
continue;
$uploads[$name]=$upload->run($file);
if (!$uploads[$name]) {
$res[$name]['code']="alert('".lang('附件保存失败!')."');";
break;
}
$res[$name]['name']=$uploads[$name];
$res[$name]['type']=$file['type'];
$rname=preg_replace('%(.*)[\\\\\/](.*)_\d+(\.[a-z]+)$%i','$2$3',$uploads[$name]);
$res[$name]['code']="
document.form1.attachment_id.value=data[key].id;
if(!document.form1.attachment_intro.value) {
document.form1.attachment_intro.value='$rname';
}
get('attachment_path').innerHTML=data[key].name;
get('file_info').innerHTML='附件已保存!大小为:'+data[key].size+'K ';
";
if(substr(config::get('base_url'),-1,1) != '/'){
$ex = '/';
}
$str = config::get('base_url').$ex.$uploads[$name];
echo $str;
return;
}
}
echo json::encode($res);
}