function AdminCats() { global $context, $lang, $db, $page, $mybb; $page->output_header($lang->gallery_text_title . ' - ' . $lang->gallery_form_managecats); DoGalleryAdminTabs('ezgallery_categories'); $dbresult = $db->query("\n\t\tSELECT\n\t\t\tID_CAT, title, roworder, description, image\n\t\tFROM " . TABLE_PREFIX . "gallery_cat ORDER BY roworder ASC"); $context['gallery_manage_cats'] = array(); while ($row = $db->fetch_array($dbresult)) { $context['gallery_manage_cats'][] = $row; } require_once MYBB_ROOT . "inc/class_parser.php"; $parser = new postParser(); $parser_options = array("allow_html" => 1, "allow_mycode" => 1, "allow_smilies" => 1, "allow_imgcode" => 1, "filter_badwords" => 1); $table = new Table(); $table->construct_header($lang->gallery_text_galleryname); $table->construct_header($lang->gallery_text_gallerydescription); $table->construct_header($lang->gallery_text_totalimage); $table->construct_header($lang->gallery_text_reorder); $table->construct_header($lang->gallery_text_options); foreach ($context['gallery_manage_cats'] as $row) { $totalpics = GetTotalPicturesBYCATID($row['ID_CAT']); $table->construct_cell('<a href="' . $mybb->settings['bburl'] . '/ezgallery.php?cat=' . $row['ID_CAT'] . '">' . $row['title'] . '</a>'); $table->construct_cell($parser->parse_message($row['description'], $parser_options)); $table->construct_cell('<div align="center">' . $totalpics . '</div>'); // Show Edit Delete and Order category $table->construct_cell('<a href="index.php?module=config/ezgallery&action=catup&cat=' . $row['ID_CAT'] . '">' . $lang->gallery_text_up . '</a> <a href="index.php?module=config/ezgallery&action=catdown&cat=' . $row['ID_CAT'] . '">' . $lang->gallery_text_down . '</a>'); $table->construct_cell('<a href="index.php?module=config/ezgallery&action=editcat&cat=' . $row['ID_CAT'] . '">' . $lang->gallery_text_edit . '</a> <a href="index.php?module=config/ezgallery&action=deletecat&cat=' . $row['ID_CAT'] . '">' . $lang->gallery_text_delete . '</a>'); $table->construct_row(); } $table->construct_cell('<a href="index.php?module=config/ezgallery&action=addcat">' . $lang->gallery_text_addcategory . '</a>', array("colspan" => 5, "align" => 'center')); $table->construct_row(); $table->output($lang->gallery_form_managecats); $page->output_footer(); }
function mainview() { global $context, $lang, $db, $gallerySettings, $mybb; global $parser_options, $parser, $config; // View the main gallery // Is the user allowed to view the gallery? isAllowedTo('view'); $context['gallery_cat_name'] = ' '; $g_add = allowedTo('add'); // MyImages if ($g_add && $mybb->user['uid'] != 0) { $context['gallery']['buttons']['mylisting'] = array('text' => $lang->gallery_myimages, 'url' => 'ezgallery.php?action=myimages&u=' . $mybb->user['uid'], 'lang' => true, 'image' => ''); } // Search $context['gallery']['buttons']['search'] = array('text' => $lang->gallery_search, 'url' => 'ezgallery.php?action=search', 'lang' => true, 'image' => ''); @($cat = intval($_REQUEST['cat'])); if ($cat) { // Get category name $dbresult1 = $db->query("\n\t\tSELECT \n\t\t\tID_CAT, title, roworder, description, image \n\t\tFROM " . TABLE_PREFIX . "gallery_cat \n\t\tWHERE ID_CAT = {$cat} LIMIT 1"); $row1 = $db->fetch_array($dbresult1); $context['gallery_cat_name'] = $row1['title']; add_breadcrumb(htmlspecialchars_uni($row1['title']), 'ezgallery.php?cat=' . $cat); $query = $db->query("\n\t\tSELECT COUNT(*) as total\n\t\t FROM " . TABLE_PREFIX . "gallery_pic as p\n\n\t\tWHERE p.ID_CAT = {$cat} AND p.approved = 1 "); $totalPicCount = $db->fetch_array($query); $perpage = $gallerySettings['gallery_set_images_per_page']; $page = intval($mybb->input['page']); if (intval($mybb->input['page']) > 0) { $start = ($page - 1) * $perpage; } else { $start = 0; $page = 1; } $pagingList = multipage($totalPicCount['total'], $perpage, $page, "ezgallery.php?cat={$cat}"); // Image Listing $dbresult = $db->query("\n\t\tSELECT p.ID_PICTURE, p.commenttotal, p.filesize, p.views, p.thumbfilename, p.filename, p.height, p.width, \n\t\t p.title, p.ID_MEMBER, m.username, p.date, p.description \n\t\t FROM " . TABLE_PREFIX . "gallery_pic as p\n\t\tLEFT JOIN " . TABLE_PREFIX . "users AS m on ( p.ID_MEMBER = m.uid) \n\t\tWHERE p.ID_CAT = {$cat} AND p.approved = 1 ORDER BY p.ID_PICTURE DESC LIMIT {$start},{$perpage}"); $context['gallery_image_list'] = array(); while ($row = $db->fetch_array($dbresult)) { $context['gallery_image_list'][] = $row; } // Link Tree $context['linktree'][] = array('url' => 'ezgallery.php', 'name' => $lang->gallery_text_title); $context['linktree'][] = array('url' => 'ezgallery.php?cat=' . $cat, 'name' => $context['gallery_cat_name']); $context['page_title'] = $context['gallery_cat_name']; gallery_header(); if (!empty($gallerySettings['gallery_who_viewing'])) { // Start out with no one at all viewing it. $context['view_members'] = array(); $context['view_members_list'] = array(); $context['view_num_hidden'] = 0; $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60; // Search for members who have this picture id set in their GET data. $request = $db->query("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tlo.uid, lo.time, mem.username, mem.invisible,\n\t\t\t\t\t\tmg.namestyle, mg.gid, mg.title\n\t\t\t\t\tFROM (" . TABLE_PREFIX . "sessions AS lo)\n\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users AS mem ON (mem.uid = lo.uid)\n\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups AS mg ON (mem.usergroup = mg.gid)\n\t\t\t\t\tWHERE INSTR(lo.location, 'ezgallery.php?cat={$cat}') AND lo.time > {$timesearch}"); while ($row = $db->fetch_array($request)) { if (empty($row['uid'])) { continue; } if (!empty($row['namestyle'])) { $link = '<a href="member.php?action=profile&uid=' . $row['uid'] . '">' . str_replace("{username}", $row['username'], $row['namestyle']) . '</a>'; } else { $link = '<a href="member.php?action=profile&uid=' . $row['uid'] . '">' . $row['username'] . '</a>'; } // Add them both to the list and to the more detailed list. if (empty($row['invisible'])) { $context['view_members_list'][$row['time'] . $row['username']] = !empty($row['invisible']) ? '<i>' . $link . '</i>' : $link; } $context['view_members'][$row['time'] . $row['username']] = array('id' => $row['uid'], 'username' => $row['username'], 'name' => $row['username'], 'group' => $row['gid'], 'href' => 'member.php?action=profile&uid=' . $row['uid'], 'link' => $link, 'hidden' => !empty($row['invisible'])); if (!empty($row['invisible'])) { $context['view_num_hidden']++; } } // The number of guests is equal to the rows minus the ones we actually used ;). $context['view_num_guests'] = $db->num_rows($request) - count($context['view_members']); // Sort the list. krsort($context['view_members']); krsort($context['view_members_list']); } // Permissions if they are allowed to edit or delete their own gallery pictures. $g_edit_own = allowedTo('edit'); $g_delete_own = allowedTo('delete'); $g_add = allowedTo('add'); $g_manage = allowedTo('manage'); // Check if GD is installed if not we will not show the thumbnails $GD_Installed = function_exists('imagecreate'); if ($g_manage) { // Warn the user if they are managing the gallery that it is not writable if (!is_writable($gallerySettings['gallery_path'])) { echo '<font color="#FF0000"><b>', $lang->gallery_write_error, $gallerySettings['gallery_path'] . '</b></font>'; } } // Get the Category @($cat = intval($_REQUEST['cat'])); echo '<table border="0" cellspacing="0" cellpadding="4" align="center" width="90%" class="tborder" > <tr class="tcat"> <td align="center"> </td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" align="center" width="90%"> <tr> <td style="padding-right: 1ex;" align="right" > <table cellpadding="0" cellspacing="0" align="right"> <tr> ', DoToolBarStrip($context['gallery']['buttons'], 'top'), ' </tr> </table> </td> </tr> </table> <br />'; $maxrowlevel = $gallerySettings['gallery_set_images_per_row']; echo '<br /> <table cellspacing="0" cellpadding="10" border="0" align="center" width="90%" class="tborder"> <tr class="tcat"> <td align="center" colspan="' . $maxrowlevel . '">' . @$context['gallery_cat_name'] . '</td> </tr>'; // Show the pictures $rowlevel = 0; $styleclass = 'trow1'; $image_count = count($context['gallery_image_list']); if ($image_count == 0) { echo ' <tr class="' . $styleclass . '"> <td colspan="' . $maxrowlevel . '" align="center"><b>', $lang->gallery_nopicsincategory, '</b></td> </tr> '; } foreach ($context['gallery_image_list'] as $row) { if ($rowlevel == 0) { echo '<tr class="' . $styleclass . '">'; } echo '<td align="center"><a href="ezgallery.php?action=view&id=' . $row['ID_PICTURE'] . '"> <img ' . ($GD_Installed == true ? 'src="' . $gallerySettings['gallery_url'] . $row['thumbfilename'] . '" ' : 'src="' . $gallerySettings['gallery_url'] . $row['filename'] . '" ') . ' border="0" alt="" /></a><br />'; echo '<span class="smalltext">' . $lang->gallery_text_views . $row['views'] . '<br />'; echo $lang->gallery_text_filesize . gallery_format_size($row['filesize'], 2) . '<br />'; echo $lang->gallery_text_date . my_date($mybb->settings['dateformat'], $row['date']) . '<br />'; echo $lang->gallery_text_comments . ' (<a href="ezgallery.php?action=view&id=' . $row['ID_PICTURE'] . '">' . $row['commenttotal'] . '</a>)<br />'; if ($row['username'] != '') { echo $lang->gallery_text_by . ' <a href="member.php?action=profile&uid=' . $row['ID_MEMBER'] . '">' . $row['username'] . '</a><br />'; } else { echo $lang->gallery_text_by, $lang->gallery_guest, '<br />'; } if ($g_manage) { echo ' <a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=unapprove&id=' . $row['ID_PICTURE'] . '">' . $lang->gallery_text_unapprove . '</a>'; } if ($g_manage || $g_edit_own && $row['ID_MEMBER'] == $mybb->user['uid']) { echo ' <a href="ezgallery.php?action=edit&id=' . $row['ID_PICTURE'] . '">' . $lang->gallery_text_edit . '</a>'; } if ($g_manage || $g_delete_own && $row['ID_MEMBER'] == $mybb->user['uid']) { echo ' <a href="ezgallery.php?action=delete&id=' . $row['ID_PICTURE'] . '">' . $lang->gallery_text_delete . '</a>'; } echo '</span></td>'; if ($rowlevel < $maxrowlevel - 1) { $rowlevel++; } else { echo '</tr>'; $rowlevel = 0; } if ($styleclass == 'trow1') { $styleclass = 'trow2'; } else { $styleclass = 'trow1'; } } if ($rowlevel != 0) { echo '<td colspan="' . ($maxrowlevel - $rowlevel) . '"></td>'; echo '</tr>'; } // Display who is viewing the picture. if (!empty($gallerySettings['gallery_who_viewing'])) { echo '<tr class="' . $styleclass . '"> <td align="center" colspan="' . $maxrowlevel . '"><span class="smalltext">'; // Show just numbers...? // show the actual people viewing the gallery? echo empty($context['view_members_list']) ? '0 ' . $lang->gallery_who_members : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || @$context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $lang->gallery_who_hidden . ')'); // Now show how many guests are here too. echo ' ' . $lang->who_and, @$context['view_num_guests'], ' ', @$context['view_num_guests'] == 1 ? $lang->guest : $lang->guests, $lang->gallery_who_viewgallery, '</span></td></tr>'; } // Show return to gallery link and Show add picture if they can echo '<tr class="' . $styleclass . '"><td colspan="' . $maxrowlevel . '">' . $pagingList . '</td></tr>'; echo ' <tr class="tcat"><td align="center" colspan="' . $maxrowlevel . '">'; if ($g_add) { echo '<a href="ezgallery.php?action=add&cat=' . $cat . '">' . $lang->gallery_text_addpicture . '</a><br />'; } echo ' <a href="ezgallery.php">' . $lang->gallery_text_returngallery . '</a></td> </tr>'; echo '</table><br />'; } else { $context['page_title'] = $lang->gallery_text_title; gallery_header(); $dbresult = $db->query("\n\t\tSELECT \n\t\t\tID_CAT, title, roworder, description, image \n\t\tFROM " . TABLE_PREFIX . "gallery_cat ORDER BY roworder ASC"); $context['gallery_cat_list'] = array(); while ($row = $db->fetch_array($dbresult)) { $context['gallery_cat_list'][] = $row; } // Get unapproved pictures $dbresult3 = $db->query("\n\t\t\tSELECT \n\t\t\t\tCOUNT(*) AS total \n\t\t\tFROM " . TABLE_PREFIX . "gallery_pic \n\t\t\tWHERE approved = 0"); $totalrow = $db->fetch_array($dbresult3); $totalpics = $totalrow['total']; $context['total_unapproved'] = $totalpics; // Total reported images $dbresult4 = $db->query("\n\t\t\tSELECT \n\t\t\t\tCOUNT(*) AS total \n\t\t\tFROM " . TABLE_PREFIX . "gallery_report"); $totalrow = $db->fetch_array($dbresult4); $totalreport = $totalrow['total']; $context['total_reported_images'] = $totalreport; // Permissions $g_manage = allowedTo('manage'); if ($g_manage) { // Warn the user if they are managing the gallery that it is not writable if (!is_writable($gallerySettings['gallery_path'])) { echo '<font color="#FF0000"><b>', $lang->gallery_write_error, $gallerySettings['gallery_path'] . '</b></font>'; } } echo '<table border="0" cellspacing="0" cellpadding="4" align="center" width="90%" class="tborder" > <tr class="tcat"> <td align="center">', $lang->gallery_text_title, '</td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" align="center" width="90%"> <tr> <td style="padding-right: 1ex;" align="right" > <table cellpadding="0" cellspacing="0" align="right"> <tr> ', DoToolBarStrip($context['gallery']['buttons'], 'top'), ' </tr> </table> </td> </tr> </table> <br />'; // List all the catagories echo '<table cellspacing="0" cellpadding="10" border="0" align="center" width="90%" class="tborder"> <tr class="tcat"> <td colspan="2">', $lang->gallery_text_galleryname, '</td> <td>', $lang->gallery_text_gallerydescription, '</td> <td align="center">', $lang->gallery_text_totalimages, '</td> '; if ($g_manage) { echo ' <td>', $lang->gallery_text_reorder, '</td> <td>', $lang->gallery_text_options, '</td> '; } echo '</tr>'; foreach ($context['gallery_cat_list'] as $row) { $totalpics = GetTotalPicturesBYCATID($row['ID_CAT']); echo '<tr class="trow2">'; if ($row['image'] == '') { echo '<td colspan="2"><a href="ezgallery.php?cat=' . $row['ID_CAT'] . '">' . $parser->parse_message($row['title'], $parser_options) . '</a></td><td>' . $parser->parse_message($row['description'], $parser_options) . '</td>'; } else { echo '<td><a href="ezgallery.php?cat=' . $row['ID_CAT'] . '"><img src="' . $row['image'] . '" border="0" alt="" /></a></td>'; echo '<td><a href="ezgallery.php?cat=' . $row['ID_CAT'] . '">' . $parser->parse_message($row['title'], $parser_options) . '</a></td><td>' . $parser->parse_message($row['description'], $parser_options) . '</td>'; } // Show total pictures in the category echo '<td align="center">', $totalpics, '</td>'; // Show Edit Delete and Order category if ($g_manage) { echo '<td><a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=catup&cat=' . $row['ID_CAT'] . '">' . $lang->gallery_text_up . '</a> <a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=catdown&cat=' . $row['ID_CAT'] . '">' . $lang->gallery_text_down . '</a></td> <td><a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=editcat&cat=' . $row['ID_CAT'] . '">' . $lang->gallery_text_edit . '</a> <a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=deletecat&cat=' . $row['ID_CAT'] . '">' . $lang->gallery_text_delete . '</a></td>'; } echo '</tr>'; } echo '</table><br /><br /><br />'; // See if they are allowed to add catagories Main Index only if ($g_manage) { echo '<table cellspacing="0" cellpadding="5" border="0" align="center" width="90%" class="tborder"> <tr class="tcat"> <td align="center">', $lang->gallery_text_adminpanel, '</td> </tr> <tr class="trow2"> <td align="center"><a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=addcat">' . $lang->gallery_text_addcategory . '</a>  <a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=adminset">' . $lang->gallery_text_settings . '</a> '; if (allowedTo('manage')) { echo '<a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=permissions">' . $lang->gallery_text_permissions . '</a>'; } echo '<br />' . $lang->gallery_text_imgwaitapproval . '<b>' . $context['total_unapproved'] . '</b> <a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=approvelist">' . $lang->gallery_text_imgcheckapproval . '</a>'; echo '<br />' . $lang->gallery_text_imgreported . '<b>' . $context['total_reported_images'] . '</b> <a href="' . $mybb->settings['bburl'] . '/' . $config['admin_dir'] . '/index.php?module=config/ezgallery&action=reportlist">' . $lang->gallery_text_imgcheckreported . '</a>'; echo '</td></tr></table><br /><br />'; } //GalleryCopyright(); } gallery_footer(); }