当前位置:首页 > 网站建设

【dede调用文档】织梦把图片发布到远程服务器(支持图集模型)

dedecms仿站吧工厂转让2019-04-30895人围观
Linux宝塔面板的小伙伴需要在PureFTPd里开启被动模式,windows小伙伴可以略过这一步
进入宝塔面板,右侧,软件管理,找到PureFTPd,设置,配置修改,搜索ForcePassiveIP,去掉它前面的#号,192.168.0.1改成你的外网IP,保存,重启PureFTPd或者服务器

其他linux环境的vsftpd,搜索pasv_address+外网IP

开启远程设置
1、打开 /dede/article_add.php 找到

//生成HTML

在它上面加入

$row1=$dsql->GetOne("SELECT*FROM`dede_multiserv_config`");
$isftp=$row1['remoteuploads'];$ftpurl=$row1['remoteupUrl'];
$ftpconfig=$row1['servinfo'];$ftpconfig_arr=array();
$ftpconfig_txt=explode('|',$ftpconfig);foreach($ftpconfig_txtas$str){$ftpconfig_arr[]=trim($str);}
if($isftp==1){$config=array('hostname'=>$ftpconfig_arr[1],'username'=>$ftpconfig_arr[3],
'password'=>$ftpconfig_arr[4],'port'=>$ftpconfig_arr[2],'debug'=>'TRUE');
$ftps=newFTP();$ftps->connect($config);$row2=$dsql->GetOne("SELECTlitpicFROM`dede_archives`WHEREid=$arcID");
$imglist=$row2['litpic'];$row3=$dsql->GetOne("SELECTbodyFROM`$addtable`WHEREaid=$arcID");
preg_match_all("/]*)\s*src=('|\")([^'\"]+)('|\")/",$row3['body'],$matches);

$arr=array_unique($matches[3]);foreach($arras$key){$imglist.=','.$key;}$imglistarr=array();
$imglist_txt=explode(',',$imglist);foreach($imglist_txtas$str){$remotefile=str_replace(DEDEROOT,'',$str);$localfile='..'.$remotefile;$remotefile2=str_replace('uploads/','uploadfile/',$remotefile);$remotedir=preg_replace('/[^\/]*\.(jpg|gif|bmp|png)/','',
$remotefile2);$ftps->rmkdir($remotedir);$ftps->upload($localfile,$remotefile2);}$dsql->ExecuteNoneQuery("UPDATE`dede_archives`SET`litpic`=REPLACE(`litpic`,'/uploads','$ftpurl/uploadfile')WHERE`litpic`LIKE'%/uploads%'AND`id`=$arcID");
$dsql->ExecuteNoneQuery("UPDATE`$addtable`SET`body`=REPLACE(`body`,'/uploads','$ftpurl/uploadfile')WHERE`body`LIKE'%/uploads%'AND`aid`=$arcID");
$ftps->close();}

2、打开 /dede/article_edit.php 找到

//生成HTML

在它上面加入

$row1=$dsql->GetOne("SELECT*FROM`dede_multiserv_config`");
$isftp=$row1['remoteuploads'];$ftpurl=$row1['remoteupUrl'];
$ftpconfig=$row1['servinfo'];$ftpconfig_arr=array();
$ftpconfig_txt=explode('|',
$ftpconfig);foreach($ftpconfig_txtas$str){$ftpconfig_arr[]=trim($str);}if($isftp==1)
{$config=array('hostname'=>$ftpconfig_arr[1],'username'=>$ftpconfig_arr[3],'password'=>
$ftpconfig_arr[4],'port'=>$ftpconfig_arr[2],'debug'=>'TRUE');$ftps=newFTP();$ftps->connect($config);
$row2=$dsql->GetOne("SELECTlitpicFROM`dede_archives`WHEREid=$id");$imglist=$row2['litpic'];
$row3=$dsql->GetOne("SELECTbodyFROM`$addtable`WHEREaid=$id");preg_match_all("/]*)\s*src=('|\")([^'\"]+)('|\")/",$row3['body'],$matches);
$arr=array_unique($matches[3]);foreach($arras$key){$imglist.=','.$key;}$imglistarr=array();
$imglist_txt=explode(',',$imglist);foreach($imglist_txtas$str){if(preg_match('/uploads/',$str))
{$remotefile=str_replace(DEDEROOT,'',$str);$localfile='..'.$remotefile;
$remotefile2=str_replace('uploads/','uploadfile/',$remotefile);
$remotedir=preg_replace('/[^\/]*\.(jpg|gif|bmp|png)/','',$remotefile2);$ftps->rmkdir($remotedir);

$ftps->upload($localfile,$remotefile2);}}
$dsql->ExecuteNoneQuery("UPDATE`dede_archives`SET`litpic`=REPLACE(`litpic`,'/uploads','$ftpurl/uploadfile')WHERE`litpic`LIKE'%/uploads%'AND`id`=$id");
$dsql->ExecuteNoneQuery("UPDATE`$addtable`SET`body`=REPLACE(`body`,'/uploads','$ftpurl/uploadfile')WHERE`body`LIKE'%/uploads%'AND`aid`=$id");
$ftps->close();}

图集模型缩略图和文章内容图片发布到远程服务器

1、打开 /dede/album_add.php 找到

//生成HTML

在它上面加入

