addBreadCrumb(['link' => INFUSIONS."gallery/gallery_admin.php".fusion_get_aidlink(), 'title' => $locale['gallery_0001']]); add_to_title($locale['gallery_0001']); $gll_settings = get_settings("gallery"); add_to_css(" .panel-default > .panel-image-wrapper { height: 120px; max-height: 120px; min-width: 100%; overflow: hidden; } .panel-default > .panel-image-wrapper img { margin-top: inherit !important; margin-left: inherit !important; } .panel-default > .panel-image-wrapper .thumb > a > img { display: block; width: 100%; } .panel-default .album_title { width: 100%; margin-bottom: 5px; padding-bottom: 5px; height: 50px; overflow:hidden; text-overflow: ellipsis; content: \"\"; position:relative; } "); $allowed_pages = ['album_form', 'photo_form', 'settings', 'submissions', 'actions']; if (isset($_GET['section']) && $_GET['section'] == "back") { redirect(clean_request("", ["ref", "section", "photo_id", "action", "cat_id", "submit_id"], FALSE)); } $_GET['section'] = isset($_GET['section']) && in_array($_GET['section'], $allowed_pages) ? $_GET['section'] : 'gallery'; $_GET['album'] = 0; if (isset($_GET['section'])){ switch ($_GET['section']) { case "photo_form": \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $locale['gallery_0002']]); break; case "album_form": \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $locale['gallery_0004']]); break; case "settings": \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $locale['gallery_0006']]); break; case "submissions": \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb(['link' => FUSION_REQUEST, 'title' => $locale['gallery_0007']]); break; default: break; } } $album_edit = isset($_GET['action']) && $_GET['action'] == "edit" && isset($_GET['cat_id']) && isnum($_GET['cat_id']) ? TRUE : FALSE; $photo_edit = isset($_GET['action']) && $_GET['action'] == "edit" && isset($_GET['photo_id']) && isnum($_GET['photo_id']) ? TRUE : FALSE; if (!empty($_GET['ref']) || isset($_GET['photo_id']) || isset($_GET['cat_id'])) { $tab['title'][] = $locale['back']; $tab['id'][] = "back"; $tab['icon'][] = "fa fa-fw fa-arrow-left"; } $tab['title'][] = $locale['gallery_0001']; $tab['id'][] = "gallery"; $tab['icon'][] = "fa fa-camera-retro"; $tab['title'][] = $photo_edit ? $locale['gallery_0003'] : $locale['gallery_0002']; $tab['id'][] = "photo_form"; $tab['icon'][] = "fa fa-picture-o"; $tab['title'][] = $album_edit ? $locale['gallery_0005'] : $locale['gallery_0004']; $tab['id'][] = "album_form"; $tab['icon'][] = "fa fa-plus"; $tab['title'][] = $locale['gallery_0007']." ".dbcount("(submit_id)", DB_SUBMISSIONS, "submit_type='p'").""; $tab['id'][] = "submissions"; $tab['icon'][] = "fa fa-inbox"; $tab['title'][] = $locale['gallery_0006']; $tab['id'][] = "settings"; $tab['icon'][] = "fa fa-cogs"; // Need to put breadcrumb here before opentable, or else it won't cache in Artemis. // @todo Class so that query data can be passed around. if (isset($_GET['album_id']) && isnum($_GET['album_id'])) { $sql = "SELECT album_title FROM ".DB_PHOTO_ALBUMS." WHERE album_id=:id"; $param = [':id' => $_GET['album_id']]; \PHPFusion\BreadCrumbs::getInstance()->addBreadCrumb([ 'link' => clean_request("album_id=".$_GET['album_id'], ["aid"], FALSE), "title" => dbresult(dbquery($sql, $param), 0) ]); } opentable($locale['gallery_0001']); echo opentab($tab, $_GET['section'], "gallery_admin", TRUE, "nav-tabs m-t-20", 'section', ['album_id']); switch ($_GET['section']) { case "photo_form": include "admin/photos.php"; break; case "album_form": include "admin/gallery_cat.php"; break; case "actions": include "admin/gallery_actions.php"; break; case "settings": include "admin/gallery_settings.php"; break; case "submissions": include "admin/photo_submissions.php"; break; default: if (isset($_GET['album_id']) && isnum($_GET['album_id'])) { gallery_photo_listing(); } else { gallery_album_listing(); } } echo closetab(); closetable(); require_once THEMES.'templates/footer.php'; /** * Gallery Photo Listing UI * * @param $id * @param $type * * @return int */ function rating_vote($id, $type) { $count_db = dbarray(dbquery("SELECT IF(SUM(rating_vote)>0, SUM(rating_vote), 0) AS total_votes FROM ".DB_RATINGS." WHERE rating_item_id=:ratingid AND rating_type=:ratingtype", [':ratingid' => $id, ':ratingtype' => $type] )); return $count_db['total_votes']; } function rating_count($id, $type) { $count_db = dbarray(dbquery("SELECT COUNT(rating_id) AS rating_count FROM ".DB_RATINGS." WHERE rating_item_id=:ratingid AND rating_type=:ratingtype", [':ratingid' => $id, ':ratingtype' => $type] )); return $count_db['rating_count']; } function gallery_photo_listing() { $locale = fusion_get_locale(); $gll_settings = get_settings('gallery'); $aidlink = fusion_get_aidlink(); // xss $photoRows = dbcount("(photo_id)", DB_PHOTOS, "album_id=:albumid", [':albumid' => intval($_GET['album_id'])]); $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $photoRows ? $_GET['rowstart'] : 0; if (!empty($photoRows)) { $result = dbquery("SELECT photos.*, album.*, photos.photo_user as user_id, u.user_name, u.user_status, u.user_avatar, COUNT(comment_id) as comment_count FROM ".DB_PHOTOS." photos INNER JOIN ".DB_PHOTO_ALBUMS." album on photos.album_id = album.album_id INNER JOIN ".DB_USERS." u on u.user_id = photos.photo_user LEFT JOIN ".DB_COMMENTS." comment on comment.comment_item_id= photos.photo_id AND comment_type = 'P' WHERE ".groupaccess('album.album_access')." AND photos.album_id = '".intval($_GET['album_id'])."' GROUP BY photo_id ORDER BY photos.photo_order ASC, photos.photo_datestamp DESC LIMIT ".intval($_GET['rowstart']).", ".intval($gll_settings['gallery_pagination'])." "); $rows = dbrows($result); // Photo Album header $album_data = dbarray(dbquery("SELECT album_id, album_title, album_description, album_datestamp, album_access FROM ".DB_PHOTO_ALBUMS." WHERE album_id=:albumid", [':albumid' => intval($_GET['album_id'])])); echo "

