Ver código fonte

调试视频注入

15954078560 2 anos atrás
pai
commit
c0f7901446
2 arquivos alterados com 185 adições e 1 exclusões
  1. 184 0
      application/admin/controller/Video.php
  2. 1 1
      application/common.php

+ 184 - 0
application/admin/controller/Video.php

@@ -3,6 +3,7 @@
 namespace app\admin\controller;
 
 use app\common\controller\Backend;
+use think\Db;
 
 /**
  * 视频专区
@@ -69,4 +70,187 @@ class Video extends Backend
         return $this->view->fetch();
     }
 
+    /**
+     * 添加
+     */
+    public function add()
+    {
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            if ($params) {
+                $params = $this->preExcludeFields($params);
+
+                if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
+                    $params[$this->dataLimitField] = $this->auth->id;
+                }
+                $result = false;
+                Db::startTrans();
+                try {
+                    //是否采用模型验证
+                    if ($this->modelValidate) {
+                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
+                        $this->model->validateFailException(true)->validate($validate);
+                    }
+                    $result = $this->model->allowField(true)->save($params);
+
+                    $id = $this->model->id;
+                    Db::commit();
+                } catch (ValidateException $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                } catch (PDOException $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                } catch (Exception $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                }
+                if ($result !== false) {
+                    //生成ftp文件
+                    $content = [
+                        'cpPrvdName' => '健康e家',
+                        'cpPrvCode' => '41000144',
+                        'cpPrvType' => '1006',
+                        'ChnName' => '健康',
+                        'ChnCode' => '1000020',
+                        'contentId' => (string)$id,
+                        'extraContentID' => '',
+                        'content' => $params['title'],
+                        'actors' => '',
+                        'directors' => '',
+                        'contentYear' => '',
+                        'tags' => '',
+                        'intent' => [
+                            'action' => '',
+                            'package' => '',
+                            'component' => [
+                                'pkg' => '',
+                                'cls' => ''
+                            ],
+                            'extras' => [
+                                'cmd' => '',
+                                'from' => '',
+                                'media_id' => ''
+                            ]
+                        ],
+                        'isEffective' => $params['status'],
+                        'pic' => one_domain_image($params['image']),
+                        'contentTime' => date('Y-m-d H:i:s'),
+                        'isPaid' => $params['is_pay'],
+                        'formatType' => ''
+                    ];
+                    $content = json_encode($content, 320);
+                    $filename = 'shipin_'.date('Ymd').'_'.date('His').'_increment'.'.json';
+                    error_log(print_r($content, 1) . PHP_EOL, 3, './jiankang/' . $filename);
+                    //调用增量注入接口
+                    $url = 'http:// test.meta.unso.gitv.tv/sendMeta';
+                    $method = 'POST';
+                    $postfields = [
+                        'priKey' => '123456',
+                        'data' => [$content]
+                    ];
+                    httpRequest($url, $method, $postfields);
+
+                    $this->success();
+                } else {
+                    $this->error(__('No rows were inserted'));
+                }
+            }
+            $this->error(__('Parameter %s can not be empty', ''));
+        }
+        return $this->view->fetch();
+    }
+
+    /**
+     * 编辑
+     */
+    public function edit($ids = null)
+    {
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        $adminIds = $this->getDataLimitAdminIds();
+        if (is_array($adminIds)) {
+            if (!in_array($row[$this->dataLimitField], $adminIds)) {
+                $this->error(__('You have no permission'));
+            }
+        }
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            if ($params) {
+                $params = $this->preExcludeFields($params);
+                $result = false;
+                Db::startTrans();
+                try {
+                    //是否采用模型验证
+                    if ($this->modelValidate) {
+                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+                        $row->validateFailException(true)->validate($validate);
+                    }
+                    $result = $row->allowField(true)->save($params);
+                    Db::commit();
+                } catch (ValidateException $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                } catch (PDOException $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                } catch (Exception $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                }
+                if ($result !== false) {
+                    $this->success();
+                } else {
+                    $this->error(__('No rows were updated'));
+                }
+            }
+            $this->error(__('Parameter %s can not be empty', ''));
+        }
+        $this->view->assign("row", $row);
+        return $this->view->fetch();
+    }
+
+    /**
+     * 删除
+     */
+    public function del($ids = "")
+    {
+        if (!$this->request->isPost()) {
+            $this->error(__("Invalid parameters"));
+        }
+        $ids = $ids ? $ids : $this->request->post("ids");
+        if ($ids) {
+            $pk = $this->model->getPk();
+            $adminIds = $this->getDataLimitAdminIds();
+            if (is_array($adminIds)) {
+                $this->model->where($this->dataLimitField, 'in', $adminIds);
+            }
+            $list = $this->model->where($pk, 'in', $ids)->select();
+
+            $count = 0;
+            Db::startTrans();
+            try {
+                foreach ($list as $k => $v) {
+                    $count += $v->delete();
+                }
+                Db::commit();
+            } catch (PDOException $e) {
+                Db::rollback();
+                $this->error($e->getMessage());
+            } catch (Exception $e) {
+                Db::rollback();
+                $this->error($e->getMessage());
+            }
+            if ($count) {
+                $this->success();
+            } else {
+                $this->error(__('No rows were deleted'));
+            }
+        }
+        $this->error(__('Parameter %s can not be empty', 'ids'));
+    }
 }

+ 1 - 1
application/common.php

@@ -635,7 +635,7 @@ function getMillisecond() {
  * @param bool|false $debug  调试开启 默认false
  * @return mixed
  */
-function httpRequest($url, $method, $postfields = null, $headers = array(), $debug = false) {
+function httpRequest($url = '', $method = '', $postfields = null, $headers = array(), $debug = false) {
     $method = strtoupper($method);
     $ci = curl_init();
     /* Curl settings */