示例#1
0
function MG_searchDisplayThumb($M, $sortOrder, $id, $page, $force = 0)
{
    global $_CONF, $_USER, $_MG_CONF, $MG_albums, $_TABLES, $_MG_USERPREFS, $LANG_MG03, $LANG_MG01, $ratedIds;
    $playback_type = $_MG_CONF['search_playback_type'];
    $retval = '';
    $nFrame = new mgFrame();
    $nFrame->constructor('mgShadow');
    $imageFrameTemplate = $nFrame->getTemplate();
    $frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR'];
    $frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB'];
    $T = new Template(MG_getTemplatePath(0));
    $T->set_file(array('media_cell_image' => 'album_page_body_media_cell.thtml', 'media_rate_results' => 'album_page_body_media_cell_rating.thtml', 'media_comments' => 'album_page_body_media_cell_comment.thtml', 'media_views' => 'album_page_body_media_cell_view.thtml', 'media_cell_keywords' => 'album_page_body_media_cell_keywords.thtml', 'mp3_podcast' => 'mp3_podcast.thtml'));
    $F = new Template($_MG_CONF['template_path']);
    $F->set_var('media_frame', $imageFrameTemplate);
    //$MG_albums[0]->imageFrameTemplate);
    // --- set the default thumbnail
    $default_thumbnail = 'generic.png';
    switch ($M['media_type']) {
        case 0:
            // standard image
            foreach ($_MG_CONF['validExtensions'] as $ext) {
                if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $ext)) {
                    $default_thumbnail = 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $ext;
                    break;
                }
            }
            break;
        case 1:
            // video file
            switch ($M['mime_type']) {
                case 'video/x-flv':
                    $default_thumbnail = 'flv.png';
                    break;
                case 'application/x-shockwave-flash':
                    $default_thumbnail = 'flash.png';
                    break;
                case 'video/mpeg':
                case 'video/x-mpeg':
                case 'video/x-mpeq2a':
                    if ($_MG_CONF['use_wmp_mpeg'] == 1) {
                        $default_thumbnail = 'wmp.png';
                        break;
                    }
                case 'video/x-motion-jpeg':
                case 'video/quicktime':
                case 'video/x-qtc':
                case 'audio/mpeg':
                    $default_thumbnail = 'quicktime.png';
                    break;
                case 'asf':
                case 'video/x-ms-asf':
                case 'video/x-ms-asf-plugin':
                case 'video/avi':
                case 'video/msvideo':
                case 'video/x-msvideo':
                case 'video/avs-video':
                case 'video/x-ms-wmv':
                case 'video/x-ms-wvx':
                case 'video/x-ms-wm':
                case 'application/x-troff-msvideo':
                case 'application/x-ms-wmz':
                case 'application/x-ms-wmd':
                    $default_thumbnail = 'wmp.png';
                    break;
                default:
                    $default_thumbnail = 'video.png';
                    break;
            }
            break;
        case 2:
            // music file
            $default_thumbnail = 'audio.png';
            break;
        case 4:
            // other files
            switch ($M['mime_type']) {
                case 'application/zip':
                case 'zip':
                case 'arj':
                case 'rar':
                case 'gz':
                    $default_thumbnail = 'zip.png';
                    break;
                case 'pdf':
                case 'application/pdf':
                    $default_thumbnail = 'pdf.png';
                    break;
                default:
                    switch ($M['media_mime_ext']) {
                        case 'pdf':
                            $default_thumbnail = 'pdf.png';
                            break;
                        case 'arj':
                            $default_thumbnail = 'zip.png';
                            break;
                        case 'gz':
                            $default_thumbnail = 'zip.png';
                            break;
                        default:
                            $default_thumbnail = 'generic.png';
                            break;
                    }
                    break;
            }
            break;
        case 5:
        case 'embed':
            if (preg_match("/youtube/i", $M['remote_url'])) {
                $default_thumbnail = 'youtube.png';
            } else {
                if (preg_match("/google/i", $M['remote_url'])) {
                    $default_thumbnail = 'googlevideo.png';
                } else {
                    $default_thumbnail = 'remote.png';
                }
            }
            break;
    }
    if ($M['media_tn_attached'] == 1) {
        $media_thumbnail_file = '';
        foreach ($_MG_CONF['validExtensions'] as $ext) {
            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext)) {
                $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext;
                $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/tn_' . $M['media_filename'] . $ext;
                break;
            }
        }
        if ($media_thumbnail_file == '') {
            $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail;
            $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail;
        }
    } else {
        $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail;
        $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail;
    }
    $resolution_x = 0;
    $resolution_y = 0;
    // type == 1 video
    // type == 2 audio
    if (($M['media_type'] == 1 || $M['media_type'] == 2 || $M['media_type'] == 5) && ($playback_type == 0 || $playback_type == 1)) {
        if ($playback_type == 0 || $playback_type == 1) {
            if ($M['media_type'] == 2) {
                // determine what type of player we will use (WMP, QT or Flash)
                $player = $_MG_CONF['mp3_player'];
                if (isset($_MG_USERPREFS['mp3_player']) && $_MG_USERPREFS['mp3_player'] != -1) {
                    $player = $_MG_USERPREFS['mp3_player'];
                }
                switch ($player) {
                    case 0:
                        // WMP
                        $new_y = 60;
                        $new_x = 350;
                        break;
                    case 1:
                        // QT
                        $new_y = 25;
                        $new_x = 350;
                        break;
                    case 2:
                        $new_y = 360;
                        $new_x = 580;
                        break;
                }
                if ($M['media_tn_attached'] == 1 && $player != 2) {
                    $tnsize = @getimagesize($media_thumbnail_file);
                    $new_y += $tnsize[0];
                    if ($tnsize[1] > $new_x) {
                        $new_x = $tnsize[1];
                    }
                }
                if ($playback_type == 0) {
                    $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $new_y . ',' . $new_x . ')';
                } else {
                    $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $MG_media->id;
                }
                $resolution_x = $new_x;
                $resolution_y = $new_y;
            } else {
                // must be a video...
                // set the default playback options...
                $playback_options['play'] = $_MG_CONF['swf_play'];
                $playback_options['menu'] = $_MG_CONF['swf_menu'];
                $playback_options['quality'] = $_MG_CONF['swf_quality'];
                $playback_options['height'] = $_MG_CONF['swf_height'];
                $playback_options['width'] = $_MG_CONF['swf_width'];
                $playback_options['loop'] = $_MG_CONF['swf_loop'];
                $playback_options['scale'] = $_MG_CONF['swf_scale'];
                $playback_options['wmode'] = $_MG_CONF['swf_wmode'];
                $playback_options['allowscriptaccess'] = $_MG_CONF['swf_allowscriptaccess'];
                $playback_options['bgcolor'] = $_MG_CONF['swf_bgcolor'];
                $playback_options['swf_version'] = $_MG_CONF['swf_version'];
                $playback_options['flashvars'] = $_MG_CONF['swf_flashvars'];
                $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($M['media_id']) . "'");
                while ($poRow = DB_fetchArray($poResult)) {
                    $playback_options[$poRow['option_name']] = $poRow['option_value'];
                }
                if (isset($M['media_resolution_x']) && $M['media_resolution_x'] > 0) {
                    $resolution_x = $M['media_resolution_x'];
                    $resolution_y = $M['media_resolution_y'];
                } else {
                    if ($M['media_resolution_x'] == 0 && $M['remote_media'] != 1) {
                        require_once $_CONF['path'] . '/lib/getid3/getid3.php';
                        // Needed for windows only
                        define('GETID3_HELPERAPPSDIR', 'C:/helperapps/');
                        $getID3 = new getID3();
                        // Analyze file and store returned data in $MG_mediaFileInfo
                        $MG_mediaFileInfo = $getID3->analyze($_MG_CONF['path_mediaobjects'] . 'orig/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext']);
                        getid3_lib::CopyTagsToComments($MG_mediaFileInfo);
                        if ($MG_mediaFileInfo['video']['resolution_x'] < 1 || $MG_mediaFileInfo['video']['resolution_y'] < 1) {
                            if (isset($MG_mediaFileInfo['meta']['onMetaData']['width']) && isset($MG_mediaFileInfo['meta']['onMetaData']['height'])) {
                                $resolution_x = $MG_mediaFileInfo['meta']['onMetaData']['width'];
                                $resolution_y = $MG_mediaFileInfo['meta']['onMetaData']['height'];
                            } else {
                                $resolution_x = -1;
                                $resolution_y = -1;
                            }
                        } else {
                            $resolution_x = $MG_mediaFileInfo['video']['resolution_x'];
                            $resolution_y = $MG_mediaFileInfo['video']['resolution_y'];
                        }
                        if ($resolution_x != 0) {
                            $sql = "UPDATE " . $_TABLES['mg_media'] . " SET media_resolution_x=" . $resolution_x . ",media_resolution_y=" . $resolution_y . " WHERE media_id='" . DB_escapeString($M['media_id']) . "'";
                            DB_query($sql, 1);
                        }
                    } else {
                        $resolution_x = $M['media_resolution_x'];
                        $resolution_y = $M['media_resolution_y'];
                    }
                }
                $resolution_x = $playback_options['width'];
                $resolution_y = $playback_options['height'];
                if ($resolution_x < 1 || $resolution_y < 1) {
                    $resolution_x = 480;
                    $resolution_y = 320;
                } else {
                    $resolution_x = $resolution_x + 40;
                    $resolution_y = $resolution_y + 40;
                }
                if ($M['mime_type'] == 'video/x-flv' && $_MG_CONF['use_flowplayer'] != 1) {
                    $resolution_x = $resolution_x + 60;
                    if ($resolution_x < 590) {
                        $resolution_x = 590;
                    }
                    $resolution_y = $resolution_y + 80;
                    if ($resolution_y < 500) {
                        $resolution_y = 500;
                    }
                }
                if ($M['media_type'] == 5) {
                    $resolution_x = 460;
                    $resolution_y = 380;
                }
                $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $resolution_y . ',' . $resolution_x . ')';
            }
        } else {
            $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id'];
        }
        // check to see if comments and rating are enabled, if not, put a link to edit...
        if ($MG_albums[0]->access == 3) {
            $T->set_var(array('edit_link' => '<br/><a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;s=1&amp;album_id=' . $M['album_id'] . '&amp;mid=' . $M['media_id'] . '">' . $LANG_MG01['edit'] . '</a>'));
        } else {
            $T->set_var(array('edit_link' => ''));
        }
    } else {
        $url_display_item = $_MG_CONF['site_url'] . '/media.php?f=0' . '&amp;sort=' . $sortOrder . '&amp;s=' . $M['media_id'] . '&amp;i=' . $id . '&amp;p=' . $page;
    }
    if ($M['media_type'] == 4) {
        // other
        $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id'];
    }
    $media_size = @getimagesize($media_thumbnail_file);
    if ($media_size == false) {
        $default_thumbnail = 'missing.png';
        $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail;
        $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail;
        $media_size = @getimagesize($media_thumbnail_file);
    }
    if ($_MG_CONF['use_upload_time'] == 1) {
        $media_time = MG_getUserDateTimeFormat($M['media_upload_time']);
    } else {
        $media_time = MG_getUserDateTimeFormat($M['media_time']);
    }
    $url_media_item = $url_display_item;
    // -- decide what thumbnail size to use, small, medium, large...
    if (isset($_MG_USERPREFS['tn_size']) && $_MG_USERPREFS['tn_size'] != -1) {
        $tn_size = $_MG_USERPREFS['tn_size'];
    } else {
        $tn_size = $_MG_CONF['gallery_tn_size'];
    }
    switch ($tn_size) {
        case '0':
            //small
            $tn_height = 100;
            break;
        case '1':
            //medium
            $tn_height = 150;
            break;
        case '2':
            $tn_height = 200;
            break;
        case '3':
            $tn_height = 200;
            break;
        default:
            $tn_height = 150;
            break;
    }
    if ($media_size[0] > $media_size[1]) {
        $ratio = $media_size[0] / $tn_height;
        $newwidth = $tn_height;
        $newheight = round($media_size[1] / $ratio);
    } else {
        $ratio = $media_size[1] / $tn_height;
        $newheight = $tn_height;
        $newwidth = round($media_size[0] / $ratio);
    }
    if ($media_size[0] > $media_size[1]) {
        $ratio = $media_size[0] / 50;
        $smallwidth = 50;
        $smallheight = round($media_size[1] / $ratio);
    } else {
        $ratio = $media_size[1] / 50;
        $smallheight = 50;
        $smallwidth = round($media_size[0] / $ratio);
    }
    if ($M['media_user_id'] != "" && $M['media_user_id'] > 1) {
        $username = DB_getItem($_TABLES['users'], 'username', "uid=" . $M['media_user_id']);
    } else {
        $username = '******';
    }
    if ($M['mime_type'] == 'audio/mpeg') {
        $T->set_var(array('play_now' => '', 'download_now' => $_MG_CONF['site_url'] . '/download.php?mid=' . $M['media_id'], 'play_in_popup' => "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $M['media_id'] . "'," . $resolution_y . ',' . $resolution_x . ')', 'mp3_file' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext'], 'site_url' => $_MG_CONF['site_url'], 'id' => $M['media_mime_ext'] . rand()));
        $T->parse('mp3_podcast', 'mp3_podcast');
    } else {
        $T->set_var(array('mp3_podcast' => ''));
    }
    /*
     * build the small rating bar
     *
     */
    if ($MG_albums[$M['album_id']]->enable_rating > 0) {
        $ip = $_SERVER['REMOTE_ADDR'];
        $uid = COM_isAnonUser() ? 1 : $_USER['uid'];
        $static = false;
        // check to see if we are the owner, if so, no rating for us...
        if (isset($_USER['uid']) && $_USER['uid'] == $M['media_user_id']) {
            $static = true;
        } else {
            if (in_array($M['media_id'], $ratedIds)) {
                $static = true;
            } else {
                $static = '';
            }
        }
        if ($MG_albums[$M['album_id']]->enable_rating == 1 && COM_isAnonUser()) {
            $static = 'static';
        }
        $rating_box = RATING_ratingBar('mediagallery', $M['media_id'], $M['media_votes'], $M['media_rating'], $static, 5, '', 'sm');
    } else {
        $rating_box = '';
    }
    $T->set_var('rating_box', $rating_box);
    if ($M['media_type'] == 0) {
        $direct_url = 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.' . $M['media_mime_ext'];
        if (!file_exists($_MG_CONF['path_mediaobjects'] . $direct_url)) {
            $direct_url = $_MG_CONF['mediaobjects_url'] . '/' . 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg';
        } else {
            $direct_url = $_MG_CONF['mediaobjects_url'] . '/' . $direct_url;
        }
    } else {
        $direct_url = $media_thumbnail;
    }
    if ($MG_albums[$M['album_id']]->access == 3) {
        $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;s=1&amp;album_id=' . $M['album_id'] . '&amp;mid=' . $M['media_id'] . '">' . $LANG_MG01['edit'] . '</a>';
    } else {
        $edit_item = '';
    }
    $L = new Template(MG_getTemplatePath(0));
    $L->set_file('media_link', 'medialink.thtml');
    $L->set_var('href', $url_media_item);
    $L->set_var('hrefdirect', $direct_url);
    $L->set_var('caption', PLG_replaceTags($M['media_title'], 'mediagallery', 'media_title'));
    $L->set_var('id', 'id' . rand());
    $L->parse('media_link_start', 'media_link');
    $media_start_link = $L->finish($L->get_var('media_link_start'));
    $T->set_var(array('row_height' => $tn_height + 40, 'media_title' => isset($M['media_title']) && $M['media_title'] != '' && $M['media_title'] != ' ' ? PLG_replaceTags($M['media_title'], 'mediagallery', 'media_title') : '', 'media_description' => isset($M['media_desc']) && $M['media_desc'] != '' && $M['media_desc'] != ' ' ? PLG_replaceTags($M['media_desc'], 'mediagallery', 'media_title') : '', 'media_tag' => isset($M['media_title']) && $M['media_title'] != '' && $M['media_title'] != ' ' ? strip_tags($M['media_title']) : '', 'media_time' => $media_time[0], 'media_owner' => $username, 'site_url' => $_MG_CONF['site_url'], 'lang_published' => $LANG_MG03['published'], 'lang_on' => $LANG_MG03['on'], 'media_link_start' => '<a href="' . $url_media_item . '">', 'media_link_end' => '</a>', 'artist' => isset($M['artist']) && $M['artist'] != ' ' ? $M['artist'] : '', 'musicalbum' => isset($M['album']) && $M['album'] != ' ' ? $M['album'] : '', 'genre' => isset($M['genre']) && $M['genre'] != ' ' ? $M['genre'] : '', 'search_album' => $LANG_MG01['album'] . ': <a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $M['album_id'] . '">' . $MG_albums[$M['album_id']]->title . '</a>'));
    // frame template variables
    $F->set_var(array('media_link_start' => $media_start_link, 'media_link_end' => '</a>', 'url_media_item' => $url_media_item, 'url_display_item' => $url_display_item, 'media_thumbnail' => $media_thumbnail, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'border_width' => $newwidth + 15, 'border_height' => $newheight + 15, 'row_height' => $tn_height + 40, 'frWidth' => $newwidth - $frWidth, 'frHeight' => $newheight - $frHeight, 'media_tag' => strip_tags($M['media_desc']), 'search_album' => $LANG_MG01['album'] . ': <a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $M['album_id'] . '">' . $MG_albums[$M['album_id']]->title . '</a>'));
    $F->parse('media', 'media_frame');
    $media_item_thumbnail = $F->finish($F->get_var('media'));
    $T->set_var('media_item_thumbnail', $media_item_thumbnail);
    if (!empty($M['media_keywords'])) {
        $kwText = '';
        $keyWords = array();
        $keyWords = explode(' ', $M['media_keywords']);
        $numKeyWords = count($keyWords);
        for ($i = 0; $i < $numKeyWords; $i++) {
            $keyWords[$i] = str_replace('"', ' ', $keyWords[$i]);
            $searchKeyword = $keyWords[$i];
            $keyWords[$i] = str_replace('_', ' ', $keyWords[$i]);
            $kwText .= $keyWords[$i] . ' ';
        }
        $T->set_var(array('media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords']));
        $T->parse('media_cell_keywords', 'media_cell_keywords');
    } else {
        $T->set_var('lang_keywords', '');
    }
    if ($_MG_CONF['search_enable_rating']) {
        if ($M['media_type'] == 4 || $M['media_type'] == 1 && $playback_type != 2 || $M['media_type'] == 2 && $playback_type != 2 || $M['media_type'] == 5 && $playback_type != 2) {
            $rateLink = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&amp;sort=' . $sortOrder . '&amp;s=' . $M['media_id'] . '">' . $LANG_MG03['rating'] . '</a>';
        } else {
            $rateLink = $LANG_MG03['rating'];
        }
        $rating = $rateLink . ': <strong> ' . $M['media_rating'] / 2 . '</strong>/5 (' . $M['media_votes'] . ' ' . $LANG_MG03['votes'] . ')';
        $T->set_var(array('media_rating' => $rating));
        $T->parse('media_rate_results', 'media_rate_results');
    }
    if ($_MG_CONF['search_enable_views']) {
        $T->set_var(array('media_views_count' => $M['media_views'], 'lang_views' => $LANG_MG03['views']));
        $T->parse('media_views', 'media_views');
    }
    $T->parse('media_cell', 'media_cell_image');
    $retval = $T->finish($T->get_var('media_cell'));
    return $retval;
}
示例#2
0
function MG_editConfig($msgString = '')
{
    global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $LANG_DIRECTION, $LANG04;
    $retval = '';
    $T = new Template($_MG_CONF['template_path'] . '/admin');
    $T->set_file('admin', 'cfgedit.thtml');
    $T->set_var('site_url', $_MG_CONF['site_url']);
    if ($msgString != '') {
        $T->set_var('feedback', $msgString);
    }
    if (!isset($_MG_CONF['rating_max'])) {
        $_MG_CONF['rating_max'] = 5;
    }
    if (!isset($_MG_CONF['moderation'])) {
        $_MG_CONF['moderation'] = 0;
    }
    // build our graphics package select...
    $gp_select = "<select name='graphicspackage'>";
    $gp_select .= "<option value='0'" . ($_MG_CONF['graphicspackage'] == 0 ? ' selected="selected"' : "") . ">ImageMagick</option>";
    $gp_select .= "<option value='1'" . ($_MG_CONF['graphicspackage'] == 1 ? ' selected="selected"' : "") . ">NetPBM</option>";
    $gp_select .= "<option value='2'" . ($_MG_CONF['graphicspackage'] == 2 ? ' selected="selected"' : "") . ">GD Libraries</option>";
    $gp_select .= "</select>";
    $block_select = '<select name="displayblocks">';
    $block_select .= '<option value="0"' . ($_MG_CONF['displayblocks'] == 0 ? ' selected="selected"' : "") . '>' . $LANG_MG01['left_blocks_only'] . '</option>';
    $block_select .= '<option value="1"' . ($_MG_CONF['displayblocks'] == 1 ? ' selected="selected"' : "") . '>' . $LANG_MG01['right_blocks_only'] . '</option>';
    $block_select .= '<option value="2"' . ($_MG_CONF['displayblocks'] == 2 ? ' selected="selected"' : "") . '>' . $LANG_MG01['left_right_blocks'] . '</option>';
    $block_select .= '<option value="3"' . ($_MG_CONF['displayblocks'] == 3 ? ' selected="selected"' : "") . '>' . $LANG_MG01['none'] . '</option>';
    $block_select .= '</select>';
    $dfid_select = '<select name="dfid"><option value="99">' . $LANG_MG00['no_date'] . '</option>' . COM_optionList($_TABLES['dateformats'], 'dfid,description', $_MG_CONF['dfid'], 0) . '</select>';
    if (isset($_MG_CONF['index_all']) && $_MG_CONF['index_all'] == 1) {
        $T->set_var('index_all_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('index_all_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['loginrequired'] == 1) {
        $T->set_var('lr_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('lr_no_checked', ' checked="checked"');
    }
    if (isset($_MG_CONF['moderation']) && $_MG_CONF['moderation'] == 1) {
        $T->set_var('au_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('au_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['htmlallowed'] == 1) {
        $T->set_var('ha_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('ha_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['whatsnew'] == 1) {
        $T->set_var('wn_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('wn_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['usage_tracking'] == 1) {
        $T->set_var('ut_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('ut_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['preserve_filename'] == 1) {
        $T->set_var('pf_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('pf_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['discard_original'] == 1) {
        $T->set_var('do_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('do_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['verbose'] == 1) {
        $T->set_var('verbose_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('verbose_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['disable_whatsnew_comments'] == 1) {
        $T->set_var('dwnc_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('dwnc_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['enable_media_id'] == 1) {
        $T->set_var('emid_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('emid_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['full_in_popup'] == 1) {
        $T->set_var('fip_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('fip_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['commentbar'] == 1) {
        $T->set_var('cmtbar_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('cmtbar_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['profile_hook'] == 1) {
        $T->set_var('ph_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('ph_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['subalbum_select'] == 1) {
        $T->set_var('sa_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('sa_no_checked', ' checked="checked"');
    }
    $T->set_var('wn_length', $_MG_CONF['title_length']);
    // -- auto tag defaults
    if ($_MG_CONF['at_border'] == 1) {
        $T->set_var('at_border_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('at_border_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['at_autoplay'] == 1) {
        $T->set_var('at_autoplay_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('at_autoplay_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['at_enable_link'] == 2) {
        $T->set_var('at_enable_link_lb_checked', ' checked="checked"');
    } elseif ($_MG_CONF['at_enable_link'] == 1) {
        $T->set_var('at_enable_link_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('at_enable_link_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['at_showtitle'] == 1) {
        $T->set_var('at_showtitle_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('at_showtitle_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['search_enable_views'] == 1) {
        $T->set_var('search_enable_views_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('search_enable_views_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['search_enable_rating'] == 1) {
        $T->set_var('search_enable_rating_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('search_enable_rating_no_checked', ' checked="checked"');
    }
    if ($_MG_CONF['gallery_only'] == 1) {
        $T->set_var('gallery_only_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('gallery_only_no_checked', ' checked="checked"');
    }
    $search_playback_type = '<select name="search_playback_type">';
    $search_playback_type .= '<option value="0"' . ($_MG_CONF['search_playback_type'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['play_in_popup'] . '</option>';
    $search_playback_type .= '<option value="1"' . ($_MG_CONF['search_playback_type'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['download_to_local'] . '</option>';
    $search_playback_type .= '<option value="2"' . ($_MG_CONF['search_playback_type'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['play_inline'] . '</option>';
    $search_playback_type .= '<option value="3"' . ($_MG_CONF['search_playback_type'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['use_mms'] . '</option>';
    $search_playback_type .= '</select>';
    $at_align_select = '<select name="at_align">';
    $at_align_select .= '<option value="none"' . ($_MG_CONF['at_align'] == 'none' ? ' selected="selected"' : "") . '>' . $LANG_MG01['none'] . '</option>';
    $at_align_select .= '<option value="auto"' . ($_MG_CONF['at_align'] == 'auto' ? ' selected="selected"' : "") . '>' . $LANG_MG01['auto'] . '</option>';
    $at_align_select .= '<option value="left"' . ($_MG_CONF['at_align'] == 'left' ? ' selected="selected"' : "") . '>' . $LANG_MG01['left'] . '</option>';
    $at_align_select .= '<option value="right"' . ($_MG_CONF['at_align'] == 'right' ? ' selected="selected"' : "") . '>' . $LANG_MG01['right'] . '</option>';
    $at_align_select .= '<option value="center"' . ($_MG_CONF['at_align'] == 'center' ? ' selected="selected"' : "") . '>' . $LANG_MG01['center'] . '</option>';
    $at_align_select .= '</select>';
    $at_src_select = '<select name="at_src">';
    $at_src_select .= '<option value="tn"' . ($_MG_CONF['at_src'] == 'tn' ? ' selected="selected"' : "") . '>' . $LANG_MG01['thumbnail'] . '</option>';
    $at_src_select .= '<option value="disp"' . ($_MG_CONF['at_src'] == 'disp' ? ' selected="selected"' : "") . '>' . $LANG_MG01['display_image'] . '</option>';
    $at_src_select .= '<option value="orig"' . ($_MG_CONF['at_src'] == 'orig' ? ' selected="selected"' : "") . '>' . $LANG_MG01['original_image'] . '</option>';
    $at_src_select .= '</select>';
    $wn_time_select = '<select name="whatsnew_time">';
    $wn_time_select .= '<option value="1"' . ($_MG_CONF['whatsnew_time'] == 1 ? ' selected="selected"' : "") . '>1 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="2"' . ($_MG_CONF['whatsnew_time'] == 2 ? ' selected="selected"' : "") . '>2 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="3"' . ($_MG_CONF['whatsnew_time'] == 3 ? ' selected="selected"' : "") . '>3 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="4"' . ($_MG_CONF['whatsnew_time'] == 4 ? ' selected="selected"' : "") . '>4 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="5"' . ($_MG_CONF['whatsnew_time'] == 5 ? ' selected="selected"' : "") . '>5 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="6"' . ($_MG_CONF['whatsnew_time'] == 6 ? ' selected="selected"' : "") . '>6 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="7"' . ($_MG_CONF['whatsnew_time'] == 7 ? ' selected="selected"' : "") . '>7 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="8"' . ($_MG_CONF['whatsnew_time'] == 8 ? ' selected="selected"' : "") . '>8 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="9"' . ($_MG_CONF['whatsnew_time'] == 9 ? ' selected="selected"' : "") . '>9 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="10"' . ($_MG_CONF['whatsnew_time'] == 10 ? ' selected="selected"' : "") . '>10 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="11"' . ($_MG_CONF['whatsnew_time'] == 11 ? ' selected="selected"' : "") . '>11 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="12"' . ($_MG_CONF['whatsnew_time'] == 12 ? ' selected="selected"' : "") . '>12 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="13"' . ($_MG_CONF['whatsnew_time'] == 13 ? ' selected="selected"' : "") . '>13 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="14"' . ($_MG_CONF['whatsnew_time'] == 14 ? ' selected="selected"' : "") . '>14 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="15"' . ($_MG_CONF['whatsnew_time'] == 15 ? ' selected="selected"' : "") . '>15 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="16"' . ($_MG_CONF['whatsnew_time'] == 16 ? ' selected="selected"' : "") . '>16 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="17"' . ($_MG_CONF['whatsnew_time'] == 17 ? ' selected="selected"' : "") . '>17 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="18"' . ($_MG_CONF['whatsnew_time'] == 18 ? ' selected="selected"' : "") . '>18 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="19"' . ($_MG_CONF['whatsnew_time'] == 19 ? ' selected="selected"' : "") . '>19 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="20"' . ($_MG_CONF['whatsnew_time'] == 20 ? ' selected="selected"' : "") . '>20 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="21"' . ($_MG_CONF['whatsnew_time'] == 21 ? ' selected="selected"' : "") . '>21 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="22"' . ($_MG_CONF['whatsnew_time'] == 22 ? ' selected="selected"' : "") . '>22 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="23"' . ($_MG_CONF['whatsnew_time'] == 23 ? ' selected="selected"' : "") . '>23 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="24"' . ($_MG_CONF['whatsnew_time'] == 24 ? ' selected="selected"' : "") . '>24 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="25"' . ($_MG_CONF['whatsnew_time'] == 25 ? ' selected="selected"' : "") . '>25 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="26"' . ($_MG_CONF['whatsnew_time'] == 26 ? ' selected="selected"' : "") . '>26 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="27"' . ($_MG_CONF['whatsnew_time'] == 27 ? ' selected="selected"' : "") . '>27 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="28"' . ($_MG_CONF['whatsnew_time'] == 28 ? ' selected="selected"' : "") . '>28 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="29"' . ($_MG_CONF['whatsnew_time'] == 29 ? ' selected="selected"' : "") . '>29 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '<option value="30"' . ($_MG_CONF['whatsnew_time'] == 30 ? ' selected="selected"' : "") . '>30 ' . $LANG_MG01['days'] . '</option>';
    $wn_time_select .= '</select>';
    $rating_select = '<select name="rating_max">';
    $rating_select .= '<option value="5"' . ($_MG_CONF['rating_max'] == 5 ? ' selected="selected"' : "") . '>5</option>';
    $rating_select .= '<option value="10"' . ($_MG_CONF['rating_max'] == 10 ? ' selected="selected"' : "") . '>10</option>';
    $rating_select .= '<option value="15"' . ($_MG_CONF['rating_max'] == 15 ? ' selected="selected"' : "") . '>15</option>';
    $rating_select .= '<option value="20"' . ($_MG_CONF['rating_max'] == 20 ? ' selected="selected"' : "") . '>20</option>';
    $rating_select .= '</select>';
    $gallery_tn_size_select = '<select name="gallery_tn_size">';
    $gallery_tn_size_select .= '<option value="0"' . ($_MG_CONF['gallery_tn_size'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['small'] . '</option>';
    $gallery_tn_size_select .= '<option value="1"' . ($_MG_CONF['gallery_tn_size'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['medium'] . '</option>';
    $gallery_tn_size_select .= '<option value="2"' . ($_MG_CONF['gallery_tn_size'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['large'] . '</option>';
    $gallery_tn_size_select .= '<option value="3"' . ($_MG_CONF['gallery_tn_size'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['custom'] . '</option>';
    $gallery_tn_size_select .= '<option value="4"' . ($_MG_CONF['gallery_tn_size'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG01['square'] . '</option>';
    $gallery_tn_size_select .= '</select>';
    $gallery_tnheight_input = '<input type="text" size="3" name="tnheight" value="' . $_MG_CONF['gallery_tn_height'] . '" />';
    $gallery_tnwidth_input = '<input type="text" size="3" name="tnwidth" value="' . $_MG_CONF['gallery_tn_width'] . '" />';
    $mp3_select = '<select name="mp3_player">';
    $mp3_select .= '<option value="0"' . ($_MG_CONF['mp3_player'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['windows_media_player'] . '</option>';
    $mp3_select .= '<option value="1"' . ($_MG_CONF['mp3_player'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['quicktime'] . '</option>';
    $mp3_select .= '<option value="2"' . ($_MG_CONF['mp3_player'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['flashplayer'] . '</option>';
    $mp3_select .= '</select>';
    $flv_select = '<select name="use_flowplayer">';
    $flv_select .= '<option value="0"' . ($_MG_CONF['use_flowplayer'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['mgflv'] . '</option>';
    $flv_select .= '<option value="1"' . ($_MG_CONF['use_flowplayer'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['flowplayer'] . '</option>';
    $flv_select .= '</select>';
    $T->set_var(array('popupfromalbum_selected' => $_MG_CONF['popup_from_album'] ? ' checked="checked"' : '', 'autotag_caption_selected' => $_MG_CONF['autotag_caption'] ? ' checked="checked"' : '', 'up_dr_selected' => $_MG_CONF['up_display_rows_enabled'] ? ' checked="checked"' : '', 'up_dc_selected' => $_MG_CONF['up_display_columns_enabled'] ? ' checked="checked"' : '', 'up_mp3_selected' => $_MG_CONF['up_mp3_player_enabled'] ? ' checked="checked"' : '', 'up_playback_selected' => $_MG_CONF['up_av_playback_enabled'] ? ' checked="checked"' : '', 'up_tn_size_selected' => $_MG_CONF['up_thumbnail_size_enabled'] ? ' checked="checked"' : '', 'jh_selected' => $_MG_CONF['jhead_enabled'] ? ' checked="checked"' : '', 'jt_selected' => $_MG_CONF['jpegtran_enabled'] ? ' checked="checked"' : '', 'zip_selected' => $_MG_CONF['zip_enabled'] ? ' checked="checked"' : '', 'ffmpeg_selected' => $_MG_CONF['ffmpeg_enabled'] ? ' checked="checked"' : '', 'at_align_select' => $at_align_select, 'at_width' => $_MG_CONF['at_width'], 'at_height' => $_MG_CONF['at_height'], 'at_src_select' => $at_src_select, 'at_delay' => $_MG_CONF['at_delay'], 'flv_select' => $flv_select, 'search_playback_type' => $search_playback_type, 'search_columns' => $_MG_CONF['search_columns'], 'search_rows' => $_MG_CONF['search_rows']));
    if ($_MG_CONF['up_display_rows_enabled'] == 1) {
        $T->set_var('up_dr_yes_checked', ' checked="checked"');
    } else {
        $T->set_var('up_dr_no_checked', ' checked="checked"');
    }
    if (ini_get('safe_mode') != 1 && $_MG_CONF['skip_file_find'] == 0) {
        // don't check in safe mode, the file_exists() will fail
        if (PHP_OS == "WINNT") {
            $binary = "/unzip.exe";
        } else {
            $binary = "/unzip";
        }
        clearstatcache();
        if (file_exists($_MG_CONF['zip_path'] . $binary)) {
            // do nothing..
        } else {
            clearstatcache();
            $_MG_CONF['zip_path'] = '/usr/bin';
            if (file_exists($_MG_CONF['zip_path'] . $binary)) {
                // do nothing..
            } else {
                clearstatcache();
                $_MG_CONF['zip_path'] = '/usr/local/bin';
                if (file_exists($_MG_CONF['zip_path'] . $binary)) {
                    // do nothing..
                } else {
                    clearstatcache();
                    $_MG_CONF['zip_path'] = '/usr/X11R6/bin';
                    if (file_exists($_MG_CONF['zip_path'] . $binary)) {
                        // do nothing..
                    }
                }
            }
        }
        if (PHP_OS == "WINNT") {
            $binary = "/ffmpeg.exe";
        } else {
            $binary = "/ffmpeg";
        }
        clearstatcache();
        if (file_exists($_MG_CONF['ffmpeg_path'] . $binary)) {
            // do nothing..
        } else {
            clearstatcache();
            $_MG_CONF['ffmpeg_path'] = '/usr/bin';
            if (file_exists($_MG_CONF['ffmpeg_path'] . $binary)) {
                // do nothing..
            } else {
                clearstatcache();
                $_MG_CONF['ffmpeg_path'] = '/usr/local/bin';
                if (file_exists($_MG_CONF['ffmpeg_path'] . $binary)) {
                    // do nothing..
                } else {
                    clearstatcache();
                    $_MG_CONF['ffmpeg_path'] = '/usr/X11R6/bin';
                    if (file_exists($_MG_CONF['ffmpeg_path'] . $binary)) {
                        // do nothing..
                    }
                }
            }
        }
    }
    $frames = new mgFrame();
    $skins = array();
    $skins = $frames->getFrames();
    if (!isset($_MG_CONF['random_skin']) || $_MG_CONF['random_skin'] == '') {
        $_MG_CONF['random_skin'] = 'mgShadow';
    }
    $skin_select = '<select name="skin">';
    $rskin_select = '<select name="rskin">';
    for ($i = 0; $i < count($skins); $i++) {
        $skin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($_MG_CONF['indexskin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
        $rskin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($_MG_CONF['random_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
    }
    $skin_select .= '</select>';
    $rskin_select .= '</select>';
    $themes = array();
    $themes = MG_getThemes();
    $theme_select = '<select name="theme">';
    for ($i = 0; $i < count($themes); $i++) {
        $theme_select .= '<option value="' . $themes[$i] . '"' . ($_MG_CONF['indextheme'] == $themes[$i] ? ' selected="selected" ' : '') . '>' . $themes[$i] . '</option>';
    }
    $theme_select .= '</select>';
    require_once $_CONF['path_system'] . 'classes/navbar.class.php';
    $navbar = new navbar();
    $navbar->add_menuitem($LANG_MG01['general_options'], 'showhideMGAdminEditorDiv("general",0);return false;', true);
    $navbar->add_menuitem($LANG_MG01['display_options'], 'showhideMGAdminEditorDiv("display",1);return false;', true);
    $navbar->add_menuitem($LANG_MG01['batch_options'], 'showhideMGAdminEditorDiv("batch",2);return false;', true);
    $navbar->add_menuitem($LANG_MG01['up_overrides'], 'showhideMGAdminEditorDiv("userprefs",3);return false;', true);
    $navbar->add_menuitem($LANG_MG01['graphicspackage_prompt'], 'showhideMGAdminEditorDiv("graphics",4);return false;', true);
    $navbar->set_selected($LANG_MG01['general_options']);
    $T->set_var('navbar', $navbar->generate());
    $T->set_var(array('no_javascript_warning' => $LANG04[150], 'lang_config_title' => $LANG_MG01['configuration_title'], 'lang_config_help' => $LANG_MG01['configuration_help'], 'lang_config_header' => $LANG_MG01['configuration_header'], 'lang_yes' => $LANG_MG01['yes'], 'lang_no' => $LANG_MG01['no'], 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_reset' => $LANG_MG01['reset'], 'lang_album_columns' => $LANG_MG01['album_display_columns_prompt'], 'lang_album_colums_help' => $LANG_MG01['album_display_columns_help'], 'lang_album_rows' => $LANG_MG01['album_display_rows'], 'lang_subalbum_select' => $LANG_MG01['subalbum_select'], 'lang_loginrequired' => $LANG_MG01['loginrequired_prompt'], 'lang_loginrequired_help' => $LANG_MG01['loginrequired_help'], 'lang_anonymous_uploads' => $LANG_MG01['anonymous_uploads_prompt'], 'lang_anonymous_uploads_help' => $LANG_MG01['anonymous_uploads_help'], 'lang_comments' => $LANG_MG01['comments_prompt'], 'lang_comments_help' => $LANG_MG01['comments_help'], 'lang_graphicspackage' => $LANG_MG01['graphicspackage_prompt'], 'lang_graphicspackage_help' => $LANG_MG01['graphicspackage_help'], 'lang_gp_path' => $LANG_MG01['graphicspackage_path_prompt'], 'lang_gp_path_help' => $LANG_MG01['graphicspackage_path_help'], 'lang_userpref_options' => $LANG_MG01['up_overrides'], 'lang_display_rows_enabled' => $LANG_MG01['up_rows_override'], 'lang_display_columns_enabled' => $LANG_MG01['up_columns_override'], 'lang_mp3_player_enabled' => $LANG_MG01['up_mp3_override'], 'lang_av_playback_enabled' => $LANG_MG01['up_av_override'], 'lang_thumbnail_size_enabled' => $LANG_MG01['up_tn_override'], 'lang_album_skin' => $LANG_MG01['index_album_skin'], 'lang_display_rows' => $LANG_MG01['album_display_rows'], 'album_display_columns' => $_MG_CONF['album_display_columns'], 'album_display_rows' => $_MG_CONF['album_display_rows'], 'loginrequired' => $_MG_CONF['loginrequired'], 'anonymous_uploads' => $_MG_CONF['moderation'], 'graphicspackage' => $gp_select, 'graphicspackage_path' => $_MG_CONF['graphicspackage_path'], 'lang_displayblock' => $LANG_MG01['displayblock_prompt'], 'lang_displayblock_help' => $LANG_MG01['displayblock_help'], 'lang_jhead_enable' => $LANG_MG01['jhead_enable'], 'lang_jh_path' => $LANG_MG01['jhead_path'], 'lang_jpegtran_enable' => $LANG_MG01['jpegtran_enable'], 'lang_ffmpeg_enable' => $LANG_MG01['ffmpeg_enable'], 'lang_jt_path' => $LANG_MG01['jpegtran_path'], 'lang_zip_enable' => $LANG_MG01['zip_enable'], 'lang_zip_path' => $LANG_MG01['zip_path'], 'lang_tmp_path' => $LANG_MG01['tmp_path'], 'lang_ffmpeg_path' => $LANG_MG01['ffmpeg_path'], 'jhead_path' => $_MG_CONF['jhead_path'], 'jpegtran_path' => $_MG_CONF['jpegtran_path'], 'zip_path' => $_MG_CONF['zip_path'], 'tmp_path' => $_MG_CONF['tmp_path'], 'ftp_path' => $_MG_CONF['ftp_path'], 'ffmpeg_path' => $_MG_CONF['ffmpeg_path'], 'displayblock' => $block_select, 'dfidselect' => $dfid_select, 'rating_select' => $rating_select, 'wn_time_select' => $wn_time_select, 'custom_image_height' => $_MG_CONF['custom_image_height'], 'random_width' => $_MG_CONF['random_width'], 'random_skin' => $_MG_CONF['random_skin'], 'custom_image_width' => $_MG_CONF['custom_image_width'], 'refresh_rate' => $_MG_CONF['def_refresh_rate'], 'item_limit' => $_MG_CONF['def_item_limit'], 'time_limit' => $_MG_CONF['def_time_limit'], 'gallery_tn_size_select' => $gallery_tn_size_select, 'gallery_tnheight_input' => $gallery_tnheight_input, 'gallery_tnwidth_input' => $gallery_tnwidth_input, 'jpg_quality' => $_MG_CONF['jpg_quality'], 'tn_jpg_quality' => $_MG_CONF['tn_jpg_quality'], 'orig_jpg_quality' => $_MG_CONF['jpg_orig_quality'], 'truncate_breadcrumb' => $_MG_CONF['truncate_breadcrumb'], 'seperator' => $_MG_CONF['seperator'], 'mp3_select' => $mp3_select, 'skin_select' => $skin_select, 'rskin_select' => $rskin_select, 'theme_select' => $theme_select, 'postcard_retention' => $_MG_CONF['postcard_retention'], 'lang_wn_time' => $LANG_MG01['whatsnew_time'], 'lang_theme_select' => $LANG_MG01['index_theme'], 'lang_gallery_tn_size' => $LANG_MG01['gallery_tn_size'], 'lang_jpg_quality' => $LANG_MG01['jpg_quality'], 'lang_tn_jpg_quality' => $LANG_MG01['tn_jpg_quality'], 'lang_orig_jpg_quality' => $LANG_MG01['orig_jpg_quality'], 'lang_truncate_breadcrumb' => $LANG_MG01['truncate_breadcrumb'], 'lang_seperator' => $LANG_MG01['seperator'], 'lang_mp3_player' => $LANG_MG01['mp3_player'], 'lang_htmlallowed' => $LANG_MG01['htmlallowed'], 'lang_whatsnew' => $LANG_MG01['whatsnew'], 'lang_dfid' => $LANG_MG01['dfid'], 'lang_general_options' => $LANG_MG01['general_options'], 'lang_display_options' => $LANG_MG01['display_options'], 'lang_graphics_options' => $LANG_MG01['graphics_options'], 'lang_usage_tracking' => $LANG_MG01['usage_tracking'], 'lang_gallery_import' => $LANG_MG01['gallery_import'], 'lang_4images_import' => $LANG_MG01['fourimages_import'], 'lang_xppubwiz_install' => $LANG_MG01['xppubwizard_install'], 'lang_logviewer' => $LANG_MG01['log_viewer'], 'lang_preserve_filename' => $LANG_MG01['preserve_filename'], 'lang_discard_originals' => $LANG_MG01['discard_originals'], 'lang_custom_image_height' => $LANG_MG01['custom_image_height'], 'lang_custom_image_width' => $LANG_MG01['custom_image_width'], 'lang_verbose' => $LANG_MG01['verbose'], 'lang_dwnc' => $LANG_MG01['disable_wn_comments'], 'lang_emid' => $LANG_MG01['enable_mid'], 'lang_fip' => $LANG_MG01['full_in_popup'], 'lang_cmtbar' => $LANG_MG01['cmtbar'], 'lang_wn_length' => $LANG_MG01['wn_title_length'], 'lang_batch_options' => $LANG_MG01['batch_options'], 'lang_refresh_rate' => $LANG_MG01['refresh_rate'], 'lang_time_limit' => $LANG_MG01['time_limit'], 'lang_item_limit' => $LANG_MG01['item_limit'], 'lang_ftp_path' => $LANG_MG01['ftp_path'], 'lang_characters' => $LANG_MG01['characters'], 'lang_postcard_retention' => $LANG_MG01['postcard_retention'], 'lang_profile_hook' => $LANG_MG01['profile_hook'], 's_form_action' => $_MG_CONF['admin_url'] . 'cfgedit.php', 'rtl' => $LANG_DIRECTION == "rtl" ? "rtl" : "", 'lang_autotag_caption' => $LANG_MG01['autotag_caption'], 'lang_popup_from_album' => $LANG_MG01['popup_from_album'], 'lang_random_size' => $LANG_MG01['random_size'], 'lang_random_skin' => $LANG_MG01['random_skin'], 'lang_auto_tag_defaults' => $LANG_MG01['auto_tag_defaults'], 'lang_alignment' => $LANG_MG01['alignment'], 'lang_border' => $LANG_MG01['border'], 'lang_width' => $LANG_MG01['width'], 'lang_height' => $LANG_MG01['height'], 'lang_source' => $LANG_MG01['source'], 'lang_autoplay' => $LANG_MG01['autoplay'], 'lang_link_to_media' => $LANG_MG01['link_to_media'], 'lang_ss_delay' => $LANG_MG01['ss_delay'], 'lang_show_titles' => $LANG_MG01['show_titles'], 'lang_flv' => $LANG_MG01['flash_video_player'], 'lang_search_result_options' => $LANG_MG01['search_result_options'], 'lang_search_columns' => $LANG_MG01['search_columns'], 'lang_search_rows' => $LANG_MG01['search_rows'], 'lang_search_av_playback' => $LANG_MG01['search_av_playback'], 'lang_search_views' => $LANG_MG01['search_views'], 'lang_search_rating' => $LANG_MG01['search_rating'], 'lang_gallery_only' => $LANG_MG01['gallery_only'], 'lang_tnheight' => $LANG_MG01['tn_height'], 'lang_tnwidth' => $LANG_MG01['tn_width'], 'lang_index_all' => $LANG_MG01['index_all'], 'gltoken_name' => CSRF_TOKEN, 'gltoken' => SEC_createToken()));
    $T->parse('output', 'admin');
    $retval .= $T->finish($T->get_var('output'));
    return $retval;
}
示例#3
0
function MG_indexAll()
{
    global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle, $ImageSkin, $sortOrder, $displayColumns, $displayRows, $tnSize, $level, $album_jumpbox;
    $album_id = 0;
    if (isset($_GET['aid'])) {
        $album_id = (int) COM_applyFilter($_GET['aid'], true);
    }
    $page = 0;
    if (isset($_GET['page'])) {
        $page = (int) COM_applyFilter($_GET['page'], true);
    }
    if ($page != 0) {
        $page = $page - 1;
    }
    $lbSlideShow = '';
    $errorMessage = '';
    $columns_per_page = $displayColumns;
    $rows_per_page = $displayRows;
    $media_per_page = $columns_per_page * $rows_per_page;
    // image frame setup
    $nFrame = new mgFrame();
    $nFrame->constructor($ImageSkin);
    $imageFrameTemplate = $nFrame->getTemplate();
    $frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR'];
    $frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB'];
    $fCSS = $nFrame->getCSS();
    // Let's build our admin menu options
    $showAdminBox = 0;
    $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB;
    $admin_box .= '<div>';
    $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB;
    $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB;
    if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && (isset($_USER['uid']) && $_USER['uid'] > 1)) {
        $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB;
        $showAdminBox = 1;
    }
    if ($MG_albums[0]->owner_id) {
        $admin_box .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB;
        $admin_box .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB;
        $admin_box .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB;
        $queue_count = DB_count($_TABLES['mg_media_album_queue']);
        $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB;
        $admin_box .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB;
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    } elseif ($MG_albums[0]->access == 3) {
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    } elseif ($_MG_CONF['member_albums'] == 1 && (isset($_USER['uid']) && $_USER['uid'] > 1) && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) {
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    }
    $admin_box .= '</select>' . LB;
    $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB;
    $admin_box .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB;
    $admin_box .= '</div>';
    $admin_box .= '</form>';
    if ($showAdminBox == 0) {
        $admin_box = '';
    }
    // construct the album jumpbox...
    $level = 0;
    $album_jumpbox = '<form name="jumpbox" id="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>';
    $album_jumpbox .= $LANG_MG03['jump_to'] . ':&nbsp;<select name="aid" onchange="forms[\'jumpbox\'].submit()">';
    $MG_albums[0]->buildJumpBox(0);
    $album_jumpbox .= '</select>';
    $album_jumpbox .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>';
    $album_jumpbox .= '<input type="hidden" name="page" value="1"/>';
    $album_jumpbox .= '</div></form>';
    // initialize our variables
    $total_media = 0;
    $arrayCounter = 0;
    $total_object_count = 0;
    $mediaObject = array();
    $begin = $media_per_page * $page;
    $end = $media_per_page;
    $MG_media = array();
    // loop thru all the albums and build a list of valid albums that the user can see
    $first = 0;
    $albumList = getAlbumList($album_id, $first);
    $orderBy = ' ORDER BY m.media_upload_time ' . $sortOrder;
    if ($albumList != '') {
        $sql = "SELECT COUNT(*) AS total FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id IN (" . $albumList . ") " . $orderBy;
        $result = DB_query($sql);
        $row = DB_fetchArray($result);
        $cCount = $row['total'];
    } else {
        $cCount = 0;
    }
    if ($albumList != '') {
        $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id IN (" . $albumList . ") " . $orderBy;
        $sql .= ' LIMIT ' . $begin . ',' . $end;
        $result = DB_query($sql);
        $nRows = DB_numRows($result);
    } else {
        $nRows = 0;
    }
    $mediaRows = 0;
    $lbss_count = 0;
    $posCount = 0;
    if ($nRows > 0) {
        while ($row = DB_fetchArray($result)) {
            $media = new MediaItem();
            $media->constructor($row, $row['album_id']);
            $MG_media[$arrayCounter] = $media;
            $MG_albums[$row['album_id']]->imageFrameTemplate = $imageFrameTemplate;
            $arrayCounter++;
            $mediaRows++;
        }
    }
    $total_media = $total_media + $mediaRows;
    $total_items_in_album = $cCount;
    $total_pages = ceil($total_items_in_album / $media_per_page);
    if ($page >= $total_pages) {
        $page = $total_pages - 1;
    }
    $start = $page * $media_per_page;
    $current_print_page = floor($start / $media_per_page) + 1;
    $total_print_pages = ceil($total_items_in_album / $media_per_page);
    if ($current_print_page == 0) {
        $current_print_page = 1;
    }
    if ($total_print_pages == 0) {
        $total_print_pages = 1;
    }
    // now build the admin select...
    $admin_box = '';
    $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0">';
    $admin_box .= '<div><input type="hidden" name="album_id" value="' . $album_id . '"/>';
    $admin_box .= '<select name="mode" onchange="forms[\'adminbox\'].submit()">';
    $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>';
    $admin_box .= '<option value="search">' . $LANG_MG01['search'] . '</option>';
    $uploadMenu = 0;
    $adminMenu = 0;
    if ($MG_albums[0]->owner_id) {
        $uploadMenu = 1;
        $adminMenu = 1;
    } else {
        if ($MG_albums[$album_id]->access == 3) {
            $uploadMenu = 1;
            $adminMenu = 1;
            if ($_MG_CONF['member_albums']) {
                if ($_MG_USERPREFS['active'] != 1) {
                    $uploadMenu = 0;
                    $adminMenu = 0;
                } else {
                    $uploadMenu = 1;
                    $adminMenu = 1;
                }
            }
        } else {
            if ($MG_albums[$album_id]->member_uploads == 1 && isset($_USER['uid']) && $_USER['uid'] >= 2) {
                $uploadMenu = 1;
                $adminMenu = 0;
            }
        }
    }
    if ($uploadMenu == 1) {
        $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>';
    }
    if ($adminMenu == 1) {
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>';
    } elseif ($_MG_CONF['member_albums'] == 1 && !empty($_USER['username']) && $_MG_CONF['member_create_new'] == 1 && $_MG_USERPREFS['active'] == 1 && $album_id == $_MG_CONF['member_album_root']) {
        $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>';
        $adminMenu = 1;
    }
    // now check for moderation capabilities....
    if ($MG_albums[$album_id]->member_uploads == 1 && $MG_albums[$album_id]->moderate == 1) {
        // check to see if we are in the album_mod_group
        if (SEC_inGroup($MG_albums[$album_id]->mod_group_id) || $MG_albums[0]->owner_id) {
            $queue_count = DB_count($_TABLES['mg_media_album_queue'], 'album_id', $album_id);
            $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>';
            $adminMenu = 1;
        }
    }
    $admin_box .= '</select>';
    $admin_box .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '" style="padding:0px;margin:0px;"/>';
    $admin_box .= '</div></form>';
    if ($uploadMenu == 0 && $adminMenu == 0) {
        $admin_box = '';
    }
    if ($MG_albums[$album_id]->enable_sort == 1) {
        $sort_box = '<form name="sortbox" id="sortbox" action="' . $_MG_CONF['site_url'] . '/album.php" method="get" style="margin:0;padding:0"><div>';
        $sort_box .= '<input type="hidden" name="aid" value="' . $album_id . '"/>';
        $sort_box .= '<input type="hidden" name="page" value="' . $page . '"/>';
        $sort_box .= $LANG_MG03['sort_by'] . '&nbsp;<select name="sort" onchange="forms[\'sortbox\'].submit()">';
        $sort_box .= '<option value="0" ' . ($sortOrder == 0 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default'] . '</option>';
        $sort_box .= '<option value="1" ' . ($sortOrder == 1 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default_asc'] . '</option>';
        $sort_box .= '<option value="2" ' . ($sortOrder == 2 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload'] . '</option>';
        $sort_box .= '<option value="3" ' . ($sortOrder == 3 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload_asc'] . '</option>';
        $sort_box .= '<option value="4" ' . ($sortOrder == 4 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture'] . '</option>';
        $sort_box .= '<option value="5" ' . ($sortOrder == 5 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture_asc'] . '</option>';
        $sort_box .= '<option value="6" ' . ($sortOrder == 6 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating'] . '</option>';
        $sort_box .= '<option value="7" ' . ($sortOrder == 7 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating_asc'] . '</option>';
        $sort_box .= '<option value="8" ' . ($sortOrder == 8 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views'] . '</option>';
        $sort_box .= '<option value="9" ' . ($sortOrder == 9 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views_asc'] . '</option>';
        $sort_box .= '<option value="10" ' . ($sortOrder == 10 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha'] . '</option>';
        $sort_box .= '<option value="11" ' . ($sortOrder == 11 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha_asc'] . '</option>';
        $sort_box .= '</select>';
        $sort_box .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>';
        $sort_box .= '</div></form>';
    } else {
        $sort_box = '';
    }
    $owner_id = $MG_albums[$album_id]->owner_id;
    if ($owner_id == '' || !isset($MG_albums[$album_id]->owner_id)) {
        $owner_id = 0;
    }
    $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . (int) $owner_id);
    $album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update);
    $T = new Template($_MG_CONF['template_path']);
    $T->set_file(array('page' => 'index-all.thtml'));
    //@TODO fix language tag
    $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'album_title' => "All Photos - Sorted by Post Date", 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => $album_jumpbox, 'album_id' => $album_id, 'lbslideshow' => $lbSlideShow, 'album_description' => $MG_albums[$album_id]->display_album_desc ? PLG_replaceTags($MG_albums[$album_id]->description) : '', 'album_id_display' => $MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => $admin_box, 'select_sortbox' => $sort_box, 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $MG_albums[$album_id]->getMediaCount(), 'lang_search' => $LANG_MG01['search'], 'table_columns' => $displayColumns));
    $T->set_var('select_adminbox', $admin_box);
    if ($_MG_CONF['rss_full_enabled']) {
        $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss');
        $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">';
        $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>';
        $T->set_var('rsslink', $rsslink);
    } else {
        $T->set_var('rsslink', '');
    }
    // completed setting header / footer vars, parse them
    PLG_templateSetVars('mediagallery', $T);
    if ($total_media == 0) {
        $T->set_var(array('lang_no_image' => $LANG_MG03['no_media_objects']));
    }
    //
    // main processing of the album contents.
    //
    $noParse = 0;
    $needFinalParse = 0;
    if ($total_media > 0) {
        $k = 0;
        $T->set_block('page', 'ImageColumn', 'IColumn');
        $T->set_block('page', 'ImageRow', 'IRow');
        for ($i = 0; $i < $media_per_page; $i += $columns_per_page) {
            for ($j = $i; $j < $i + $columns_per_page; $j++) {
                if ($j >= $total_media) {
                    $k = $i + $columns_per_page - $j;
                    $m = $k % $columns_per_page;
                    for ($z = $m; $z > 0; $z--) {
                        $T->set_var(array('CELL_DISPLAY_IMAGE' => ''));
                        $T->parse('IColumn', 'ImageColumn', true);
                        $needFinalParse = 1;
                    }
                    if ($needFinalParse == 1) {
                        $T->parse('IRow', 'ImageRow', true);
                        $T->set_var('IColumn', '');
                    }
                    $noParse = 1;
                    break;
                }
                $previous_image = $i - 1;
                if ($previous_image < 0) {
                    $previous_image = -1;
                }
                $next_image = $i + 1;
                if ($next_image >= $total_media - 1) {
                    $next_image = -1;
                }
                $z = $j + $start;
                $celldisplay = $MG_media[$j]->displayThumb($z, 0, $imageFrameTemplate);
                if ($MG_media[$j]->type == 1) {
                    $PhotoURL = $_MG_CONF['mediaobjects_url'] . '/disp/' . $MG_media[$j]->filename[0] . '/' . $MG_media[$j]->filename . '.jpg';
                    $T->set_var(array('URL' => $PhotoURL));
                }
                $T->set_var(array('CELL_DISPLAY_IMAGE' => $celldisplay));
                $T->parse('IColumn', 'ImageColumn', true);
            }
            if ($noParse == 1) {
                break;
            }
            $T->parse('IRow', 'ImageRow', true);
            $T->set_var('IColumn', '');
        }
    }
    $T->parse('output', 'page');
    $fCSS = $nFrame->getCSS();
    if ($fCSS != '') {
        $outputHandle = outputHandler::getInstance();
        $outputHandle->addStyle($fCSS);
    }
    $display = MG_siteHeader(strip_tags($MG_albums[$album_id]->title));
    $display .= $T->finish($T->get_var('output'));
    $display .= MG_siteFooter();
    echo $display;
}
示例#4
0
function MG_index()
{
    global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle;
    $display = '';
    $media_size = false;
    $page = 0;
    if (isset($_GET['page'])) {
        $page = COM_applyFilter($_GET['page'], true);
    }
    if ($page != 0) {
        $page = $page - 1;
    }
    $themeStyle = MG_getThemeCSS(0);
    if (!isset($_MG_CONF['album_display_columns']) || $_MG_CONF['album_display_columns'] < 1) {
        $_MG_CONF['album_display_columns'] = 1;
    }
    switch ($_MG_CONF['album_display_columns']) {
        case 1:
            $albumListTemplate = 'gallery_page_body_1.thtml';
            $albumColumnWidth = "100%";
            break;
        case 2:
            $albumListTemplate = 'gallery_page_body_2.thtml';
            $albumColumnWidth = "50%";
            break;
        default:
            $albumListTemplate = 'gallery_page_body_3.thtml';
            $albumColumnWidth = @intval(100 / $_MG_CONF['album_display_columns']) . '%';
            if ($albumColumnWidth == 0) {
                $albumColumnWidth = "25%";
            }
            break;
    }
    $T = new Template(MG_getTemplatePath(0));
    $T->set_file(array('page' => 'gallery_page.thtml', 'body' => $albumListTemplate, 'noitems' => 'gallery_page_noitems.thtml'));
    $T->set_var(array('lang_menulabel' => $_MG_CONF['menulabel'], 'lang_search' => $LANG_MG01['search'], 'site_url' => $_MG_CONF['site_url']));
    if ($_MG_CONF['rss_full_enabled']) {
        $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss');
        $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">';
        $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>';
        $T->set_var('rsslink', $rsslink);
        $T->set_var('rsslink_url', $feedUrl);
    } else {
        $T->set_var('rsslink', '');
    }
    $nFrame = new mgFrame();
    $nFrame->constructor($_MG_CONF['indexskin']);
    $MG_albums[0]->albumFrameTemplate = $nFrame->getTemplate();
    $MG_albums[0]->afrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR'];
    $MG_albums[0]->afrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB'];
    // Let's build our admin menu options
    $showAdminBox = 0;
    $admin_box_item = '';
    $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB;
    $admin_box .= '<div>';
    $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB;
    $admin_box_item .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB;
    if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) {
        $admin_box_item .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB;
        $showAdminBox = 1;
    }
    if ($MG_albums[0]->owner_id) {
        $admin_box_item .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB;
        $admin_box_item .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB;
        $admin_box_item .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB;
        $queue_count = DB_count($_TABLES['mg_media_album_queue']);
        $admin_box_item .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB;
        $admin_box_item .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB;
        $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    } elseif ($MG_albums[0]->access == 3) {
        $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) {
        $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB;
        $showAdminBox = 1;
    }
    $admin_box .= $admin_box_item;
    $admin_box .= '</select>' . LB;
    $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB;
    $admin_box .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB;
    $admin_box .= '</div>';
    $admin_box .= '</form>';
    // build ul
    $admin_menu = '';
    $showAdminMenu = 0;
    $admin_url = $_MG_CONF['site_url'] . '/admin.php?album_id=0';
    if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) {
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=upload">' . $LANG_MG01['add_media'] . '</a></li>';
        $showAdminMenu = 1;
    }
    if ($MG_albums[0]->owner_id) {
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=albumsort">' . $LANG_MG01['sort_albums'] . '</a></li>';
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=globalattr">' . $LANG_MG01['globalattr'] . '</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=globalperm">' . $LANG_MG01['globalperm'] . '</a></li>' . LB;
        $queue_count = DB_count($_TABLES['mg_media_album_queue']);
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=wmmanage">' . $LANG_MG01['wm_management'] . '</a></li>' . LB;
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB;
        $showAdminMenu = 1;
    } elseif ($MG_albums[0]->access == 3) {
        $admin_Menu .= '<li><a href="' . $abmin_url . '&amp;mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB;
        $showAdminMenu = 1;
    } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) {
        $admin_menu .= '<li><a href="' . $admin_url . '&amp;mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB;
        $showAdminMenu = 1;
    }
    // end of ul
    if ($showAdminBox == 0) {
        $admin_box = '';
        $admin_box_item = '';
    }
    if ($showAdminMenu == 1) {
        $T->set_var('admin_menu', $admin_menu);
    }
    $T->set_var('select_adminbox', $admin_box);
    $T->set_var('select_box_items', $admin_box_item);
    $album_count = 0;
    $width = intval(100 / $_MG_CONF['album_display_columns']);
    $rowcounter = 0;
    $albumCount = 0;
    $indexCounter = 0;
    if (COM_isAnonUser()) {
        $lastlogin = time();
    } else {
        if (!COM_isAnonUser()) {
            $lastlogin = $_USER['lastlogin'];
        } else {
            $lastlogin = time();
        }
    }
    $children = $MG_albums[0]->getChildren();
    $nrows = count($children);
    $checkCounter = 0;
    $aCount = 0;
    $achild = array();
    for ($i = 0; $i < $nrows; $i++) {
        $access = $MG_albums[$children[$i]]->access;
        if ($access == 0 || $MG_albums[$children[$i]]->hidden == 1 && $access != 3) {
            // no op
        } else {
            $achild[] = $MG_albums[$children[$i]]->id;
            $aCount++;
        }
    }
    if ($_MG_CONF['album_display_rows'] < 1) {
        $_MG_CONF['album_display_rows'] = 9;
    }
    $items_per_page = $_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows'];
    $begin = $items_per_page * $page;
    $end = $items_per_page;
    $nrows = count($achild);
    $indexCounter = $begin;
    $noParse = 0;
    $needFinalParse = 0;
    if ($nrows > 0) {
        $k = 0;
        $T->set_block('body', 'AlbumColumn', 'AColumn');
        $T->set_block('body', 'AlbumRow', 'ARow');
        for ($i = $begin; $i < $begin + $items_per_page; $i += $_MG_CONF['album_display_columns']) {
            for ($j = $i; $j < $i + $_MG_CONF['album_display_columns']; $j++) {
                $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                if ($j >= $nrows) {
                    $k = $i + $_MG_CONF['album_display_columns'] - $j;
                    $m = $k % $_MG_CONF['album_display_columns'];
                    for ($z = $m; $z > 0; $z--) {
                        $needFinalParse = 1;
                    }
                    if ($needFinalParse == 1) {
                        $T->parse('ARow', 'AlbumRow', true);
                        $T->set_var('AColumn', '');
                    }
                    $noParse = 1;
                    break;
                }
                $access = $MG_albums[$achild[$indexCounter]]->access;
                if ($access == 0 || $MG_albums[$achild[$indexCounter]]->hidden == 1 && $access != 3) {
                    $j--;
                    $indexCounter++;
                    continue;
                }
                $albumCount++;
                if ($MG_albums[$achild[$indexCounter]]->media_count > 0) {
                    if ($MG_albums[$achild[$indexCounter]]->cover_filename != '' && $MG_albums[$achild[$indexCounter]]->cover_filename != '0') {
                        $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update);
                        if (substr($MG_albums[$achild[$indexCounter]]->cover_filename, 0, 3) == 'tn_') {
                            $offset = 3;
                        } else {
                            $offset = 0;
                        }
                        foreach ($_MG_CONF['validExtensions'] as $ext) {
                            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext)) {
                                $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext;
                                $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext);
                                break;
                            }
                        }
                        $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count;
                        if (!COM_isAnonUser()) {
                            if ($MG_albums[$achild[$indexCounter]]->last_update > $lastlogin) {
                                $album_last_update[0] = '<font color="red">' . $album_last_update[0] . '</font>';
                            }
                        }
                        $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt']));
                    } else {
                        $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count;
                        $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update);
                        $filename = $MG_albums[$achild[$indexCounter]]->findCover();
                        if ($filename == '') {
                            $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                            $media_size = array(200, 200);
                        } else {
                            if (substr($filename, 0, 3) == 'tn_') {
                                $offset = 3;
                            } else {
                                $offset = 0;
                            }
                            foreach ($_MG_CONF['validExtensions'] as $ext) {
                                if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext)) {
                                    $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[$offset] . '/' . $filename . $ext;
                                    $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext);
                                    break;
                                }
                            }
                        }
                        $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt']));
                    }
                } else {
                    // nothing in the album yet...
                    // here we need to search the sub-albums if any and see if we can find a picture....
                    $album_media_count = 0;
                    $album_last_update[0] = "";
                    $filename = $MG_albums[$achild[$indexCounter]]->findCover();
                    if ($filename == '') {
                        $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                        $media_size = array(200, 200);
                    } else {
                        foreach ($_MG_CONF['validExtensions'] as $ext) {
                            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) {
                                $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext;
                                $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext);
                                break;
                            }
                        }
                    }
                    $T->set_var('updated_prompt', '');
                }
                $T->clear_var(array('lang_views', 'views'));
                if ($MG_albums[$achild[$indexCounter]]->enable_album_views) {
                    $T->set_var(array('lang_views' => $LANG_MG03['views'], 'views' => $MG_albums[$achild[$indexCounter]]->views));
                }
                if ($MG_albums[$achild[$indexCounter]]->tn_attached == 1) {
                    $media_size = false;
                    foreach ($_MG_CONF['validExtensions'] as $ext) {
                        if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext)) {
                            $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext;
                            $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext);
                            break;
                        }
                    }
                }
                // a little fail safe here to make sure we don't show empty boxes...
                if ($media_size === false || $media_size[0] == 0 || $media_size[1] == 0) {
                    $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                    $media_size = array(200, 200);
                }
                // set the image size here...
                switch ($_MG_CONF['gallery_tn_size']) {
                    case '0':
                        //small
                        $tn_height = 100;
                        $tn_width = 100;
                        break;
                    case '1':
                        //medium
                        $tn_height = 150;
                        $tn_width = 150;
                        break;
                    case '2':
                        $tn_height = 200;
                        $tn_width = 200;
                        break;
                    case '3':
                        $tn_height = $_MG_CONF['gallery_tn_height'];
                        $tn_width = $_MG_CONF['gallery_tn_width'];
                        break;
                    default:
                        $tn_height = 200;
                        $tn_width = 200;
                        break;
                }
                if ($media_size[0] > $media_size[1]) {
                    $ratio = $media_size[0] / $tn_height;
                    $newwidth = $tn_height;
                    $newheight = @round($media_size[1] / $ratio);
                } else {
                    $ratio = $media_size[1] / $tn_height;
                    $newheight = $tn_height;
                    $newwidth = @round($media_size[0] / $ratio);
                }
                // pull the sub-album info here
                $subAlbumDisplay = '';
                if (isset($_MG_CONF['subalbum_select']) && $_MG_CONF['subalbum_select'] == 1) {
                    $subAlbumDisplay = '<form name="subalbums' . $MG_albums[$achild[$indexCounter]]->id . '" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0">';
                    $subAlbumDisplay .= '<select name="aid" onchange="forms[\'subalbums' . $MG_albums[$achild[$indexCounter]]->id . '\'].submit()">';
                    $subAlbumDisplay .= '<optgroup label="' . $LANG_MG01['select_subalbum'] . '">' . LB;
                }
                $saRows = 0;
                $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist'));
                if (!empty($MG_albums[$achild[$indexCounter]]->children)) {
                    $SAchildren = $MG_albums[$achild[$indexCounter]]->getChildren();
                    foreach ($SAchildren as $SAchild) {
                        if ($MG_albums[$SAchild]->access > 0) {
                            if ($MG_albums[$SAchild]->hidden) {
                                if ($MG_albums[$SAchild]->access == 3) {
                                    $mediaCount = $MG_albums[$SAchild]->getMediaCount();
                                    if ($_MG_CONF['subalbum_select'] == 1) {
                                        if (strlen($MG_albums[$SAchild]->title) > 50) {
                                            $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...';
                                        } else {
                                            $aTitle = $MG_albums[$SAchild]->title;
                                        }
                                        $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>';
                                    } else {
                                        $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&amp;page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>';
                                    }
                                    $saRows++;
                                }
                            } else {
                                $mediaCount = $MG_albums[$SAchild]->getMediaCount();
                                if ($_MG_CONF['subalbum_select'] == 1) {
                                    if (strlen($MG_albums[$SAchild]->title) > 50) {
                                        $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...';
                                    } else {
                                        $aTitle = $MG_albums[$SAchild]->title;
                                    }
                                    $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>';
                                } else {
                                    $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&amp;page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>';
                                }
                                $saRows++;
                            }
                        }
                    }
                    if ($_MG_CONF['subalbum_select'] == 1) {
                        $subAlbumDisplay .= '</optgroup></select>';
                        $subAlbumDisplay .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '" />';
                        $subAlbumDisplay .= '<input type="hidden" name="page" value="1"/>';
                        $subAlbumDisplay .= '</form>';
                    }
                    if ($_MG_CONF['album_display_columns'] > 1 && $_MG_CONF['subalbum_select'] != 1) {
                        $T->set_var(array('subalbumlist' => '<span style="font-weight:bold;">' . $LANG_MG01['subalbums'] . '</span> (' . $saRows . ')'));
                    } else {
                        $T->set_var(array('lang_subalbums' => $LANG_MG01['subalbums'], 'subalbumcount' => '(' . $saRows . ')', 'subalbumlist' => $subAlbumDisplay));
                    }
                }
                if ($saRows == 0) {
                    $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist'));
                }
                $T->clear_var(array('saulstart', 'saulend'));
                if ($saRows > 0 && $_MG_CONF['subalbum_select'] != 1) {
                    $T->set_var(array('saulstart' => '<ul>', 'saulend' => '</ul>'));
                }
                // now pull the total image count for all sub albums...
                $total_images_subalbums = $MG_albums[$achild[$indexCounter]]->getMediaCount();
                $owner_id = $MG_albums[$achild[$indexCounter]]->owner_id;
                if ($owner_id == '' || !isset($MG_albums[$achild[$indexCounter]]->owner_id)) {
                    $owner_id = 0;
                }
                $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($owner_id));
                $F = new Template($_MG_CONF['template_path']);
                $F->set_var('media_frame', $MG_albums[0]->albumFrameTemplate);
                $F->set_var(array('border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight));
                $F->parse('media', 'media_frame');
                $media_item_thumbnail = $F->finish($F->get_var('media'));
                $T->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'class' => $rowcounter % 2, 'table_column_width' => 'width="' . $width . '%"', 'album_id' => $MG_albums[$achild[$indexCounter]]->id, 'album_title' => PLG_replaceTags($MG_albums[$achild[$indexCounter]]->title, 'mediagallery', 'album_title'), 'album_desc' => $MG_albums[$achild[$indexCounter]]->description == '' ? '' : PLG_replaceTags($MG_albums[$achild[$indexCounter]]->description, 'mediagallery', 'album_description'), 'album_media_count' => $album_media_count, 'subalbum_media_count' => $total_images_subalbums, 'album_owner' => $ownername, 'album_last_update' => $album_last_update[0], 'column_width' => $albumColumnWidth, 'column_width2' => $tn_height + 35 . 'px', 'lang_album' => $LANG_MG00['album'], 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&amp;page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight));
                $T->parse('AColumn', 'AlbumColumn', true);
                $indexCounter++;
            }
            if ($noParse == 1) {
                break;
            } else {
                $T->parse('ARow', 'AlbumRow', true);
                $T->set_var('AColumn', '');
            }
        }
    }
    $T->set_var(array('bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, ceil($aCount / $items_per_page)), 'table_columns' => $_MG_CONF['album_display_columns']));
    if ($albumCount == 0) {
        $T->set_var(array('noitems' => $LANG_MG03['no_album_objects']));
        $T->parse('gallery_noitems', 'noitems');
    } else {
        $T->parse('gallery_body', 'body');
    }
    $T->parse('output', 'page');
    $nCSS = $nFrame->getCSS();
    if ($nCSS != '') {
        $outputHandle = outputHandler::getInstance();
        $outputHandle->addStyle($nCSS);
    }
    $display .= MG_siteHeader($LANG_MG00['plugin']);
    $display .= $T->finish($T->get_var('output'));
    $display .= MG_siteFooter();
    echo $display;
    exit;
}
示例#5
0
/**
* edits or creates an album
*
* @param    int     album_id    album_id to edit
* @param    string  mode        create or edit
* @param    string  actionURL   where to redirection on finish
* @param    int     oldaid      original album id
* @return   string              HTML
*
*/
function MG_editAlbum($album_id = 0, $mode = '', $actionURL = '', $oldaid = 0)
{
    global $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_ACCESS, $REMOTE_ADDR;
    global $MG_albums, $album_selectbox, $_DB_dbms;
    $valid_albums = 0;
    if ($actionURL == '') {
        $actionURL = $_CONF['site_admin_url'] . '/plugins/mediagallery/index.php';
    }
    if ($_DB_dbms == "mssql") {
        $sql = "SELECT *,CAST(album_desc AS TEXT) as album_desc FROM " . $_TABLES['mg_albums'] . " WHERE album_id=" . $album_id;
    } else {
        $sql = "SELECT * FROM " . $_TABLES['mg_albums'] . " WHERE album_id=" . intval($album_id);
    }
    $result = DB_query($sql);
    $numRows = DB_numRows($result);
    if ($numRows > 0) {
        $A = DB_fetchArray($result);
    }
    $retval = '';
    $T = new Template(MG_getTemplatePath($album_id));
    $T->set_var('site_url', $_CONF['site_url']);
    $T->set_var('site_admin_url', $_CONF['site_admin_url']);
    if ($album_id != 0 && $mode == 'edit') {
        // If edit, pull up the existing album information...
        if ($MG_albums[$album_id]->access != 3) {
            COM_errorLog("MediaGallery: Someone has tried to illegally edit a Media Gallery Album.  User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1);
            return MG_genericError($LANG_MG00['access_denied_msg']);
        }
    } else {
        if ($album_id == 0 && $mode == 'create') {
            // create the album...
            $A['album_id'] = -1;
            $A['album_order'] = 0;
            $album_id = -1;
            $A['album_parent'] = 0;
            $A['album_title'] = '';
            $A['album_desc'] = '';
            $A['hidden'] = 0;
            $A['album_cover'] = -1;
            $A['featured'] = 0;
            $A['cbposition'] = 0;
            $A['cbpage'] = 'all';
            $A['owner_id'] = $_USER['uid'];
            $A['member_uploads'] = $_MG_CONF['ad_member_uploads'];
            $A['moderate'] = $_MG_CONF['ad_moderate'];
            $A['tn_attached'] = 0;
            $A['exif_display'] = $_MG_CONF['ad_exif_display'];
            $A['enable_slideshow'] = $_MG_CONF['ad_enable_slideshow'];
            $A['enable_random'] = $_MG_CONF['ad_enable_random'];
            $A['enable_shutterfly'] = $_MG_CONF['ad_enable_shutterfly'];
            $A['enable_views'] = $_MG_CONF['ad_enable_views'];
            $A['enable_keywords'] = $_MG_CONF['ad_enable_keywords'];
            $A['display_album_desc'] = $_MG_CONF['ad_display_album_desc'];
            $A['enable_album_views'] = $_MG_CONF['ad_enable_album_views'];
            $A['image_skin'] = $_MG_CONF['ad_image_skin'];
            $A['album_skin'] = $_MG_CONF['ad_album_skin'];
            $A['display_skin'] = $_MG_CONF['ad_display_skin'];
            $A['enable_sort'] = $_MG_CONF['ad_enable_sort'];
            $A['enable_rss'] = $_MG_CONF['ad_enable_rss'];
            $A['enable_postcard'] = $_MG_CONF['ad_enable_postcard'];
            $A['albums_first'] = $_MG_CONF['ad_albums_first'];
            $A['enable_rating'] = $_MG_CONF['ad_enable_rating'];
            $A['enable_comments'] = $_MG_CONF['ad_enable_comments'];
            $A['tn_size'] = $_MG_CONF['ad_tn_size'];
            $A['allow_download'] = $_MG_CONF['ad_allow_download'];
            $A['max_image_height'] = $_MG_CONF['ad_max_image_height'];
            $A['max_image_width'] = $_MG_CONF['ad_max_image_width'];
            $A['max_filesize'] = $_MG_CONF['ad_max_filesize'];
            $A['display_image_size'] = $_MG_CONF['ad_display_image_size'];
            $A['display_rows'] = $_MG_CONF['ad_display_rows'];
            $A['display_columns'] = $_MG_CONF['ad_display_columns'];
            $A['valid_formats'] = $_MG_CONF['ad_valid_formats'];
            $A['filename_title'] = $_MG_CONF['ad_filename_title'];
            $A['wm_auto'] = $_MG_CONF['ad_wm_auto'];
            $A['wm_id'] = $_MG_CONF['ad_wm_id'];
            $A['opacity'] = $_MG_CONF['ad_wm_opacity'];
            $A['wm_location'] = $_MG_CONF['ad_wm_location'];
            $A['album_sort_order'] = $_MG_CONF['ad_album_sort_order'];
            $A['email_mod'] = $_MG_CONF['ad_email_mod'];
            $A['album_cover_filename'] = '';
            $A['last_update'] = 0;
            $A['media_count'] = 0;
            $A['full_display'] = $_MG_CONF['ad_full_display'];
            $A['playback_type'] = $_MG_CONF['ad_playback_type'];
            $A['podcast'] = isset($_MG_CONF['ad_podcast']) ? $_MG_CONF['ad_podcast'] : 0;
            $A['mp3ribbon'] = 0;
            $A['rsschildren'] = 0;
            $A['usealternate'] = isset($_MG_CONF['ad_use_alternate']) ? $_MG_CONF['ad_use_alternate'] : 0;
            $A['skin'] = isset($_MG_CONF['ad_skin']) ? $_MG_CONF['ad_skin'] : 'default';
            $gresult = DB_query("SELECT grp_id FROM {$_TABLES['groups']} WHERE grp_name LIKE 'mediagallery Admin'");
            $grow = DB_fetchArray($gresult);
            $grp_id = $grow['grp_id'];
            $A['group_id'] = $grp_id;
            $A['mod_group_id'] = $grp_id;
            $A['perm_owner'] = $_MG_CONF['ad_perm_owner'];
            $A['perm_group'] = $_MG_CONF['ad_perm_group'];
            $A['perm_members'] = $_MG_CONF['ad_perm_members'];
            $A['perm_anon'] = $_MG_CONF['ad_perm_anon'];
            $A['tnheight'] = $_MG_CONF['ad_tn_height'];
            $A['tnwidth'] = $_MG_CONF['ad_tn_width'];
        }
    }
    $T->set_var('album_id', $A['album_id']);
    $retval .= COM_startBlock($mode == 'create' ? $LANG_MG01['create_album'] : $LANG_MG01['edit_album'] . ' - ' . strip_tags($A['album_title']), '', COM_getBlockTemplate('_admin_block', 'header'));
    // If edit, pull up the existing album information...
    $T->set_file(array('admin' => 'editalbum.thtml', 'falbum' => 'featured_album.thtml', 'perms_admin' => 'edit_album_permissions.thtml', 'perms_member' => 'edit_album_perm_member.thtml', 'admin_attr' => 'editalbum_admin.thtml', 'admin_formats' => 'editalbum_formats.thtml'));
    // construct the album jumpbox...
    if ($mode == 'create') {
        $select = $oldaid;
    } else {
        $select = $A['album_parent'];
    }
    $album_selectbox = '<select name="parentaid">';
    $valid_albums += $MG_albums[0]->buildAlbumBox($select, 3, $A['album_id'], $mode);
    $album_selectbox .= '</select>';
    $album_select = $album_selectbox;
    if ($valid_albums == 0) {
        COM_errorLog("MediaGallery: Someone has tried to illegally create a Medig Gallery Album.  User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1);
        return MG_genericError($LANG_MG00['access_denied_msg']);
    }
    // build exif select box...
    $exif_select = '<select name="enable_exif">';
    $exif_select .= '<option value="0"' . ($A['exif_display'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disable_exif'] . '</option>';
    $exif_select .= '<option value="1"' . ($A['exif_display'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['display_below_media'] . '</option>';
    $exif_select .= '<option value="2"' . ($A['exif_display'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['display_in_popup'] . '</option>';
    $exif_select .= '<option value="3"' . ($A['exif_display'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['both'] . '</option>';
    $exif_select .= '</select>';
    $full_select = '<select name="full_display"' . ($_MG_CONF['discard_original'] ? ' disabled=disabled ' : '') . '>';
    $full_select .= '<option value="0"' . ($A['full_display'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['always'] . '</option>';
    $full_select .= '<option value="1"' . ($A['full_display'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['members_only'] . '</option>';
    $full_select .= '<option value="2"' . ($A['full_display'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $full_select .= '</select>';
    $ranking_select = '<select name="enable_rating">';
    $ranking_select .= '<option value="0"' . ($A['enable_rating'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $ranking_select .= '<option value="1"' . ($A['enable_rating'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['members_only'] . '</option>';
    $ranking_select .= '<option value="2"' . ($A['enable_rating'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['always'] . '</option>';
    $ranking_select .= '</select>';
    $podcast_select = '<input type="checkbox" name="podcast" value="1" ' . ($A['podcast'] ? ' checked="checked"' : '') . '/>';
    $mp3ribbon_select = '<input type="checkbox" name="mp3ribbon" value="1" ' . ($A['mp3ribbon'] ? ' checked="checked"' : '') . '/>';
    $rsschildren_select = '<input type="checkbox" name="rsschildren" value="1" ' . ($A['rsschildren'] ? ' checked="checked"' : '') . '/>';
    $comment_select = '<input type="checkbox" name="enable_comments" value="1" ' . ($A['enable_comments'] ? ' checked="checked"' : '') . '/>';
    $ss_select = '<select name="enable_slideshow">';
    $ss_select .= '<option value="0" ' . ($A['enable_slideshow'] == 0 ? ' selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $ss_select .= '<option value="1"' . ($A['enable_slideshow'] == 1 ? ' selected="selected"' : '') . '>' . $LANG_MG01['js_slideshow'] . '</option>';
    $ss_select .= '<option value="2"' . ($A['enable_slideshow'] == 2 ? ' selected="selected"' : '') . '>' . $LANG_MG01['lightbox'] . '</option>';
    $ss_select .= '<option value="3"' . ($A['enable_slideshow'] == 3 ? ' selected="selected"' : '') . '>' . $LANG_MG01['flash_slideshow_disp'] . '</option>';
    $ss_select .= '<option value="4"' . ($A['enable_slideshow'] == 4 ? ' selected="selected"' : '') . '>' . $LANG_MG01['flash_slideshow_full'] . '</option>';
    $ss_select .= '<option value="5"' . ($A['enable_slideshow'] == 5 ? ' selected="selected"' : '') . '>' . $LANG_MG01['mp3_jukebox'] . '</option>';
    $ss_select .= '</select>';
    $sf_select = '<input type="checkbox" name="enable_shutterfly" value="1" ' . ($A['enable_shutterfly'] ? ' checked="checked"' : '') . '/>';
    $views_select = '<input type="checkbox" name="enable_views" value="1" ' . ($A['enable_views'] ? ' checked="checked"' : '') . '/>';
    $keywords_select = '<input type="checkbox" name="enable_keywords" value="1" ' . ($A['enable_keywords'] ? ' checked="checked"' : '') . '/>';
    $sort_select = '<input type="checkbox" name="enable_sort" value="1" ' . ($A['enable_sort'] ? ' checked="checked"' : '') . '/>';
    $rss_select = '<input type="checkbox" name="enable_rss" value="1" ' . ($A['enable_rss'] ? ' checked="checked"' : '') . '/>';
    $postcard_select = '<select name="enable_postcard">';
    $postcard_select .= '<option value="0"' . ($A['enable_postcard'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $postcard_select .= '<option value="1"' . ($A['enable_postcard'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['members_only'] . '</option>';
    $postcard_select .= '<option value="2"' . ($A['enable_postcard'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['all_users'] . '</option>';
    $postcard_select .= '</select>';
    $afirst_select = '<input type="checkbox" name="albums_first" value="1" ' . ($A['albums_first'] ? ' checked="checked"' : '') . '/>';
    $usealternate_select = '<input type="checkbox" name="usealternate" value="1" ' . ($A['usealternate'] ? ' checked="checked"' : '') . '/>';
    $album_views_select = '<input type="checkbox" name="enable_album_views" value="1" ' . ($A['enable_album_views'] ? ' checked="checked"' : '') . '/>';
    $display_album_desc_select = '<input type="checkbox" name="display_album_desc" value="1" ' . ($A['display_album_desc'] ? ' checked="checked"' : '') . '/>';
    $tn_size_select = '<select name="tn_size">';
    $tn_size_select .= '<option value="0"' . ($A['tn_size'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['small'] . '</option>';
    $tn_size_select .= '<option value="1"' . ($A['tn_size'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['medium'] . '</option>';
    $tn_size_select .= '<option value="2"' . ($A['tn_size'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['large'] . '</option>';
    $tn_size_select .= '<option value="3"' . ($A['tn_size'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['custom'] . '</option>';
    $tn_size_select .= '<option value="4"' . ($A['tn_size'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG01['square'] . '</option>';
    $tn_size_select .= '</select>';
    $display_image_size_select = '<select name="display_image_size">';
    $display_image_size_select .= '<option value="0"' . ($A['display_image_size'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_500x375'] . '</option>';
    $display_image_size_select .= '<option value="1"' . ($A['display_image_size'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_600x450'] . '</option>';
    $display_image_size_select .= '<option value="2"' . ($A['display_image_size'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_620x465'] . '</option>';
    $display_image_size_select .= '<option value="3"' . ($A['display_image_size'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_720x540'] . '</option>';
    $display_image_size_select .= '<option value="4"' . ($A['display_image_size'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_800x600'] . '</option>';
    $display_image_size_select .= '<option value="5"' . ($A['display_image_size'] == 5 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_912x684'] . '</option>';
    $display_image_size_select .= '<option value="6"' . ($A['display_image_size'] == 6 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_1024x768'] . '</option>';
    $display_image_size_select .= '<option value="7"' . ($A['display_image_size'] == 7 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_1152x864'] . '</option>';
    $display_image_size_select .= '<option value="8"' . ($A['display_image_size'] == 8 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_1280x1024'] . '</option>';
    $display_image_size_select .= '<option value="9"' . ($A['display_image_size'] == 9 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_custom'] . $_MG_CONF['custom_image_width'] . 'x' . $_MG_CONF['custom_image_height'] . '</option>';
    $display_image_size_select .= '</select>';
    $rows_input = '<input type="text" size="3" name="display_rows" value="' . $A['display_rows'] . '"/>';
    $columns_input = '<input type="text" size="3" name="display_columns" value="' . $A['display_columns'] . '"/>';
    $max_image_height_input = '<input type="text" size="4" name="max_image_height" value="' . $A['max_image_height'] . '"/>';
    $max_image_width_input = '<input type="text" size="4" name="max_image_width" value="' . $A['max_image_width'] . '"/>';
    $tnheight_input = '<input type="text" size="3" name="tnheight" value="' . $A['tnheight'] . '"/>';
    $tnwidth_input = '<input type="text" size="3" name="tnwidth" value="' . $A['tnwidth'] . '"/>';
    if ($A['max_filesize'] != 0) {
        $A['max_filesize'] = $A['max_filesize'] / 1024;
    }
    $max_filesize_input = '<input type="text" size="10" name="max_filesize" value="' . $A['max_filesize'] . '"/>';
    $email_mod_select = '<input type="checkbox" name="email_mod" value="1" ' . ($A['email_mod'] ? ' checked="checked"' : '') . '/>';
    $playback_type = '<select name="playback_type">';
    $playback_type .= '<option value="0"' . ($A['playback_type'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['play_in_popup'] . '</option>';
    $playback_type .= '<option value="1"' . ($A['playback_type'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['download_to_local'] . '</option>';
    $playback_type .= '<option value="2"' . ($A['playback_type'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['play_inline'] . '</option>';
    $playback_type .= '<option value="3"' . ($A['playback_type'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['use_mms'] . '</option>';
    $playback_type .= '</select>';
    $themes = MG_getThemes();
    $album_theme_select = '<select name="album_theme">';
    for ($i = 0; $i < count($themes); $i++) {
        $album_theme_select .= '<option value="' . $themes[$i] . '"' . ($A['skin'] == $themes[$i] ? 'selected="selected"' : '') . '>' . $themes[$i] . '</option>';
    }
    $album_theme_select .= '</select>';
    $attach_select = '<input type="checkbox" name="attach_tn" value="1" ' . ($A['tn_attached'] ? ' checked="checked"' : '') . '/>';
    $result = DB_query("SELECT * FROM {$_TABLES['users']}");
    $nRows = DB_numRows($result);
    $owner_select = '<select name="owner_id">';
    for ($i = 0; $i < $nRows; $i++) {
        $row = DB_fetchArray($result);
        if ($row['uid'] == 1) {
            continue;
        }
        $owner_select .= '<option value="' . $row['uid'] . '"' . ($A['owner_id'] == $row['uid'] ? 'selected="selected"' : '') . '>' . COM_getDisplayName($row['uid'], $row['username'], $row['fullname'], $row['remoteusername'], $row['remoteservice']) . '</option>';
    }
    $owner_select .= '</select>';
    $album_sort_select = '<select name="album_sort_order">';
    $album_sort_select .= '<option value="0"' . ($A['album_sort_order'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG03['no_sort'] . '</option>';
    $album_sort_select .= '<option value="1"' . ($A['album_sort_order'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_capture_asc'] . '</option>';
    $album_sort_select .= '<option value="2"' . ($A['album_sort_order'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_capture'] . '</option>';
    $album_sort_select .= '<option value="3"' . ($A['album_sort_order'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_upload_asc'] . '</option>';
    $album_sort_select .= '<option value="4"' . ($A['album_sort_order'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_upload'] . '</option>';
    $album_sort_select .= '<option value="5"' . ($A['album_sort_order'] == 5 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_alpha'] . '</option>';
    $album_sort_select .= '<option value="6"' . ($A['album_sort_order'] == 6 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_alpha_asc'] . '</option>';
    $album_sort_select .= '</select>';
    if (SEC_hasRights('mediagallery.admin')) {
        //
        // -- build the featured selects and info...
        //
        $featured_select = '<input type="checkbox" name="featured" value="1" ' . ($A['featured'] ? ' checked="checked"' : '') . '/>';
        // build featurepage select...
        $featurepage_select = '<select name="featurepage">';
        $featurepage_select .= '<option value="all"' . ($A['cbpage'] == 'all' ? 'selected="selected"' : '') . '>' . $LANG_MG01['all'] . '</option>';
        $featurepage_select .= '<option value="allnhp"' . ($A['cbpage'] == 'allnhp' ? 'selected="selected"' : '') . '>' . $LANG_MG01['all_nhp'] . '</option>';
        $featurepage_select .= '<option value="none"' . ($A['cbpage'] == 'none' ? 'selected="selected"' : '') . '>' . $LANG_MG01['homepage_only'] . '</option>';
        $featurepage_select .= COM_topicList('tid,topic', $A['cbpage']);
        $featurepage_select .= '</select>';
        // position
        $feature_pos = '<select name="featureposition">';
        $feature_pos .= '<option value="1"' . ($A['cbposition'] == 1 ? ' selected="selected"' : '') . '>' . $LANG_MG01['top'] . '</option>';
        $feature_pos .= '<option value="2"' . ($A['cbposition'] == 2 ? ' selected="selected"' : '') . '>' . $LANG_MG01['after_featured_articles'] . '</option>';
        $feature_pos .= '<option value="3"' . ($A['cbposition'] == 3 ? ' selected="selected"' : '') . '>' . $LANG_MG01['bottom'] . '</option>';
        $feature_pos .= '</select>    ';
        $T->set_var(array('featured_select' => $featured_select, 'feature_page_select' => $featurepage_select, 'feature_position' => $feature_pos, 'lang_featured_album' => $LANG_MG01['featured_album'], 'lang_set_featured' => $LANG_MG01['set_featured'], 'lang_featured_help' => $LANG_MG01['featured_help'], 'lang_position' => $LANG_MG01['position'], 'lang_topic' => $LANG_MG01['topic']));
        $T->parse('featureselect', 'falbum');
        $ri_select = '<input type="checkbox" name="enable_random" value="1" ' . ($A['enable_random'] ? ' checked="checked"' : '') . '/>';
        $T->set_var(array('height_input' => $max_image_height_input, 'width_input' => $max_image_width_input, 'max_size_input' => $max_filesize_input, 'ri_select' => $ri_select, 'lang_ri_enable' => $LANG_MG01['ri_enable'], 'lang_max_image_height' => $LANG_MG01['max_image_height'], 'lang_max_image_width' => $LANG_MG01['max_image_width'], 'lang_max_filesize' => $LANG_MG01['max_filesize']));
        $T->parse('adminattr', 'admin_attr');
        $T->set_var(array('jpg_checked' => $A['valid_formats'] & MG_JPG ? ' checked="checked"' : '', 'png_checked' => $A['valid_formats'] & MG_PNG ? ' checked="checked"' : '', 'tif_checked' => $A['valid_formats'] & MG_TIF ? ' checked="checked"' : '', 'gif_checked' => $A['valid_formats'] & MG_GIF ? ' checked="checked"' : '', 'bmp_checked' => $A['valid_formats'] & MG_BMP ? ' checked="checked"' : '', 'tga_checked' => $A['valid_formats'] & MG_TGA ? ' checked="checked"' : '', 'psd_checked' => $A['valid_formats'] & MG_PSD ? ' checked="checked"' : '', 'mp3_checked' => $A['valid_formats'] & MG_MP3 ? ' checked="checked"' : '', 'ogg_checked' => $A['valid_formats'] & MG_OGG ? ' checked="checked"' : '', 'asf_checked' => $A['valid_formats'] & MG_ASF ? ' checked="checked"' : '', 'swf_checked' => $A['valid_formats'] & MG_SWF ? ' checked="checked"' : '', 'mov_checked' => $A['valid_formats'] & MG_MOV ? ' checked="checked"' : '', 'mp4_checked' => $A['valid_formats'] & MG_MP4 ? ' checked="checked"' : '', 'mpg_checked' => $A['valid_formats'] & MG_MPG ? ' checked="checked"' : '', 'zip_checked' => $A['valid_formats'] & MG_ZIP ? ' checked="checked"' : '', 'flv_checked' => $A['valid_formats'] & MG_FLV ? ' checked="checked"' : '', 'rflv_checked' => $A['valid_formats'] & MG_RFLV ? ' checked="checked"' : '', 'emb_checked' => $A['valid_formats'] & MG_EMB ? ' checked="checked"' : '', 'other_checked' => $A['valid_formats'] & MG_OTHER ? ' checked="checked"' : '', 'lang_jpg' => $LANG_MG01['jpg'], 'lang_png' => $LANG_MG01['png'], 'lang_tif' => $LANG_MG01['tif'], 'lang_gif' => $LANG_MG01['gif'], 'lang_bmp' => $LANG_MG01['bmp'], 'lang_tga' => $LANG_MG01['tga'], 'lang_psd' => $LANG_MG01['psd'], 'lang_mp3' => $LANG_MG01['mp3'], 'lang_ogg' => $LANG_MG01['ogg'], 'lang_asf' => $LANG_MG01['asf'], 'lang_swf' => $LANG_MG01['swf'], 'lang_mov' => $LANG_MG01['mov'], 'lang_mp4' => $LANG_MG01['mp4'], 'lang_mpg' => $LANG_MG01['mpg'], 'lang_zip' => $LANG_MG01['zip'], 'lang_flv' => $LANG_MG01['flv'], 'lang_rflv' => $LANG_MG01['rflv'], 'lang_emb' => $LANG_MG01['emb'], 'lang_other' => $LANG_MG01['other'], 'lang_allowed_formats' => $LANG_MG01['allowed_media_formats'], 'lang_image' => $LANG_MG01['image'], 'lang_audio' => $LANG_MG01['audio'], 'lang_video' => $LANG_MG01['video']));
        $T->parse('valid_formats', 'admin_formats');
    }
    $r = rand();
    if ($A['tn_attached']) {
        $media_size = false;
        foreach ($_MG_CONF['validExtensions'] as $ext) {
            if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $A['album_id'] . $ext)) {
                $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $A['album_id'] . $ext;
                $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $A['album_id'] . $ext);
                if ($media_size != false) {
                    $T->set_var('thumbnail', '<img src="' . $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $A['album_id'] . $ext . '?r=' . $r . '" alt=""/>');
                }
                break;
            }
        }
        //        $T->set_var('thumbnail','<img src="' . $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $A['album_id'] . '.jpg?r=' . $r . '" alt="">');
    }
    $filename_title_select = '<input type="checkbox" name="filename_title" value="1" ' . ($A['filename_title'] ? ' checked="checked"' : '') . '/>';
    // watermark stuff...
    $wm_auto_select = '<input type="checkbox" name="wm_auto" value="1" ' . ($A['wm_auto'] ? ' checked="checked"' : '') . '/>';
    $wm_opacity_select = '<select name="wm_opacity">';
    $wm_opacity_select .= '<option value="10"' . ($A['opacity'] == 10 ? 'selected="selected"' : '') . '>10%</option>';
    $wm_opacity_select .= '<option value="20"' . ($A['opacity'] == 20 ? 'selected="selected"' : '') . '>20%</option>';
    $wm_opacity_select .= '<option value="30"' . ($A['opacity'] == 30 ? 'selected="selected"' : '') . '>30%</option>';
    $wm_opacity_select .= '<option value="40"' . ($A['opacity'] == 40 ? 'selected="selected"' : '') . '>40%</option>';
    $wm_opacity_select .= '<option value="50"' . ($A['opacity'] == 50 ? 'selected="selected"' : '') . '>50%</option>';
    $wm_opacity_select .= '<option value="60"' . ($A['opacity'] == 60 ? 'selected="selected"' : '') . '>60%</option>';
    $wm_opacity_select .= '<option value="70"' . ($A['opacity'] == 70 ? 'selected="selected"' : '') . '>70%</option>';
    $wm_opacity_select .= '<option value="80"' . ($A['opacity'] == 80 ? 'selected="selected"' : '') . '>80%</option>';
    $wm_opacity_select .= '<option value="90"' . ($A['opacity'] == 90 ? 'selected="selected"' : '') . '>90%</option>';
    $wm_opacity_select .= '</select>';
    $wm_location_select = '<select name="wm_location">';
    $wm_location_select .= '<option value="1"' . ($A['wm_location'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['top_left'] . '</option>';
    $wm_location_select .= '<option value="2"' . ($A['wm_location'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['top_center'] . '</option>';
    $wm_location_select .= '<option value="3"' . ($A['wm_location'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['top_right'] . '</option>';
    $wm_location_select .= '<option value="4"' . ($A['wm_location'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG01['middle_left'] . '</option>';
    $wm_location_select .= '<option value="5"' . ($A['wm_location'] == 5 ? 'selected="selected"' : '') . '>' . $LANG_MG01['middle_center'] . '</option>';
    $wm_location_select .= '<option value="6"' . ($A['wm_location'] == 6 ? 'selected="selected"' : '') . '>' . $LANG_MG01['middle_right'] . '</option>';
    $wm_location_select .= '<option value="7"' . ($A['wm_location'] == 7 ? 'selected="selected"' : '') . '>' . $LANG_MG01['bottom_left'] . '</option>';
    $wm_location_select .= '<option value="8"' . ($A['wm_location'] == 8 ? 'selected="selected"' : '') . '>' . $LANG_MG01['bottom_center'] . '</option>';
    $wm_location_select .= '<option value="9"' . ($A['wm_location'] == 9 ? 'selected="selected"' : '') . '>' . $LANG_MG01['bottom_right'] . '</option>';
    $wm_location_select .= '</select>';
    // now select what watermarks we have permission to use...
    $whereClause = " WHERE wm_id<>0 AND ";
    if (SEC_hasRights('mediagallery.admin')) {
        $whereClause .= "1=1";
    } else {
        $whereClause .= "(owner_id=" . $_USER['uid'] . " OR owner_id=0)";
    }
    $sql = "SELECT * FROM {$_TABLES['mg_watermarks']} " . $whereClause . " ORDER BY owner_id";
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    $wm_select = '<select name="wm_id"  onchange="change(this)">';
    $wm_select .= '<option value="blank.png">' . $LANG_MG01['no_watermark'] . '</option>';
    $wm_current = '<img src="' . $_MG_CONF['site_url'] . '/watermarks/blank.png" name="myImage" alt=""/>';
    for ($i = 0; $i < $nRows; $i++) {
        $row = DB_fetchArray($result);
        $wm_select .= '<option value="' . $row['filename'] . '"' . ($A['wm_id'] == $row['wm_id'] ? 'selected="selected"' : '') . '>' . $row['filename'] . '</option>';
        if ($A['wm_id'] == $row['wm_id']) {
            $wm_current = '<img src="' . $_MG_CONF['site_url'] . '/watermarks/' . $row['filename'] . '" name="myImage" alt=""/>';
        }
    }
    $wm_select .= '</select>';
    $frames = new mgFrame();
    $skins = array();
    $skins = $frames->getFrames();
    $skin_select = '<select name="skin">';
    $askin_select = '<select name="askin">';
    $dskin_select = '<select name="dskin">';
    for ($i = 0; $i < count($skins); $i++) {
        $skin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($A['image_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
        $askin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($A['album_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
        $dskin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($A['display_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
    }
    $skin_select .= '</select>';
    $askin_select .= '</select>';
    $dskin_select .= '</select>';
    // permission template
    $usergroups = SEC_getUserGroups();
    $groupdd = '';
    $moddd = '';
    $groupdd .= '<select name="group_id">';
    $moddd .= '<select name="mod_id">';
    for ($i = 0; $i < count($usergroups); $i++) {
        if ($usergroups[key($usergroups)] != 2 && $usergroups[key($usergroups)] != 13) {
            $groupdd .= '<option value="' . $usergroups[key($usergroups)] . '"';
            $moddd .= '<option value="' . $usergroups[key($usergroups)] . '"';
            if ($A['group_id'] == $usergroups[key($usergroups)]) {
                $groupdd .= ' selected="selected"';
            }
            if ($A['mod_group_id'] == $usergroups[key($usergroups)]) {
                $moddd .= ' selected="selected"';
            }
            $groupdd .= '>' . key($usergroups) . '</option>';
            $moddd .= '>' . key($usergroups) . '</option>';
        }
        next($usergroups);
    }
    $groupdd .= '</select>';
    $moddd .= '</select>';
    $upload_select = '<input type="checkbox" name="uploads" value="1" ' . ($A['member_uploads'] ? ' checked="checked"' : '') . '/>';
    $moderate_select = '<input type="checkbox" name="moderate" value="1" ' . ($A['moderate'] ? ' checked="checked"' : '') . '/>';
    $child_update_select = '<input type="checkbox" name="force_child_update" value="1"/>';
    $hidden_select = '<input type="checkbox" name="hidden" value="1" ' . ($A['hidden'] ? ' checked="checked"' : '') . '/>';
    $allow_download_select = '<input type="checkbox" name="allow_download" value="1" ' . ($A['allow_download'] ? ' checked="checked"' : '') . '/>';
    if (SEC_hasRights('mediagallery.admin')) {
        $perm_editor = SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
    } else {
        $perm_editor = MG_getMemberPermissionsHTML($A['perm_members'], $A['perm_anon']);
    }
    $T->set_var(array('lang_uploads' => $LANG_MG01['anonymous_uploads_prompt'], 'lang_accessrights' => $LANG_ACCESS['accessrights'], 'lang_owner' => $LANG_ACCESS['owner'], 'owner_username' => DB_getItem($_TABLES['users'], 'username', "uid={$A['owner_id']}"), 'owner_id' => $A['owner_id'], 'lang_group' => $LANG_ACCESS['group'], 'lang_permissions' => $LANG_ACCESS['permissions'], 'lang_perm_key' => $LANG_ACCESS['permissionskey'], 'lang_hidden' => $LANG_MG01['hidden'], 'permissions_msg' => $LANG_ACCESS['permmsg'], 'permissions_editor' => $perm_editor, 'origaid' => '<input type="hidden" name="origaid" value="' . $oldaid . '"/>', 'group_dropdown' => $groupdd, 'mod_dropdown' => $moddd, 'lang_member_upload' => $LANG_MG01['member_upload'], 'lang_moderate_album' => $LANG_MG01['mod_album'], 'lang_mod_group' => $LANG_MG01['moderation_group'], 'uploads' => $upload_select, 'moderate' => $moderate_select, 'hidden' => $hidden_select, 'force_child_update' => $child_update_select, 'lang_force_child_update' => $LANG_MG01['force_child_update'], 'lang_allow_download' => $LANG_MG01['allow_download'], 'owner_select' => $owner_select, 'email_mod_select' => $email_mod_select, 'lang_email_mods_on_submission' => $LANG_MG01['email_mods_on_submission']));
    if (SEC_hasRights('mediagallery.admin')) {
        $T->parse('perm_editor', 'perms_admin');
    } else {
        $T->parse('perm_editor', 'perms_member');
    }
    $T->set_var(array('action' => 'album', 'path_mg' => $_MG_CONF['site_url'], 'attach_select' => $attach_select, 'comment_select' => $comment_select, 'exif_select' => $exif_select, 'ranking_select' => $ranking_select, 'podcast_select' => $podcast_select, 'mp3ribbon_select' => $mp3ribbon_select, 'rsschildren_select' => $rsschildren_select, 'full_select' => $full_select, 'ss_select' => $ss_select, 'sf_select' => $sf_select, 'views_select' => $views_select, 'keywords_select' => $keywords_select, 'album_views_select' => $album_views_select, 'display_album_desc_select' => $display_album_desc_select, 'sort_select' => $sort_select, 'rss_select' => $rss_select, 'postcard_select' => $postcard_select, 'afirst_select' => $afirst_select, 'tn_size_select' => $tn_size_select, 'display_image_size' => $display_image_size_select, 'rows_input' => $rows_input, 'columns_input' => $columns_input, 'playback_type' => $playback_type, 'album_title' => $A['album_title'], 'album_desc' => $A['album_desc'], 'album_id' => $A['album_id'], 'parent_select' => $album_select, 'album_cover' => $A['album_cover'], 'album_owner' => $A['owner_id'], 'album_order' => $A['album_order'], 'album_cover_filename' => $A['album_cover_filename'], 'last_update' => $A['last_update'], 'media_count' => $A['media_count'], 'wm_auto_select' => $wm_auto_select, 'wm_opacity_select' => $wm_opacity_select, 'wm_location_select' => $wm_location_select, 'wm_select' => $wm_select, 'wm_current' => $wm_current, 'album_theme_select' => $album_theme_select, 'album_sort_select' => $album_sort_select, 'allow_download_select' => $allow_download_select, 'filename_title_select' => $filename_title_select, 'skin_select' => $skin_select, 'askin_select' => $askin_select, 'dskin_select' => $dskin_select, 'tnheight_input' => $tnheight_input, 'tnwidth_input' => $tnwidth_input, 'usealternate_select' => $usealternate_select, 'lang_usealternate' => $LANG_MG01['use_alternate_url'], 'lang_tnheight' => $LANG_MG01['tn_height'], 'lang_tnwidth' => $LANG_MG01['tn_width'], 'lang_save' => $LANG_MG01['save'], 'lang_edit_title' => $mode == 'create' ? $LANG_MG01['create_album'] : $LANG_MG01['edit_album'], 's_form_action' => $actionURL, 'lang_image_skin' => $LANG_MG01['image_skin'], 'lang_album_skin' => $LANG_MG01['album_skin'], 'lang_display_skin' => $LANG_MG01['display_skin'], 'lang_album_edit_help' => $LANG_MG01['album_edit_help'], 'lang_title' => $LANG_MG01['title'], 'lang_podcast' => $LANG_MG01['podcast'], 'lang_mp3ribbon' => $LANG_MG01['mp3ribbon'], 'lang_rsschildren' => $LANG_MG01['rsschildren'], 'lang_parent_album' => $LANG_MG01['parent_album'], 'lang_description' => $LANG_MG01['description'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_comments' => $LANG_MG01['comments_prompt'], 'lang_enable_exif' => $LANG_MG01['enable_exif'], 'lang_enable_ratings' => $LANG_MG01['enable_ratings'], 'lang_ss_enable' => $LANG_MG01['ss_enable'], 'lang_sf_enable' => $LANG_MG01['sf_enable'], 'lang_tn_size' => $LANG_MG01['tn_size'], 'lang_rows' => $LANG_MG01['rows'], 'lang_columns' => $LANG_MG01['columns'], 'lang_av_play_album' => $LANG_MG01['av_play_album'], 'lang_av_play_options' => $LANG_MG01['av_play_options'], 'lang_attached_thumbnail' => $LANG_MG01['attached_thumbnail'], 'lang_thumbnail' => $LANG_MG01['thumbnail'], 'lang_album_attributes' => $LANG_MG01['album_attributes'], 'lang_album_cover' => $LANG_MG01['album_cover'], 'lang_enable_views' => $LANG_MG01['enable_views'], 'lang_enable_keywords' => $LANG_MG01['enable_keywords'], 'lang_enable_album_views' => $LANG_MG01['enable_album_views'], 'lang_enable_sort' => $LANG_MG01['enable_sort'], 'lang_enable_rss' => $LANG_MG01['enable_rss'], 'lang_enable_postcard' => $LANG_MG01['enable_postcard'], 'lang_albums_first' => $LANG_MG01['albums_first'], 'lang_full_display' => $LANG_MG01['full_display'], 'lang_display_image_size' => $LANG_MG01['display_image_size'], 'lang_album_sort' => $LANG_MG01['default_album_sort'], 'lang_watermark' => $LANG_MG01['watermark'], 'lang_wm_auto' => $LANG_MG01['watermark_auto'], 'lang_wm_opacity' => $LANG_MG01['watermark_opacity'], 'lang_wm_location' => $LANG_MG01['watermark_location'], 'lang_wm_id' => $LANG_MG01['watermark_image'], 'lang_unlimited' => $LANG_MG01['zero_unlimited'], 'lang_display_album_desc' => $LANG_MG01['display_album_desc'], 'lang_filename_title' => $LANG_MG01['filename_title'], 'lang_media_attributes' => $LANG_MG01['media_attributes'], 'lang_theme_select' => $LANG_MG01['album_theme']));
    if ($_MG_CONF['htmlallowed'] == 1) {
        $T->set_var('allowed_html', COM_allowedHTML(SEC_getUserPermissions(), false, 'mediagallery', 'album_title'));
    }
    $T->parse('output', 'admin');
    $retval .= $T->finish($T->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
示例#6
0
$columns_per_page = $MG_albums[$album_id]->display_columns == 0 ? $_MG_CONF['ad_display_columns'] : $MG_albums[$album_id]->display_columns;
$rows_per_page = $MG_albums[$album_id]->display_rows == 0 ? $_MG_CONF['ad_display_rows'] : $MG_albums[$album_id]->display_rows;
if (isset($_MG_USERPREFS['display_rows']) && $_MG_USERPREFS['display_rows'] > 0) {
    $rows_per_page = $_MG_USERPREFS['display_rows'];
}
if (isset($_MG_USERPREFS['display_columns']) && $_MG_USERPREFS['display_columns'] > 0) {
    $columns_per_page = $_MG_USERPREFS['display_columns'];
}
$media_per_page = $columns_per_page * $rows_per_page;
// image frame setup
$nFrame = new mgFrame();
$nFrame->constructor($MG_albums[$album_id]->image_skin);
$MG_albums[$album_id]->imageFrameTemplate = $nFrame->getTemplate();
$MG_albums[$album_id]->frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR'];
$MG_albums[$album_id]->frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB'];
$aFrame = new mgFrame();
$aFrame->constructor($MG_albums[$album_id]->album_skin);
$MG_albums[$album_id]->albumFrameTemplate = $aFrame->getTemplate();
$MG_albums[$album_id]->afrWidth = $aFrame->frame['wHL'] + $aFrame->frame['wHR'];
$MG_albums[$album_id]->afrHeight = $aFrame->frame['hVT'] + $aFrame->frame['hVB'];
// construct the album jumpbox...
$level = 0;
$MG_albums[0]->buildJumpBox($album_id);
$album_jumpbox_raw = $album_jumpbox;
$level = 0;
$album_jumpbox = '<form name="jumpbox" id="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>';
$album_jumpbox .= $LANG_MG03['jump_to'] . ':&nbsp;<select name="aid" onchange="forms[\'jumpbox\'].submit()">';
$MG_albums[0]->buildJumpBox($album_id);
$album_jumpbox .= '</select>';
$album_jumpbox .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>';
$album_jumpbox .= '<input type="hidden" name="page" value="1"/>';
示例#7
0
function MG_editDefaults()
{
    global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_ACCESS, $LANG_DIRECTION;
    global $LANG04;
    $retval = '';
    $T = new Template($_MG_CONF['template_path'] . '/admin');
    $T->set_file(array('admin' => 'editdefaults.thtml', 'admin_formats' => 'editalbum_formats.thtml'));
    $T->set_var('site_url', $_MG_CONF['site_url']);
    $T->set_var('site_admin_url', $_CONF['site_admin_url']);
    include_once $_CONF['path_system'] . "classes/navbar.class.php";
    $navbar = new navbar();
    $navbar->add_menuitem($LANG_MG01['album_attributes'], 'showhideMGAdminEditorDiv("attributes",0);return false;', true);
    $navbar->add_menuitem($LANG_MG01['watermark'], 'showhideMGAdminEditorDiv("watermark",1);return false;', true);
    $navbar->add_menuitem($LANG_MG01['allowed_media_formats'], 'showhideMGAdminEditorDiv("media",2);return false;', true);
    $navbar->add_menuitem($LANG_MG01['anonymous_uploads_prompt'], 'showhideMGAdminEditorDiv("useruploads",3);return false;', true);
    $navbar->add_menuitem($LANG_ACCESS['accessrights'], 'showhideMGAdminEditorDiv("access",4);return false;', true);
    $navbar->set_selected($LANG_MG01['album_attributes']);
    $T->set_var('navbar', $navbar->generate());
    $T->set_var('no_javascript_warning', $LANG04[150]);
    // build exif select box...
    $exif_select = '<select name="enable_exif">';
    $exif_select .= '<option value="0"' . ($_MG_CONF['ad_exif_display'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disable_exif'] . '</option>';
    $exif_select .= '<option value="1"' . ($_MG_CONF['ad_exif_display'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['display_below_media'] . '</option>';
    $exif_select .= '<option value="2"' . ($_MG_CONF['ad_exif_display'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['display_in_popup'] . '</option>';
    $exif_select .= '<option value="3"' . ($_MG_CONF['ad_exif_display'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['both'] . '</option>';
    $exif_select .= '</select>';
    $full_select = '<select name="full_display"' . ($_MG_CONF['discard_original'] ? ' disabled=disabled ' : '') . '>';
    $full_select .= '<option value="0"' . ($_MG_CONF['ad_full_display'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['always'] . '</option>';
    $full_select .= '<option value="1"' . ($_MG_CONF['ad_full_display'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['members_only'] . '</option>';
    $full_select .= '<option value="2"' . ($_MG_CONF['ad_full_display'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $full_select .= '</select>';
    $ranking_select = '<select name="enable_rating">';
    $ranking_select .= '<option value="0"' . ($_MG_CONF['ad_enable_rating'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $ranking_select .= '<option value="1"' . ($_MG_CONF['ad_enable_rating'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['members_only'] . '</option>';
    $ranking_select .= '<option value="2"' . ($_MG_CONF['ad_enable_rating'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['always'] . '</option>';
    $ranking_select .= '</select>';
    $mp3ribbon_select = '<input type="checkbox" name="mp3ribbon" value="1" />';
    $rsschildren_select = '<input type="checkbox" name="rsschildren" value="1" />';
    $themes = MG_getThemes();
    $album_theme_select = '<select name="album_theme">';
    for ($i = 0; $i < count($themes); $i++) {
        $album_theme_select .= '<option value="' . $themes[$i] . '"' . ($_MG_CONF['ad_album_skin'] == $themes[$i] ? 'selected="selected"' : '') . '>' . $themes[$i] . '</option>';
    }
    $album_theme_select .= '</select>';
    $comment_select = '<input type="checkbox" name="enable_comments" value="1" ' . ($_MG_CONF['ad_enable_comments'] ? ' checked="checked"' : '') . '/>';
    $podcast_select = '<input type="checkbox" name="podcast" value="1" />';
    $ss_select = '<select name="enable_slideshow">';
    $ss_select .= '<option value="0" ' . ($_MG_CONF['ad_enable_slideshow'] == 0 ? ' selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $ss_select .= '<option value="1"' . ($_MG_CONF['ad_enable_slideshow'] == 1 ? ' selected="selected"' : '') . '>' . $LANG_MG01['js_slideshow'] . '</option>';
    $ss_select .= '<option value="2"' . ($_MG_CONF['ad_enable_slideshow'] == 2 ? ' selected="selected"' : '') . '>' . $LANG_MG01['lightbox'] . '</option>';
    $ss_select .= '<option value="3"' . ($_MG_CONF['ad_enable_slideshow'] == 3 ? ' selected="selected"' : '') . '>' . $LANG_MG01['flash_slideshow_disp'] . '</option>';
    $ss_select .= '<option value="4"' . ($_MG_CONF['ad_enable_slideshow'] == 4 ? ' selected="selected"' : '') . '>' . $LANG_MG01['flash_slideshow_full'] . '</option>';
    $ss_select .= '</select>';
    $ri_select = '<input type="checkbox" name="enable_random" value="1" ' . ($_MG_CONF['ad_enable_random'] ? ' checked="checked"' : '') . '/>';
    $sf_select = '<input type="checkbox" name="enable_shutterfly" value="1" ' . ($_MG_CONF['ad_enable_shutterfly'] ? ' checked="checked"' : '') . '/>';
    $views_select = '<input type="checkbox" name="enable_views" value="1" ' . ($_MG_CONF['ad_enable_views'] ? ' checked="checked"' : '') . '/>';
    $keywords_select = '<input type="checkbox" name="enable_keywords" value="1" ' . ($_MG_CONF['ad_enable_keywords'] ? ' checked="checked"' : '') . '/>';
    $sort_select = '<input type="checkbox" name="enable_sort" value="1" ' . ($_MG_CONF['ad_enable_sort'] ? ' checked="checked"' : '') . '/>';
    $rss_select = '<input type="checkbox" name="enable_rss" value="1" ' . ($_MG_CONF['ad_enable_rss'] ? ' checked="checked"' : '') . '/>';
    $postcard_select = '<select name="enable_postcard">';
    $postcard_select .= '<option value="0"' . ($_MG_CONF['ad_enable_postcard'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $postcard_select .= '<option value="1"' . ($_MG_CONF['ad_enable_postcard'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['members_only'] . '</option>';
    $postcard_select .= '<option value="2"' . ($_MG_CONF['ad_enable_postcard'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['all_users'] . '</option>';
    $postcard_select .= '</select>';
    $afirst_select = '<input type="checkbox" name="albums_first" value="1" ' . ($_MG_CONF['ad_albums_first'] ? ' checked="checked"' : '') . '/>';
    $album_views_select = '<input type="checkbox" name="enable_album_views" value="1" ' . ($_MG_CONF['ad_enable_album_views'] ? ' checked="checked"' : '') . '/>';
    $tn_size_select = '<select name="tn_size">';
    $tn_size_select .= '<option value="0"' . ($_MG_CONF['ad_tn_size'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['small'] . '</option>';
    $tn_size_select .= '<option value="1"' . ($_MG_CONF['ad_tn_size'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['medium'] . '</option>';
    $tn_size_select .= '<option value="2"' . ($_MG_CONF['ad_tn_size'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['large'] . '</option>';
    $tn_size_select .= '<option value="3"' . ($_MG_CONF['ad_tn_size'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['custom'] . '</option>';
    $tn_size_select .= '<option value="4"' . ($_MG_CONF['ad_tn_size'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG01['square'] . '</option>';
    $tn_size_select .= '</select>';
    $tnheight_input = '<input type="text" size="3" name="tnheight" value="' . $_MG_CONF['ad_tn_height'] . '"' . '/>';
    $tnwidth_input = '<input type="text" size="3" name="tnwidth" value="' . $_MG_CONF['ad_tn_width'] . '"' . '/>';
    $display_image_size_select = '<select name="display_image_size">';
    $display_image_size_select .= '<option value="0"' . ($_MG_CONF['ad_display_image_size'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_500x375'] . '</option>';
    $display_image_size_select .= '<option value="1"' . ($_MG_CONF['ad_display_image_size'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_600x450'] . '</option>';
    $display_image_size_select .= '<option value="2"' . ($_MG_CONF['ad_display_image_size'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_620x465'] . '</option>';
    $display_image_size_select .= '<option value="3"' . ($_MG_CONF['ad_display_image_size'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_720x540'] . '</option>';
    $display_image_size_select .= '<option value="4"' . ($_MG_CONF['ad_display_image_size'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_800x600'] . '</option>';
    $display_image_size_select .= '<option value="5"' . ($_MG_CONF['ad_display_image_size'] == 5 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_912x684'] . '</option>';
    $display_image_size_select .= '<option value="6"' . ($_MG_CONF['ad_display_image_size'] == 6 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_1024x768'] . '</option>';
    $display_image_size_select .= '<option value="7"' . ($_MG_CONF['ad_display_image_size'] == 7 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_1152x864'] . '</option>';
    $display_image_size_select .= '<option value="8"' . ($_MG_CONF['ad_display_image_size'] == 8 ? 'selected="selected"' : '') . '>' . $LANG_MG01['size_1280x1024'] . '</option>';
    $display_image_size_select .= '<option value="9"' . ($_MG_CONF['ad_display_image_size'] == 9 ? 'selected="selected"' : '') . '>' . $LANG_MG01['custom'] . ' - ' . $_MG_CONF['custom_image_width'] . 'x' . $_MG_CONF['custom_image_height'] . '</option>';
    $display_image_size_select .= '</select>';
    $rows_input = '<input type="text" size="3" name="display_rows" value="' . $_MG_CONF['ad_display_rows'] . '"' . '/>';
    $columns_input = '<input type="text" size="3" name="display_columns" value="' . $_MG_CONF['ad_display_columns'] . '"' . '/>';
    $max_image_height_input = '<input type="text" size="4" name="max_image_height" value="' . $_MG_CONF['ad_max_image_height'] . '"' . '/>';
    $max_image_width_input = '<input type="text" size="4" name="max_image_width" value="' . $_MG_CONF['ad_max_image_width'] . '"' . '/>';
    if ($_MG_CONF['ad_max_filesize'] != 0) {
        $max_filesize = $_MG_CONF['ad_max_filesize'] / 1024;
    } else {
        $max_filesize = 0;
    }
    $max_filesize_input = '<input type="text" size="10" name="max_filesize" value="' . $max_filesize . '"' . '/>';
    $email_mod_select = '<input type="checkbox" name="email_mod" value="1" ' . ($_MG_CONF['ad_email_mod'] ? ' checked="checked"' : '') . '/>';
    $playback_type = '<select name="playback_type">';
    $playback_type .= '<option value="0"' . ($_MG_CONF['ad_playback_type'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['play_in_popup'] . '</option>';
    $playback_type .= '<option value="1"' . ($_MG_CONF['ad_playback_type'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['download_to_local'] . '</option>';
    $playback_type .= '<option value="2"' . ($_MG_CONF['ad_playback_type'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['play_inline'] . '</option>';
    $playback_type .= '<option value="3"' . ($_MG_CONF['ad_playback_type'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['use_mms'] . '</option>';
    $playback_type .= '</select>';
    $album_sort_select = '<select name="album_sort_order">';
    $album_sort_select .= '<option value="0"' . ($_MG_CONF['ad_album_sort_order'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG03['no_sort'] . '</option>';
    $album_sort_select .= '<option value="1"' . ($_MG_CONF['ad_album_sort_order'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_capture_asc'] . '</option>';
    $album_sort_select .= '<option value="2"' . ($_MG_CONF['ad_album_sort_order'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_capture'] . '</option>';
    $album_sort_select .= '<option value="3"' . ($_MG_CONF['ad_album_sort_order'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_upload_asc'] . '</option>';
    $album_sort_select .= '<option value="4"' . ($_MG_CONF['ad_album_sort_order'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_upload'] . '</option>';
    $album_sort_select .= '<option value="5"' . ($_MG_CONF['ad_album_sort_order'] == 5 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_alpha'] . '</option>';
    $album_sort_select .= '<option value="6"' . ($_MG_CONF['ad_album_sort_order'] == 6 ? 'selected="selected"' : '') . '>' . $LANG_MG03['sort_alpha_asc'] . '</option>';
    $album_sort_select .= '</select>';
    $display_album_desc_select = '<input type="checkbox" name="display_album_desc" value="1" ' . ($_MG_CONF['ad_display_album_desc'] ? ' checked="checked"' : '') . '/>';
    // watermark stuff...
    $wm_auto_select = '<input type="checkbox" name="wm_auto" value="1" ' . ($_MG_CONF['ad_wm_auto'] ? ' checked="checked"' : '') . '/>';
    $wm_opacity_select = '<select name="wm_opacity">';
    $wm_opacity_select .= '<option value="10"' . ($_MG_CONF['ad_wm_opacity'] == 10 ? 'selected="selected"' : '') . '>10%</option>';
    $wm_opacity_select .= '<option value="20"' . ($_MG_CONF['ad_wm_opacity'] == 20 ? 'selected="selected"' : '') . '>20%</option>';
    $wm_opacity_select .= '<option value="30"' . ($_MG_CONF['ad_wm_opacity'] == 30 ? 'selected="selected"' : '') . '>30%</option>';
    $wm_opacity_select .= '<option value="40"' . ($_MG_CONF['ad_wm_opacity'] == 40 ? 'selected="selected"' : '') . '>40%</option>';
    $wm_opacity_select .= '<option value="50"' . ($_MG_CONF['ad_wm_opacity'] == 50 ? 'selected="selected"' : '') . '>50%</option>';
    $wm_opacity_select .= '<option value="60"' . ($_MG_CONF['ad_wm_opacity'] == 60 ? 'selected="selected"' : '') . '>60%</option>';
    $wm_opacity_select .= '<option value="70"' . ($_MG_CONF['ad_wm_opacity'] == 70 ? 'selected="selected"' : '') . '>70%</option>';
    $wm_opacity_select .= '<option value="80"' . ($_MG_CONF['ad_wm_opacity'] == 80 ? 'selected="selected"' : '') . '>80%</option>';
    $wm_opacity_select .= '<option value="90"' . ($_MG_CONF['ad_wm_opacity'] == 90 ? 'selected="selected"' : '') . '>90%</option>';
    $wm_opacity_select .= '</select>';
    $wm_location_select = '<select name="wm_location">';
    $wm_location_select .= '<option value="1"' . ($_MG_CONF['ad_wm_location'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['top_left'] . '</option>';
    $wm_location_select .= '<option value="2"' . ($_MG_CONF['ad_wm_location'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['top_center'] . '</option>';
    $wm_location_select .= '<option value="3"' . ($_MG_CONF['ad_wm_location'] == 3 ? 'selected="selected"' : '') . '>' . $LANG_MG01['top_right'] . '</option>';
    $wm_location_select .= '<option value="4"' . ($_MG_CONF['ad_wm_location'] == 4 ? 'selected="selected"' : '') . '>' . $LANG_MG01['middle_left'] . '</option>';
    $wm_location_select .= '<option value="5"' . ($_MG_CONF['ad_wm_location'] == 5 ? 'selected="selected"' : '') . '>' . $LANG_MG01['middle_center'] . '</option>';
    $wm_location_select .= '<option value="6"' . ($_MG_CONF['ad_wm_location'] == 6 ? 'selected="selected"' : '') . '>' . $LANG_MG01['middle_right'] . '</option>';
    $wm_location_select .= '<option value="7"' . ($_MG_CONF['ad_wm_location'] == 7 ? 'selected="selected"' : '') . '>' . $LANG_MG01['bottom_left'] . '</option>';
    $wm_location_select .= '<option value="8"' . ($_MG_CONF['ad_wm_location'] == 8 ? 'selected="selected"' : '') . '>' . $LANG_MG01['bottom_center'] . '</option>';
    $wm_location_select .= '<option value="9"' . ($_MG_CONF['ad_wm_location'] == 9 ? 'selected="selected"' : '') . '>' . $LANG_MG01['bottom_right'] . '</option>';
    $wm_location_select .= '</select>';
    // now select what watermarks we have permission to use...
    $whereClause = " WHERE wm_id<>0 AND ";
    if (SEC_hasRights('mediagallery.config')) {
        $whereClause .= "1=1";
    } else {
        $whereClause .= "(owner_id=" . $_USER['uid'] . " OR owner_id=0)";
    }
    $sql = "SELECT * FROM {$_TABLES['mg_watermarks']} " . $whereClause . " ORDER BY owner_id";
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    $wm_select = '<select name="wm_id"  onchange="javascript:change(this)">';
    $wm_select .= '<option value="blank.png">' . $LANG_MG01['no_watermark'] . '</option>';
    $wm_current = '<img src="' . $_MG_CONF['site_url'] . '/watermarks/blank.png" name="myImage" alt=""' . '/>';
    for ($i = 0; $i < $nRows; $i++) {
        $row = DB_fetchArray($result);
        $wm_select .= '<option value="' . $row['filename'] . '"' . ($_MG_CONF['ad_wm_id'] == $row['wm_id'] ? 'selected="selected"' : '') . '>' . $row['filename'] . '</option>';
        if ($_MG_CONF['ad_wm_id'] == $row['wm_id']) {
            $wm_current = '<img src="' . $_MG_CONF['site_url'] . '/watermarks/' . $row['filename'] . '" name="myImage" alt=""' . '/>';
        }
    }
    $wm_select .= '</select>';
    $allow_download_select = '<input type="checkbox" name="allow_download" value="1" ' . ($_MG_CONF['ad_allow_download'] ? ' checked="checked"' : '') . '/>';
    $filename_title_select = '<input type="checkbox" name="filename_title" value="1" ' . ($_MG_CONF['ad_filename_title'] ? ' checked="checked"' : '') . '/>';
    // permission template
    $usergroups = SEC_getUserGroups();
    $groupdd = '';
    $moddd = '';
    $gresult = DB_query("SELECT grp_id FROM {$_TABLES['groups']} WHERE grp_name LIKE 'mediagallery Admin'");
    $grow = DB_fetchArray($gresult);
    $default_group_id = $grow['grp_id'];
    if (!isset($_MG_CONF['ad_mod_group_id'])) {
        $_MG_CONF['ad_mod_group_id'] = $default_group_id;
    }
    $groupdd .= '<select name="group_id">';
    $moddd .= '<select name="mod_id">';
    for ($i = 0; $i < count($usergroups); $i++) {
        if ($usergroups[key($usergroups)] != 2 && $usergroups[key($usergroups)] != 13) {
            $groupdd .= '<option value="' . $usergroups[key($usergroups)] . '"';
            $moddd .= '<option value="' . $usergroups[key($usergroups)] . '"';
            if ($default_group_id == $usergroups[key($usergroups)]) {
                $groupdd .= ' selected="selected"';
                $groupname = key($usergroups);
            }
            if ($_MG_CONF['ad_mod_group_id'] == $usergroups[key($usergroups)]) {
                $moddd .= ' selected="selected"';
            }
            $groupdd .= '>' . key($usergroups) . '</option>';
            $moddd .= '>' . key($usergroups) . '</option>';
        }
        next($usergroups);
    }
    $groupdd .= '</select>';
    $moddd .= '</select>';
    $upload_select = '<input type="checkbox" name="uploads" value="1" ' . ($_MG_CONF['ad_member_uploads'] ? ' checked="checked"' : '') . '/>';
    $moderate_select = '<input type="checkbox" name="moderate" value="1" ' . ($_MG_CONF['ad_moderate'] ? ' checked="checked"' : '') . '/>';
    $frames = new mgFrame();
    $skins = array();
    $skins = $frames->getFrames();
    $skin_select = '<select name="skin">';
    $askin_select = '<select name="askin">';
    $dskin_select = '<select name="dskin">';
    for ($i = 0; $i < count($skins); $i++) {
        $skin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($_MG_CONF['ad_image_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
        $askin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($_MG_CONF['ad_album_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
        $dskin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($_MG_CONF['ad_display_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
    }
    $skin_select .= '</select>';
    $askin_select .= '</select>';
    $dskin_select .= '</select>';
    $T->set_var(array('jpg_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_JPG ? ' checked="checked"' : '', 'png_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_PNG ? ' checked="checked"' : '', 'tif_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_TIF ? ' checked="checked"' : '', 'gif_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_GIF ? ' checked="checked"' : '', 'bmp_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_BMP ? ' checked="checked"' : '', 'tga_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_TGA ? ' checked="checked"' : '', 'psd_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_PSD ? ' checked="checked"' : '', 'mp3_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_MP3 ? ' checked="checked"' : '', 'ogg_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_OGG ? ' checked="checked"' : '', 'asf_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_ASF ? ' checked="checked"' : '', 'swf_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_SWF ? ' checked="checked"' : '', 'mov_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_MOV ? ' checked="checked"' : '', 'mp4_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_MP4 ? ' checked="checked"' : '', 'mpg_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_MPG ? ' checked="checked"' : '', 'zip_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_ZIP ? ' checked="checked"' : '', 'flv_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_FLV ? ' checked="checked"' : '', 'rflv_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_RFLV ? ' checked="checked"' : '', 'emb_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_EMB ? ' checked="checked"' : '', 'other_checked' => (int) $_MG_CONF['ad_valid_formats'] & (int) MG_OTHER ? ' checked="checked"' : '', 'lang_jpg' => $LANG_MG01['jpg'], 'lang_png' => $LANG_MG01['png'], 'lang_tif' => $LANG_MG01['tif'], 'lang_gif' => $LANG_MG01['gif'], 'lang_bmp' => $LANG_MG01['bmp'], 'lang_tga' => $LANG_MG01['tga'], 'lang_psd' => $LANG_MG01['psd'], 'lang_mp3' => $LANG_MG01['mp3'], 'lang_ogg' => $LANG_MG01['ogg'], 'lang_asf' => $LANG_MG01['asf'], 'lang_swf' => $LANG_MG01['swf'], 'lang_mov' => $LANG_MG01['mov'], 'lang_mp4' => $LANG_MG01['mp4'], 'lang_mpg' => $LANG_MG01['mpg'], 'lang_zip' => $LANG_MG01['zip'], 'lang_flv' => $LANG_MG01['flv'], 'lang_rflv' => $LANG_MG01['rflv'], 'lang_emb' => $LANG_MG01['emb'], 'lang_other' => $LANG_MG01['other'], 'lang_allowed_formats' => $LANG_MG01['allowed_media_formats'], 'lang_image' => $LANG_MG01['image'], 'lang_audio' => $LANG_MG01['audio'], 'lang_video' => $LANG_MG01['video']));
    $T->parse('valid_formats', 'admin_formats');
    $T->set_var(array('lang_uploads' => $LANG_MG01['anonymous_uploads_prompt'], 'lang_accessrights' => $LANG_ACCESS['accessrights'], 'lang_owner' => $LANG_ACCESS['owner'], 'lang_group' => $LANG_ACCESS['group'], 'lang_permissions' => $LANG_ACCESS['permissions'], 'lang_perm_key' => $LANG_ACCESS['permissionskey'], 'lang_hidden' => $LANG_MG01['hidden'], 'permissions_editor' => SEC_getPermissionsHTML($_MG_CONF['ad_perm_owner'], $_MG_CONF['ad_perm_group'], $_MG_CONF['ad_perm_members'], $_MG_CONF['ad_perm_anon']), 'permissions_msg' => $LANG_ACCESS['permmsg'], 'group_dropdown' => $groupdd, 'mod_dropdown' => $moddd, 'lang_member_upload' => $LANG_MG01['member_upload'], 'lang_moderate_album' => $LANG_MG01['mod_album'], 'lang_mod_group' => $LANG_MG01['moderation_group'], 'lang_zero_unlimited' => $LANG_MG01['zero_unlimited'], 'uploads' => $upload_select, 'moderate' => $moderate_select));
    $T->set_var(array('action' => 'album', 'path_mg' => $_MG_CONF['site_url'], 'comment_select' => $comment_select, 'exif_select' => $exif_select, 'ranking_select' => $ranking_select, 'full_select' => $full_select, 'ss_select' => $ss_select, 'ri_select' => $ri_select, 'sf_select' => $sf_select, 'views_select' => $views_select, 'keywords_select' => $keywords_select, 'album_views_select' => $album_views_select, 'display_album_desc_select' => $display_album_desc_select, 'sort_select' => $sort_select, 'rss_select' => $rss_select, 'podcast_select' => $podcast_select, 'postcard_select' => $postcard_select, 'afirst_select' => $afirst_select, 'tn_size_select' => $tn_size_select, 'tnheight_input' => $tnheight_input, 'tnwidth_input' => $tnwidth_input, 'height_input' => $max_image_height_input, 'width_input' => $max_image_width_input, 'max_size_input' => $max_filesize_input, 'display_image_size' => $display_image_size_select, 'rows_input' => $rows_input, 'columns_input' => $columns_input, 'email_mod_select' => $email_mod_select, 'playback_type' => $playback_type, 'album_theme_select' => $album_theme_select, 'rsschildren_select' => $rsschildren_select, 'mp3ribbon_select' => $mp3ribbon_select, 'wm_auto_select' => $wm_auto_select, 'wm_opacity_select' => $wm_opacity_select, 'wm_location_select' => $wm_location_select, 'wm_select' => $wm_select, 'wm_current' => $wm_current, 'album_sort_select' => $album_sort_select, 'allow_download_select' => $allow_download_select, 'filename_title_select' => $filename_title_select, 'skin_select' => $skin_select, 'askin_select' => $askin_select, 'dskin_select' => $dskin_select, 'lang_save' => $LANG_MG01['save'], 's_form_action' => $_CONF['site_admin_url'] . '/plugins/mediagallery/defaults.php', 'lang_album_edit_help' => $LANG_MG01['album_edit_help'], 'lang_title' => $LANG_MG01['title'], 'lang_parent_album' => $LANG_MG01['parent_album'], 'lang_description' => $LANG_MG01['description'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_comments' => $LANG_MG01['comments_prompt'], 'lang_enable_exif' => $LANG_MG01['enable_exif'], 'lang_enable_ratings' => $LANG_MG01['enable_ratings'], 'lang_ss_enable' => $LANG_MG01['ss_enable'], 'lang_ri_enable' => $LANG_MG01['ri_enable'], 'lang_sf_enable' => $LANG_MG01['sf_enable'], 'lang_tn_size' => $LANG_MG01['tn_size'], 'lang_rows' => $LANG_MG01['rows'], 'lang_columns' => $LANG_MG01['columns'], 'lang_av_play_album' => $LANG_MG01['av_play_album'], 'lang_av_play_options' => $LANG_MG01['av_play_options'], 'lang_attached_thumbnail' => $LANG_MG01['attached_thumbnail'], 'lang_thumbnail' => $LANG_MG01['thumbnail'], 'lang_email_mods_on_submission' => $LANG_MG01['email_mods_on_submission'], 'lang_album_attributes' => $LANG_MG01['album_attributes'], 'lang_album_cover' => $LANG_MG01['album_cover'], 'lang_enable_views' => $LANG_MG01['enable_views'], 'lang_enable_keywords' => $LANG_MG01['enable_keywords'], 'lang_enable_album_views' => $LANG_MG01['enable_album_views'], 'lang_enable_sort' => $LANG_MG01['enable_sort'], 'lang_enable_rss' => $LANG_MG01['enable_rss'], 'lang_enable_postcard' => $LANG_MG01['enable_postcard'], 'lang_albums_first' => $LANG_MG01['albums_first'], 'lang_full_display' => $LANG_MG01['full_display'], 'lang_max_image_height' => $LANG_MG01['max_image_height'], 'lang_max_image_width' => $LANG_MG01['max_image_width'], 'lang_max_filesize' => $LANG_MG01['max_filesize'], 'lang_display_image_size' => $LANG_MG01['display_image_size'], 'lang_album_sort' => $LANG_MG01['default_album_sort'], 'lang_watermark' => $LANG_MG01['watermark'], 'lang_wm_auto' => $LANG_MG01['watermark_auto'], 'lang_wm_opacity' => $LANG_MG01['watermark_opacity'], 'lang_wm_location' => $LANG_MG01['watermark_location'], 'lang_wm_id' => $LANG_MG01['watermark_image'], 'lang_allow_download' => $LANG_MG01['allow_download'], 'lang_display_album_desc' => $LANG_MG01['display_album_desc'], 'lang_filename_title' => $LANG_MG01['filename_title'], 'lang_image_skin' => $LANG_MG01['image_skin'], 'lang_album_skin' => $LANG_MG01['album_skin'], 'lang_display_skin' => $LANG_MG01['display_skin'], 'rtl' => $LANG_DIRECTION == "rtl" ? "rtl" : "", 'lang_podcast' => $LANG_MG01['podcast'], 'lang_theme_select' => $LANG_MG01['album_theme'], 'lang_rsschildren' => $LANG_MG01['rsschildren'], 'lang_mp3ribbon' => $LANG_MG01['mp3ribbon'], 'lang_tnheight' => $LANG_MG01['tn_height'], 'lang_tnwidth' => $LANG_MG01['tn_width']));
    $T->parse('output', 'admin');
    $retval .= $T->finish($T->get_var('output'));
    return $retval;
}
示例#8
0
function MG_displayMediaImage($mediaObject, $full, $sortOrder, $comments, $sortID = 0, $spage = 0)
{
    global $MG_albums, $_TABLES, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG04, $LANG_ACCESS, $LANG01, $album_jumpbox, $glversion, $_USER, $_MG_USERPREFS;
    global $_DB_dbms, $LANG04, $ratedIds;
    $retval = '';
    $media_link_start = '';
    $media_link_end = '';
    $srcID = $mediaObject;
    $outputHandle = outputHandler::getInstance();
    $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($mediaObject) . '"');
    if (isset($MG_albums[$aid]->pid)) {
        $pid = $MG_albums[$aid]->pid;
    } else {
        $pid = 0;
    }
    if (@method_exists($MG_albums[$aid], 'getOffset')) {
        $aOffset = $MG_albums[$aid]->getOffset();
    } else {
        $aOffset = -1;
    }
    if ($aOffset == -1 || $MG_albums[$aid]->access == 0) {
        $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
        return array($LANG_MG00['access_denied_msg'], $retval);
    }
    $mid = $mediaObject;
    $orderBy = MG_getSortOrder($aid, $sortOrder);
    $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma LEFT JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id=" . $aid . $orderBy;
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    $total_media = $nRows;
    $media = array();
    while ($row = DB_fetchArray($result)) {
        $media[] = $row;
        $ids[] = $row['media_id'];
    }
    $key = array_search($mid, $ids);
    if ($key === false) {
        $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
        return array($LANG_MG00['access_denited_msg'], $retval);
    }
    $mediaObject = $key;
    if ($MG_albums[$aid]->full == 2 || $_MG_CONF['discard_original'] == 1 || $MG_albums[$aid]->full == 1 && COM_isAnonUser()) {
        $full = 0;
    }
    if ($full) {
        $disp = 'orig';
    } else {
        $disp = 'disp';
    }
    if ($MG_albums[$aid]->enable_comments == 0) {
        $comments = 0;
    }
    if ($sortID > 0) {
        $MG_albums[$aid]->enable_slideshow = 0;
    }
    $themeCSS = '';
    $nFrame = new mgFrame();
    $nFrame->constructor($MG_albums[$aid]->display_skin);
    $MG_albums[$aid]->displayFrameTemplate = $nFrame->getTemplate();
    $MG_albums[$aid]->dfrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR'];
    $MG_albums[$aid]->dfrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB'];
    $themeCSS = $nFrame->getCSS();
    if ($themeCSS != '') {
        $outputHandle->addStyle($themeCSS);
        $themeCSS = '';
    }
    $T = new Template(MG_getTemplatePath($aid));
    switch ($media[$mediaObject]['media_type']) {
        case '0':
            // image
            $T->set_file('page', 'view_image.thtml');
            $ogType = 'article';
            break;
        case '1':
            // video
        // video
        case '5':
            // embedded video
            $meta_file_name = $_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext'];
            COM_errorLog("DEBUG: Video File: " . $meta_file_name);
            $meta = IMG_getMediaMetaData($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext']);
            COM_errorLog("DEBUG: Video Meta Type: " . $meta['mime_type']);
            if ($meta['mime_type'] == 'video/quicktime') {
                if ($meta['fileformat'] == 'mp4') {
                    $media[$mediaObject]['mime_type'] = 'video/mp4';
                }
            }
            $T->set_file('page', 'view_video.thtml');
            $ogType = 'video.movie';
            break;
        case '2':
            // audio
            $T->set_file('page', 'view_audio.thtml');
            $ogType = 'music.song';
            break;
        default:
            $T->set_file('page', 'view_image.thtml');
            $ogType = 'article';
            break;
    }
    $ptitle = isset($media[$mediaObject]['media_title']) && $media[$mediaObject]['media_title'] != ' ' ? PLG_replaceTags($media[$mediaObject]['media_title'], 'mediagallery', 'media_title') : '';
    $permalink = COM_buildUrl($_MG_CONF['site_url'] . '/media.php?s=' . $srcID);
    $outputHandle->addLink("canonical", $permalink);
    $outputHandle->addMeta('property', 'og:title', $ptitle);
    $outputHandle->addMeta('property', 'og:type', $ogType);
    $outputHandle->addMeta('property', 'og:url', $permalink);
    $T->set_var('permalink', $permalink);
    $T->set_file(array('shutterfly' => 'digibug.thtml'));
    $T->set_var('header', $LANG_MG00['plugin']);
    $T->set_var('site_url', $_MG_CONF['site_url']);
    $T->set_var('plugin', 'mediagallery');
    // construct the album jumpbox...
    $level = 0;
    $album_jumpbox = '<form name="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>';
    $album_jumpbox .= $LANG_MG03['jump_to'] . ':&nbsp;<select name="aid" onchange="forms[\'jumpbox\'].submit()">';
    $MG_albums[0]->buildJumpBox($aid);
    $album_jumpbox .= '</select>';
    $album_jumpbox .= '&nbsp;<input type="submit" value="' . $LANG_MG03['go'] . '"/>';
    $album_jumpbox .= '<input type="hidden" name="page" value="1"/>';
    $album_jumpbox .= '</div></form>';
    // Update the views count... But only for non-admins
    if (!$MG_albums[0]->owner_id) {
        $media_views = $media[$mediaObject]['media_views'] + 1;
        DB_query("UPDATE " . $_TABLES['mg_media'] . " SET media_views=" . $media_views . " WHERE media_id='" . DB_escapeString($media[$mediaObject]['media_id']) . "'");
    }
    $columns_per_page = $MG_albums[$aid]->display_columns == 0 ? $_MG_CONF['ad_display_columns'] : $MG_albums[$aid]->display_columns;
    $rows_per_page = $MG_albums[$aid]->display_rows == 0 ? $_MG_CONF['ad_display_rows'] : $MG_albums[$aid]->display_rows;
    if (isset($_MG_USERPREFS['display_rows']) && $_MG_USERPREFS['display_rows'] > 0) {
        $rows_per_page = $_MG_USERPREFS['display_rows'];
    }
    if (isset($_MG_USERPREFS['display_columns']) && $_MG_USERPREFS['display_columns'] > 0) {
        $columns_per_page = $_MG_USERPREFS['display_columns'];
    }
    $media_per_page = $columns_per_page * $rows_per_page;
    if ($MG_albums[$aid]->albums_first) {
        $childCount = $MG_albums[$aid]->getChildCount();
        $page = intval(($mediaObject + $childCount) / $media_per_page) + 1;
    } else {
        $page = intval($mediaObject / $media_per_page) + 1;
    }
    /*
     * check to see if the original image exists, if not fall back to full image
     */
    $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . '.' . $media[$mediaObject]['media_mime_ext']);
    if ($media_size_orig == false) {
        $full = 0;
        $disp = 'disp';
    }
    $aPage = intval($aOffset / ($_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows'])) + 1;
    if ($sortID > 0) {
        $birdseed = '<a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a> ' . ($_MG_CONF['gallery_only'] == 1 ? '' : $_MG_CONF['seperator'] . ' <a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a> ') . $_MG_CONF['seperator'] . '<a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&amp;page=' . $spage . '">' . $LANG_MG03['search_results'] . '</a>';
        $MG_albums[$aid]->getPath(1, $sortOrder, $page) . '</a>';
        $birdseed_ul = '<li><a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&amp;page=' . $spage . '">' . $LANG_MG03['search_results'] . '</a></li>' . $MG_albums[$aid]->getPath_ul(1, $sortOrder, $page) . '</a>';
        $album_link = '<a href="' . $_MG_CONF['site_url'] . '/search.php?id=' . $sortID . '&amp;page=' . $spage . '">';
    } else {
        $birdseed = '<a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a> ' . ($_MG_CONF['gallery_only'] == 1 ? '' : $_MG_CONF['seperator'] . ' <a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a> ') . $MG_albums[$aid]->getPath(1, $sortOrder, $page) . '</a>';
        $birdseed_ul = '<li><a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a></li>' . '<li><a href="' . $_MG_CONF['site_url'] . '/index.php?page=' . $aPage . '">' . $_MG_CONF['menulabel'] . '</a></li>' . $MG_albums[$aid]->getPath_ul(1, $sortOrder, $page) . '</a>';
        $album_link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '&amp;page=' . $page . '&amp;sort=' . $sortOrder . '">';
    }
    mg_usage('media_view', $MG_albums[$aid]->title, $media[$mediaObject]['media_title'], $media[$mediaObject]['media_id']);
    // hack for tga files...
    if ($media[$mediaObject]['mime_type'] == 'image/x-targa' || $media[$mediaObject]['mime_type'] == 'image/tga') {
        $full = 0;
        $disp = 'disp';
    }
    switch ($media[$mediaObject]['mime_type']) {
        case 'video/x-ms-asf':
        case 'video/x-ms-asf-plugin':
        case 'video/avi':
        case 'video/msvideo':
        case 'video/x-msvideo':
        case 'video/avs-video':
        case 'video/x-ms-wmv':
        case 'video/x-ms-wvx':
        case 'video/x-ms-wm':
        case 'application/x-troff-msvideo':
        case 'application/x-ms-wmz':
        case 'application/x-ms-wmd':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full);
            break;
        case 'audio/x-ms-wma':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP3($aid, $media[$mediaObject], $full);
            break;
        case 'video/mp4':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP4($aid, $media[$mediaObject], $full);
            break;
        case 'video/mpeg':
        case 'video/x-mpeg':
        case 'video/x-mpeq2a':
            if ($_MG_CONF['use_wmp_mpeg'] == 1) {
                list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full);
                break;
            }
        case 'video/x-motion-jpeg':
        case 'video/quicktime':
        case 'video/x-qtc':
        case 'video/x-m4v':
            if ($media[$mediaObject]['media_mime_ext'] == 'mp4' && isset($_MG_CONF['play_mp4_flv']) && $_MG_CONF['play_mp4_flv'] == true) {
                list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayFLV($aid, $media[$mediaObject], $full);
            } else {
                list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMOV($aid, $media[$mediaObject], $full);
            }
            break;
        case 'embed':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayEmbed($aid, $media[$mediaObject], $full, $mediaObject);
            break;
        case 'application/x-shockwave-flash':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displaySWF($aid, $media[$mediaObject], $full);
            break;
        case 'video/x-flv':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayFLV($aid, $media[$mediaObject], $full);
            break;
        case 'audio/mpeg':
        case 'audio/x-mpeg':
        case 'audio/mpeg3':
        case 'audio/x-mpeg-3':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayMP3($aid, $media[$mediaObject], $full);
            break;
        case 'application/ogg':
        case 'application/x-ogg':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayOGG($aid, $media[$mediaObject], $full);
            break;
        case 'image/x-targa':
        case 'image/tga':
        case 'image/tiff':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayTGA($aid, $media[$mediaObject], $full, $mediaObject);
            break;
        case 'image/photoshop':
        case 'image/x-photoshop':
        case 'image/psd':
        case 'application/photoshop':
        case 'application/psd':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayPSD($aid, $media[$mediaObject], $full, $mediaObject);
            break;
        case 'image/gif':
        case 'image/jpeg':
        case 'image/jpg':
        case 'image/png':
        case 'image/bmp':
            list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url, $media_link_start, $media_link_end) = MG_displayJPG($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder, $sortID, $spage);
            break;
        default:
            switch ($media[$mediaObject]['media_mime_ext']) {
                case 'jpg':
                case 'gif':
                case 'png':
                case 'bmp':
                    list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url, $media_link_start, $media_link_end) = MG_displayJPG($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder, $sortID, $spage);
                    break;
                case 'asf':
                    list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayASF($aid, $media[$mediaObject], $full);
                    break;
                default:
                    list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_displayGeneric($aid, $media[$mediaObject], $full, $media[$mediaObject]['media_id'], $sortOrder);
                    break;
            }
    }
    $mid = $media[$mediaObject]['media_id'];
    $media_date = MG_getUserDateTimeFormat($media[$mediaObject]['media_time']);
    $upload_date = MG_getUserDateTimeFormat($media[$mediaObject]['media_upload_time']);
    // build the rating bar if rating is enabled.
    if ($MG_albums[$aid]->enable_rating > 0) {
        $uid = COM_isAnonUser() ? 1 : $_USER['uid'];
        $static = false;
        $voted = 0;
        // check to see if we are the owner, if so, no rating for us...
        if (isset($_USER['uid']) && $_USER['uid'] == $media[$mediaObject]['media_user_id']) {
            $static = true;
            $voted = 0;
        } else {
            if (in_array($media[$mediaObject]['media_id'], $ratedIds)) {
                $static = true;
                $voted = 1;
            } else {
                $static = 0;
                $voted = 0;
            }
        }
        if ($MG_albums[$aid]->enable_rating == 1 && COM_isAnonUser()) {
            $static = true;
            $voted = 0;
        }
        $rating_box = RATING_ratingBar('mediagallery', $media[$mediaObject]['media_id'], $media[$mediaObject]['media_votes'], $media[$mediaObject]['media_rating'], $voted, 5, $static, '');
    } else {
        $rating_box = '';
    }
    $T->set_var('rating_box', $rating_box);
    if ($MG_albums[$aid]->allow_download) {
        $T->set_var(array('download' => '<a href="' . $_MG_CONF['site_url'] . '/download.php?mid=' . $media[$mediaObject]['media_id'] . '">' . $LANG_MG01['download'] . '</a>'));
    }
    if ($media[$mediaObject]['media_type'] == 0 && $MG_albums[$aid]->enable_shutterfly) {
        $media_size_orig = false;
        $media_size_tn = false;
        if ($_MG_CONF['discard_original'] == 1) {
            foreach ($_MG_CONF['validExtensions'] as $ext) {
                if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) {
                    $sf_picture = $_MG_CONF['mediaobjects_url'] . '/disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext;
                    $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext);
                    break;
                }
            }
        } else {
            foreach ($_MG_CONF['validExtensions'] as $ext) {
                if (file_exists($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) {
                    $sf_picture = $_MG_CONF['mediaobjects_url'] . '/orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext;
                    $media_size_orig = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext);
                    break;
                }
            }
        }
        foreach ($_MG_CONF['validExtensions'] as $ext) {
            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext)) {
                $tnImage = $_MG_CONF['mediaobjects_url'] . '/tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext;
                $media_size_tn = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $media[$mediaObject]['media_filename'][0] . '/' . $media[$mediaObject]['media_filename'] . $ext);
                break;
            }
        }
        $outputHandle->addMeta('property', 'og:image', $tnImage);
        if ($media_size_orig != false && $media_size_tn != false) {
            $T->set_var(array('sf_height' => $media_size_orig[1], 'sf_width' => $media_size_orig[0], 'sf_tn_height' => $media_size_tn[1], 'sf_tn_width' => $media_size_tn[0], 'sf_thumbnail' => $tnImage, 'sf_picture' => $sf_picture, 'sf_title' => $media[$mediaObject]['media_title'], 'lang_print_digibug' => $LANG_MG03['print_digibug'], 'lang_print_shutterfly' => $LANG_MG03['print_shutterfly']));
            $T->parse('shutterfly_submit', 'shutterfly');
        }
    }
    if ($MG_albums[$aid]->access == 3 || $_MG_CONF['allow_user_edit'] == true && isset($_USER['uid']) && $media[$mediaObject]['media_user_id'] == $_USER['uid']) {
        $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;s=1&amp;album_id=' . $aid . '&amp;mid=' . $mid . '">' . $LANG_MG01['edit'] . '</a>';
    } else {
        $edit_item = '';
    }
    $media_desc = PLG_replaceTags(nl2br($media[$mediaObject]['media_desc']), 'mediagallery', 'media_description');
    if (strlen($media_desc) > 0) {
        USES_lib_html2text();
        $metaDesc = $media_desc;
        $metaDesc = strip_tags($metaDesc);
        $html2txt = new html2text($metaDesc, false);
        $metaDesc = trim($html2txt->get_text());
        $shortComment = '';
        $metaArray = explode(' ', $metaDesc);
        $wordCount = count($metaArray);
        $lengthCount = 0;
        $tailString = '';
        foreach ($metaArray as $word) {
            $lengthCount = $lengthCount + strlen($word);
            $shortComment .= $word . ' ';
            if ($lengthCount >= 100) {
                $tailString = '...';
                break;
            }
        }
        $metaDesc = trim($shortComment) . $tailString;
        $outputHandle->addMeta('name', 'description', htmlspecialchars($metaDesc, ENT_QUOTES, COM_getEncodingt()));
        $media_desc .= '<br/><br/>';
    }
    // start of the lightbox slideshow code
    if ($MG_albums[$aid]->enable_slideshow == 2) {
        $lbSlideShow = '<noscript><div class="pluginAlert">' . $LANG04[150] . '</div></noscript>' . LB;
        $lbSlideShow .= '<script type="text/javascript">' . LB;
        $lbSlideShow .= 'function openGallery1() {' . LB;
        $lbSlideShow .= '    return loadXMLDoc("' . $_MG_CONF['site_url'] . '/lightbox.php?aid=' . $aid . '");';
        $lbSlideShow .= '}' . LB;
        $lbSlideShow .= '</script>' . LB;
        $T->set_var('lbslideshow', $lbSlideShow);
    } else {
        $T->set_var('lbslideshow', '');
    }
    // end of the lightbox slideshow code
    switch ($MG_albums[$aid]->enable_slideshow) {
        case 0:
            $url_slideshow = '';
            break;
        case 1:
            $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/slideshow.php?aid=' . $aid . '&amp;sort=' . $sortOrder . '"><b>' . $LANG_MG03['slide_show'] . '</b></a>';
            break;
        case 2:
            $lbss_count = DB_count($_TABLES['mg_media'], 'media_type', 0);
            $sql = "SELECT COUNT(m.media_id) as lbss_count FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE m.media_type = 0 AND ma.album_id=" . $aid;
            $res = DB_query($sql);
            list($lbss_count) = DB_fetchArray($res);
            if ($lbss_count != 0) {
                $url_slideshow = '<span id="mgslideshow" class="jsenabled_show" style="display:none"><a href="#" onclick="return openGallery1()"><b>' . $LANG_MG03['slide_show'] . '</b></a></span>';
            } else {
                $MG_albums[$aid]->enable_slideshow = 0;
            }
            break;
        case 3:
            $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/fslideshow.php?aid=' . $aid . '&amp;src=disp"><b>' . $LANG_MG03['slide_show'] . '</b></a>';
            break;
        case 4:
            $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/fslideshow.php?aid=' . $aid . '&amp;src=orig"><b>' . $LANG_MG03['slide_show'] . '</b></a>';
            break;
    }
    $prevLink = '';
    $nextLink = '';
    list($prevLink, $nextLink) = $sortID > 0 ? array('', '') : MG_getNextandPrev($_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&amp;sort=" . $sortOrder, $nRows, 1, $mediaObject, $media, TRUE);
    $T->set_var(array('birdseed' => $birdseed, 'birdseed_ul' => $birdseed_ul, 'slide_show' => isset($url_slideshow) ? $url_slideshow : '', 'image_detail' => $u_image, 'border_height' => $raw_image_height + 30, 'border_width' => $raw_image_width + 30, 'media_title' => isset($media[$mediaObject]['media_title']) && $media[$mediaObject]['media_title'] != ' ' ? PLG_replaceTags($media[$mediaObject]['media_title'], 'mediagallery', 'media_title') : '', 'album_title' => $sortID > 0 ? $LANG_MG03['search_results'] : $MG_albums[$aid]->title, 'media_desc' => isset($media[$mediaObject]['media_desc']) && $media[$mediaObject]['media_desc'] != ' ' ? $media_desc : '', 'artist' => isset($media[$mediaObject]['artist']) ? $media[$mediaObject]['artist'] : '', 'media_time' => $media_date[0], 'upload_time' => $upload_date[0], 'media_views' => $MG_albums[$aid]->enable_views ? $media[$mediaObject]['media_views'] : '', 'media_comments' => $MG_albums[$aid]->enable_comments ? $media[$mediaObject]['media_comments'] . '<br />' : '', 'pagination' => $sortID > 0 ? '' : generate_pic_pagination($_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&amp;sort=" . $sortOrder, $nRows, 1, $mediaObject, $media, TRUE), 'media_number' => sprintf("%s %d %s %d", $LANG_MG03['image'], $mediaObject + 1, $LANG_MG03['of'], $total_media), 'jumpbox' => $album_jumpbox, 'edit_item' => $edit_item, 'site_url' => $_MG_CONF['site_url'], 'lang_prev' => $LANG_MG03['previous'], 'lang_next' => $LANG_MG03['next'], 'next_link' => $nextLink, 'prev_link' => $prevLink, 'image_height' => $raw_image_height, 'image_width' => $raw_image_width, 'left_side' => intval($raw_image_width / 2) - 1, 'right_side' => intval($raw_image_width / 2), 'raw_image' => $raw_image, 'media_link_start' => $media_link_start, 'media_link_end' => $media_link_end, 'raw_link_url' => $raw_link_url, 'album_link' => $MG_albums[$aid]->getPath(1, $sortOrder, $page), 'item_number' => $mediaObject + 1, 'total_items' => $total_media, 'lang_of' => $LANG_MG03['of'], 'album_link' => $album_link));
    $getid3link = '';
    $getid3linkend = '';
    $T->set_var(array('getid3' => $getid3link, 'getid3end' => $getid3linkend));
    if ($getid3link != '') {
        $T->set_var('media_properties', $LANG_MG03['media_properties']);
    } else {
        $T->set_var('media_properties', '');
    }
    if ($MG_albums[$aid]->enable_keywords == 1 && !empty($media[$mediaObject]['media_keywords'])) {
        $kwText = '';
        $keyWords = array();
        $keyWords = explode(' ', $media[$mediaObject]['media_keywords']);
        $numKeyWords = count($keyWords);
        for ($i = 0; $i < $numKeyWords; $i++) {
            $keyWords[$i] = str_replace('"', ' ', $keyWords[$i]);
            $searchKeyword = $keyWords[$i];
            $keyWords[$i] = str_replace('_', ' ', $keyWords[$i]);
            $kwText .= '<a href="' . $_MG_CONF['site_url'] . '/search.php?mode=search&amp;swhere=1&amp;keywords=' . $searchKeyword . '&amp;keyType=any">' . $keyWords[$i] . '</a> ';
        }
        $T->set_var(array('media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords']));
    } else {
        $T->set_var(array('media_keywords' => '', 'lang_keywords' => ''));
    }
    if ($media[$mediaObject]['media_user_id'] == '' || !isset($media[$mediaObject]['media_user_id'])) {
        $media[$mediaObject]['media_user_id'] = 0;
    }
    if ($_CONF['show_fullname']) {
        $displayname = 'fullname';
    } else {
        $displayname = 'username';
    }
    $owner_name = DB_getItem($_TABLES['users'], $displayname, "uid = {$media[$mediaObject]['media_user_id']}");
    if (empty($owner_name) || $owner_name == '') {
        $owner_name = DB_getItem($_TABLES['users'], 'username', "uid = {$media[$mediaObject]['media_user_id']}");
        if (empty($owner_name) || $owner_name == '') {
            $owner_name = 'unknown';
        }
    }
    if ($owner_name != 'unknown') {
        $owner_link = '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $media[$mediaObject]['media_user_id'] . '">' . $owner_name . '</a>';
    } else {
        $owner_link = $owner_name;
    }
    $T->set_var('owner_username', $owner_link);
    if (($MG_albums[$aid]->exif_display == 2 || $MG_albums[$aid]->exif_display == 3) && $media[$mediaObject]['media_type'] == 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
        $haveEXIF = MG_haveEXIF($media[$mediaObject]['media_id']);
        if ($haveEXIF) {
            $T->set_var(array('property' => $_MG_CONF['site_url'] . '/property.php?mid=' . $media[$mediaObject]['media_id'], 'lang_property' => $LANG_MG04['exif_header']));
        }
    }
    if ($MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1) {
        $T->set_var(array('media_id' => $media[$mediaObject]['media_id']));
    }
    // Language specific vars
    $T->set_var(array('lang_comments' => $MG_albums[$aid]->enable_comments ? $LANG_MG03['comments'] : '', 'lang_views' => $MG_albums[$aid]->enable_views ? $LANG_MG03['views'] : '', 'lang_title' => $LANG_MG01['title'], 'print_shutterfly' => $LANG_MG03['print_shutterfly'], 'lang_uploaded_by' => $LANG_MG01['uploaded_by'], 'album_id' => $aid, 'lang_search' => $LANG_MG01['search']));
    if (($MG_albums[$aid]->exif_display == 1 || $MG_albums[$aid]->exif_display == 3) && $media[$mediaObject]['media_type'] == 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
        $haveEXIF = MG_haveEXIF($media[$mediaObject]['media_id']);
        if ($haveEXIF) {
            $exifData = MG_readEXIF($media[$mediaObject]['media_id'], 2);
            $T->set_var(array('exif_info' => $exifData));
        }
    }
    if ($sortID == 0) {
        if ($MG_albums[$aid]->enable_postcard == 1 && !COM_isAnonUser() || $MG_albums[$aid]->enable_postcard == 2) {
            if ($media[$mediaObject]['media_type'] == 0) {
                $postcard_link = '<a href="' . $_MG_CONF['site_url'] . '/postcard.php?mode=edit&amp;mid=' . $media[$mediaObject]['media_id'] . '"><img src="' . MG_getImageFile('icon_envelopeSmall.gif') . '" alt="' . $LANG_MG03['send_postcard'] . '" style="border:none;"/></a>';
                $T->set_var('postcard_link', $postcard_link);
            }
        }
    }
    PLG_templateSetVars('mediagallery', $T);
    $T->parse('output', 'page');
    $retval .= $T->finish($T->get_var('output'));
    if ($comments) {
        // glFusion Comment support
        $mid = $media[$mediaObject]['media_id'];
        if ($MG_albums[$aid]->enable_comments == 1) {
            USES_lib_comment();
            if ($MG_albums[$aid]->access == 3 || $MG_albums[0]->owner_id) {
                $delete_option = true;
            } else {
                $delete_option = false;
            }
            if (DB_count($_TABLES['comments'], 'sid', $mid) > 0 || $_MG_CONF['commentbar']) {
                $cid = $mid;
                $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0;
                if (isset($_POST['order'])) {
                    $comorder = $_POST['order'] == 'ASC' ? 'ASC' : 'DESC';
                } elseif (isset($_GET['order'])) {
                    $comorder = $_GET['order'] == 'ASC' ? 'ASC' : 'DESC';
                } else {
                    $comorder = '';
                }
                if (isset($_POST['mode'])) {
                    $commode = COM_applyFilter($_POST['mode']);
                } elseif (isset($_GET['mode'])) {
                    $commode = COM_applyFilter($_GET['mode']);
                } else {
                    $commode = '';
                }
                $valid_cmt_modes = array('flat', 'nested', 'nocomment', 'nobar');
                if (!in_array($commode, $valid_cmt_modes)) {
                    $commode = 'nested';
                }
                $commentbar = CMT_userComments($cid, $media[$mediaObject]['media_title'], 'mediagallery', $comorder, $commode, 0, $page, false, $delete_option, 0, $media[$mediaObject]['media_user_id']);
                $retval .= $commentbar;
            } else {
                $retval .= ' <center><a href="' . $_CONF['site_url'] . '/comment.php?sid=' . $mid . '&amp;title=' . $title . '&amp;pid=0&amp;type=mediagallery' . '">' . $LANG01[60] . '</a></center>';
            }
        }
    }
    return array(strip_tags($media[$mediaObject]['media_title']), $retval, '', $aid);
}
示例#9
0
/**
* Global album attribute editor
*
* @return   string              HTML
*
**/
function MG_globalAlbumAttributeEditor($adminMenu = 0)
{
    global $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $REMOTE_ADDR;
    global $MG_albums, $album_jumpbox;
    $retval = '';
    $valid_albums = 0;
    if (!SEC_hasRights('mediagallery.admin')) {
        $display .= COM_startBlock('', '', COM_getBlockTemplate('_admin_block', 'header'));
        $T = new Template($_MG_CONF['template_path']);
        $T->set_file('admin', 'error.thtml');
        $T->set_var('site_url', $_CONF['site_url']);
        $T->set_var('site_admin_url', $_CONF['site_admin_url']);
        $T->set_var('errormessage', $LANG_MG00['access_denied_msg']);
        $T->parse('output', 'admin');
        $display .= $T->finish($T->get_var('output'));
        $display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
        $display .= MG_siteFooter();
        return $display;
    }
    $T = new Template(MG_getTemplatePath(0));
    $T->set_var('site_url', $_CONF['site_url']);
    $T->set_var('site_admin_url', $_CONF['site_admin_url']);
    $A['enable_slideshow'] = 0;
    $A['enable_random'] = 0;
    $A['enable_shutterfly'] = 0;
    $A['enable_views'] = 0;
    $A['enable_keywords'] = 0;
    $A['enable_sort'] = 0;
    $A['enable_rating'] = 0;
    $A['albums_first'] = 0;
    $A['tn_size'] = 1;
    $A['display_rows'] = 3;
    $A['display_columns'] = 3;
    $A['full_display'] = 0;
    $A['enable_album_views'] = 0;
    $A['allow_download'] = 0;
    $A['display_album_desc'] = 0;
    $A['filename_title'] = 0;
    $A['podcast'] = 0;
    $A['mp3ribbon'] = 0;
    $A['rsschildren'] = 1;
    $A['skin'] = '';
    $retval .= COM_startBlock($LANG_MG01['global_attr_editor'], '', COM_getBlockTemplate('_admin_block', 'header'));
    $T->set_file(array('admin' => 'global_album_attr.thtml'));
    // build exif select box...
    $exif_select = '<select name="enable_exif">';
    $exif_select .= '<option value="0">' . $LANG_MG01['disable_exif'] . '</option>';
    $exif_select .= '<option value="1">' . $LANG_MG01['display_below_media'] . '</option>';
    $exif_select .= '<option value="2">' . $LANG_MG01['display_in_popup'] . '</option>';
    $exif_select .= '<option value="3">' . $LANG_MG01['both'] . '</option>';
    $exif_select .= '</select>';
    $full_select = '<select name="full_display">';
    $full_select .= '<option value="0"' . ($A['full_display'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['always'] . '</option>';
    $full_select .= '<option value="1"' . ($A['full_display'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['members_only'] . '</option>';
    $full_select .= '<option value="2"' . ($A['full_display'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $full_select .= '</select>';
    $ranking_select = '<select name="enable_rating">';
    $ranking_select .= '<option value="0"' . ($A['enable_rating'] == 0 ? 'selected="selected"' : '') . '>' . $LANG_MG01['disabled'] . '</option>';
    $ranking_select .= '<option value="1"' . ($A['enable_rating'] == 1 ? 'selected="selected"' : '') . '>' . $LANG_MG01['members_only'] . '</option>';
    $ranking_select .= '<option value="2"' . ($A['enable_rating'] == 2 ? 'selected="selected"' : '') . '>' . $LANG_MG01['always'] . '</option>';
    $ranking_select .= '</select>';
    $podcast_select = '<input type="checkbox" name="podcast" value="1" ' . ($A['podcast'] ? ' checked="checked"' : '') . '/>';
    $mp3ribbon_select = '<input type="checkbox" name="mp3ribbon" value="1" ' . ($A['mp3ribbon'] ? ' checked="checked"' : '') . '/>';
    $rsschildren_select = '<input type="checkbox" name="rsschildren" value="1" ' . ($A['rsschildren'] ? ' checked="checked"' : '') . '/>';
    $filename_title_select = '<input type="checkbox" name="filename_title" value="1" />';
    $comment_select = '<input type="checkbox" name="enable_comments" value="1" />';
    $ss_select = '<select name="enable_slideshow">';
    $ss_select .= '<option value="0">' . $LANG_MG01['disabled'] . '</option>';
    $ss_select .= '<option value="1">' . $LANG_MG01['js_slideshow'] . '</option>';
    $ss_select .= '<option value="2">' . $LANG_MG01['lightbox'] . '</option>';
    $ss_select .= '</select>';
    $ri_select = '<input type="checkbox" name="enable_random" value="1" />';
    $sf_select = '<input type="checkbox" name="enable_shutterfly" value="1" />';
    $views_select = '<input type="checkbox" name="enable_views" value="1" />';
    $keywords_select = '<input type="checkbox" name="enable_keywords" value="1" />';
    $sort_select = '<input type="checkbox" name="enable_sort" value="1" />';
    $afirst_select = '<input type="checkbox" name="albums_first" value="1" />';
    $album_views_select = '<input type="checkbox" name="enable_album_views" value="1" />';
    $tn_size_select = '<select name="tn_size">';
    $tn_size_select .= '<option value="0">' . $LANG_MG01['small'] . '</option>';
    $tn_size_select .= '<option value="1">' . $LANG_MG01['medium'] . '</option>';
    $tn_size_select .= '<option value="2">' . $LANG_MG01['large'] . '</option>';
    $tn_size_select .= '<option value="3">' . $LANG_MG01['custom'] . '</option>';
    $tn_size_select .= '<option value="4">' . $LANG_MG01['square'] . '</option>';
    $tn_size_select .= '</select>';
    $tnheight_input = '<input type="text" size="3" name="tnheight" value="" />';
    $tnwidth_input = '<input type="text" size="3" name="tnwidth" value="" />';
    $display_image_size_select = '<select name="display_image_size">';
    $display_image_size_select .= '<option value="0">' . $LANG_MG01['size_500x375'] . '</option>';
    $display_image_size_select .= '<option value="1">' . $LANG_MG01['size_600x450'] . '</option>';
    $display_image_size_select .= '<option value="2">' . $LANG_MG01['size_620x465'] . '</option>';
    $display_image_size_select .= '<option value="3">' . $LANG_MG01['size_720x540'] . '</option>';
    $display_image_size_select .= '<option value="4">' . $LANG_MG01['size_800x600'] . '</option>';
    $display_image_size_select .= '<option value="5">' . $LANG_MG01['size_912x684'] . '</option>';
    $display_image_size_select .= '<option value="6">' . $LANG_MG01['size_1024x768'] . '</option>';
    $display_image_size_select .= '<option value="7">' . $LANG_MG01['size_1152x864'] . '</option>';
    $display_image_size_select .= '<option value="8">' . $LANG_MG01['size_1280x1024'] . '</option>';
    $display_image_size_select .= '<option value="9">' . $LANG_MG01['size_custom'] . $_MG_CONF['custom_image_width'] . 'x' . $_MG_CONF['custom_image_height'] . '</option>';
    $display_image_size_select .= '</select>';
    $max_image_height_input = '<input type="text" size="4" name="max_image_height" value="0"' . '/>';
    $max_image_width_input = '<input type="text" size="4" name="max_image_width" value="0" />';
    $max_filesize_input = '<input type="text" size="10" name="max_filesize" value="0" />';
    $rows_input = '<input type="text" size="3" name="display_rows" value="' . $_MG_CONF['display_rows'] . '" />';
    $columns_input = '<input type="text" size="3" name="display_columns" value="' . $_MG_CONF['display_columns'] . '" />';
    $playback_type = '<select name="playback_type">';
    $playback_type .= '<option value="0">' . $LANG_MG01['play_in_popup'] . '</option>';
    $playback_type .= '<option value="1">' . $LANG_MG01['download_to_local'] . '</option>';
    $playback_type .= '<option value="2">' . $LANG_MG01['play_inline'] . '</option>';
    $playback_type .= '<option value="3">' . $LANG_MG01['use_mms'] . '</option>';
    $playback_type .= '</select>';
    $rss_select = '<input type="checkbox" name="enable_rss" value="1" />';
    $display_album_desc_select = '<input type="checkbox" name="display_album_desc" value="1" />';
    $postcard_select = '<select name="enable_postcard">';
    $postcard_select .= '<option value="0">' . $LANG_MG01['disabled'] . '</option>';
    $postcard_select .= '<option value="1">' . $LANG_MG01['members_only'] . '</option>';
    $postcard_select .= '<option value="2">' . $LANG_MG01['all_users'] . '</option>';
    $postcard_select .= '</select>';
    $allow_download_select = '<input type="checkbox" name="allow_download" value="1" />';
    // build album list for starting point...
    $album_jumpbox = '<select name="startaid">';
    $album_jumpbox .= '<option value="0">------</option>';
    $valid_albums += $MG_albums[0]->buildJumpBox(0, 3);
    $album_jumpbox .= '</select>';
    $frames = new mgFrame();
    $skins = array();
    $skins = $frames->getFrames();
    $skin_select = '<select name="skin">';
    $askin_select = '<select name="askin">';
    $dskin_select = '<select name="dskin">';
    for ($i = 0; $i < count($skins); $i++) {
        $skin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($_MG_CONF['ad_image_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
        $askin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($_MG_CONF['ad_album_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
        $dskin_select .= '<option value="' . $skins[$i]['dir'] . '"' . ($_MG_CONF['ad_display_skin'] == $skins[$i]['dir'] ? ' selected="selected" ' : '') . '>' . $skins[$i]['name'] . '</option>';
    }
    $skin_select .= '</select>';
    $askin_select .= '</select>';
    $dskin_select .= '</select>';
    $themes = MG_getThemes();
    $album_theme_select = '<select name="album_theme">';
    for ($i = 0; $i < count($themes); $i++) {
        $album_theme_select .= '<option value="' . $themes[$i] . '"' . ($A['skin'] == $themes[$i] ? 'selected="selected"' : '') . '>' . $themes[$i] . '</option>';
    }
    $album_theme_select .= '</select>';
    $T->set_var(array('action' => 'globalattr', 'album_list' => $album_jumpbox, 'display_image_size_select' => $display_image_size_select, 'max_image_height_input' => $max_image_height_input, 'max_image_width_input' => $max_image_width_input, 'max_filesize_input' => $max_filesize_input, 'comment_select' => $comment_select, 'exif_select' => $exif_select, 'ranking_select' => $ranking_select, 'podcast_select' => $podcast_select, 'mp3ribbon_select' => $mp3ribbon_select, 'rsschildren_select' => $rsschildren_select, 'ss_select' => $ss_select, 'full_select' => $full_select, 'ri_select' => $ri_select, 'sf_select' => $sf_select, 'rss_select' => $rss_select, 'postcard_select' => $postcard_select, 'views_select' => $views_select, 'keywords_select' => $keywords_select, 'album_theme_select' => $album_theme_select, 'display_album_desc_select' => $display_album_desc_select, 'album_views_select' => $album_views_select, 'sort_select' => $sort_select, 'afirst_select' => $afirst_select, 'tn_size_select' => $tn_size_select, 'tnheight_input' => $tnheight_input, 'tnwidth_input' => $tnwidth_input, 'rows_input' => $rows_input, 'height_input' => $max_image_height_input, 'width_input' => $max_image_width_input, 'max_size_input' => $max_filesize_input, 'columns_input' => $columns_input, 'playback_type' => $playback_type, 'admin_menu' => $adminMenu, 'allow_download_select' => $allow_download_select, 'filename_title_select' => $filename_title_select, 'skin_select' => $skin_select, 'askin_select' => $askin_select, 'dskin_select' => $dskin_select, 'lang_image_skin' => $LANG_MG01['image_skin'], 'lang_album_skin' => $LANG_MG01['album_skin'], 'lang_display_skin' => $LANG_MG01['display_skin'], 'lang_jpg' => $LANG_MG01['jpg'], 'lang_png' => $LANG_MG01['png'], 'lang_tif' => $LANG_MG01['tif'], 'lang_gif' => $LANG_MG01['gif'], 'lang_bmp' => $LANG_MG01['bmp'], 'lang_tga' => $LANG_MG01['tga'], 'lang_psd' => $LANG_MG01['psd'], 'lang_mp3' => $LANG_MG01['mp3'], 'lang_ogg' => $LANG_MG01['ogg'], 'lang_asf' => $LANG_MG01['asf'], 'lang_swf' => $LANG_MG01['swf'], 'lang_mov' => $LANG_MG01['mov'], 'lang_mp4' => $LANG_MG01['mp4'], 'lang_mpg' => $LANG_MG01['mpg'], 'lang_zip' => $LANG_MG01['zip'], 'lang_flv' => $LANG_MG01['flv'], 'lang_rflv' => $LANG_MG01['rflv'], 'lang_emb' => $LANG_MG01['emb'], 'lang_other' => $LANG_MG01['other'], 'lang_allowed_formats' => $LANG_MG01['allowed_media_formats'], 'lang_image' => $LANG_MG01['image'], 'lang_audio' => $LANG_MG01['audio'], 'lang_video' => $LANG_MG01['video'], 'lang_save' => $LANG_MG01['save'], 'lang_edit_title' => $LANG_MG01['edit_album'], 's_form_action' => $_MG_CONF['site_url'] . '/admin.php', 'lang_album_edit_help' => $LANG_MG01['album_edit_help'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_comments' => $LANG_MG01['comments_prompt'], 'lang_enable_exif' => $LANG_MG01['enable_exif'], 'lang_enable_ratings' => $LANG_MG01['enable_ratings'], 'lang_ss_enable' => $LANG_MG01['ss_enable'], 'lang_ri_enable' => $LANG_MG01['ri_enable'], 'lang_sf_enable' => $LANG_MG01['sf_enable'], 'lang_tn_size' => $LANG_MG01['tn_size'], 'lang_rows' => $LANG_MG01['rows'], 'lang_columns' => $LANG_MG01['columns'], 'lang_av_play_album' => $LANG_MG01['av_play_album'], 'lang_av_play_options' => $LANG_MG01['av_play_options'], 'lang_album_attributes' => $LANG_MG01['album_attributes'], 'lang_global_attr_help' => $LANG_MG01['global_attr_help'], 'lang_value' => $LANG_MG01['value'], 'lang_attribute' => $LANG_MG01['attribute'], 'lang_update' => $LANG_MG01['update'], 'lang_enable_views' => $LANG_MG01['enable_views'], 'lang_enable_keywords' => $LANG_MG01['enable_keywords'], 'lang_enable_album_views' => $LANG_MG01['enable_album_views'], 'lang_enable_sort' => $LANG_MG01['enable_sort'], 'lang_albums_first' => $LANG_MG01['albums_first'], 'lang_full_display' => $LANG_MG01['full_display'], 'lang_max_image_height' => $LANG_MG01['max_image_height'], 'lang_max_image_width' => $LANG_MG01['max_image_width'], 'lang_max_filesize' => $LANG_MG01['max_filesize'], 'lang_display_image_size' => $LANG_MG01['display_image_size'], 'lang_starting_album' => $LANG_MG01['starting_album'], 'lang_enable_rss' => $LANG_MG01['enable_rss'], 'lang_enable_postcard' => $LANG_MG01['enable_postcard'], 'lang_allow_download' => $LANG_MG01['allow_download'], 'lang_display_album_desc' => $LANG_MG01['display_album_desc'], 'lang_filename_title' => $LANG_MG01['filename_title'], 'lang_theme_select' => $LANG_MG01['album_theme'], 'lang_podcast' => $LANG_MG01['podcast'], 'lang_mp3ribbon' => $LANG_MG01['mp3ribbon'], 'lang_rsschildren' => $LANG_MG01['rsschildren'], 'lang_tnheight' => $LANG_MG01['tn_height'], 'lang_tnwidth' => $LANG_MG01['tn_width']));
    $T->parse('output', 'admin');
    $retval .= $T->finish($T->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}