Главная
Статьи
Новости
Форум
Реклама
Нажмите
/
для поиска
Поиск
Войти
Регистрация
Open AI тестирует память для ChatGPT
И инструменты управления контекстом
Тренды маркетинга в 2024 году: мобильные продажи, углубленная аналитика и ИИ
Экспертная оценка Адмитад
SupeR-InG
Рейтинг
0
Регистрация
05.11.2020
Топики
1
Комментарии
2
Статьи
0
Помогите с кодом
5 ноября 2020, 22:24
Вот код в чем ошибка?
Помогите с кодом
5 ноября 2020, 22:23
<?php
//This part of the code writes the comment to a text file
$name = $comment = ""; // Creates the variables and makes them blank
if ($_SERVER["REQUEST_METHOD"] == "POST") { // If the post button is pressed
function format($data) {
$data = trim($data); // Trims the data
$data = stripslashes($data); // Un-quotes the data (Do not change this)
$data = htmlspecialchars($data); // Protects against characters that would break the code
return $data; // Gives back the data
}
$comment = format($_POST["comment"]); // Formats the comment
$name = format($_POST["name"]); // Formats the name
if($comment != "") { // If the user has typed something into the comment box
if($name == "") { // If there is no name
$name = "Anonymous"; // Set the name to Anonymous
}
// These just turn ASCII emoticons in to unicode ones
$comment = str_replace(">:(","😡",$comment);
$comment = str_replace(":(","🙁",$comment);
$comment = str_replace(":)","😊",$comment);
$comment = str_replace(";)","😉",$comment);
$comment = str_replace(":v","😏",$comment);
$comment = str_replace(":D","😄",$comment);
$date = date("d.m.Y"); // Generate the current date
$file = file_get_contents("chat.txt"); // Defines the file in wich comments are stored
$datarray = unserialize($file); // Turns the files contents into an array
$full = array // Combines all the data into an array
($date, $name, $comment);
$datarray[] = $full; // Adds this array to a bigger array of all the comments
$newfile = serialize($datarray); // Turns the array into a string we can store
file_put_contents("chat.txt", $newfile); // Stores the string into the file
function Redirect($url, $permanent = false) // Refreshes the page so the comment appears(and removes the old data so you dont post the same comment again on refresh)
{
if (headers_sent() === false)
{
header('Location: ' . $url, true, ($permanent == true) ? 301 : 302);
}
exit();
}
Redirect('http://galashki.ru/comment/)', false);
}
}
// The bottom html code is the comment submitting box
?>