Exemple #1
0
 $info['album_link'] = array('link' => INFUSIONS . 'gallery/gallery.php?album_id=' . $_GET['album_id'], 'name' => $info['album_title']);
 $info['max_rows'] = dbcount("(photo_id)", DB_PHOTOS, "album_id='" . $_GET['album_id'] . "'");
 $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $info['max_rows'] ? $_GET['rowstart'] : 0;
 if ($info['max_rows'] > 0) {
     // Album stats
     $latest_update = dbarray(dbquery("\n\t\t\t\t\tSELECT tp.photo_datestamp, tu.user_id, tu.user_name, tu.user_status\n\t\t\t\t\tFROM " . DB_PHOTOS . " tp\n\t\t\t\t\tLEFT JOIN " . DB_USERS . " tu ON tp.photo_user=tu.user_id\n\t\t\t\t\tWHERE album_id='" . intval($_GET['album_id']) . "'\n\t\t\t\t\tORDER BY photo_datestamp DESC LIMIT 1"));
     $info['album_stats'] = $locale['422'] . $info['max_rows'] . "<br />\n";
     $info['album_stats'] .= $locale['423'] . profile_link($latest_update['user_id'], $latest_update['user_name'], $latest_update['user_status']) . "" . $locale['424'] . showdate("longdate", $latest_update['photo_datestamp']) . "\n";
     $result = dbquery("SELECT tp.*,\n\t\t\t\t\ttu.user_id, tu.user_name, tu.user_status, tu.user_avatar,\n\t\t\t\t\tSUM(tr.rating_vote) 'sum_rating',\n\t\t\t\t\tCOUNT(tr.rating_vote) 'count_rating',\n\t\t\t\t\tCOUNT(tr.rating_item_id) 'count_votes'\n\t\t\t\t\tFROM " . DB_PHOTOS . " tp\n\t\t\t\t\tLEFT JOIN " . DB_USERS . " tu ON tp.photo_user=tu.user_id\n\t\t\t\t\tLEFT JOIN " . DB_RATINGS . " tr ON tr.rating_item_id = tp.photo_id AND tr.rating_type='P'\n\t\t\t\t\tWHERE album_id='" . intval($_GET['album_id']) . "'\n\t\t\t\t\tGROUP BY photo_id ORDER BY photo_order\n\t\t\t\t\tlimit " . intval($_GET['rowstart']) . "," . intval($gallery_settings['gallery_pagination']));
     $info['photo_rows'] = dbrows($result);
     $info['page_nav'] = $info['max_rows'] > $gallery_settings['gallery_pagination'] ? makepagenav($_GET['rowstart'], $gallery_settings['gallery_pagination'], $info['max_rows'], 3, INFUSIONS . "gallery/gallery.php?album_id=" . $_GET['album_id'] . "&amp;") : '';
     if ($info['photo_rows'] > 0) {
         // this is photo
         while ($data = dbarray($result)) {
             // data manipulation
             $data += array("photo_link" => array('link' => INFUSIONS . "gallery/gallery.php?photo_id=" . $data['photo_id'], 'name' => $data['photo_title']), "image" => displayPhotoImage($data['photo_id'], $data['photo_filename'], $data['photo_thumb1'], $data['photo_thumb2'], INFUSIONS . "gallery/gallery.php?photo_id=" . $data['photo_id']), "title" => $data['photo_title'] ? $data['photo_title'] : $data['image'], "description" => $data['photo_description'] ? nl2br(parse_textarea($data['photo_description'])) : '', "photo_views" => format_word($data['photo_views'], $locale['fmt_views']));
             if (iADMIN && checkrights("PH")) {
                 global $aidlink;
                 $data['photo_edit'] = array("link" => INFUSIONS . "gallery/gallery_admin.php" . $aidlink . "&amp;section=photo_form&amp;action=edit&amp;photo_id=" . $data['photo_id'], "name" => $locale['edit']);
                 $data['photo_delete'] = array("link" => INFUSIONS . "gallery/gallery_admin.php" . $aidlink . "&amp;section=actions&amp;action=delete&amp;photo_id=" . $data['photo_id'], "name" => $locale['delete']);
             }
             if ($data['photo_allow_comments']) {
                 $data += array("photo_votes" => $data['count_votes'] > 0 ? $data['count_votes'] : '0', "photo_comments" => array('link' => $data['photo_link']['link'] . '#comments', 'name' => $data['count_votes'], 'word' => format_word($data['count_votes'], $locale['fmt_comment'])));
             }
             if ($data['photo_allow_ratings']) {
                 $data += array("sum_rating" => $data['sum_rating'] > 0 ? $data['sum_rating'] : '0', "photo_ratings" => array('link' => $data['photo_link']['link'] . '#ratings', 'name' => $data['sum_rating'], 'word' => $data['sum_rating'] > 0 ? $data['sum_rating'] / $data['count_rating'] * 10 . "/10" : "0/10"));
             }
             $info['item'][] = $data;
         }
     }
 }
