ssllist.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. include_once('tpl/header.php');
  3. ?>
  4. <div class="layui-container" style = "margin-top:40px;margin-bottom:60px;">
  5. <div class="layui-row">
  6. <div class="layui-col-lg10 layui-col-md-offset1">
  7. <!--提示-->
  8. <div>
  9. <pre class="layui-code">注意:域名不需要加http://,比如直接填写west.cn即可。为了方便区分,建议填写备注。(<span style = "color:red;">若添加证书后未及时显示,请按Ctrl + F5刷新。</span>)</pre>
  10. </div>
  11. <!--提示END-->
  12. <!--选项卡-->
  13. <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  14. <ul class="layui-tab-title">
  15. <li class="layui-this" onclick = "tabf('listssl')">SSL证书列表</li>
  16. <li onclick = "tabf('addssl')">添加SSL证书</li>
  17. </ul>
  18. <div class="layui-tab-content"></div>
  19. </div>
  20. <!--选项卡END-->
  21. <!--证书列表-->
  22. <div id="ssllist">
  23. <table class="layui-table">
  24. <colgroup>
  25. <col width="50%">
  26. <col width="15%">
  27. <col width="20%">
  28. <col width="15%">
  29. </colgroup>
  30. <thead>
  31. <tr>
  32. <th>域名</th>
  33. <th>最后更新</th>
  34. <th>备注</th>
  35. <th>操作</th>
  36. </tr>
  37. </thead>
  38. <tbody id = "listssl">
  39. </tbody>
  40. </table>
  41. </div>
  42. <!--证书END-->
  43. <!--表单-->
  44. <div id="addssl">
  45. <form class="layui-form" action="">
  46. <div class="layui-form-item">
  47. <label class="layui-form-label">域名</label>
  48. <div class="layui-input-block">
  49. <input type="text" id="domain" required lay-verify="required" placeholder="请输证书对应的域名" autocomplete="off" class="layui-input">
  50. </div>
  51. </div>
  52. <div class="layui-form-item layui-form-text">
  53. <label class="layui-form-label">.cer and .crt</label>
  54. <div class="layui-input-block">
  55. <textarea id="crt" placeholder="请将.cer和.crt内容复制到这里,.cer内容在前,.crt内容在后" class="layui-textarea" style = "height:200px;"></textarea>
  56. </div>
  57. </div>
  58. <div class="layui-form-item layui-form-text">
  59. <label class="layui-form-label">.key</label>
  60. <div class="layui-input-block">
  61. <textarea id="key" placeholder="请将.key内容复制到这里" class="layui-textarea" style = "height:200px;"></textarea>
  62. </div>
  63. </div>
  64. <div class="layui-form-item">
  65. <label class="layui-form-label">备注</label>
  66. <div class="layui-input-block">
  67. <input type="text" id="note" placeholder="建议填写" autocomplete="off" class="layui-input">
  68. </div>
  69. </div>
  70. </form>
  71. <div class="layui-form-item">
  72. <div class="layui-input-block">
  73. <button class="layui-btn" lay-filter="formDemo" id = "btn">保存</button>
  74. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  75. </div>
  76. </div>
  77. </div>
  78. <!--表单END-->
  79. </div>
  80. </div>
  81. </div>
  82. <?php
  83. include_once('tpl/footer.php');
  84. ?>
  85. <script>
  86. //Demo
  87. layui.use(['form','element'], function(){
  88. var form = layui.form;
  89. //监听提交
  90. });
  91. $(document).ready(function(){
  92. $("title").empty();
  93. $("title").append("SSL证书列表/添加SSL证书");
  94. $("#btn").click(function(){
  95. var domain = $("#domain").val();
  96. var crt = $("#crt").val();
  97. var key = $("#key").val();
  98. var note = $("#note").val();
  99. $.post("./functions/method.php?type=add_cert",{domain:domain,crt:crt,note:note,key:key},function(data){
  100. layer.open({
  101. title:'温馨提示',
  102. content:data,
  103. time:2000
  104. });
  105. });
  106. });
  107. $.get("./functions/method.php?type=list_ssl",function(data,status){
  108. $("#listssl").append(data);
  109. });
  110. });
  111. //选项卡切换
  112. function tabf(istype) {
  113. if(istype == 'listssl') {
  114. $("#listssl").empty();
  115. $.get("./functions/method.php?type=list_ssl",function(data,status){
  116. $("#listssl").append(data);
  117. });
  118. $("#ssllist").show();
  119. $("#addssl").hide();
  120. }
  121. if(istype == 'addssl') {
  122. $("#addssl").show();
  123. $("#ssllist").hide();
  124. }
  125. }
  126. //删除证书
  127. function delssl(id){
  128. var msg = "确认删除?";
  129. if (confirm(msg)==true){
  130. $.post("./functions/method.php?type=del_ssl",{id:id},function(data,status){
  131. if(data == 'ok') {
  132. $("#ssl"+id).remove();
  133. }
  134. else {
  135. layer.open({
  136. title:'温馨提示',
  137. content:data,
  138. time:2000
  139. });
  140. }
  141. });
  142. }else{
  143. return false;
  144. }
  145. }
  146. </script>