dever 6 anos atrás
pai
commit
fa09cad612

+ 82 - 0
database/streams.php

@@ -0,0 +1,82 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'streams',
+    # 显示给用户看的名称
+    'lang' => '直播流管理',
+    'order' => 2,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '流名称',
+            'default'   => '',
+            'desc'      => '名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'space'      => array
+        (
+            'type'      => 'varchar-300',
+            'name'      => '空间名',
+            'default'   => '',
+            'desc'      => '空间名',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '创建时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            //'search'  => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        //'excel'   => true,
+        //'delete' => false,
+        //'edit' => false,
+        //'insert' => false,
+    ),
+
+    'request' => array
+    (
+        
+    )
+
+);

+ 15 - 4
database/upload.php

@@ -17,10 +17,9 @@ $cover = array
 	3 => '不覆盖,直接生成新文件',
 );
 
-$yun = array
-(
-	1 => '七牛云',
-);
+$yun = function() {
+	return Dever::db('upload/yun')->state();
+};
 
 $save_type = array
 (
@@ -155,6 +154,18 @@ return array
 			//'list'		=> true,
 			'show'	=> 'save_type=2,3,4',
 		),
+
+		'bucket'		=> array
+		(
+			'type' 		=> 'varchar-800',
+			'name' 		=> 'bucket名称',
+			'default' 	=> '',
+			'desc' 		=> 'bucket名称',
+			'match' 	=> 'option',
+			'update'	=> 'text',
+			//'list'		=> true,
+			'show'	=> 'save_type=2,3,4',
+		),
 		
 		'state'		=> array
 		(

+ 101 - 0
database/yun.php

@@ -0,0 +1,101 @@
+<?php
+/**
+ * 上传表
+ */
+
+return array
+(
+    # 表名
+    'name' => 'yun',
+    # 显示给用户看的名称
+    'lang' => '云端配置',
+    'order' => 1,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '配置ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-24',
+            'name'      => '配置名',
+            'default'   => '',
+            'desc'      => '请输入配置名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'host'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '域名',
+            'default'   => '',
+            'desc'      => '域名',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+        
+        'appkey'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => 'appkey',
+            'default'   => '',
+            'desc'      => 'appkey',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'appsecret'      => array
+        (
+            'type'      => 'varchar-200',
+            'name'      => 'appsecret',
+            'default'   => '',
+            'desc'      => 'appsecret',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+        
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+    
+    
+    'manage' => array
+    (
+        
+    ),
+);

BIN
sdk/Qiniu/.DS_Store


+ 0 - 1
sdk/Qiniu/Cdn/CdnManager.php

@@ -175,7 +175,6 @@ final class CdnManager
         $deadline = time() + $durationInSeconds;
         $expireHex = dechex($deadline);
         $path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '';
-        $path = implode('/', array_map('rawurlencode', explode('/', $path)));
 
         $strToSign = $encryptKey . $path . $expireHex;
         $signStr = md5($strToSign);

+ 1 - 4
sdk/Qiniu/Config.php

@@ -3,7 +3,7 @@ namespace Qiniu;
 
 final class Config
 {
-    const SDK_VER = '7.2.7';
+    const SDK_VER = '7.2.3';
 
     const BLOCK_SIZE = 4194304; //4*1024*1024 分块上传块大小,该参数为接口规格,不能修改
 
@@ -11,9 +11,6 @@ final class Config
     const API_HOST = 'api.qiniu.com';
     const RS_HOST = 'rs.qiniu.com';      //RS Host
     const UC_HOST = 'https://api.qiniu.com';              //UC Host
-    const RTCAPI_HOST = 'http://rtc.qiniuapi.com';
-    const ARGUS_HOST = 'argus.atlab.ai';
-    const RTCAPI_VERSION = 'v3';
 
     // Zone 空间对应的机房
     public $zone;

+ 1 - 12
sdk/Qiniu/Http/Client.php

@@ -13,12 +13,6 @@ final class Client
         return self::sendRequest($request);
     }
 
-    public static function delete($url, array $headers = array())
-    {
-        $request = new Request('DELETE', $url, $headers);
-        return self::sendRequest($request);
-    }
-
     public static function post($url, $body, array $headers = array())
     {
         $request = new Request('POST', $url, $headers, $body);
@@ -135,7 +129,7 @@ final class Client
             $headerLine = trim($line);
             $kv = explode(':', $headerLine);
             if (count($kv) > 1) {
-                $kv[0] =self::ucwordsHyphen($kv[0]);
+                $kv[0] = ucwords($kv[0], '-');
                 $headers[$kv[0]] = trim($kv[1]);
             }
         }
@@ -148,9 +142,4 @@ final class Client
         $replace = array("\\\\", "\\\"");
         return str_replace($find, $replace, $str);
     }
-    
-    private static function ucwordsHyphen($str)
-    {
-        return str_replace('- ', '-', ucwords(str_replace('-', '- ', $str)));
-    }
 }

