";
}
else {
$pickcat = "";}
// select next picture from the database
if (isset($who)) {
$result = mysql_query("SELECT id FROM $imagetable WHERE name = '$who' order by average desc LIMIT 1");
$id = mysql_result($result,0,"id");
}
if ($id > 0){
$result = mysql_query("SELECT * FROM $imagetable WHERE id = '$id' LIMIT 1");
$rowz =mysql_num_rows($result);
if ($rowz < 1) $id = 0;
}
if ($id > 0) {
$query = "SELECT * FROM $imagetable WHERE id = '$id' LIMIT 1";
$counter = 0;
$result = mysql_query("SELECT id FROM $imagetable WHERE status = 'active' order by id DESC");
while ($row = mysql_fetch_array ($result)) {
if ($row["id"] == $id) { break; }
$counter++;
}
$rnum = $counter;
}
else {
srand ((double)microtime()*1000000);
if ($c == "all") {
if (($order == "loop")&& (isset($rnum))) {
$result = mysql_query("SELECT id FROM $imagetable WHERE status = 'active' and category = '{$categories[0]}' order by id DESC");
$rnum++;
$rowz = mysql_num_rows($result);
if ($rowz < 1) {
langerrors();print NOIMAGES;
exit;
}
if ($rnum >= $rowz) $rnum = 0;
}
else {
$result = mysql_query("SELECT id FROM $imagetable WHERE status = 'active' and category = '{$categories[0]}'");
$rowz = mysql_numrows($result);
if ($rowz < 1) {langerrors();print NOIMAGES; exit;}
$rnum = rand() % $rowz;
}
$query = "SELECT * FROM $imagetable WHERE id = ";
$query .= mysql_result($result,$rnum,"id");
}
else {
// query for specific category
$result = mysql_query("SELECT id FROM $imagetable WHERE category = '{$categories[0]}' AND status = 'active' order by name");
$rowz = mysql_numrows($result);
if ($rowz < 1) {langerrors();print NOIMAGES; exit;}
if (($order == "loop")&& (isset($rnum))) {
$rnum++;
if ($rnum >= $rowz) $rnum = 0;
}
else
$rnum = rand() % $rowz;
$query = "SELECT * FROM $imagetable WHERE id = ";
$query .= mysql_result($result,$rnum,"id");
}
}
$result=mysql_query($query);
$newuser=mysql_fetch_array($result);
$newid =$newuser["id"];
$newmember=$newuser["name"];
$newurl =$newuser["url"];
$category =$newuser["category"];
$resize =$newuser["resize"];
$description =$newuser["description"];
// Loads id # of user's other images in $imgresult
// the next two lines can be removed if you don't use this feature
$imgresult=mysql_query("SELECT id FROM $imagetable WHERE name='$newmember'");
$numimages = mysql_num_rows($imgresult);
$userresult = mysql_query("SELECT * FROM $usertable WHERE name= '$newmember'") or die(mysql_error());
$newinfo=mysql_fetch_array($userresult);
/* delete this line to add the $homepage variable
$result2 = mysql_query("SELECT homepage FROM $usertable WHERE name= '$newmember'");
$homepage = mysql_result($result2,0,"homepage");
delete this line to add the $homepage variable */
if ($reportauto == "yes")
$autoreport = " name=userImage onAbort=\"document.reportForm.submit()\" onError=\"document.reportForm.submit()\"";
if($resize == "yes")
$newimage = "\n";
else {
$newimage = "\n";
}
if($max_width > 0 && (ereg( "[4-9]\.[0-9]\.[5-9].*", phpversion() ) || ereg("[4-9]\.[1-9]\.[0-9].*", phpversion() ) ) ) {
list($image_width,$image_height) = GetImageSize($newurl);
list($displaywidth,$displayheight) = resizepic($image_width,$image_height);
$newimage = "\n";
}
if ($commentson > 0) {
// get sample comments for user
if ($commentson == 1)
$mailresult=mysql_query("SELECT * FROM $commenttable WHERE name='$newid' and status='ok' ORDER BY id DESC LIMIT $samplecomments");
else
$mailresult=mysql_query("SELECT * FROM $commenttable WHERE name='$newid' ORDER BY id DESC LIMIT $samplecomments");
$samplecomments = mysql_num_rows($mailresult);
if ($samplecomments == 0) {
$samples = NOCOMMENTS;
$samples .= "