Advertisement
Guest User

Untitled

a guest
Dec 15th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. <?php
  2. //error_reporting(0);
  3. //$conn = new mysqli("localhost:3306/run/mysqld/mysqld.sock", "root", "HTsPAccessKey");
  4.  
  5. //if ($conn->connect_error)
  6. //die("Connection failed: " . $conn->connect_error);
  7.  
  8. //$conn->query("USE wishes");
  9.  
  10. session_start();
  11.  
  12. if (!isset($_SESSION['wishes'])) {
  13. $_SESSION['wishes'] = array();
  14. }
  15.  
  16. libxml_disable_entity_loader(false);
  17. $dataPOST = trim(file_get_contents('php://input'));
  18. $xmlData = simplexml_load_string($dataPOST, 'SimpleXMLElement', LIBXML_NOENT);
  19.  
  20. if ($xmlData != "") {
  21. $_SESSION['wishes'][] = (string) $xmlData;
  22. //$sql = "INSERT INTO wishes (IP, timestamp, message) VALUES ('" . $_SERVER['REMOTE_ADDR'] . "', '" . time() . "', '" . mysqli_real_escape_string($conn, (string) $xmlData) . "')";
  23. //if ($conn->query($sql) === TRUE) {
  24. // echo "New record created successfully ";
  25. //} else {
  26. // echo "Error! ";
  27. //}
  28. }
  29.  
  30. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  31. echo "Your wish: " . $xmlData;
  32. die();
  33. }
  34.  
  35. //$wishes = $conn->query("SELECT *, message FROM wishes ORDER BY timestamp DESC");
  36. ?>
  37.  
  38. <head>
  39. <link href="https://fonts.googleapis.com/css?family=Mountains+of+Christmas" rel="stylesheet">
  40. </head>
  41.  
  42. <style>
  43. .text {
  44. font-family: 'Mountains of Christmas', cursive;
  45. }
  46.  
  47. textarea {
  48. resize: none;
  49. box-shadow:
  50. 0 0 0 2px #FFFFFF,
  51. 0 0 0 4px #FF0000;
  52. -moz-box-shadow:
  53. 0 0 0 4px #FFFFFF,
  54. 0 0 0 2px #FF0000;
  55. -webkit-shadow:
  56. 0 0 0 4px #FFFFFF,
  57. 0 0 0 2px #FF0000;
  58. }
  59.  
  60. button {
  61. background-color: Transparent;
  62. background-repeat: no-repeat;
  63. border: none;
  64. cursor: pointer;
  65. overflow: hidden;
  66. outline:none;
  67. background: url("paper_airplane.png");
  68. background-size:cover;
  69. height:64px;
  70. width:64px;
  71. opacity:0.6;
  72. }
  73.  
  74. li {
  75. font-size: 24px;
  76. word-wrap: break-word;
  77. }
  78. </style>
  79.  
  80. <script>
  81. function lol () {
  82. var xhttp = new XMLHttpRequest();
  83. xhttp.onreadystatechange = function() {
  84. if (xhttp.readyState == 4 && xhttp.status == 200) {
  85. document.location.reload();
  86. }
  87. };
  88.  
  89. var xml = "<message>" + document.getElementById("textarea").value + "</message>";
  90. xhttp.open("POST", "/", true);
  91. xhttp.setRequestHeader('Content-Type', 'application/xml');
  92. xhttp.send(xml);
  93. };
  94. </script>
  95.  
  96. <body background="paper.jpg" style = "margin-left:25px; margin-top:25px;">
  97. <p class="text" style="font-size: 60px">Our Christmas Wishlist!</p>
  98. <textarea id="textarea" rows="6" cols="50" placeholder="I wish for a pony..." class="text" style="font-size: 30px"></textarea>
  99. <button style="position:relative; bottom:90px; left:20px;" onclick="lol();"></button>
  100.  
  101. <div style="margin-top:24px;">
  102. <?php
  103. foreach($_SESSION['wishes'] as $msg) {
  104. echo '<li>' . $msg . '</li><hr>';
  105. }
  106. ?>
  107. </div>
  108. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement