/* 根据文档id获取文档的body部分 */ function getArcBody($arcid) { global $dsql; if(empty($arcid)) return ; $body = ''; $query = "select arc.*,ch.addtable,ch.fieldset from `dede_arctiny` as arc left join `dede_channeltype` as ch on arc.channel=ch.id where arc.id=$arcid"; $row = $dsql->GetOne($query); if(empty($row)) return ; $addtable = $row['addtable']; $fieldset = $row['fieldset']; include_once(DEDEINC.'./dedetag.class.php'); $dtp = new DedeTagParse(); $dtp->SetNameSpace('field','<','>'); $dtp->LoadSource($fieldset); if(is_array($dtp->CTags)) { foreach($dtp->CTags as $tid=>$tag) { if($tag->GetAtt('type')=='htmltext') { $body = $tag->GetName(); break; } } } if(!empty($body)) { $query = "select $body from `$addtable` where aid=$arcid"; $row = $dsql->GetOne($query); $body = $row[$body]; return $body; } return ; } /* 解析文档内容的本地图片图片 */ function get_img_from_body($body) { $result = array(); if(empty($body)) return $result; preg_match_all('/\ssrc=([\"|\'])([^\1]*?)\.(gif|jpg|jpeg|png)\1/',$body,$res); if(!empty($res[2])) { foreach($res[2] as $k=>$v) { $result[] = $v.'.'.$res[3][$k]; } } return $result; } |
$body = getArcBody($aid); |
return true; |
if($body) { $img_arr = get_img_from_body($body); if(!empty($img_arr)) { foreach($img_arr as $v) { $img_file = GetTruePath().str_replace($GLOBALS['cfg_basehost'],'',$v); if(file_exists($img_file) && !is_dir($img_file)) @unlink($img_file); } } } |
暂停服务!