人人商城

attachment.html 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. {template 'common/header'}
  2. <div class="we7-page-title">附件设置</div>
  3. <ul class="we7-page-tab">
  4. <li {if $do == 'global'}class="active"{/if}><a href="{php echo url('system/attachment/global')}">全局设置</a></li>
  5. <li {if $do == 'remote'}class="active"{/if}><a href="{php echo url('system/attachment/remote')}">远程附件</a></li>
  6. </ul>
  7. {if $do == 'global'}
  8. <div class="alert we7-page-alert">
  9. <p><i class="wi wi-info-sign"></i>全局设置只对上传到服务器的文件有效</p>
  10. </div>
  11. <div class="clearfix">
  12. <form action="" method="post" class="we7-form form" id="form">
  13. {if !empty($upload_max_filesize) && !empty($post_max_size)}
  14. <div class="form-group">
  15. <label class="col-sm-2 control-label">PHP 环境说明</label>
  16. <div class="col-sm-10">
  17. <div class="form-control-static">1. 当前 PHP 环境允许最大单个上传文件大小为: {$upload_max_filesize}</div>
  18. <div class="form-control-static">2. 当前 PHP 环境允许最大 POST 表单大小为: {$post_max_size}</div>
  19. </div>
  20. </div>
  21. {/if}
  22. <h5 class="page-header">附件空间设置</h5>
  23. <div class="form-group">
  24. <label class="col-sm-2 control-label">空间容量</label>
  25. <div class="col-sm-5">
  26. <div class="input-group">
  27. <input name="upload[attachment_limit]" value="{$upload['attachment_limit']}" type="number" class="form-control">
  28. <span class="input-group-addon">M</span>
  29. </div>
  30. <div class="help-block">设置为 0 时不限制空间</div>
  31. </div>
  32. </div>
  33. <h5 class="page-header">附件缩略设置</h5>
  34. <div class="form-group">
  35. <label class="col-sm-2 control-label">缩略设置</label>
  36. <div class="col-sm-10">
  37. <input type="radio" name="upload[image][thumb]" id="radio_image_thumb_0" value="0" {if empty($upload['image']['thumb'])} checked{/if} />
  38. <label for="radio_image_thumb_0" class="radio-inline">
  39. 不启用缩略
  40. </label>
  41. <input type="radio" name="upload[image][thumb]" id="radio_image_thumb_1" value="1" {if !empty($upload['image']['thumb'])} checked{/if} />
  42. <label for="radio_image_thumb_1" class="radio-inline">
  43. 启用缩略
  44. </label>
  45. <div class="help-block"></div>
  46. </div>
  47. </div>
  48. <div class="form-group upload-image-thumb-width-height" {if empty($upload['image']['thumb'])} style="display:none;"{/if}>
  49. <label class="col-sm-2 control-label"></label>
  50. <div class="col-sm-3">
  51. <div class="input-group">
  52. <span class="input-group-addon">宽</span>
  53. <input name="upload[image][width]" value="{$upload['image']['width']}" type="text" class="form-control">
  54. <span class="input-group-addon">px</span>
  55. </div>
  56. <span class="help-block">缩略后图片 <b>最大宽度</b></span>
  57. </div>
  58. </div>
  59. <h5 class="page-header">图片附件设置</h5>
  60. <div class="form-group">
  61. <label class="col-sm-2 control-label">支持文件后缀</label>
  62. <div class="col-sm-5">
  63. <textarea name="upload[image][extentions]" class="form-control" rows="4">{$upload['image']['extentions']}</textarea>
  64. <div class="help-block">填写图片后缀名称, 如: jpg, 换行输入, 一行一个后缀 (如果为空,则采用系统默认设置).</div>
  65. </div>
  66. </div>
  67. <div class="form-group">
  68. <label class="col-sm-2 control-label">支持文件大小</label>
  69. <div class="col-sm-5">
  70. <div class="input-group">
  71. <input name="upload[image][limit]" value="{$upload['image']['limit']}" type="text" class="form-control">
  72. <span class="input-group-addon">KB</span>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="form-group">
  77. <label class="col-sm-2 control-label">图片压缩</label>
  78. <div class="col-sm-5">
  79. <div class="input-group">
  80. <input name="upload[image][zip_percentage]" value="{$upload['image']['zip_percentage']}" type="number" step="1" min="10"
  81. max="100" class="form-control" placeholder="请输入原图的压缩比(100%表示不压缩)">
  82. <span class="input-group-addon">%</span>
  83. </div>
  84. <div class="help-block">100不压缩 值越大越清晰</div>
  85. </div>
  86. </div>
  87. <h5 class="page-header">音频视频附件设置</h5>
  88. <div class="form-group">
  89. <label class="col-sm-2 control-label">支持文件后缀</label>
  90. <div class="col-sm-5">
  91. <textarea name="upload[audio][extentions]" class="form-control" rows="4">{$upload['audio']['extentions']}</textarea>
  92. <div class="help-block">填写音频视频后缀名称, 如: mp3, 换行输入, 一行一个后缀 (如果为空,则采用系统默认设置).</div>
  93. </div>
  94. </div>
  95. <div class="form-group">
  96. <label class="col-sm-2 control-label">支持文件大小</label>
  97. <div class="col-sm-5">
  98. <div class="input-group">
  99. <input name="upload[audio][limit]" value="{$upload['audio']['limit']}" type="text" class="form-control">
  100. <span class="input-group-addon">KB</span>
  101. </div>
  102. </div>
  103. </div>
  104. <div class="form-group">
  105. <div class="col-sm-offset-2 col-md-offset-2 col-lg-offset-2 col-sm-10 col-md-10 col-lg-10">
  106. <input name="submit" type="submit" value="提交" class="btn btn-primary span3" />
  107. <input type="hidden" name="token" value="{$_W['token']}" />
  108. </div>
  109. </div>
  110. <script type="text/javascript">
  111. $(function(){
  112. $('input[name="upload[image][thumb]"]').click(function(){
  113. if($(this).val() == 1){
  114. $('.upload-image-thumb-width-height').css('display', '');
  115. } else {
  116. $('.upload-image-thumb-width-height').css('display', 'none');
  117. }
  118. });
  119. });
  120. </script>
  121. </form>
  122. </div>
  123. {elseif $do == 'remote'}
  124. <form action="" method="post" class="we7-form form" id="form">
  125. <div class="form-group">
  126. <div class="col-sm-12">
  127. <input type="radio" name="type" id="type-0" value="0" onclick="$('.remote-qiniu').hide();$('.remote-alioss').hide();$('.remote-ftp').hide();$('.remote-close').show();$('.remote-cos').hide();" {if empty($remote['type']) || $remote['type'] == '0'} checked="checked" {/if}>
  128. <label class="radio-inline" for="type-0">
  129. 关闭
  130. </label>
  131. <input type="radio" name="type" id="type-1" value="1" onclick="$('.remote-qiniu').hide();$('.remote-ftp').show();$('.remote-alioss').hide();$('.remote-close').hide();$('.remote-cos').hide();" {if !empty($remote['type']) && $remote['type'] == '1'} checked="checked" {/if}>
  132. <label class="radio-inline" for="type-1">
  133. FTP服务器
  134. </label>
  135. <input type="radio" name="type" id="type-2" value="2" onclick="$('.remote-qiniu').hide();$('.remote-alioss').show();$('.remote-ftp').hide();$('.remote-close').hide();$('.remote-cos').hide();" {if !empty($remote['type']) && $remote['type'] == '2'} checked="checked" {/if}>
  136. <label class="radio-inline" for="type-2">
  137. 阿里云OSS <span class="label label-success">推荐,快速稳定</span>
  138. </label>
  139. <input type="radio" name="type" id="type-3" value="3" onclick="$('.remote-qiniu').show();$('.remote-alioss').hide();$('.remote-ftp').hide();$('.remote-close').hide();$('.remote-cos').hide();" {if !empty($remote['type']) && $remote['type'] == '3'} checked="checked" {/if}>
  140. <label class="radio-inline" for="type-3">
  141. 七牛云存储 <span class="label label-success">推荐,快速稳定</span>
  142. </label>
  143. <input type="radio" name="type" id="type-4" value="4" onclick="$('.remote-qiniu').hide();$('.remote-alioss').hide();$('.remote-ftp').hide();$('.remote-close').hide();$('.remote-cos').show();" {if !empty($remote['type']) && $remote['type'] == '4'} checked="checked" {/if}>
  144. <label class="radio-inline" for="type-4">
  145. 腾讯云存储 <span class="label label-success">推荐,快速稳定</span>
  146. </label>
  147. <span class="help-block"></span>
  148. </div>
  149. </div>
  150. <div class="remote-ftp" {if empty($remote['type']) || $remote['type'] != '1'} style="display:none;" {/if}>
  151. <div class="form-group">
  152. <label class="col-sm-2 control-label">启用SSL连接</label>
  153. <div class="col-sm-9">
  154. <input type="radio" id="ftp[ssl]-1" name="ftp[ssl]" value="1" {if !empty($remote['ftp']['ssl'])} checked="checked" {/if}>
  155. <label class="radio-inline" for="ftp[ssl]-1">
  156. </label>
  157. <input type="radio" id="ftp[ssl]-0" name="ftp[ssl]" value="0" {if empty($remote['ftp']['ssl'])} checked="checked" {/if}>
  158. <label class="radio-inline" for="ftp[ssl]-0">
  159. </label>
  160. <span class="help-block">注意:选择是后,FTP 服务器必须开启了 SSL,一般情况选择否即可</span>
  161. </div>
  162. </div>
  163. <div class="form-group">
  164. <label class="col-sm-2 control-label">FTP服务器地址</label>
  165. <div class="col-sm-9">
  166. <input type="text" name="ftp[host]" class="form-control" value="{$remote['ftp']['host']}" />
  167. <span class="help-block">可以是 FTP 服务器的 IP 地址或域名</span>
  168. </div>
  169. </div>
  170. <div class="form-group">
  171. <label class="col-sm-2 control-label">FTP服务器端口</label>
  172. <div class="col-sm-9">
  173. <input type="text" name="ftp[port]" class="form-control" value="{if empty($remote['ftp']['port'])}21{else}{$remote['ftp']['port']}{/if}" />
  174. <span class="help-block">默认为21</span>
  175. </div>
  176. </div>
  177. <div class="form-group">
  178. <label class="col-sm-2 control-label">FTP帐号</label>
  179. <div class="col-sm-9">
  180. <input type="text" name="ftp[username]" class="form-control" value="{$remote['ftp']['username']}" />
  181. <span class="help-block">该帐号必须具有以下权限:读取文件、写入文件、删除文件、创建目录、子目录继承</span>
  182. </div>
  183. </div>
  184. <div class="form-group">
  185. <label class="col-sm-2 control-label">FTP密码</label>
  186. <div class="col-sm-9">
  187. <input type="text" name="ftp[password]" class="form-control encrypt" value="{$remote['ftp']['password']}" />
  188. <span class="help-block">基于安全考虑将只显示 FTP 密码的第一位和最后一位,中间显示八个 * 号</span>
  189. </div>
  190. </div>
  191. <div class="form-group">
  192. <label class="col-sm-2 control-label">被动模式(pasv)连接:</label>
  193. <div class="col-sm-9">
  194. <label class="radio-inline">
  195. <input type="radio" name="ftp[pasv]" value="1" {if !empty($remote['ftp']['pasv'])} checked="checked" {/if}> 是
  196. </label>
  197. <label class="radio-inline">
  198. <input type="radio" name="ftp[pasv]" value="0" {if empty($remote['ftp']['pasv'])} checked="checked" {/if}> 否
  199. </label>
  200. <span class="help-block">一般情况下非被动模式即可,如果存在上传失败问题,可尝试打开此设置</span>
  201. </div>
  202. </div>
  203. <div class="form-group">
  204. <label class="col-sm-2 control-label">远程附件目录</label>
  205. <div class="col-sm-9">
  206. <input type="text" name="ftp[dir]" class="form-control" value="{$remote['ftp']['dir']}" />
  207. <span class="help-block">远程附件目录的绝对路径或相对于 FTP 主目录的相对路径,结尾不要加斜杠 "/" , 例如:/attachment</span>
  208. </div>
  209. </div>
  210. <div class="form-group">
  211. <label class="col-sm-2 control-label">远程访问URL</label>
  212. <div class="col-sm-9">
  213. <input type="text" name="ftp[url]" class="form-control" value="{$remote['ftp']['url']}" />
  214. <span class="help-block">支持 HTTP 和 FTP 协议,结尾不要加斜杠 "/" ; 例如:http://mydomin.com/attachment 如果使用 FTP 协议,FTP 服务器必须支持 PASV 模式,为了安全起见,
  215. 使用 FTP 连接的帐号不要设置可写权限和列表权限</span>
  216. </div>
  217. </div>
  218. <div class="form-group">
  219. <label class="col-sm-2 control-label">FTP传输超时时间</label>
  220. <div class="col-sm-9">
  221. <input type="text" name="ftp[overtime]" class="form-control" value="{if empty($remote['ftp']['overtime'])}0{else}{$remote['ftp']['overtime']}{/if}" />
  222. <span class="help-block">单位:秒,0为服务器默认</span>
  223. </div>
  224. </div>
  225. <div class="form-group">
  226. <div class="">
  227. <button name="submit" class="btn btn-primary" value="submit">保存配置</button>
  228. <button name="button" type="button" class="btn btn-info js-checkremoteftp" value="check">测试配置(无需保存)</button>
  229. {if !empty($_W['setting']['remote_complete_info']['type']) && !empty($local_attachment)}
  230. <a name="button" class="btn btn-info one-key" href="javascript:;">一键上传</a>
  231. {/if}
  232. <input type="hidden" name="token" value="{$_W['token']}" />
  233. </div>
  234. </div>
  235. </div>
  236. <div class="remote-alioss" {if empty($remote['type']) || $remote['type'] != '2'} style="display:none;" {/if}>
  237. <div class="alert alert-info">
  238. 启用阿里oss后,请把/attachment目录(不包括此目录)下的子文件及子目录上传至阿里云oss, 相关工具:<br>
  239. <ul class="link-list">
  240. <li><a target="_blank" href="http://market.aliyun.com/products/52738003/cmgj000304.html?spm=5176.383663.9.21.faitxp" class="product-grey-font" data-spm-anchor-id="5176.383663.9.21">cloudfs4oss(ECS挂载文件盘工具)</a></li>
  241. <li><a target="_blank" href="http://market.aliyun.com/products/53690006/cmgj000281.html?spm=5176.383663.9.22.faitxp" class="product-grey-font" data-spm-anchor-id="5176.383663.9.22">官方推荐OSS客户端工具(Windows版)</a></li>
  242. <li><a target="_blank" href="http://market.aliyun.com/products/53690006/cmgj000282.html?spm=5176.383663.9.23.faitxp" class="product-grey-font" data-spm-anchor-id="5176.383663.9.23">官方推荐OSS客户端工具(Mac版)</a></li>
  243. <li><a target="_blank" href="http://market.aliyun.com/products/53690006/cmgj000208.html?spm=5176.383663.9.24.faitxp" class="product-grey-font" data-spm-anchor-id="5176.383663.9.24">Ftp4ossServer(OSS的FTP云工具)</a></li>
  244. <li><a target="_blank" href="http://bbs.aliyun.com/read/239565.html?spm=5176.383663.9.25.faitxp&amp;pos=2" class="product-grey-font" data-spm-anchor-id="5176.383663.9.25">OSS图片服务Demo工具</a></li>
  245. <li><a target="_blank" href="http://docs.aliyun.com/?spm=5176.383663.9.26.faitxp#/pub/oss/utilities/osscmd&amp;install" class="product-grey-font" data-spm-anchor-id="5176.383663.9.26">批量上传工具(Python)版</a></li>
  246. <li><a target="_blank" href="https://docs.aliyun.com/?spm=5176.383663.9.27.faitxp#/pub/oss/utilities/oss-import&amp;index" class="product-grey-font" data-spm-anchor-id="5176.383663.9.27">OSS数据迁移工具-OSS Import</a></li>
  247. <li><a target="_blank" href="http://market.aliyun.com/products/52738004/cmfw000394.html?spm=5176.383663.9.28.faitxp" class="product-grey-font" data-spm-anchor-id="5176.383663.9.28">海量数据迁移至OSS服务</a></li>
  248. <li><a target="_blank" href="http://bbs.aliyun.com/read/247023.html?spm=5176.383663.9.29.faitxp" class="product-grey-font" data-spm-anchor-id="5176.383663.9.29">更多官方推荐工具</a></li>
  249. </ul>
  250. </div>
  251. <div class="form-group">
  252. <label class="col-sm-2 control-label">Access Key ID</label>
  253. <div class="col-sm-9">
  254. <input type="text" name="alioss[key]" class="form-control" value="{$remote['alioss']['key']}" placeholder="" />
  255. <span class="help-block">
  256. Access Key ID是您访问阿里云API的密钥,具有该账户完全的权限,请您妥善保管。
  257. </span>
  258. </div>
  259. </div>
  260. <div class="form-group">
  261. <label class="col-sm-2 control-label">Access Key Secret</label>
  262. <div class="col-sm-9">
  263. <input type="text" name="alioss[secret]" class="form-control encrypt" value="{$remote['alioss']['secret']}" placeholder="" />
  264. <span class="help-block">
  265. Access Key Secret是您访问阿里云API的密钥,具有该账户完全的权限,请您妥善保管。(填写完Access Key ID 和 Access Key Secret 后请选择bucket)
  266. </span>
  267. </div>
  268. </div>
  269. <div class="form-group">
  270. <label class="col-sm-2 control-label">内网上传</label>
  271. <div class="col-sm-9">
  272. <input type="radio" name="alioss[internal]" id="type-12" value="1" {if $remote['alioss']['internal'] == 1}checked{/if}>
  273. <label class="radio-inline" for="type-12">
  274. </label>
  275. <input type="radio" name="alioss[internal]" id="type-13" value="0" {if $remote['alioss']['internal'] != 1}checked{/if}>
  276. <label class="radio-inline" for="type-13">
  277. </label>
  278. <span class="help-block">
  279. 如果此站点使用的是阿里云ecs服务器,并且服务器与bucket在同一地区(如:同在华北一区),您可以选择通过内网上传的方式上传附件,以加快上传速度、节省带宽。
  280. </span>
  281. </div>
  282. </div>
  283. <div class="form-group" id="bucket" {if empty($remote['alioss']['key'])}style="display: none;{/if}">
  284. <label class="col-sm-2 control-label">Bucket选择</label>
  285. <div class="col-sm-9">
  286. <select name="alioss[bucket]" class="form-control">
  287. </select>
  288. <span class="help-block">
  289. 完善Access Key ID和Access Key Secret资料后可以选择存在的Bucket(请保证bucket为可公共读取的),否则请手动输入。
  290. </span>
  291. </div>
  292. </div>
  293. <div class="form-group">
  294. <label class="col-sm-2 control-label">自定义URL</label>
  295. <div class="col-sm-9">
  296. <input type="text" name="custom[url]" class="form-control" {if !strexists($remote['alioss']['url'],'aliyuncs.com') && $remote['type'] == 2}value="{$remote['alioss']['url']}"{/if} placeholder="默认URL不需要填写"/>
  297. <span class="help-block">
  298. 阿里云oss支持用户自定义访问域名,如果自定义了URL则用自定义的URL,如果未自定义,则用系统生成出来的URL。注:自定义url开头加http://或https://结尾不加 ‘/’例:http://abc.com
  299. </span>
  300. </div>
  301. </div>
  302. <div class="form-group">
  303. <div class="">
  304. <button name="submit" class="btn btn-primary" value="submit">保存配置</button>
  305. <button name="button" type="button" class="btn btn-info js-checkremoteoss" value="check">测试配置(无需保存)</button>
  306. {if !empty($_W['setting']['remote_complete_info']['type']) && !empty($local_attachment)}
  307. <a name="button" class="btn btn-info one-key" href="javascript:;">一键上传</a>
  308. {/if}
  309. <input type="hidden" name="token" value="{$_W['token']}" />
  310. </div>
  311. </div>
  312. </div>
  313. <div class="remote-qiniu" {if empty($remote['type']) || $remote['type'] != '3'} style="display:none;" {/if}>
  314. <div class="alert alert-info">
  315. 启用七牛云存储后,请把/attachment目录(不包括此目录)下的子文件及子目录上传至七牛云存储, 相关工具:<br>
  316. <ul class="link-list">
  317. <li><a target="_blank" href="https://portal.qiniu.com/signin" class="product-grey-font" >七牛云存储</a></li>
  318. </ul>
  319. </div>
  320. <div class="form-group">
  321. <label class="col-sm-2 control-label">Accesskey</label>
  322. <div class="col-sm-9">
  323. <input type="text" name="qiniu[accesskey]" class="form-control" value="{$remote['qiniu']['accesskey']}" placeholder="" />
  324. <span class="help-block">用于签名的公钥</span>
  325. </div>
  326. </div>
  327. <div class="form-group">
  328. <label class="col-sm-2 control-label">Secretkey</label>
  329. <div class="col-sm-9">
  330. <input type="text" name="qiniu[secretkey]" class="form-control encrypt" value="{$remote['qiniu']['secretkey']}" placeholder="" />
  331. <span class="help-block">用于签名的私钥</span>
  332. </div>
  333. </div>
  334. <div class="form-group" id="qiniubucket">
  335. <label class="col-sm-2 control-label">Bucket</label>
  336. <div class="col-sm-9">
  337. <input type="text" name="qiniu[bucket]" class="form-control" value="{$remote['qiniu']['bucket']}" placeholder="" />
  338. <span class="help-block">请保证bucket为可公共读取的</span>
  339. </div>
  340. </div>
  341. <div class="form-group">
  342. <label class="col-sm-2 control-label">Url</label>
  343. <div class="col-sm-9">
  344. <input type="text" name="qiniu[url]" class="form-control" value="{$remote['qiniu']['url']}" placeholder="" />
  345. <span class="help-block">七牛支持用户自定义访问域名。注:url开头加http://或https://结尾不加 ‘/’例:http://abc.com</span>
  346. </div>
  347. </div>
  348. <div class="form-group">
  349. <div class="">
  350. <button name="submit" class="btn btn-primary" value="submit">保存配置</button>
  351. <button name="button" type="button" class="btn btn-info js-checkremoteqiniu" value="check">测试配置(无需保存)</button>
  352. {if !empty($_W['setting']['remote_complete_info']['type']) && !empty($local_attachment)}
  353. <a name="button" class="btn btn-info one-key" href="javascript:;">一键上传</a>
  354. {/if}
  355. <input type="hidden" name="token" value="{$_W['token']}" />
  356. </div>
  357. </div>
  358. </div>
  359. <div class="remote-cos" {if empty($remote['type']) || $remote['type'] != '4'} style="display:none;" {/if}>
  360. <div class="alert alert-info">
  361. 启用腾讯云cos对象存储后,请把/attachment目录(不包括此目录)下的子文件及子目录上传至腾讯云存储, 相关工具:<br>
  362. <ul class="link-list">
  363. <li><a target="_blank" href="https://console.qcloud.com/cos/bucket" class="product-grey-font" >腾讯云存储</a></li>
  364. </ul>
  365. </div>
  366. <div class="form-group">
  367. <label class="col-sm-2 control-label">APPID</label>
  368. <div class="col-sm-9">
  369. <input type="text" name="cos[appid]" class="form-control" value="{$remote['cos']['appid']}" placeholder="" />
  370. <span class="help-block">APPID 是您项目的唯一ID</span>
  371. </div>
  372. </div>
  373. <div class="form-group">
  374. <label class="col-sm-2 control-label">SecretID</label>
  375. <div class="col-sm-9">
  376. <input type="text" name="cos[secretid]" class="form-control" value="{$remote['cos']['secretid']}" placeholder="" />
  377. <span class="help-block">SecretID 是您项目的安全秘钥,具有该账户完全的权限,请妥善保管</span>
  378. </div>
  379. </div>
  380. <div class="form-group">
  381. <label class="col-sm-2 control-label">SecretKEY</label>
  382. <div class="col-sm-9">
  383. <input type="text" name="cos[secretkey]" class="form-control encrypt" value="{$remote['cos']['secretkey']}" placeholder="" />
  384. <span class="help-block">SecretKEY 是您项目的安全秘钥,具有该账户完全的权限,请妥善保管</span>
  385. </div>
  386. </div>
  387. <div class="form-group" id="cosbucket">
  388. <label class="col-sm-2 control-label">Bucket</label>
  389. <div class="col-sm-9">
  390. <input type="text" name="cos[bucket]" class="form-control" value="{$remote['cos']['bucket']}" placeholder="" />
  391. <span class="help-block">请保证bucket为可公共读取的</span>
  392. </div>
  393. </div>
  394. <div class="form-group" id="cos_local">
  395. <label class="col-xs-12 col-sm-3 col-md-2 control-label">bucket所在区域</label>
  396. <div class="col-sm-9 col-xs-12">
  397. <select class="form-control" name="cos[local]">
  398. <option value="" {if $remote['cos']['local'] == ''}selected{/if}>无</option>
  399. <option value="tj" {if $remote['cos']['local'] == 'tj'}selected{/if}>华北</option>
  400. <option value="sh" {if $remote['cos']['local'] == 'sh'}selected{/if}>华东</option>
  401. <option value="gz" {if $remote['cos']['local'] == 'gz'}selected{/if}>华南</option>
  402. <option value="cd" {if $remote['cos']['local'] == 'cd'}selected{/if}>西南</option>
  403. <option value="bj" {if $remote['cos']['local'] == 'bj'}selected{/if}>北京</option>
  404. <option value="sgp" {if $remote['cos']['local'] == 'sgp'}selected{/if}>新加坡</option>
  405. <option value="hk" {if $remote['cos']['local'] == 'hk'}selected{/if}>香港</option>
  406. <option value="ca" {if $remote['cos']['local'] == 'ca'}selected{/if}>多伦多</option>
  407. <option value="ger" {if $remote['cos']['local'] == 'ger'}selected{/if}>法兰克福</option>
  408. </select>
  409. <span class="help-block">选择bucket对应的区域,如果没有选择无</span>
  410. </div>
  411. </div>
  412. <div class="form-group" >
  413. <label class="col-sm-2 control-label">Url</label>
  414. <div class="col-sm-9">
  415. <input type="text" name="cos[url]" class="form-control" value="{$remote['cos']['url']}" placeholder="" />
  416. <span class="help-block">腾讯云支持用户自定义访问域名。注:url开头加http://或https://结尾不加 ‘/’例:http://abc.com</span>
  417. </div>
  418. </div>
  419. <div class="form-group">
  420. <div class="">
  421. <button name="submit" class="btn btn-primary" value="submit">保存配置</button>
  422. <button name="button" type="button" class="btn btn-info js-checkremotecos" value="check">测试配置(无需保存)</button>
  423. {if !empty($_W['setting']['remote_complete_info']['type']) && !empty($local_attachment)}
  424. <a name="button" class="btn btn-info one-key" href="javascript:;">一键上传</a>
  425. {/if}
  426. <input type="hidden" name="token" value="{$_W['token']}" />
  427. </div>
  428. </div>
  429. </div>
  430. <div class="remote-close" {if !empty($remote['type'])} style="display:none;" {/if}>
  431. <div class="form-group">
  432. <div class="">
  433. <button name="submit" class="btn btn-primary" value="submit">保存配置</button>
  434. <input type="hidden" name="token" value="{$_W['token']}" />
  435. </div>
  436. </div>
  437. </div>
  438. <div class="modal fade" id="name" tabindex="-1" role="dialog" aria-hidden="true">
  439. <div class="we7-modal-dialog modal-dialog we7-form">
  440. <div class="modal-content">
  441. <div class="modal-header">
  442. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  443. <div class="modal-title">上传文件</div>
  444. </div>
  445. <div class="modal-body">
  446. 正在上传....
  447. </div>
  448. </div>
  449. </div>
  450. </div>
  451. </form>
  452. <script type="text/javascript">
  453. $(function() {
  454. $('.encrypt').val(function() {
  455. return util.encrypt($(this).val());
  456. });
  457. });
  458. $('.js-checkremoteftp').on('click', function(){
  459. var ssl = parseInt($(':radio[name="ftp[ssl]"]:checked').val());
  460. var pasv = parseInt($(':radio[name="ftp[pasv]"]:checked').val());
  461. var param = {
  462. 'ssl' : ssl,
  463. 'host' : $.trim($(':text[name="ftp[host]"]').val()),
  464. 'username' : $.trim($(':text[name="ftp[username]"]').val()),
  465. 'password' : $.trim($(':text[name="ftp[password]"]').val()),
  466. 'pasv' : pasv,
  467. 'dir': $.trim($(':text[name="ftp[dir]"]').val()),
  468. 'url': $.trim($(':text[name="ftp[url]"]').val()),
  469. 'port' : parseInt($(':text[name="ftp[port]"]').val()),
  470. 'overtime' : parseInt($(':text[name="ftp[overtime]"]').val())
  471. };
  472. $.post("{php echo url('system/attachment/ftp')}", param, function(data){
  473. var data = $.parseJSON(data);
  474. if(data.message.errno == 0) {
  475. util.message(data.message.message);
  476. return false;
  477. }
  478. if(data.message.errno < 0) {
  479. util.message(data.message.message);
  480. return false;
  481. }
  482. });
  483. });
  484. $('.one-key').click(function() {
  485. upload_remote();
  486. return false;
  487. });
  488. var upload_remote = function() {
  489. $('#name').modal('show');
  490. $.post("{php echo url('system/attachment/upload_remote')}", {}, function(data) {
  491. var data = $.parseJSON(data);
  492. if (data.message.errno == 2) {
  493. upload_remote();
  494. }
  495. if (data.message.errno == 0) {
  496. util.message('上传完毕', location.reload(), 'success');
  497. }
  498. if (data.message.errno == 1) {
  499. util.message(data.message.message, '', 'success');
  500. }
  501. });
  502. }
  503. $('.js-checkremoteoss').on('click', function(){
  504. var bucket = $.trim($('select[name="alioss[bucket]"]').val());
  505. if (bucket == '') {
  506. bucket = $.trim($(':text[name="alioss[bucket]"]').val());
  507. }
  508. var param = {
  509. 'key' : $.trim($(':text[name="alioss[key]"]').val()),
  510. 'secret' : $.trim($(':text[name="alioss[secret]"]').val()),
  511. 'url' : $.trim($(':text[name="custom[url]"]').val()),
  512. 'bucket' : bucket,
  513. 'internal' : $('[name="alioss[internal]"]:checked').val()
  514. };
  515. $.post("{php echo url('system/attachment/oss')}", param, function(data) {
  516. var data = $.parseJSON(data);
  517. if(data.message.errno == 0) {
  518. util.message('配置成功');
  519. return false;
  520. }
  521. if(data.message.errno < 0) {
  522. util.message(data.message.message);
  523. return false;
  524. }
  525. });
  526. });
  527. $('.js-checkremoteqiniu').on('click', function(){
  528. var key = $.trim($(':text[name="qiniu[accesskey]"]').val());
  529. if (key == '') {
  530. util.message('请填写Accesskey');
  531. return false;
  532. }
  533. var secret = $.trim($(':text[name="qiniu[secretkey]"]').val());
  534. if (secret == '') {
  535. util.message('请填写Secretkey');
  536. return false;
  537. }
  538. var param = {
  539. 'accesskey' : $.trim($(':text[name="qiniu[accesskey]"]').val()),
  540. 'secretkey' : $.trim($(':text[name="qiniu[secretkey]"]').val()),
  541. 'url' : $.trim($(':text[name="qiniu[url]"]').val()),
  542. 'bucket' : $.trim($(':text[name="qiniu[bucket]"]').val())
  543. };
  544. $.post("{php echo url('system/attachment/qiniu')}",param, function(data) {
  545. var data = $.parseJSON(data);
  546. if(data.message.errno == 0) {
  547. util.message('配置成功');
  548. return false;
  549. }
  550. if(data.message.errno < 0) {
  551. util.message(data.message.message);
  552. return false;
  553. }
  554. });
  555. });
  556. $('.js-checkremotecos').on('click', function(){
  557. var appid = $.trim($(':text[name="cos[appid]"]').val());
  558. if (appid == '') {
  559. util.message('请填写APPID');
  560. return false;
  561. }
  562. var secretid = $.trim($(':text[name="cos[secretid]"]').val());
  563. if (secretid == '') {
  564. util.message('请填写secretid');
  565. return false;
  566. }
  567. var secretkey = $.trim($(':text[name="cos[secretkey]"]').val());
  568. if (secretkey == '') {
  569. util.message('请填写Secretkey');
  570. return false;
  571. }
  572. var bucket = $.trim($(':text[name="cos[bucket]"]').val());
  573. if (bucket == '') {
  574. util.message('请填写bucket');
  575. return false;
  576. }
  577. var url = $.trim($(':text[name="cos[url]"]').val());
  578. var local = $('[name="cos[local]"]').val();
  579. var param = {
  580. 'appid' : appid,
  581. 'secretid' : secretid,
  582. 'secretkey' : secretkey,
  583. 'bucket' : bucket,
  584. 'url' : url,
  585. 'local' : local
  586. };
  587. $.post("{php echo url('system/attachment/cos')}",param, function(data) {
  588. var data = $.parseJSON(data);
  589. if(data.message.errno == 0) {
  590. util.message('配置成功');
  591. return false;
  592. }
  593. if(data.message.errno < 0) {
  594. util.message(data.message.message);
  595. return false;
  596. }
  597. });
  598. });
  599. var alibucket = '{$_W['setting']['remote']['alioss']['bucket']}';
  600. var buck = function() {
  601. var key = $(':text[name="alioss[key]"]').val();
  602. var secret = $(':text[name="alioss[secret]"]').val();
  603. if (secret.indexOf('*') > 0) {
  604. secret = '{$_W['setting']['remote']['alioss']['secret']}';
  605. }
  606. if (key == '' || secret == '') {
  607. $('#bucket').hide();
  608. return false;
  609. }
  610. $.post("{php echo url('system/attachment/buckets')}", {'key' : key, 'secret' : secret}, function(data) {
  611. try {
  612. var data = $.parseJSON(data);
  613. } catch (error) {
  614. util.message('Access Key ID 或 Access Key Secret 填写错误,请重新填写。', '', 'error');
  615. $('#bucket').hide();
  616. $('select[name="alioss[bucket]"]').val('');
  617. return false;
  618. }
  619. if (data.message.errno < 0 ) {
  620. return false;
  621. } else {
  622. $('#bucket').show();
  623. var bucket = $('select[name="alioss[bucket]"]');
  624. bucket.empty();
  625. var buckets = eval(data.message.message);
  626. for (var i in buckets) {
  627. var selected = alibucket == buckets[i]['name'] || alibucket == buckets[i]['name'] + '@@' + buckets[i]['location'] ? 'selected' : '';
  628. bucket.append('<option value="' + buckets[i]['name'] + '@@' + buckets[i]['location'] + '"' + selected + '>'+buckets[i]['loca_name'] + '</option>');
  629. }
  630. }
  631. });
  632. };
  633. buck();
  634. $(':text[name="alioss[secret]"]').blur(function() {buck();});
  635. $('form').submit(function() {
  636. if ($('[name="type"]:checked').val() == 2 && ($('select[name="alioss[bucket]"]').val() == null || $('select[name="alioss[bucket]"]').val() == '')) {
  637. util.message('请完善信息后再保存设置!');
  638. return false;
  639. }
  640. });
  641. </script>
  642. {/if}
  643. {template 'common/footer'}