|
@@ -866,6 +866,11 @@ class CameraApiController extends BaseController
|
|
|
|
|
|
if(count($result) > 0){
|
|
if(count($result) > 0){
|
|
for($i=0;$i<count($result);$i++){
|
|
for($i=0;$i<count($result);$i++){
|
|
|
|
+ if($result[$i]->type=="mkxw"){
|
|
|
|
+ unset($result[$i]);
|
|
|
|
+ $newObject = ['type' => 'mkxw','name'=>'煤矿新闻'];
|
|
|
|
+ array_unshift($result, $newObject);
|
|
|
|
+ }
|
|
if($result[$i]->type == 'aqsc'){
|
|
if($result[$i]->type == 'aqsc'){
|
|
$result[$i]->name = '安全生产';
|
|
$result[$i]->name = '安全生产';
|
|
}
|
|
}
|
|
@@ -923,7 +928,9 @@ class CameraApiController extends BaseController
|
|
|
|
|
|
$result = DB::connection('etl_zaoquan')->select("select * from news_column_list where type = '".$params['type']."' order by create_time desc limit ".$params['page_size']." offset ".$offset);
|
|
$result = DB::connection('etl_zaoquan')->select("select * from news_column_list where type = '".$params['type']."' order by create_time desc limit ".$params['page_size']." offset ".$offset);
|
|
|
|
|
|
- $pattern = '/<img(.*?)src=["\'](.*?)["\'](.*?)>/i';
|
|
|
|
|
|
+ $pattern = '/<img(.*?)src=["\'](.*?)["\'](.*?)>/i';//图片
|
|
|
|
+
|
|
|
|
+ $pattern2 = '/href="([^"]+)"/';//文件
|
|
|
|
|
|
if(count($result) > 0){
|
|
if(count($result) > 0){
|
|
for($i=0;$i<count($result);$i++){
|
|
for($i=0;$i<count($result);$i++){
|
|
@@ -942,8 +949,9 @@ class CameraApiController extends BaseController
|
|
|
|
|
|
unset($result[$i]->create_time);
|
|
unset($result[$i]->create_time);
|
|
|
|
|
|
- //替换text
|
|
|
|
|
|
+ //替换text的图片
|
|
preg_match_all($pattern, $result[$i]->text, $matches);
|
|
preg_match_all($pattern, $result[$i]->text, $matches);
|
|
|
|
+
|
|
foreach ($matches[2] as $index => $oldSrc) {
|
|
foreach ($matches[2] as $index => $oldSrc) {
|
|
$news_img_list = DB::connection('etl_zaoquan')->select("select * from news_img_list where img_name ='".basename($oldSrc)."'");
|
|
$news_img_list = DB::connection('etl_zaoquan')->select("select * from news_img_list where img_name ='".basename($oldSrc)."'");
|
|
if(count($news_img_list) > 0){
|
|
if(count($news_img_list) > 0){
|
|
@@ -951,6 +959,18 @@ class CameraApiController extends BaseController
|
|
$result[$i]->text = str_replace($oldSrc, $newSrc, $result[$i]->text);
|
|
$result[$i]->text = str_replace($oldSrc, $newSrc, $result[$i]->text);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //替换text的文件
|
|
|
|
+ preg_match_all($pattern2, $result[$i]->text, $matches2);
|
|
|
|
+
|
|
|
|
+ foreach ($matches2[1] as $index => $oldSrc) {
|
|
|
|
+ $news_file_list = DB::connection('etl_zaoquan')->select("select * from news_img_list where img_name ='".basename($oldSrc)."'");
|
|
|
|
+ if(count($news_file_list) > 0){
|
|
|
|
+ $newSrc = $news_file_list[0]->new_name;
|
|
|
|
+
|
|
|
|
+ $result[$i]->text = str_replace($oldSrc, $newSrc, $result[$i]->text);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -987,20 +1007,24 @@ class CameraApiController extends BaseController
|
|
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
|
|
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
|
|
$rawdata = curl_exec ($ch);
|
|
$rawdata = curl_exec ($ch);
|
|
curl_close ($ch);
|
|
curl_close ($ch);
|
|
|
|
+
|
|
|
|
+ $houzhui = explode('.',$file_path);
|
|
|
|
+ $houzhui = '.'.$houzhui[count($houzhui)-1];
|
|
|
|
+
|
|
// 使用中文文件名需要转码
|
|
// 使用中文文件名需要转码
|
|
- $fp = fopen(public_path() . '/filedownload/' . $rename.'.jpg', 'w');
|
|
|
|
|
|
+ $fp = fopen(public_path() . '/filedownload/' . $rename.$houzhui, 'w');
|
|
fwrite($fp, $rawdata);
|
|
fwrite($fp, $rawdata);
|
|
fclose($fp);
|
|
fclose($fp);
|
|
|
|
|
|
$file_name = $rename;
|
|
$file_name = $rename;
|
|
|
|
|
|
//上传文件
|
|
//上传文件
|
|
- $file_oss_path = $this->uploadFile($file_name);
|
|
|
|
|
|
+ $file_oss_path = $this->uploadFile($file_name,$houzhui);
|
|
return $file_oss_path;
|
|
return $file_oss_path;
|
|
}
|
|
}
|
|
|
|
|
|
//上传文件
|
|
//上传文件
|
|
- public function uploadFile($file_name)
|
|
|
|
|
|
+ public function uploadFile($file_name,$houzhui)
|
|
{
|
|
{
|
|
try{
|
|
try{
|
|
$oss = new OssClient(
|
|
$oss = new OssClient(
|
|
@@ -1009,8 +1033,8 @@ class CameraApiController extends BaseController
|
|
Config::get('filesystems.disks.oss_view.endpoint')
|
|
Config::get('filesystems.disks.oss_view.endpoint')
|
|
);
|
|
);
|
|
|
|
|
|
- $file_path = public_path() . '/filedownload/' . $file_name.'.jpg';
|
|
|
|
- $res = $oss->uploadFile(Config::get('filesystems.disks.oss_view.bucket'), $file_name.'.jpeg', $file_path);
|
|
|
|
|
|
+ $file_path = public_path() . '/filedownload/' . $file_name.$houzhui;
|
|
|
|
+ $res = $oss->uploadFile(Config::get('filesystems.disks.oss_view.bucket'), $file_name.$houzhui, $file_path);
|
|
} catch(\OssException $e) {
|
|
} catch(\OssException $e) {
|
|
printf(__FUNCTION__ . ": FAILED\n");
|
|
printf(__FUNCTION__ . ": FAILED\n");
|
|
printf($e->getMessage() . "\n");
|
|
printf($e->getMessage() . "\n");
|