From 894877084d50e48516e8eb875ac65af8771fc7d3 Mon Sep 17 00:00:00 2001 From: Laurent Raufaste Date: Sun, 12 May 2013 23:21:15 -0400 Subject: [PATCH] Let's not crap out if we don't specify a user, find a random one --- demoblog.php | 15 +++++++-------- demoglop.php | 16 +++++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/demoblog.php b/demoblog.php index 517c21a..2f21c6d 100644 --- a/demoblog.php +++ b/demoblog.php @@ -5,6 +5,13 @@ require("include/libbb.php"); require("recaptchalib.php"); $who = (int)$_GET["who"]; +if(!$who) { + $result = mysql_query("SELECT id FROM users"); + while($tmp = mysql_fetch_row($result)) { + $ids[]=$tmp[0]; + } + $who=$ids[mt_rand(0,count($ids)-1)]; +} $usercustom=$user; @@ -16,14 +23,6 @@ $nbmsg=mysql_result($result,0); if(!$page) $page=1; -if(!is_numeric($who)) { - $result = mysql_query("SELECT id FROM users"); - while($tmp = mysql_fetch_row($result)) { - $ids[]=$tmp[0]; - } - $who=$ids[mt_rand(0,count($ids)-1)]; -} - $result = mysql_query_debug("SELECT * FROM users WHERE id=".$who); $user = mysql_fetch_array($result); diff --git a/demoglop.php b/demoglop.php index 636b9a0..b267e6b 100644 --- a/demoglop.php +++ b/demoglop.php @@ -4,7 +4,13 @@ require("include/top.php"); require("include/libbb.php"); $who = (int)$_GET["who"]; -//$linebypage = $_GET["lines"]; +if(!$who) { + $result = mysql_query("SELECT id FROM users"); + while($tmp = mysql_fetch_row($result)) { + $ids[]=$tmp[0]; + } + $who=$ids[mt_rand(0,count($ids)-1)]; +} $usercustom=$user; @@ -16,14 +22,6 @@ $nbmsg=mysql_result($result,0); if(!$page) $page=1; -if(!is_numeric($who)) { - $result = mysql_query("SELECT id FROM users"); - while($tmp = mysql_fetch_row($result)) { - $ids[]=$tmp[0]; - } - $who=$ids[mt_rand(0,count($ids)-1)]; -} - $result = mysql_query_debug("SELECT * FROM users WHERE id=".$who); $user = mysql_fetch_array($result);