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; } } } } } }
/** * 处理不同类型的数据 * * @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; } } } } } } } } } } }
/** * 上传一个未经处理的图片 * * @access public * @param string $upname 上传框名称 * @param string $handurl 手工填写的网址 * @param string $ddisremote 是否下载远程图片 0 不下, 1 下载 * @param string $ntitle 注解文字 如果表单有 title 字段可不管 * @return mixed */ function UploadOneImage($upname, $handurl = '', $isremote = 1, $ntitle = '') { global $cuserLogin, $cfg_basedir, $cfg_image_dir, $title, $dsql; if ($ntitle != '') { $title = $ntitle; } $ntime = time(); $filename = ''; $isrm_up = FALSE; $handurl = trim($handurl); //如果用户自行上传了图片 if (!empty($_FILES[$upname]['tmp_name']) && is_uploaded_file($_FILES[$upname]['tmp_name'])) { $istype = 0; $sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png"); $_FILES[$upname]['type'] = strtolower(trim($_FILES[$upname]['type'])); if (!in_array($_FILES[$upname]['type'], $sparr)) { ShowMsg("上传的图片格式错误,请使用JPEG、GIF、PNG格式的其中一种!", "-1"); exit; } if (!empty($handurl) && !preg_match("#^http:\\/\\/#i", $handurl) && file_exists($cfg_basedir . $handurl)) { if (!is_object($dsql)) { $dsql = new DedeSql(); } $dsql->ExecuteNoneQuery("DELETE FROM `#@__uploads` WHERE url LIKE '{$handurl}' "); $fullUrl = preg_replace("#\\.([a-z]*)\$#i", "", $handurl); } else { $savepath = $cfg_image_dir . '/' . strftime("%Y-%m", $ntime); CreateDir($savepath); $fullUrl = $savepath . '/' . strftime("%d", $ntime) . dd2char(strftime("%H%M%S", $ntime) . '0' . $cuserLogin->getUserID() . '0' . mt_rand(1000, 9999)); } if (strtolower($_FILES[$upname]['type']) == "image/gif") { $fullUrl = $fullUrl . ".gif"; } else { if (strtolower($_FILES[$upname]['type']) == "image/png") { $fullUrl = $fullUrl . ".png"; } else { $fullUrl = $fullUrl . ".jpg"; } } //保存 @move_uploaded_file($_FILES[$upname]['tmp_name'], $cfg_basedir . $fullUrl); $filename = $fullUrl; //水印 @WaterImg($imgfile, 'up'); $isrm_up = TRUE; } else { if ($handurl == '') { return ''; } //远程图片并要求本地化 if ($isremote == 1 && preg_match("#^http:\\/\\/#i", $handurl)) { $ddinfos = GetRemoteImage($handurl, $cuserLogin->getUserID()); if (!is_array($ddinfos)) { $litpic = ""; } else { $filename = $ddinfos[0]; } $isrm_up = TRUE; //本地图片或远程不要求本地化 } else { $filename = $handurl; } } $imgfile = $cfg_basedir . $filename; if (is_file($imgfile) && $isrm_up && $filename != '') { $info = ""; $imginfos = GetImageSize($imgfile, $info); //把新上传的图片信息保存到媒体文档管理档案中 $inquery = "\n INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,mid)\n VALUES ('{$title}','{$filename}','1','" . $imginfos[0] . "','" . $imginfos[1] . "','0','" . filesize($imgfile) . "','" . time() . "','" . $cuserLogin->getUserID() . "');\n "; $dsql->ExecuteNoneQuery($inquery); } return $filename; }
function UploadOneImage($upname,$handurl='',$ddisremote=1,$ntitle='') { global $cuserLogin,$cfg_basedir,$cfg_image_dir,$dsql,$title; if($ntitle!='') $title = $ntitle; $ntime = time(); $filename = ''; $isrm_up = false; $handurl = trim($handurl); //如果用户自行上传了图片 if(!empty($_FILES[$upname]['tmp_name']) && is_uploaded_file($_FILES[$upname]['tmp_name'])) { $istype = 0; $sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png"); $_FILES[$upname]['type'] = strtolower(trim($_FILES[$upname]['type'])); if(!in_array($_FILES[$upname]['type'],$sparr)){ ShowMsg("上传的图片格式错误,请使用JPEG、GIF、PNG格式的其中一种!","-1"); exit(); } if(!empty($handurl) && !eregi("^http://",$handurl) && file_exists($cfg_basedir.$handurl) ){ if(!is_object($dsql)) $dsql = new DedeSql(); $dsql->ExecuteNoneQuery("Delete From #@__uploads where url like '$handurl' "); $fullUrl = eregi_replace("\.([a-z]*)$","",$handurl); }else{ $savepath = $cfg_image_dir."/".strftime("%Y-%m",$ntime); CreateDir($savepath); $fullUrl = $savepath."/".strftime("%d",$ntime).dd2char(strftime("%H%M%S",$ntime).'0'.$cuserLogin->getUserID().'0'.mt_rand(1000,9999)); } if(strtolower($_FILES[$upname]['type'])=="image/gif") $fullUrl = $fullUrl.".gif"; else if(strtolower($_FILES[$upname]['type'])=="image/png") $fullUrl = $fullUrl.".png"; else $fullUrl = $fullUrl.".jpg"; //保存 @move_uploaded_file($_FILES[$upname]['tmp_name'],$cfg_basedir.$fullUrl); $filename = $fullUrl; //水印 @WaterImg($imgfile,'up'); $isrm_up = true; } //远程或选择本地图片 else{ if($handurl=='') return ''; //远程图片并要求本地化 if($isremote==1 && eregi("^http://",$handurl)){ $ddinfos = GetRemoteImage($handurl,$cuserLogin->getUserID()); if(!is_array($ddinfos)) $litpic = ""; else $filename = $ddinfos[0]; $isrm_up = true; //本地图片或远程不要求本地化 }else{ $filename = $handurl; } } $imgfile = $cfg_basedir.$filename; if(is_file($imgfile) && $isrm_up && $filename!=''){ $info = ""; $imginfos = GetImageSize($imgfile,$info); //把新上传的图片信息保存到媒体文档管理档案中 $inquery = " INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,adminid,memberid) VALUES ('$title','$filename','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".time()."','".$cuserLogin->getUserID()."','0'); "; $dsql = new DedeSql(false); $dsql->ExecuteNoneQuery($inquery); } return $filename; }
//总信息数 $pagesize = 10; //一页显示信息数 $page = isset($page) ? max(1, intval($page)) : 1; //处理页码变量 $offset = ($page - 1) * $pagesize; //偏移量 $dataarray = $Table->getdata("{$offset},{$pagesize}", $wheresql, '', 'oid,goodsimg,orderimg'); //获取团购数据 $msg = "总共需要抓取图片:{$total}个<br/>"; if (!empty($dataarray)) { //抓取图片操作 foreach ($dataarray as $val) { //远程图本地化 if (!empty($val['goodsimg'])) { $tempimg = GetRemoteImage($val['goodsimg']); $thumbname = "../" . $tempimg['savepath'] . "_thumb_" . $tempimg['filename']; makeThumb("../" . $tempimg['filepath'], $thumbname); editstate($Table->table, "orderimg", "oid=" . $val['oid'], $tempimg['filepath']); //更改图片地址操作 $msg .= "更新订单ID:{$val['oid']} 图片地址成功<br/>"; } } $url = geturl(); $goto = url::replace($url, "page=" . ($page + 1), 0, 1); showmsg($msg, $goto); } else { showmsg("抓取完成!", "goodsimg_get.php"); } } else { //包含后台模板文件
$iinfo = str_replace("'","`",stripslashes(${'imgmsg'.$i})); //非上传图片 if(!is_uploaded_file($_FILES['imgfile'.$i]['tmp_name'])) { $iurl = stripslashes(${'imgurl'.$i}); $ioldurl = @stripslashes(${'imgurlold'.$i}); $ioldddimg = @stripslashes(${'oldddimg'.$i}); if(trim($iurl)=="") continue; $iurl = trim(str_replace($cfg_basehost,"",$iurl)); if((eregi("^http://",$iurl) && !eregi($cfg_basehost,$iurl)) && $cfg_isUrlOpen) //远程图片 { $reimgs = ""; if($cfg_isUrlOpen && $isrm==1) { $reimgs = GetRemoteImage($iurl,$adminID); if(is_array($reimgs)){ $litpicname = GetImageMapDD($reimgs[0],$ddmaxwidth); $imgurls .= "{dede:img ddimg='$litpicname' text='$iinfo' width='".$reimgs[1]."' height='".$reimgs[2]."'} ".$reimgs[0]." {/dede:img}\r\n"; }else{ echo "下载:".$iurl." 失败,可能图片有反采集功能或http头不正确!<br />\r\n"; } }else{ $imgurls .= "{dede:img text='$iinfo' width='' height=''} ".$iurl." {/dede:img}\r\n"; } //站内图片 }else if($iurl!="") { $imgfile = $cfg_basedir.$iurl; if(is_file($imgfile)) {
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; } }
//出错! if (empty($goodsurl)) { showmsg("商品地址不能为空!", PHP_SELF); } //出错! if (empty($goodsname)) { showmsg("商品名称不能为空!", PHP_SELF); } //出错! if (empty($goodsprice)) { showmsg("商品价格不能为空!", PHP_SELF); } //出错! //远程图本地化 if (!empty($goodsimg)) { $tempimg = GetRemoteImage($goodsimg); $thumbname = "../" . $tempimg['savepath'] . "_thumb_" . $tempimg['filename']; makeThumb("../" . $tempimg['filepath'], $thumbname); $goodsimg = $tempimg['filepath']; } $arrayadd = array("gtypeid" => GetNum($gtypeid), "goodsurl" => Char_cv($goodsurl), "goodsname" => Char_cv($goodsname), "goodsseller" => Char_cv($goodsseller), "goodsimg" => Char_cv($goodsimg), "sellerurl" => Char_cv($sellerurl), "shopname" => Char_cv($shopname), "why" => Char_cv($why), "goodsprice" => GetNum($goodsprice), "rindex" => GetNum($rank), "views" => GetNum($views), "buynum" => GetNum($buynum), "listorder" => GetNum($listorder), "about" => HtmlReplace($about, -1), "flag" => Char_cv($flag), "Audit" => 1, "addtime" => time()); $info = $Table->add($arrayadd); if (GetNum($info)) { showmsg("发布成功!", PHP_SELF); //出错! } else { showmsg("发布失败!", "-1"); //出错! } } else { if (!empty($_POST['goodsurl'])) {