|
@@ -11,6 +11,11 @@
|
|
|
class body_filder
|
|
|
{
|
|
|
private $goods_common;
|
|
|
+ static $save_path = BASE_DATA_PATH . '/upload/detail';
|
|
|
+ static $down_path = BASE_DATA_PATH . '/Download/detail';
|
|
|
+
|
|
|
+ //static $req_path = 'http://p.lrlz.com/upload/detail/';
|
|
|
+ static $req_path = 'http://localhost/data/upload/detail/';
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
@@ -28,13 +33,10 @@ class body_filder
|
|
|
return $val;
|
|
|
}
|
|
|
|
|
|
- private function download($url,&$path)
|
|
|
+ private function download($url,$path)
|
|
|
{
|
|
|
$info = pathinfo($url);
|
|
|
- $name = md5($url) . '.' . $info['extension'];
|
|
|
|
|
|
- $path = BASE_DATA_PATH . '/upload/detail';
|
|
|
- $path = $path . '/' . $name;
|
|
|
if(!file_exists($path)) {
|
|
|
$pic_url = $info['dirname'] . '/' . urlencode($info['basename']);
|
|
|
exec("wget -O $path $pic_url");
|
|
@@ -45,6 +47,7 @@ class body_filder
|
|
|
if(filesize($path) > 0) {
|
|
|
return true;
|
|
|
} else {
|
|
|
+ unlink($path);
|
|
|
return false;
|
|
|
}
|
|
|
} else {
|
|
@@ -56,11 +59,6 @@ class body_filder
|
|
|
//
|
|
|
private function filterex($val,$commid)
|
|
|
{
|
|
|
- static $save_path = BASE_DATA_PATH . '/upload/detail';
|
|
|
- static $req_path = 'http://p.lrlz.com/upload/detail/';
|
|
|
-
|
|
|
- //static $req_path = 'http://localhost/data/upload/detail/';
|
|
|
-
|
|
|
$style = '/\s*<img\s*[^>]*src\s*=\s*\"([^>\"]*)\"\s*[^>]*>/i';
|
|
|
$val = preg_match_all($style,$val,$match);
|
|
|
if(!empty($val) && $val > 0)
|
|
@@ -70,21 +68,23 @@ class body_filder
|
|
|
foreach($match[1] as $url)
|
|
|
{
|
|
|
$info = pathinfo($url);
|
|
|
-
|
|
|
if(empty($info['extension'])) continue;
|
|
|
- //if(strtolower($info['extension']) == 'gif') continue;
|
|
|
|
|
|
- if($this->download($url,$path))
|
|
|
+ $name = md5($url) . '.' . $info['extension'];
|
|
|
+ $path = self::$down_path . '/' . $name;
|
|
|
+
|
|
|
+ if(file_exists($path) || $this->download($url,$path))
|
|
|
{
|
|
|
$name = "{$commid}-{$num}.{$info['extension']}";
|
|
|
- $newpath = "{$save_path}/{$name}";
|
|
|
+ $newpath = self::$save_path . "/{$name}";
|
|
|
|
|
|
- if(file_exists($newpath)) unlink($newpath);
|
|
|
+ if(file_exists($newpath)) {
|
|
|
+ unlink($newpath);
|
|
|
+ }
|
|
|
+ copy($path,$newpath);
|
|
|
|
|
|
- rename($path,$newpath);
|
|
|
++$num;
|
|
|
-
|
|
|
- $html .= "<img src=\"{$req_path}{$name}\">";
|
|
|
+ $html .= "<img src=\"" . self::$req_path . "{$name}\">";
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -105,7 +105,6 @@ class body_filder
|
|
|
$body = $val['description'];
|
|
|
$this->goods_common->where(array('num_iid' => $num_iid))->update(array('goods_body' => $body));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public function proc()
|