public function actionView($productId)
 {
     $categories = array();
     $categories = Platform::getPlatformList();
     $product = Products::getProductById($productId);
     $productId = $product['id'];
     $platform = Platform::getPlatformById($product['platform_id']);
     $comments = Comment::getCommentsByProductId($productId);
     //COMMENTS
     if (isset($_POST['submit'])) {
         $userComment = $_POST['message'];
         $errors = false;
         if (!Comment::validateMessage($userComment)) {
             $errors[] = "Введите собщение";
         }
         if (User::isGuest()) {
             $userName = $_POST['name'];
             $userEmail = $_POST['email'];
             if (!User::validateUsername($userName)) {
                 $errors[] = "Неверное имя";
             }
             if (!User::validateEmail($userEmail)) {
                 $errors[] = "Неверный Email";
             }
             $userId = false;
         } else {
             $userId = User::validateLogged();
             $user = User::getUserById($userId);
             $userName = $user['name'];
         }
         Comment::addComment($userComment, $userId, $userName, $productId);
     }
     require_once ROOT . '/views/product/view.php';
     return true;
 }
Esempio n. 2
0
 public static function comment($sent)
 {
     $comment = $sent["comment_field"];
     if ($comment != NULL && $comment != FALSE) {
         try {
             Comment::addComment($sent["to"], $comment, $sent["commentator"]);
         } catch (PDOException $e) {
             die($e->getMessage());
         }
     }
 }
Esempio n. 3
0
 public function addComment($id_membre, $id_salle)
 {
     $msg = "";
     if ($_POST) {
         $comment = htmlentities($_POST['comment'], ENT_QUOTES, "utf-8");
         $note = htmlentities($_POST['note'], ENT_QUOTES, "utf-8");
         $dateNow = new DateTime("now");
         $date = $dateNow->format('Y-m-d H:i:s');
         $commentaire = new Comment();
         $commentaire->setIdMembre($id_membre);
         $commentaire->setIdSalle($id_salle);
         $commentaire->setComment($comment);
         $commentaire->setNote($note);
         $commentaire->setDate($date);
         //Vérifications si besoin avant entrée en base
         $msgError = "";
         //Entrée en base
         if ($msgError == "") {
             $commentaire->addComment();
         } else {
             $msg .= $msgError;
         }
     }
 }
            }
        }
    }
    public function getComments()
    {
        $result = self::$db->query("SELECT * FROM comments ORDER BY id DESC");
        $result->setFetchMode(PDO::FETCH_ASSOC);
        while ($row = $result->fetch()) {
            $formatdate = date("d:m:y H:i:s", $row['datetime']);
            $id = $row['id'];
            $email = $data->{"email"};
            $fio = $row['fio'];
            $telephone = $row['telephone'];
            $file = $row['imgpath'];
            $comment = $row['comment'];
            if ($file == 0) {
                echo "<div class='panel panel-default'><div class='panel-heading'><p>id:{$id} &nbsp; Date:{$formatdate}</p><p>фио:{$fio}</p></div><div class='panel-body'><p>комментарий:{$comment}</p></div></div>";
            } else {
                echo "<div class='panel panel-default'><div class='panel-heading'><p>id:{$id} &nbsp; Date:{$formatdate}</p><p>фио:{$fio}</p></div><div class='panel-body'><p>img:{$file}<br>комментарий:{$comment}</p></div></div>";
            }
        }
    }
}
$comment = new Comment();
Comment::db();
if (isset($_POST['jsonData'])) {
    $comment->addComment();
}
if (isset($_POST['getComments'])) {
    $comment->getComments();
}
Esempio n. 5
0
<?php

