#!/usr/bin/ruby require 'rubygems' require 'dbi' require 'cgi' require 'conf' db=$db page="Blagues" subpage="Derniers ajouts" cgi = CGI.new puts cgi.header if cgi['page'] =~ /\d*/ page = cgi['page'].to_i else page = 1 end puts < BDG — Blagues de Geek HTML_BDG require 'menu' puts menu_bdg(page,subpage) puts <

Dernières blagues ajoutés

HTML_BDG num_bdg = 0 db.execute("SELECT count(id) FROM blague").each { |row| num_bdg = row[0].to_i } num_page = ((num_bdg+11)/10+1) i = 0 if page > 5 then i = page puts <1 HTML_BDG end until i == num_page i = i+1 if i > (page+10) and num_page/2 > 10 then puts <#{(num_page+page)/2} HTML_BDG break elsif i > 5 and page > 5 then puts <#{i-4} HTML_BDG elsif i < 11 and page <= 5 puts <#{i} HTML_BDG end end if num_page > 10 then puts <#{num_page} HTML_BDG end puts"
" i = 0 db.execute("SELECT * FROM blague WHERE id < ((SELECT id FROM blague ORDER BY id DESC LIMIT 1)-#{(page*10)-11}) ORDER BY id DESC LIMIT 10").each { |row| unless row[1] == "" if i.modulo(2) == 1 parity = " impair" else parity = "" end i = i + 1 puts <

\##{row[0]} - #{CGI::escapeHTML(row[1])} ( #{row[5]} / #{row[6]} )

#{CGI::escapeHTML(row[3]).gsub(/\r\n|\r|\n/,"
")}

posté par #{CGI::escapeHTML(row[2])} le #{row[4]}

HTML_BDG end } require 'infos' puts infos_bdg() puts < HTML_BDG