summaryrefslogtreecommitdiffstats
path: root/latest.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'latest.cgi')
-rwxr-xr-xlatest.cgi26
1 files changed, 20 insertions, 6 deletions
diff --git a/latest.cgi b/latest.cgi
index 30ee24a..18ba1e5 100755
--- a/latest.cgi
+++ b/latest.cgi
@@ -14,7 +14,7 @@ require 'header'
puts header_bdg()
cgi=$cgi
-if cgi['page'] =~ /\d*/
+if cgi['page'] =~ /\d+/
current_page = cgi['page'].to_i
else
current_page = 1
@@ -27,13 +27,27 @@ puts <<HTML_BDG
<table id="milieu">
<tr>
<td id="gauche"><h1><a href="latest.cgi">Dernières blagues ajoutés</a></h1>
- <div id="page">
+
+ <div id="pageq">
+ <form method="get" action="latest.cgi">
+ <fieldset>
+ <input type="submit" value="&gt;&gt;" />
+ <input type="text" name="page" size="15" />
+ </fieldset>
+ </form>
+ </div>
+ <div id="page">
+
HTML_BDG
-num_bdg = 0
-db.execute("SELECT count(id) FROM blague").each { |row| num_bdg = row[0].to_i }
+num_page = 0
+db.execute("SELECT count(id) FROM blague").each { |row| num_page = row[0].to_s.chop.to_i+1 }
+
+if current_page > num_page then
+ current_page = num_page
+end
+
-num_page = ((num_bdg+11)/10+1)
i = 0
if current_page > 5 then
i = current_page
@@ -77,7 +91,7 @@ puts"
</div>"
i = 0
-db.execute("SELECT * FROM blague WHERE id < ((SELECT id FROM blague ORDER BY id DESC LIMIT 1)-#{(current_page*10)-11}) ORDER BY id DESC LIMIT 10").each { |row|
+db.execute("SELECT * FROM blague WHERE id <= #{current_page-1}9 AND id >= #{current_page-1}0 ORDER BY id DESC LIMIT 10").each { |row|
unless row[1] == ""
if i.modulo(2) == 1
parity = " impair"