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; }
<?php /** * 获取dede系统提示信息 * * @version $Id: getdedesysmsg.php 1 11:06 2010年7月13日Z tianya $ * @package DedeCMS.Administrator * @copyright Copyright (c) 2007 - 2010, DesDev, Inc. * @license http://help.dedecms.com/usersguide/license.html * @link http://www.dedecms.com */ require_once dirname(__FILE__) . '/config.php'; require_once DEDEINC . '/dedehttpdown.class.php'; AjaxHead(); $dhd = new DedeHttpDown(); $dhd->OpenUrl('http://www.dedecms.com/officialinfo.html'); $str = trim($dhd->GetHtml()); $dhd->Close(); if ($cfg_soft_lang == 'utf-8') { $str = gb2utf8($str); } echo $str;
/** * 获得文章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; }
/** * caijixia for dedecms * @version $Id: cjx.class.php 112 2013-05-28 01:22:57Z qinjinpeng $ * @copyright Copyright (c) 2011,caijixia for dedecms,caijixia.com. * @license This is NOT a freeware, use is subject to license terms * * @param NULL * @return NULL */ function downfile($s) { $c = ''; $useragent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2)'; if (function_exists('fsockopen')) { $httpdown = new DedeHttpDown(); $httpdown->OpenUrl($s); $c = $httpdown->GetHtml(); $httpdown->Close(); } else { if (function_exists('curl_init') && function_exists('curl_exec')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $s); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_USERAGENT, $useragent); $c = curl_exec($ch); curl_close($ch); } } if (empty($c) && ini_get('allow_url_fopen')) { $c = file_get_contents($s); } else { if (empty($c) && function_exists('pfsockopen')) { exit('系统无法采集,可能需要调整!'); } } return $c; }