POST TIME:2020-04-02 13:57
織夢CMS欄目管理-高級選項里有綁定域名功能,可以讓我們用一級或二級域名綁定欄目來訪問,但是有個問題就是欄目綁定二級域名后圖片不顯示,路徑錯誤,解決這個問題需要修改程序代碼來解決。
修改方法如下:
將 dede/INC 的inc_archives_functions.php 文件改為如下代碼就OK了
代碼:
<?php
require_once(DEDEADMIN."/../include/pub_httpdown.php");
require_once(DEDEADMIN."/../include/inc_photograph.php");
require_once(DEDEADMIN."/../include/pub_oxwindow.php");
require_once(DEDEADMIN."/../include/inc_tag_functions.php");
require_once(DEDEADMIN."/../include/inc_custom_fields.php");
//---------------------------
//HTML獠吭賜?
//---------------------
function GetCurContentAlbum($body,$rfurl,&$firstdd)
{
global $cfg_multi_site,$cfg_basehost,$ddmaxwidth,$cfg_basedir;
include_once(DEDEADMIN."/../include/pub_collection_functions.php");
if(empty($ddmaxwidth)) $ddmaxwidth = 150;
$rsimg = '';
$cfg_uploaddir = $GLOBALS['cfg_image_dir'];
$cfg_basedir = $GLOBALS['cfg_basedir'];
$basehost = "dede_arctype where ID='$typeid' ");
if($row['ispart']!=0 || $row['channeltype']!=$channelid) { return false; }
else { return true; }
}
//---------------
//檢測檔案權(quán)限
//---------------
function CheckArcAdmin($aid,$adminid)
{
$dsql = new DedeSql(false);
$row = $dsql->GetOne("Select adminid From dede_archives where ID='$aid' ");
if($row['adminid']!=$adminid) return false;
else return true;
}
//---------------
//文檔自動分頁
//---------------
function SpLongBody(&$mybody,$spsize,$sptag)
{
if(strlen($mybody)<$spsize) return $mybody;
$bds = explode('<',$mybody);
$npageBody = "";
$istable = 0;
$mybody = "";
foreach($bds as $i=>$k)
{
if($i==0){ $npageBody .= $bds[$i]; continue;}
$bds[$i] = "<".$bds[$i];
if(strlen($bds[$i])>6){
$tname = substr($bds[$i],1,5);
if(strtolower($tname)=='table') $istable++;
else if(strtolower($tname)=='/tabl') $istable--;
if($istable>0){ $npageBody .= $bds[$i]; continue; }
else $npageBody .= $bds[$i];
}else{
$npageBody .= $bds[$i];
}
if(strlen($npageBody)>$spsize){
$mybody .= $npageBody.$sptag;
$npageBody = "";
}
}
if($npageBody!="") $mybody .= $npageBody;
return $mybody;
}
//-----------------------
//創(chuàng)建指定ID的文檔
//-----------------------
function MakeArt($aid,$mkindex=true,$upcache=true)
{
global $cfg_makeindex,$cfg_basedir,$cfg_templets_dir,$cfg_df_style,$cfg_up_prenext,$typeid,$envs,$typeid;
include_once(DEDEADMIN."/../include/inc_archives_view.php");
if(!$upcache) $envs['nocache'] = true;
$arc = new Archives($aid);
$reurl = $arc->MakeHtml();
if($mkindex)
{
//更新上下篇文章
if($cfg_up_prenext=='Y' && !empty($typeid))
{
$preRow = $arc->dsql->GetOne("Select ID From `{$arc->MainTable}` where ID<$aid And ID>".($aid-1000)." And arcrank>-1 And typeid='$typeid' order by ID desc");
$nextRow = $arc->dsql->GetOne("Select ID From `{$arc->MainTable}` where ID>$aid And ID<".($aid+1000)." And arcrank>-1 And typeid='$typeid' order by ID asc");
if(is_array($preRow)){
$arc = new Archives($preRow['ID']);
$arc->MakeHtml();
}
if(is_array($nextRow)){
$arc = new Archives($nextRow['ID']);
$arc->MakeHtml();
}
}
//更新主頁
if($cfg_makeindex=='Y')
{
$pv = new PartView();
$row = $pv->dsql->GetOne("Select * From dede_homepageset");
$templet = str_replace("{style}",$cfg_df_style,$row['templet']);
$homeFile = dirname(__FILE__)."/../".$row['position'];
$homeFile = str_replace("\","/",$homeFile);
$homeFile = str_replace("//","/",$homeFile);
$fp = fopen($homeFile,"w") or die("頁募{$homeFile} 沒寫權(quán)蓿");
fclose($fp);
$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet);
$pv->SaveToHtml($homeFile);
}
}
return $reurl;
}
//---------------------------
//上傳縮略圖
//--------------------------
/*
參數(shù)一
litpic 默認為上傳表單的名稱
值為 noneddfirst 強制不查檢上傳
值為 ddfirst 則強制把已存在的本地圖生成縮略圖
參數(shù)二
picname 手工填寫的圖片路徑
參數(shù)三
isremote 是否下載遠程圖片 0 為不下載, 1為下載到本地
*/
function GetDDImage($litpic,$picname,$isremote,$ntitle='')
{
global $cuserLogin,$cfg_ddimg_width,$cfg_ddimg_height;
global $cfg_basedir,$ddcfg_image_dir,$title,$dsql;
$ntime = time();
$saveinfo = false;
if($ntitle!='') $title = $ntitle;
$picname = trim($picname);
if(($litpic!='none'||$litpic!='ddfirst') &&
!empty($_FILES[$litpic]['tmp_name']) && is_uploaded_file($_FILES[$litpic]['tmp_name']))
//如果用戶自行上傳縮略圖
{
$istype = 0;
$sparr = Array("image/pjpeg","image/jpeg","image/gif","image/png");
$_FILES[$litpic]['type'] = strtolower(trim($_FILES[$litpic]['type']));
if(!in_array($_FILES[$litpic]['type'],$sparr)){
ShowMsg("洗圖片式使JPEGGIFPNG式一鄭","-1");
exit();
}
if(!empty($picname) && !eregi("^http://",$picname) && file_exists($cfg_basedir.$picname) ){
if(!is_object($dsql)) $dsql = new DedeSql();
$dsql->ExecuteNoneQuery("Delete From dede_uploads where url like '$picname' ");
$fullUrl = eregi_replace(".([a-z]*)$","",$picname);
}else{
$savepath = $ddcfg_image_dir."/".strftime("%y%m%d",$ntime);
CreateDir($savepath);
$fullUrl = $savepath."/".dd2char(strftime("%H%M%S",$ntime).$cuserLogin->getUserID().mt_rand(1000,9999));
}
if(strtolower($_FILES[$litpic]['type'])=="image/gif") $fullUrl = $fullUrl.".gif";
else if(strtolower($_FILES[$litpic]['type'])=="image/png") $fullUrl = $fullUrl.".png";
else $fullUrl = $fullUrl.".jpg";
@move_uploaded_file($_FILES[$litpic]['tmp_name'],$cfg_basedir.$fullUrl);
$litpic = $fullUrl;
@ImageResize($cfg_basedir.$fullUrl,$cfg_ddimg_width,$cfg_ddimg_height);
$saveinfo = true;
}else{
if($picname=='') return '';
//遠程縮略
if($isremote==1 && eregi("^http://",$picname)){
$ddinfos = GetRemoteImage($picname,$cuserLogin->getUserID());
if(!is_array($ddinfos)) $litpic = "";
else{
$litpic = $ddinfos[0];
if($ddinfos[1] > $cfg_ddimg_width || $ddinfos[2] > $cfg_ddimg_height){
@ImageResize($cfg_basedir.$litpic,$cfg_ddimg_width,$cfg_ddimg_height);
}
}
$saveinfo = true;
}
//本地縮略
else{
//本地大圖強制生成本地圖縮略
if($litpic=='ddfirst' && !eregi("^http://",$picname)){
$oldpic = $cfg_basedir.$picname;
if(!eregi('_lit',$litpic)){
$litpic = str_replace('.','_lit.',$picname);
$saveinfo = true;
}
@ImageResize($oldpic,$cfg_ddimg_width,$cfg_ddimg_height,$cfg_basedir.$litpic);
}else{
$litpic = $picname;
}
}
}
$imgfile = $cfg_basedir.$litpic;
if($saveinfo && is_file($imgfile) && $litpic!=''){
$info = "";
$imginfos = GetImageSize($imgfile,$info);
//把新上傳的圖片信息保存到媒體文檔管理檔案中
$inquery = "
INSERT INTO dede_uploads(title,url,mediatype,width,height,playtime,filesize,uptime,adminid,memberid)
VALUES ('{$title} 圖','$litpic','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".time()."','".$cuserLogin->getUserID()."','0');
";
$dsql = new DedeSql();
$dsql->ExecuteNoneQuery($inquery);
}
return $litpic;
}
//檢測欄目是否設(shè)置了瀏覽權(quán)限
function GetCoRank($arcrank,$typeid){
$dsql = new DedeSql(false);
$row = $dsql->GetOne("Select corank From dede_arctype where ID='$typeid' ");
if($row['corank']!=0) return $row['corank'];
else return $arcrank;
}
//圖集里大圖的小圖
function GetImageMapDD($filename,$ddm,$oldname=''){
if($oldname!='' && !eregi("^http://",$oldname)){
$ddpicok = $oldname;
}else{
$ddn = substr($filename,-3);
$ddpicok = ereg_replace(".".$ddn."$","-lp.".$ddn,$filename);
}
$toFile = $GLOBALS['cfg_basedir'].$ddpicok;
ImageResize($GLOBALS['cfg_basedir'].$filename,$ddm,300,$toFile);
return $ddpicok;
}
//------------------------
//上傳一個未經(jīng)處理的圖片
//------------------------
/*
//參數(shù)一 upname 上傳框名稱
//參數(shù)二 handurl 手工填寫的網(wǎng)址
//參數(shù)三 ddisremote 是否下載遠程圖片 0 不下, 1 下載
//參數(shù)四 ntitle 注解文字 如果表單有 title 字段可不管
*/
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("洗圖片式使JPEGGIFPNG式一鄭","-1");
exit();
}
if(!empty($handurl) && !eregi("^http://",$handurl) && file_exists($cfg_basedir.$handurl) ){
if(!is_object($dsql)) $dsql = new DedeSql();
$dsql->ExecuteNoneQuery("Delete From dede_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 dede_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;
}
//------------------
//取第一個圖片為縮略圖
//------------------
function GetDDImgFromBody(&$body)
{
$litpic = '';
preg_match_all("/(src|SRC)=[&;|'| ]{0,}(.*.(gif|jpg|jpeg|bmp|png))/isU",$body,$img_array);
$img_array = array_unique($img_array[2]);
if(count($img_array)>0){
$picname = preg_replace("/[&;|'| ]{1,}/","",$img_array[0]);
if(ereg("_lit.",$picname)) $litpic = $picname;
else $litpic = GetDDImage('ddfirst',$picname,0);
}
return $litpic;
}
//獲得一個附加表單
//-----------------------------
function GetFormItemA($ctag)
{
return GetFormItem($ctag,'admin');
}
//---------------------------
//處理不同類型的數(shù)據(jù)
//---------------------------
function GetFieldValueA($dvalue,$dtype,$aid=0,$job='add',$addvar='')
{
return GetFieldValue($dvalue,$dtype,$aid,$job,$addvar,'admin');
}
//獲得帶值的表單(編輯時用)
//-----------------------------
function GetFormItemValueA($ctag,$fvalue)
{
return GetFormItemValue($ctag,$fvalue,'admin');
}
//載入自定義表單(用于發(fā)布)
function PrintAutoFieldsAdd(&$fieldset,$loadtype='all')
{
$dtp = new DedeTagParse();
$dtp->SetNameSpace("field","<",">");
$dtp->LoadSource($fieldset);
$dede_addonfields = "";
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $tid=>$ctag)
{
if($loadtype!='autofield'
|| ($loadtype=='autofield' && $ctag->GetAtt('autofield')==1) )
{
$dede_addonfields .= ( $dede_addonfields=="" ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type') );
echo GetFormItemA($ctag);
}
}
}
echo "<input type='hidden' name='dede_addonfields' value=&;".$dede_addonfields."&;> ";
}
//載入自定義表單(用于編輯)
function PrintAutoFieldsEdit(&$fieldset,&$fieldValues,$loadtype='all')
{
$dtp = new DedeTagParse();
$dtp->SetNameSpace("field","<",">");
$dtp->LoadSource($fieldset);
$dede_addonfields = "";
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $tid=>$ctag)
{
if($loadtype!='autofield'
|| ($loadtype=='autofield' && $ctag->GetAtt('autofield')==1) )
{
$dede_addonfields .= ( $dede_addonfields=='' ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type') );
echo GetFormItemValueA($ctag,$fieldValues[$ctag->GetName()]);
}
}
}
echo "<input type='hidden' name='dede_addonfields' value=&;".$dede_addonfields."&;> ";
}
function getfilenameonly($arcid, $typeid, $senddate, $title, $ismake, $arcrank, $money)
{
global $dsql;
require_once DEDEINC.'/inc_channel_unit_functions.php';
$row = $dsql->getone("select namerule, typedir, siterefer, sitepath ,channeltype from dede_arctype where ID='$typeid'");
if(is_array($row)){
if($row['channeltype'] == -2) return $GLOBALS['cfg_plus_dir']."/view.php?aid=$arcid";
$filename = GetFileNewName($arcid, $typeid, $senddate, $title, $ismake, $arcrank, $row['namerule'],
$row['typedir'],$money,$row['siterefer'], $row['sitepath']);
}else{
showmsg('目id','-1');
exit;
}
if($filename=="") $filename = $GLOBALS['cfg_plus_dir']."/view.php?aid=$arcid";
return $filename;
}
?>