From 7fac0f20beffe1a1b99351893add73d5eef33f2c Mon Sep 17 00:00:00 2001 From: piernov Date: Thu, 7 Mar 2013 00:08:36 +0100 Subject: Importation initiale du projet --- proposer.cgi | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 proposer.cgi (limited to 'proposer.cgi') 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 < +
+

Commentaires

+
+
+Pseudo : #{pseudo}
+E-Mail : #{email}
+Page : #{page}
+Texte : #{texte}
+
+ +HTML_TPE +texte.gsub!("\n", "
") +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) -- cgit v1.2.3-70-g09d2