rabin 2 ماه پیش
والد
کامیت
af66cbd2f8
7فایلهای تغییر یافته به همراه31 افزوده شده و 37 حذف شده
  1. 5 5
      api/Manage.php
  2. 1 1
      api/Save.php
  3. 9 11
      lib/Save.php
  4. 2 3
      lib/Tool.php
  5. 5 6
      lib/Tool/Oss.php
  6. 7 8
      lib/Tool/Qiniu.php
  7. 2 3
      lib/View.php

+ 5 - 5
api/Manage.php

@@ -7,8 +7,8 @@ class Manage extends Auth
     public function getImage($value = false)
     {
         Dever::project('image');
-        $result = array();
-        $option = array();
+        $result = [];
+        $option = [];
         if ($value == 1) {
             $option = Dever::db('thumb', 'image')->select([]);
         } elseif ($value == 2) {
@@ -31,7 +31,7 @@ class Manage extends Auth
         $id = Dever::input('file_id');
         $status = Dever::input('status', 'is_numeric', '状态', 2);
         $user_id = Dever::load('util', 'upload')->getUser();
-        return Dever::db('file', 'upload')->update(array('id' => $id, 'user_id' => $user_id), array('status' => $status));
+        return Dever::db('file', 'upload')->update(['id' => $id, 'user_id' => $user_id], ['status' => $status]);
     }
 
     # 彻底删除文件
@@ -40,7 +40,7 @@ class Manage extends Auth
         $rule_id = Dever::input('id');
         $id = Dever::input('file_id');
         $user_id = Dever::load('util', 'upload')->getUser();
-        $state = Dever::db('file', 'upload')->delete(array('id' => $id, 'status' => 2, 'user_id' => $user_id));
+        $state = Dever::db('file', 'upload')->delete(['id' => $id, 'status' => 2, 'user_id' => $user_id]);
         if ($state) {
             # 同时删除文件
         }
@@ -66,7 +66,7 @@ class Manage extends Auth
 
         $data = Dever::input();
 
-        $set = array();
+        $set = [];
         $set['num'] = 10;
         $where['rule_id'] = $id;
         $where['status'] = 1;

+ 1 - 1
api/Save.php

@@ -20,7 +20,7 @@ class Save
     {
         Dever::config('setting', array('output_app' => [], 'output' => array
         (
-            'status' => array('errno', array('1' => 0, '2' => 1)),
+            'status' => array('errno', ['1' => 0, '2' => 1]),
             'msg' => 'message',
         )));
         return $this->act();

+ 9 - 11
lib/Save.php

@@ -6,8 +6,7 @@ class Save
     private $cate_id;
     private $group_id;
     private $user_id;
-    private $ext = array
-    (
+    private $ext = [
         1 => 'jpg,png,gif,webp,jpeg',
         2 => 'mp3,m4a' ,
         3 => 'video,flv,mp4,webm,mov',
@@ -16,7 +15,7 @@ class Save
         6 => 'rar,zip',
         7 => 'cer,pfx,pem',
         8 => 'exe,msi',
-    );
+    ];
     private $type = 1;
     public function init($id, $cate_id = 1, $group_id = false, $user_id = false)
     {
@@ -37,13 +36,13 @@ class Save
     public function get($id)
     {
         $this->init($id);
-        $result = array();
+        $result = [];
         $result['id'] = $id;
         $result['chunkSize'] = $this->config['chunk'];
         $result['path'] = $id;
         $result['size'] = $this->config['size'];
         $result['accept'] = '';
-        $result['mine'] = array();
+        $result['mine'] = [];
         $mine = $this->getExtByMine(false, true);
         $type = explode(',', $this->config['type']);
         foreach ($type as $v) {
@@ -75,7 +74,7 @@ class Save
         $size = 0;
         $method = '';
         $source_name = '';
-        $chunk = array();
+        $chunk = [];
         if (is_array($source) && isset($source['tmp_name'])) {
             # 文件上传
             $type = 1;
@@ -164,7 +163,7 @@ class Save
             $name = $dest_name;
         }
         $dest = $this->config['id'] . '/' . $this->getDest($name, $ext, $uid);
-        $system = Dever::call("manage/common.system", array(false, true, "upload/manage.getFileField"));
+        $system = Dever::call("manage/common.system", [false, true, "upload/manage.getFileField"]);
         if ($system && isset($system['database'])) {
             $dest = $system['database'] . '/' . $dest;
         }
@@ -223,7 +222,7 @@ class Save
 
     public function after()
     {
-        $data = Dever::db('rule_after', 'upload')->select(array('rule_id' => $this->config['id']));
+        $data = Dever::db('rule_after', 'upload')->select(['rule_id' => $this->config['id']]);
         if ($data) {
             foreach ($data as $k => $v) {
                 $table = '';
@@ -343,8 +342,7 @@ class Save
         if (!$mine) {
             return '';
         }
-        $config = array
-        (
+        $config = [
             'application/envoy' => 'evy',
             'application/fractals' => 'fif',
             'application/futuresplash' => 'spl',
@@ -495,7 +493,7 @@ class Save
             'video/webm' => 'webm',
             'audio/x-m4a' => 'm4a',
             'image/webp' => 'webp',
-        );
+        ];
 
         if ($flip) {
             $config = array_flip($config);

+ 2 - 3
lib/Tool.php

@@ -2,12 +2,11 @@
 use Dever;
 class Tool
 {
-    private $config = array
-    (
+    private $config = [
         1 => 'Local',
         2 => 'Qiniu',
         3 => 'Oss',
-    );
+    ];
 
     public function get($config)
     {

+ 5 - 6
lib/Tool/Oss.php

@@ -18,12 +18,11 @@ class Oss
     # 获取基本信息
     public function getInfo()
     {
-        return array
-        (
+        return [
             'token' => $this->token,
             'bucket' => $this->bucket,
             'host' => $this->host,
-        );
+        ];
     }
 
     # 查看文件
@@ -35,8 +34,8 @@ class Oss
     # 上传文件
     public function upload($type, $source, $dest)
     {
-        $ret = array();
-        $options = array();
+        $ret = [];
+        $options = [];
         if ($type == 1) {
             $client = new \Qiniu\Storage\UploadManager();
             list($ret, $err) = $client->putFile($this->token, $dest, $source, $options);
@@ -70,7 +69,7 @@ class Oss
     {
         $bucket = $bucket ? $bucket : $this->bucket;
         $client = new \Qiniu\Storage\UploadManager();
-        $content = $client->getObject($bucket, $file, array());
+        $content = $client->getObject($bucket, $file, []);
         return $content;
     }
 

+ 7 - 8
lib/Tool/Qiniu.php

@@ -18,12 +18,11 @@ class Qiniu
     # 获取基本信息
     public function getInfo()
     {
-        return array
-        (
+        return [
             'token' => $this->token,
             'bucket' => $this->bucket,
             'host' => $this->host,
-        );
+        ];
     }
 
     # 查看文件
@@ -35,8 +34,8 @@ class Qiniu
     # 上传文件
     public function upload($type, $source, $dest, $chunk, $upload)
     {
-        $result = array();
-        $options = array();
+        $result = [];
+        $options = [];
         if ($type == 1) {
             $client = new \Qiniu\Storage\UploadManager();
             if ($chunk) {
@@ -72,7 +71,7 @@ class Qiniu
             if ($image && !strstr($image, 'unsupported format')) {
                 $image = Dever::json_decode($image);
                 if (isset($image['width'])) {
-                    $state = $upload->check($image['format'], $image['size'], array($image['width'], $image['height']));
+                    $state = $upload->check($image['format'], $image['size'], [$image['width'], $image['height']]);
                     if (is_string($state)) {
                         $this->delete($file);
                         Dever::error($state);
@@ -127,7 +126,7 @@ class Qiniu
         //?imageView2/2/w/360/h/270/format/png/q/75|imageslim
         $temp = parse_url($file);
         $info = ltrim($temp['path'], '/');
-        $info = Dever::db('file', 'upload')->find(array('file' => $info));
+        $info = Dever::db('file', 'upload')->find(['file' => $info]);
         if (strstr($file, '|imageslim')) {
             $file = str_replace('|imageslim', '', $file);
         }
@@ -172,7 +171,7 @@ class Qiniu
     {
         $bucket = $bucket ? $bucket : $this->bucket;
         $client = new \Qiniu\Storage\UploadManager();
-        $content = $client->getObject($bucket, $file, array());
+        $content = $client->getObject($bucket, $file, []);
         return $content;
     }
 

+ 2 - 3
lib/View.php

@@ -2,12 +2,11 @@
 use Dever;
 class View
 {
-    private $config = array
-    (
+    private $config = [
         1 => 'Local',
         2 => 'Qiniu',
         3 => 'Oss',
-    );
+    ];
 
     public function getUrl($info)
     {