diff options
author | piernov <piernov@piernov.servegame.org> | 2012-10-21 21:40:48 +0200 |
---|---|---|
committer | piernov <piernov@piernov.servegame.org> | 2012-10-21 21:40:48 +0200 |
commit | 9e5495e169ef0cb888a91a1ead62bc81e1b2bdba (patch) | |
tree | 91d54cbf14deec05c027e9c204997b2c04185957 /latest.cgi | |
parent | 8a03b03fb21e168ace1c5424967d0e6ddbc6c7cc (diff) | |
download | bdg-master.tar.gz bdg-master.tar.bz2 bdg-master.tar.xz bdg-master.zip |
Diffstat (limited to 'latest.cgi')
-rwxr-xr-x | latest.cgi | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -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=">>" /> + <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" |