STRING, 'sl' => STRING, 'name' => STRING, 'ppuser' => INT, 'cat' => INT,
'limit' => STRING, 'catp' => STRING,'page' => INT,'perpage' => INT,'sort' => INT, 'page' => INT));
// Set cookies first
if ( $perpage || $sort || $sl )
{
// perpage, sortby, sorttime, way, thumbsonly, sort, sl
if ( !$perpage ) $perpage = 12;
$setcookie = serialize( array( $perpage, $sortby, $sorttime, $way, $thumbsonly, $sort, $sl ) );
@setcookie( "ppperpage", $setcookie, 0, $Globals['cookie_path'], $Globals['domain_path'] );
}
else
{
// perpage, sortby, sorttime, way, thumbsonly
typecast($_COOKIE, array('ppperpage' => STRING));
if ( $ppperpage )
{
list( $perpage, $sortby, $sorttime, $way, $thumbsonly, $sort, $sl ) = unserialize( un_htmlspecialchars($ppperpage) );
}
}
// Init some variables
if ( !isset($cat) ) $cat = 500;
authenticate();
if ( $Globals['ppboards'] == "closed" && $User['adminedit'] != 1 )
{
diewell( $Globals['closedmsg'] );
}
if ( is_numeric($cat) )
{
$ctitleq = ppmysql_query("SELECT catname,thumbs,cattype,parent,theme,sortorder,frames,intro,introtitle,introcopy,ratingtype,takevotes
FROM {$Globals['pp_db_prefix']}categories WHERE id=$cat", $link);
if ( !$ctitleq )
{
diewell( $Globals['pp_lang']['noview'] );
}
list( $thecatname, $catthumbs, $cattype, $catparent, $cattheme, $catsortorder, $frames, $hasintro, $introtitle, $introcopy, $ratingtype, $takevotes ) = mysql_fetch_row($ctitleq);
ppmysql_free_result( $ctitleq );
if ( !preg_match("/([\<])([^\>]{1,})*([\>])/i", $introtitle) )
{
$introtitle = preg_replace("/(\r\n|\r|\n)/i","
",$introtitle);
}
if ( !preg_match("/([\<])([^\>]{1,})*([\>])/i", $introcopy) )
{
$introcopy = preg_replace("/(\r\n|\r|\n)/i","
",$introcopy);
}
if ( $cattype == "a" )
{
$titlereplace = "$tusername's {$Globals['pp_lang']['persalbum']}";
$catthumbs = "yes";
}
// Nonstandard theme
if ( !empty($cattheme) )
{
$Globals['theme'] = $cattheme;
if ( is_dir( "{$Globals['PP_PATH']}/stylesheets/{$Globals['theme']}" ) )
{
$Globals['idir'] = "{$Globals['maindir']}/stylesheets/{$Globals['theme']}";
}
}
// Non standard frames
if ( !empty($frames) )
{
unset( $Globals['thumbstd'] );
include( "{$Globals['PP_PATH']}/{$Globals['TMPL_PATH']}/$frames.tmpl" );
}
is_cat_protected( $cat, $catp, $cattype );
if ( $User['userid'] > 0 && $Globals['displaynew'] == "yes" )
{
$lasttimeon = time();
$resultb = ppmysql_query("REPLACE INTO {$Globals['pp_db_prefix']}laston VALUES('$cat','{$User['userid']}','$lasttimeon')", $link);
}
}
$perpage1x = $Globals['thumbcols'];
$perpage3x = ($perpage1x * 3);
$perpage4x = ($perpage1x * 4);
$perpage5x = ($perpage1x * 5);
$perpage6x = ($perpage1x * 6);
if ( $perpage )
{
if ( $perpage > 90 ) {
$perpage = 90;
}
if ($perpage < $perpage1x) {
$perpage = $perpage1x;
}
}
else
{
if ( isset($ppperpage) )
{
$perpage = $ppperpage;
}
else
{
$perpage = ($Globals['thumbcols'] * $Globals['thumbrows']);
}
}
if ( isset($page) && $page > 0 )
{
$startnumb = ($page*$perpage)-$perpage+1;
}
else
{
$page = 1;
$startnumb = 1;
}
// do the sort box //
$sortoptions = null;
$sortdefault="";
// This is the default sort (4 = Alphabetical)
if ( empty($sort) )
{
$sortparam = ( isset($catsortorder) && $catsortorder > 0 ? $catsortorder : 4 );
}
else
{
$sortparam = ( isset($sort) && $sort > 0 ? $sort : 4 );
}
$resultc = ppmysql_query("SELECT * FROM {$Globals['pp_db_prefix']}sortmemb", $link);
while ( list($sortid, $sortname, $sortc) = mysql_fetch_row($resultc) )
{
if ( $sortparam != $sortid )
{
$sortoptions .= "";
}
else
{
$sortdefault = "";
$sortcode = "$sortc";
}
if ( $sortdefault == "" )
{
$sortdefault = "";
}
}
ppmysql_free_result( $resultc );
$sort = "";
// end sort box //
$datecheck = null;
if ( !empty($limit) )
{
if ( $limit == "all" )
{
$thecatname = $Globals['pp_lang']['callimages'];
$days = 0;
}
elseif ( $limit == "last1" )
{
$thecatname = $Globals['pp_lang']['clastday'];
$days = 1;
}
elseif ( $limit == "last7" )
{
$thecatname = $Globals['pp_lang']['clast7'];
$days = 7;
}
elseif ( $limit == "last14" )
{
$thecatname = $Globals['pp_lang']['clast14'];
$days = 14;
}
if ( $days > 0 )
{
$timeq = time() - (($days * 24) * 3600);
$datecheck = " p.date > $timeq ";
}
}
elseif ( !empty($date) )
{
$thisdate = getdate($date);
$thismonth = $thisdate['mon'];
$thisyear = $thisdate['year'];
$thisday = $thisdate['mday'];
$lowdate = mktime(0, 0, 0, $thismonth, $thisday, $thisyear);
$highdate = mktime(0, 0, 0, $thismonth, $thisday+1, $thisyear);
$datecheck = " p.date >= $lowdate AND p.date < $highdate";
}
printheader( $cat, $thecatname );
childsub($cat);
$childnav = "{$Globals['pp_lang']['home']} $childnav";
topmenu();
if ( $Globals['features'] == "yes" && $ppuser )
{
if ( $Globals['mostrecent'] == "yes" && $Globals['recentdefault'] == "no" )
{
display_gallery("latest", $ppuser);
}
list( $tuserid, $tname, $tmail ) = get_userinfo( "", $ppuser);
}
elseif ( $Globals['features'] == "yes" && ($Globals['mostrecent'] == "yes" && $Globals['recentdefault'] == "no") )
{
display_gallery("latest", "", $cat);
}
// If we're not in the member gallery cat, then print thumbs..
// Otherwise, print a list of users.
$phrase = null;
if ( !empty($si) )
{
$sterms = trim($si);
$searchterms = explode(" ", $sterms);
$htmlsi = htmlspecialchars($si);
$scount=0;
$totalterms = count($searchterms);
$totalterms++;
foreach ( $searchterms as $key )
{
$scount++;
if ($scount > 1)
{
$phrase .= " AND ";
}
$phrase .= "(p.user LIKE '%$key%')";
}
if ( $phrase )
{
$phrase = "WHERE $phrase";
}
}
if ( $datecheck && $phrase )
{
$phrase .= " AND $datecheck";
}
elseif ( !$phrase && $datecheck )
{
$phrase = "WHERE $datecheck";
}
if ( isset($sl) && !empty($sl) )
{
if ( empty($phrase) )
{
$phrase = "WHERE p.user LIKE '$sl%'";
}
else
{
$phrase .= " AND p.user LIKE '$sl%'";
}
}
if ( is_numeric($cat) && $cat != 500 )
{
if ( empty($phrase) )
{
$phrase .= "WHERE ";
}
else
{
$phrase .= "AND ";
}
$phrase .= "p.cat=$cat";
}
elseif ( is_numeric($cat) && $cat == 500 )
{
if ( empty($phrase) )
{
$phrase .= "WHERE ";
}
else
{
$phrase .= "AND ";
}
$phrase .= "p.approved=1";
}
if ( $Globals['membthumb'] == "yes" && $cat == 500 )
{
$queryz = ppmysql_query("SELECT p.id, p.date, p.user, p.userid, SUM(p.views) AS tviews, COUNT(*) AS pcount, SUM(p.numcom) as numcom,
MAX(p.lastpost) AS maxlast, MAX(p.date) AS maxdate, SUM(p.filesize) AS tfilesize,
u.lastphoto, u.lastdate,
p2.bigimage, p2.cat, p2.storecat, p2.height, p2.width, p2.ismature
FROM {$Globals['pp_db_prefix']}photos p
LEFT JOIN {$Globals['pp_db_prefix']}users u ON (u.userid=p.userid)
LEFT JOIN {$Globals['pp_db_prefix']}photos p2 ON (p2.id=u.lastphoto)
$phrase
GROUP BY p.userid $sortcode", $link);
}
else
{
$queryz = ppmysql_query("SELECT p.id, p.date, p.user, p.userid, SUM(p.views) AS tviews, COUNT(*) AS pcount, SUM(p.numcom) as numcom,
MAX(p.lastpost) AS maxlast, MAX(p.date) AS maxdate, SUM(p.filesize) AS tfilesize
FROM {$Globals['pp_db_prefix']}photos p
$phrase
GROUP BY p.userid $sortcode", $link);
}
$rowcnt = mysql_num_rows($queryz);
if ( $posternav )
{
$posternav = "
$posternav
";
}
$noresults = null;
if ( $rowcnt == 0 )
{
$noresults = "