Ejemplo n.º 1
0
	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;
	  }
	}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
 /**
  *  移动文件
  *
  * @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} -&gt; {$truepath}/{$mfile} 失败,可能是某个位置权限不足!", "file_manage_main.php?activepath={$mpath}", 0, 1000);
             return 0;
         }
     } else {
         ShowMsg("对不起,你移动的路径不合法!", "-1", 0, 5000);
         return 0;
     }
 }
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;
}
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);
}
Ejemplo n.º 6
0
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);
}
/**
 * 获得文章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;
}
Ejemplo n.º 8
0
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);
Ejemplo n.º 9
0
    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;
    }
Ejemplo n.º 10
0
             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) {
Ejemplo n.º 11
0
/**
 *  处理不同类型的数据
 *
 * @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 = '';
                                            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 {
                                        if ($dtype == 'addon' && $admintype == 'diy') {
                                            if (preg_match("#[\\|/]uploads[\\|/]userup#", $dvalue)) {
                                                return $dvalue;
                                            }
                                            $dvalue = MemberUploads($fieldname, '', 0, 'addon', '', -1, -1, false);
                                            return $dvalue;
                                        } else {
                                            if ($admintype == 'member' || $admintype == 'diy') {
                                                $dvalue = HtmlReplace($dvalue, 1);
                                            }
                                            return $dvalue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
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;
	}
}
Ejemplo n.º 13
0
 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;
 }
Ejemplo n.º 14
0
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;
    }
}
	}
	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';
	}
	
Ejemplo n.º 16
0
 public function dbbak()
 {
     if (!IS_POST) {
         $this->message2('无效请求!', __APP__ . '/Admin');
     }
     $tablearr = I('tablearr', NULL);
     if (empty($tablearr)) {
         echo '你没选中任何表!';
         exit;
     }
     $bkdir = 'Public/Uploads/backupdata';
     if (!is_dir($bkdir)) {
         MkdirAll($bkdir);
     }
     if (empty($_POST['tablearr'])) {
         $table = $this->getTable();
     } else {
         $table = explode(',', $_POST['tablearr']);
     }
     $struct = $this->bakStruct($table);
     $record = $this->bakRecord($table);
     $sqls = $struct . $record;
     $dir = $bkdir . '/' . date('y-m-d') . '.sql';
     if (file_exists($dir)) {
         unlink($dir);
     }
     file_put_contents($dir, $sqls);
     if (file_exists($dir)) {
         echo '备份成功';
         exit;
     } else {
         echo '备份失败';
         exit;
     }
 }
Ejemplo n.º 17
0
		else if(eregi('audio|media|video',$upfile_type)
	  && eregi("\.".$cfg_softtype."$",$upfile_name)){
		  $mediatype=3;
		  $savePath = $cfg_other_medias."/".$dpath;
		}
		else if(eregi("\.".$cfg_softtype."$",$upfile_name)){
			$mediatype=4;
			$savePath = $cfg_soft_dir."/".$dpath;
		}
		else continue;
		$filename = "{$adminid}_".strftime("%H%M%S",$uptime).mt_rand(100,999).$i;
		$fs = explode(".",${"upfile".$i."_name"});
		$filename = $filename.".".$fs[count($fs)-1];
		$filename = $savePath."/".$filename;
		if(!is_dir($cfg_basedir.$savePath)){
			MkdirAll($cfg_basedir.$savePath,$GLOBALS['cfg_dir_purview']);
			CloseFtp();
		}
		$fullfilename = $cfg_basedir.$filename;
    if($mediatype==1){
       @move_uploaded_file(${"upfile".$i},$fullfilename);
       $info = "";
    	 $data = getImagesize($fullfilename,$info);
    	 $width = $data[0];
    	 $height = $data[1];
		 	if(in_array($upfile_type,$cfg_photo_typenames)) WaterImg($fullfilename,'up');
    }else{
       @move_uploaded_file(${"upfile".$i},$fullfilename);
    }
    if($i>1){ $ntitle = $title."_".$i; }
    else $ntitle = $title;
Ejemplo n.º 18
0
<?php 
require_once(dirname(__FILE__)."/config.php");
if(empty($job)) $job = "";
if($job=="newdir")
{
	$dirname = trim(ereg_replace("[ \r\n\t\.\*\%\\/\?><\|\":]{1,}","",$dirname));
	if($dirname==""){
		ShowMsg("目录名非法!","-1");
		exit();
	}
	MkdirAll($cfg_basedir.$activepath."/".$dirname,$GLOBALS['cfg_dir_purview']);
	CloseFtp();
	ShowMsg("成功创建一个目录!","select_soft.php?f=$f&activepath=".urlencode($activepath."/".$dirname));
	exit();
}
if($job=="upload")
{
	if(empty($uploadfile)) $uploadfile = "";
	if(!is_uploaded_file($uploadfile)){
		 ShowMsg("你没有选择上传的文件!","-1");
	   exit();
	}
	if(ereg("^text",$uploadfile_type)){
		ShowMsg("不允许文本类型附件!","-1");
		exit();
	}
	if(!eregi("\.".$cfg_softtype,$uploadfile_name))
	{
		ShowMsg("你所上传的文件类型不能被识别,请更改系统对扩展名限定的配置!","-1");
		exit();
	}
Ejemplo n.º 19
0
}
$bkdir = DEDEDATA . '/' . $cfg_backup_dir;
//跳转到一下页的JS
$gotojs = "function GotoNextPage(){\r\n    document.gonext." . "submit();\r\n}" . "\r\nset" . "Timeout('GotoNextPage()',500);";
$dojs = "<script language='javascript'>{$gotojs}</script>";
/*--------------------
备份数据
function __bak_data();
--------------------*/
if ($dopost == 'bak') {
    if (empty($tablearr)) {
        ShowMsg('你没选中任何表!', 'javascript:;');
        exit;
    }
    if (!is_dir($bkdir)) {
        MkdirAll($bkdir, $cfg_dir_purview);
        CloseFtp();
    }
    //初始化使用到的变量
    $tables = explode(',', $tablearr);
    if (!isset($isstruct)) {
        $isstruct = 0;
    }
    if (!isset($startpos)) {
        $startpos = 0;
    }
    if (!isset($iszip)) {
        $iszip = 0;
    }
    if (empty($nowtable)) {
        $nowtable = '';
Ejemplo n.º 20
0
/**
 *  获得文章body里的外部资源
 *
 * @access    public
 * @param     string  $body  内容
 * @return    string
 */
function GetCurContent(&$body)
{
    global $cfg_multi_site, $cfg_basehost, $cfg_basedir, $cfg_user_dir, $title, $cfg_ml;
    include_once DEDEINC . "/dedecollection.func.php";
    $htd = new DedeHttpDown();
    $basehost = "http://" . $_SERVER["HTTP_HOST"];
    $img_array = array();
    preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\\/\\/([^>]*)\\.(gif|jpg|png))/isU", $body, $img_array);
    $img_array = array_unique($img_array[2]);
    $imgUrl = $cfg_user_dir . "/" . $cfg_ml->M_ID;
    $imgPath = $cfg_basedir . $imgUrl;
    if (!is_dir($imgPath . "/")) {
        MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']);
        CloseFtp();
    }
    $milliSecond = MyDate("ymdHis", 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) {
            $body = str_replace($value, $fileurl, $body);
            @WaterImg($rndFileName, 'down');
        }
        $info = '';
        $imginfos = GetImageSize($rndFileName, $info);
        SaveUploadInfo($title, $fileurl, 1, $imginfos);
    }
    $htd->Close();
    return $body;
}
Ejemplo n.º 21
0
 /**
  *  获得下载媒体的随机名称
  *
  * @access    public
  * @param     string  $url  地址
  * @param     string  $v  值
  * @return    string
  */
 function GetRndName($url, $v)
 {
     global $cfg_image_dir, $cfg_dir_purview;
     $this->mediaCount++;
     $mnum = $this->mediaCount;
     $timedir = "c" . MyDate("ymd", time());
     //存放路径
     $fullurl = preg_replace("#\\/{1,}#", "/", $cfg_image_dir . "/");
     if (!is_dir($GLOBALS['cfg_basedir'] . "/{$fullurl}")) {
         MkdirAll($GLOBALS['cfg_basedir'] . "/{$fullurl}", $cfg_dir_purview);
     }
     $fullurl = $fullurl . $timedir . "/";
     if (!is_dir($GLOBALS['cfg_basedir'] . "/{$fullurl}")) {
         MkdirAll($GLOBALS['cfg_basedir'] . "/{$fullurl}", $cfg_dir_purview);
     }
     //文件名称
     $timename = str_replace('.', '', ExecTime());
     $threadnum = 0;
     if (isset($_GET['threadnum'])) {
         $threadnum = intval($_GET['threadnum']);
     }
     $filename = dd2char($timename . $threadnum . '-' . $mnum . mt_rand(1000, 9999));
     //分配扩展名
     $urls = explode('.', $url);
     if ($v == 'img') {
         $shortname = '.jpg';
         if (preg_match("#\\.gif\$#i", $url)) {
             $shortname = '.gif';
         } else {
             if (preg_match("#\\.png\$#i", $url)) {
                 $shortname = '.png';
             }
         }
     } else {
         if ($v == 'embed') {
             $shortname = '.swf';
         } else {
             $shortname = '';
         }
     }
     $fullname = $fullurl . $filename . $shortname;
     return preg_replace("#\\/{1,}#", "/", $fullname);
 }
