爱采购

发产品

  • 发布供应
  • 管理供应
DESTOON-七牛云对象存储DESTOON-七牛云对象存储_destoon教程_PHP 教程_软件编程_教程资讯_大秦朝旭-码农学习站

DESTOON-七牛云对象存储

   2023-10-08 83 0
导读

destoon7.0系统七牛云对象存储1.注意客户购买的空间的存储区域,区域不同对应的上传域名不同destoon 七牛云上传文件 用下面源码替换include/ftp.class.php文件代

destoon7.0系统七牛云对象存储

1.注意客户购买的空间的存储区域,区域不同对应的上传域名不同


destoon  七牛云上传文件   用下面源码替换include/ftp.class.php

文件代码如下:

  1. <?php
  2. defined('IN_DESTOON') or exit('Access Denied');
  3. class dftp {
  4. var $connected = 0;
  5. var $ak;
  6. var $sk;
  7. var $bk;
  8.  
  9. function __construct($ftphost, $ftpuser, $ftppass, $ftpport = 21, $root = '/', $pasv = 0, $ssl = 0) {
  10. $this->connected = 1;
  11. $this->ak = $ftpuser;
  12. $this->sk = $ftppass;
  13. $this->bk = $root;
  14. }
  15.  
  16. function dftp($ftphost, $ftpuser, $ftppass, $ftpport = 21, $root = '/', $pasv = 0, $ssl = 0) {
  17. $this->__construct($ftphost, $ftpuser, $ftppass, $ftpport, $root, $pasv, $ssl);
  18. }
  19.  
  20. function dftp_delete($file) {
  21. $key = $file;
  22. $entry = $this->bk.':'.$key;
  23. $encodedEntryURI = $this->dftp_encode($entry);
  24. $signingStr = "/delete/".$encodedEntryURI."\n";
  25. $sign = hash_hmac('sha1', $signingStr, $this->sk, true);
  26. $encodedSign = $this->dftp_encode($sign);
  27. $accessToken = $this->ak.':'.$encodedSign;
  28. $headers = array();
  29. $headers[] = 'Authorization: QBox '.$accessToken;
  30. $cur = curl_init('http://rs.qiniu.com/delete/'.$encodedEntryURI);
  31. curl_setopt($cur, CURLOPT_POST, 1);
  32. curl_setopt($cur, CURLOPT_POSTFIELDS, '');
  33. curl_setopt($cur, CURLOPT_FOLLOWLOCATION, 1);
  34. curl_setopt($cur, CURLOPT_HEADER, 0);
  35. curl_setopt($cur, CURLOPT_SSL_VERIFYPEER, 0);
  36. curl_setopt($cur, CURLOPT_RETURNTRANSFER, 1);
  37. curl_setopt($cur, CURLOPT_HTTPHEADER, $headers);
  38. $rec = curl_exec($cur);
  39. curl_close($cur);
  40. }
  41.  
  42. function dftp_put($local, $remote = '') {
  43. global $DT_TIME;
  44. $remote or $remote = $local;
  45. $local = DT_ROOT.'/'.$local;
  46. $key = $remote;
  47. $P = array();
  48. $P['scope'] = $this->bk.':'.$key;
  49. $P['deadline'] = $DT_TIME + 3600;
  50. $putPolicy = json_encode($P);
  51. $encodedPutPolicy = $this->dftp_encode($putPolicy);
  52. $sign = hash_hmac('sha1', $encodedPutPolicy, $this->sk, true);
  53. $encodedSign = $this->dftp_encode($sign);
  54. $uploadToken = $this->ak.':'.$encodedSign.':'.$encodedPutPolicy;
  55. $headers = array();
  56. $headers[] = 'Expect: ';
  57. $par = array();
  58. $par['key'] = $key;
  59. $par['token'] = $uploadToken;
  60. #$par['file'] = '@'.$local;
  61. $par['file'] = file_get_contents($local);
  62. $cur = curl_init('http://upload-z2.qiniu.com/');
  63. curl_setopt($cur, CURLOPT_POST, 1);
  64. curl_setopt($cur, CURLOPT_POSTFIELDS, $par);
  65. curl_setopt($cur, CURLOPT_FOLLOWLOCATION, 1);
  66. curl_setopt($cur, CURLOPT_HEADER, 0);
  67. curl_setopt($cur, CURLOPT_SSL_VERIFYPEER, 0);
  68. curl_setopt($cur, CURLOPT_RETURNTRANSFER, 1);
  69. curl_setopt($cur, CURLOPT_HTTPHEADER, $headers);
  70. $rec = curl_exec($cur);
  71. curl_close($cur);
  72. if(strpos($rec, 'key') !== false) {
  73. $arr = json_decode($rec, true);
  74. if($arr['key'] == $key) return true;
  75. }
  76. return false;
  77. }
  78.  
  79. function dftp_chdir() {
  80. if(!function_exists('hash_hmac')) return false;
  81. if(!function_exists('curl_init')) return false;
  82. return true;
  83. }
  84.  
  85. function dftp_encode($str) {
  86. return str_replace(array('+', '/'), array('-', '_'), base64_encode($str));
  87. }
  88. }
  89. ?>

后台设置:

配置细节说明:

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/


 
反对 0举报 0 收藏 0 打赏 0评论 0
免责声明
• 
本文为会员destoon8发布,欢迎转载,转载请注明原文出处:http://52419.net/news/show-38701.html 。本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们。
 
更多>同类destoon教程

入驻

企业入驻成功 可尊享多重特权

入驻热线:17792038992

请手机扫码访问

客服

客服热线:17792038992

小程序

小程序更便捷的查找产品

为您提供专业帮买咨询服务

请用微信扫码

公众号

微信公众号,收获商机

微信扫码关注

顶部