function showArticleById($idArticle)
{
    $articleModel = new articleModel();
    $article = $articleModel->getArticle($idArticle);
    $commentModel = new commentModel();
    $comment = $commentModel->getComments($idArticle);
    include 'view/viewArticle.php';
}
 public function putcomment()
 {
     $inputdetails['userid'] = Auth::user()->ID;
     $inputdetails['contest_participant_id'] = $_GET['participantid'];
     $inputdetails['comment'] = $_GET['comment'];
     $curdate = date('Y-m-d h:i:s');
     $inputdetails['createddate'] = $curdate;
     $savecomment = commentModel::create($inputdetails);
     if ($savecomment) {
         return Redirect::to("contest_info/" . $_GET['contest_id'])->with('tab', 'gallery')->with('gallerytype', 'comment')->with('viewcommentforparticipant', $_GET['participantid'])->with('Massage', 'Comment added successfully');
     }
 }
 public function takeactionforreport()
 {
     $contestparticipantid = Input::get('contestparticipantid');
     $contest_id = Input::get('contest_id');
     $contest_partipant_id = Input::get('contest_partipant_id');
     if ($contestparticipantid != '') {
         $comment = commentModel::select('id')->where('contest_participant_id', $contestparticipantid)->get();
         for ($i = 0; $i < count($comment); $i++) {
             $replycmt = replycommentModel::where('comment_id', $comment[$i]['id'])->get()->count();
             if ($replycmt) {
                 replycommentModel::where('comment_id', $comment[$i]['id'])->delete();
             }
         }
         if (count($comment)) {
             commentModel::select('id')->where('contest_participant_id', $contestparticipantid)->delete();
         }
         $votingcnt = votingModel::where('contest_participant_id', $contestparticipantid)->get()->count();
         if ($votingcnt) {
             votingModel::where('contest_participant_id', $contestparticipantid)->delete();
         }
         $participantid = contestparticipantModel::where('ID', $contestparticipantid)->get()->count();
         if ($participantid) {
             $delete = contestparticipantModel::where('ID', $contestparticipantid)->delete();
             $data['message'] = 'That Contest participant details removed successfully';
         } else {
             $data['message'] = 'That Contest participant details already removed';
         }
         $reportflagcnt = reportflagModel::where('contest_participant_id', $contestparticipantid)->get()->count();
         $inputdetails['action_taken'] = 1;
         if ($reportflagcnt) {
             reportflagModel::where('contest_participant_id', $contestparticipantid)->update($inputdetails);
         }
         if ($contest_partipant_id == "") {
             return Redirect::to('contest_info/' . $contest_id)->with('data', $data)->with('tab', 'gallery');
         } else {
             $data['message'] = 'Action taken for this report';
             return Redirect::to('reportlist')->with('data', $data);
         }
     }
 }
 private function show()
 {
     $user = new userModel();
     $upload = new UploadFile("pic", "public/uploads/member");
     if (isset($_POST['send'])) {
         $user->id = $_POST['id'];
         $user->email = $_POST['email'];
         if ($_POST['pwd'] == $_POST['newpwd']) {
             $user->pwd = $_POST['newpwd'];
         } else {
             $user->pwd = md5($_POST['newpwd']);
         }
         if (is_uploaded_file($_FILES['pic']['tmp_name'])) {
             if ($upload->upload("pic")) {
                 $user->icon = $upload->getNewName();
             }
         } else {
             $user->icon = $_POST['newpic'];
             //echo "没有上传".$_POST['newpic'];
         }
         //Tools::dump($_POST);
         if ($user->updateUser()) {
             //echo "ok";
             Tools::Redirect("会员资料修改成功", $_SERVER['HTTP_REFERER']);
         } else {
             if ($user->updateUser() == 0) {
                 Tools::Redirect("会员资料没有修改", $_SERVER['HTTP_REFERER']);
                 //echo "not changed";
             } else {
                 Tools::Redirect("会员资料修改失败", $_SERVER['HTTP_REFERER'], 2);
             }
         }
     }
     $comment = new commentModel();
     $article = new articleModel();
     $product = new productModel();
     $ask = new askModel();
     $quiz = new quizModel();
     if ($_GET['id']) {
         $user->id = $_GET['id'];
         $oneUser = $user->getOneUserByID();
         $this->smarty->assign("oneUser", $oneUser);
         /////////////////////////////////
         $comment->uid = $_GET['id'];
         $allComments = $comment->getAllCommentsByUID();
         foreach ($allComments as $key => $value) {
             $article->id = $value->aid;
             $oneArticle = $article->getOneArticle();
             $value->title = $oneArticle->title;
         }
         $product->uid = $_GET['id'];
         $allOrders = $product->getAllOrdersByUID();
         foreach ($allOrders as $value) {
             $pids = explode(",", $value->pid);
             $str = null;
             foreach ($pids as $v) {
                 $product->id = $v;
                 //Tools::dump($v);
                 $oneProduct = $product->getOneProduct();
                 //Tools::dump($oneProduct);
                 $str .= $oneProduct->name . ",";
             }
             $str = rtrim($str, ",");
             //Tools::dump($str);
             $value->pid = $str;
             switch ($value->payed) {
                 case 0:
                     $value->payed = "<span style='color:red;'>[未付]</span>";
                     break;
                 case 1:
                     $value->payed = "<span style='color:green;'>[已付]</span>";
             }
             switch ($value->sent) {
                 case 0:
                     $value->sent = "<span style='color:red;'>[未发货]</span>";
                     break;
                 case 1:
                     $value->sent = "<span style='color:green;'>[已发货]</span>";
             }
         }
         $ask->aid = $_GET['id'];
         $allAsks = $ask->getAllAskByAID();
         $this->smarty->assign("allAsks", $allAsks);
         $this->smarty->assign("allOrders", $allOrders);
         $this->smarty->assign("allComments", $allComments);
         $quiz->uid = $_GET["id"];
         $allScores = $quiz->getAllScoresByUID();
         $course = new courseModel();
         foreach ($allScores as $key => $value) {
             $course->id = $value->cid;
             $oneCourse = $course->getOneCourse();
             $value->cid = $oneCourse->name;
         }
         $this->smarty->assign("allScores", $allScores);
     }
     $this->smarty->assign("show", true);
 }
     $itemModel = new itemModel();
     if (isset($_POST['is_cover'])) {
         $result = $itemModel->addCoverImage($_POST['item_name'], $_POST['owner'], $_POST['image_url']);
     } else {
         $result = $itemModel->addNonCoverImage($_POST['item_name'], $_POST['owner'], $_POST['image_url']);
     }
     if ($result == true) {
         $result = "<p class='text-success'>Item Image Successfully Created!</p>";
     } else {
         $result = "<p class='text-danger'>Error Occured! Try checking your database constraint.</p>";
     }
 } else {
     if (isset($_POST['item_name']) && isset($_POST['owner']) && isset($_POST['commentor']) && isset($_POST['content'])) {
         // adding comment entry
         include 'models/commentModel.php';
         $commentModel = new commentModel();
         $result = $commentModel->addComment($_POST['item_name'], $_POST['owner'], $_POST['commentor'], $_POST['content']);
         if ($result == true) {
             $result = "<p class='text-success'>Review Successfully Created!</p>";
         } else {
             $result = "<p class='text-danger'>Error Occured! Try checking your database constraint.</p>";
         }
     } else {
         if (isset($_POST['reviewer']) && isset($_POST['reviewee']) && isset($_POST['content'])) {
             // adding review entry
             include 'models/reviewModel.php';
             $reviewModel = new reviewModel();
             if (isset($_POST['has_like'])) {
                 $result = $reviewModel->addNewReview($_POST['reviewer'], $_POST['reviewee'], $_POST['content'], 1);
             } else {
                 $result = $reviewModel->addNewReview($_POST['reviewer'], $_POST['reviewee'], $_POST['content'], 0);
 private function member()
 {
     $comment = new commentModel();
     if (isset($_GET['id'])) {
         $this->model->id = $_GET['id'];
         $oneUser = $this->model->getOneUserByID();
         $comment->uid = $oneUser->username;
         $page = new Page($comment->getAllCommentsByUIDTotal());
         $comment->limit = $page->limit;
         $allComments = $comment->getAllCommentsByUID();
         //Tools::dump($allComments);
         $this->smarty->assign('page', $page->display());
         $this->smarty->assign("allComments", $allComments);
         $this->smarty->assign("oneUser", $oneUser);
     }
     $this->smarty->assign("member", true);
     $this->smarty->display('home/member.html');
     exit;
 }
function postComment($login, $article, $comment)
{
    $commentModel = new commentModel();
    $comment = $commentModel->addComment($login, $article, $comment);
    include 'view/viewArticle.php';
}
<?php

require_once 'commentModel.class.php';
$commentModel = new commentModel();
// $commentModel->getComments('1');
$action = $_GET['action'];
$blogId = $_REQUEST['blogId'];
switch ($action) {
    case 'getComments':
        $result = $commentModel->getComments($blogId);
        echo json_encode($result);
        break;
    case 'addComment':
        $content = $_POST['content'];
        if (strlen($content) >= 10) {
            $result = $commentModel->addComment($blogId, $content);
            if ($result) {
                // require_once 'swiftmailer-master/lib/swift_required.php';
                // $email = '*****@*****.**';
                // //发送邮件,以QQ邮箱为例
                // //配置邮件服务器,得到传输对象
                // $transport=Swift_SmtpTransport::newInstance('smtp.qq.com',25);
                // //设置登陆帐号和密码
                // $transport->setUsername('*****@*****.**');
                // $transport->setPassword('songwanfu0531');
                // //得到发送邮件对象Swift_Mailer对象
                // $mailer=Swift_Mailer::newInstance($transport);
                // //得到邮件信息对象
                // $msg=Swift_Message::newInstance();
                // //设置管理员的信息
                // $msg->setFrom(array('*****@*****.**'=>'Meet Better Me'));
 public function putcomments()
 {
     $inputdetails = Input::get();
     $curdate = date('Y-m-d h:i:s');
     $inputdetails['createddate'] = $curdate;
     $validation = Validator::make($inputdetails, commentModel::$rules);
     if ($validation->passes()) {
         $savecomment = commentModel::create($inputdetails);
         if ($savecomment) {
             $Response = array('success' => '1', 'message' => 'Comment saved successfully', 'msgcode' => "c134");
             $final = array("response" => $Response);
             return json_encode($final);
         }
     } else {
         $Response = array('success' => '0', 'message' => 'Some details are Missing', 'msgcode' => "c101");
         $final = array("response" => $Response);
         return json_encode($final);
     }
 }
                        <a href="{{ URL::to('contesttab?contest_id='.$contest_id.'&contest_partipant_id='.$viewcommentforparticipant) }}" class="ib-close" >Close</a>
                        <h1>{{ $contestdetails[0]['contest_name']}}</h1>
                        <div class="cont_det_con">

                            <div class="cont_des_con">

                                {{ isset($Massage)?"<p style='color:red;text-align:center'>".$Massage."</p>":""}}

                                <strong>Contest Comment</strong>
                                <input type="hidden" class="contest_participant_id" value="<?php 
    echo $viewcommentforparticipant;
    ?>
" >

    <?php 
    $commentcnt = commentModel::select('comments.id as comment_id', 'comments.userid as commentuserid', 'comments.comment', 'user.profilepicture', 'user.firstname', 'user.lastname', 'user.username')->LeftJoin('user', 'user.ID', '=', 'comments.userid')->where('contest_participant_id', $viewcommentforparticipant)->get();
    for ($i = 0; $i < count($commentcnt); $i++) {
        ?>

                                    <table width="98%" border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td align="left">
                                                <div>
                                                    <textarea  id="cmt" name="cmt" value="" class="full_cmt rud_gry" disabled>{{ $commentcnt[$i]['comment'] }}</textarea>
                                                    <input type="button" value="Reply" class="cmt_btn reply_div" id="showdiv_<?php 
        echo $i;
        ?>
"   >
                                                </div>
                                            </td>
                                            <td width="1%"></td>
 public function view()
 {
     session_start();
     $owner = '';
     $itemName = '';
     if (!empty($_GET['owner']) && !empty($_GET['item'])) {
         $owner = $_GET['owner'];
         $itemName = $_GET['item'];
     }
     // get item info
     include 'models/itemModel.php';
     include 'models/memberModel.php';
     include 'models/itemAvailabilityModel.php';
     include 'models/commentModel.php';
     include 'models/loanRequestModel.php';
     $loanRequestModel = new loanRequestModel();
     $itemModel = new itemModel();
     $memberModel = new memberModel();
     $itemAvailabilityModel = new itemAvailabilityModel();
     $commentModel = new commentModel();
     $result = $itemModel->getByKey($owner, $itemName);
     $item = pg_fetch_array($result);
     $submitSuccess = false;
     $submitError = false;
     if (!empty($_POST)) {
         if ($_POST['action'] == 'requestLoan') {
             if ($_POST['start'] == '' || $_POST['end'] == '' || $_POST['bidPrice'] == '') {
                 $submitError = true;
             } else {
                 // process loan request
                 $start = $_POST['start'];
                 $end = $_POST['end'];
                 $bidPrice = $_POST['bidPrice'];
                 $request = $loanRequestModel->addLoanRequest($item['item_name'], $item['owner'], $_SESSION['username'], $start, $end, $bidPrice);
                 if ($request) {
                     $submitSuccess = true;
                 } else {
                     $submitError = true;
                 }
             }
         }
         if ($_POST['action'] == 'submitComment') {
             $commentModel->addComment($_POST['item_name'], $_POST['owner'], $_SESSION['username'], $_POST['content']);
         }
     }
     // get all available dates
     $result = $itemAvailabilityModel->getAllByItemKey($owner, $itemName);
     $availabilityArray = pg_fetch_all($result);
     // get all accepted pending
     $result = $loanRequestModel->getAllAcceptedByItem($itemName, $owner);
     $acceptedArray = pg_fetch_all($result);
     if ($acceptedArray) {
         $acceptedDates = [];
         foreach ($acceptedArray as $accepted) {
             $startDate = strtotime($accepted['date_start']);
             $endDate = strtotime($accepted['date_end']);
             $yearStart = intval(date("Y", $startDate));
             $monthStart = intval(date("m", $startDate));
             $dateStart = intval(date("d", $startDate));
             $yearEnd = intval(date("Y", $endDate));
             $monthEnd = intval(date("m", $endDate));
             $dateEnd = intval(date("d", $endDate));
             for ($y = $yearStart; $y <= $yearEnd; $y++) {
                 for ($m = $monthStart; $m <= $monthEnd; $m++) {
                     for ($d = $dateStart; $d <= $dateEnd; $d++) {
                         $acceptedDates[] = $d . '-' . $m . '-' . $y;
                     }
                 }
             }
         }
     }
     $freeDates = [];
     if ($availabilityArray) {
         foreach ($availabilityArray as $availability) {
             $startDate = strtotime($availability['date_start']);
             $endDate = strtotime($availability['date_end']);
             $yearStart = intval(date("Y", $startDate));
             $monthStart = intval(date("m", $startDate));
             $dateStart = intval(date("d", $startDate));
             $yearEnd = intval(date("Y", $endDate));
             $monthEnd = intval(date("m", $endDate));
             $dateEnd = intval(date("d", $endDate));
             for ($y = $yearStart; $y <= $yearEnd; $y++) {
                 for ($m = $monthStart; $m <= $monthEnd; $m++) {
                     for ($d = $dateStart; $d <= $dateEnd; $d++) {
                         $freeDates[] = $d . '-' . $m . '-' . $y;
                     }
                 }
             }
         }
     }
     if ($acceptedArray) {
         for ($i = 0; $i < count($freeDates); $i++) {
             for ($j = 0; $j < count($acceptedDates); $j++) {
                 if (strcmp($freeDates[$i], $acceptedDates[$j]) == 0) {
                     $freeDates[$i] = -1;
                 }
             }
         }
     }
     // get all comments
     date_default_timezone_set("Asia/Singapore");
     $result = $commentModel->getCommentsByItemKey($owner, $itemName);
     $commentArray = pg_fetch_all($result);
     include 'views/item.php';
 }