From 6f7626473d0ab01622d9f23a58dca491197f30cb Mon Sep 17 00:00:00 2001 From: Anandakurniawan Date: Fri, 10 Oct 2014 07:34:46 +0700 Subject: [PATCH 01/10] coba push --- coba.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 coba.txt diff --git a/coba.txt b/coba.txt new file mode 100644 index 0000000..e69de29 From c54dc99c839d9f49a6c545a1b01bc6f759a93b3b Mon Sep 17 00:00:00 2001 From: Anandakurniawan Date: Fri, 10 Oct 2014 13:26:24 +0700 Subject: [PATCH 02/10] coba ketik --- coba.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/coba.txt b/coba.txt index e69de29..7af6bef 100644 --- a/coba.txt +++ b/coba.txt @@ -0,0 +1 @@ +coba \ No newline at end of file From 21ad54dd5a9c073ce6ceac28d3812512f0430afb Mon Sep 17 00:00:00 2001 From: Anandakurniawan Date: Fri, 10 Oct 2014 14:41:34 +0700 Subject: [PATCH 03/10] Tambah post --- config.php | 44 +++++++++++++ index.php | 138 ++++++++++++++++++++++++++++++++++++++++ new_post.php | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 357 insertions(+) create mode 100644 config.php create mode 100644 index.php create mode 100644 new_post.php diff --git a/config.php b/config.php new file mode 100644 index 0000000..cd51cea --- /dev/null +++ b/config.php @@ -0,0 +1,44 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + +//set timezone +date_default_timezone_set('Europe/London'); + +//load classes as needed +function __autoload($class) { + + $class = strtolower($class); + + //if call from within assets adjust the path + $classpath = 'classes/class.'.$class . '.php'; + if ( file_exists($classpath)) { + require_once $classpath; + } + + //if call from within admin adjust the path + $classpath = '../classes/class.'.$class . '.php'; + if ( file_exists($classpath)) { + require_once $classpath; + } + + //if call from within admin adjust the path + $classpath = '../../classes/class.'.$class . '.php'; + if ( file_exists($classpath)) { + require_once $classpath; + } + +} + + +?> \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..eaa8200 --- /dev/null +++ b/index.php @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog + +prepare('DELETE FROM blog_posts WHERE postID = :postID') ; + $stmt->execute(array(':postID' => $_GET['delpost'])); + + header('Location: index.php?action=deleted'); + exit; +} +?> + + + + + + +
+ + + +
+
+ +
+
+ + + +
+ + + + + + + + \ No newline at end of file diff --git a/new_post.php b/new_post.php new file mode 100644 index 0000000..3630f5f --- /dev/null +++ b/new_post.php @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Simple Blog | Tambah Post + +prepare('INSERT INTO blog_posts (postTitle,postDesc,postCont,postDate) VALUES (:postTitle, :postDesc, :postCont, :postDate)') ; + $stmt->execute(array( + ':postTitle' => $postTitle, + ':postDesc' => $postDesc, + ':postCont' => $postCont, + ':postDate' => date('Y-m-d H:i:s') + )); + + //redirect to index page + header('Location: index.php?action=added'); + exit; + + } catch(PDOException $e) { + echo $e->getMessage(); + } + + } + +} + +//check for any errors +if(isset($error)){ + foreach($error as $error){ + echo '

'.$error.'

'; + } +} +?> + + + + +
+ + + +
+ + +

-

+ +
+
+

Tambah Post

+ +
+
+ + '> + + + + +
+ + +
+ + + +
+
+
+
+ +
+ + + +
+ + + + + + + + \ No newline at end of file From 538aeb6f6784c63183f0d19a4ec2072609cce27f Mon Sep 17 00:00:00 2001 From: Anandakurniawan Date: Mon, 13 Oct 2014 00:37:10 +0700 Subject: [PATCH 04/10] list post --- index.php | 61 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/index.php b/index.php index eaa8200..49cd859 100644 --- a/index.php +++ b/index.php @@ -49,7 +49,7 @@ + + + + + + \ No newline at end of file From b960e0f047df4dbaae4d01c0c8da18a99b10db16 Mon Sep 17 00:00:00 2001 From: Anandakurniawan Date: Mon, 13 Oct 2014 00:37:46 +0700 Subject: [PATCH 07/10] view post --- viewpost.php | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 viewpost.php diff --git a/viewpost.php b/viewpost.php new file mode 100644 index 0000000..60fa9c9 --- /dev/null +++ b/viewpost.php @@ -0,0 +1,146 @@ +prepare('SELECT postID, postTitle, postCont, postDate FROM blog_posts WHERE postID = :postID'); +$stmt->execute(array(':postID' => $_GET['id'])); +$row = $stmt->fetch(); + +//if post does not exists redirect user. +if($row['postID'] == ''){ + header('Location: ./'); + exit; +} + +?> + + + + + + + + + + + + + + + + + + + + + + + + + + Simple Blog | <?php echo $row['postTitle'];?> + + + +
+ + + +
+'; + echo '
'; + echo ''; + echo '

'.$row['postTitle'].'

'; + echo '

'; + echo '
'; +echo ''; +?> +
+
+
+ '; + echo '

'.$row['postCont'].'

'; + echo ''; + ?> + +

Komentar

+ +
+
+ + + + + + +
+ + + +
+
+ +
    +
  • +
    +

    Jems

    +
    2 menit lalu
    +
    +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

    +
  • + +
  • +
    +

    Kave

    +
    1 jam lalu
    +
    +

    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis repudiandae quae natus quos alias eos repellendus a obcaecati cupiditate similique quibusdam, atque omnis illum, minus ex dolorem facilis tempora deserunt! …

    +
  • +
+
+
+ + + + + + + + + + + + + + \ No newline at end of file From 0be15b262337fd09ec03870d101e894e2be70076 Mon Sep 17 00:00:00 2001 From: Anandakurniawan Date: Tue, 14 Oct 2014 13:02:09 +0700 Subject: [PATCH 08/10] list post dan view post --- index.html | 114 -------------------------- index.php | 162 ++++++++++++++++++++++++------------- new_post.html | 111 ------------------------- new_post.php | 114 ++++++++++---------------- post.html => view_post.php | 143 +++++++++++++++++++++++++------- 5 files changed, 263 insertions(+), 381 deletions(-) delete mode 100644 index.html delete mode 100644 new_post.html rename post.html => view_post.php (57%) diff --git a/index.html b/index.html deleted file mode 100644 index 07cff0b..0000000 --- a/index.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Simple Blog - - - - - -
- - - -
-
- -
-
- - - -
- - - - - - - - \ No newline at end of file diff --git a/index.php b/index.php index 49cd859..b5f5d32 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,5 @@ + + @@ -31,75 +33,57 @@ Simple Blog -prepare('DELETE FROM blog_posts WHERE postID = :postID') ; - $stmt->execute(array(':postID' => $_GET['delpost'])); - - header('Location: index.php?action=deleted'); - exit; -} -?> - - -
+ + +
-
- '; - echo ''; - echo '
'; - } catch(PDOException $e) { - echo $e->getMessage(); - } - ?> -
+
+ +