editsite.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. include_once('tpl/header.php');
  3. include_once('functions/medoo.php');
  4. include_once("config.php");
  5. $database = new medoo([
  6. 'database_type' => 'sqlite',
  7. 'database_file' => 'data/nssl.db3']);
  8. $siteid = $_GET['siteid'];
  9. $siteinfo = $database->get("s_site",["domain","sslid","https"],["id" => $siteid]);
  10. //开关按钮状态
  11. if($siteinfo['https'] == 1) {
  12. $isswitch = "checked";
  13. }
  14. if($siteinfo['https'] == 0) {
  15. $isswitch = "";
  16. }
  17. ?>
  18. <div class="layui-container" style = "margin-top:40px;">
  19. <div class="layui-row">
  20. <div class="layui-col-lg10 layui-col-md-offset1">
  21. <!--提示-->
  22. <div>
  23. <pre class="layui-code">请在下方填写需要启用SSL的站点,域名不需要包含http://,如果您的网站调用了http链接,强制HTTPS会导致网站异常。</pre>
  24. </div>
  25. <!--提示END-->
  26. <!--表单-->
  27. <div id="" style = "margin-top:40px;">
  28. <form class="layui-form" action="">
  29. <div class="layui-form-item">
  30. <label class="layui-form-label">域名</label>
  31. <div class="layui-input-block">
  32. <input type="text" id="domain" readonly="readonly" required lay-verify="required" placeholder="输入要启用SSL的域名" autocomplete="off" class="layui-input" value = "<?php echo $siteinfo['domain']; ?>">
  33. </div>
  34. </div>
  35. <div class="layui-form-item">
  36. <label class="layui-form-label">强制HTTPS</label>
  37. <div class="layui-input-block">
  38. <input type="checkbox" name="switch" lay-skin="switch" id = "https" <?php echo $isswitch; ?>>
  39. </div>
  40. </div>
  41. </form>
  42. <div class="layui-form-item">
  43. <div class="layui-input-block">
  44. <button class="layui-btn" lay-filter="formDemo" id = "btn">保存</button>
  45. <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
  46. </div>
  47. </div>
  48. </div>
  49. <!--表单END-->
  50. </div>
  51. </div>
  52. </div>
  53. <?php
  54. include_once('tpl/footer.php');
  55. ?>
  56. <script>
  57. layui.use(['form','element'], function(){
  58. var form = layui.form;
  59. //监听提交
  60. });
  61. $(document).ready(function(){
  62. $("title").empty();
  63. $("title").append("是否强制HTTPS?");
  64. $("#btn").click(function(){
  65. //alert('dsds');
  66. var domain = $("#domain").val();
  67. var siteid = <?php echo $siteid; ?>
  68. //是否强制SSL
  69. if ($("#https").get(0).checked) {
  70. var https = 1;
  71. }
  72. else {
  73. var https = 0;
  74. }
  75. $.post("./functions/method.php?type=update_site",{domain:domain,siteid:siteid,https:https},function(data,status){
  76. layer.open({
  77. title:'温馨提示',
  78. content:data,
  79. time:2000
  80. });
  81. });
  82. });
  83. });
  84. </script>