<%mn=2%> Форум - дистанционное обучение. Центр дистанционного обучения IT-STUDY.ru - компьютерные курсы в Интернет online.

<% application("forum_conn")="Driver={Microsoft Access Driver (*.mdb)}; DBQ="&server.mappath("\")&"\forum\forum.mdb" thisref="forum.asp" act=trim(request("act")) topic=trim(request("topic")) if topic="" then topic="no" set connsql=server.createobject("adodb.connection") set rs=server.createobject("adodb.recordset") connsql.open application("forum_conn") // <-- генератор идентификатора капчи и номера для показа Randomize number = Int( Rnd() * 89999 + 10000 ) captcha_id = number * 17 - 539 // ---> if act="new_topic" then topic_name=parsestr_in(trim(request("topic_name"))) author_name=parsestr_in(trim(request("author_name"))) author_email=parsestr_in(trim(request("author_email"))) password=parsestr_in(trim(request("password"))) in_captcha_id=parsestr_in(trim(request("captcha_id"))) in_captcha_number=Abs(parsestr_in(trim(request("captcha_number")))) if author_email="" then author_email=" " message=parsestr_in(trim(request("message"))) if topic_name="" then err_msg=err_msg&""Название темы" " if author_name="" then if err_msg<> "" then err_msg=err_msg&", " err_msg=err_msg&""Ваше имя" " end if if message="" then if err_msg<> "" then err_msg=err_msg&", " err_msg=err_msg&""Сообщение" " end if true_number=( in_captcha_id + 539 )/17 if true_number<>in_captcha_number then if err_msg<> "" then err_msg=err_msg&", " err_msg=err_msg&""Число с картинки" " end if if err_msg<>"" then err_msg="Новая тема не создана. Пожалуйста, заполните поле "&err_msg&". " if err_msg="" then strsql="SELECT topic_id FROM topics WHERE topic_name='"&topic_name&"'" rs.open strsql,connsql if not rs.eof then err_msg="Тема с указанным Вами названием уже существует." rs.close if err_msg="" then strsql="INSERT INTO topics (topic_name) VALUES ('"&topic_name&"')" connsql.execute strsql strsql="SELECT MAX(topic_id) AS current_topic_id FROM topics WHERE topic_name = '"&topic_name&"'" rs.open strsql,connsql if not rs.eof then topic_id=trim(rs("current_topic_id")) else topic_id=0 end if rs.close strsql="INSERT INTO messages (topic_id,message_author_name, message_author_email, message_text) VALUES ("&topic_id&",'"&author_name&"','"&author_email&"','"&message&"')" connsql.execute strsql message="" topic_name="" author_name="" author_email="" end if end if end if 'new topic if act="new_message" then author_name=parsestr_in(trim(request("author_name"))) author_email=parsestr_in(trim(request("author_email"))) password=parsestr_in(trim(request("password"))) in_captcha_id=parsestr_in(trim(request("captcha_id"))) in_captcha_number=Abs(parsestr_in(trim(request("captcha_number")))) if author_email="" then author_email=" " message=parsestr_in(trim(request("message"))) if author_name="" then err_msg=err_msg&""Ваше имя" " if message="" then if err_msg<> "" then err_msg=err_msg&", " err_msg=err_msg&""Сообщение" " end if true_number=(in_captcha_id + 539)/17 if true_number <> in_captcha_number then if err_msg<> "" then err_msg=err_msg&", " err_msg=err_msg&""Число с картинки" " end if if err_msg<>"" then err_msg="Ваше сообщение не добавлено. Пожалуйста, заполните поле "&err_msg&". " if err_msg="" and isnumeric(topic) then strsql="INSERT INTO messages (topic_id,message_author_name, message_author_email, message_text) VALUES ("&topic&",'"&author_name&"','"&author_email&"','"&message&"')" connsql.execute strsql message="" author_name="" author_email="" else errmsg="Попытка добавить сообщение в несуществующую тему." end if end if' new message if err_msg<>"" then%>

<%=err_msg%>

<%end if if isnumeric(topic) then strsql="SELECT topic_name FROM topics WHERE topic_id="&topic rs.open strsql,connsql if not rs.eof then topic_name=trim(rs("topic_name")) end if rs.close strsql="SELECT * FROM messages WHERE topic_id="&topic&" ORDER BY message_date ASC" rs.open strsql,connsql %>
<%=topic_name%>

>[к списку тем]

<% do while not rs.eof message_author_email=trim(rs("message_author_email")) %> <% rs.movenext loop rs.close %>
<%if message_author_email<>"" then%>><%end if%><%=rs("message_author_name")%><%if message_author_email<>"" then%><%end if%> <%=trim(rs("message_date"))%>

<%=parsestr_out(trim(rs("message_text")))%>



?topic=<%=topic%> method=post>
Новое сообщение<%=true_number%>
Ваше имя:
Ваш e-mail:
Сообщение:
Введите число с картинки:
  

>[к списку тем]

<% else strsql="SELECT topics.topic_id, topic_name, message_author_name, message_author_email, T.last_change, T.message_count FROM topics, messages, (SELECT DISTINCT messages.topic_id, COUNT(message_id) AS message_count, MIN(message_id) AS first_message_id, MAX(message_date) AS last_change FROM topics LEFT JOIN messages ON (topics.topic_id=messages.topic_id) GROUP BY messages.topic_id) T WHERE T.topic_id=topics.topic_id AND messages.message_id=first_message_id ORDER BY last_change DESC" rs.open strsql, connsql %> <%do while not rs.eof message_count=rs("message_count") message_author_email=trim(rs("message_author_email")) %><% rs.movenext loop rs.close %>
Тема Автор Сообщений Изменена
?topic=<%=rs("topic_id")%>&count=<%=message_count%>><%=rs("topic_name")%> <%if message_author_email<>"" then%>><%end if%><%=rs("message_author_name")%><%if message_author_email<>"" then%><%end if%> <%=message_count%> <%=rs("last_change")%>


method=post>
Новая тема
Название темы:
Ваше имя:
Ваш e-mail:
Сообщение:
Введите число с картинки:
  
<% end if' topic connsql.close set connsql=nothing function parsestr_out(rawstr) res="" strlen=len(rawstr) i=1 do while i<=strlen curchar=Mid(rawstr,i,1) select case curchar case "<" res=res+"<" case ">" res=res+">" case chr(13) res=res+"
" case chr(10) case else res=res+curchar end select i=i+1 loop parsestr_out=res end function function parsestr_in(rawstr) res="" strlen=len(rawstr) i=1 do while i<=strlen curchar=Mid(rawstr,i,1) select case curchar case "'" res=res+"''" case else res=res+curchar end select i=i+1 loop parsestr_in=res end function function parsestr_datetime(rawstr) res="" strlen=len(rawstr) i=1 do while i<=strlen curchar=Mid(rawstr,i,1) select case curchar case " " res=res+"
" case else res=res+curchar end select i=i+1 loop parsestr_datetime=res end function %>