query_read(" SELECT catid, title, description, parent, parentlist, catimage, imagecount, postcount, lastimageid, lastimagetitle, lastimageuserid, lastimageusername, lastimagedateline, lastpostid, lastpostuserid, lastpostusername, lastpostimagetitle, lastpostdateline FROM " . TABLE_PREFIX ."adv_gallery_categories ORDER BY $vba_options[gallery_catsorderby] $vba_options[gallery_catsdirection] "); while ($categories = $vbulletin->db->fetch_array($getcats)) { if ($categories['parent'] AND !$categorycache["$categories[parent]"]['active']) { $categorycache["$categories[catid]"]['active'] = 0; continue; } if ($categoryperms["$categories[catid]"]['canviewimages'] OR $vba_options['gallery_showimagecount']) { $stats['categories']++; $stats['images'] += $categories['imagecount']; $stats['posts'] += $categories['postcount']; $categorycache["$categories[catid]"]['description'] = $categories['description']; $categorycache["$categories[catid]"]['catimage'] = $categories['catimage']; if ($categories['lastimagedateline'] > $categorycache["$categories[catid]"]['lastimagedateline']) { $categorycache["$categories[catid]"]['lastimagedateline'] = $categories['lastimagedateline']; $categorycache["$categories[catid]"]['lastimagetitle'] = $categories['lastimagetitle']; $categorycache["$categories[catid]"]['lastimageid'] = $categories['lastimageid']; $categorycache["$categories[catid]"]['lastimageusername'] = $categories['lastimageusername']; $categorycache["$categories[catid]"]['lastimageuserid'] = $categories['lastimageuserid']; } if ($categories['lastpostdateline'] > $categorycache["$categories[catid]"]['lastpostdateline']) { $categorycache["$categories[catid]"]['lastpostdateline'] = $categories['lastpostdateline']; $categorycache["$categories[catid]"]['lastpostimagetitle'] = $categories['lastpostimagetitle']; $categorycache["$categories[catid]"]['lastpostid'] = $categories['lastpostid']; $categorycache["$categories[catid]"]['lastpostusername'] = $categories['lastpostusername']; $categorycache["$categories[catid]"]['lastpostuserid'] = $categories['lastpostuserid']; } if ($categorycache["$categories[catid]"]['level'] >= $vba_options['gallery_catdepth'] AND $vba_options['gallery_showsubcats']) { $categorycache["$categories[parent]"]['subcats']["$categories[catid]"]['title'] = $categories['title']; $categorycache["$categories[parent]"]['subcats']["$categories[catid]"]['lastimagedateline'] = $categories['lastimagedateline']; $categorycache["$categories[parent]"]['subcats']["$categories[catid]"]['lastpostdateline'] = $categories['lastpostdateline']; } if ($categories['parentlist']) { foreach (explode(',', $categories['parentlist']) AS $parid) { $categorycache["$parid"]['imagecount'] += $categories['imagecount']; $categorycache["$parid"]['postcount'] += $categories['postcount']; if ($categories['lastimagedateline'] > $categorycache["$parid"]['lastimagedateline']) { $categorycache["$parid"]['lastimagedateline'] = $categories['lastimagedateline']; $categorycache["$parid"]['lastimagetitle'] = $categories['lastimagetitle']; $categorycache["$parid"]['lastimageid'] = $categories['lastimageid']; $categorycache["$parid"]['lastimageusername'] = $categories['lastimageusername']; $categorycache["$parid"]['lastimageuserid'] = $categories['lastimageuserid']; } if ($categories['lastpostdateline'] > $categorycache["$parid"]['lastpostdateline']) { $categorycache["$parid"]['lastpostdateline'] = $categories['lastpostdateline']; $categorycache["$parid"]['lastpostimagetitle'] = $categories['lastpostimagetitle']; $categorycache["$parid"]['lastpostid'] = $categories['lastpostid']; $categorycache["$parid"]['lastpostusername'] = $categories['lastpostusername']; $categorycache["$parid"]['lastpostuserid'] = $categories['lastpostuserid']; } } } } } $db->free_result($getcats); unset($categories); } if ($vba_options['gallery_allowreplies']) { $show['replycells'] = true; $stylevar['imagecount'] = 'alt2'; $stylevar['moderator'] = 'alt2'; } else { $stylevar['imagecount'] = 'alt1'; $stylevar['moderator'] = 'alt2'; } $vba_options['gallery_catdepth'] = $vba_options['gallery_catdepth_index']; // Print the categories $categorybits = print_categories(intval($catid), iif(!intval($catid), $categorycache)); require_once('./includes/functions_bigthree.php4'); $ignusers = fetch_ignored_users(); if ($ignusers) { $ignquery = 'AND images.userid NOT IN(' . $ignusers . ')'; } if (!$catid) { $show['directoryhead'] = true; if ($vba_options['gallery_showstats']) { $show['stats'] = true; $stats['categories'] = vb_number_format($stats['categories']); $stats['images'] = vb_number_format($stats['images']); $stats['posts'] = vb_number_format($stats['posts']); $getstats = $db->query_first("SELECT SUM(views) AS views, SUM(filesize) AS filesize " . iif($vba_options['gallery_saveoriginal'], ', SUM(originalfilesize) AS origfilesize') . " FROM " . TABLE_PREFIX . "adv_gallery_images WHERE valid = 1"); $stats['views'] = vb_number_format($getstats['views']); $stats['diskspace'] = make_good_size($getstats['filesize'] + $getstats['origfilesize']); } $show['category'] = iif($showfields['category'], true, false); if ($vba_options['gallery_newhomeimages'] OR $vba_options['gallery_randomhomeimages']) { include_once('./includes/class_bbcode.php4'); $bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list()); $query = fetch_image_fields(); $cellwidth = round(100 / $vba_options['gallery_columns']) . '%'; if ($privatecatids = fetch_private_categories()) { $privatecatids = explode(',', $privatecatids); } if ($vba_options['gallery_homeexcats']) { $vba_options['gallery_homeexcats'] = explode(',', $vba_options['gallery_homeexcats']); if(empty($privatecatids)) { $privatecatids = $vba_options['gallery_homeexcats']; } else { $privatecatids = array_merge($privatecatids, $vba_options['gallery_homeexcats']); } } if (!empty($privatecatids)) { $privcatids = 'images.catid NOT IN(' . implode(',', $privatecatids) . ') AND '; } } // Newest images if ($vba_options['gallery_newhomeimages']) { $show['newimages'] = true; $counter = 0; $adv_sorturl = '&catid=newimages'; $getnew = $db->query_read(" SELECT imageid, images.title, filename, thumbname, originalname, extension, images.catid $query[fields] FROM " . TABLE_PREFIX . "adv_gallery_images AS images $query[tables] WHERE $privcatids valid = 1 $ignquery ORDER BY dateline DESC LIMIT $vba_options[gallery_newhomeimages] "); if ($db->num_rows($getnew)) { while ($images = $vbulletin->db->fetch_array($getnew)) { $counter++; $newimagebits .= construct_imagebits($images); } if ($vba_options['gallery_newhomeimages'] >= $vba_options['gallery_columns']) { $newimagebits .= construct_empty_cellbits($vba_options['gallery_columns']); } } else { eval('$newimagebits = "' . fetch_template('adv_gallery_nodisplay') . '";'); } $db->free_result($getnew); unset($images); } // Random images if ($vba_options['gallery_randomhomeimages']) { $show['randomimages'] = true; $counter = 0; $getrand = $db->query_read(" SELECT imageid, images.title, filename, thumbname, originalname, extension, images.catid $query[fields] FROM " . TABLE_PREFIX . "adv_gallery_images AS images $query[tables] WHERE $privcatids valid = 1 $ignquery ORDER BY RAND() LIMIT $vba_options[gallery_randomhomeimages] "); if ($db->num_rows($getrand)) { while ($images = $vbulletin->db->fetch_array($getrand)) { $counter++; $adv_sorturl = '&catid=' . $images['catid']; $randomimagebits .= construct_imagebits($images); } if ($vba_options['gallery_randomhomeimages'] >= $vba_options['gallery_columns']) { $randomimagebits .= construct_empty_cellbits($vba_options['gallery_columns']); } } else { eval('$randomimagebits = "' . fetch_template('adv_gallery_nodisplay') . '";'); } $db->free_result($getrand); unset($images); } if ($vba_options['gallery_navbarhomelink']) { $navbits[''] = $vba_options['gallery_title']; $navbits = construct_navbits($navbits); } eval('$navbar = "' . fetch_template('navbar') . '";'); } else { $show['subcats'] = true; $categoryjump = print_category_jump($catid); foreach ($categorycache AS $navcat) { if ($navcat['catid'] == $catid) { $navinfo['title'] = stripslashes($navcat['title']); $navinfo['parentlist'] = $navcat['parentlist']; } } if ($vba_options['gallery_navbarhomelink']) { $navbits["$vba_options[gallery_url]"] = $vba_options['gallery_title']; } $navbits = construct_dir_navbits($navinfo['parentlist']); $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); } $pagetitle = $vba_options['gallery_title']; if (defined('VBA_PORTAL')) { eval('$HTML .= "' . fetch_template('ADV_GALLERY') . '";'); print_portal_output($home, $HTML); } else { eval('print_output("' . fetch_template('ADV_GALLERY') . '");'); } ?>