Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##index.php
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- include 'config.php';
- /* connect to mysql database */
- $db = connect();
- /* catch errors */
- if (mysqli_connect_errno()) {
- die('Konnte keine Verbindung zur Datenbank herstellen<br />MySQL meldete: <font color="red"><b>'.mysqli_connect_error().'</b></font>');
- }
- /* include the header template */
- include 'tmp/header.html';
- /* get news */
- $sql = 'SELECT
- Titel,
- Datum,
- Inhalt
- FROM
- News
- ORDER BY
- Datum DESC';
- $result = $db->query($sql);
- if (!$result) {
- die('Konnte den Query nicht senden: <b><font color="green">'.$sql.'</font></b><br />\nFehlermeldung: <b><font color="red">'.$db->error.'</font></b>');
- }
- if (!$result->num_rows) {
- echo '<p id="info">Es sind keine Newsbeiträge vorhanden.</p>';
- } else {
- while ($row = $result->fetch_assoc()) {
- echo '<h1>'.$row['Titel']."</h1>\n";
- echo '<p id="date">'.$row['Datum']."</p>\n";
- echo '<p>'.$row['Inhalt']."</p>\n";
- }
- }
- /* include the footer template */
- include 'tmp/footer.html';
- ?>
- ##config.php
- <?php
- function connect() {
- $host = "localhost"; // MySQL Host
- $user = "root"; // MySQL User
- $pass = ""; // MySQL Password
- $daba = "simple"; // MySQL Database
- $db = @new MySQLi($host, $user, $pass, $daba);
- return $db;
- }
- ?>
- ##header.html
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>#go4more <3</title>
- <link rel="stylesheet" type="text/css" href="tmp/css.css">
- </head>
- <body>
- <div align="center">
- <div id="hdr">
- <h1><span style="color: #777777;">bl1nk</span>.4bit.ws <span style="color: #ff1402; font-family: 'Lucida Sans Unicode';">♥</span> <span style="color: #777777;">#go4more</span></h1>
- </div>
- <div id="content">
- ##footer.html
- </div>
- </body>
- </html>
- ##css.css
- body {
- background: #f7f7f7;
- padding: 0;
- margin: 0;
- color: #797979;
- font-family: "Droid Sans","Bitstream Vera Sans","DejaVu Sans",sans,sans-serif;
- font-size: 96%;
- border-top: 5px solid #ecc049;
- line-height: 1.4; }
- /* Links */
- a, a:active, a:visited {
- color: #1474ca;
- text-decoration: none;
- background: #dfe9e5;
- padding: 0 5px;
- font-weight: normal; }
- a:hover {
- color: #ffffff;
- background: #ecc049;
- text-decoration: none;
- font-weight: normal; }
- /* header */
- #hdr {
- width: 450px;
- margin: 0 auto 0;
- text-shadow: #FFFFFF 0 1px 0;
- text-align: left; }
- #hdr h1 {
- font-size: 1.6em;
- color: #dddddd;
- padding: 0;
- margin: 0; }
- /* content */
- #content {
- margin: 0 auto 0;
- width: 450px;
- background: #ffffff;
- border: 1px solid #dfe9e5;
- border-bottom: 1px solid #ecc049;
- padding:10px;
- text-align: left; }
- #content p {
- letter-spacing: -1px;
- padding: 3px;
- margin: 0; }
- #content h1 {
- color: #1474ca;
- font-variant: small-caps;
- font-weight: bold;
- font-size: 1.2em;
- letter-spacing: -1/*0.05em*/;
- padding: 0;
- margin: 0;
- text-shadow: #dfe9e5 0 2px 0; }
- #content ul {
- list-style: none;
- padding: 3px;
- margin: 0; }
- #email {
- unicode-bidi: bidi-override;
- direction:rtl; }
- #date {
- color: #666666;
- font-size: .8em;
- font-weight: bold;
- text-align: left; }
- #info {
- background: #ecc049;
- padding: 0.5em ;
- margin: 0;
- color: #ffffff;
- font-weight: bold; }
- #warning {
- background: #FF4B4B;
- padding: 0.5em ;
- margin: 0;
- color: #ffffff;
- font-weight: bold; }
- ##admin.php
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- include 'config.php';
- $db = connect();
- if ($_POST) {
- $title = $_POST['Heading'];
- $text = $_POST['Text'];
- $passwort = "f27aba06ce4ebdbb24d614eea7a20b5c";
- if ($passwort == md5($_POST['Passwort'])) {
- if (empty($title) || empty($text)) {
- echo "<p id=\"info\">Bitte alle Felder ausfüllen!</p>";
- } else {
- $post = 'INSERT INTO news (`ID`, `Titel`, `Datum`, `Inhalt`) VALUES (NULL, "'.$title.'", NOW(), "'.$text.'")';
- $db->query($post);
- unset($title, $text);
- }
- } else {
- echo "<p id=\"warning\">Das Passwort ist falsch!</p>";
- }
- }
- include 'tmp/header.html';
- ?>
- <form action="admin.php" method="post">
- <h1>Heading</h1><input type="text" name="Heading" size="66" value="<?php if (isset($title)) { echo $title; } ?>" />
- <textarea name="Text" cols="50" rows="5"><?php if (isset($text)) { echo $text; } ?></textarea><br />
- <h1>Password</h1><input type="password" name="Passwort" /><input type="submit" name="sub" value="GO4MORE" />
- </form>
Add Comment
Please, Sign In to add comment