summaryrefslogtreecommitdiffstats
path: root/proposer.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'proposer.cgi')
-rwxr-xr-xproposer.cgi70
1 files changed, 70 insertions, 0 deletions
diff --git a/proposer.cgi b/proposer.cgi
new file mode 100755
index 0000000..e7821a7
--- /dev/null
+++ b/proposer.cgi
@@ -0,0 +1,70 @@
+#!/usr/bin/env ruby1.9.1
+# encoding: utf-8
+
+require 'rubygems'
+require 'dbi'
+require 'cgi'
+
+require './conf'
+db=$db
+
+require './header'
+header, cgi = header_tpe()
+
+pseudo=CGI.escapeHTML(cgi['pseudo']) or "Pseudo"
+email=CGI.escapeHTML(cgi['email']) or "E-mail"
+page=CGI.escapeHTML(cgi['page']) or "Inconnue"
+texte=CGI.escapeHTML(cgi['texte']) or ""
+
+if page =~ /^\d+$/
+ id = page.to_i
+ page_actuelle = id
+elsif page != ""
+ entree = page.split("/")
+ page_actuelle = entree
+else
+ id = 0
+ page_actuelle = 0
+end
+
+require './menu'
+menu, longueur_max, id, page = menu_tpe(page_actuelle)
+
+titre = "Pas de titre"
+contenu = "Pas de contenu"
+derniere_maj = ""
+derniere_maj_form = ""
+
+db.execute("SELECT titre, entree, contenu, derniere_maj, DATE_FORMAT(derniere_maj, '%W %e %M %Y à %k:%i') as derniere_maj_form FROM pages WHERE id=#{id}").each { |row| titre, entree, contenu, derniere_maj, derniere_maj_form = row}
+
+header["$titre$"] = " - " + titre
+
+puts header
+
+menu["$width$"] = (0.64*longueur_max).to_s()
+div_width = (0.64*longueur_max+3).to_s()
+
+puts menu
+
+if pseudo != "" and email != "" and id > 0 and page.split("/").last == entree and texte != "" then
+puts <<HTML_TPE
+<section id="comments" style="margin-left:#{div_width}em">
+ <header>
+ <h3>Commentaires</h3>
+ </header>
+<pre>
+Pseudo : #{pseudo}
+E-Mail : #{email}
+Page : #{page}
+Texte : #{texte}
+</pre>
+</section>
+HTML_TPE
+texte.gsub!("\n", "<br />")
+db.do("INSERT INTO en_attente (id_page, auteur, email, texte, date) VALUES(?, ?, ?, ?, NOW())", id, pseudo, email, texte)
+else
+puts "Erreur lors de l'envoi du commentaire."
+end
+
+require './footer'
+puts footer_tpe(derniere_maj, derniere_maj_form)