\n".$album_data['album_title']."

\n"; echo "".$locale['album_0003']." ".$album_data['album_description']; echo "
\n"; echo "
".sprintf($locale['gallery_0019'], $rows, $photoRows)."
\n"; echo "".$locale['gallery_0020']." ".timer($album_data['album_datestamp'])."\n"; echo "".$locale['gallery_0021']." ".getgroupname($album_data['album_access'])."\n"; if ($photoRows > $rows) { echo "
\n"; echo makepagenav($_GET['rowstart'], $gll_settings['gallery_pagination'], $photoRows, 3, FUSION_SELF.$aidlink."&album_id=".$_GET['album_id']."&"); echo "
\n"; } echo "
\n"; echo "
\n"; if ($rows > 0) { echo "".$locale['photo_0025']."\n"; echo "
\n"; $i = 1; while ($data = dbarray($result)) { $rcount = rating_count($data['photo_id'], 'P'); $vcount = rating_vote($data['photo_id'], 'P'); echo "
\n"; // echo "
\n"; echo "
\n"; echo displayPhotoImage($data['photo_filename'], $data['photo_thumb1'], $data['photo_thumb2'], IMAGES_G.$data['photo_filename']); echo "
\n"; echo "
\n"; echo "\n"; echo "
\n"; echo "

".$data['photo_title']."\n