Ejemplo n.º 22
0
		 	  	exit();
     	  }
     }else{
     	  if(!eregi("\.".$cfg_softtype,$upfile_name)){
     	  	ShowMsg("你上传的附件扩展名无法被识别,请更改系统配置的参数!","javascript:history.go(-1);");
		 	  	exit();
     	  } 
     }
     //保存文件
     $nowtime = time();
     $oldfile = $myrow['url'];
     $oldfiles = explode('/',$oldfile);
     $fullfilename = $cfg_basedir.$oldfile;
     $oldfile_path = ereg_replace($oldfiles[count($oldfiles)-1]."$","",$oldfile);
		 if(!is_dir($cfg_basedir.$oldfile_path)){
		 	  MkdirAll($cfg_basedir.$oldfile_path,$GLOBALS['cfg_dir_purview']);
		 	  CloseFtp();
		 }
		 @move_uploaded_file($upfile,$fullfilename);
		 if($mediatype==1){
		 	  require_once(dirname(__FILE__)."/../include/inc_photograph.php");
		 	  if(in_array($upfile_type,$cfg_photo_typenames)) WaterImg($fullfilename,'up');
		 }
		 $filesize = $upfile_size;
		 $imgw = 0;
		 $imgh = 0;
		 if($mediatype==1){
		 	 $info = "";
       $sizes[0] = 0; $sizes[1] = 0;
	     @$sizes = getimagesize($fullfilename,$info);
	     $imgw = $sizes[0];
Ejemplo n.º 23
0
         } else {
             if (!preg_match("#\\." . $cfg_softtype . "#", $upfile_name)) {
                 ShowMsg("你上传的附件扩展名无法被识别,请更改系统配置的参数!", "javascript:history.go(-1);");
                 exit;
             }
         }
     }
 }
 //保存文件
 $nowtime = time();
 $oldfile = $myrow['url'];
 $oldfiles = explode('/', $oldfile);
 $fullfilename = $cfg_basedir . $oldfile;
 $oldfile_path = preg_replace("#" . $oldfiles[count($oldfiles) - 1] . "\$#", "", $oldfile);
 if (!is_dir($cfg_basedir . $oldfile_path)) {
     MkdirAll($cfg_basedir . $oldfile_path, 777);
     CloseFtp();
 }
 @move_uploaded_file($upfile, $fullfilename);
 if ($mediatype == 1) {
     require_once DEDEINC . "/image.func.php";
     if (in_array($upfile_type, $cfg_photo_typenames)) {
         WaterImg($fullfilename, 'up');
     }
 }
 $filesize = $upfile_size;
 $imgw = 0;
 $imgh = 0;
 if ($mediatype == 1) {
     $info = "";
     $sizes[0] = 0;
Ejemplo n.º 24
0
function GetCurContent($body)
{
    global $cfg_multi_site, $cfg_basehost, $cfg_basedir, $cfg_image_dir;
    $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]);
    $imgUrl = $cfg_uploaddir . '/' . MyDate("ymd", time());
    $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 (eregi($basehost, $value)) {
            continue;
        }
        if ($cfg_basehost != $basehost && eregi($cfg_basehost, $value)) {
            continue;
        }
        if (!eregi("^http://", $value)) {
            continue;
        }
        $htd->OpenUrl($value);
        $itype = $htd->GetHead("content-type");
        $itype = substr($value, -4, 4);
        if (!eregi("\\.(jpg|gif|png)", $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) {
            if ($cfg_multi_site == 'Y') {
                $fileurl = $cfg_basehost . $fileurl;
            }
            $body = str_replace($value, $fileurl, $body);
            @WaterImg($rndFileName, 'down');
        }
    }
    $htd->Close();
    return $body;
}
Ejemplo n.º 25
0
CheckPurview('plus_友情链接模块');

