您的位置:首页 > 其它

dedecms采集的时候自动把图片上传到又拍云

2013-07-22 17:08 423 查看
打开dede/co_export.php找到37行在require_once(DEDEINC.'/dedecollection.class.php');下面判断时候开启了又拍云

/*

*是否开启又拍云

*导入unyun.class

*/

if (($cfg_open_upyun == 'Y') && $cfg_upyun_username && $cfg_upyun_spacename && $cfg_upyun_password ) {
include DEDEADMIN.'/inc/UpYun.class.php';
$upyun	=	new UpYun($cfg_upyun_spacename, $cfg_upyun_username, $cfg_upyun_password);
$openUpYun = true;
} else {
$openUpYun = false;;
}
$cfg_open_upyun开关,我在后台添加了一个boolean类型的变量

$cfg_upyun_username 又拍用户名

$cfg_upyun_spacename 空间名

$cfg_upyun_password密码

然后找到247行 $addSql = str_replace("@$itemname@", $itemvalue, $addSql);在下面增加如下代码

//开启又拍云存储
if($openUpYun) {
$values	=	$ctag->GetInnerText();
if($itemname == 'litpic') {
try {
$fh		=	fopen('../..'.$values, 'rb');
$rsp	=	$upyun->writeFile('/'.$litpic, $fh, True);   // 上传图片,自动创建目录
fclose($fh);
} catch(Exception $e) {
echo $e->getCode();
echo $e->getMessage();
exit;
}
}
if($itemname == 'imgurls') {
$dtp = new DedeTagParse();
$dtp->LoadSource(stripslashes($values));
if(is_array($dtp->CTags)) {
foreach($dtp->CTags as $ctag) {
if($ctag->GetName()=="img") {
$bigimg = trim($ctag->GetInnerText());
if($ctag->GetAtt('ddimg') != $bigimg && $ctag->GetAtt('ddimg')!='') {
$litimg = $ctag->GetAtt('ddimg');
} else {
$litimg = $bigimg;
}
try {
$fh		=	fopen('../..'.$litimg, 'rb');
$rsp	=	$upyun->writeFile($litimg, $fh, True);   // 上传图片,自动创建目录
fclose($fh);
} catch(Exception $e) {
echo $e->getCode();
echo $e->getMessage();
exit;
}
}
}
}
$dtp->Clear();
}
}
fopen里面的路径需要根据实际情况修改下。

以上就是采集完成导出内容的时候把图片附件上传到又拍云上面。写的不好,请见谅。如有更好的解决方式请告知谢谢!sobeautiy@126.com

太囧笑话网
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