Новые |
Популярные |
Поиск
";
echo "
";
echo "
";
//*************************************************************************************************
function showGalleryImage($id) {
//GET THUMBNAIL OF THE LAST IMAGE IN THE GALLERY.
$r = mysql_query("SELECT id FROM `images` WHERE galleryid = '$id' ORDER BY number DESC LIMIT 1");
if (!mysql_num_rows($r))
echo "

";
else {
$row = mysql_fetch_array($r);
$imageid = $row['id'];
echo "

";
}
}
if (isset($_GET["query"])) {
$query = $_GET["query"];
$opt = $_GET["opt"];
$max_show = 10;
$total = 0;
$found = 0;
$safe = true;
if ($session == true) {
if (isset($_GET["safe"]))
$safe = true;
else
$safe = false;
}
else
$safe = true;
if (isset($_GET["page"]))
$page = $_GET["page"];
else
$page = 1;
if ($query != "") {
if ($opt == "tags") {
if ($safe == true)
$q = "SELECT * FROM `images` WHERE ((type = 'member-public') OR (type = 'gallery') OR (type = 'public')) AND (adult = 'false')";
else
$q = "SELECT * FROM `images` WHERE (type = 'member-public') OR (type = 'gallery') OR (type = 'public')";
if(!($result_set = mysql_query($q))) die(mysql_error());
$number = mysql_num_rows($result_set);
if ($number) {
while ($row = mysql_fetch_array($result_set))
{
if ($row['type'] == "gallery") {
$galleryid = $row['galleryid'];
$result = mysql_query("SELECT type FROM `galleries` WHERE id = '$galleryid'");
$row1 = mysql_fetch_row($result);
$a = $row1[0];
if ($a == "public") {
$id[] = $row['id'];
$tags[] = $row['tags'];
$total++;
}
}
else {
$id[] = $row[0];
$tags[] = $row['tags'];
$total++;
}
}
}
if ($total) {
$found = 0;
for ($i=0; $i < $total; $i++)
{
if (stristr($tags[$i], $query) != "") {
$id1[] = $id[$i];
$found++;
}
}
$from2 = $page * $max_show;
if ($from2 > $found)
{
$diff = $found % $max_show;
$from2 = $found;
$from1 = $from2 - $diff;
}
else
$from1 = $from2 - $max_show;
if ($found != 0) {
echo "
Search Completed: Your search for '$query' returned $found results !
Page : $page
";
echo "";
//NOW PRINT THE RECORDS IN THE REQUIRED RANGE
for ($i=$from1; $i < $from2; $i++)
{
if (($i % 5) == 0) echo "
";
$idTemp = $id1[$i];
echo " ";
echo " | ";
}
echo "
";
}
}
} //$opt end
//##########################################################################################################
if ($opt == "gallery") {
//GET ALL THE GALLERIES IN AN ARRAY
$total = 0;
$q = "SELECT id, name FROM `galleries` WHERE type = 'public'";
if(!($result_set = mysql_query($q))) die(mysql_error());
$number = mysql_num_rows($result_set);
$total = $total + $number;
if ($number) {
while ($row = mysql_fetch_array($result_set))
{
$id[] = $row['id'];
$name[] = $row['name'];
}
}
if ($total) {
$found = 0;
for ($i=0; $i < $total; $i++)
{
$t = $name[$i];
if (stristr($t, $query) != "") {
$id1[] = $id[$i];
$name1[] = $name[$i];
$found++;
}
}
$from2 = $page * $max_show;
if ($from2 > $found)
{
$diff = $found % $max_show;
$from2 = $found;
$from1 = $from2 - $diff;
}
else
$from1 = $from2 - $max_show;
if ($found != 0) {
echo "
Search Completed: Your search for '$query' returned $found results !
Page : $page
";
echo "";
$x = -1;
//NOW PRINT THE RECORDS IN THE REQUIRED RANGE
for ($i=$from1; $i < $from2; $i++)
{
$x++;
if (($x % 4) == 0) echo "
";
echo "";
showGalleryImage($id1[$i]);
echo "
{$name1[$i]} | ";
}
echo "
";
}
}
else
echo "There are no public galleries to search !";
}
//**************************************************************************************************************
if ($found) {
//SHOW THE NEXT AND PREVIOUS LINKS IN A TABLE (IF REQUIRED)
echo "
";
echo "| ";
if ($from1 > 0)
{
$previous = $page - 1;
echo "<< Previous Page";
} echo " | ";
echo " ";
if ($from2 < $found)
{
$next = $page + 1;
echo "Next Page >>";
} echo " |
";
}//$found !=0
else
echo "
Sorry ! Your search for '$query' returned no results.";
}
else
echo "
Please enter some text to search.";
}
?>