INT, 'catp' => STRING, 'votecontrol' => STRING, 'sortby' => STRING, 'sorttime' => INT, 'way' => STRING, 'thumbsonly' => INT, 'perpage' => INT, 'page' => INT));
if ( $perpage )
{
// perpage, sortby, sorttime, way, thumbsonly
$setcookie = serialize( array( $perpage, $sortby, $sorttime, $way, $thumbsonly, $sort, $sl ) );
@setcookie( "ppperpage", $setcookie, 0, $Globals['cookie_path'], $Globals['domain_path'] );
}
if ( $votecontrol )
{
$setvotes = "$votecontrol-$id";
@setcookie( "ppvote", $setvotes, 0, "{$Globals['cookie_path']}", $Globals['domain_path'] );
}
if ( isset($catp) )
{
@setcookie( "catp", $catp, 0, "{$Globals['cookie_path']}", $Globals['domain_path'] );
$GLOBALS['catp'] = $catp;
}
}
if ( $id > 0 )
{
$cat = $id;
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: '. construct_newppurl( "showgallery.php", array('cat' => $id, 'ppuser' => $ppuser) ) );
exit;
}
}
typecast($_REQUEST, array('si' => STRING, 'name' => STRING, 'cat' => STRING, 'catp' => STRING, 'page' => INT,
'ppuser' => INT, 'what' => STRING, 'when' => STRING, 'whenterm' => STRING,
'thumbcheck' => INT, 'votecontrol' => STRING, 'quickjump' => STRING, 'sortby' => STRING,
'sorttime' => INT, 'thumbsonly' => INT, 'perpage' => INT, 'way' => STRING
));
if ( $quickjump == "Go" )
{
unset($what, $sorttime, $when, $way, $shortby, $thumbsonly);
}
// Set cookies first
if ( $perpage || $sort || $sl )
{
// perpage, sortby, sorttime, way, thumbsonly, sort, sl
$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) || empty($cat) && $ppuser ) $cat = "500";
elseif ( !isset($cat) || empty($cat) && !$ppuser ) $cat = "all";
if ( !isset($page) ) $page = 1;
if ( !isset($what) || empty($what) ) $what = "allfields";
// Do we need to set password or get last used password?
if ( isset($catp) )
{
@setcookie( "catp", $catp, 0, "{$Globals['cookie_path']}", $Globals['domain_path'] );
$GLOBALS['catp'] = $catp;
}
else
{
typecast($_COOKIE, array('catp' => STRING));
}
if ( !$ppuser && ($cat == 500 || $cat == MOBILE_CAT) )
{
// They shouldnt be here if they didnt give us a valid user, send em to showmembers
header( "Location: {$Globals['maindir']}/showmembers.php" );
exit;
}
// Let do this....
authenticate();
if ( $Globals['ppboards'] == "closed" && $User['adminedit'] != 1 )
{
diewell( $Globals['closedmsg'] );
}
$catinfo = array( 'intro' => 'no', 'thumbtype' => 0);
if ( is_numeric($cat) )
{
$ctitleq = ppmysql_query("SELECT c.id,c.catname,c.description,c.thumbs,c.cattype,c.parent,c.theme,c.thumbtype,
c.sortorder,c.frames,c.intro,c.introtitle,c.introcopy,c.ratingtype,c.takevotes,c.ismember,n.userid AS notify
FROM {$Globals['pp_db_prefix']}categories c
LEFT JOIN {$Globals['pp_db_prefix']}notify n ON (n.userid='{$User['userid']}' AND n.photo=c.id AND n.type=1)
WHERE c.id=$cat", $link);
$catinfo = mysql_fetch_assoc($ctitleq);
if ( !$catinfo['id'] )
{
diewell( $Globals['pp_lang']['noview'] );
}
if ( (($catinfo['ismember'] == 1 || $thumbsonly == 3) || (!$thumbcheck && $catinfo['thumbtype'] == 3)) && empty($ppuser) )
{
// They shouldnt be here if they didnt give us a valid user, send em to showmembers
header( "Location: {$Globals['maindir']}/showmembers.php?cat={$catinfo['id']}&date=$date" );
exit;
}
if ( !preg_match("/([\<])([^\>]{1,})*([\>])/i", $catinfo['introtitle']) )
{
$catinfo['introtitle'] = preg_replace("/(\r\n|\r|\n)/i","
", $catinfo['introtitle']);
}
if ( !preg_match("/([\<])([^\>]{1,})*([\>])/i", $catinfo['introcopy']) )
{
$catinfo['introcopy'] = preg_replace("/(\r\n|\r|\n)/i","
", $catinfo['introcopy']);
$catinfo['introcopy'] = convert_markups( $catinfo['introcopy'] );
}
if ( $catinfo['cattype'] == "a" )
{
$titlereplace = "$tusername's {$Globals['pp_lang']['persalbum']}";
$catinfo['thumbs'] = true;
}
// Nonstandard theme
if ( $catinfo['theme'] && !$Globals['forumstyle'] )
{
//$Globals['theme'] = $catinfo['theme'];
if ( is_dir( "{$Globals['PP_PATH']}/stylesheets/{$Globals['theme']}" ) )
{
//$Globals['idir'] = "{$Globals['maindir']}/stylesheets/{$Globals['theme']}";
}
}
// Non standard frames
if ( !empty($catinfo['frames']) )
{
unset( $Globals['thumbnail'] );
$Globals['thumbnail'] = $catinfo['frames'];
unset( $Globals['thumbstd'] );
include( "$Globals[tmpldir]/{$catinfo['frames']}.tmpl" );
}
is_cat_protected( $cat, $catp, $catinfo['cattype'] );
if ( $User['userid'] > 0 && $Globals['displaynew'] )
{
$lasttimeon = time();
$resultb = ppmysql_query("REPLACE INTO {$Globals['pp_db_prefix']}laston VALUES('$cat', '{$User['userid']}', '$lasttimeon')", $link);
}
$ismod = false;
if ( $catinfo['ratingtype'] == 1 )
{
typecast($_COOKIE, array('ppvote' => STRING));
if ( $ppvote )
{
$parts = explode("-", $ppvote);
$votecheck = $parts[0];
$votecat = $parts[1];
if ( $votecat == $cat )
{
$votecontrol = $votecheck;
}
}
if ( !$sortby )
{
if ( $catinfo['takevotes'] == 0 )
{
$sortby = "b";
$catinfo['sortorder'] = 4;
}
elseif ( $catinfo['takevotes'] == 1 )
{
$sortby = "x";
$catinfo['sortorder'] = 4;
}
else
{
$sortby = "r";
$catinfo['sortorder'] = 6;
}
}
if ( $User['userid'] > 0 )
{
// Voting controls
if ( $User['adminedit'] == 1 || $User['moderator'] == 1 )
{
$ismod = true;
if ( $User['moderator'] == 1 )
{
$ismod = is_moderator($cat);
}
}
if ( isset($votecontrol) && $ismod )
{
if ( $votecontrol == "enable" )
{
// enable and set order to random
$updateq = ppmysql_query("UPDATE {$Globals['pp_db_prefix']}categories SET takevotes=1,sortorder=6 WHERE id=$cat", $link);
$catinfo['takevotes'] = 1;
setcookie( "ppvote", "", time()-3600, $Globals['cookie_path'], $Globals['domain_path'] );
}
elseif ( $votecontrol == "disable" )
{
// disable and set order to highest rated
$updateq = ppmysql_query("UPDATE {$Globals['pp_db_prefix']}categories SET takevotes=0,sortorder=4 WHERE id=$cat", $link);
$catinfo['takevotes'] = 0;
setcookie( "ppvote", "", time()-3600, $Globals['cookie_path'], $Globals['domain_path'] );
}
elseif ( $votecontrol == "end" )
{
// disable and set order to highest rated
$updateq = ppmysql_query("UPDATE {$Globals['pp_db_prefix']}categories SET takevotes=2,sortorder=4 WHERE id=$cat", $link);
$catinfo['takevotes'] = 2;
setcookie( "ppvote", "", time()-3600, $Globals['cookie_path'], $Globals['domain_path'] );
}
elseif ( $votecontrol == "reset" )
{
$updateq = ppmysql_query("UPDATE {$Globals['pp_db_prefix']}photos SET votes=0 WHERE cat=$cat", $link);
$updateq = ppmysql_query("DELETE FROM {$Globals['pp_db_prefix']}comments WHERE cat=$cat AND votes=1", $link);
setcookie( "ppvote", "", time()-3600, $Globals['cookie_path'], $Globals['domain_path'] );
}
}
// Grab the image they voted on (if they voted)
$result = ppmysql_query("SELECT photo FROM {$Globals['pp_db_prefix']}comments WHERE cat=$cat AND userid={$User['userid']} AND votes=1", $link);
$hasvoted = mysql_num_rows($result);
list( $uservoted ) = mysql_fetch_row($result);
}
}
}
else
{
if ( $thumbsonly == 3 && empty($ppuser) )
{
// They shouldnt be here if they didnt give us a valid user, send em to showmembers
header( "Location: {$Globals['maindir']}/showmembers.php?cat=$cat" );
exit;
}
}
if ( $thumbsonly != 3 )
{
$thumbsonly = ( isset($thumbsonly) ? $thumbsonly : $catinfo['thumbtype'] );
}
$perpage1x = $Globals['thumbcols'];
$perpage3x = ($perpage1x * 3);
$perpage4x = ($perpage1x * 4);
$perpage5x = ($perpage1x * 5);
$perpage6x = ($perpage1x * 6);
// Force a contest catgeory to show all images on one page
if ( $catinfo['ratingtype'] == 1 )
{
unset($page);
$perpage = 1000000;
}
else
{
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 //
$catrows = $sortcode = null;
if ( empty($sortby) && is_numeric($cat) )
{
$sortparam = ( isset($catinfo['sortorder']) && $catinfo['sortorder'] > 0 ? $catinfo['sortorder'] : 1 );
$resultc = ppmysql_query("SELECT * FROM {$Globals['pp_db_prefix']}sort WHERE sortid=$sortparam", $link);
list($sortid, $sortname, $sortcode, $sortby, $way) = mysql_fetch_row($resultc);
}
else
{
$sortcode = "ORDER BY disporder,date DESC";
}
$subcats = $seemore = null;
if (!empty($ppuser))
{
if ( $cat == 500 || $cat == MOBILE_CAT )
{
list( $tuserid, $tusername, $tmail ) = get_userinfo( "", $ppuser);
$catinfo['catname'] = "$tusername {$Globals['pp_lang']['gallery']}";
$titlereplace = "$tusername's {$Globals['pp_lang']['gallery']}";
if ( !$Globals['memformat'] )
{
$seemore = "{$Globals['pp_lang']['tosee']} $tusername's {$Globals['pp_lang']['littlephotos']}";
}
}
elseif ( $catinfo['cattype'] == "a" )
{
list( $tuserid, $tusername, $tmail ) = get_userinfo( "", $ppuser);
$catinfo['catname'] = "$tusername {$Globals['pp_lang']['album']}";
$titlereplace = "$tusername {$Globals['pp_lang']['album']}";
}
}
$fillercode = $albumfiller = " ";
$albblanks = $subblanks = null;
// Don't do these if we are not on page 1
$subalbums = $albums = array();
if ( $page == 1 )
{
$x = 0;
if ( !empty($ppuser) )
{
$arows = ppmysql_query("SELECT c.id,c.parent,c.catname,c.description,c.photos,c.private,
p.bigimage, p.cat, p.storecat, p.approved, p.width, p.height, p.userid,
p2.bigimage AS thumbnail, p2.cat AS thumbcat, p2.storecat AS thumbstore, p2.userid AS thumbuserid
FROM {$Globals['pp_db_prefix']}categories c
LEFT JOIN {$Globals['pp_db_prefix']}photos p ON p.id=c.lastphoto
LEFT JOIN {$Globals['pp_db_prefix']}photos p2 ON p2.id=c.thumbnail
WHERE ( c.parent=$ppuser AND c.cattype='a' AND c.photos > 0 AND c.subalbum=0 ) ORDER BY catorder ASC", $link);
while ( $album = mysql_fetch_assoc($arows) )
{
$albumlink = construct_newppurl( "showgallery.php", array('cat' => $album['id']) );
if ( $album['private'] == "no" || $User['userid'] == $album['parent'] || $User['adminedit'] == 1 )
{
if ( !empty($album['thumbnail']) )
{
if ( $album['thumbstore'] != 0 )
{
$album['thumbcat'] = $album['thumbstore'];
}
$thumbrc = get_imagethumb( $album['thumbnail'], $album['thumbcat'], $album['thumbuserid'], $album['approved'] );
}
else
{
if ( $album['storecat'] != 0 )
{
$album['cat'] = $album['storecat'];
}
$thumbrc = get_imagethumb( $album['bigimage'], $album['cat'], $album['userid'], $album['approved'] );
}
}
else {
continue;
//$thumbrc = "";
//$thumbtag = "{$Globals['idir']}/lock.jpg";
}
$albums[$x]['thumb'] = $thumbrc;
$albums[$x]['thumbtag'] = $thumbtag;
$albums[$x]['desc'] = ( empty($album['description']) ? "" : "
". $album['description'] );
$albums[$x]['desc'] .= ( $album['private'] == "no" ? "" : "
{$Globals['pp_lang']['private']}" );
$albums[$x]['name'] = $album['catname'];
$albums[$x]['photos'] = $album['photos'];
$albums[$x]['link'] = $albumlink;
$albums[$x]['private'] = $album['private'];
$albums[$x]['width'] = $album['width'];
$albums[$x]['height'] = $album['height'];
$albums[$x]['username'] = $tusername;
$memrec['userid'] = $album['parent'];
$albums[$x]['thumbnail'] = get_thumbtmpl( $id, $thumbrc, $album['height'], $album['width'], $thumbtag, $album['id'], $albumlink );
$x++;
}
ppmysql_free_result( $arows );
$numrows = floor($x / $Globals[thumbcols]);
$numblank = $Globals[thumbcols] - ($x - ($numrows * $Globals[thumbcols]));
$albblanks = null;
if ( $numblank > 0 && $numblank != $Globals[thumbcols] )
{
for ( $z=0; $z < $numblank; $z++ ) {
$albblanks .= "