destoon7.0系统七牛云对象存储
1.注意客户购买的空间的存储区域,区域不同对应的上传域名不同
destoon 七牛云上传文件 用下面源码替换include/ftp.class.php
文件代码如下:
- <?php
- defined('IN_DESTOON') or exit('Access Denied');
- class dftp {
- var $connected = 0;
- var $ak;
- var $sk;
- var $bk;
- function __construct($ftphost, $ftpuser, $ftppass, $ftpport = 21, $root = '/', $pasv = 0, $ssl = 0) {
- $this->connected = 1;
- $this->ak = $ftpuser;
- $this->sk = $ftppass;
- $this->bk = $root;
- }
- function dftp($ftphost, $ftpuser, $ftppass, $ftpport = 21, $root = '/', $pasv = 0, $ssl = 0) {
- $this->__construct($ftphost, $ftpuser, $ftppass, $ftpport, $root, $pasv, $ssl);
- }
- function dftp_delete($file) {
- $key = $file;
- $entry = $this->bk.':'.$key;
- $encodedEntryURI = $this->dftp_encode($entry);
- $signingStr = "/delete/".$encodedEntryURI."\n";
- $sign = hash_hmac('sha1', $signingStr, $this->sk, true);
- $encodedSign = $this->dftp_encode($sign);
- $accessToken = $this->ak.':'.$encodedSign;
- $headers = array();
- $headers[] = 'Authorization: QBox '.$accessToken;
- $cur = curl_init('http://rs.qiniu.com/delete/'.$encodedEntryURI);
- curl_setopt($cur, CURLOPT_POST, 1);
- curl_setopt($cur, CURLOPT_POSTFIELDS, '');
- curl_setopt($cur, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($cur, CURLOPT_HEADER, 0);
- curl_setopt($cur, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($cur, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($cur, CURLOPT_HTTPHEADER, $headers);
- $rec = curl_exec($cur);
- curl_close($cur);
- }
- function dftp_put($local, $remote = '') {
- global $DT_TIME;
- $remote or $remote = $local;
- $local = DT_ROOT.'/'.$local;
- $key = $remote;
- $P = array();
- $P['scope'] = $this->bk.':'.$key;
- $P['deadline'] = $DT_TIME + 3600;
- $putPolicy = json_encode($P);
- $encodedPutPolicy = $this->dftp_encode($putPolicy);
- $sign = hash_hmac('sha1', $encodedPutPolicy, $this->sk, true);
- $encodedSign = $this->dftp_encode($sign);
- $uploadToken = $this->ak.':'.$encodedSign.':'.$encodedPutPolicy;
- $headers = array();
- $headers[] = 'Expect: ';
- $par = array();
- $par['key'] = $key;
- $par['token'] = $uploadToken;
- #$par['file'] = '@'.$local;
- $par['file'] = file_get_contents($local);
- $cur = curl_init('http://upload-z2.qiniu.com/');
- curl_setopt($cur, CURLOPT_POST, 1);
- curl_setopt($cur, CURLOPT_POSTFIELDS, $par);
- curl_setopt($cur, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($cur, CURLOPT_HEADER, 0);
- curl_setopt($cur, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($cur, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($cur, CURLOPT_HTTPHEADER, $headers);
- $rec = curl_exec($cur);
- curl_close($cur);
- if(strpos($rec, 'key') !== false) {
- $arr = json_decode($rec, true);
- if($arr['key'] == $key) return true;
- }
- return false;
- }
- function dftp_chdir() {
- if(!function_exists('hash_hmac')) return false;
- if(!function_exists('curl_init')) return false;
- return true;
- }
- function dftp_encode($str) {
- return str_replace(array('+', '/'), array('-', '_'), base64_encode($str));
- }
- }
- ?>
后台设置:
配置细节说明:
FTP帐号:AccessKey 例如:db2N1b4xpqtA7UltwE97feeetgssYNjHFf9k-ZFs
远程存储目录:存储空间 bucket 名称 例如:img-destoon-com
<p text-indent:0px;"="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; font-family: "Microsoft Yahei", "HanHei SC", PingHei, "PingFang SC", "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", "Heiti SC", "WenQuanYi Micro Hei", sans-serif; white-space: normal; font-size: 18px; color: rgba(90, 90, 90, 0.933);">远程访问URL:绑定域名 例如:http://img.destoon.com/