コード例 #1
0
ファイル: send.php プロジェクト: Chortan/Chat
 * 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.
 */
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/User.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/Message.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/Canal.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/controller/functions.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/controller/userSystem.php";
session_start();
authentificationRequire();
if (isset($_POST["id_canal"]) && isset($_POST["message"])) {
    if (is_numeric($_POST["id_canal"])) {
        $canal = Canal::getCanalByID(intval($_POST["id_canal"]));
        if ($canal) {
            if ($canal->isInCanal($_SESSION["user"])) {
                $canal->addMessage(new Message($_POST["message"], $_SESSION["user"]));
                echo "Save canal ... ";
                $canal->save();
                echo "ok<br/>";
                header("Location: /Salon/Canal/" . $canal->getID());
            } else {
                $messages[] = new Message("Vous ne faisez pas partie de se canal, vous ne pouvez donc pas y envoyer et recevoir des messages.", $_SESSION["system"]);
            }
        } else {
            $message = new Message("Le canal n'existe pas !", $_SESSION["system"]);
        }
    }
}
コード例 #2
0
ファイル: CanalSQL.php プロジェクト: Chortan/Chat
 /**
  * Créer le canal s'il n'existe pas sinon il le met à jour
  */
 private function createCanal()
 {
     include $_SERVER["DOCUMENT_ROOT"] . "/modele/bdd/connect.php";
     if (!Canal::getCanalByID($this->_canal->getID())) {
         $sql = "INSERT INTO canal VALUES (:id_canal,:name,:dateCreated,:creator)";
     } else {
         $sql = "UPDATE canal SET \n                id_canal=:id_canal,\n                name=:name,\n                dateCreated=:dateCreated,\n                creator=:creator";
     }
     $req = $bdd->prepare($sql);
     $array = array(":id_canal" => $this->_canal->getID(), ":name" => $this->_canal->getName(), ":dateCreated" => $this->_canal->getDateCreated(), ":creator" => $this->_canal->getCreator()->getID());
     $req->execute($array);
 }
コード例 #3
0
ファイル: get.php プロジェクト: Chortan/Chat
<?php

/* 
 * 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.
 */
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/User.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/Message.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/Canal.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/controller/functions.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/controller/userSystem.php";
session_start();
authentificationRequire();
if (isset($_POST["id_canal"])) {
    $canal = Canal::getCanalByID(isset($_POST["id_canal"]));
    if ($canal->isInCanal($_SESSION["user"])) {
        $messages = array();
        if (isset($_POST["lastMessage"])) {
            $messages = $canal->getMessagesByDate(intval($_POST["lastMessage"]));
        } else {
            $messages = $canal->getAllMessages();
        }
        if (count($messages) == 0) {
            //http_response_code(410);
            http_response_code(204);
        } else {
            http_response_code(200);
        }
        foreach ($messages as $message) {
            if ($message->getTransmitter()->equals($_SESSION["user"])) {
コード例 #4
0
ファイル: create.php プロジェクト: Chortan/Chat
<?php

/* 
 * 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.
 */
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/User.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/Message.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/modele/Canal.php";
session_start();
require_once $_SERVER["DOCUMENT_ROOT"] . "/controller/functions.php";
authentificationRequire();
if (isset($_GET["user"])) {
    $to = User::getUserByID($_GET["user"]);
    $me = $_SESSION["user"];
    $canal = new Canal($me->getPseudo() . ", " . $to->getPseudo(), $me);
    $canal->addUser($to);
    if (($id_canal = $canal->exists()) != false) {
        $canal = Canal::getCanalByID($id_canal);
    } else {
        $canal->save();
    }
    header("Location: /Salon/Canal/" . $canal->getID());
}
?>

コード例 #5
0
ファイル: canal.php プロジェクト: Chortan/Chat
<?php

authentificationRequire();
if (isset($_GET["id"])) {
    if (is_numeric($_GET["id"])) {
        $canal = Canal::getCanalByID($_GET["id"]);
        if ($canal) {
            if ($canal->isInCanal($_SESSION["user"])) {
                echo "<h3 id='idCanal'>" . $canal->getName() . "</h3>";
            }
        } else {
            $message = new Message("Ce canal n'existe pas !", $_SESSION["system"]);
            echo "<div id='message' class='other'><a id='date'>" . date("H:i", $message->getDate()) . "</a>" . $message->getTransmitter()->getPseudo() . " : " . $message->getContent() . "</div>";
        }
    }
    ?>
<script src="/vue/page/salon/scripts/getMessage.js"></script>
<script src="/vue/page/salon/scripts/sendMessage.js"></script>
<div id="messages"><input type="hidden" name="lastMessage" value="0"/></div>

<form id="messageSender" action="/controller/message/send.php" method="POST">
    <input type="hidden" name="id_canal" value="<?php 
    echo $_GET["id"];
    ?>
"/>
    <input type="text" name="message" id="message" class="form-control" placeholder="Message ..."/>
    <input type="submit" id="envoiMessage" class="btn btn-primary"/>
</form>


<?php