+ 0 - 204
sdk/Qiniu/Rtc/AppClient.php

@@ -1,204 +0,0 @@
-<?php
-namespace Qiniu\Rtc;
-
-use Qiniu\Http\Client;
-use Qiniu\Http\Error;
-use Qiniu\Config;
-use Qiniu\Auth;
-
-class AppClient
-{
-    private $auth;
-    private $baseURL;
-
-    public function __construct(Auth $auth)
-    {
-        $this->auth = $auth;
-
-        $this->baseURL = sprintf("%s/%s/apps", Config::RTCAPI_HOST, Config::RTCAPI_VERSION);
-    }
-
-    /*
-     * hub: 直播空间名
-     * title: app 的名称  注意,Title 不是唯一标识,重复 create 动作将生成多个 app
-     * maxUsers:人数限制
-     * NoAutoKickUser: bool 类型,可选,禁止自动踢人(抢流)。默认为 false ,
-       即同一个身份的 client (app/room/user) ,新的连麦请求可以成功,旧连接被关闭。
-     */
-    public function createApp($hub, $title, $maxUsers = null, $noAutoKickUser = null)
-    {
-        $params['hub'] = $hub;
-        $params['title'] = $title;
-        if (!empty($maxUsers)) {
-            $params['maxUsers'] = $maxUsers;
-        }
-        if (!empty($noAutoKickUser)) {
-            $params['noAutoKickUser'] = $noAutoKickUser;
-        }
-        $body = json_encode($params);
-        $ret = $this->post($this->baseURL, $body);
-        return $ret;
-    }
-
-    /*
-     * appId: app 的唯一标识,创建的时候由系统生成。
-     * Title: app 的名称, 可选。
-     * Hub: 绑定的直播 hub,可选,用于合流后 rtmp 推流。
-     * MaxUsers: int 类型,可选,连麦房间支持的最大在线人数。
-     * NoAutoKickUser: bool 类型,可选,禁止自动踢人。
-     * MergePublishRtmp: 连麦合流转推 RTMP 的配置,可选择。其详细配置包括如下
-            Enable: 布尔类型,用于开启和关闭所有房间的合流功能。
-            AudioOnly: 布尔类型,可选,指定是否只合成音频。
-            Height, Width: int64,可选,指定合流输出的高和宽,默认为 640 x 480。
-            OutputFps: int64,可选,指定合流输出的帧率,默认为 25 fps 。
-            OutputKbps: int64,可选,指定合流输出的码率,默认为 1000 。
-            URL: 合流后转推旁路直播的地址,可选,支持魔法变量配置按照连麦房间号生成不同的推流地址。如果是转推到七牛直播云,不建议使用该配置。
-            StreamTitle: 转推七牛直播云的流名,可选,支持魔法变量配置按照连麦房间号生成不同的流名。例如,配置 Hub 为 qn-zhibo ,配置 StreamTitle 为 $(roomName) ,则房间 meeting-001 的合流将会被转推到 rtmp://pili-publish.qn-zhibo.***.com/qn-zhibo/meeting-001地址。详细配置细则,请咨询七牛技术支持。
-     */
-    public function updateApp($appId, $hub, $title, $maxUsers = null, $mergePublishRtmp = null, $noAutoKickUser = null)
-    {
-        $url = $this->baseURL . '/' . $appId;
-        $params['hub'] = $hub;
-        $params['title'] = $title;
-        if (!empty($maxUsers)) {
-            $params['maxUsers'] = $maxUsers;
-        }
-        if (!empty($noAutoKickUser)) {
-            $params['noAutoKickUser'] = $noAutoKickUser;
-        }
-        if (!empty($mergePublishRtmp)) {
-            $params['mergePublishRtmp'] = $mergePublishRtmp;
-        }
-        $body = json_encode($params);
-        $ret = $this->post($url, $body);
-        return $ret;
-    }
-
-    /*
-     * appId: app 的唯一标识,创建的时候由系统生成。
-     */
-    public function getApp($appId)
-    {
-        $url = $this->baseURL . '/' . $appId;
-        $ret  = $this->get($url);
-        return $ret;
-    }
-
-    /*
-     * appId: app 的唯一标识,创建的时候由系统生成
-     */
-    public function deleteApp($appId)
-    {
-        $url = $this->baseURL . '/' . $appId;
-        list(, $err)  = $this->delete($url);
-        return $err;
-    }
-
-    /*
-     * 获取房间的人数
-     * appId: app 的唯一标识,创建的时候由系统生成。
-     * roomName: 操作所查询的连麦房间。
-     */
-    public function listUser($appId, $roomName)
-    {
-        $url = sprintf("%s/%s/rooms/%s/users", $this->baseURL, $appId, $roomName);
-        $ret  = $this->get($url);
-        return $ret;
-    }
-
-   /*
-    * 踢出玩家
-    * appId: app 的唯一标识,创建的时候由系统生成。
-    * roomName: 连麦房间
-    * userId: 请求加入房间的用户ID
-    */
-    public function kickUser($appId, $roomName, $userId)
-    {
-        $url = sprintf("%s/%s/rooms/%s/users/%s", $this->baseURL, $appId, $roomName, $userId);
-        list(, $err)  = $this->delete($url);
-        return $err;
-    }
-
-    /*
-     * 获取房间的人数
-     * appId: app 的唯一标识,创建的时候由系统生成。
-     * prefix: 所查询房间名的前缀索引,可以为空。
-     * offset: int 类型,分页查询的位移标记。
-     * limit: int 类型,此次查询的最大长度。
-     * GET /v3/apps/<AppID>/rooms?prefix=<RoomNamePrefix>&offset=<Offset>&limit=<Limit>
-     */
-    public function listActiveRooms($appId, $prefix = null, $offset = null, $limit = null)
-    {
-        if (isset($prefix)) {
-            $query['prefix'] = $prefix;
-        }
-        if (isset($offset)) {
-            $query['offset'] = $offset;
-        }
-        if (isset($limit)) {
-            $query['limit'] = $limit;
-        }
-        if (isset($query) && !empty($query)) {
-            $query = '?' . http_build_query($query);
-            $url = sprintf("%s/%s/rooms%s", $this->baseURL, $appId, $query);
-        } else {
-            $url = sprintf("%s/%s/rooms", $this->baseURL, $appId);
-        }
-        $ret  = $this->get($url);
-        return $ret;
-    }
-
-    /*
-     * appId: app 的唯一标识,创建的时候由系统生成。
-     * roomName: 房间名称,需满足规格 ^[a-zA-Z0-9_-]{3,64}$
-     * userId: 请求加入房间的用户 ID,需满足规格 ^[a-zA-Z0-9_-]{3,50}$
-     * expireAt: int64 类型,鉴权的有效时间,传入以秒为单位的64位Unix
-       绝对时间,token 将在该时间后失效。
-     * permission: 该用户的房间管理权限,"admin" 或 "user",默认为 "user" 。
-       当权限角色为 "admin" 时,拥有将其他用户移除出房间等特权.
-     */
-    public function appToken($appId, $roomName, $userId, $expireAt, $permission)
-    {
-        $params['appId'] = $appId;
-        $params['userId'] = $userId;
-        $params['roomName'] = $roomName;
-        $params['permission'] = $permission;
-        $params['expireAt'] = $expireAt;
-        $appAccessString = json_encode($params);
-        return $this->auth->signWithData($appAccessString);
-    }
-
-    private function get($url, $cType = null)
-    {
-        $rtcToken = $this->auth->authorizationV2($url, "GET", null, $cType);
-        $rtcToken['Content-Type'] = $cType;
-        $ret = Client::get($url, $rtcToken);
-        if (!$ret->ok()) {
-            return array(null, new Error($url, $ret));
-        }
-        return array($ret->json(), null);
-    }
-
-    private function delete($url, $contentType = 'application/json')
-    {
-        $rtcToken = $this->auth->authorizationV2($url, "DELETE", null, $contentType);
-        $rtcToken['Content-Type'] = $contentType;
-        $ret = Client::delete($url, $rtcToken);
-        if (!$ret->ok()) {
-            return array(null, new Error($url, $ret));
-        }
-        return array($ret->json(), null);
-    }
-
-    private function post($url, $body, $contentType = 'application/json')
-    {
-        $rtcToken = $this->auth->authorizationV2($url, "POST", $body, $contentType);
-        $rtcToken['Content-Type'] = $contentType;
-        $ret = Client::post($url, $body, $rtcToken);
-        if (!$ret->ok()) {
-            return array(null, new Error($url, $ret));
-        }
-        $r = ($ret->body === null) ? array() : $ret->json();
-        return array($r, null);
-    }
-}

