confession.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. if ($templateMode) {
  3. include('./includes/header.php');
  4. }
  5. ?>
  6. <a target="_blank" style="color:#4F4F4F" href="
  7. <?php
  8. if ($REWRITE) {
  9. echo "/admin";
  10. } else {
  11. echo '/?page=admin';
  12. }
  13. ?>" class="mdui-btn mdui-btn-icon mdui-float-right">
  14. <i class="mdui-icon material-icons">arrow_back</i>
  15. </a>
  16. <div class="mdui-typo">
  17. <h1 class="doc-chapter-title doc-chapter-title-first mdui-text-color-theme">表白管理</h1>
  18. </div>
  19. <br /><br />
  20. <div class="mdui-table-fluid" style="border-radius: 16px">
  21. <table class="mdui-table">
  22. <thead>
  23. <tr>
  24. <th>表白标识符</th>
  25. <th>被点赞的次数</th>
  26. <th>表白人</th>
  27. <th>表白给</th>
  28. <th>时间</th>
  29. <th>可用操作</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. <?php
  34. $flag = true;
  35. try {
  36. $pdo = pdoConnect();
  37. $stmt = $pdo->prepare("select * from loveway_data ORDER BY time ASC");
  38. if ($stmt->execute()) {
  39. while ($row = $stmt->fetch()) {
  40. $flag = false;
  41. if ($REWRITE) {
  42. $pageURL = "/card/" . $row['id'];
  43. } else {
  44. $pageURL = '/?page=card&id=' . $row['id'];
  45. }
  46. ?>
  47. <tr id="id-<?php echo $row['id'] ?>">
  48. <td><?php echo $row['id'] ?></td>
  49. <td><?php echo $row['favorite'] ?></td>
  50. <td><?php echo $row['confessor'] ?></td>
  51. <td><?php echo $row['to_who'] ?></td>
  52. <td><?php echo $row['time'] ?></td>
  53. <td>
  54. <button id="delete-<?php echo $row['id'] ?>" mdui-tooltip="{content: '删除此表白'}" class="mdui-color-theme-accent mdui-btn mdui-btn-icon mdui-text-color-white" onclick="deleteF('<?php echo $row['id'] ?>')"><i class="mdui-icon material-icons">delete</i></button>
  55. <a id="to-<?php echo $row['id'] ?>" mdui-tooltip="{content: '去看看'}" class="mdui-color-theme-accent mdui-btn mdui-btn-icon mdui-text-color-white" href="<?php echo $pageURL ?>" target="_BLANK"><i class="mdui-icon material-icons">keyboard_arrow_right</i></a>
  56. </td>
  57. </tr>
  58. <?php
  59. }
  60. } else {
  61. echo '抱歉!操作数据库时出现了一个致命错误!';
  62. }
  63. } catch (Exception $e) {
  64. echo '抱歉!连接数据库失败!';
  65. }
  66. ?>
  67. </tbody>
  68. </table>
  69. </div>
  70. <script>
  71. function deleteF(id) {
  72. requestApi("delete_confession", {
  73. id: id
  74. }, false, true, true, "")
  75. }
  76. function setCookie(cname, cvalue, exdays) {
  77. var d = new Date();
  78. d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
  79. var expires = "expires=" + d.toUTCString();
  80. document.cookie = cname + "=" + cvalue + "; " + expires;
  81. }
  82. </script>