public function hideTweet($tweet_id) { if (Request::ajax()) { $tweet = Tweet::create(['tweet_id' => $tweet_id]); return Response::json(true); } }
public static function addFavoris($req_twitter, $name_id) { foreach ($req_twitter as $key => $value) { Tweet::create(array('name_id' => $name_id->id, 'id_str' => $value->id, 'screen_name' => $value->user->screen_name, 'name' => $value->user->name, 'profile_image_url' => $value->user->profile_image_url, 'text' => $value->text, 'date_tweet' => $value->created_at)); $max_id = $value->id; } return $max_id; }
<?php session_start(); require_once '../resources/require.php'; // Dodaje nowy wpis do bazy, uzupełnia komunikat o dodaniu bądź błędach. if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (trim($_POST['text']) != '') { $tweet = new Tweet($mysqli); $tweet->setUserId($_SESSION['user_id']); $tweet->setText($_POST['text']); if (!$tweet->create()) { $info = 'Błąd przy dodawaniu wpisu'; } else { $info = 'Dodano nowy wpis'; } } else { $info = 'Uzupełnij treść wpisu!'; } } ?> <!DOCTYPE html> <html lang="pl-PL"> <title>Twitter | Strona główna</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> </head> <body>
<?php include_once "../configRoot.php"; require_once ROOT_NAME . "/classes/Database.php"; require_once ROOT_NAME . "/classes/Tweet.php"; require_once ROOT_NAME . "/includes/checkProfile.php"; if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST["tweet"])) { $text = $_POST["tweet"]; $text = htmlspecialchars($text); $db = Database::getInstance(); $conn = $db->getConnection(); $tweet = new Tweet($conn); $tweet->setUserId($id); $tweet->setText($text); $tweet->create(); header("location: ../index.php"); } else { header("location: ../index.php"); }
<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'; } } }