attachment.html 32 KB

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