-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
259 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
<?php | ||
include 'config.php'; | ||
include 'layout.php'; | ||
include 'functions.php'; | ||
include 'db.php'; | ||
|
||
use Blog\Functions; | ||
use Blog\DB, | ||
Blog\Layout; | ||
|
||
// Connect to the db | ||
$conn = Functions\connect($config); | ||
if ( !$conn ) die('Problem connecting to the database see file config.php.'); | ||
// Constructor to the db | ||
$db = new DB\DB($config); | ||
|
||
// Constructor to layout view | ||
$layout = new Layout\Layout(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,21 @@ | ||
<?php | ||
|
||
require 'app.php'; | ||
use Blog\Functions; | ||
|
||
$id = $_POST['article_id']; | ||
$postCollection = $conn->posts; | ||
$post = $postCollection->findOne(array('_id' => new MongoId($id))); | ||
if ($_SERVER['REQUEST_METHOD'] === 'POST' ) { | ||
|
||
if (isset($post['comments'])) { | ||
$comments = $post['comments']; | ||
}else{ | ||
$comments = array(); | ||
} | ||
$id = $_POST['article_id']; | ||
$comment = array( | ||
'name' => $_POST['fName'], | ||
'email' => $_POST['fEmail'], | ||
'comment' => $_POST['fComment'], | ||
'posted_at' => new MongoDate() | ||
); | ||
$status = $db->commentId($id,'posts',$comment); | ||
|
||
$comment = array( | ||
'name' => $_POST['fName'], | ||
'email' => $_POST['fEmail'], | ||
'comment' => $_POST['fComment'], | ||
'posted_at' => new MongoDate() | ||
); | ||
|
||
array_push($comments, $comment); | ||
if ($status == TRUE) { | ||
header('Location: single.php?id='.$id); | ||
} | ||
|
||
|
||
$postCollection->update( | ||
array('_id' => new MongoId($id)), | ||
array('$set' => array('comments' => $comments))); | ||
header('Location: single.php?id='.$id); | ||
} |
Oops, something went wrong.