require_once '../php/User.php';
require_once '../php/Vehicle.php';
require_once '../php/Comment.php';
require_once '../php/Data.php';
$isPost = filter_input(INPUT_SERVER, 'REQUEST_METHOD') == 'POST';
$url = filter_input(INPUT_SERVER, "PHP_SELF", FILTER_SANITIZE_SPECIAL_CHARS);
if ($isPost && $url && isset($_POST["to"])) {
    $rules = array('comment_field' => FILTER_SANITIZE_SPECIAL_CHARS, 'to' => FILTER_SANITIZE_SPECIAL_CHARS, 'commentator' => FILTER_SANITIZE_SPECIAL_CHARS);
    $sent = filter_input_array(INPUT_POST, $rules);
    $comment = $sent["comment_field"];
    $id = User::getUser($sent["to"]);
    if ($comment != NULL && $comment != FALSE) {
        try {
            Comment::addComment($id["iduser"], $comment, $sent["commentator"]);
            header("Location: ../html/my_vehicle.php");
        } catch (PDOException $e) {
            die($e->getMessage());
        }
    }
} else {
    if ($isPost && $url && isset($_POST["uid"])) {
        $rules = array('miles' => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 0)), 'gas' => array('filter' => FILTER_VALIDATE_INT, 'options' => array('min_range' => 1)));
        $sent = filter_input_array(INPUT_POST, $rules);
        $m = $sent["miles"];
        $g = $sent["gas"];
        $uid = filter_input(INPUT_POST, "uid", FILTER_VALIDATE_INT);
        if ($m != NULL && $m != FALSE && $g != NULL && $g != FALSE) {
            try {
                Data::insertData($m, $g, $uid);
Esempio n. 6
0
<?php

session_start();
include 'initclasses.php';
$comment = new Comment();
$comment->addComment($_SESSION['logged_user'], $_POST['target'], $_POST['comment'], $_POST['commenttable']);
header("Location: profile.php?user={$_POST['target']}&page=feed");
Esempio n. 7
0
<?php

$strPageTitle = 'Add a Comment';
include "layout/header.php";
if (!empty($_POST)) {
    $objComment = new Comment($_POST['comment'], $_POST['component'], $_POST['type']);
    $blnCommentAdded = $objComment->addComment();
    if ($blnCommentAdded) {
        setTopMessage('success', 'Success! the comment has been added.');
        header('Location: ' . $strLocation . 'admin/add_comments.php');
    }
}
$objComment = new Comment(NULL, NULL, NULL);
$arrComponents = $objComment->getComponents();
$arrCommentTypes = $objComment->getCommentTypes();
?>
  <form id="comment-form" data-abide method="post" action="add_comments.php">
    <div class="row">
      <div class="medium-8 panel columns left">
        <div class="row collapse">
          <p>Please fill out the comment details below:</p>
        </div>
        <?php 
if (is_array($arrComponents)) {
    ?>
        <div class="row prefix-radius">
          <div class="columns">
            <select name="component">
              <option disabled="disabled" selected>Choose a Component</option>
              <?php 
    foreach ($arrComponents as $arrComponent) {
Esempio n. 8
0
<?php

$base = "../../";
require_once $base . "functions.php";
require_once $base . "loginCheck.php";
header('Content-type: text/html; charset=UTF-8');
$uid = getUid();
$hash = getCookieHash();
checkCookieHash($uid, $hash);
//comment, itemId
if (!isset($_POST["comment"]) || !$_POST["comment"]) {
    add_return_data(0, 5, "Comment is a must.");
}
$com = $_POST["comment"];
if (!isset($_POST["itemId"]) || !$_POST["itemId"]) {
    add_return_data(0, 6, "itemId is a must.");
}
$itemId = $_POST["itemId"];
$comment = new Comment();
if (!$comment->addComment($uid = $uid, $hash = $hash, $itemId = $itemId, $com = $com)) {
    add_return_data(0, 7, "Error while commenting.");
}
add_return_data(1, 1, "Commented");
Esempio n. 9
0
                <input type="hidden" name="tweet_id" value="' . $tweet['id'] . '">
                <input type="submit" value="Dodaj komentarz">
            </form>
        ';
        $comment_counter = 0;
        //licznik komentarzy zawsze zaczyna od zera
        foreach (Comment::loadAllComments($tweet['id']) as $comment) {
            $comment_counter++;
            //zliczanie ilosci komentarzy
        }
        echo '<div class="comment">Ilość komentarzy: ' . $comment_counter . '<a href="show_post.php?tweetId=' . $tweet['id'] . '&userName='******'"> POKAŻ WIĘCEJ</a></div>';
        echo '<div style=" margin: 60px 0px"></div>';
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['forms'] == 'sending_message') {
        if ($_POST['message'] != null) {
            Message::sendMessage($currentlyLoggedUser->getId(), $_POST['receiver'], $_POST['message'], date('Y-m-d G:i:s'));
            header('Location: showUser.php?userId=' . $_POST['receiver']);
        }
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['forms'] == 'adding_comment') {
        Comment::addComment($_POST['tweet_id'], $currentlyLoggedUser->getId(), $_POST['comment'], date('Y-m-d G:i:s'));
    }
    if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['forms'] == 'adding_tweet') {
        if ($_POST['tweet_text'] != null) {
            Tweet::create($currentlyLoggedUser->getId(), $_POST['tweet_text'], date('Y-m-d G:i:s'));
            header('Location: showUser.php');
        } else {
            echo 'Twoj tweet jest pusty, jeżeli chcesz go wysłać to wprowadź do niego tekst';
        }
    }
}