Guest User

Untitled

a guest
Jul 12th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. ##index.php
  2. <?php
  3.  
  4. error_reporting(E_ALL);
  5. ini_set('display_errors', 1);
  6.  
  7. include 'config.php';
  8.  
  9. /* connect to mysql database */
  10. $db = connect();
  11.  
  12. /* catch errors */
  13. if (mysqli_connect_errno()) {
  14. die('Konnte keine Verbindung zur Datenbank herstellen<br />MySQL meldete: <font color="red"><b>'.mysqli_connect_error().'</b></font>');
  15. }
  16.  
  17. /* include the header template */
  18. include 'tmp/header.html';
  19.  
  20. /* get news */
  21. $sql = 'SELECT
  22. Titel,
  23. Datum,
  24. Inhalt
  25. FROM
  26. News
  27. ORDER BY
  28. Datum DESC';
  29.  
  30. $result = $db->query($sql);
  31.  
  32. if (!$result) {
  33. die('Konnte den Query nicht senden: <b><font color="green">'.$sql.'</font></b><br />\nFehlermeldung: <b><font color="red">'.$db->error.'</font></b>');
  34. }
  35.  
  36. if (!$result->num_rows) {
  37. echo '<p id="info">Es sind keine Newsbeiträge vorhanden.</p>';
  38. } else {
  39. while ($row = $result->fetch_assoc()) {
  40. echo '<h1>'.$row['Titel']."</h1>\n";
  41. echo '<p id="date">'.$row['Datum']."</p>\n";
  42. echo '<p>'.$row['Inhalt']."</p>\n";
  43. }
  44. }
  45.  
  46. /* include the footer template */
  47. include 'tmp/footer.html';
  48. ?>
  49. ##config.php
  50. <?php
  51. function connect() {
  52. $host = "localhost"; // MySQL Host
  53. $user = "root"; // MySQL User
  54. $pass = ""; // MySQL Password
  55. $daba = "simple"; // MySQL Database
  56.  
  57. $db = @new MySQLi($host, $user, $pass, $daba);
  58.  
  59. return $db;
  60. }
  61. ?>
  62. ##header.html
  63.  
  64. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  65. <html>
  66. <head>
  67. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  68. <title>#go4more <3</title>
  69. <link rel="stylesheet" type="text/css" href="tmp/css.css">
  70. </head>
  71. <body>
  72. <div align="center">
  73.  
  74. <div id="hdr">
  75.  
  76. <h1><span style="color: #777777;">bl1nk</span>.4bit.ws <span style="color: #ff1402; font-family: 'Lucida Sans Unicode';">&hearts;</span> <span style="color: #777777;">#go4more</span></h1>
  77.  
  78. </div>
  79.  
  80. <div id="content">
  81. ##footer.html
  82. </div>
  83. </body>
  84. </html>
  85. ##css.css
  86. body {
  87. background: #f7f7f7;
  88. padding: 0;
  89. margin: 0;
  90. color: #797979;
  91. font-family: "Droid Sans","Bitstream Vera Sans","DejaVu Sans",sans,sans-serif;
  92. font-size: 96%;
  93. border-top: 5px solid #ecc049;
  94. line-height: 1.4; }
  95.  
  96. /* Links */
  97. a, a:active, a:visited {
  98. color: #1474ca;
  99. text-decoration: none;
  100. background: #dfe9e5;
  101. padding: 0 5px;
  102. font-weight: normal; }
  103. a:hover {
  104. color: #ffffff;
  105. background: #ecc049;
  106. text-decoration: none;
  107. font-weight: normal; }
  108.  
  109. /* header */
  110. #hdr {
  111. width: 450px;
  112. margin: 0 auto 0;
  113. text-shadow: #FFFFFF 0 1px 0;
  114. text-align: left; }
  115. #hdr h1 {
  116. font-size: 1.6em;
  117. color: #dddddd;
  118. padding: 0;
  119. margin: 0; }
  120.  
  121. /* content */
  122. #content {
  123. margin: 0 auto 0;
  124. width: 450px;
  125. background: #ffffff;
  126. border: 1px solid #dfe9e5;
  127. border-bottom: 1px solid #ecc049;
  128. padding:10px;
  129. text-align: left; }
  130. #content p {
  131. letter-spacing: -1px;
  132. padding: 3px;
  133. margin: 0; }
  134. #content h1 {
  135. color: #1474ca;
  136. font-variant: small-caps;
  137. font-weight: bold;
  138. font-size: 1.2em;
  139. letter-spacing: -1/*0.05em*/;
  140. padding: 0;
  141. margin: 0;
  142. text-shadow: #dfe9e5 0 2px 0; }
  143. #content ul {
  144. list-style: none;
  145. padding: 3px;
  146. margin: 0; }
  147. #email {
  148. unicode-bidi: bidi-override;
  149. direction:rtl; }
  150.  
  151.  
  152. #date {
  153. color: #666666;
  154. font-size: .8em;
  155. font-weight: bold;
  156. text-align: left; }
  157.  
  158. #info {
  159. background: #ecc049;
  160. padding: 0.5em ;
  161. margin: 0;
  162. color: #ffffff;
  163. font-weight: bold; }
  164.  
  165. #warning {
  166. background: #FF4B4B;
  167. padding: 0.5em ;
  168. margin: 0;
  169. color: #ffffff;
  170. font-weight: bold; }
  171. ##admin.php
  172. <?php
  173.  
  174. error_reporting(E_ALL);
  175. ini_set('display_errors', 1);
  176.  
  177. include 'config.php';
  178. $db = connect();
  179.  
  180. if ($_POST) {
  181. $title = $_POST['Heading'];
  182. $text = $_POST['Text'];
  183. $passwort = "f27aba06ce4ebdbb24d614eea7a20b5c";
  184.  
  185. if ($passwort == md5($_POST['Passwort'])) {
  186. if (empty($title) || empty($text)) {
  187. echo "<p id=\"info\">Bitte alle Felder ausfüllen!</p>";
  188. } else {
  189. $post = 'INSERT INTO news (`ID`, `Titel`, `Datum`, `Inhalt`) VALUES (NULL, "'.$title.'", NOW(), "'.$text.'")';
  190. $db->query($post);
  191. unset($title, $text);
  192. }
  193. } else {
  194. echo "<p id=\"warning\">Das Passwort ist falsch!</p>";
  195. }
  196. }
  197.  
  198. include 'tmp/header.html';
  199. ?>
  200.  
  201. <form action="admin.php" method="post">
  202. <h1>Heading</h1><input type="text" name="Heading" size="66" value="<?php if (isset($title)) { echo $title; } ?>" />
  203. <textarea name="Text" cols="50" rows="5"><?php if (isset($text)) { echo $text; } ?></textarea><br />
  204. <h1>Password</h1><input type="password" name="Passwort" /><input type="submit" name="sub" value="GO4MORE" />
  205. </form>
Add Comment
Please, Sign In to add comment