function getCurContent($content)
{
$reg = '/<img (.*?)+src=[\'"](.*?)[\'"]/i';
preg_match_all( $reg , $content , $img_array );
$bb = $img_array[2];
$img_array = array_unique($bb);
if ($img_array != '') {
$imgUrl = DS . 'uploads' . DS . date("Ymd") . DS;
$imgPath = ROOT_PATH . $imgUrl;
$htd = new Http();
foreach ($bb as $key => $value) {
$md5 = strtolower($htd->getHash($value, true));
$filemode = Db::name('file');
$n = $filemode->where('md5', $md5)->find();
$realpath = '';
if (empty($n)) {
$itype = substr(strrchr($value, '.'), 1);
$milliSecondN = md5(microtime(true));
$rndFileName = $imgPath . $milliSecondN . '.' . $itype;
$fileurl = $imgUrl . $milliSecondN . '.' . $itype;
$rs = $htd->http_down($value, $rndFileName);
if ($rs) {
$path = str_replace("\\", "/", $fileurl);
$realpath = WEB_URL . $path;
$data['sha1'] = sha1($rndFileName);
$data['md5'] = md5($rndFileName);
$data['create_time'] = time();
$data['size'] = filesize($rndFileName);
$data['name'] = $milliSecondN . '.' . $itype;
$data['ext'] = $itype;
$data['savepath'] = $realpath;
$data['savename'] = $milliSecondN . '.' . $itype;
Db::name('file')->insert($data);
}
} else {
$realpath = $n['savepath'];
}
$content = str_replace($value, $realpath, $content);
}
}
return $content;
}