$dsql = new DedeSql(false);

if(empty($dopost)) $dopost="";
if($dopost=="add")
{
   $dtime = strftime("%Y-%m-%d %H:%M:%S",time());
   if(is_uploaded_file($logoimg))
   {
	   $names = split("\.",$logoimg_name);
	   $shortname = ".".$names[count($names)-1];
	   $filename = strftime("%Y%m%d%H%M%S",time()).mt_rand(1000,9999).$shortname;
	   $imgurl = $cfg_medias_dir."/flink";
	   if(!is_dir($cfg_basedir.$imgurl)){
	   	  MkdirAll($cfg_basedir.$imgurl,$GLOBALS['cfg_dir_purview']);
	   	  CloseFtp();
	   }
	   $imgurl = $imgurl."/".$filename;
	   move_uploaded_file($logoimg,$cfg_basedir.$imgurl) or die("复制文件到:".$cfg_basedir.$imgurl."失败");
	   @unlink($logoimg);
   }
   else 
	 { $imgurl = $logo; }
   $query = "Insert Into #@__flink(sortrank,url,webname,logo,msg,email,typeid,dtime,ischeck) 
   Values('$sortrank','$url','$webname','$imgurl','$msg','$email',$typeid,'$dtime','$ischeck')";
   $dsql->SetQuery($query);
   $dsql->ExecuteNoneQuery();
   if(!empty($_COOKIE['ENV_GOBACK_URL'])) $burl = $_COOKIE['ENV_GOBACK_URL'];
   else $burl = "friendlink_main.php";
   $dsql->Close();
Ejemplo n.º 26
0
$CKEditorFuncNum = isset($CKEditorFuncNum) ? $CKEditorFuncNum : 1;
$imgfile_name = trim(preg_replace("#[ \r\n\t\\*\\%\\\\/\\?><\\|\":]{1,}#", '', $imgfile_name));
if (!preg_match("#\\.(" . $cfg_imgtype . ")#i", $imgfile_name)) {
    ShowMsg("你所上传的图片类型不在许可列表,请更改系统对扩展名限定的配置!", "-1");
    exit;
}
$nowtme = time();
$sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp");
$imgfile_type = strtolower(trim($imgfile_type));
if (!in_array($imgfile_type, $sparr)) {
    ShowMsg("上传的图片格式错误,请使用JPEG、GIF、PNG、WBMP格式的其中一种!", "-1");
    exit;
}
$mdir = MyDate($cfg_addon_savetype, $nowtme);
if (!is_dir($cfg_basedir . $activepath . "/{$mdir}")) {
    MkdirAll($cfg_basedir . $activepath . "/{$mdir}", $cfg_dir_purview);
    CloseFtp();
}
$filename_name = $cuserLogin->getUserID() . '-' . dd2char(MyDate("ymdHis", $nowtme) . mt_rand(100, 999));
$filename = $mdir . '/' . $filename_name;
$fs = explode('.', $imgfile_name);
$filename = $filename . '.' . $fs[count($fs) - 1];
$filename_name = $filename_name . '.' . $fs[count($fs) - 1];
$fullfilename = $cfg_basedir . $activepath . "/" . $filename;
move_uploaded_file($imgfile, $fullfilename) or die("上传文件到 {$fullfilename} 失败!");
if ($cfg_remote_site == 'Y' && $remoteuploads == 1) {
    //分析远程文件路径
    $remotefile = str_replace(DEDEROOT, '', $fullfilename);
    $localfile = '../..' . $remotefile;
    //创建远程文件夹
    $remotedir = preg_replace('/[^\\/]*\\.(jpg|gif|bmp|png)/', '', $remotefile);
         } else {
             if (preg_match("#\\." . $cfg_softtype . "+\\." . $cfg_softtype . "\$#i", $upfile_name)) {
                 $mediatype = 4;
                 $savePath = $cfg_soft_dir . "/" . $dpath;
             } else {
                 continue;
             }
         }
     }
 }
 $filename = "{$adminid}_" . MyDate("His", $uptime) . mt_rand(100, 999) . $i;
 $fs = explode(".", ${"upfile" . $i . "_name"});
 $filename = $filename . "." . $fs[count($fs) - 1];
 $filename = $savePath . "/" . $filename;
 if (!is_dir($cfg_basedir . $savePath)) {
     MkdirAll($cfg_basedir . $savePath, 777);
     CloseFtp();
 }
 $fullfilename = $cfg_basedir . $filename;
 if ($mediatype == 1) {
     @move_uploaded_file(${"upfile" . $i}, $fullfilename);
     $info = '';
     $data = getImagesize($fullfilename, $info);
     $width = $data[0];
     $height = $data[1];
     if (in_array($upfile_type, $cfg_photo_typenames)) {
         WaterImg($fullfilename, 'up');
     }
 } else {
     @move_uploaded_file(${"upfile" . $i}, $fullfilename);
 }
