示例#1
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;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
			foreach($marr as $k=>$v){
			  $rmfalsh = $k;
			  break;
		  }
		}
		else
		{
			foreach($marr as $k=>$v){
			  $rmfalsh = $k;
			  if(GetAlabNum($dml->MediaInfos[$rmfalsh][0])>300&&
			  GetAlabNum($dml->MediaInfos[$rmfalsh][1])>250)
			  { break; }
		  }
		}
		$width  = GetAlabNum($dml->MediaInfos[$rmfalsh][0]);
		$height = GetAlabNum($dml->MediaInfos[$rmfalsh][1]);
	}
	$dml->Clear();
	if($cfg_isUrlOpen && $downremote==1) $rmflash = GetRemoteFlash($rmfalsh,$adminID);
}
//Flash Url 为远程地址
else if(eregi("^http://",$flashurl)
  && !eregi($cfg_basehost,$flashurl) && $downremote==1)
{
	if($cfg_isUrlOpen) $rmflash = GetRemoteFlash($flashurl,$adminID);
}

if($width==0)  $width  = "500";
if($height==0) $height = "350";
if($rmflash!="") $flashurl = $rmflash;
$shorttitle = cn_substr($shorttitle,36);
$color =  cn_substr($color,10);
$writer =  cn_substr($writer,30);
$source = cn_substr($source,50);
$description = cn_substr($description,250);
if($keywords!="") $keywords = trim(cn_substr($keywords,50))." ";
if(!TestPurview('a_Check,a_AccCheck,a_MyCheck')){ $arcrank = -1; }

//处理上传的缩略图
if(empty($ddisremote)) $ddisremote = 0;
$litpic = GetDDImage('none',$picname,$ddisremote);

$filesize = $filesize;
$playtime = $tms; 
$width  = GetAlabNum($width);
$height = GetAlabNum($height);

//处理远程的Flash
//------------------
if(empty($downremote)) $downremote = 0;
$rmflash = "";
if(eregi("^http://",$flashurl) 
  && !eregi($cfg_basehost,$flashurl) && $downremote==1)
{
	if($cfg_isUrlOpen) $rmflash = GetRemoteFlash($flashurl,$adminID);
}
if($width==0)  $width  = "500";
if($height==0) $height = "350";
if($rmflash!="") $flashurl = $rmflash;

if($flashurl==""){
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;
	}
}
示例#5
0
     if ($oldcomface != '' && file_exists($cfg_basedir . $oldcomface)) {
         @unlink($cfg_basedir . $oldcomface);
     }
     //上传新工图片
     $comface = MemberUploads('comface', '', $cfg_ml->M_ID, 'image', 'comface', 600, 450);
 } else {
     $comface = $oldcomface;
 }
 if (empty($city)) {
     $place = $province;
 } else {
     $place = $city;
 }
 $tel = GetAlabNum($tel);
 $fax = GetAlabNum($fax);
 $mobile = GetAlabNum($mobile);
 $email = cn_substrR(eregi_replace("[^0-9a-z\\.@-]", '', $email), 50);
 $url = cn_substrR(eregi_replace("[^0-9a-z\\.:/-]", '', $url), 50);
 $product = cn_substrR(HtmlReplace($product, 1), 20);
 $linkman = cn_substrR(HtmlReplace($linkman, 1), 20);
 $company = cn_substrR(HtmlReplace($company, 1), 36);
 $address = cn_substrR(HtmlReplace($address, 1), 50);
 $introduce = HtmlReplace($introduce, -1);
 $uptime = time();
 $dsql->ExecuteNoneQuery("Delete From `#@__member_company` where mid='{$cfg_ml->M_ID}' ");
 $inquery = "INSERT INTO `#@__member_company` (`mid` , `company` , `product` , `place` , `vocation` , `cosize` , `tel` , `fax` , `linkman` , `address`,`uptime` ,`mobile`,`email`,`url`, `introduce` ,`comface`)\r\n                VALUES ('{$cfg_ml->M_ID}','{$company}','{$product}','{$place}','{$vocation}','{$cosize}','{$tel}','{$fax}','{$linkman}','{$address}','{$uptime}','{$mobile}','{$email}','{$url}','{$introduce}', '{$comface}'); ";
 $rs = $dsql->ExecuteNoneQuery($inquery);
 if (!$rs) {
     ShowMsg("保存信息时发生错误,请联系管理员!" . $dsql->GetError(), 'javascript:;');
     exit;
 }