0)"; } else { $sql= "SELECT p.pid FROM $prefix"._gallery_pictures." AS p, $prefix"._gallery_categories." AS c WHERE (c.gallid=p.gid) AND (c.visible > 1)"; } mt_srand((double)microtime()*1000000); $result = $db->sql_query($sql); $total = $db->sql_numrows($result); $p = mt_rand(0,($total - 1)); if (is_user($user)) { $sql= "SELECT p.*, c.galloc FROM $prefix"._gallery_pictures." AS p, $prefix"._gallery_categories." AS c WHERE (c.gallid=p.gid) AND (c.visible > 0) LIMIT $p, 1"; } else { $sql= "SELECT p.*, c.galloc FROM $prefix"._gallery_pictures." AS p, $prefix"._gallery_categories." AS c WHERE (c.gallid=p.gid) AND (c.visible > 1) LIMIT $p, 1"; } $result = $db->sql_query($sql); $pic = $db->sql_fetchrow($result); $pic['description'] = substr($pic['description'],0,255); $galloc = $pic['galloc']; $img = $pic['img']; $default_thumb = 0; $ext = substr($img, (strrpos($img,'.') + 1)); if (file_exists("$gallerypath/$galloc/thumb/$img")) { $thumb = "$gallerypath/$galloc/thumb/$img"; } else { $row = $db->sql_fetchrow($db->sql_query("SELECT thumbnail from $prefix"._gallery_media_types." where extension='$ext'")); $thumb = "$imagepath/$row[thumbnail]"; $default_thumb = 1; } if (strlen($pic[name]) > 12) { $pic[name] = substr($pic[name],0,10).".."; } $sdate = strftime("%d/%m/%Y",strtotime($pic[date])); if ($default_thumb) { $content = "