本文整理匯總了PHP中MkdirAll函數的典型用法代碼示例。如果您正苦於以下問題:PHP MkdirAll函數的具體用法?PHP MkdirAll怎麽用?PHP MkdirAll使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MkdirAll函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: MoveFile
function MoveFile($mfile,$mpath)
{
if($mpath!="" && !ereg("\.\.",$mpath))
{
$oldfile = $this->baseDir.$this->activeDir."/$mfile";
$mpath = str_replace("\\","/",$mpath);
$mpath = ereg_replace("/{1,}","/",$mpath);
if(!ereg("^/",$mpath)){ $mpath = $this->activeDir."/".$mpath; }
$truepath = $this->baseDir.$mpath;
if(is_readable($oldfile)
&& is_readable($truepath) && is_writable($truepath))
{
if(is_dir($truepath)) copy($oldfile,$truepath."/$mfile");
else{
MkdirAll($truepath,$GLOBALS['cfg_dir_purview']);
CloseFtp();
copy($oldfile,$truepath."/$mfile");
}
unlink($oldfile);
ShowMsg("成功移動文件!","file_manage_main.php?activepath=$mpath",0,1000);
return 1;
}
else
{
ShowMsg("移動文件 $oldfile -> $truepath/$mfile 失敗,可能是某個位置權限不足!","file_manage_main.php?activepath=$mpath",0,1000);
return 0;
}
}
else{
ShowMsg("對不起,你移動的路徑不合法!","-1",0,5000);
return 0;
}
}
示例2: SpCreateDir
function SpCreateDir($spath)
{
global $cfg_dir_purview, $cfg_basedir, $cfg_ftp_mkdir, $isSafeMode;
if ($spath == '') {
return true;
}
$flink = false;
$truepath = $cfg_basedir;
$truepath = str_replace("\\", "/", $truepath);
$spaths = explode("/", $spath);
$spath = "";
foreach ($spaths as $spath) {
if ($spath == "") {
continue;
}
$spath = trim($spath);
$truepath .= "/" . $spath;
if (!is_dir($truepath) || !is_writeable($truepath)) {
if (!is_dir($truepath)) {
$isok = MkdirAll($truepath, $cfg_dir_purview);
} else {
$isok = ChmodAll($truepath, $cfg_dir_purview);
}
if (!$isok) {
echo "創建或修改目錄:" . $truepath . " 失敗!<br>";
CloseFtp();
return false;
}
}
}
CloseFtp();
return true;
}
示例3: MoveFile
/**
* 移動文件
*
* @access public
* @param string $mfile 文件
* @param string $mpath 路徑
* @return string
*/
function MoveFile($mfile, $mpath)
{
if ($mpath != "" && !preg_match("#\\.\\.#", $mpath)) {
$oldfile = $this->baseDir . $this->activeDir . "/{$mfile}";
$mpath = str_replace("\\", "/", $mpath);
$mpath = preg_replace("#\\/{1,}#", "/", $mpath);
if (!preg_match("#^/#", $mpath)) {
$mpath = $this->activeDir . "/" . $mpath;
}
$truepath = $this->baseDir . $mpath;
if (is_readable($oldfile) && is_readable($truepath) && is_writable($truepath)) {
if (is_dir($truepath)) {
copy($oldfile, $truepath . "/{$mfile}");
} else {
MkdirAll($truepath, $GLOBALS['cfg_dir_purview']);
CloseFtp();
copy($oldfile, $truepath . "/{$mfile}");
}
unlink($oldfile);
ShowMsg("成功移動文件!", "file_manage_main.php?activepath={$mpath}", 0, 1000);
return 1;
} else {
ShowMsg("移動文件 {$oldfile} -> {$truepath}/{$mfile} 失敗,可能是某個位置權限不足!", "file_manage_main.php?activepath={$mpath}", 0, 1000);
return 0;
}
} else {
ShowMsg("對不起,你移動的路徑不合法!", "-1", 0, 5000);
return 0;
}
}
示例4: SpCreateDir
function SpCreateDir($spath,$siterefer='',$sitepath='')
{
if($spath=="") return true;
global $cfg_dir_purview,$cfg_basedir,$cfg_ftp_mkdir;
$flink = false;
if($siterefer==1) $truepath = ereg_replace("/{1,}","/",$cfg_basedir."/".$sitepath);
else if($siterefer==2){
$truepath = $sitepath;
if($cfg_isSafeMode||$cfg_ftp_mkdir=='Y'){ echo "Not Suppot Safemode !"; exit(); }
}
else $truepath = $cfg_basedir;
$spaths = explode("/",$spath);
$spath = "";
foreach($spaths as $spath){
if($spath=="") continue;
$spath = trim($spath);
$truepath .= "/".$spath;
$truepath = str_replace("\\","/",$truepath);
$truepath = ereg_replace("/{1,}","/",$truepath);
if(!is_dir($truepath) || !is_writeable($truepath)){
if(!is_dir($truepath)) $isok = MkdirAll($truepath,$GLOBALS['cfg_dir_purview']);
else $isok = ChmodAll($truepath,$GLOBALS['cfg_dir_purview']);
if(!$isok){ echo "Create dir ".$truepath." False!<br>"; CloseFtp(); return false; }
}
}
CloseFtp();
return true;
}
示例5: WriteBookText
function WriteBookText($cid,$body)
{
global $cfg_cmspath,$cfg_basedir;
$ipath = $cfg_cmspath."/data/textdata";
$tpath = ceil($cid/5000);
if(!is_dir($cfg_basedir.$ipath)) MkdirAll($cfg_basedir.$ipath,$GLOBALS['cfg_dir_purview']);
if(!is_dir($cfg_basedir.$ipath.'/'.$tpath)) MkdirAll($cfg_basedir.$ipath.'/'.$tpath,$GLOBALS['cfg_dir_purview']);
$bookfile = $cfg_basedir.$ipath."/{$tpath}/bk{$cid}.php";
$body = "<"."?php exit();\r\n".$body."\r\n?".">";
@$fp = fopen($bookfile,'w');
@flock($fp);
@fwrite($fp,$body);
@fclose($fp);
}
示例6: WriteBookText
function WriteBookText($cid, $body)
{
$body = stripslashes($body);
global $cfg_cmspath, $cfg_basedir;
$ipath = $cfg_cmspath . "/data/textdata";
$tpath = ceil($cid / 5000);
if (!is_dir($cfg_basedir . $ipath)) {
MkdirAll($cfg_basedir . $ipath, $GLOBALS['cfg_dir_purview']);
}
if (!is_dir($cfg_basedir . $ipath . '/' . $tpath)) {
MkdirAll($cfg_basedir . $ipath . '/' . $tpath, $GLOBALS['cfg_dir_purview']);
}
$bookfile = $cfg_basedir . $ipath . "/{$tpath}/bk{$cid}.inc";
$body = "<" . "?php error_reporting(0); exit();\r\n" . $body . "\r\n?" . ">";
@($fp = fopen($bookfile, 'w'));
@flock($fp);
@fwrite($fp, $body);
@fclose($fp);
}
示例7: GetCurContent
/**
* 獲得文章body裏的外部資源
*
* @access public
* @param string $body 文檔內容
* @return string
*/
function GetCurContent($body)
{
global $cfg_multi_site, $cfg_basehost, $cfg_basedir, $cfg_image_dir, $arcID, $cuserLogin, $dsql;
$cfg_uploaddir = $cfg_image_dir;
$htd = new DedeHttpDown();
$basehost = "http://" . $_SERVER["HTTP_HOST"];
$img_array = array();
preg_match_all("/src=[\"|'|\\s]{0,}(http:\\/\\/([^>]*)\\.(gif|jpg|png))/isU", $body, $img_array);
$img_array = array_unique($img_array[1]);
//修改DEDECMS默認的遠程圖片的下載保存路徑
//$imgUrl = $cfg_uploaddir.'/'.MyDate("ymd", time());
$imgUrl = '/image';
$imgPath = $cfg_basedir . $imgUrl;
if (!is_dir($imgPath . '/')) {
MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']);
CloseFtp();
}
$milliSecond = MyDate('His', time());
foreach ($img_array as $key => $value) {
if (preg_match("#" . $basehost . "#i", $value)) {
continue;
}
if ($cfg_basehost != $basehost && preg_match("#" . $cfg_basehost . "#i", $value)) {
continue;
}
if (!preg_match("#^http:\\/\\/#i", $value)) {
continue;
}
$htd->OpenUrl($value);
$itype = $htd->GetHead("content-type");
$itype = substr($value, -4, 4);
if (!preg_match("#\\.(jpg|gif|png)#i", $itype)) {
if ($itype == 'image/gif') {
$itype = ".gif";
} else {
if ($itype == 'image/png') {
$itype = ".png";
} else {
$itype = '.jpg';
}
}
}
$milliSecondN = dd2char($milliSecond . mt_rand(1000, 8000));
$value = trim($value);
$rndFileName = $imgPath . '/' . $milliSecondN . '-' . $key . $itype;
$fileurl = $imgUrl . '/' . $milliSecondN . '-' . $key . $itype;
$rs = $htd->SaveToBin($rndFileName);
if ($rs) {
$info = '';
$imginfos = GetImageSize($rndFileName, $info);
$fsize = filesize($rndFileName);
//保存圖片附件信息
$inquery = "INSERT INTO `#@__uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)\n\t\t\tVALUES ('{$arcID}','{$rndFileName}','{$fileurl}','1','{$imginfos[0]}','{$imginfos['1']}','0','{$fsize}','" . time() . "','" . $cuserLogin->getUserID() . "'); ";
$dsql->ExecuteNoneQuery($inquery);
$fid = $dsql->GetLastID();
AddMyAddon($fid, $fileurl);
if ($cfg_multi_site == 'Y') {
$fileurl = $cfg_basehost . $fileurl;
}
$body = str_replace($value, $fileurl, $body);
@WaterImg($rndFileName, 'down');
}
}
$htd->Close();
return $body;
}
示例8: CheckPurview
CheckPurview('plus_友情鏈接模塊');
if (empty($dopost)) {
$dopost = "";
}
if ($dopost == "add") {
$dtime = time();
if (is_uploaded_file($logoimg)) {
$names = split("\\.", $logoimg_name);
$shortname = "." . $names[count($names) - 1];
if (!preg_match("#(jpg|gif|png)\$#", $shortname)) {
$shortname = '.gif';
}
$filename = MyDate("ymdHis", time()) . mt_rand(1000, 9999) . $shortname;
$imgurl = $cfg_medias_dir . "/flink";
if (!is_dir($cfg_basedir . $imgurl)) {
MkdirAll($cfg_basedir . $imgurl, $cfg_dir_purview);
CloseFtp();
}
$imgurl = $imgurl . "/" . $filename;
move_uploaded_file($logoimg, $cfg_basedir . $imgurl) or die("複製文件到:" . $cfg_basedir . $imgurl . "失敗");
@unlink($logoimg);
} else {
$imgurl = $logo;
}
//強製檢測用戶友情鏈接分類是否數據結構不符
if (empty($typeid) || preg_match("#[^0-9]#", $typeid)) {
$typeid = 0;
$dsql->ExecuteNoneQuery("ALTER TABLE `#@__flinktype` CHANGE `ID` `id` MEDIUMINT( 8 ) UNSIGNED DEFAULT NULL AUTO_INCREMENT; ");
}
$query = "INSERT INTO `#@__flink`(sortrank,url,webname,logo,msg,email,typeid,dtime,ischeck)\n VALUES('{$sortrank}','{$url}','{$webname}','{$imgurl}','{$msg}','{$email}','{$typeid}','{$dtime}','{$ischeck}'); ";
$rs = $dsql->ExecuteNoneQuery($query);
示例9: str_replace
exit;
}
//軟件類型所有支持的附件
$cfg_softtype = $cfg_softtype;
$cfg_softtype = str_replace('||', '|', $cfg_softtype);
$uploadfile_name = trim(preg_replace("#[ \r\n\t\\*\\%\\\\/\\?><\\|\":]{1,}#", '', $uploadfile_name));
if (!preg_match("#\\.(" . $cfg_softtype . ")#i", $uploadfile_name)) {
ShowMsg("你所上傳的{$uploadmbtype}不在許可列表,請更改係統對擴展名限定的配置!", "");
exit;
}
$nowtme = time();
if ($activepath == $cfg_soft_dir) {
$newdir = MyDate($cfg_addon_savetype, $nowtme);
$activepath = $activepath . '/' . $newdir;
if (!is_dir($cfg_basedir . $activepath)) {
MkdirAll($cfg_basedir . $activepath, $cfg_dir_purview);
CloseFtp();
}
}
//文件名(前為手工指定, 後者自動處理)
if (!empty($newname)) {
$filename = $newname;
if (!preg_match("#\\.#", $filename)) {
$fs = explode('.', $uploadfile_name);
} else {
$fs = explode('.', $filename);
}
if (preg_match("#" . $cfg_not_allowall . "#", $fs[count($fs) - 1])) {
ShowMsg("你指定的文件名被係統禁止!", 'javascript:;');
exit;
}
示例10: exit
break;
case 6:
$ftype = 'image/bmp';
$sname = '.bmp';
break;
}
}
if ($ftype == '') {
@unlink($Filedata);
echo "ERROR: Image type Error! ";
exit(0);
}
//保存原圖
$filedir = $cfg_image_dir . '/' . MyDate($cfg_addon_savetype, time());
if (!is_dir(DEDEROOT . $filedir)) {
MkdirAll($cfg_basedir . $filedir, $cfg_dir_purview);
CloseFtp();
}
$filename = $cuserLogin->getUserID() . '-' . dd2char(MyDate('ymdHis', time()));
if (file_exists($cfg_basedir . $filedir . '/' . $filename . $sname)) {
for ($i = 50; $i <= 5000; $i++) {
if (!file_exists($cfg_basedir . $filedir . '/' . $filename . '-' . $i . $sname)) {
$filename = $filename . '-' . $i;
break;
}
}
}
$fileurl = $filedir . '/' . $filename . $sname;
$rs = copy($FiledataNew, $cfg_basedir . $fileurl);
unlink($FiledataNew);
if (!$rs) {
示例11: GetFieldValue
/**
* 處理不同類型的數據
*
* @access public
* @param string $dvalue 默認值
* @param string $dtype 默認類型
* @param int $aid 文檔ID
* @param string $job 操作類型
* @param string $addvar 值
* @param string $admintype 管理類型
* @param string $fieldname 變量類型
* @return string
*/
function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '', $admintype = 'admin', $fieldname = '')
{
global $cfg_basedir, $cfg_cmspath, $adminid, $cfg_ml, $cfg_cookie_encode;
if (!empty($adminid)) {
$adminid = $adminid;
} else {
$adminid = isset($cfg_ml) ? $cfg_ml->M_ID : 1;
}
if ($dtype == 'int') {
if ($dvalue == '') {
return 0;
}
return GetAlabNum($dvalue);
} else {
if ($dtype == 'stepselect') {
$dvalue = trim(preg_replace("#[^0-9\\.]#", "", $dvalue));
return $dvalue;
} else {
if ($dtype == 'float') {
if ($dvalue == '') {
return 0;
}
return GetAlabNum($dvalue);
} else {
if ($dtype == 'datetime') {
if ($dvalue == '') {
return 0;
}
return GetMkTime($dvalue);
} else {
if ($dtype == 'checkbox') {
$okvalue = '';
if (is_array($dvalue)) {
$okvalue = join(',', $dvalue);
}
return $okvalue;
} else {
if ($dtype == "htmltext") {
if ($admintype == 'member' || $admintype == 'diy') {
$dvalue = HtmlReplace($dvalue, -1);
}
return $dvalue;
} else {
if ($dtype == "multitext") {
if ($admintype == 'member' || $admintype == 'diy') {
$dvalue = HtmlReplace($dvalue, 0);
}
return $dvalue;
} else {
if ($dtype == "textdata") {
$ipath = $cfg_cmspath . "/data/textdata";
$tpath = ceil($aid / 5000);
if (!is_dir($cfg_basedir . $ipath)) {
MkdirAll($cfg_basedir . $ipath, $GLOBALS['cfg_dir_purview']);
}
if (!is_dir($cfg_basedir . $ipath . '/' . $tpath)) {
MkdirAll($cfg_basedir . $ipath . '/' . $tpath, $GLOBALS['cfg_dir_purview']);
}
$ipath = $ipath . '/' . $tpath;
$filename = "{$ipath}/{$aid}-" . cn_substr(md5($cfg_cookie_encode), 0, 16) . ".txt";
//會員投稿內容安全處理
if ($admintype == 'member' || $admintype == 'diy') {
$dvalue = HtmlReplace($dvalue, -1);
}
$fp = fopen($cfg_basedir . $filename, "w");
fwrite($fp, stripslashes($dvalue));
fclose($fp);
CloseFtp();
return $filename;
} else {
if ($dtype == 'img' || $dtype == 'imgfile') {
if (preg_match("#[\\|/]uploads[\\|/]userup#", $dvalue)) {
return $dvalue;
}
if ($admintype == 'diy') {
$iurl = MemberUploads($fieldname, '', 0, 'image', '', -1, -1, false);
return $iurl;
}
$iurl = stripslashes($dvalue);
if (trim($iurl) == '') {
return '';
}
$iurl = trim(str_replace($GLOBALS['cfg_basehost'], "", $iurl));
$imgurl = "{dede:img text='' width='' height=''} " . $iurl . " {/dede:img}";
if (preg_match("/^http:\\/\\//i", $iurl) && $GLOBALS['cfg_isUrlOpen']) {
//遠程圖片
$reimgs = '';
//.........這裏部分代碼省略.........
示例12: GetFieldValue
function GetFieldValue($dvalue,$dtype,$aid=0,$job='add',$addvar='',$admintype='admin')
{
global $cfg_basedir,$cfg_cmspath,$adminID,$cfg_ml;
if(!empty($adminID)) $adminid = $adminID;
else $adminid = $cfg_ml->M_ID;
if($dtype=="int"){
return GetAlabNum($dvalue);
}
else if($dtype=="float"){
return GetAlabNum($dvalue);
}
else if($dtype=="datetime"){
return GetMkTime($dvalue);
}
else if($dtype=="checkbox"){
$okvalue = '';
if(is_array($dvalue)){
foreach($dvalue as $v){ $okvalue .= ($okvalue=='' ? $v : ",{$v}"); }
}
return $okvalue;
}
else if($dtype=="textdata")
{
if($job=='edit')
{
$addvarDirs = explode('/',$addvar);
$addvarDir = ereg_replace("/".$addvarDirs[count($addvarDirs)-1]."$","",$addvar);
$mdir = $cfg_basedir.$addvarDir;
if(!is_dir($mdir)){ MkdirAll($mdir); }
$fp = fopen($cfg_basedir.$addvar,"w");
fwrite($fp,stripslashes($dvalue));
fclose($fp);
CloseFtp();
return $addvar;
}else{
$ipath = $cfg_cmspath."/data/textdata";
$tpath = ceil($aid/5000);
if(!is_dir($cfg_basedir.$ipath)) MkdirAll($cfg_basedir.$ipath,$GLOBALS['cfg_dir_purview']);
if(!is_dir($cfg_basedir.$ipath.'/'.$tpath)) MkdirAll($cfg_basedir.$ipath.'/'.$tpath,$GLOBALS['cfg_dir_purview']);
$ipath = $ipath.'/'.$tpath;
$filename = "{$ipath}/{$aid}.txt";
$fp = fopen($cfg_basedir.$filename,"w");
fwrite($fp,stripslashes($dvalue));
fclose($fp);
CloseFtp();
return $filename;
}
}
else if($dtype=="img"||$dtype=="imgfile")
{
$iurl = stripslashes($dvalue);
if(trim($iurl)=="") return "";
$iurl = trim(str_replace($GLOBALS['cfg_basehost'],"",$iurl));
$imgurl = "{dede:img text='' width='' height=''} ".$iurl." {/dede:img}";
if(eregi("^http://",$iurl) && $GLOBALS['cfg_isUrlOpen']) //遠程圖片
{
$reimgs = "";
if($GLOBALS['cfg_isUrlOpen']){
$reimgs = GetRemoteImage($iurl,$adminid);
if(is_array($reimgs)){
if($dtype=="imgfile") $imgurl = $reimgs[1];
else $imgurl = "{dede:img text='' width='".$reimgs[1]."' height='".$reimgs[2]."'} ".$reimgs[0]." {/dede:img}";
}
}else{
if($dtype=="imgfile") $imgurl = $iurl;
else $imgurl = "{dede:img text='' width='' height=''} ".$iurl." {/dede:img}";
}
}
else if($iurl!=""){ //站內圖片
$imgfile = $cfg_basedir.$iurl;
if(is_file($imgfile)){
$info = '';
$imginfos = GetImageSize($imgfile,$info);
if($dtype=="imgfile") $imgurl = $iurl;
else $imgurl = "{dede:img text='' width='".$imginfos[0]."' height='".$imginfos[1]."'} $iurl {/dede:img}";
}
}
return addslashes($imgurl);
}else{
return $dvalue;
}
}
示例13: log_export
public function log_export()
{
if (!IS_POST) {
$this->message2('', '失敗', 0);
}
$log_model = new Model('kongbao_order');
$userid = session('userid');
$where['user_id'] = $userid;
$where['order_status'] = 1;
$keyword = I('keyword', NULL);
$ftype = I('ftype', NULL);
if (!empty($keyword) && !empty($ftype)) {
$where[$ftype] = array('like', '%' . $keyword . '%');
}
$type_id = I('type_id', '');
if ($type_id != '') {
$where['type_id'] = $type_id;
}
$log_list = $log_model->where($where)->order('order_time desc')->select();
$log_array = array();
$kb_type = M('kongbao_type')->select();
$type_array = array();
foreach ($kb_type as $type) {
$type_array[$type['id']] = $type['name'];
}
$i = 0;
foreach ($log_list as $k => $log) {
$i++;
$log_temp = array();
$log_temp[] = $i;
$log_temp[] = $type_array[$log['type_id']];
$log_temp[] = $log['order_time'];
$log_temp[] = $log['note_no'];
$log_temp[] = $log['send_province'] . '-' . $log['send_city'] . '-' . $log['send_district'];
$log_temp[] = $log['rec_province'] . '-' . $log['rec_city'] . '-' . $log['rec_district'] . $log['rec_address'];
$log_temp[] = $log['rec_name'];
$log_array[] = $log_temp;
}
$headers = array(array('序號', '快遞類型', '下單時間', '單號', '發貨地址', '收貨地址', '收貨人'));
$order_counts = count($log_array);
$file_name = $userid . '-' . $order_counts . '-' . time();
$fileurl = 'Public/Uploads/kb_log/' . $userid . '/';
MkdirAll($fileurl);
$filename = $file_name . '.xls';
$fileurl = $fileurl . md5($file_name) . '.xls';
include 'Public/PHPExcel/PHPExcel.php';
include 'Public/PHPExcel/PHPExcel/Writer/Excel5.php';
include 'Public/PHPExcel/PHPExcel/Cell/DataType.php';
$m_objPHPExcel = new PHPExcel();
$this->write_xls($m_objPHPExcel, $fileurl, $headers, $log_array);
import('ORG.Net.Http');
ob_end_clean();
$download = new Http();
$download->download($fileurl, $filename);
exit;
}
示例14: MemberUploads
function MemberUploads($upname, $handname, $userid = 0, $utype = 'image', $exname = '', $maxwidth = 0, $maxheight = 0, $water = false, $isadmin = false)
{
global $cfg_imgtype, $cfg_mb_addontype, $cfg_mediatype, $cfg_user_dir, $cfg_basedir, $cfg_dir_purview;
//當為遊客投稿的情況下,這個 id 為 0
if (empty($userid)) {
$userid = 0;
}
if (!is_dir($cfg_basedir . $cfg_user_dir . "/{$userid}")) {
MkdirAll($cfg_basedir . $cfg_user_dir . "/{$userid}", $cfg_dir_purview);
CloseFtp();
}
//有上傳文件
$allAllowType = str_replace('||', '|', $cfg_imgtype . '|' . $cfg_mediatype . '|' . $cfg_mb_addontype);
if (!empty($GLOBALS[$upname]) && is_uploaded_file($GLOBALS[$upname])) {
$nowtme = time();
$GLOBALS[$upname . '_name'] = trim(ereg_replace("[ \r\n\t\\*\\%\\/\\?><\\|\":]{1,}", '', $GLOBALS[$upname . '_name']));
//源文件類型檢查
if ($utype == 'image') {
if (!eregi("\\.(" . $cfg_imgtype . ")\$", $GLOBALS[$upname . '_name'])) {
ShowMsg("你所上傳的圖片類型不在許可列表,請上傳{$cfg_imgtype}類型!", '-1');
exit;
}
$sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp");
$imgfile_type = strtolower(trim($GLOBALS[$upname . '_type']));
if (!in_array($imgfile_type, $sparr)) {
ShowMsg('上傳的圖片格式錯誤,請使用JPEG、GIF、PNG、WBMP格式的其中一種!', '-1');
exit;
}
} else {
if ($utype == 'flash' && !eregi("\\.swf\$", $GLOBALS[$upname . '_name'])) {
ShowMsg('上傳的文件必須為flash文件!', '-1');
exit;
} else {
if ($utype == 'media' && !eregi("\\.(" . $cfg_mediatype . ")\$", $GLOBALS[$upname . '_name'])) {
ShowMsg('你所上傳的文件類型必須為:' . $cfg_mediatype, '-1');
exit;
} else {
if (!eregi("\\.(" . $allAllowType . ")\$", $GLOBALS[$upname . '_name'])) {
ShowMsg("你所上傳的文件類型不被允許!", '-1');
exit;
}
}
}
}
//再次嚴格檢測文件擴展名是否符合係統定義的類型
$fs = explode('.', $GLOBALS[$upname . '_name']);
$sname = $fs[count($fs) - 1];
$alltypes = explode('|', $allAllowType);
if (!in_array(strtolower($sname), $alltypes)) {
ShowMsg('你所上傳的文件類型不被允許!', '-1');
exit;
}
//強製禁止的文件類型
if (eregi("\\.(asp|php|pl|cgi|shtm|js)", $sname)) {
ShowMsg('你上傳的文件為係統禁止的類型!', '-1');
exit;
}
if ($exname == '') {
$filename = $cfg_user_dir . "/{$userid}/" . dd2char($nowtme . '-' . mt_rand(1000, 9999)) . '.' . $sname;
} else {
$filename = $cfg_user_dir . "/{$userid}/{$exname}." . $sname;
}
move_uploaded_file($GLOBALS[$upname], $cfg_basedir . $filename) or die("上傳文件到 {$filename} 失敗!");
@unlink($GLOBALS[$upname]);
if (@filesize($cfg_basedir . $filename) > $GLOBALS['cfg_mb_upload_size'] * 1024) {
@unlink($cfg_basedir . $filename);
ShowMsg('你上傳的文件超出係統大小限製!', '-1');
exit;
}
//加水印或縮小圖片
if ($utype == 'image') {
include_once DEDEINC . '/image.func.php';
if ($maxwidth > 0 || $maxheight > 0) {
ImageResize($cfg_basedir . $filename, $maxwidth, $maxheight);
} else {
if ($water) {
WaterImg($cfg_basedir . $filename);
}
}
}
return $filename;
} else {
//強製禁止的文件類型
if ($handname == '') {
return $handname;
} else {
if (eregi("\\.(asp|php|pl|cgi|shtm|js)", $handname)) {
exit('Not allow filename for not safe!');
} else {
if (!eregi("\\.(" . $allAllowType . ")\$", $handname)) {
exit('Not allow filename for filetype!');
} else {
if (!eregi('^http:', $handname) && !eregi('^' . $cfg_user_dir . '/' . $userid, $handname) && !$isadmin) {
exit('Not allow filename for not userdir!');
}
}
}
}
return $handname;
}
//.........這裏部分代碼省略.........
示例15: time
}
if(ereg("^text",$imgfile_type)){
ShowMsg("不允許文本類型附件!","-1");
exit();
}
$nowtme = time();
$sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png","image/x-png","image/wbmp");
$imgfile_type = strtolower(trim($imgfile_type));
if(!in_array($imgfile_type,$sparr)){
ShowMsg("上傳的圖片格式錯誤,請使用JPEG、GIF、PNG、WBMP格式的其中一種!","-1");
exit();
}
$mdir = strftime("%y%m%d",$nowtme);
if(!is_dir($cfg_basedir.$activepath."/$mdir")){
MkdirAll($cfg_basedir.$activepath."/$mdir",$GLOBALS['cfg_dir_purview']);
CloseFtp();
}
$sname = '.jpg';
//圖片的限定擴展名
if($imgfile_type=='image/pjpeg'||$imgfile_type=='image/jpeg'){
$sname = '.jpg';
}else if($imgfile_type=='image/gif'){
$sname = '.gif';
}else if($imgfile_type=='image/png'){
$sname = '.png';
}else if($imgfile_type=='image/wbmp'){
$sname = '.bmp';
}