Создание гостевой книги. Гостевая книга на PHP Точный guestbook php

1. На бесплатном хостинге есть только то, что дают.
2. Лучше, но совсем не обязательно. Порядочный гость оставит сообщение так как нужно (через мою форму), а хороший хакер все равно обойдет ваши $_GET, $_POST, $_COOKIE и $HTTP_REFERER тоже.
3. Контроль длины производиться, но только неявно, самой БД (единственно, что только само сообщение может быть огромно - до 64Кб).
4. Да, есть, HtmlSpecialChars была использована, не использовал AddSlashes (и это большая ошибка, признаю свою вину, см. ниже). При в ключеной magic_quotes_gpc, данная проблема не столь остра, но дыра в безопасности остается (в панели управления).
5. Да, согласен, можно было бы и вырезать, но имя #$@%#$^%$ ничем не хуже чем AF4ETX09T43 . В e-mail и url есть дырка, можно использовать скрипты.
6. Интересно, что не неинициализировано?

Есть еще ряд интересных приемов, как например защита от автоматического ввода через картинку (как на этом сайте) http://www.сайт/webmast/php/Security-Images-in-PHP/
...

Картинок кажется небыло, зачем усложнять демонстрационный пример. Пока ни разу не встречал гостевой с подобной защитой. Что касается этого сайта, то это не гостевая.

Анатомия межсайтового скриптинга XSS
http://www.woweb.ru/index.htm/id/1073393942

Очень интересно, спасибо.

З.Ы. Если бы Аффтор потрудился бы почитать (и вниктуть) в статьи что на этом же сайте, то понял бы, на сколько его труд непрофессионален. Стоит учитывать опыт предыдущих Авторов и, по крайней мере, уважать их труды - они же для вас писали.

Где есть не уважение? Извините если кого обидел.

Что касается защиты, то советую еще раз прочесть первый абзац статьи, я не ставил цели расматривать надежную гостевую, а лишь показать как можно написать протейшую гостевую, для тех кто только начинает познавать CGI, ведь не все сразу приходит, надо начинать с простого, и ты тоже не сразу стал таким умным, тоже совершал ошибки, так что давай оставим аспекты защиты другим статьям, другим авторам.

Да, с точки зрения защиты этот скрипт непрофессионален, и я непрофесионал в области защиты, поэтому в первом абзаце и стоит соответвующая оговорка, которую, к сожалению не все прочли.

PS Цитата:
Закон "Об авторском праве и смежных правах"
Статья 6. Объект авторского права. Общие положения
1. Авторское право распространяется на произведения науки, литературы и искусства, являющиеся результатом творческой деятельности, независимо от назначения и достоинства произведения, а также от способа его выражения.
Остальное можешь прочесть тут: http://www.febras.ru/~patent/copyright/2_3part2.html
В том числе и Статья 9. п.1
И не тебе решать пользоваться мне моим правом или нет.

For HTML codes, guestbook programming might seem unchallenging at first, and rightly so. When you see a guestbook, basic information is requested and it appears that anyone with a fundamental knowledge of the HTML programming language can write guestbook HTML codes. However, guestbooks, from the best to the worst, require a bit more skill than you think.

What is a Guestbook?

A guestbook is an online way to let visitors to your site comment or request information. Most guestbooks post what is written to the webpage so that everyone can read guest comments. The most common items you see on a guestbook are:

  • Name or Username
  • Where they reside (though you can set the HTML code to hide this fact)
  • Email (again, you can hide this fact and have it sent only to your email for communication purposes
  • Comments
  • Some guestbooks forego a comments section for a quick survey. You can usually find questions like "What did you think of this site: good, decent, bad, awesome" or "Was the information provided: enough, not enough, just right"
  • Options to request a reply or other information
Related Articles

Guestbooks can be programmed to send this information to an email address of your choice so that you don"t have to continually log into the site to view guestbook entries.

Where to Find HTML Codes, Guestbook

Whether you know HTML programming, you are a beginning web designer or you simply want a guestbook on your site, using prewritten HTML codes can save you time. The codes you can find online are typically well-tested and provide the most basic programming needed for easy-to-use guestbooks.

  • The code at HTML Comment Box provides the basic outline of an HTML code guestbook. All you need to do is customize the text to your needs and for your domain name. Instructions are provided at the beginning of the page. The code includes lines for name and address.
  • For a large selection of HTML codes and scripts, visit . With such a varied and large selection, you should be able to find one that works into the website you are creating. You can choose from basic guestbooks to more advanced programming that includes drop down menus and code for Macs and Linux machines. The codes are only 30-day free trials, so if you find a set of codes you like you"ll have to pay for the full use.
  • At Freebok you can input some basic information about what text you want on your guestbook and the website will generate the code for you. Afterwards, you can customize the guestbook even more by creating a template and editing the code in Freebok"s template layout mode. Other instructions are available on the site to help you with certain links you may need. You do need to sign up for an account in order to use Freebok.
  • To quickly add a guestbook with just a comment box, go to Guestbook Code . The initial code is already generated, but there are five options you can check and uncheck in order to alter the code slightly:
    • Collapse Guest Book. This includes a link that can open and close the guestbook on the webpage you insert it on.
    • Put Guest Book At Top. If this is unchecked, the guestbook and comment box will appear below any entries in the list.
    • Show Submission Date of Entries. This will add a date and time. The time will be the user"s local time zone, not yours.
    • Profanity Filter. Deletes any profanities that people may write.
    • You can also change the number of comments that are posted to the page for others to read. Minimum is one and maximum is one hundred. It"s recommended that you set it between five to twenty-five.

В данном уроке мы создадим гостевую книгу на PHP с использованием AJAX. Записи будут храниться в базе данных. Таблица будет содержать следующую информацию: имя отправителя, адрес email, IP адрес и дата-время последней записи. Будет использоваться jQuery (для реализации AJAX). Также будет реализована простая защита от спама - можно размещать не более одной записи каждые 10 минут.

Шаг 1. SQL

Для работы нашего приложения требуется создать таблицу:

CREATE TABLE IF NOT EXISTS `s178_guestbook` (`id` int(10) unsigned NOT NULL auto_increment, `name` varchar(255) default "", `email` varchar(255) default "", `description` varchar(255) default "", `when` int(11) NOT NULL default "0", `ip` varchar(20) default NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Шаг 2. PHP

Основной файл будет содержать следующий код:

guestbook.php

Гостевая книга Добавьте ваш отзыв здесь function submitComment(e) { var name = $("#name").val(); var email = $("#email").val(); var text = $("#text").val(); if (name && email && text) { $.post("guestbook.php", { "name": name, "email": email, "text": text }, function(data){ if (data != "1") { $("#records_list").fadeOut(1000, function () { $(this).html(data); $(this).fadeIn(1000); }); } else { $("#warning2").fadeIn(2000, function () { $(this).fadeOut(2000); }); } }); } else { $("#warning1").fadeIn(2000, function () { $(this).fadeOut(2000); }); } };

Ваше имя:
Ваш email:
Отзыв:
Заполните все обязательные поля Вы не можете размещать более одного отзыва в течении 10 минут (защита от спама)
mob_info