<?php
/**
 * @Cscms open source management system
 * @copyright 2009-2014 chshcms.com. All rights reserved.
 * @Author:Cheng Jie
 * @Dtime:2014-04-29
 */
require_once CSCMSPATH.'lib/Cs_Qiniu.php';
require_once CSCMSPATH.'qiniu/io.php';
require_once CSCMSPATH.'qiniu/rs.php';

//七牛云单文件上传
if(!function_exists('get_qn_up')) {
    function get_qn_up($path,$key1){
       Qiniu_SetKeys(CS_Qn_Ak, CS_Qn_Sk);
       $putPolicy = new Qiniu_RS_PutPolicy(CS_Qn_Bk);
       $upToken = $putPolicy->Token(null);
       $putExtra = new Qiniu_PutExtra();
       $putExtra->Crc32 = 1;
       list($ret, $err) = Qiniu_PutFile($upToken, $key1,$path, $putExtra);
   
       if ($err !== null) {  //失败
            return FALSE;
       } else {  //成功
            return $ret['key'];
       }
    }
}

//七牛云单文件删除
if(!function_exists('get_qn_del')) {
    function get_qn_del($key1){
       Qiniu_SetKeys(CS_Qn_Ak, CS_Qn_Sk);
       $client = new Qiniu_MacHttpClient(null);
       $err = Qiniu_RS_Delete($client, CS_Qn_Bk, $key1);
       if ($err !== null) {  //失败
            return FALSE;
       } else {  //成功
            return TRUE;
       }
    }
}