Ejemplo n.º 28
0
 public function order_exp_post()
 {
     if (!IS_AJAX) {
         $this->message2('无效请求', __APP__ . '/Admin');
     }
     $type_list = M('kongbao_type')->where('state=0')->order('is_true desc,id asc')->select();
     $exp_time = time();
     $exp_date = date('Ymd', $exp_time);
     $exp_datetime = date('Y-m-d H:i:s', $exp_time);
     $exp_date_new = date('YmdHis', $exp_time);
     $where = array();
     $where['exp_date'] = $exp_date;
     $sys_config = M('config')->where('id=1')->find();
     $sys_config = json_decode($sys_config['kongbao_config'], true);
     $count = M('exp_log')->where($where)->count();
     if (0 < $count && $sys_config['exp_setting'] != 1) {
         $this->ajaxReturn('', '今日已经做过批量导出!', 0);
     }
     include 'Public/PHPExcel/PHPExcel.php';
     include 'Public/PHPExcel/PHPExcel/Writer/Excel5.php';
     include 'Public/PHPExcel/PHPExcel/Cell/DataType.php';
     $output_path = 'Public/Uploads/kb_log/';
     MkdirAll($output_path);
     $post_type_id = I('type_id', '');
     foreach ($type_list as $k => $type) {
         if ($post_type_id != '') {
             if ($type['id'] != $post_type_id) {
                 continue;
             }
         }
         $type_id = $type['id'];
         $type_name = $type['name'];
         $type['last_down_time'] = $type['last_down_time'] + 1;
         $last_datetime = date('Y-m-d H:i:s', $type['last_down_time']);
         $last_date = date('YmdHis', $type['last_down_time']);
         $where = array();
         $where['type_id'] = $type_id;
         $where['order_status'] = 1;
         $where['order_time'] = array('between', array($last_datetime, $exp_datetime));
         $headers = $this->getHeaderFromFile_kb($type['exp_id']);
         $fields = $this->getFieldFromFile_kb($type['exp_id']);
         $exp_list_temp = M('kongbao_order')->field($fields)->where($where)->order('note_no asc,order_time desc')->select();
         $exp_list = array();
         $i = 0;
         foreach ($exp_list_temp as $k => $v) {
             $i++;
             if (isset($v['id'])) {
                 $v['id'] = $i;
             }
             if (isset($v['type_id'])) {
                 $v['type_id'] = $type_name;
             }
             $exp_list[] = $v;
         }
         $order_counts = count($exp_list);
         $filename = $type_name . '-' . $order_counts . '-' . $last_date . '-' . $exp_date_new . '.xls';
         $fileurl = $output_path . md5($type_name . '-' . $order_counts . '-' . $last_date . '-' . $exp_date_new) . '.xls';
         $update_array = array();
         $update_array['exp_status'] = 1;
         M('kongbao_order')->where($where)->data($update_array)->save();
         $m_objPHPExcel = new PHPExcel();
         $this->write_xls($m_objPHPExcel, $fileurl, $headers, $exp_list);
         $logdata = array();
         $logdata['type_id'] = $type_id;
         $logdata['type_name'] = $type_name;
         $logdata['exp_counts'] = count($exp_list);
         $logdata['exp_filename'] = $filename;
         $logdata['exp_fileurl'] = $fileurl;
         $logdata['last_time'] = $last_datetime;
         $logdata['exp_time'] = $exp_datetime;
         $logdata['exp_date'] = $exp_date;
         M('exp_log')->data($logdata)->add();
         $updatedata = array();
         $updatedata['id'] = $type_id;
         $updatedata['last_down_time'] = $exp_time;
         M('kongbao_type')->data($updatedata)->save();
     }
     $this->ajaxReturn('', '执行完毕!', 1);
 }
