logo

blog

My little blog can’t be this cute! git clone https://hacktivis.me/git/blog.git
commit: e1dd5388adaed6d0e6beadd72c91a69091804fe0
parent 1f437239e9bf07c9901b74055f30d83043993098
Author: lanodan <lanodan.delta@free.fr>
Date:   Sun, 20 Apr 2014 20:56:21 +0200

Correct RSS feed, add posts view and page

Diffstat:

Mcss/basic.css6++++++
Dcss/index.css0
Mindex.php10+++++-----
Apost.php43+++++++++++++++++++++++++++++++++++++++++++
Mrss.php42+++++++++++++-----------------------------
5 files changed, 67 insertions(+), 34 deletions(-)

diff --git a/css/basic.css b/css/basic.css @@ -12,6 +12,12 @@ a { text-decoration: none; } a:hover {text-decoration: underline;} +article { + box-shadow: 0px 0px 10px 0px; + padding: 10px; + margin: 10px; + border-radius: 10px; +} code { background-color: #222222; color: #C4C4C4; diff --git a/css/index.css b/css/index.css diff --git a/index.php b/index.php @@ -28,11 +28,11 @@ <?php /* fetch associative array */ $row = mysqli_fetch_array($result, MYSQLI_ASSOC); - print ' <article>'."\n"; - //print ' <a href="'.$row['permalink'].'"><h1>'.$row['title'].'</h1></a>'."\n"; - print ' <p>'.$row['content'].'</p>'."\n"; - print ' <div class="tags">'.$row['tags'].'</div>'."\n"; - print ' </article>'."\n"; + print ' <article> + <a href="post?id='.$row['id'].'"><h1>'.$row['title'].'</h1></a> + <p>'.$row['content'].'</p> + <div class="tags">'.$row['tags'].'</div> + </article>'."\n"; mysqli_free_result($result); mysqli_close($link); diff --git a/post.php b/post.php @@ -0,0 +1,43 @@ +<?php + require_once 'lang/lang.php'; + require_once 'config.php'; + + $link = mysqli_connect($mysql['host'], $mysql['user'], $mysql['passwd'], $mysql['database']); + $query = 'SELECT * FROM '.$mysql['table'].' WHERE id = '.$_GET['id']; + + if (mysqli_connect_errno()) { + print 'Connect failed: '.mysqli_connect_error(); + exit(); + } + + $result = mysqli_query($link, $query); + +?> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title><?=mainPage.baseTitle?></title> + <link rel="stylesheet" type="text/css" href="css/basic.css"> + <link rel="stylesheet" type="text/css" href="css/navbar.css"> + <link rel="stylesheet" type="text/css" href="css/footer.css"> + </head> + <body> + <?php include 'navbar.php'; ?> + <section id=content> + <?php + /* fetch associative array */ + $row = mysqli_fetch_array($result, MYSQLI_ASSOC); + print ' <article> + <h1>'.$row['title'].'</h1> + <p>'.$row['content'].'</p> + <div class="tags">'.$row['tags'].'</div> + </article>'."\n"; + + mysqli_free_result($result); + mysqli_close($link); + ?> + </section> + <?php include 'footer.php';?> + </body> +</html> diff --git a/rss.php b/rss.php @@ -3,12 +3,13 @@ <channel> <title><?=baseTitle?></title> <description></description> - <link>http://lanodan.the-delta.net/</link> + <link>http://<?=$_SERVER['HTTP_HOST']?>/</link> <?php header('Content-Type: application/xml; charset=UTF-8'); + require_once 'config.php'; - $link = mysqli_connect('localhost', 'www_data', 'minepqss', 'www_data'); - $query = "SELECT * FROM lanodan ORDER by id"; + $link = mysqli_connect($mysql['host'], $mysql['user'], $mysql['passwd'], $mysql['database']); + $query = 'SELECT * FROM '.$mysql['table'].' ORDER by id'; if (mysqli_connect_errno()) { print 'Connect failed: '.mysqli_connect_error(); @@ -19,34 +20,17 @@ /* fetch associative array */ $row = mysqli_fetch_array($result, MYSQLI_ASSOC); - print ' <item>'."\n"; - print ' <description>'.$row['description'].'</description>'."\n"; - print ' <link>'.$row['permalink'].'</link>'."\n"; - print ' <guid>'.$row['permalink'].'</guid>'."\n"; - print ' <pubDate>'.$row['pubDate'].'</pubDate>'."\n"; - print ' <category>'.$row['tags'].'</category>'."\n"; - print ' </item>'."\n"; + print ' <item> + <description>'.$row['description'].'</description> + <link>http://'.$_SERVER['HTTP_HOST'].'/post?id='.$row['id'].'</link> + <guid>'.$row['id'].'</guid> + <pubDate>'.$row['pubDate'].'</pubDate> + <category>'.$row['tags'].'</category> + </item>'."\n"; - // free result set - mysqli_free_result($result); + mysqli_free_result($result); //print the results - // close connection - mysqli_close($link); - - /* Item Example - * - * <item> - * <title>Ubuntu &amp; Canonical sucks !</title> - * <description>Ok so this is the long story of lanodan vs. ubuntu/canonical The beginning Ok so about years ago,...</description> - * <link>http://lanodan.the-delta.net/post/74193409614</link> - * <guid>http://lanodan.the-delta.net/post/74193409614</guid> - * <pubDate>Wed, 22 Jan 2014 20:20:54 +0100</pubDate> - * <category>MerciCanonical</category> - * <category>ThanksCanonical</category> - * <category>MerciUbuntu</category> - * <category>ThanksUbuntu</category> - * </item> - */ + mysqli_close($link);//close the mysql connection ?> </channel> </rss>