Example #1
0
</body>


<?php 
require_once "./src/connection.php";
if (isset($_GET["userId"])) {
    $userId = $_GET["userId"];
} else {
    $userId = $_SESSION['userId'];
}
$userToShow = User::GetUserById($userId);
if ($userToShow !== FALSE) {
    echo "<h1>{$userToShow->getName()}</h1>";
    echo "\n        <h3>Nowy tweet:</h3>";
    $tweet_text = $_POST["tweet_text"];
    if ($tweet_text !== FALSE) {
        $tweet1 = Tweet::CreateTweet($userId, $tweet_text, date("Y/m/d"));
    }
    echo "\n        <form action='showUser.php' method='post'>\n        <input type='text' name='tweet_text'>\n        <input type='submit'>\n        </form>";
    echo "<h3>Posty uzytkownika:</h3>";
    $tweets = $userToShow->loadAllTweets();
    foreach ($tweets as $tweet) {
        echo "<hr>";
        echo "{$tweet->getText()}<br>";
        echo "<a href='showTweet.php?tweetId={$tweet->getId()}'>Show</a><br>";
    }
}
?>

Example #2
0
}
if (isset($_GET['userId'])) {
    $userId = $_GET['userId'];
} else {
    $userId = $_SESSION['userId'];
}
$userToShow = User::GetUserById($userId);
if ($userToShow !== FALSE) {
    if ($userToShow->getId() !== $_SESSION['userId']) {
        echo "<h1>{$userToShow->getName()}</h1>";
    }
    if ($userToShow->getId() === $_SESSION['userId']) {
        echo "<h1>Witaj {$userToShow->getName()}</h1>";
        echo "\n        <a href='AllMessages.php?userId={$userToShow->getId()}'>Twoje wiadomosci</a>\n        <br><br>";
        if ($_SERVER['REQUEST_METHOD'] === "POST") {
            $tweet = Tweet::CreateTweet($_SESSION['userId'], $_POST['tweet_text']);
            if ($tweet === FALSE) {
                echo "Nieprawidlowy wpis.<br>";
            }
        }
        echo "\n        <form action='ShowUser.php' method='POST'>\n        <label>Dodaj Tweet'a:</label>\n        <input type='text' name='tweet_text''>\n        <input type='submit'>\n        </form>\n        ";
    }
    foreach ($userToShow->loadAllTweets() as $tweet) {
        echo "{$tweet->getText()} | Komentarze: {$tweet->numberOfComments()} | ";
        echo "<a href='ShowTweet.php?tweetId={$tweet->getId()}'>Show info</a><br>";
    }
    if ($userToShow->getId() !== $_SESSION['userId']) {
        echo "\n        <form action='ShowUser.php?userId={$userToShow->getId()}' method='POST'>\n        <label>Wyslij wiadomosc:</label>\n        <input type='text' name='message_text''>\n        <input type='submit'>\n        </form>\n        ";
        if ($_SERVER['REQUEST_METHOD'] === "POST") {
            $message = Message::CreateMessage($_SESSION['userId'], $userToShow->getId(), $_POST['message_text']);
            if ($message === FALSE) {
Example #3
0
<?php

require_once "./src/connections.php";
if (isset($_SESSION['userId']) !== TRUE) {
    header("Location: login.php");
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (strlen(trim($_POST['tweet_text'])) > 0) {
        $tweetText = $_POST['tweet_text'];
        $tweet = Tweet::CreateTweet($tweetText);
        header("Location: indeks.php");
    } else {
        echo "Nie udało się utworzyć tweeta :(";
    }
}
$userId = $_SESSION['userId'];
$userToShow = User::GetUserById($userId);
$allTweets = $userToShow->getAllFriendsAndMineTweets();
//var_dump($allTweets);
echo "<h1> Tweety Twoje oraz twoich przyjaciół </h1>";
if ($userToShow->getId() === $_SESSION['userId']) {
    ?>
    <h3>Nowy tweet</h3>
    <form action='showUser.php' method='post'>
        <label>
            <input type='text' name='tweet_text'>
        </label>
        <input type='submit'>
    </form>

<?php