/**
 * Gallery Photo Listing UI
 */
function gallery_photo_listing()
{
    global $locale, $gll_settings, $aidlink;
    // xss
    $photoRows = dbcount("(photo_id)", DB_PHOTOS, "album_id='" . intval($_GET['album_id']) . "'");
    $_GET['rowstart'] = isset($_GET['rowstart']) && isnum($_GET['rowstart']) && $_GET['rowstart'] <= $photoRows ? $_GET['rowstart'] : 0;
    if (!empty($photoRows)) {
        $result = dbquery("\n\t\tselect photos.*,\n\t\talbum.*,\n\t\tphotos.photo_user as user_id, u.user_name, u.user_status, u.user_avatar,\n\t\tcount(comment_id) as comment_count,\n\t\tsum(rating_vote) as total_votes,\n\t\tcount(rating_id) as rating_count\n\t\tFROM " . DB_PHOTOS . " photos\n\t\tINNER JOIN " . DB_PHOTO_ALBUMS . " album on photos.album_id = album.album_id\n\t\tINNER JOIN " . DB_USERS . " u on u.user_id = photos.photo_user\n\t\tLEFT JOIN " . DB_COMMENTS . " comment on comment.comment_item_id= photos.photo_id AND comment_type = 'PH'\n\t\tLEFT JOIN " . DB_RATINGS . " rating on rating.rating_item_id = photos.photo_id AND rating_type = 'PH'\n\t\tWHERE " . groupaccess('album.album_access') . " and photos.album_id = '" . intval($_GET['album_id']) . "'\n\t\tGROUP BY photo_id\n\t\tORDER BY photos.photo_order ASC, photos.photo_datestamp DESC LIMIT " . intval($_GET['rowstart']) . ", " . intval($gll_settings['gallery_pagination']) . "\n\t\t");
        $rows = dbrows($result);
        // Photo Album header
        echo "<aside class='text-left' style='border-bottom:1px solid #ddd; padding-bottom:15px;'>\n";
        $album_data = dbarray(dbquery("select album_id, album_title, album_description, album_datestamp, album_access from " . DB_PHOTO_ALBUMS . " WHERE album_id='" . intval($_GET['album_id']) . "'"));
        add_breadcrumb(array('link' => clean_request("album_id=" . $album_data['album_id'], array("aid"), FALSE), "title" => $album_data['album_title']));
        echo "<h2><strong>\n" . $album_data['album_title'] . "</strong></h2>\n";
        echo $locale['album_0003'] . " " . $album_data['album_description'];
        echo "<div class='clearfix m-t-10'>\n";
        echo "<div class='pull-right text-right col-xs-6 col-sm-6'>" . sprintf($locale['gallery_0019'], $rows, $photoRows) . "</div>\n";
        echo "<span class='m-r-15'>" . $locale['gallery_0020'] . " " . timer($album_data['album_datestamp']) . "</span>\n";
        echo "<span class='m-r-15'>" . $locale['gallery_0021'] . " " . getgroupname($album_data['album_access']) . "</span>\n";
        if ($photoRows > $rows) {
            echo "<div class='display-inline-block m-b-10'>\n";
            echo makepagenav($_GET['rowstart'], $gll_settings['gallery_pagination'], $photoRows, 3, FUSION_SELF . $aidlink . "&amp;album_id=" . $_GET['album_id'] . "&amp;");
            echo "</div>\n";
        }
        echo "</div>\n";
        echo "</aside>\n";
        if ($rows > 0) {
            echo "<a class='m-t-10 btn btn-danger' href='" . FUSION_SELF . $aidlink . "&amp;section=actions&amp;action=purge&amp;cat_id=" . $_GET['album_id'] . "'>" . $locale['photo_0025'] . "</a>\n";
            echo "<div class='row m-t-20'>\n";
            $i = 1;
            while ($data = dbarray($result)) {
                echo "<div style='width:" . ($gll_settings['thumb_w'] + 15) . "px; float:left; padding-left:10px; padding-right:10px;'>\n";
                echo "<div class='panel panel-default'>\n";
                echo "<div class='overflow-hide' style='background: #ccc; height: " . ($gll_settings['thumb_h'] - 15) . "px'>\n";
                echo displayPhotoImage($data['photo_filename'], $data['photo_thumb1'], $data['photo_thumb2'], IMAGES_G . $data['photo_filename']);
                echo "</div>\n";
                echo "<div class='panel-body'>\n";
                echo "<div class='dropdown'>\n";
                echo "<button data-toggle='dropdown' class='btn btn-default dropdown-toggle btn-block' type='button'> " . $locale['gallery_0013'] . " <span class='caret'></span></button>\n";
                echo "<ul class='dropdown-menu'>\n";
                echo "<li><a href='" . FUSION_SELF . $aidlink . "&amp;section=photo_form&amp;action=edit&amp;photo_id=" . $data['photo_id'] . "'><i class='fa fa-edit fa-fw'></i> " . $locale['gallery_0016'] . "</a></li>\n";
                echo $i > 1 ? "<li><a href='" . FUSION_SELF . $aidlink . "&amp;section=actions&amp;action=pu&amp;photo_id=" . $data['photo_id'] . "&amp;album_id=" . $data['album_id'] . "&amp;order=" . ($data['photo_order'] - 1) . "'><i class='fa fa-arrow-left fa-fw'></i> " . $locale['gallery_0014'] . "</a></li>\n" : "";
                echo $i !== $rows ? "<li><a href='" . FUSION_SELF . $aidlink . "&amp;section=actions&amp;action=pd&amp;photo_id=" . $data['photo_id'] . "&amp;album_id=" . $data['album_id'] . "&amp;order=" . ($data['photo_order'] + 1) . "'><i class='fa fa-arrow-right fa-fw'></i> " . $locale['gallery_0015'] . "</a></li>\n" : "";
                echo "<li class='divider'></li>\n";
                echo "<li><a href='" . FUSION_SELF . $aidlink . "&amp;section=actions&amp;action=delete&amp;photo_id=" . $data['photo_id'] . "'><i class='fa fa-trash fa-fw'></i> " . $locale['gallery_0017'] . "</a></li>\n";
                echo "</ul>\n";
                echo "</div>\n";
                echo "</div>\n";
                echo "<div class='panel-footer'>\n";
                echo "<span class='m-r-10'>\n<i class='fa fa-comments-o' title='" . $locale['comments'] . "'></i> " . $data['comment_count'] . "</span>\n";
                echo "<span class='m-r-5'>\n<i class='fa fa-star' title='" . $locale['ratings'] . "'></i> " . ($data['rating_count'] > 0 ? $data['total_votes'] / $data['rating_count'] * 10 : 0) . " /10</span>\n";
                echo "</div>\n</div>\n";
                echo "</div>\n";
                $i++;
            }
            echo "</div>\n";
        } else {
            redirect(FUSION_SELF . $aidlink);
        }
    } else {
        redirect(FUSION_SELF . $aidlink);
    }
}