Ejemplo n.º 29
0
function GetFieldValue($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '')
{
    global $cfg_cookie_encode, $cfg_dir_purview;
    if ($dtype == "int") {
        $dvalue = trim(ereg_replace("[^0-9]", "", $dvalue));
        if ($dvalue == "") {
            $dvalue = 0;
        }
        return $dvalue;
    } else {
        if ($dtype == "float") {
            $dvalue = trim(ereg_replace("[^0-9\\.]", "", $dvalue));
            if ($dvalue == "") {
                $dvalue = 0;
            }
            return $dvalue;
        } else {
            if ($dtype == "datetime") {
                return GetMkTime($dvalue);
            } else {
                if ($dtype == "textdata") {
                    if ($job == 'edit') {
                        $addvarDirs = explode('/', $addvar);
                        $addvarDir = ereg_replace("/" . $addvarDirs[count($addvarDirs) - 1] . "\$", "", $addvar);
                        $mdir = $GLOBALS['cfg_basedir'] . $addvarDir;
                        if (!is_dir($mdir)) {
                            MkdirAll($mdir, $GLOBALS['cfg_dir_purview']);
                        }
                        $fp = fopen($GLOBALS['cfg_basedir'] . $addvar, "w");
                        fwrite($fp, stripslashes($dvalue));
                        fclose($fp);
                        CloseFtp();
                        return $addvar;
                    } else {
                        $ipath = $GLOBALS['cfg_cmspath'] . "/data/textdata";
                        $tpath = ceil($aid / 5000);
                        if (!is_dir($GLOBALS['cfg_basedir'] . $ipath)) {
                            MkdirAll($GLOBALS['cfg_basedir'] . $ipath, $cfg_dir_purview);
                        }
                        if (!is_dir($GLOBALS['cfg_basedir'] . $ipath . '/' . $tpath)) {
                            MkdirAll($GLOBALS['cfg_basedir'] . $ipath . '/' . $tpath, $cfg_dir_purview);
                        }
                        $ipath = $ipath . '/' . $tpath;
                        $filename = "{$ipath}/{$aid}-" . cn_substr(md5($cfg_cookie_encode), 0, 16) . ".txt";
                        $fp = fopen($GLOBALS['cfg_basedir'] . $filename, "w");
                        fwrite($fp, stripslashes($dvalue));
                        fclose($fp);
                        CloseFtp();
                        return $filename;
                    }
                } else {
                    if ($dtype == "img") {
                        $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['isUrlOpen']) {
                            //远程图片
                            $reimgs = "";
                            if ($isUrlOpen) {
                                $reimgs = GetRemoteImage($iurl, $GLOBALS['adminid']);
                                if (is_array($reimgs)) {
                                    $imgurl = "{dede:img text='' width='" . $reimgs[1] . "' height='" . $reimgs[2] . "'} " . $reimgs[0] . " {/dede:img}";
                                }
                            } else {
                                $imgurl = "{dede:img text='' width='' height=''} " . $iurl . " {/dede:img}";
                            }
                        } else {
                            if ($iurl != "") {
                                //站内图片
                                $imgfile = $GLOBALS['cfg_basedir'] . $iurl;
                                if (is_file($imgfile)) {
                                    $imginfos = GetImageSize($imgfile, &$info);
                                    $imgurl = "{dede:img text='' width='" . $imginfos[0] . "' height='" . $imginfos[1] . "'} {$iurl} {/dede:img}";
                                }
                            }
                        }
                        return addslashes($imgurl);
                    } else {
                        return $dvalue;
                    }
                }
            }
        }
    }
}
function GetCurContent($body)
{
	global $cfg_multi_site,$cfg_basehost;
	$cfg_uploaddir = $GLOBALS['cfg_image_dir'];
	$cfg_basedir = $GLOBALS['cfg_basedir'];
	$htd = new DedeHttpDown();
	
	$basehost = "http://".$_SERVER["HTTP_HOST"];
	
	/*
	//避免删除本地链接
	if($cfg_multi_site == 'N'){
		$body = str_replace(strtolower($basehost),"",$body);
		$body = str_replace(strtoupper($basehost),"",$body);
	}else{
		if($cfg_basehost!=$basehost){
			$body = str_replace(strtolower($basehost),$cfg_basehost,$body);
			$body = str_replace(strtoupper($basehost),$cfg_basehost,$body);
		}
	}
	*/
  
	$img_array = array();
	preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\/\/(.*)\.(gif|jpg|jpeg|bmp|png))/isU",$body,$img_array);
	$img_array = array_unique($img_array[2]);
	
	$imgUrl = $cfg_uploaddir."/".strftime("%y%m%d",time());
	$imgPath = $cfg_basedir.$imgUrl;
	if(!is_dir($imgPath."/")){
		MkdirAll($imgPath,$GLOBALS['cfg_dir_purview']);
		CloseFtp();
	}
	$milliSecond = strftime("%H%M%S",time());
	
	foreach($img_array as $key=>$value)
	{
		if(eregi($basehost,$value)) continue;
		if($cfg_basehost!=$basehost && eregi($cfg_basehost,$value)) continue;
		if(!eregi("^http://",$value)) continue;
		//随机命名文件
		$htd->OpenUrl($value);
		$itype = $htd->GetHead("content-type");
		if($itype=="image/gif") $itype = ".gif";
		else if($itype=="image/png") $itype = ".png";
		else $itype = ".jpg";
		$value = trim($value);
		$rndFileName = $imgPath."/".$milliSecond.$key.$itype;
		$fileurl = $imgUrl."/".$milliSecond.$key.$itype;
		//下载并保存文件
		$rs = $htd->SaveToBin($rndFileName);
		if($rs){
			$body = str_replace($value,$fileurl,$body);
			@WaterImg($rndFileName,'down');
	  }
	}
	$htd->Close();
	return $body;
}