+ 0 - 73
sdk/Qiniu/Storage/ArgusManager.php

@@ -1,73 +0,0 @@
-<?php
-namespace Qiniu\Storage;
-
-use Qiniu\Auth;
-use Qiniu\Config;
-use Qiniu\Zone;
-use Qiniu\Http\Client;
-use Qiniu\Http\Error;
-
-/**
- * 主要涉及了鉴黄接口的实现,具体的接口规格可以参考
- *
- * @link https://developer.qiniu.com/dora/manual/3674/kodo-product-introduction
- */
-final class ArgusManager
-{
-    private $auth;
-    private $config;
-
-    public function __construct(Auth $auth, Config $config = null)
-    {
-        $this->auth = $auth;
-        if ($config == null) {
-            $this->config = new Config();
-        } else {
-            $this->config = $config;
-        }
-    }
-
-    /**
-     * 视频鉴黄
-     *
-     * @param $body     body信息
-     * @param $vid      videoID
-     *
-     * @return mixed      成功返回NULL,失败返回对象Qiniu\Http\Error
-     * @link  https://developer.qiniu.com/dora/manual/4258/video-pulp
-     */
-    public function pulpVideo($body, $vid)
-    {
-        $path = '/v1/video/' . $vid;
-        
-        return $this->arPost($path, $body);
-    }
-
-    private function getArHost()
-    {
-        $scheme = "http://";
-        if ($this->config->useHTTPS == true) {
-            $scheme = "https://";
-        }
-        return $scheme . Config::ARGUS_HOST;
-    }
-
-    private function arPost($path, $body = null)
-    {
-        $url = $this->getArHost() . $path;
-        return $this->post($url, $body);
-    }
-
-    private function post($url, $body)
-    {
-        $headers = $this->auth->authorizationV2($url, 'POST', $body, 'application/json');
-        $headers['Content-Type']='application/json';
-        $ret = Client::post($url, $body, $headers);
-        if (!$ret->ok()) {
-            print($ret->statusCode);
-            return array(null, new Error($url, $ret));
-        }
-        $r = ($ret->body === null) ? array() : $ret->json();
-        return array($r, null);
-    }
-}