$row1=$dsql->GetOne("SELECT*FROM`dede_multiserv_config`");$isftp=$row1['remoteuploads'];$ftpurl=$row1['remoteupUrl'];
$ftpconfig=$row1['servinfo'];$ftpconfig_arr=array();$ftpconfig_txt=explode('|',$ftpconfig);foreach($ftpconfig_txtas$str)
{$ftpconfig_arr[]=trim($str);}if($isftp==1)
{$config=array('hostname'=>$ftpconfig_arr[1],'username'=>$ftpconfig_arr[3],'password'=>$ftpconfig_arr[4],'port'=>$ftpconfig_arr[2],'debug'=>0);$ftps=newFTP();
$ftps->connect($config);$row2=$dsql->GetOne("SELECTlitpicFROM`dede_archives`WHEREid=$arcID");$imglist=$row2['litpic'];
$row3=$dsql->GetOne("SELECTimgurlsFROM`$addtable`WHEREaid=$arcID");$imgurls=$row3['imgurls'];if($imgurls!='')
{$dtp=newDedeTagParse();$dtp->LoadSource($imgurls);$images=array();if(is_array($dtp->CTags)){foreach($dtp->CTagsas$ctag)
{if($ctag->GetName()=='img'){$imglist.=','.trim($ctag->GetInnerText());}}}$dtp->Clear();}$imglistarr=array();
$imglist_txt=explode(',',$imglist);foreach($imglist_txtas$str){$remotefile=str_replace(DEDEROOT,'',$str);
$localfile='..'.$remotefile;$remotefile2=str_replace('uploads/','uploadfile/',$remotefile);
$remotedir=preg_replace('/[^\/]*\.(jpg|gif|bmp|png)/','',$remotefile2);$ftps->rmkdir($remotedir);
$ftps->upload($localfile,$remotefile2);}$dsql->ExecuteNoneQuery("UPDATE`dede_archives`SET`litpic`=REPLACE(`litpic`,'/uploads','$ftpurl/uploadfile')WHERE`litpic`LIKE'%/uploads%'AND`id`=$arcID");
$dsql->ExecuteNoneQuery("UPDATE`$addtable`SET`imgurls`=
REPLACE(`imgurls`,'/uploads','$ftpurl/uploadfile')WHERE`imgurls`LIKE'%/uploads%'AND`aid`=$arcID");$ftps->close();}
2、打开 /dede/album_edit.php 找到

//生成HTML

在它上面加入

$row1=$dsql->GetOne("SELECT*FROM`dede_multiserv_config`");$isftp=$row1['remoteuploads'];
$ftpurl=$row1['remoteupUrl'];$ftpconfig=$row1['servinfo'];$ftpconfig_arr=array();
$ftpconfig_txt=explode('|',$ftpconfig);foreach($ftpconfig_txtas$str)
{$ftpconfig_arr[]=trim($str);}if($isftp==1){$config=array('hostname'=>$ftpconfig_arr[1],'username'=>$ftpconfig_arr[3],'password'=>$ftpconfig_arr[4],'port'=>$ftpconfig_arr[2],'debug'=>0);$ftps=newFTP();$ftps->connect($config);$row2=$dsql->GetOne("SELECTlitpicFROM`dede_archives`WHEREid=$id");$imglist=$row2['litpic'];
$row3=$dsql->GetOne("SELECTimgurlsFROM`$addtable`WHEREaid=$id");$imgurls=$row3['imgurls'];if($imgurls!='')
{$dtp=newDedeTagParse();$dtp->LoadSource($imgurls);$images=array();
if(is_array($dtp->CTags)){foreach($dtp->CTagsas$ctag){if($ctag->GetName()=='img')
{$imglist.=','.trim($ctag->GetInnerText());}}}$dtp->Clear();}$imglistarr=array();$imglist_txt=explode(',',$imglist);foreach($imglist_txtas$str)
{if(preg_match('/uploads/',$str)){$remotefile=str_replace(DEDEROOT,'',$str);$localfile='..'.
$remotefile;
$remotefile2=str_replace('uploads/','uploadfile/',$remotefile);$remotedir=preg_replace('/[^\/]*\.(jpg|gif|bmp|png)/','',$remotefile2);
$ftps->rmkdir($remotedir);
$ftps->upload($localfile,$remotefile2);}}
$dsql->ExecuteNoneQuery("UPDATE`dede_archives`SET`litpic`=REPLACE(`litpic`,'/uploads','$ftpurl/uploadfile')WHERE`litpic`LIKE'%/uploads%'AND`id`=$id");
$dsql->ExecuteNoneQuery("UPDATE`$addtable`SET`imgurls`=REPLACE(`imgurls`,'/uploads','$ftpurl/uploadfile')WHERE`imgurls`LIKE'%/uploads%'AND`aid`=$id");
$ftps->close();}
 

    版权声明:

    博主在此发文(包括但不限于汉字、拼音、拉丁字母)均为随意敲击键盘所出,用于检验本人电脑键盘录入、屏幕显示的机械、光电性能,并不代表本人局部或全部同意、支持或者反对观点

    如需要详查请直接与键盘生产厂商法人代表联系。挖井挑水无水表,不会网购无快递。

    文章内容除非注明原创,否则来源于互联网,不代表本人的任何立场;涉及到的软件来源于互联网,仅供个人下载使用,请勿用于商业用途,版权归软件开发者所有,下载后请于24小时内删除,请支持正版!

    因下载本站任何资源造成的损失,全部责任由使用者本人承担!

    如果你是版权方,认为本文内容对您的权益有所侵犯,请联系博主,待博主进行严格地审查和背景调查后,情况属实的将在三天内将本文删除或修正。

    博主的文章没有高度、深度和广度,只是凑字数。由于博主的水平不高(其实是个菜B),不足和错误之处在所难免,希望大家能够批评指出。