From 05a22cfc6de5b1db420d9e6426ddb9178df538e3 Mon Sep 17 00:00:00 2001 From: User Date: Sat, 11 Oct 2014 20:52:10 +0700 Subject: [PATCH 1/2] index done --- .gitignore | 1 + assets/css/screen.css | 7 +++ new_post.html => editor.php | 0 index.html | 114 ----------------------------------- index.php | 113 ++++++++++++++++++++++++++++++++++ nbproject/project.properties | 7 +++ nbproject/project.xml | 9 +++ post.html => post.php | 0 readme.md | 4 +- util.php | 0 10 files changed, 139 insertions(+), 116 deletions(-) create mode 100644 .gitignore rename new_post.html => editor.php (100%) delete mode 100644 index.html create mode 100644 index.php create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml rename post.html => post.php (100%) create mode 100644 util.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14bc68c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/nbproject/private/ \ No newline at end of file diff --git a/assets/css/screen.css b/assets/css/screen.css index 1d8fdf3..0f057c1 100644 --- a/assets/css/screen.css +++ b/assets/css/screen.css @@ -1,6 +1,13 @@ @import url(http://fonts.googleapis.com/css?family=Open+Sans); @import url(http://fonts.googleapis.com/css?family=Questrial); + +form.hidden{ + display: none; +} + + + /* Reset & Basics (Inspired by E. Meyers) ================================================== */ html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, address, cite, code, em, img, small, strong, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, embed, figure, figcaption, footer, header, hgroup, menu, nav, section, summary, time, audio, video { diff --git a/new_post.html b/editor.php similarity index 100% rename from new_post.html rename to editor.php 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 new file mode 100644 index 0000000..9b6a09e --- /dev/null +++ b/index.php @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Ini blok ----- nya tina + +prepare("DELETE FROM `simpelblok`.`post` WHERE `post`.`ID` = ?"); + $stm->bindParam(1, $_POST["del"]); + $stm->execute(); +} + + +$stm = $dbh->prepare("SELECT * FROM post"); +$stm->execute(); + +?> + + + + +
+ + + +
+
+ +
+
+ +
+ + +
ψ
+ +
+ +
+ + + + + + + \ No newline at end of file diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..b652f77 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_55 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..e7d12e5 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + Simple Blog + + + diff --git a/post.html b/post.php similarity index 100% rename from post.html rename to post.php diff --git a/readme.md b/readme.md index 931e382..ea671ff 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,7 @@ Gunakan template ini untuk membuat sebuah blog sederhana dengan menggunakan baha ## Spesifikasi -### List Post +### [DONE] List Post List Post merupakan halaman awal blog yang berisi daftar post yang sudah pernah dibuat. Setiap item pada list post mengandung `Judul`, `Tanggal`, `Konten`. Terdapat juga menu untuk mengedit dan menghapus item post tersebut. @@ -22,7 +22,7 @@ Add Post merupakan halaman untuk menambahkan post baru. Post baru memiliki form Mengedit post yang sudah pernah dibuat. Form yang ditampilkan sama seperti saat menambahkan form baru. -### Delete Post +### [DONE] Delete Post Menghapus post yang sudah pernah dibuat. Lakukan **konfimasi** dengan javascript untuk konfirmasi pengguna terhadap penghapusan post tersebut. Keluarkan konfirmasi berisi pesan berikut diff --git a/util.php b/util.php new file mode 100644 index 0000000..e69de29 From 8557e79e4594e31decd565888eeba0a4b4799671 Mon Sep 17 00:00:00 2001 From: User Date: Wed, 15 Oct 2014 00:07:45 +0700 Subject: [PATCH 2/2] 2 --- assets/css/screen.css | 7 ++-- assets/js/ajax.js | 46 ++++++++++++++++++++++ editor.php | 92 +++++++++++++++++++++++++++++++++++-------- index.php | 8 ++-- komen.php | 38 ++++++++++++++++++ post.php | 79 ++++++++++++++++--------------------- 6 files changed, 202 insertions(+), 68 deletions(-) create mode 100644 assets/js/ajax.js create mode 100644 komen.php diff --git a/assets/css/screen.css b/assets/css/screen.css index 0f057c1..01a5587 100644 --- a/assets/css/screen.css +++ b/assets/css/screen.css @@ -232,7 +232,7 @@ div.cover > img { } /* Header */ .art-header { - height: 900px; + height: 500px; /* Background image is defined in the post */ background-position: top center; background-attachment: fixed; @@ -240,7 +240,7 @@ div.cover > img { } /* Contains the time, title and subtitle for an article */ .art-header-inner { - position: fixed; + position: relative; top: 300px; left: 50%; margin-left: -490px; @@ -281,6 +281,7 @@ div.cover > img { /* Body */ .art-body { position: relative; + top: 40px; width: 100%; background: #fff; z-index: 100; @@ -822,7 +823,7 @@ hr.featured-article { text-align: center; } hr.featured-article:after { - content: "✭ Featured Article ✭"; + content: "✭ FEATURED ARTICLE ✭"; display: inline-block; position: relative; top: -0.8em; diff --git a/assets/js/ajax.js b/assets/js/ajax.js new file mode 100644 index 0000000..f22e3ea --- /dev/null +++ b/assets/js/ajax.js @@ -0,0 +1,46 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + + +var xmlhttp; +function ajaxGET(url,cfunc) { // Ajax Processor (not to be called from HTML) + xmlhttp=new XMLHttpRequest(); + xmlhttp.onreadystatechange=cfunc; + xmlhttp.open("GET",url,true); + xmlhttp.send(); + return xmlhttp; +} +function ajaxPOST(url,data,cfunc) { // Ajax Processor (not to be called from HTML) + xmlhttp=new XMLHttpRequest(); + xmlhttp.onreadystatechange=cfunc; + xmlhttp.open("POST",url,true); + xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); + xmlhttp.send(data); + return xmlhttp; +} +function loadPage(url,eid) { // Ajax LoadPage Handler + ajaxGET(url,function(){ + if (xmlhttp.readyState===4 && xmlhttp.status===200) { + document.getElementById([eid]).innerHTML=xmlhttp.responseText; + } + }); +} + +function postComment(form,url,eid) { // Ajax LoadPage Handle + var input = document.getElementById("Email"); + var validformat=/^\S*@\S*\.\S*$/; //Basic check for format validity + if (!validformat.test(input.value)) { + alert("Invalid Email Format. Please correct and submit again."); + } else { + var data = "Nama=" + form.Nama.value + "&Email=" + form.Email.value + "&postid=" + form.postid.value + "&Komentar=" + form.Komentar.value; + ajaxPOST(url, data, function(){ + if (xmlhttp.readyState===4 && xmlhttp.status===200) { + document.getElementById([eid]).innerHTML=xmlhttp.responseText; + } + }); + } + return false; +} \ No newline at end of file diff --git a/editor.php b/editor.php index fc4e18e..d496682 100644 --- a/editor.php +++ b/editor.php @@ -1,6 +1,66 @@ - + + + + prepare("SELECT * FROM post WHERE ID=?"); + $test->bindParam(1, $_GET["id"]); + $test->execute(); + $row = $test->fetch(PDO::FETCH_ASSOC); + $judul = $row['Judul']; + $konten = $row['Konten']; + $initID = $row['ID']; + } + + if(isset($_POST["Judul"]) && isset($_POST["Tanggal"]) && isset($_POST["Konten"]) && isset($_POST["id"])) { + $dbh = new PDO("mysql:dbname=simpelblok;host=localhost", "simpelblok", "simpelblok"); + if($_POST["id"] == -1) { + $tes = $dbh->prepare("INSERT INTO `simpelblok`.`post` (`ID`, `Judul`, `Tanggal`, `Konten`) VALUES (NULL, ?, ?, ?);"); + $tes->bindParam(1, $_POST["Judul"]); + $tes->bindParam(2, $_POST["Tanggal"]); + $tes->bindParam(3, $_POST["Konten"]); + $tes->execute(); + } else { + $edit = $dbh->prepare("UPDATE `simpelblok`.`post` SET `Judul` = :judul, `Tanggal` = :tanggal, `Konten` = :konten WHERE `post`.`ID` = :id;"); + $edit->bindParam(':judul', $_POST["Judul"]); + $edit->bindParam(':tanggal', $_POST["Tanggal"]); + $edit->bindParam(':konten', $_POST["Konten"]); + $edit->bindParam(':id', $_POST["id"]); + $edit->execute(); + + } + } + + ?> @@ -38,14 +98,15 @@
+

-

@@ -54,21 +115,28 @@

Tambah Post

-
+ - +
- + + +
+ + @@ -96,16 +164,8 @@ - + + \ No newline at end of file diff --git a/index.php b/index.php index 9b6a09e..f341adf 100644 --- a/index.php +++ b/index.php @@ -29,7 +29,7 @@ -Ini blok ----- nya tina +Simple Blog >
-

+

>Edit | >Hapus |

- +
+ + + + @@ -106,16 +114,7 @@
Ψ
@@ -125,16 +124,6 @@ - \ No newline at end of file