\n"; echo "
\n"; echo "
\n"; echo "\n ".$data['comment_count']."\n"; echo "\n ".number_format(($rcount > 0 ? $rcount / $vcount * 10 : 0), 2)." /10\n"; echo "
\n"; echo "
\n"; echo "
\n"; // echo "
\n"; $i++; } echo "
\n"; } else { redirect(INFUSIONS.'gallery/gallery_admin.php'.$aidlink); } } else { redirect(INFUSIONS.'gallery/gallery_admin.php'.$aidlink); } } /** * Gallery Album Listing UI */ function gallery_album_listing() { $locale = fusion_get_locale(); $aidlink = fusion_get_aidlink(); $gll_settings = get_settings('gallery'); // xss $albumRows = dbcount("(album_id)", DB_PHOTO_ALBUMS, multilang_table("PG") ? in_group('album_language', LANGUAGE) : ""); $photoRows = dbcount("(photo_id)", DB_PHOTOS, ""); $update = dbarray(dbquery("SELECT MAX(photo_datestamp) 'last_updated' FROM ".DB_PHOTOS."")); $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $albumRows ? $_GET['rowstart'] : 0; if (!empty($albumRows)) { // get albums. $gallery_sql = "SELECT album.album_id, album.album_title, album.album_image, album.album_thumb2, album.album_thumb1, album.album_order, album.album_user as user_id, u.user_name, u.user_status, u.user_avatar, COUNT(photo.photo_id) AS photo_count FROM ".DB_PHOTO_ALBUMS." album LEFT JOIN ".DB_PHOTOS." photo on photo.album_id=album.album_id INNER JOIN ".DB_USERS." u on u.user_id=album.album_user ".(multilang_table("PG") ? "WHERE ".in_group('album.album_language', LANGUAGE)." AND " : "WHERE ").groupaccess('album.album_access')." GROUP BY album.album_id ORDER BY album.album_order ASC, album.album_datestamp DESC LIMIT ".intval($_GET['rowstart']).", ".$gll_settings['gallery_pagination']; $result = dbquery($gallery_sql); $rows = dbrows($result); // Photo Album header echo "
\n"; echo "

\n".$locale['gallery_0022']."

\n"; echo "\n"; echo "".sprintf($locale['gallery_0023'], $albumRows, $photoRows, timer($update['last_updated'])).""; if ($albumRows > $rows) { echo "
\n"; echo makepagenav($_GET['rowstart'], $gll_settings['gallery_pagination'], $albumRows, 3, FUSION_SELF.$aidlink."&"); echo "
\n"; } echo "
\n"; echo "
\n"; if ($rows > 0) { echo "
\n"; $i = 1; while ($data = dbarray($result)) { echo "
\n"; // echo "
\n"; echo "
\n"; if ($data['photo_count']) { $link = FUSION_SELF.$aidlink."&album_id=".$data['album_id']; echo displayAlbumImage($data['album_image'], $data['album_thumb1'], $data['album_thumb2'], $link); } else { echo displayAlbumImage($data['album_image'], $data['album_thumb1'], $data['album_thumb2'], ""); } echo "
\n"; echo "
\n"; echo "\n"; echo "
\n"; echo ($data['photo_count'] ? "

\n".$data['album_title']."\n

\n" : "

".$data['album_title']."

