INT, 'cpage' => INT, 'date' => INT));
typecast($_REQUEST, array('cat' => INT, 'final' => STRING, 'preview' => STRING, 'ppuser' => INT,
'what' => STRING, 'name' => STRING, 'condition' => STRING, 'keywords' => STRING,
'cats' => STRING, 'whenterm' => STRING, 'when' => INT));
authenticate();
if ( $Globals['ppboards'] == "closed" && $User['adminedit'] != 1 )
{
diewell( $Globals['closedmsg'] );
}
if ( $Globals['searchreg'] && $User['userid'] == 0 )
{
diewell( $Globals['pp_lang']['searchreg'] );
}
$ipaddress = addslashes( findenv("REMOTE_ADDR") );
topmenu();
if ( $searchid )
{
$squery = ppmysql_query("SELECT idlist,searchtype,searchterms,numresults,preview,searchdate FROM {$Globals['pp_db_prefix']}searchids WHERE searchid=$searchid LIMIT 1", $link);
$sresult = mysql_fetch_assoc($squery);
if ( !$sresult['idlist'] )
{
diewell( $Globals['pp_lang']['searchid'] );
}
$sresults = explode( ",", $sresult['idlist'] );
$numresults = $sresult[numresults];
$sterms = explode(" ", trim($sresult['searchterms']));
$keyhtml = htmlspecialchars( $sresult['searchterms'] );
$stype = $sresult['searchtype'];
if ( $keyhmtl ) $keyhtml = "( $keyhtml )";
$searchtype = $Globals['pp_lang']['callimages'];
if ( $sresult['searchtype'] == "f" )
{
list( $tuserid, $tusername, $tmail ) = get_userinfo( "", $User['userid']);
$searchtype = "$tusername {$Globals['pp_lang']['favorites']}";
}
elseif ( $sresult['searchdate'] == "1-d" )
{
$searchtype = $Globals['pp_lang']['clastday'];
}
elseif ( $sresult['searchdate'] == "1-w" )
{
$searchtype = $Globals['pp_lang']['clast7'];
}
elseif ( $sresult['searchdate'] == "2-w" )
{
$searchtype = $Globals['pp_lang']['clast14'];
}
elseif ( $sresult['searchdate'] > 0 )
{
$searchtype = formatppdate( $sresult['searchdate'] );
}
if ( $pperpage > 0 )
{
$pages = ($numresults/$pperpage);
}
else
{
$pperpage = ($Globals['thumbcols'] * 5);
$pages = ($numresults/$pperpage);
}
$pwidth = intval(100 / $Globals['thumbcols']);
if ( intval($pages) < $pages )
{
$pages = intval($pages)+1;
}
else
{
$pages = intval($pages);
}
if ( $cpage )
{
$cstartnumb = ($cpage*$pperpage)-$pperpage;
}
else
{
$cpage = 1;
$cstartnumb = 0;
}
$idlist = null; $limitq = 0;
for ( $x = $cstartnumb; $x < ($cstartnumb+$pperpage); $x++ )
{
if ( $sresults[$x] )
{
$idlist .= ( $idlist ? "," : "" ). $sresults[$x];
$limitq++;
}
}
if ( !$limitq || !$idlist )
{
diewell( $Globals['pp_lang']['nophotos'] );
}
$mcheck = true;
if ( $Globals['mature'] )
{
$mcheck = false;
if ( $User['userid'] )
{
$mcheck = $User['mature'];
}
}
if ( $stype == "p" || $stype == "f" )
{
$getsearch = ppmysql_query("SELECT id,user,userid,date,bigimage,cat,storecat,rating,title,description,ismature FROM {$Globals['pp_db_prefix']}photos WHERE id IN ($idlist) LIMIT $limitq", $link);
}
else
{
$getsearch = ppmysql_query("SELECT c.id,c.username,c.userid AS comuserid,c.date,c.rating,c.comment AS description,c.cat,c.photo,p.bigimage,p.cat,p.storecat,p.user,p.userid,p.title,p.ismature FROM {$Globals['pp_db_prefix']}comments c
LEFT JOIN {$Globals['pp_db_prefix']}photos p ON p.id=c.photo WHERE c.id IN ($idlist) LIMIT $limitq", $link);
}
$itemcnt = 0;
while( $getphoto = mysql_fetch_assoc($getsearch) )
{
if ( ($getphoto[ismature] == 1 && $mcheck) || $getphoto[ismature] == 0 )
{
$results['cid'][$itemcnt] = $getphoto[id];
$getphoto['savetitle'] = $getphoto[title];
if ( $sresult[searchtype] == "p" || $sresult[searchtype] == "f" )
{
$conurl = construct_newppurl( "showphoto.php", array('photo' => $getphoto['id'], 'title' => $getphoto['savetitle'], 'cat' => $getphoto['cat']) );
}
else
{
$conurl = construct_newppurl( "showphoto.php", array('photo' => $getphoto['photo'], 'title' => $getphoto['savetitle'], 'cat' => $getphoto['cat']) );
}
$ucuser[$itemcnt] = "$getphoto[user]";
$cuserid[$itemcnt] = $getphoto[userid];
$imgtime[$itemcnt] = formatpptime( $getphoto[date] );
$imgdate[$itemcnt] = formatppdate( $getphoto[date] );
if ($getphoto[rating] > 0 && $Globals['allowrate'] )
{
$ratingdisp[$itemcnt] = "
{$Globals['pp_lang']['rating']}: $getphoto[rating] ";
}
else
{
$ratingdisp[$itemcnt] = null;
}
reset($sterms);
foreach($sterms as $key)
{
$key = trim(addslashes($key));
if ( $key )
{
$getphoto[description] = preg_replace( "/($key)/i", "[i]$1[/i]", $getphoto[description] );
$getphoto[title] = preg_replace( "/($key)/i", "[i]$1[/i]", $getphoto[title] );
}
}
$getphoto[title] = ( strlen($getphoto[title]) > 22 ? substr($getphoto[title],0,22)."..." : $getphoto[title] );
$getphoto[title] = convert_markups($getphoto[title]);
if ( $getphoto[title] )
{
$getphoto[title] = "$getphoto[title] ";
}
if ( $sresult[searchtype] == "c" )
{
$getphoto[title] .= "({$Globals['pp_lang']['commentby']} ". htmlspecialchars($getphoto[username]) .")";
}
if ( $getphoto[title] )
{
$getphoto[title] .= "
";
}
$restitle[$itemcnt] = convert_returns($getphoto[title]);
if ( VB3_ENHANCEDINT == "on" )
{
$getphoto[description] = convert_markups(un_htmlspecialchars($getphoto[description]));
}
else
{
$getphoto[description] = convert_markups($getphoto[description]);
}
$restext[$itemcnt] = convert_returns($getphoto[description]);
$ccat[$itemcnt] = $getphoto[cat];
$cphoto[$itemcnt] = $getphoto[id];
$thumbrc[$itemcnt] = null;
if ( $sresult[preview] == 1 )
{
if ( $getphoto[storecat] )
{
$getphoto[cat] = $getphoto[storecat];
}
$thisthumb = get_imagethumb( $getphoto[bigimage], $getphoto[cat], $getphoto[userid], 1 );
if ( $sresult[searchtype] == "p" || $sresult[searchtype] == "f" )
{
$conurl = construct_newppurl( "showphoto.php", array('photo' => $getphoto['id'], 'title' => $getphoto['savetitle'], 'cat' => $getphoto['cat']) );
}
else
{
$conurl = construct_newppurl( "showphoto.php", array('photo' => $getphoto['photo'], 'title' => $getphoto['savetitle'], 'cat' => $getphoto['cat']) );
}
$thumbrc[$itemcnt] = "$thisthumb
";
}
$itemcnt++;
}
}
$more = $less = " ";
if ( $cpage != $pages && $pages > 1 )
{
$nextpage = $cpage+1;
$more = "{$Globals['pp_lang']['nextpage']}";
}
if ( $cpage > 1 )
{
$prevpage = $cpage-1;
$less = "{$Globals['pp_lang']['prevpage']}";
}
$numrows = floor($itemcnt / $Globals[thumbcols]);
$numblank = $Globals[thumbcols] - ($itemcnt - ($numrows * $Globals[thumbcols]));
$blanks = null;
if ( $numblank > 0 && $numblank != $Globals[thumbcols] )
{
for ( $z=0; $z < $numblank; $z++ ) {
$blanks .= "