+ 0 - 17
sdk/Qiniu/Storage/BucketManager.php

@@ -225,23 +225,6 @@ final class BucketManager
         return $error;
     }
 
-    /**
-     * 修改文件的存储状态,即禁用状态和启用状态间的的互相转换
-     *
-     * @param $bucket     待操作资源所在空间
-     * @param $key        待操作资源文件名
-     * @param $status       待操作文件目标文件类型
-     *
-     * @return mixed      成功返回NULL,失败返回对象Qiniu\Http\Error
-     * @link  https://developer.qiniu.com/kodo/api/4173/modify-the-file-status
-     */
-    public function changeStatus($bucket, $key, $status)
-    {
-        $resource = \Qiniu\entry($bucket, $key);
-        $path = '/chstatus/' . $resource . '/status/' . $status;
-        list(, $error) = $this->rsPost($path);
-        return $error;
-    }
 
     /**
      * 从指定URL抓取资源,并将该资源存储到指定空间中

+ 3 - 3
sdk/Qiniu/Storage/UploadManager.php

@@ -108,6 +108,7 @@ final class UploadManager
                 $this->config,
                 $params,
                 $mime,
+                $checkCrc,
                 basename($filePath)
             );
         }
@@ -133,9 +134,8 @@ final class UploadManager
         }
         $ret = array();
         foreach ($params as $k => $v) {
-            $pos1 = strpos($k, 'x:');
-            $pos2 = strpos($k, 'x-qn-meta-');
-            if (($pos1 === 0 || $pos2 === 0) && !empty($v)) {
+            $pos = strpos($k, 'x:');
+            if ($pos === 0 && !empty($v)) {
                 $ret[$k] = $v;
             }
         }

+ 20 - 46
sdk/Qiniu/Zone.php

@@ -44,48 +44,22 @@ final class Zone
         $Zone_z0 = new Zone(
             array("up.qiniup.com", 'up-jjh.qiniup.com', 'up-xs.qiniup.com'),
             array('upload.qiniup.com', 'upload-jjh.qiniup.com', 'upload-xs.qiniup.com'),
-            'rs.qbox.me',
-            'rsf.qbox.me',
+            'rs.qiniu.com',
+            'rsf.qiniu.com',
             'api.qiniu.com',
             'iovip.qbox.me'
         );
         return $Zone_z0;
     }
 
-    //华东机房内网上传
-    public static function zoneZ0()
-    {
-        $Zone_z01 = new Zone(
-            array("free-qvm-z0-xs.qiniup.com"),
-            'rs.qbox.me',
-            'rsf.qbox.me',
-            'api.qiniu.com',
-            'iovip.qbox.me'
-        );
-        return $Zone_z01;
-    }
-
-    //华北机房内网上传
-    public static function zoneZ1()
-    {
-        $Zone_z12 = new Zone(
-            array("free-qvm-z1-zz.qiniup.com"),
-            "rs-z1.qbox.me",
-            "rsf-z1.qbox.me",
-            "api-z1.qiniu.com",
-            "iovip-z1.qbox.me"
-        );
-        return $Zone_z12;
-    }
-
     //华北机房
     public static function zone1()
     {
         $Zone_z1 = new Zone(
             array('up-z1.qiniup.com'),
             array('upload-z1.qiniup.com'),
-            "rs-z1.qbox.me",
-            "rsf-z1.qbox.me",
+            "rs-z1.qiniu.com",
+            "rsf-z1.qiniu.com",
             "api-z1.qiniu.com",
             "iovip-z1.qbox.me"
         );
@@ -99,8 +73,8 @@ final class Zone
         $Zone_z2 = new Zone(
             array('up-z2.qiniup.com', 'up-dg.qiniup.com', 'up-fs.qiniup.com'),
             array('upload-z2.qiniup.com', 'upload-dg.qiniup.com', 'upload-fs.qiniup.com'),
-            "rs-z2.qbox.me",
-            "rsf-z2.qbox.me",
+            "rs-z2.qiniu.com",
+            "rsf-z2.qiniu.com",
             "api-z2.qiniu.com",
             "iovip-z2.qbox.me"
         );
@@ -114,8 +88,8 @@ final class Zone
         $Zone_na0 = new Zone(
             array('up-na0.qiniup.com'),
             array('upload-na0.qiniup.com'),
-            "rs-na0.qbox.me",
-            "rsf-na0.qbox.me",
+            "rs-na0.qiniu.com",
+            "rsf-na0.qiniu.com",
             "api-na0.qiniu.com",
             "iovip-na0.qbox.me"
         );
@@ -129,8 +103,8 @@ final class Zone
         $Zone_as0 = new Zone(
             array('up-as0.qiniup.com'),
             array('upload-as0.qiniup.com'),
-            "rs-as0.qbox.me",
-            "rsf-as0.qbox.me",
+            "rs-as0.qiniu.com",
+            "rsf-as0.qiniu.com",
             "api-as0.qiniu.com",
             "iovip-as0.qbox.me"
         );
@@ -171,24 +145,24 @@ final class Zone
 
         //set specific hosts
         if (strstr($zone->iovipHost, "z1") !== false) {
-            $zone->rsHost = "rs-z1.qbox.me";
-            $zone->rsfHost = "rsf-z1.qbox.me";
+            $zone->rsHost = "rs-z1.qiniu.com";
+            $zone->rsfHost = "rsf-z1.qiniu.com";
             $zone->apiHost = "api-z1.qiniu.com";
         } elseif (strstr($zone->iovipHost, "z2") !== false) {
-            $zone->rsHost = "rs-z2.qbox.me";
-            $zone->rsfHost = "rsf-z2.qbox.me";
+            $zone->rsHost = "rs-z2.qiniu.com";
+            $zone->rsfHost = "rsf-z2.qiniu.com";
             $zone->apiHost = "api-z2.qiniu.com";
         } elseif (strstr($zone->iovipHost, "na0") !== false) {
-            $zone->rsHost = "rs-na0.qbox.me";
-            $zone->rsfHost = "rsf-na0.qbox.me";
+            $zone->rsHost = "rs-na0.qiniu.com";
+            $zone->rsfHost = "rsf-na0.qiniu.com";
             $zone->apiHost = "api-na0.qiniu.com";
         } elseif (strstr($zone->iovipHost, "as0") !== false) {
-            $zone->rsHost = "rs-as0.qbox.me";
-            $zone->rsfHost = "rsf-as0.qbox.me";
+            $zone->rsHost = "rs-as0.qiniu.com";
+            $zone->rsfHost = "rsf-as0.qiniu.com";
             $zone->apiHost = "api-as0.qiniu.com";
         } else {
-            $zone->rsHost = "rs.qbox.me";
-            $zone->rsfHost = "rsf.qbox.me";
+            $zone->rsHost = "rs.qiniu.com";
+            $zone->rsfHost = "rsf.qiniu.com";
             $zone->apiHost = "api.qiniu.com";
         }
 

+ 1 - 1
sdk/Qiniu/functions.php

@@ -255,7 +255,7 @@ if (!defined('QINIU_FUNCTIONS_VERSION')) {
             return array(null, null, "invalid uptoken");
         }
         $accessKey = $items[0];
-        $putPolicy = json_decode(base64_urlSafeDecode($items[2]));
+        $putPolicy = json_decode(base64_decode($items[2]));
         $scope = $putPolicy->scope;
         $scopeItems = explode(':', $scope);
         $bucket = $scopeItems[0];

+ 20 - 0
sdk/qiniu.php

@@ -0,0 +1,20 @@
+<?php
+
+
+Dever::apply('sdk/Qiniu/Config', 'upload');
+Dever::apply('sdk/Qiniu/functions', 'upload');
+
+Dever::apply('sdk/Qiniu/Http/Client', 'upload');
+Dever::apply('sdk/Qiniu/Http/Error', 'upload');
+Dever::apply('sdk/Qiniu/Zone', 'upload');
+
+Dever::apply('sdk/Qiniu/Auth', 'upload');
+
+Dever::apply('sdk/Qiniu/Http/Request', 'upload');
+Dever::apply('sdk/Qiniu/Http/Response', 'upload');
+
+Dever::apply('sdk/Qiniu/Storage/ResumeUploader', 'upload');
+Dever::apply('sdk/Qiniu/Storage/FormUploader', 'upload');
+
+
+Dever::apply('sdk/Qiniu/Storage/UploadManager', 'upload');

+ 0 - 6
sdk/quniu.php

@@ -1,6 +0,0 @@
-<?php
-
-Dever::apply('sdk/Qiniu/WxPay.Api', 'upload');
-Dever::apply('sdk/wechat/WxPay.JsApiPay', 'pay');
-Dever::apply('sdk/wechat/WxPay.Config', 'pay');
-Dever::apply('sdk/wechat/WxPay.Notify', 'pay');

+ 6 - 1
src/Store/Core.php

@@ -225,6 +225,9 @@ class Core
 		if (isset($this->handle) && is_array($this->handle)) {
 			foreach ($this->handle as $k => $v) {
 				$method = 'handle_' . $v[0];
+				if (method_exists($this, $method)) {
+					$this->$method($v);
+				}
 				$this->$method($v[1]);
 			}
 		} elseif (isset($this->config['alter']) && $this->config['alter']) {
@@ -232,7 +235,9 @@ class Core
 			if ($handle) {
 				foreach ($handle as $k => $v) {
 					$method = 'handle_' . $k;
-					$this->$method($v);
+					if (method_exists($this, $method)) {
+						$this->$method($v);
+					}
 				}
 			}
 		}

+ 1 - 1
src/Store/Handle.php

@@ -19,7 +19,7 @@ class Handle
         $this->yun = $config['yun'];
         if ($this->save_type >= 2) {
             if ($this->yun == 1) {
-                $yun = 'Qiniu';
+                $yun = 'Upload\Src\Store\Qiniu';
             }
             
             $this->yun = new $yun($data);

+ 1 - 1
src/Store/Local.php

@@ -49,7 +49,7 @@ class Local extends Core implements Config
 				$this->output['status'] = -1;
 				$this->output['message'] = '文件已经存在';
 			} else {
-				unlink($this->data['file']['tmp_name']);
+				//unlink($this->data['file']['tmp_name']);
 			}
 
 			@chmod($this->output['file'], 0755);

+ 28 - 27
src/Store/Qiniu.php

@@ -2,6 +2,7 @@
 namespace Upload\Src\Store;
 
 use Dever;
+Dever::apply('sdk/qiniu', 'upload');
 
 class Qiniu extends Core implements Config
 {
@@ -12,29 +13,37 @@ class Qiniu extends Core implements Config
      */
     public function save()
     {
-        $this->root();
-        
+        $config = Dever::db('upload/yun')->one($this->config['yun']);
+        $accessKey = $config['appkey'];
+        $secretKey = $config['appsecret'];
+        $this->host = $config['host'];
+        $auth = new \Qiniu\Auth($accessKey, $secretKey);
+        $bucket = $this->config['bucket'];
+
+        $policy = array(
+            'callbackUrl' => 'http://your.domain.com/upload_verify_callback.php',
+            'callbackBody' => 'filename=$(fname)&filesize=$(fsize)'
+        );
+
+        // 生成上传Token
+        $token = $auth->uploadToken($bucket, null, 3600);
+        // 构建 UploadManager 对象
+        $upload = new \Qiniu\Storage\UploadManager();
+
         $this->path()->name($this->data['file']['name'])->ext()->file();
-        
-        # 不覆盖
-        if (is_file($this->output['file']) && $this->config['cover'] == 2) {
-            $this->output['status'] = -1;
-            $this->output['message'] = '文件已经存在';
-        } else {
-            # 不覆盖 生成新文件
-            if (is_file($this->output['file']) && $this->config['cover'] == 3) {
-                // . microtime() . rand(0,1000)
-                $this->name($this->output['file'] . '_' . microtime() . '_' . rand(0,1000))->file();
-            } else {
-                $file = Dever::load('upload/file-name', array('where_name' => $this->name));
-            }
 
+        list($ret, $err) = $upload->putFile($token, $this->file, $this->data['file']['tmp_name'], $param = null);
+
+        if (isset($ret['hash']) && isset($ret['key']) && $ret['key'] == $this->file) {
+
+            $file = Dever::load('upload/file-name', array('where_name' => $this->name));
+            
             if (!$this->limit) {
                 //$this->limit = getimagesize($this->output['file']);
             }
 
             if (!$this->size) {
-                $this->size = filesize($this->output['file']);
+                //$this->size = filesize($this->output['file']);
             }
             
             if (isset($file) && $file) {
@@ -44,15 +53,7 @@ class Qiniu extends Core implements Config
                 $this->insert();
             }
             
-            if (!copy($this->data['file']['tmp_name'], $this->output['file'])) {
-                $this->output['status'] = -1;
-                $this->output['message'] = '文件已经存在';
-            } else {
-                unlink($this->data['file']['tmp_name']);
-            }
-
-            @chmod($this->output['file'], 0755);
-            @system('chmod -R 777 ' . $this->output['file']);
+            unlink($this->data['file']['tmp_name']);
 
             return $this->output['url'];
         }
@@ -85,8 +86,8 @@ class Qiniu extends Core implements Config
     {
         $this->file = $this->path . $this->name . $this->ext;
 
-        $this->output['file'] = is_file($this->base . $this->file) ? $this->base . $this->file : Dever::path($this->base, $this->file);
-        $this->output['url'] = Dever::config('host')->uploadRes . $this->file;
+        $this->output['file'] = $this->file;
+        $this->output['url'] = $this->host . $this->file;
 
         return $this->output['file'];
     }