\n")."\n"; echo "
\n"; echo "
\n"; echo format_word($data['photo_count'], $locale['fmt_photo']); echo "
\n"; echo "
\n"; echo "
\n"; // echo "
\n"; $i++; } echo "
\n"; } else { echo "
\n"; echo $locale['gallery_0024']; echo "
\n"; } } else { echo "
\n"; echo $locale['gallery_0024']; echo "
\n"; } } /** * Get all the album listing. * * @return array */ function get_albumOpts() { $list = []; $result = dbquery("SELECT * FROM ".DB_PHOTO_ALBUMS." ".(multilang_table("PG") ? "where ".in_group('album_language', LANGUAGE) : "")." ORDER BY album_order ASC"); if (dbrows($result) > 0) { while ($data = dbarray($result)) { $list[$data['album_id']] = $data['album_title']; } } return $list; } /** * Delete and Purge Album Photos * * @param $albumData */ function purgeAlbumImage($albumData) { if (!empty($albumData['album_image']) && file_exists(IMAGES_G.$albumData['album_image'])) { unlink(IMAGES_G.$albumData['album_image']); } sleep(0.3); if (!empty($albumData['album_thumb1']) && file_exists(IMAGES_G_T.$albumData['album_thumb1'])) { unlink(IMAGES_G_T.$albumData['album_thumb1']); } sleep(0.3); if (!empty($albumData['album_thumb2']) && file_exists(IMAGES_G_T.$albumData['album_thumb2'])) { unlink(IMAGES_G_T.$albumData['album_thumb2']); } } /** * Purge all photo images * * @param $photoData */ function purgePhotoImage($photoData) { if (!empty($photoData['photo_filename']) && file_exists(IMAGES_G.$photoData['photo_filename'])) { unlink(IMAGES_G.$photoData['photo_filename']); } sleep(0.3); if (!empty($photoData['photo_thumb1']) && file_exists(IMAGES_G_T.$photoData['photo_thumb1'])) { unlink(IMAGES_G_T.$photoData['photo_thumb1']); } sleep(0.3); if (!empty($photoData['photo_thumb2']) && file_exists(IMAGES_G_T.$photoData['photo_thumb2'])) { unlink(IMAGES_G_T.$photoData['photo_thumb2']); } } /** * Purge all submissions photo images * * @param $photoData */ function purgeSubmissionsPhotoImage($photoData) { $submissions_dir = INFUSIONS."gallery/submissions/"; $submissions_dir_t = INFUSIONS."gallery/submissions/thumbs/"; if (!empty($photoData['photo_filename']) && file_exists($submissions_dir.$photoData['photo_filename'])) { unlink($submissions_dir.$photoData['photo_filename']); } sleep(0.3); if (!empty($photoData['photo_thumb1']) && file_exists($submissions_dir_t.$photoData['photo_thumb1'])) { unlink($submissions_dir_t.$photoData['photo_thumb1']); } sleep(0.3); if (!empty($photoData['photo_thumb2']) && file_exists($submissions_dir_t.$photoData['photo_thumb2'])) { unlink($submissions_dir_t.$photoData['photo_thumb2']); } } /** * Displays the Album Image * * @param $album_image * @param $album_thumb1 * @param $album_thumb2 * @param $link * * @return string */ function displayAlbumImage($album_image, $album_thumb1, $album_thumb2, $link) { $gll_settings = get_settings('gallery'); // Thumb will have 2 possible path following v7 if (!empty($album_thumb1) && (file_exists(IMAGES_G_T.$album_thumb1) || file_exists(IMAGES_G.$album_thumb1))) { if (file_exists(IMAGES_G.$album_thumb1)) { // uncommon first $image = thumbnail(IMAGES_G.$album_thumb1, $gll_settings['thumb_w']."px", $link, FALSE, FALSE, "cropfix center-xy"); } else { // sure fire if image is usually more than thumb threshold $image = thumbnail(IMAGES_G_T.$album_thumb1, $gll_settings['thumb_w']."px", $link, FALSE, FALSE, "cropfix"); } return $image; } if (!empty($album_thumb2) && file_exists(IMAGES_G.$album_thumb2)) { return thumbnail(IMAGES_G.$album_thumb2, $gll_settings['thumb_w']."px", $link, FALSE, FALSE, "cropfix center-xy"); } if (!empty($album_image) && file_exists(IMAGES_G.$album_image)) { return thumbnail(IMAGES_G.$album_image, $gll_settings['thumb_w']."px", $link, FALSE, FALSE, "cropfix"); } return thumbnail(IMAGES_G."album_default.jpg", $gll_settings['thumb_w']."px", $link, FALSE, FALSE, "cropfix"); } /** * Displays Album Thumb with Colorbox * * @param $photo_filename * @param $photo_thumb1 * @param $photo_thumb2 * @param $link * * @return string */ function displayPhotoImage($photo_filename, $photo_thumb1, $photo_thumb2, $link) { $gll_settings = get_settings('gallery'); // Thumb will have 2 possible path following v7 if (!empty($photo_thumb1) && (file_exists(IMAGES_G_T.$photo_thumb1) || file_exists(IMAGES_G.$photo_thumb1))) { if (file_exists(IMAGES_G.$photo_thumb1)) { // uncommon first return thumbnail(IMAGES_G.$photo_thumb1, $gll_settings['thumb_w']."px", $link, TRUE, FALSE, "cropfix"); } else { // sure fire if image is usually more than thumb threshold return thumbnail(IMAGES_G_T.$photo_thumb1, $gll_settings['thumb_w']."px", $link, TRUE, FALSE, "cropfix"); } } if (!empty($photo_thumb2) && file_exists(IMAGES_G.$photo_thumb2)) { return thumbnail(IMAGES_G.$photo_thumb2, $gll_settings['thumb_w']."px", $link, TRUE, FALSE, "cropfix"); } if (!empty($photo_filename) && file_exists(IMAGES_G.$photo_filename)) { return thumbnail(IMAGES_G.$photo_filename, $gll_settings['thumb_w']."px", $link, TRUE, FALSE, "cropfix"); } return thumbnail(IMAGES_G."album_default.jpg", $gll_settings['thumb_w']."px", "", FALSE, FALSE, "cropfix"); }