function GetRemoteImage($url,$uid=0) { global $title,$cfg_mb_rmdown,$cfg_photo_typenames,$cfg_ml; if($cfg_mb_rmdown=='N') return ''; $cfg_uploaddir = $GLOBALS['cfg_user_dir']; $cfg_basedir = $GLOBALS['cfg_basedir']; $revalues = Array(); $revalues[0] = ''; $revalues[1] = ''; $revalues[2] = ''; $ok = false; $htd = new DedeHttpDown(); $htd->OpenUrl($url); $sparr = $cfg_photo_typenames; if(!in_array($htd->GetHead("content-type"),$sparr)){ return ""; }else{ $imgUrl = $cfg_uploaddir."/".$cfg_ml->M_ID; $imgPath = $cfg_basedir.$imgUrl; CreateDir($imgUrl); $itype = $htd->GetHead("content-type"); if($itype=="image/gif") $itype = ".gif"; else if($itype=="image/png") $itype = ".png"; else if($itype=="image/wbmp") $itype = ".bmp"; else $itype = ".jpg"; $rndname = dd2char($cfg_ml->M_ID."0".strftime("%y%m%d%H%M%S",$nowtme)."0".mt_rand(1000,9999)).'-rm'; $rndtrueName = $imgPath."/".$rndname.$itype; $fileurl = $imgUrl."/".$rndname.$itype; $ok = $htd->SaveToBin($rndtrueName); if($ok){ $info = ""; $data = GetImageSize($rndtrueName,$info); $revalues[0] = $fileurl; $revalues[1] = $data[0]; $revalues[2] = $data[1]; } @WaterImg($rndtrueName,'down'); //保存用户上传的记录到数据库 if($title=='') $title = '用户保存的远程图片'; $addinfos[0] = $data[0]; $addinfos[1] = $data[1]; $addinfos[2] = filesize($rndtrueName); SaveUploadInfo($title."(远程图片)",$fileurl,1,$addinfos); } $htd->Close(); if($ok) return $revalues; else return ''; }
/** * 获取远程flash * * @access public * @param string $url 地址 * @param int $uid 用户id * @return string */ function GetRemoteFlash($url, $uid = 0) { global $cfg_addon_savetype, $cfg_media_dir, $cfg_basedir; $cfg_uploaddir = $cfg_media_dir; $revalues = ''; $sparr = 'application/x-shockwave-flash'; $htd = new DedeHttpDown(); $htd->OpenUrl($url); if ($htd->GetHead("content-type") != $sparr) { return ''; } else { $imgUrl = $cfg_uploaddir . '/' . MyDate($cfg_addon_savetype, time()); $imgPath = $cfg_basedir . $imgUrl; CreateDir($imgUrl); $itype = '.swf'; $milliSecond = $uid . '_' . MyDate('mdHis', time()); $rndFileName = $imgPath . '/' . $milliSecond . $itype; $fileurl = $imgUrl . '/' . $milliSecond . $itype; $ok = $htd->SaveToBin($rndFileName); if ($ok) { $revalues = $fileurl; } } $htd->Close(); return $revalues; }
function GetRemoteFlash($url,$uid=0) { $cfg_uploaddir = $GLOBALS['media_dir']; $cfg_basedir = $GLOBALS['cfg_basedir']; $revalues = ""; $sparr = "application/x-shockwave-flash"; $htd = new DedeHttpDown(); $htd->OpenUrl($url); if($htd->GetHead("content-type")!=$sparr){ return ""; }else{ $imgUrl = $cfg_uploaddir."/".strftime("%y%m%d",time()); $imgPath = $cfg_basedir.$imgUrl; CreateDir($imgUrl); $itype = ".swf"; $milliSecond = $uid."_".strftime("%H%M%S",time()); $rndFileName = $imgPath."/".$milliSecond.$itype; $fileurl = $imgUrl."/".$milliSecond.$itype; $ok = $htd->SaveToBin($rndFileName); if($ok) $revalues = $fileurl; } $htd->Close(); return $revalues; }
include DEDEADMIN . '/templets/sys_verifies_getfiles.htm'; exit; } else { if ($action == 'down') { $cacheFiles = DEDEROOT . '/data/modifytmp.inc'; require_once $cacheFiles; if ($fileConut == -1 || $curfile > $fileConut) { ShowMsg("已下载所有文件<br /><a href='sys_verifies.php?action=apply'>[直接替换文件]</a> <a href='#'>[我自己手动替换文件]</a>", "javascript:;"); exit; } //检查临时文件保存目录是否可用 MkTmpDir($tmpdir, $files[$curfile]); $downfile = $updateHost . $cfg_soft_lang . '/source/' . $files[$curfile]; $dhd = new DedeHttpDown(); $dhd->OpenUrl($downfile); $dhd->SaveToBin(DEDEROOT . '/data/' . $tmpdir . '/' . $files[$curfile]); $dhd->Close(); ShowMsg("成功下载文件:{$files[$curfile]}; 继续下载下一个文件。", "sys_verifies.php?action=down&curfile=" . ($curfile + 1)); exit; } else { if ($action == 'modify') { if (!isset($modifys)) { ShowMsg("没选定要修改的文件!", "-1"); exit; } else { foreach ($modifys as $fname) { if ($method == 'local') { $tureFilename = str_replace('../dede', './', $fname); if (file_exists($tureFilename)) { $fp = fopen($tureFilename, 'r'); $ct = fread($fp, filesize($tureFilename));
include DEDEADMIN . '/templets/sys_verifies_getfiles.htm'; exit; } else { if ($action == 'down') { $cacheFiles = DEDEDATA . '/modifytmp.inc'; require_once $cacheFiles; if ($fileConut == -1 || $curfile > $fileConut) { ShowMsg("已下载所有文件<br /><a href='sys_verifies.php?action=apply'>[直接替换文件]</a> <a href='#'>[我自己手动替换文件]</a>", "javascript:;"); exit; } //检查临时文件保存目录是否可用 MkTmpDir($tmpdir, $files[$curfile]); $downfile = $updateHost . $cfg_soft_lang . '/source/' . $files[$curfile]; $dhd = new DedeHttpDown(); $dhd->OpenUrl($downfile); $dhd->SaveToBin(DEDEDATA . '/' . $tmpdir . '/' . $files[$curfile]); $dhd->Close(); ShowMsg("成功下载文件:{$files[$curfile]}; 继续下载下一个文件。", "sys_verifies.php?action=down&curfile=" . ($curfile + 1)); exit; } else { if ($action == 'modify') { if (!isset($modifys)) { ShowMsg("没选定要修改的文件!", "-1"); exit; } else { foreach ($modifys as $fname) { if ($method == 'local') { $tureFilename = str_replace('../dede', './', $fname); if (file_exists($tureFilename)) { $fp = fopen($tureFilename, 'r'); $ct = fread($fp, filesize($tureFilename));
/** * 获得文章body里的外部资源 * * @access public * @param string $body 内容 * @return string */ function GetCurContent(&$body) { global $cfg_multi_site, $cfg_basehost, $cfg_basedir, $cfg_user_dir, $title, $cfg_ml; include_once DEDEINC . "/dedecollection.func.php"; $htd = new DedeHttpDown(); $basehost = "http://" . $_SERVER["HTTP_HOST"]; $img_array = array(); preg_match_all("/(src|SRC)=[\"|'| ]{0,}(http:\\/\\/([^>]*)\\.(gif|jpg|png))/isU", $body, $img_array); $img_array = array_unique($img_array[2]); $imgUrl = $cfg_user_dir . "/" . $cfg_ml->M_ID; $imgPath = $cfg_basedir . $imgUrl; if (!is_dir($imgPath . "/")) { MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']); CloseFtp(); } $milliSecond = MyDate("ymdHis", time()); foreach ($img_array as $key => $value) { if (preg_match("#" . $basehost . "#i", $value)) { continue; } if ($cfg_basehost != $basehost && preg_match("#" . $cfg_basehost . "#i", $value)) { continue; } if (!preg_match("#^http:\\/\\/#i", $value)) { continue; } $htd->OpenUrl($value); $itype = $htd->GetHead("content-type"); $itype = substr($value, -4, 4); if (!preg_match("#\\.(jpg|gif|png)#i", $itype)) { if ($itype == 'image/gif') { $itype = ".gif"; } else { if ($itype == 'image/png') { $itype = ".png"; } else { $itype = '.jpg'; } } } $milliSecondN = dd2char($milliSecond . '-' . mt_rand(1000, 8000)); $value = trim($value); $rndFileName = $imgPath . "/" . $milliSecondN . '-' . $key . $itype; $fileurl = $imgUrl . "/" . $milliSecondN . '-' . $key . $itype; $rs = $htd->SaveToBin($rndFileName); if ($rs) { $body = str_replace($value, $fileurl, $body); @WaterImg($rndFileName, 'down'); } $info = ''; $imginfos = GetImageSize($rndFileName, $info); SaveUploadInfo($title, $fileurl, 1, $imginfos); } $htd->Close(); return $body; }