Beispiel #1
0
function MG_rebuildThumbConfirm()
{
    global $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01;
    $retval = '';
    $B = new Template($_MG_CONF['template_path']);
    $B->set_file('admin', 'thumbs.thtml');
    $B->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_CONF['site_url'], 'xhtml' => XHTML, 'lang_title' => $LANG_MG01['rebuild_thumb'], 's_form_action' => $_MG_CONF['admin_url'] . 'maint.php?mode=thumbs&step=two', 'lang_next' => $LANG_MG01['next'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_help' => $LANG_MG01['rebuild_thumb_help'], 'lang_details' => $LANG_MG01['rebuild_thumb_details']));
    $T = new Template($_MG_CONF['template_path']);
    $T->set_file('admin', 'administration.thtml');
    $T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'xhtml' => XHTML, 'admin_body' => $B->finish($B->parse('output', 'admin')), 'title' => $LANG_MG01['rebuild_thumb'], 'lang_admin' => $LANG_MG00['admin'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"' . XHTML . '>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Rebuild_Thumbs'));
    $retval .= $T->finish($T->parse('output', 'admin'));
    return $retval;
}
Beispiel #2
0
    }
    DB_query("UPDATE {$_TABLES['mg_exif_tags']} set selected=0");
    // resets all to 0
    for ($i = 0; $i < $numItems; $i++) {
        $sql = "UPDATE {$_TABLES['mg_exif_tags']} set selected=1 WHERE name='" . DB_escapeString($exif[$i]['sel']) . "'";
        DB_query($sql);
    }
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php?msg=3');
    exit;
}
$T = new Template($_MG_CONF['template_path'] . '/admin/');
$T->set_file(array('admin' => 'administration.thtml'));
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'mg_navigation' => MG_navigation(), 'lang_admin' => $LANG_MG00['admin'], 'version' => $_MG_CONF['pi_version']));
/* --- Main Processing Here --- */
if (!isset($_POST['mode'])) {
    $T->set_var(array('admin_body' => MG_adminEXIF(), 'title' => $LANG_MG01['exif_admin_header'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"/>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#EXIFIPTC_Administration'));
} else {
    $mode = COM_applyFilter($_POST['mode']);
    switch ($mode) {
        case $LANG_MG01['save']:
            MG_adminEXIFsave();
            break;
        case $LANG_MG01['cancel']:
            echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
            break;
        default:
            echo COM_refresh($_MG_CONF['admin_url'] . 'index.php?msg=3');
            break;
    }
}
$T->parse('output', 'admin');
Beispiel #3
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);
}
Beispiel #4
0
* Main
*/
$display = '';
$mode = '';
if (isset($_POST['save'])) {
    $mode = 'save';
}
if (isset($_POST['cancel'])) {
    $mode = 'cancel';
}
$T = new Template($_MG_CONF['template_path'] . '/admin');
$T->set_file('admin', 'administration.thtml');
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'mg_navigation' => MG_navigation(), 'lang_admin' => $LANG_MG00['admin'], 'version' => $_MG_CONF['pi_version']));
if ($mode == 'save' && SEC_checkToken()) {
    $T->set_var(array('admin_body' => MG_saveConfig(), 'mg_navigation' => MG_navigation()));
} elseif ($mode == 'cancel') {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} elseif ($mode == $LANG_MG01['continue']) {
    COM_setMessage(2);
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    $T->set_var(array('admin_body' => MG_editConfig(), 'title' => $LANG_MG01['system_options'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?" />', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#System_Options'));
}
$T->parse('output', 'admin');
$display = COM_siteHeader('menu', '');
$display .= $T->finish($T->get_var('output'));
$display .= COM_siteFooter();
echo $display;
exit;
Beispiel #5
0
        MG_updateQuotaUsage($row['album_id']);
    }
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php?msg=16');
    exit;
}
$mode = '';
if (isset($_POST['mode'])) {
    $mode = COM_applyFilter($_POST['mode']);
} else {
    if (isset($_GET['mode'])) {
        $mode = COM_applyFilter($_GET['mode']);
    }
}
$T = new Template($_MG_CONF['template_path']);
$T->set_file('admin', 'administration.thtml');
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'lang_admin' => $LANG_MG00['admin'], 'xhtml' => XHTML));
if ($mode == $LANG_MG01['save'] && !empty($LANG_MG01['save'])) {
    MG_rebuildQuota();
} elseif ($mode == $LANG_MG01['cancel']) {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    $T->set_var(array('admin_body' => MG_quotaConfirm(), 'title' => $LANG_MG01['rebuild_quota'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" border="0" alt="?">', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Rebuild_User_Quota'));
}
$T->parse('output', 'admin');
$display = COM_startBlock($LANG_MG00['admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
$display .= MG_showAdminMenu('batch_sessions');
$display .= $T->finish($T->get_var('output'));
$display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
$display = COM_createHTMLDocument($display);
COM_output($display);
Beispiel #6
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;
}
Beispiel #7
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;
}
Beispiel #8
0
}
/**
* Main
*/
$display = '';
$mode = '';
if (isset($_POST['mode'])) {
    $mode = COM_applyFilter($_POST['mode']);
} else {
    if (isset($_GET['mode'])) {
        $mode = COM_applyFilter($_GET['mode']);
    }
}
$T = new Template($_MG_CONF['template_path'] . '/admin');
$T->set_file(array('admin' => 'administration.thtml'));
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'mg_navigation' => MG_navigation(), 'lang_admin' => $LANG_MG00['admin'], 'version' => $_MG_CONF['pi_version']));
if ($mode == $LANG_MG01['save'] && !empty($LANG_MG01['save'])) {
    // save the config
    $T->set_var(array('admin_body' => MG_saveMemberDefaults()));
} elseif ($mode == $LANG_MG01['cancel']) {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    $T->set_var(array('admin_body' => MG_editMemberDefaults(), 'title' => $LANG_MG01['member_album_options'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"' . '/>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Member_Album_Options'));
}
$T->parse('output', 'admin');
$display = COM_siteHeader('menu', '');
$display .= $T->finish($T->get_var('output'));
$display .= COM_siteFooter();
echo $display;
exit;
Beispiel #9
0
}
$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=" . intval($owner_id));
$album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update);
$T = new Template(MG_getTemplatePath($album_id));
$T->set_file(array('page' => 'album_page.thtml', 'noitems' => 'album_page_noitems.thtml'));
SESS_setVar('mediagallery.album.page', $page + 1);
$T->set_var(array('site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'birdseed_ul' => $birdseedUL, 'album_title' => PLG_replaceTags($MG_albums[$album_id]->title, 'mediagallery', 'album_title'), 'url_slideshow' => $url_slideshow, 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&amp;sort=' . $sortOrder, $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&amp;sort=' . $sortOrder, $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_jumpbox_raw' => $album_jumpbox_raw, 'album_id' => $album_id, 'lbslideshow' => $lbSlideShow, 'album_description' => $MG_albums[$album_id]->display_album_desc ? PLG_replaceTags($MG_albums[$album_id]->description, 'mediagallery', 'album_description') : '', 'album_id_display' => $MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'lang_slideshow' => $lang_slideshow, 'select_adminbox' => $admin_box, 'admin_box_items' => $admin_box_items, 'admin_menu' => $admin_menu, 'select_sortbox' => $sort_box, 'select_sortbox_raw' => $sort_box_raw, 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $MG_albums[$album_id]->getMediaCount(), 'lang_search' => $LANG_MG01['search']));
if ($MG_albums[$album_id]->enable_rss) {
    $rssfeedname = sprintf($_MG_CONF['rss_feed_name'] . "%06d", $album_id);
    $feedUrl = MG_getFeedUrl($rssfeedname . '.rss');
    $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">';
    $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" style="border:none;" alt=""/></a>';
    $T->set_var('rsslink', $rsslink);
} else {
    $T->set_var('rsslink', '');
}
$subscribe = '';
if (!COM_isAnonUser()) {
    if (PLG_isSubscribed('mediagallery', '', $album_id, $_USER['uid'])) {
        $subscribe = '<a class="subscribelink" href="' . $_MG_CONF['site_url'] . '/subscription.php?op=unsubscribe&amp;sid=' . $album_id . '">' . $LANG01['unsubscribe'] . '</a>';
        $subscribe_url = $_MG_CONF['site_url'] . '/subscription.php?op=unsubscribe&amp;sid=' . $album_id;
        $subscribe_text = $LANG01['unsubscribe'];
    } else {
        $subscribe = '<a class="subscribelink" href="' . $_MG_CONF['site_url'] . '/subscription.php?op=subscribe&amp;sid=' . $album_id . '">' . $LANG01['subscribe'] . '</a>';
        $subscribe_url = $_MG_CONF['site_url'] . '/subscription.php?op=subscribe&amp;sid=' . $album_id;
        $subscribe_text = $LANG01['subscribe'];
    }
Beispiel #10
0
function MG_autotags($op, $content = '', $autotag = '')
{
    global $_MG_CONF, $_CONF, $_TABLES, $LANG_MG00, $LANG_MG03, $side_count, $swfjsinclude;
    //@@@@@20120730add---->
    $p1 = COM_applyFilter($autotag['parm1']);
    $p2 = COM_applyFilter($autotag['parm2']);
    $p = MG_parm2($p2);
    //@@@@@20120730add<----
    static $ss_count = 0;
    /*
     * Process the auto tag to remove any embedded &nbsp;
     */
    $tag = str_replace('&nbsp;', ' ', $autotag['tagstr']);
    $parms = explode(' ', $tag);
    // Extra test to see if autotag was entered with a space
    // after the module name
    if (substr($parms[0], -1) == ':') {
        $startpos = strlen($parms[0]) + strlen($parms[1]) + 2;
        $label = str_replace(']', '', substr($tag, $startpos));
        $tagid = $parms[1];
    } else {
        $label = str_replace(']', '', substr($tag, strlen($parms[0]) + 1));
        $parms = explode(':', $parms[0]);
        if (count($parms) > 2) {
            // whoops, there was a ':' in the tag id ...
            array_shift($parms);
            $tagid = implode(':', $parms);
        } else {
            $tagid = $parms[1];
        }
    }
    $autotag['parm1'] = str_replace(']', '', $tagid);
    $autotag['parm2'] = $label;
    /*
     * end of tag replacement
     */
    // see if we have an alignment option included
    $caption = $autotag['parm2'];
    $aSet = 0;
    $skip = 0;
    // default values for parameters
    $border = $_MG_CONF['at_border'];
    $align = $_MG_CONF['at_align'];
    $width = $_MG_CONF['at_width'];
    $height = $_MG_CONF['at_height'];
    $src = $_MG_CONF['at_src'];
    $autoplay = $_MG_CONF['at_autoplay'];
    $enable_link = $_MG_CONF['at_enable_link'];
    $delay = $_MG_CONF['at_delay'];
    $transition = 'Fade';
    $showtitle = $_MG_CONF['at_showtitle'];
    $destination = 'content';
    $target = '';
    $linkID = 0;
    $alt = 0;
    $link_src = 'disp';
    if ($align != '') {
        $aSet = 1;
    }
    // parameter processing - logic borrowed from
    // Dirk Haun's Flickr plugin
    $px = explode(' ', trim($autotag['parm2']));
    if (is_array($px)) {
        foreach ($px as $part) {
            if (substr($part, 0, 6) == 'width:') {
                $a = explode(':', $part);
                $width = $a[1];
                $skip++;
            } elseif (substr($part, 0, 7) == 'height:') {
                $a = explode(':', $part);
                $height = $a[1];
                $skip++;
            } elseif (substr($part, 0, 7) == 'border:') {
                $a = explode(':', $part);
                $border = $a[1];
                $skip++;
            } elseif (substr($part, 0, 6) == 'align:') {
                $a = explode(':', $part);
                $align = $a[1];
                $skip++;
                $aSet = 1;
            } elseif (substr($part, 0, 4) == 'src:') {
                $a = explode(':', $part);
                $src = $a[1];
                $skip++;
            } elseif (substr($part, 0, 9) == 'autoplay:') {
                $a = explode(':', $part);
                $autoplay = $a[1];
                $skip++;
            } elseif (substr($part, 0, 5) == 'link:') {
                $a = explode(':', $part);
                $enable_link = $a[1];
                $skip++;
            } elseif (substr($part, 0, 6) == 'delay:') {
                $a = explode(':', $part);
                $delay = $a[1];
                $skip++;
            } elseif (substr($part, 0, 11) == 'transition:') {
                $a = explode(':', $part);
                $transition = $a[1];
                $skip++;
            } elseif (substr($part, 0, 6) == 'title:') {
                $a = explode(':', $part);
                $showtitle = $a[1];
                $skip++;
            } elseif (substr($part, 0, 5) == 'dest:') {
                $a = explode(':', $part);
                $destination = $a[1];
                if ($destination != 'content' && $destination != 'block') {
                    $destination = 'content';
                }
                $skip++;
            } elseif (substr($part, 0, 7) == 'linkid:') {
                $a = explode(':', $part);
                $linkID = $a[1];
                $skip++;
            } elseif (substr($part, 0, 4) == 'alt:') {
                $a = explode(':', $part);
                $alt = $a[1];
                $skip++;
            } elseif (substr($part, 0, 7) == 'target:') {
                $a = explode(':', $part);
                $target = $a[1];
                $skip++;
            } elseif (substr($part, 0, 5) == 'type:') {
                $a = explode(':', $part);
                $mp3_type = $a[1];
                $skip++;
            } elseif (substr($part, 0, 8) == 'linksrc:') {
                $a = explode(':', $part);
                $link_src = $a[1];
                if (!in_array($link_src, array('tn', 'disp', 'orig'))) {
                    $link_src = 'disp';
                }
                $skip++;
            } else {
                break;
            }
        }
        if ($skip != 0) {
            $caption = '';
            if (count($px) > $skip) {
                for ($i = 0; $i < $skip; $i++) {
                    array_shift($px);
                }
                $caption = trim(implode(' ', $px));
            }
        }
    } else {
        $caption = trim($autotag['parm2']);
    }
    if (!is_numeric($autotag['parm1'][0])) {
        switch ($autotag['parm1'][0]) {
            case 'n':
                $align = '';
                $aSet = 1;
                break;
            case 'c':
                $align = 'center';
                $aSet = 1;
                break;
            case 'l':
                $align = 'left';
                $aSet = 1;
                break;
            case 'r':
                $align = 'right';
                $aSet = 1;
                break;
            case 'a':
                $align = !($side_count % 2) ? 'left' : 'right';
                $side_count++;
                $aSet = 1;
                break;
            default:
                $align = 'left';
                $side_count++;
                break;
        }
        $parm1 = COM_applyFilter(substr($autotag['parm1'], 1, strlen($autotag['parm1']) - 1));
    } else {
        $parm1 = COM_applyFilter($autotag['parm1']);
        if ($aSet == 0 || $align == 'auto') {
            $align = !($side_count % 2) ? 'left' : 'right';
            $side_count++;
        }
    }
    if ($align == 'none') {
        $align = '';
    }
    // sanity check incase the album has been deleted or something...
    if (!in_array($autotag['tag'], array('media', 'image', 'video', 'audio', 'download', 'oimage', 'img', 'mlink', 'alink', 'playall'))) {
        if (DB_count($_TABLES['mg_albums'], 'album_id', intval($parm1)) == 0) {
            return str_replace($autotag['tagstr'], '', $content);
        }
    }
    $ss_count = mt_rand(0, 32768);
    switch ($autotag['tag']) {
        case 'download':
            $side_count--;
            $sql = "SELECT ma.album_id " . "FROM {$_TABLES['mg_media']} AS m " . "LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id " . "WHERE m.media_id='" . addslashes($parm1) . "'";
            $result = DB_query($sql);
            if (DB_numRows($result) <= 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            $row = DB_fetchArray($result);
            $album_data = MG_getAlbumData($row['album_id'], array('album_id'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            $link = '<a href="' . $_MG_CONF['site_url'] . '/download.php?mid=' . $parm1 . '">' . ($caption != '' ? $caption : 'download') . '</a>';
            break;
        case 'mlink':
            $side_count--;
            $sql = "SELECT m.remote_url,ma.album_id " . "FROM {$_TABLES['mg_media']} AS m " . "LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id " . "WHERE m.media_id='" . addslashes($parm1) . "'";
            $result = DB_query($sql);
            if (DB_numRows($result) <= 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            $row = DB_fetchArray($result);
            $album_data = MG_getAlbumData($row['album_id'], array('album_id'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            if ($alt == 1 && $row['remote_url'] != '') {
                $href = $row['remote_url'];
            } else {
                $href = $_MG_CONF['site_url'] . '/media.php?f=0&amp;sort=0&amp;s=' . $parm1;
            }
            $link = '<a href="' . $href . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . ($caption != '' ? $caption : $LANG_MG03['click_here']) . '</a>';
            break;
        case 'playall':
            $album_data = MG_getAlbumData($parm1, array('album_id'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0 || COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            $V = COM_newTemplate(MG_getTemplatePath(0));
            $V->set_file('xspf', 'xspf_radio.thtml');
            $V->set_var(array('aid' => $parm1, 'site_url' => $_MG_CONF['site_url'], 'autoplay' => $autoplay ? 'play' : 'stop', 'id' => 'mp3radio' . rand(), 'id2' => 'mp3radio' . rand(), 'xhtml' => XHTML));
            $media = $V->finish($V->parse('output', 'xspf'));
            $link = MG_helper_getContainer($media, $align, 'span');
            break;
        case 'video':
            $sql = "SELECT ma.album_id,m.media_id,m.mime_type,m.remote_url,m.media_filename," . "m.media_mime_ext,m.media_original_filename,m.media_tn_attached," . "m.media_resolution_x,m.media_resolution_y,m.remote_media " . "FROM {$_TABLES['mg_media']} AS m " . "LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id " . "WHERE m.media_id='" . addslashes($parm1) . "'";
            $result = DB_query($sql);
            if (DB_numRows($result) <= 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            $row = DB_fetchArray($result);
            $album_data = MG_getAlbumData($row['album_id'], array('album_id'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            $orig_media_url = $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
            // determine height / width and aspect
            if ($width === 'auto' && $row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0) {
                $videoheight = $row['media_resolution_y'];
                $videowidth = $row['media_resolution_x'];
            } else {
                $ratio = 0.75;
                $orientation = 0;
                if ($row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0) {
                    if ($row['media_resolution_x'] >= $row['media_resolution_y']) {
                        // landscape
                        $ratio = $row['media_resolution_y'] / $row['media_resolution_x'];
                    } else {
                        // portrait
                        $ratio = $row['media_resolution_x'] / $row['media_resolution_y'];
                        $orientation = 1;
                    }
                }
                if ($orientation == 0) {
                    if ($width > 0 && $height == 0) {
                        $videoheight = round($width * $ratio);
                        $videowidth = $width;
                    } else {
                        if ($width == 0 && $height == 0) {
                            $videoheight = 200 * $ratio;
                            $videowidth = 200;
                        } else {
                            if ($width == 0 && $height > 0) {
                                $videowidth = round($height / $ratio);
                                $videoheight = $height;
                            } else {
                                if ($width > 0 && $height > 0) {
                                    $videowidth = $width;
                                    $videoheight = $height;
                                }
                            }
                        }
                    }
                } else {
                    if ($width > 0 && $height == 0) {
                        $videoheight = round($width / $ratio);
                        $videowidth = $width;
                    } else {
                        if ($width == 0 && $height == 0) {
                            $videoheight = 200;
                            $videowidth = round(200 / $ratio);
                        } else {
                            if ($width == 0 && $height > 0) {
                                $videowidth = round($height * $ratio);
                                $videoheight = $height;
                            } else {
                                if ($width > 0 && $height > 0) {
                                    $videowidth = $width;
                                    $videoheight = $height;
                                }
                            }
                        }
                    }
                }
            }
            switch ($row['mime_type']) {
                case 'embed':
                    $media = $row['remote_url'];
                    break;
                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':
                    $V = COM_newTemplate(MG_getTemplatePath(0));
                    $V->set_file('video', 'view_asf.thtml');
                    $V->set_var(array('autostart' => $autoplay ? 'true' : 'false', 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'false', 'showcontrols' => 'true', 'showdisplay' => 'false', 'height' => $videoheight, 'width' => $videowidth, 'bgcolor' => '#FFFFFF', 'playcount' => '9999', 'loop' => 'true', 'movie' => $orig_media_url, 'autostart0' => $autoplay ? '1' : '0', 'enablecontextmenu0' => '1', 'stretchtofit0' => '0', 'showstatusbar0' => '0', 'uimode0' => 'none', 'showcontrols0' => '1', 'showdisplay0' => '0', 'xhtml' => XHTML));
                    $media = $V->finish($V->parse('output', 'video'));
                    break;
                case 'video/mpeg':
                case 'video/x-motion-jpeg':
                case 'video/quicktime':
                case 'video/mpeg':
                case 'video/x-mpeg':
                case 'video/x-mpeq2a':
                case 'video/x-qtc':
                case 'video/x-m4v':
                    $V = COM_newTemplate(MG_getTemplatePath(0));
                    $V->set_file('video', 'view_quicktime.thtml');
                    $V->set_var(array('autoref' => 'true', 'autoplay' => $autoplay ? 'true' : 'false', 'controller' => 'true', 'kioskmode' => 'true', 'scale' => 'aspect', 'height' => $videoheight, 'width' => $videowidth, 'bgcolor' => '#F0F0F0', 'loop' => 'true', 'movie' => $orig_media_url, 'xhtml' => XHTML));
                    $media = $V->finish($V->parse('output', 'video'));
                    break;
                case 'application/x-shockwave-flash':
                    // 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='" . $row['media_id'] . "'");
                    while ($poRow = DB_fetchArray($poResult)) {
                        $playback_options[$poRow['option_name']] = $poRow['option_value'];
                    }
                    if ($swfjsinclude > 0) {
                        $link = '';
                    } else {
                        $S = COM_newTemplate(MG_getTemplatePath(0));
                        $S->set_file('swf', 'swfobject.thtml');
                        $S->set_var('site_url', $_MG_CONF['site_url']);
                        $link = $S->finish($S->parse('output', 'swf'));
                        $swfjsinclude++;
                    }
                    $V = COM_newTemplate(MG_getTemplatePath(0));
                    $V->set_file('video', 'view_swf.thtml');
                    $V->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'play' => $autoplay ? 'true' : 'false', 'menu' => $playback_options['menu'] ? 'true' : 'false', 'loop' => $playback_options['loop'] ? 'true' : 'false', 'scale' => $playback_options['scale'], 'wmode' => $playback_options['wmode'], 'flashvars' => $playback_options['flashvars'], 'quality' => $playback_options['quality'], 'height' => $videoheight, 'width' => $videowidth, 'asa' => $playback_options['allowscriptaccess'], 'bgcolor' => $playback_options['bgcolor'], 'swf_version' => $playback_options['swf_version'], 'filename' => $row['media_original_filename'], 'id' => $row['media_filename'] . rand(), 'id2' => $row['media_filename'] . rand(), 'movie' => $orig_media_url, 'xhtml' => XHTML));
                    $media = $V->finish($V->parse('output', 'video'));
                    break;
                case 'video/x-flv':
                    // 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='" . $row['media_id'] . "'");
                    while ($poRow = DB_fetchArray($poResult)) {
                        $playback_options[$poRow['option_name']] = $poRow['option_value'];
                    }
                    if ($swfjsinclude > 0) {
                        $link = '';
                    } else {
                        $S = COM_newTemplate(MG_getTemplatePath(0));
                        $S->set_file('swf', 'swfobject.thtml');
                        $S->set_var('site_url', $_MG_CONF['site_url']);
                        $link = $S->finish($S->parse('output', 'swf'));
                        $swfjsinclude++;
                    }
                    // now the player specific items.
                    if ($autoplay == 1) {
                        // auto start
                        $playButton = '';
                    } else {
                        if ($row['media_tn_attached'] == 1) {
                            $tfn = 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'];
                            $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $tfn);
                            $playImage = $_MG_CONF['mediaobjects_url'] . '/' . $tfn . $ext;
                        } else {
                            $playImage = MG_getImageFile('blank_blk.jpg');
                        }
                        $playButton = "{ url: '" . $playImage . "', overlayId: 'play' },";
                    }
                    if ($row['remote_media'] == 1) {
                        $urlParts = array();
                        $urlParts = parse_url($row['remote_url']);
                        $pathParts = array();
                        $pathParts = explode('/', $urlParts['path']);
                        $ppCount = count($pathParts);
                        $pPath = '';
                        for ($row = 1; $row < $ppCount - 1; $row++) {
                            $pPath .= '/' . $pathParts[$row];
                        }
                        $videoFile = $pathParts[$ppCount - 1];
                        $pos = strrpos($videoFile, '.');
                        if ($pos === false) {
                            $basefilename = $videoFile;
                        } else {
                            $basefilename = substr($videoFile, 0, $pos);
                        }
                        $videoFile = $basefilename;
                        $streamingServerURL = "streamingServerURL: '" . $urlParts['scheme'] . '://' . $urlParts['host'] . $pPath . "',";
                        $streamingServer = "streamingServer: 'fms',";
                    } else {
                        $streamingServerURL = '';
                        $streamingServer = '';
                        $videoFile = urlencode($orig_media_url);
                    }
                    $width = $videowidth;
                    $height = $videoheight + 22;
                    $resolution_x = $videowidth;
                    $resolution_y = $videoheight;
                    $id = 'id_' . rand();
                    $id2 = 'id2_' . rand();
                    $F = COM_newTemplate(MG_getTemplatePath(0));
                    $F->set_file('player', 'flvfp.thtml');
                    $F->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'play' => $autoplay ? 'true' : 'false', 'menu' => $playback_options['menu'] ? 'true' : 'false', 'loop' => $playback_options['loop'] ? 'true' : 'false', 'scale' => $playback_options['scale'], 'wmode' => $playback_options['wmode'], 'width' => $width, 'height' => $height, 'streamingServerURL' => $streamingServerURL, 'streamingServer' => $streamingServer, 'videoFile' => $videoFile, 'playButton' => $playButton, 'id' => $id, 'id2' => $id2, 'resolution_x' => $resolution_x, 'resolution_y' => $resolution_y, 'xhtml' => XHTML));
                    $flv_player = $F->finish($F->parse('output', 'player'));
                    $V = COM_newTemplate(MG_getTemplatePath(0));
                    $V->set_file('video', 'view_flv_light.thtml');
                    $V->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'id' => $id, 'id2' => $id2, 'width' => $resolution_x, 'height' => $resolution_y, 'flv_player' => $flv_player, 'xhtml' => XHTML));
                    $media = $V->finish($V->parse('output', 'video'));
                    break;
            }
            $link = MG_helper_getContainer($media, $align, 'div');
            break;
        case 'audio':
            $sql = "SELECT ma.album_id,m.media_title,m.mime_type,m.media_tn_attached,m.media_filename,m.media_mime_ext " . "FROM {$_TABLES['mg_media']} AS m " . "LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id " . "WHERE m.media_id='" . addslashes($parm1) . "'";
            $result = DB_query($sql);
            if (DB_numRows($result) <= 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            $row = DB_fetchArray($result);
            $album_data = MG_getAlbumData($row['album_id'], array('album_id'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            $orig_media_url = $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
            switch ($row['mime_type']) {
                case 'audio/mpeg':
                    $playback_options['height'] = 50;
                    $playback_options['width'] = 200;
                    $u_pic = '';
                    if ($row['media_tn_attached'] == 1) {
                        $tfn = 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'];
                        $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $tfn);
                        $u_tn = $_MG_CONF['mediaobjects_url'] . '/' . $tfn . $ext;
                        $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . $tfn . $ext);
                        $border_width = $media_size_disp[0] + 12;
                        $u_pic = '<img src="' . $u_tn . '" alt="" style="border:none;vertical-align:bottom;"' . XHTML . '>';
                    }
                    $V = COM_newTemplate(MG_getTemplatePath(0));
                    $V->set_file('audio', $mp3_type == 'ribbon' ? 'mp3_podcast.thtml' : 'view_mp3_flv.thtml');
                    $V->set_var(array('autostart' => $autoplay ? 'play' : 'stop', 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'true', 'uimode' => 'mini', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => '#FFFFFF', 'loop' => 'true', 'u_pic' => $u_pic, 'title' => urlencode($row['media_title']), 'id' => 'mp3' . rand(), 'id2' => 'mp3' . rand(), 'site_url' => $_MG_CONF['site_url'], 'movie' => $orig_media_url, 'mp3_file' => $orig_media_url, 'xhtml' => XHTML));
                    $media = $V->finish($V->parse('output', 'audio'));
                    break;
                case 'audio/x-ms-wma':
                case 'audio/x-ms-wax':
                case 'audio/x-ms-wmv':
                    $playback_options['height'] = 50;
                    $playback_options['width'] = 200;
                    $u_pic = '';
                    if ($row['media_tn_attached'] == 1) {
                        $tfn = 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'];
                        $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $tfn);
                        $u_tn = $_MG_CONF['mediaobjects_url'] . '/' . $tfn . $ext;
                        $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . $tfn . $ext);
                        $border_width = $media_size_disp[0] + 12;
                        $u_pic = '<div class="out" style="width:' . $border_width . 'px"><div class="in ltin tpin"><img src="' . $u_tn . '" alt="" style="vertical-align:bottom;"' . XHTML . '></div></div>';
                    }
                    $V = COM_newTemplate(MG_getTemplatePath(0));
                    $V->set_file('audio', 'view_mp3_wmp.thtml');
                    $V->set_var(array('autostart' => $autoplay ? '1' : '0', 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'true', 'uimode' => 'mini', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => '#FFFFFF', 'loop' => 'true', 'u_pic' => $u_pic, 'movie' => $orig_media_url, 'xhtml' => XHTML));
                    $media = $V->finish($V->parse('output', 'audio'));
                    break;
            }
            $link = MG_helper_getContainer($media, $align, 'div');
            break;
        case 'fslideshow':
            if (empty($parm1)) {
                return $content;
            }
            $album_data = MG_getAlbumData($parm1, array('album_title', 'album_id', 'hidden'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            if ($width > 0 && $height == 0) {
                $height = $width * 0.75;
            } else {
                if ($width == 0 && $height == 0) {
                    $height = $width = 200;
                } else {
                    if ($width == 0 && $height > 0) {
                        $width = $height * 1.3333;
                    }
                }
            }
            // if none of the above, assume height and width both specified.
            if ($caption == '' && $_MG_CONF['autotag_caption'] && isset($parm1)) {
                $caption = $album_data['album_title'];
            }
            $captionHTML = '<br' . XHTML . '><span style="width:' . $width . 'px;font-style:italic;font-size: smaller;text-indent:0;">' . $caption . '</span>' . LB;
            $ss_count++;
            $T = COM_newTemplate(MG_getTemplatePath(0));
            $T->set_file('fslideshow', 'fsat.thtml');
            $T->set_var('site_url', $_MG_CONF['site_url']);
            $T->set_var(array('id' => 'mms' . $ss_count, 'id2' => 'fsid' . $ss_count, 'movie' => $_MG_CONF['site_url'] . '/xml.php?aid=' . $parm1 . '%26src=' . trim($src), 'dropshadow' => 'true', 'delay' => $delay, 'nolink' => $album_data['hidden'] || $enable_link == 0 ? 'true' : 'false', 'showtitle' => $showtitle == 'bottom' || $showtitle == 'top' ? '&showTitle=' . $showtitle : '', 'width' => $width, 'height' => $height, 'xhtml' => XHTML));
            $swfobject = $T->finish($T->parse('output', 'fslideshow'));
            $media = $swfobject . $captionHTML;
            /*
                        $style = '';
                        if ($align == 'center') {
                            $style = 'text-align:center;';
                        } else if ($align != '') {
                            $style = 'float:' . $align . ';';
                        }
                        $link = '<span style="' . $style . 'padding:5px;">' . $media . '</span>';
            */
            if ($align != '' && $align != "center") {
                $link = '<div style="float:' . $align . ';padding:5px;text-align:center;">' . $media . '</div>';
            } else {
                if ($align == 'center') {
                    $link = '<div style="padding:5px;text-align:center;">' . $media . '</div>';
                } else {
                    $link = '<div style="padding:5px;text-align:center;">' . $media . '</div>';
                }
            }
            break;
        case 'slideshow':
            if (empty($parm1)) {
                return $content;
            }
            $album_data = MG_getAlbumData($parm1, array('album_title', 'album_id', 'hidden'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            if ($caption == '' && $_MG_CONF['autotag_caption']) {
                $caption = $album_data['album_title'];
            }
            $aid = $parm1;
            $pics = '';
            $counter = 0;
            $maxwidth = 0;
            $maxheight = 0;
            $ss_count++;
            $sql = MG_buildMediaSql(array('album_id' => $aid, 'fields' => array('media_filename', 'media_mime_ext', 'remote_url'), 'where' => "m.media_type = 0 AND m.include_ss = 1"));
            $result = DB_query($sql);
            while ($row = DB_fetchArray($result)) {
                switch ($src) {
                    case 'orig':
                        $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']);
                        $ext = $row['media_mime_ext'];
                        break;
                    case 'disp':
                        $mfn = 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'];
                        $tnext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $mfn);
                        $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . $mfn . $tnext);
                        $ext = substr($tnext, 1, 3);
                        // no use ?
                        break;
                    default:
                        $mfn = 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'];
                        $tnext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $mfn);
                        $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . $mfn . $tnext);
                        $ext = substr($tnext, 1, 3);
                        // no use ?
                        $src = 'tn';
                        break;
                }
                if ($media_size == false) {
                    continue;
                }
                $counter++;
                if ($width > 0 && $height == 0) {
                    if ($media_size[0] > $media_size[1]) {
                        // landscape
                        $ratio = $media_size[0] / $width;
                        $newwidth = $width;
                        $newheight = round($media_size[1] / $ratio);
                    } else {
                        // portrait
                        $ratio = $media_size[1] / $width;
                        $newheight = $width;
                        $newwidth = round($media_size[0] / $ratio);
                    }
                } else {
                    if ($width == 0 && $height == 0) {
                        if ($media_size[0] > $media_size[1]) {
                            // landscape
                            $ratio = $media_size[0] / 200;
                            $newwidth = 200;
                            $newheight = round($media_size[1] / $ratio);
                        } else {
                            // portrait
                            $ratio = $media_size[1] / 200;
                            $newheight = 200;
                            $newwidth = round($media_size[0] / $ratio);
                        }
                    } else {
                        if ($width == 0 && $height > 0) {
                            if ($height > $media_size[1]) {
                                $newheight = $media_size[1];
                                $newwidth = $media_size[0];
                            } else {
                                $ratio = $height / $media_size[1];
                                $newheight = $height;
                                $newwidth = round($media_size[0] * $ratio);
                            }
                        } else {
                            $newwidth = $width;
                            $newheight = $height;
                        }
                    }
                }
                if ($newheight > $maxheight) {
                    $maxheight = $newheight;
                }
                if ($newwidth > $maxwidth) {
                    $maxwidth = $newwidth;
                }
                /*
                                if ($album->hidden == 1 || $enable_link == 0) {
                                    $pics .= '<img class="slideshowThumbnail' . $ss_count . '" src="' . $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext . '" alt="" style="width:' . $newwidth . 'px;height:' . $newheight . 'px;border:none;position:absolute;left:0px;top:0px;vertical-align:bottom;"' . XHTML . '>' . LB;
                                } else {
                                    $pics .= '<img class="slideshowThumbnail' . $ss_count . '" src="' . $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext . '" alt="" style="width:' . $newwidth . 'px;height:' . $newheight . 'px;border:none;position:absolute;left:0px;top:0px;vertical-align:bottom;"' . XHTML . '>' . LB;
                                }
                */
                $pics .= '<img class="slideshowThumbnail' . $ss_count . '" src="' . $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext . '" alt="" style="width:' . $newwidth . 'px;height:' . $newheight . 'px;' . 'border:none;position:absolute;left:0px;top:0px;vertical-align:bottom;"' . XHTML . '>' . LB;
            }
            if ($delay <= 0) {
                $delay = 10;
            }
            if ($album_data['hidden'] == 1 || $enable_link == 0) {
                $ss_url = '';
            } else {
                //              $ss_url = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '"' . ($target=='' ? '' : ' target="' . $target . '"') . '>';
                $ss_url = $_MG_CONF['site_url'] . '/album.php?aid=' . $aid;
            }
            $link = '';
            if ($counter != 0) {
                $T = COM_newTemplate($_MG_CONF['template_path']);
                $T->set_file('tag', 'autotag_ss.thtml');
                $T->set_var(array('align' => $align, 'pics' => $pics, 'caption' => $caption, 'maxheight' => $maxheight, 'maxwidth' => $maxwidth, 'width' => $maxwidth, 'framewidth' => $maxwidth + 10, 'ss_count' => $ss_count, 'delay' => $delay * 1000, 'border' => $border ? 'border: silver solid;border-width: 1px;' : '', 'xhtml' => XHTML, 'sslink' => $ss_url));
                if ($align == 'left' || $align == 'right') {
                    $T->set_var('float', 'float: ' . $align . ';');
                } else {
                    $T->set_var('float', 'float:left;');
                    $align = 'left';
                }
                $T->set_var('margin-right', $align == 'left' ? 'margin-right:15px;' : '');
                $link = $T->finish($T->parse('output', 'tag'));
            }
            /*
                        if ($align == 'center') {
                            $link = '<center>' . $link . '</center>';
                        }
            */
            break;
            // Testing //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Testing //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        case 'gallery':
            if (empty($parm1)) {
                return $content;
            }
            $album_data = MG_getAlbumData($parm1, array('album_title', 'album_id', 'hidden'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            if ($caption == '' && $_MG_CONF['autotag_caption']) {
                $caption = $album_data['album_title'];
            }
            $aid = $parm1;
            $pics = '';
            $counter = 0;
            $maxwidth = 0;
            $maxheight = 0;
            $ss_count++;
            $sql = MG_buildMediaSql(array('album_id' => $aid, 'fields' => array('media_filename', 'media_mime_ext', 'remote_url'), 'where' => "m.media_type = 0 AND m.include_ss = 1"));
            $result = DB_query($sql);
            while ($row = DB_fetchArray($result)) {
                switch ($src) {
                    case 'orig':
                        $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']);
                        $ext = $row['media_mime_ext'];
                        break;
                    case 'disp':
                        $mfn = 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'];
                        $tnext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $mfn);
                        $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . $mfn . $tnext);
                        $ext = substr($tnext, 1, 3);
                        // no use ?
                        break;
                    default:
                        $mfn = 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'];
                        $tnext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $mfn);
                        $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . $mfn . $tnext);
                        $ext = substr($tnext, 1, 3);
                        // no use ?
                        $src = 'tn';
                        break;
                }
                if ($media_size == false) {
                    continue;
                }
                $counter++;
                if ($width > 0 && $height == 0) {
                    if ($media_size[0] > $media_size[1]) {
                        // landscape
                        $ratio = $media_size[0] / $width;
                        $newwidth = $width;
                        $newheight = round($media_size[1] / $ratio);
                    } else {
                        // portrait
                        $ratio = $media_size[1] / $width;
                        $newheight = $width;
                        $newwidth = round($media_size[0] / $ratio);
                    }
                } else {
                    if ($width == 0 && $height == 0) {
                        if ($media_size[0] > $media_size[1]) {
                            // landscape
                            $ratio = $media_size[0] / 200;
                            $newwidth = 200;
                            $newheight = round($media_size[1] / $ratio);
                        } else {
                            // portrait
                            $ratio = $media_size[1] / 200;
                            $newheight = 200;
                            $newwidth = round($media_size[0] / $ratio);
                        }
                    } else {
                        if ($width == 0 && $height > 0) {
                            if ($height > $media_size[1]) {
                                $newheight = $media_size[1];
                                $newwidth = $media_size[0];
                            } else {
                                $ratio = $height / $media_size[1];
                                $newheight = $height;
                                $newwidth = round($media_size[0] * $ratio);
                            }
                        } else {
                            $newwidth = $width;
                            $newheight = $height;
                        }
                    }
                }
                if ($newheight > $maxheight) {
                    $maxheight = $newheight;
                }
                if ($newwidth > $maxwidth) {
                    $maxwidth = $newwidth;
                }
                $pics .= '<img class="slideshowThumbnail' . $ss_count . '" src="' . $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext . '" alt="" style="width:' . $newwidth . 'px;height:' . $newheight . 'px;' . 'border:none;position:absolute;left:0px;top:0px;vertical-align:bottom;"' . XHTML . '>' . LB;
            }
            if ($delay <= 0) {
                $delay = 10;
            }
            if ($album_data['hidden'] == 1 || $enable_link == 0) {
                $ss_url = '';
            } else {
                $ss_url = $_MG_CONF['site_url'] . '/album.php?aid=' . $aid;
            }
            $link = '';
            if ($counter != 0) {
                $T = COM_newTemplate($_MG_CONF['template_path']);
                $T->set_file('tag', 'autotag_ss.thtml');
                $T->set_var(array('align' => $align, 'pics' => $pics, 'caption' => $caption, 'maxheight' => $maxheight, 'maxwidth' => $maxwidth, 'width' => $maxwidth, 'framewidth' => $maxwidth + 10, 'ss_count' => $ss_count, 'delay' => $delay * 1000, 'border' => $border ? 'border: silver solid;border-width: 1px;' : '', 'xhtml' => XHTML, 'sslink' => $ss_url));
                if ($align == 'left' || $align == 'right') {
                    $T->set_var('float', 'float: ' . $align . ';');
                } else {
                    $T->set_var('float', 'float:left;');
                    $align = 'left';
                }
                $T->set_var('margin-right', $align == 'left' ? 'margin-right:15px;' : '');
                $link = $T->finish($T->parse('output', 'tag'));
            }
            break;
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //@@@@@
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //@@@@@
        case 'medialist':
            $link = MG_medialist($p1, $p['lastparm2'], $p['theme'], $p['limitcnt'], $p['sort']);
            break;
        case 'albumlist':
            $link = MG_albumlist($p1, $p['limitcnt'], $p['order'], $p['lastparm2'], $p['theme']);
            break;
            //@@@@@
        //@@@@@
        case 'album':
            if (empty($parm1)) {
                $side_count--;
                return $content;
            }
            $album_data = MG_getAlbumData($parm1, array('album_title', 'album_id', 'hidden', 'tn_attached'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                $side_count--;
                return str_replace($autotag['tagstr'], '', $content);
            }
            $ss_count++;
            if ($caption != '') {
                $alttag = ' alt="' . $caption . '" title="' . $caption . '"';
            } else {
                $alttag = ' alt=""';
                if ($_MG_CONF['autotag_caption']) {
                    $caption = $album_data['album_title'];
                }
            }
            //            $aid = $parm1;
            if ($album_data['tn_attached'] == 1) {
                $tfn = 'covers/cover_' . $parm1;
                $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $tfn);
                $tnImage = $_MG_CONF['mediaobjects_url'] . '/' . $tfn . $ext;
                $tnFileName = $_MG_CONF['path_mediaobjects'] . $tfn . $ext;
            } else {
                $filename = MG_getAlbumCover($parm1);
                if ($filename != '') {
                    $tfn = 'tn/' . $filename[0] . '/' . $filename . '_cropcustom';
                    $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $tfn);
                    $tnImage = $_MG_CONF['mediaobjects_url'] . '/' . $tfn . $ext;
                    $tnFileName = $_MG_CONF['path_mediaobjects'] . $tfn . $ext;
                } else {
                    $tnImage = $_MG_CONF['mediaobjects_url'] . '/empty.png';
                    $tnFileName = $_MG_CONF['path_mediaobjects'] . 'empty.png';
                }
            }
            $media_size = @getimagesize($tnFileName);
            if ($media_size == false) {
                $tnImage = $_MG_CONF['mediaobjects_url'] . '/missing.png';
                $tnFileName = $_MG_CONF['path_mediaobjects'] . 'missing.png';
                $media_size = @getimagesize($tnFileName);
            }
            if ($width > 0 && $height == 0) {
                $ratio = $media_size[0] / $width;
                $newwidth = $width;
                $newheight = round($media_size[1] / $ratio);
            } else {
                if ($width == 0 && $height == 0) {
                    if ($media_size[0] > $media_size[1]) {
                        // landscape
                        $ratio = $media_size[0] / 200;
                        $newwidth = 200;
                        $newheight = round($media_size[1] / $ratio);
                    } else {
                        // portrait
                        $ratio = $media_size[1] / 200;
                        $newheight = 200;
                        $newwidth = round($media_size[0] / $ratio);
                    }
                } else {
                    if ($width == 0 && $height > 0) {
                        $ratio = $height / $media_size[1];
                        $newheight = $height;
                        $newwidth = round($media_size[0] * $ratio);
                    } else {
                        $newwidth = $width;
                        $newheight = $height;
                    }
                }
            }
            $tagtext = '<img src="' . $tnImage . '" ' . $alttag . 'style="width:' . $newwidth . 'px;height:' . $newheight . 'px;border:none;vertical-align:bottom;"' . XHTML . '>';
            if ($linkID == 0) {
                $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $parm1;
            } else {
                if ($linkID < 1000000) {
                    $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $linkID;
                } else {
                    $url = $_MG_CONF['site_url'] . '/media.php?s=' . $linkID;
                }
            }
            if ($enable_link == 0) {
                $link = $tagtext;
            } else {
                $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
            }
            $T = COM_newTemplate($_MG_CONF['template_path']);
            $T->set_file('tag', $border == 0 ? 'autotag_nb.thtml' : 'autotag.thtml');
            $T->set_var(array('ss_count' => $ss_count, 'align' => $align, 'autotag' => $link, 'caption' => $caption, 'width' => $newwidth, 'framewidth' => $newwidth, 'xhtml' => XHTML, 'float' => $align == 'left' || $align == 'right' ? 'float:' . $align . ';' : '', 'margin-right' => $align == 'left' ? 'margin-right:15px;' : ''));
            if ($align == 'center') {
                $T->set_var('margin-right', 'margin:0 auto;');
            }
            $link = $T->finish($T->parse('output', 'tag'));
            if ($align == 'center') {
                $link = '<div style="text-align:center;">' . LB . $link . '</div>' . LB;
            }
            break;
        case 'alink':
            if ($parm1 == '' || $parm1 == 0) {
                $side_count--;
                return $content;
            }
            $album_data = MG_getAlbumData($parm1, array('album_title', 'album_id', 'hidden'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                $side_count--;
                return str_replace($autotag['tagstr'], '', $content);
            }
            if ($caption == '') {
                $caption = $album_data['album_title'];
            }
            $link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $album_data['album_id'] . '">' . $caption . '</a>';
            return str_replace($autotag['tagstr'], $link, $content);
            break;
        case 'media':
            /* image, oimage and img are depreciated */
        /* image, oimage and img are depreciated */
        case 'image':
        case 'oimage':
        case 'img':
            if (empty($parm1)) {
                return $content;
            }
            $direct_link = '';
            $ss_count++;
            $alttag = ' alt=""';
            if ($caption != '') {
                $alttag = ' alt="' . $caption . '" title="' . $caption . '"';
            }
            $sql = "SELECT ma.album_id,m.media_title,m.media_type,m.media_filename," . "m.media_mime_ext,m.mime_type,m.media_tn_attached,m.remote_url " . "FROM {$_TABLES['mg_media']} AS m " . "LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id " . "WHERE m.media_id='" . addslashes($parm1) . "'";
            $result = DB_query($sql);
            if (DB_numRows($result) <= 0) {
                return $content;
            }
            // no image found
            $row = DB_fetchArray($result);
            $aid = $row['album_id'];
            $album_data = MG_getAlbumData($aid, array('album_id', 'hidden'), true);
            if (!isset($album_data['album_id']) || $album_data['access'] == 0) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            if ($caption == '' && $_MG_CONF['autotag_caption']) {
                $caption = $row['media_title'];
            }
            switch ($row['media_type']) {
                case 0:
                    // standard image
                    $fn = $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
                    $tfn = 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'];
                    if ($autotag['tag'] == 'oimage') {
                        $default_thumbnail = ($_MG_CONF['discard_original'] == 1 ? 'disp/' : 'orig/') . $fn;
                    } else {
                        switch ($src) {
                            case 'orig':
                                $default_thumbnail = ($_MG_CONF['discard_original'] == 1 ? 'disp/' : 'orig/') . $fn;
                                break;
                            case 'disp':
                                $default_thumbnail = 'disp/' . $fn;
                                break;
                            default:
                                $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $tfn);
                                $default_thumbnail = $tfn . $ext;
                                break;
                        }
                        $lfn = $link_src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'];
                        $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $lfn);
                        $direct_link = $_MG_CONF['mediaobjects_url'] . '/' . $lfn . $ext;
                    }
                    break;
                case 1:
                    // video file
                    switch ($row['mime_type']) {
                        case 'application/x-shockwave-flash':
                            $default_thumbnail = 'flash.png';
                            break;
                        case 'video/quicktime':
                        case 'video/mpeg':
                        case 'video/x-m4v':
                            $default_thumbnail = 'quicktime.png';
                            break;
                        case 'video/x-ms-asf':
                        case 'video/x-ms-wvx':
                        case 'video/x-ms-wm':
                        case 'video/x-ms-wmx':
                        case 'video/x-msvideo':
                        case 'application/x-ms-wmz':
                        case 'application/x-ms-wmd':
                            $default_thumbnail = 'wmp.png';
                            break;
                        default:
                            $default_thumbnail = 'video.png';
                            break;
                    }
                    $src = 'tn';
                    break;
                case 2:
                    // music file
                    $src = 'tn';
                    $default_thumbnail = 'audio.png';
                    break;
            }
            if ($row['media_tn_attached'] == 1 && ($src != 'orig' && $src != 'disp')) {
                $tfn = 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'];
                $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $tfn);
                $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $tfn . $ext;
                $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $tfn . $ext;
            } else {
                if ($src == 'tn' and $row['media_type'] == 0) {
                    $tfn = 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '_cropcustom';
                    $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . $tfn);
                    $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $tfn . $ext;
                    $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $tfn . $ext;
                } else {
                    $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail;
                    $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail;
                }
            }
            $mediaSize = @getimagesize($media_thumbnail_file);
            if ($mediaSize == false) {
                return str_replace($autotag['tagstr'], '', $content);
            }
            if ($autotag['tag'] == 'oimage' || $src == 'orig') {
                $newwidth = $mediaSize[0];
                $newheight = $mediaSize[1];
            } else {
                if ($width > 0) {
                    $tn_height = $width;
                } else {
                    switch ($src) {
                        case 'orig':
                        case 'disp':
                            $tn_height = $mediaSize[0];
                            break;
                        default:
                            $tn_height = 200;
                            break;
                    }
                }
                if ($mediaSize[0] > $mediaSize[1]) {
                    $ratio = $mediaSize[0] / $tn_height;
                    $newwidth = $tn_height;
                    $newheight = round($mediaSize[1] / $ratio);
                } else {
                    $ratio = $mediaSize[1] / $tn_height;
                    $newheight = $tn_height;
                    $newwidth = round($mediaSize[0] / $ratio);
                }
            }
            $tagtext = '<img src="' . $media_thumbnail . '" ' . $alttag . ' style="width:' . $newwidth . 'px;height:' . $newheight . 'px;border:none;vertical-align:bottom;"' . XHTML . '>';
            $link = '';
            if ($alt == 1 && $row['remote_url'] != '') {
                $url = $row['remote_url'];
                if ($autotag['tag'] != 'image' && $enable_link != 0) {
                    $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                } else {
                    $link = $tagtext;
                }
            } else {
                if ($linkID == 0) {
                    $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1;
                } else {
                    if ($linkID < 1000000) {
                        $link_album = MG_getAlbumData($linkID, array('album_id', 'hidden'), false);
                        if (!isset($link_album['album_id'])) {
                            $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $linkID;
                            if ($autotag['tag'] != 'image' && $link_album['hidden'] != 1 && $enable_link != 0) {
                                $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                            } else {
                                $link = $tagtext;
                            }
                        } else {
                            $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1;
                        }
                    } else {
                        $linkAID = intval(DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . addslashes($linkID) . '"'));
                        if ($linkAID != 0) {
                            $url = $_MG_CONF['site_url'] . '/media.php?s=' . $linkID;
                            $hidden = DB_getItem($_TABLES['mg_albums'], 'hidden', "album_id=" . intval($linkAID));
                            if ($autotag['tag'] != 'image' && $hidden != 1 && $enable_link != 0) {
                                $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                            } else {
                                $link = $tagtext;
                            }
                        } else {
                            $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1;
                        }
                    }
                }
            }
            if ($link == '') {
                if ($autotag['tag'] != 'image' && ($album_data['hidden'] != 1 || $enable_link == 2) && $enable_link != 0) {
                    if ($enable_link == 2 && $direct_link != '') {
                        if ($_MG_CONF['disable_lightbox'] == true) {
                            $link = $tagtext;
                        } else {
                            $link = '<a href="' . $direct_link . '" rel="lightbox" title="' . strip_tags(str_replace('$', '&#36;', $caption)) . '">' . $tagtext . '</a>';
                        }
                    } else {
                        $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                    }
                } else {
                    $link = $tagtext;
                }
            }
            if ($autotag['tag'] == 'img') {
                $link = MG_helper_getContainer($link, $align, 'div');
            } else {
                $T = COM_newTemplate($_MG_CONF['template_path']);
                $T->set_file('tag', $border == 0 ? 'autotag_nb.thtml' : 'autotag.thtml');
                $T->set_var(array('ss_count' => $ss_count, 'align' => $align, 'autotag' => $link, 'caption' => $caption, 'width' => $newwidth, 'framewidth' => $newwidth, 'xhtml' => XHTML, 'float' => $align == 'left' || $align == 'right' ? 'float:' . $align . ';' : '', 'margin-right' => $align == 'left' ? 'margin:15px;' : ''));
                if ($align == 'center') {
                    $T->set_var('margin-right', 'margin:0 auto;');
                }
                $link = $T->finish($T->parse('output', 'tag'));
                if ($align == 'center') {
                    $link = '<div style="text-align:center;">' . LB . $link . '</div>' . LB;
                }
            }
            break;
    }
    return str_replace($autotag['tagstr'], $link, $content);
}
Beispiel #11
0
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
}
/**
* Main
*/
$display = '';
$mode = '';
if (isset($_POST['save'])) {
    $mode = 'save';
}
if (isset($_POST['cancel'])) {
    $mode = 'cancel';
}
$T = new Template($_MG_CONF['template_path'] . '/admin');
$T->set_file(array('admin' => 'administration.thtml'));
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'mg_navigation' => MG_navigation(), 'lang_admin' => $LANG_MG00['admin'], 'version' => $_MG_CONF['pi_version']));
if ($mode == 'save' && SEC_checkToken()) {
    $T->set_var(array('admin_body' => MG_saveAVDefaults(), 'title' => $LANG_MG01['av_default_editor']));
} elseif ($mode == 'cancel') {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    $T->set_var(array('admin_body' => MG_editAVDefaults(), 'title' => $LANG_MG01['av_default_editor'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"/>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Audio__Video_Defaults'));
}
$T->parse('output', 'admin');
$display = COM_siteHeader('menu', '');
$display .= $T->finish($T->get_var('output'));
$display .= COM_siteFooter();
echo $display;
exit;
            // see if they have an entry in userprefs
            $result3 = DB_query("SELECT uid FROM {$_TABLES['mg_userprefs']} WHERE uid=" . $U['uid']);
            $pRows = DB_numRows($result3);
            $member_gallery = $nRows > 0 ? 1 : 0;
            if ($pRows > 0) {
                DB_change($_TABLES['mg_userprefs'], 'member_gallery', $member_gallery, 'uid', $U['uid']);
                DB_change($_TABLES['mg_userprefs'], 'active', 1, 'uid', $U['uid']);
            } else {
                $sql = "INSERT INTO {$_TABLES['mg_userprefs']} " . "(uid, active, display_rows, display_columns, mp3_player, playback_mode, tn_size, quota, member_gallery) " . "VALUES (" . $U['uid'] . ",1,0,0,-1,-1,-1," . $_MG_CONF['member_quota'] . "," . $member_gallery . ")";
                DB_query($sql);
            }
        }
        echo COM_refresh($_MG_CONF['admin_url'] . 'index.php?msg=14');
        exit;
    default:
        $B = new Template($_MG_CONF['template_path']);
        $B->set_file('admin', 'thumbs.thtml');
        $B->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_CONF['site_url'], 'xhtml' => XHTML, 'lang_title' => $LANG_MG01['reset_members'], 's_form_action' => $_MG_CONF['admin_url'] . 'resetmembers.php?step=two', 'lang_next' => $LANG_MG01['next'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_details' => $LANG_MG01['reset_members_details']));
        $B->parse('output', 'admin');
        $T = new Template($_MG_CONF['template_path']);
        $T->set_file('admin', 'administration.thtml');
        $T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'xhtml' => XHTML, 'admin_body' => $B->finish($B->get_var('output')), 'title' => $LANG_MG01['reset_members'], 'lang_admin' => $LANG_MG00['admin'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"' . XHTML . '>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Reset_Member_Album_Create_Flag'));
        $T->parse('output', 'admin');
        $display = COM_startBlock($LANG_MG00['admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
        $display .= MG_showAdminMenu('member_albums');
        $display .= $T->finish($T->get_var('output'));
        $display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
        $display = COM_createHTMLDocument($display);
        COM_output($display);
        break;
}
Beispiel #13
0
if ($mode == $LANG_MG01['save'] && !empty($LANG_MG01['save'])) {
    $cat_id = COM_applyFilter($_POST['cat_id'], true);
    $T->set_var(array('admin_body' => MG_saveCategory($cat_id)));
} elseif ($mode == $LANG_MG01['cancel']) {
    $page = 'index.php';
    if ($action == 'edit_category') {
        $page = 'category.php';
    }
    echo COM_refresh($_MG_CONF['admin_url'] . $page);
    exit;
} elseif ($mode == $LANG_MG01['create'] && !empty($LANG_MG01['create'])) {
    $T->set_var(array('admin_body' => MG_editCategory(0, 'create'), 'title' => $LANG_MG01['create_category']));
} elseif ($mode == 'edit') {
    $cat_id = COM_applyFilter($_GET['id'], true);
    $T->set_var(array('admin_body' => MG_editCategory($cat_id, 'edit'), 'title' => $LANG_MG01['edit_category']));
} elseif ($mode == $LANG_MG01['delete'] && !empty($LANG_MG01['delete'])) {
    if (isset($_POST['cat_id'])) {
        $cat_id = $_POST['cat_id'];
        MG_batchDeleteCategory($cat_id);
    } else {
        MG_batchDeleteCategory(0);
    }
} else {
    $T->set_var(array('admin_body' => MG_displayCategories(), 'title' => $LANG_MG01['category_manage_help'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"' . XHTML . '>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Category_Maintenance'));
}
$display = COM_startBlock($LANG_MG00['admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
$display .= MG_showAdminMenu();
$display .= $T->finish($T->parse('output', 'admin'));
$display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
$display = COM_createHTMLDocument($display);
COM_output($display);
Beispiel #14
0
$retval = '';
$aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($mid) . '"');
if ($MG_albums[$aid]->access == 0) {
    $display = MG_siteHeader();
    $display .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
    $display .= MG_siteFooter();
    echo $display;
    exit;
}
$sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma LEFT JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE m.media_id='" . DB_escapeString($mid) . "'";
$result = DB_query($sql);
$nRows = DB_numRows($result);
if ($nRows < 1) {
    $display = MG_siteHeader();
    $display .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
    $display .= MG_siteFooter();
    echo $display;
    exit;
}
$M = DB_fetchArray($result);
// build the template...
$T = new Template(MG_getTemplatePath($aid));
$T->set_file('postcard', 'getcard.thtml');
$media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg');
$T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/postcard.php', 'mid' => $mid, 'media_title' => $M['media_title'], 'alt_media_title' => htmlspecialchars(strip_tags($M['media_title'])), 'media_description' => $M['media_description'], 'media_url' => $_MG_CONF['site_url'] . '/media.php?s=' . $mid, 'media_image' => $_MG_CONF['mediaobjects_url'] . '/disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg', 'site_url' => $_MG_CONF['site_url'] . '/', 'postcard_subject' => $subject, 'postcard_message' => $message, 'from_email' => $fromemail, 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'to_name' => $toname, 'from_name' => $fromname, 'stamp_url' => MG_getImageFile('stamp.gif'), 'lang_to' => $LANG_MG03['to'], 'lang_from' => $LANG_MG03['from'], 'lang_send_to' => $LANG_MG03['send_to'], 'lang_subject' => $LANG_MG03['subject'], 'lang_send' => $LANG_MG03['send'], 'lang_cancel' => $LANG_MG03['cancel'], 'lang_preview' => $LANG_MG03['preview'], 'lang_message' => $LANG_MG03['message_body'], 'lang_send_from' => $LANG_MG03['send_from'], 'lang_postcard_from' => $LANG_MG03['postcard_from'], 'lang_visit' => $LANG_MG03['visit']));
$T->parse('output', 'postcard');
$retval .= $T->finish($T->get_var('output'));
$display = MG_siteHeader();
$display .= $retval;
$display .= MG_siteFooter();
echo $display;
Beispiel #15
0
function MG_displayFLV($I, $opt = array())
{
    global $_TABLES, $_CONF, $_MG_CONF, $LANG_MG03;
    // 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='" . addslashes($I['media_id']) . "'");
    while ($poRow = DB_fetchArray($poResult)) {
        $playback_options[$poRow['option_name']] = $poRow['option_value'];
    }
    $_MG_USERPREFS = MG_getUserPrefs();
    if (isset($_MG_USERPREFS['playback_mode']) && $_MG_USERPREFS['playback_mode'] != -1) {
        $playback_type = $_MG_USERPREFS['playback_mode'];
    } else {
        $playback_type = $opt['playback_type'];
    }
    $resolution_x = $I['resolution_x'];
    $resolution_y = $I['resolution_y'];
    if ($resolution_x == 0) {
        $resolution_x = 320;
        //$I['media_resolution_x'];
        $resolution_y = 240;
        //$I['media_resolution_y'];
        if ($I['media_resolution_x'] == 0 && $I['remote_media'] == 0) {
            $filepath = Media::getFilePath('orig', $I['media_filename'], $I['media_mime_ext']);
            list($resolution_x, $resolution_y) = Media::getResolutionID3($filepath);
        }
    }
    switch ($playback_type) {
        case 0:
            // Popup Window
            $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 ($I['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 ($I['media_type'] == 5) {
                $resolution_x = 460;
                $resolution_y = 380;
            }
            $u_pic = Media::getHref_showvideo($I['media_id'], $resolution_y, $resolution_x);
            list($u_image, $p_image, $media_size_orig) = Media::getThumbInfo($I);
            break;
        case 1:
            // download
            $u_pic = $_MG_CONF['site_url'] . '/download.php?mid=' . $I['media_id'];
            $raw_link_url = $u_pic;
            list($u_image, $p_image, $media_size_orig) = Media::getThumbInfo($I);
            break;
        case 3:
            // mms - not supported for flash
        // mms - not supported for flash
        case 2:
            // inline
            $u_image = '';
            // Initialize the view_flv.thtml template
            $V = COM_newTemplate(MG_getTemplatePath_byName($opt['skin']));
            $V->set_file('video', 'view_flv.thtml');
            // now the player specific items.
            $F = COM_newTemplate(MG_getTemplatePath_byName($opt['skin']));
            if ($_MG_CONF['use_flowplayer'] == 1) {
                // FlowPlayer Setup
                $F->set_file('player', 'flvfp.thtml');
            } else {
                $F->set_file('player', 'flvmg.thtml');
            }
            if ($playback_options['play'] == 1) {
                // auto start
                $playButton = '';
                $playButtonMG = '';
                $autoplay = 'true';
            } else {
                if ($I['media_tn_attached'] == 1) {
                    $playImage = Media::getFileUrl('tn', $I['media_filename'], 'jpg', 1);
                    $playButtonMG = 'flashvars.thumbUrl="' . $playImage . '";';
                } else {
                    $playImage = $_MG_CONF['site_url'] . MG_getImageFile('blank_blk.jpg');
                    $playButtonMG = '';
                }
                $playButton = "{ url: '" . $playImage . "', overlayId: 'play' },";
                $autoplay = 'false';
            }
            if ($I['remote_media'] == 1) {
                $urlParts = array();
                $urlParts = parse_url($I['remote_url']);
                $pathParts = array();
                $pathParts = explode('/', $urlParts['path']);
                $ppCount = count($pathParts);
                $pPath = '';
                for ($I = 1; $I < $ppCount - 1; $I++) {
                    $pPath .= '/' . $pathParts[$I];
                }
                $videoFile = $pathParts[$ppCount - 1];
                $pos = strrpos($videoFile, '.');
                if ($pos === false) {
                    $basefilename = $videoFile;
                } else {
                    $basefilename = substr($videoFile, 0, $pos);
                }
                $videoFile = $basefilename;
                $streamingServerURL = "streamingServerURL: '" . $urlParts['scheme'] . '://' . $urlParts['host'] . $pPath . "',";
                $streamingServerURLmg = 'flashvars.streamingServerUrl="' . $urlParts['scheme'] . '://' . $urlParts['host'] . $pPath . '";';
                $streamingServer = "streamingServer: 'fms',";
            } else {
                $videoFile = urlencode(Media::getFileUrl('orig', $I['media_filename'], $I['media_mime_ext']));
                $streamingServerURL = '';
                $streamingServerURLmg = '';
                $streamingServer = '';
            }
            $width = $playback_options['width'];
            $height = $playback_options['height'];
            if ($opt['allow_download'] == 1) {
                $allowDl = 'true';
            } else {
                $allowDl = 'false';
            }
            if ($I['media_title'] != '' && $I['media_title'] != ' ') {
                $title = urlencode($I['media_title']);
            } else {
                $title = urlencode($I['media_original_filename']);
            }
            if ($_MG_CONF['use_flowplayer'] == 1) {
                $resolution_x = $width;
                $resolution_y = $height;
            } else {
                $resolution_x = $resolution_x + 60;
                $resolution_y = $resolution_y + 190;
                if ($resolution_x < 565) {
                    $resolution_x = 565;
                }
            }
            $id = 'id' . rand();
            $id2 = 'idtwo' . rand();
            $F->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'play' => $autoplay, 'autoplay' => $autoplay, 'menu' => $playback_options['menu'] ? 'true' : 'false', 'loop' => $playback_options['loop'] ? 'true' : 'false', 'scale' => $playback_options['scale'], 'wmode' => $playback_options['wmode'], 'width' => $width, 'height' => $height, 'allowDl' => $allowDl, 'title' => $title, 'streamingServerURL' => $streamingServerURL, 'videoFile' => $videoFile, 'playButton' => $playButton, 'streamingServerURLmg' => $streamingServerURLmg, 'playButtonMG' => $playButtonMG, 'id' => $id, 'id2' => $id2, 'lang_download' => $LANG_MG03['download'], 'lang_large' => $LANG_MG03['large'], 'lang_normal' => $LANG_MG03['normal'], 'resolution_x' => $resolution_x, 'resolution_y' => $resolution_y));
            $flv_player = $F->finish($F->parse('output', 'player'));
            $V->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'id' => $id, 'id2' => $id2, 'resolution_x' => $resolution_x, 'resolution_y' => $resolution_y, 'flv_player' => $flv_player));
            $u_image .= $V->finish($V->parse('output', 'video'));
            return array($u_image, '', $resolution_x, $resolution_y, '');
            break;
    }
    $retval = MG_getFramedImage($opt['display_skin'], $I['media_title'], $u_pic, $u_image, $media_size_disp[0], $media_size_disp[1]);
    return array($retval, $u_image, $media_size_disp[0], $media_size_disp[1], $u_pic);
}
Beispiel #16
0
function MG_editPostCard($mode, $mid, $msg = '')
{
    global $MG_albums, $_MG_CONF, $_CONF, $_TABLES, $_USER, $LANG_MG03, $LANG_ACCESS, $LANG_MG00;
    $retval = '';
    $errMsg = '';
    $toname = '';
    $toemail = '';
    $fromname = '';
    $fromemail = '';
    $subject = '';
    $message = '';
    if ($mode == 'edit') {
        $mid = COM_applyFilter($_POST['mid']);
        $toname = COM_applyFilter($_POST['toname']);
        $toemail = COM_applyFilter($_POST['toemail']);
        $fromname = COM_applyFilter($_POST['fromname']);
        $fromemail = COM_applyFilter($_POST['fromemail']);
        $subject = strip_tags(COM_checkWords($_POST['subject']));
        $message = htmlspecialchars(strip_tags(COM_checkWords($_POST['message'])));
        $ccself = isset($_POST['ccself']) ? 1 : 0;
        // do some validation
        if (!COM_isEmail($toemail)) {
            $errMsg .= $LANG_MG03['invalid_to_email'] . '<br/>';
        }
        if (!COM_isEmail($fromemail)) {
            $errMsg .= $LANG_MG03['invalid_from_email'] . '<br/>';
        }
        if (empty($subject)) {
            $errMsg .= $LANG_MG03['invalid_subject'] . '<br/>';
        }
        if (empty($message)) {
            $errMsg .= $LANG_MG03['invalid_message'] . '<br/>';
        }
        if ($msg != '') {
            $errMsg .= $msg;
        }
    } else {
        $fromname = empty($_USER['fullname']) ? $_USER['username'] : $_USER['fullname'];
        $fromemail = $_USER['email'];
    }
    $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($mid) . '"');
    if ($MG_albums[$aid]->access == 0 || $MG_albums[$aid]->enable_postcard == 0 || COM_isAnonUser() && $MG_albums[$aid]->enable_postcard != 2) {
        $retval = MG_siteHeader();
        $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
        $retval .= MG_siteFooter();
        echo $retval;
        exit;
    }
    $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma LEFT JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE m.media_id='" . DB_escapeString($mid) . "'";
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    if ($nRows < 1) {
        $retval = MG_siteHeader();
        $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true);
        $retval .= MG_siteFooter();
        echo $retval;
        exit;
    }
    $M = DB_fetchArray($result);
    // build the template...
    $T = new Template(MG_getTemplatePath($aid));
    $T->set_file('postcard', 'pc_edit.thtml');
    $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg');
    $T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/postcard.php', 'mid' => $mid, 'display_url' => $_MG_CONF['site_url'] . '/media.php?s=' . $mid, 'image_url' => $_MG_CONF['mediaobjects_url'] . '/disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg', 'image_tn' => $_MG_CONF['mediaobjects_url'] . '/tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg', 'stamp_url' => $_MG_CONF['site_url'] . MG_getImageFile('stamp.jpg'), 'border_width' => $media_size[0] + 15, 'lang_send_postcard' => $LANG_MG03['send_postcard'], 'lang_to_name' => $LANG_MG03['to_name'], 'lang_to_email' => $LANG_MG03['to_email'], 'lang_from_name' => $LANG_MG03['from_name'], 'lang_from_email' => $LANG_MG03['from_email'], 'lang_send_to' => $LANG_MG03['send_to'], 'lang_subject' => $LANG_MG03['subject'], 'lang_send' => $LANG_MG03['send'], 'lang_cancel' => $LANG_MG03['cancel'], 'lang_preview' => $LANG_MG03['preview'], 'lang_message' => $LANG_MG03['message_body'], 'lang_send_from' => $LANG_MG03['send_from'], 'postcard_subject' => $subject, 'postcard_message' => $message, 'from_name' => $fromname, 'from_email' => $fromemail, 'to_name' => $toname, 'to_email' => $toemail, 'errMsg' => $errMsg, 'lang_ccself' => $LANG_MG03['ccself'], 'ccself_checked' => isset($_POST['ccself']) ? ' checked="checked"' : ''));
    if (function_exists('plugin_templatesetvars_captcha')) {
        plugin_templatesetvars_captcha('mediagallery', $T);
    } else {
        $T->set_var('captcha', '');
    }
    $T->parse('output', 'postcard');
    $retval .= $T->finish($T->get_var('output'));
    return $retval;
}
Beispiel #17
0
     if ($_MG_CONF['discard_original'] != 1) {
         $display = MG_siteHeader();
         $display .= MG_errorHandler($LANG_MG01['remove_error']);
         $display .= MG_siteFooter();
         echo $display;
         exit;
     }
     $T = new Template($_MG_CONF['template_path'] . '/admin');
     $T->set_file(array('admin' => 'administration.thtml'));
     $B = new Template($_MG_CONF['template_path'] . '/admin');
     $B->set_file(array('admin' => 'thumbs.thtml'));
     $B->set_var('site_url', $_CONF['site_url']);
     $B->set_var('site_admin_url', $_CONF['site_admin_url']);
     $B->set_var(array('lang_title' => $LANG_MG01['remove_originals'], 's_form_action' => $_MG_CONF['admin_url'] . 'maint.php?mode=remove&amp;step=two', 'lang_next' => $LANG_MG01['next'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_help' => $LANG_MG01['remove_help'], 'lang_details' => $LANG_MG01['remove_details']));
     $B->parse('output', 'admin');
     $T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'admin_body' => $B->finish($B->get_var('output')), 'mg_navigation' => MG_navigation(), 'title' => $LANG_MG01['discard_originals'], 'lang_admin' => $LANG_MG00['admin'], 'version' => $_MG_CONF['version'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"/>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Discard_Original_Images'));
     $T->parse('output', 'admin');
     $display = COM_siteHeader();
     $display .= $T->finish($T->get_var('output'));
     $display .= COM_siteFooter();
     echo $display;
     exit;
     break;
 case 'two':
     $sql = "SELECT * 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";
     $result = DB_query($sql);
     $nRows = DB_numRows($result);
     if ($nRows > 0) {
         $session_id = MG_beginSession('droporiginal', $_MG_CONF['admin_url'] . 'index.php', $LANG_MG01['discard_originals']);
         for ($x = 0; $x < $nRows; $x++) {
             $row = DB_fetchArray($result);
Beispiel #18
0
function _mg_autotags($op, $content = '', $autotag = '')
{
    global $MG_albums, $_MG_CONF, $_CONF, $_MG_USERPREFS, $_TABLES, $LANG_MG00, $LANG_MG03, $side_count, $swfjsinclude;
    global $mgAutoTagArray, $mg_installed_version;
    static $ss_count = 0;
    if ($mg_installed_version != $_MG_CONF['pi_version']) {
        return $content;
    }
    $default_thumbnail = 'placeholder.svg';
    if ($op == 'parse') {
        if (!isset($mgAutoTagArray['count']) || empty($mgAutoTagArray['count'])) {
            $mgAutoTagArray['count'] = 0;
        }
        /*
         * Process the auto tag to remove any embedded &nbsp;
         */
        $tag = str_replace('&nbsp;', ' ', $autotag['tagstr']);
        $parms = explode(' ', $tag);
        // Extra test to see if autotag was entered with a space
        // after the module name
        if (substr($parms[0], -1) == ':') {
            $startpos = strlen($parms[0]) + strlen($parms[1]) + 2;
            $label = str_replace(']', '', substr($tag, $startpos));
            $tagid = $parms[1];
        } else {
            $label = str_replace(']', '', substr($tag, strlen($parms[0]) + 1));
            $parms = explode(':', $parms[0]);
            if (count($parms) > 2) {
                // whoops, there was a ':' in the tag id ...
                array_shift($parms);
                $tagid = implode(':', $parms);
            } else {
                $tagid = $parms[1];
            }
        }
        $autotag['parm1'] = str_replace(']', '', $tagid);
        $autotag['parm2'] = $label;
        /*
         * end of tag replacement
         */
        $T = new Template($_MG_CONF['template_path']);
        // see if we have an alignment option included
        $caption = $autotag['parm2'];
        $aSet = 0;
        $skip = 0;
        // default values for parameters
        $border = $_MG_CONF['at_border'];
        $align = $_MG_CONF['at_align'];
        $width = $_MG_CONF['at_width'];
        $height = $_MG_CONF['at_height'];
        $src = $_MG_CONF['at_src'];
        $autoplay = $_MG_CONF['at_autoplay'];
        $enable_link = $_MG_CONF['at_enable_link'];
        $delay = $_MG_CONF['at_delay'];
        $transition = 'Fade';
        $showtitle = $_MG_CONF['at_showtitle'];
        $destination = 'content';
        $target = '';
        $linkID = 0;
        $alt = 0;
        $link_src = 'disp';
        $classes = '';
        $nosize = 0;
        $tag = '';
        if ($align != '') {
            $aSet = 1;
        }
        // parameter processing - logic borrowed from
        // Dirk Haun's Flickr plugin
        $px = explode(' ', trim($autotag['parm2']));
        if (is_array($px)) {
            foreach ($px as $part) {
                if (substr($part, 0, 6) == 'width:') {
                    $a = explode(':', $part);
                    $width = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 7) == 'height:') {
                    $a = explode(':', $part);
                    $height = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 7) == 'border:') {
                    $a = explode(':', $part);
                    $border = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 6) == 'align:') {
                    $a = explode(':', $part);
                    $align = $a[1];
                    $skip++;
                    $aSet = 1;
                } elseif (substr($part, 0, 4) == 'src:') {
                    $a = explode(':', $part);
                    $src = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 9) == 'autoplay:') {
                    $a = explode(':', $part);
                    $autoplay = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 5) == 'link:') {
                    $a = explode(':', $part);
                    $enable_link = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 6) == 'delay:') {
                    $a = explode(':', $part);
                    $delay = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 11) == 'transition:') {
                    $a = explode(':', $part);
                    $transition = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 6) == 'title:') {
                    $a = explode(':', $part);
                    $showtitle = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 5) == 'dest:') {
                    $a = explode(':', $part);
                    $destination = $a[1];
                    $skip++;
                    if ($destination != 'content' && $destination != 'block') {
                        $destination = 'content';
                    }
                } elseif (substr($part, 0, 7) == 'linkid:') {
                    $a = explode(':', $part);
                    $linkID = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 4) == 'alt:') {
                    $a = explode(':', $part);
                    $alt = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 7) == 'target:') {
                    $a = explode(':', $part);
                    $target = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 5) == 'type:') {
                    $a = explode(':', $part);
                    $mp3_type = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 6) == 'class:') {
                    $a = explode(':', $part);
                    $c = explode(',', $a[1]);
                    foreach ($c as $class) {
                        $classes .= ' ' . $class;
                    }
                    $skip++;
                } elseif (substr($part, 0, 7) == 'nosize:') {
                    $a = explode(':', $part);
                    $nosize = $a[1];
                    $skip++;
                } elseif (substr($part, 0, 4) == 'tag:') {
                    $a = explode(':', $part);
                    $tag = str_replace('_', ' ', $a[1]);
                    $skip++;
                } elseif (substr($part, 0, 8) == 'linksrc:') {
                    $a = explode(':', $part);
                    $link_src = $a[1];
                    if (!in_array($link_src, array('tn', 'disp', 'orig'))) {
                        $link_src = 'disp';
                    }
                    $skip++;
                } else {
                    break;
                }
            }
            if ($skip != 0) {
                if (count($px) > $skip) {
                    for ($i = 0; $i < $skip; $i++) {
                        array_shift($px);
                    }
                    $caption = trim(implode(' ', $px));
                } else {
                    $caption = '';
                }
            }
        } else {
            $caption = trim($autotag['parm2']);
        }
        if ($tag == '') {
            $tag = $caption;
        }
        if (!is_numeric($autotag['parm1'][0])) {
            switch ($autotag['parm1'][0]) {
                case 'n':
                    $align = '';
                    $aSet = 1;
                    break;
                case 'c':
                    $align = "center";
                    $aSet = 1;
                    break;
                case 'l':
                    $align = "left";
                    $aSet = 1;
                    break;
                case 'r':
                    $align = "right";
                    $aSet = 1;
                    break;
                case 'a':
                    $align = !($side_count % 2) ? "left" : "right";
                    $side_count++;
                    $aSet = 1;
                    break;
                default:
                    $align = !($side_count % 2) ? "left" : "right";
                    $side_count++;
                    break;
            }
            $parm1 = COM_applyFilter(substr($autotag['parm1'], 1, strlen($autotag['parm1']) - 1));
        } else {
            $parm1 = COM_applyFilter($autotag['parm1']);
            if ($aSet == 0 || $align == 'auto') {
                $align = !($side_count % 2) ? "left" : "right";
                $side_count++;
            }
        }
        if ($align == 'none') {
            $align = '';
        }
        if (!in_array($autotag['tag'], array('album', 'media', 'img', 'slideshow', 'fslideshow', 'video', 'audio', 'download', 'image', 'oimage', 'mlink', 'alink', 'playall'))) {
            return $content;
        }
        MG_initAlbums();
        // sanity check incase the album has been deleted or something...
        if ($autotag['tag'] != 'media' && $autotag['tag'] != 'image' && $autotag['tag'] != 'video' && $autotag['tag'] != 'audio' && $autotag['tag'] != 'download' && $autotag['tag'] != 'oimage' && $autotag['tag'] != 'img' && $autotag['tag'] != 'mlink' && $autotag['tag'] != 'alink' && $autotag['tag'] != 'playall') {
            if (!isset($MG_albums[$parm1]->id)) {
                $link = '';
                $content = str_replace($autotag['tagstr'], $link, $content);
                return $content;
            }
        }
        $ss_count = mt_rand(0, 32768);
        switch ($autotag['tag']) {
            case 'download':
                $side_count--;
                $sql = "SELECT ma.album_id FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'";
                $result = DB_query($sql);
                if (DB_numRows($result) > 0) {
                    $row = DB_fetchArray($result);
                    $aid = $row['album_id'];
                    if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) {
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                        return $content;
                    }
                    $link = '<a href="' . $_MG_CONF['site_url'] . '/download.php?mid=' . $parm1 . '">';
                    if ($caption != "") {
                        $link .= $caption;
                    } else {
                        $link .= 'download';
                    }
                    $link .= '</a>';
                    if ($destination != 'block') {
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    } else {
                        $autoTagCount = $mgAutoTagArray['count'];
                        $mgAutoTagArray['tags'][$autoTagCount] = $link;
                        $mgAutoTagArray['count']++;
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    }
                    return $content;
                } else {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                }
                break;
            case 'mlink':
                $side_count--;
                $sql = "SELECT m.remote_url,ma.album_id FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'";
                $result = DB_query($sql);
                if (DB_numRows($result) > 0) {
                    $row = DB_fetchArray($result);
                    $aid = $row['album_id'];
                    if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) {
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                        return $content;
                    }
                    if ($alt == 1 && $row['remote_url'] != '') {
                        $link = '<a href="' . $row['remote_url'] . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>';
                    } else {
                        $link = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0&amp;sort=0&amp;s=' . $parm1 . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>';
                    }
                    if ($caption != "") {
                        $link .= $caption;
                    } else {
                        $link .= $LANG_MG03['click_here'];
                    }
                    $link .= '</a>';
                    if ($destination != 'block') {
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    } else {
                        $autoTagCount = $mgAutoTagArray['count'];
                        $mgAutoTagArray['tags'][$autoTagCount] = $link;
                        $mgAutoTagArray['count']++;
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    }
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                } else {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                }
                break;
            case 'playall':
                if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0 || COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                }
                $V = new Template(MG_getTemplatePath(0));
                $V->set_file(array('xspf' => 'xspf_radio.thtml'));
                $V->set_var(array('aid' => $parm1, 'site_url' => $_MG_CONF['site_url'], 'autoplay' => $autoplay ? 'play' : 'stop', 'id' => 'mp3radio' . rand(), 'id2' => 'mp3radio' . rand()));
                $V->parse('output', 'xspf');
                if ($align != '' && $align != "center") {
                    $link = '<span style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                } else {
                    if ($align == "center") {
                        $link = '<span style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                    } else {
                        $link = '<span style="padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                    }
                }
                if ($destination != 'block') {
                    $content = str_replace($autotag['tagstr'], $link, $content);
                } else {
                    $autoTagCount = $mgAutoTagArray['count'];
                    $mgAutoTagArray['tags'][$autoTagCount] = $link;
                    $mgAutoTagArray['count']++;
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                }
                $content = str_replace($autotag['tagstr'], $link, $content);
                return $content;
                break;
            case 'video':
                $sql = "SELECT ma.album_id,m.media_id,m.mime_type,m.remote_url,m.media_filename,m.media_mime_ext,m.media_original_filename,m.media_tn_attached,m.media_resolution_x,m.media_resolution_y,m.remote_media FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'";
                $result = DB_query($sql);
                if (DB_numRows($result) > 0) {
                    $row = DB_fetchArray($result);
                    $aid = $row['album_id'];
                    if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) {
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                        return $content;
                    }
                    $meta_file_name = $_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
                    $meta = IMG_getMediaMetaData($meta_file_name);
                    if ($meta['mime_type'] == 'video/quicktime' || $meta['mime_type'] == 'video/mp4') {
                        if ($meta['fileformat'] == 'mp4') {
                            $row['mime_type'] = 'video/mp4';
                        }
                    }
                    // determine height / width and aspect
                    if (($width == 'auto' || $width == 0 || $width == -1 || $height == -1) && $row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0) {
                        $videoheight = $row['media_resolution_y'];
                        $videowidth = $row['media_resolution_x'];
                    } else {
                        if ($row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0) {
                            if ($row['media_resolution_x'] >= $row['media_resolution_y']) {
                                // landscape
                                $ratio = $row['media_resolution_y'] / $row['media_resolution_x'];
                                $orientation = 0;
                            } else {
                                // portrait
                                $ratio = $row['media_resolution_x'] / $row['media_resolution_y'];
                                $orientation = 1;
                            }
                        } else {
                            $ratio = 0.75;
                            $orientation = 0;
                        }
                        if ($orientation == 0) {
                            if ($width > 0 && $height == 0) {
                                $videoheight = round($width * $ratio);
                                $videowidth = $width;
                            } else {
                                if ($width == 0 && $height == 0) {
                                    $videoheight = 200 * $ratio;
                                    $videowidth = 200;
                                } else {
                                    if ($width == 0 && $height > 0) {
                                        $videowidth = round($height / $ratio);
                                        $videoheight = $height;
                                    } else {
                                        if ($width > 0 && $height > 0) {
                                            $videowidth = $width;
                                            $videoheight = $height;
                                        }
                                    }
                                }
                            }
                        } else {
                            if ($width > 0 && $height == 0) {
                                $videoheight = round($width / $ratio);
                                $videowidth = $width;
                            } else {
                                if ($width == 0 && $height == 0) {
                                    $videoheight = 200;
                                    $videowidth = round(200 / $ratio);
                                } else {
                                    if ($width == 0 && $height > 0) {
                                        $videowidth = round($height * $ratio);
                                        $videoheight = $height;
                                    } else {
                                        if ($width > 0 && $height > 0) {
                                            $videowidth = $width;
                                            $videoheight = $height;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    switch ($row['mime_type']) {
                        case 'embed':
                            if (preg_match("/vimeo/i", $row['remote_url'])) {
                                $vimeo = 'vimeo, ';
                            } else {
                                $vimeo = '';
                            }
                            if ($align != '' && $align != "center") {
                                $link = '<div class="js-video [' . $vimeo . 'widescreen] ' . $classes . '"><span style="float:' . $align . ';padding:5px;">' . $row['remote_url'] . '</span></div>';
                            } else {
                                if ($align == 'center') {
                                    $link = '<div class="js-video [' . $vimeo . 'widescreen] ' . $classes . '"><span style="text-align:center;padding:5px;">' . $row['remote_url'] . '</span></div>';
                                } else {
                                    $link = '<div class="js-video [' . $vimeo . 'widescreen] ' . $classes . '"><span style="padding:5px;">' . $row['remote_url'] . '</span></div>';
                                }
                            }
                            if ($destination != 'block') {
                                $content = str_replace($autotag['tagstr'], $link, $content);
                            } else {
                                $autoTagCount = $mgAutoTagArray['count'];
                                $mgAutoTagArray['tags'][$autoTagCount] = $link;
                                $mgAutoTagArray['count']++;
                                $link = '';
                                $content = str_replace($autotag['tagstr'], $link, $content);
                            }
                            return $content;
                            break;
                        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':
                            $V = new Template(MG_getTemplatePath(0));
                            $V->set_file('video', 'view_asf.thtml');
                            $V->set_var(array('autostart' => $autoplay ? 'true' : 'false', 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'false', 'showcontrols' => 'true', 'showdisplay' => 'false', 'height' => $videoheight, 'width' => $videowidth, 'bgcolor' => '#FFFFFF', 'playcount' => '9999', 'loop' => 'true', 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'], 'autostart0' => $autoplay ? '1' : '0', 'enablecontextmenu0' => '1', 'stretchtofit0' => '0', 'showstatusbar0' => '0', 'uimode0' => 'none', 'showcontrols0' => '1', 'showdisplay0' => '0'));
                            $V->parse('output', 'video');
                            if ($align != '' && $align != "center") {
                                $u_image = '<span style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                            } else {
                                if ($align == 'center') {
                                    $u_image = '<span style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                                } else {
                                    $u_image = '<span style="padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                                }
                            }
                            break;
                        case 'video/mp4':
                            if ($row['media_tn_attached'] == 1) {
                                $foundTN = 0;
                                foreach ($_MG_CONF['validExtensions'] as $ext) {
                                    if (file_exists($_MG_CONF['path_mediaobjects'] . '/orig/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) {
                                        $thumb = $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                                        $media_size_orig = $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . '/orig/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext);
                                        $foundTN = 1;
                                        break;
                                    }
                                }
                                if ($foundTN == 0) {
                                    foreach ($_MG_CONF['validExtensions'] as $ext) {
                                        if (file_exists($_MG_CONF['path_mediaobjects'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) {
                                            $thumb = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                                            $media_size_orig = $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext);
                                            break;
                                        }
                                    }
                                }
                            } else {
                                $thumb = '';
                                //$_MG_CONF['mediaobjects_url'] . '/video-placeholder.png';
                                //                                $thumb = $_MG_CONF['mediaobjects_url'].'/placeholder_video_w.svg';
                            }
                            $V = new Template(MG_getTemplatePath(0));
                            $V->set_file(array('video' => 'view_mp4.thtml'));
                            $V->set_var(array('mime_type' => 'video/mp4', 'autoref' => 'true', 'autoplay' => $autoplay ? 'true' : 'false', 'autoplay_text' => $autoplay ? ' autoplay ' : '', 'controller' => 'true', 'kioskmode' => 'true', 'scale' => 'aspect', 'height' => $videoheight, 'width' => $videowidth, 'bgcolor' => '#F0F0F0', 'loop' => 'true', 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'], 'thumbnail' => $thumb, 'site_url' => $_MG_CONF['site_url'], 'player_url' => $_CONF['site_url'] . '/javascript/addons/mediaplayer/'));
                            if ($align != '' && $align != "center") {
                                $V->set_var('alignment', 'float:' . $align . ';');
                            } else {
                                if ($align == 'center') {
                                    $V->set_var('alignment', 'text-align:center;');
                                } else {
                                    $V->set_var('alignment', 'text-align:center;');
                                }
                            }
                            $V->parse('output', 'video');
                            $u_image = $V->finish($V->get_var('output'));
                            break;
                        case 'video/mpeg':
                        case 'video/x-motion-jpeg':
                        case 'video/quicktime':
                        case 'video/mpeg':
                        case 'video/x-mpeg':
                        case 'video/x-mpeq2a':
                        case 'video/x-qtc':
                        case 'video/x-m4v':
                            $V = new Template(MG_getTemplatePath(0));
                            $V->set_file(array('video' => 'view_quicktime.thtml'));
                            $V->set_var(array('autoref' => 'true', 'autoplay' => $autoplay ? 'true' : 'false', 'controller' => 'true', 'kioskmode' => 'true', 'scale' => 'aspect', 'height' => $videoheight, 'width' => $videowidth, 'bgcolor' => '#F0F0F0', 'loop' => 'true', 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']));
                            $V->parse('output', 'video');
                            if ($align != '' && $align != "center") {
                                $u_image = '<div style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                            } else {
                                if ($align == 'center') {
                                    $u_image = '<div style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                                } else {
                                    $u_image = '<div style="padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                                }
                            }
                            break;
                        case 'application/x-shockwave-flash':
                            // 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='" . $row['media_id'] . "'");
                            while ($poRow = DB_fetchArray($poResult)) {
                                $playback_options[$poRow['option_name']] = $poRow['option_value'];
                            }
                            if ($swfjsinclude > 0) {
                                $u_image = '';
                            } else {
                                $S = new Template(MG_getTemplatePath(0));
                                $S->set_file(array('swf' => 'swfobject.thtml'));
                                $S->set_var(array('site_url' => $_MG_CONF['site_url']));
                                $S->parse('output', 'swf');
                                $u_image = $S->finish($S->get_var('output'));
                                $swfjsinclude++;
                            }
                            $V = new Template(MG_getTemplatePath(0));
                            $V->set_file(array('video' => 'view_swf.thtml'));
                            $V->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'play' => $autoplay ? 'true' : 'false', 'menu' => $playback_options['menu'] ? 'true' : 'false', 'loop' => $playback_options['loop'] ? 'true' : 'false', 'scale' => $playback_options['scale'], 'wmode' => $playback_options['wmode'], 'flashvars' => $playback_options['flashvars'], 'quality' => $playback_options['quality'], 'height' => $videoheight, 'width' => $videowidth, 'asa' => $playback_options['allowscriptaccess'], 'bgcolor' => $playback_options['bgcolor'], 'swf_version' => $playback_options['swf_version'], 'filename' => $row['media_original_filename'], 'id' => $row['media_filename'] . rand(), 'id2' => $row['media_filename'] . rand(), 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']));
                            $V->parse('output', 'video');
                            if ($align != '' && $align != "center") {
                                $u_image = '<div style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                            } else {
                                if ($align == "center") {
                                    $u_image = '<div style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                                } else {
                                    $u_image = '<div style="padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                                }
                            }
                            break;
                        case 'video/x-flv':
                            // 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='" . $row['media_id'] . "'");
                            while ($poRow = DB_fetchArray($poResult)) {
                                $playback_options[$poRow['option_name']] = $poRow['option_value'];
                            }
                            if ($swfjsinclude > 0) {
                                $u_image = '';
                            } else {
                                $S = new Template(MG_getTemplatePath(0));
                                $S->set_file(array('swf' => 'swfobject.thtml'));
                                $S->set_var(array('site_url' => $_MG_CONF['site_url']));
                                $S->parse('output', 'swf');
                                $u_image = $S->finish($S->get_var('output'));
                                $swfjsinclude++;
                            }
                            $V = new Template(MG_getTemplatePath(0));
                            $V->set_file('video', 'view_flv_light.thtml');
                            $playImage = MG_getImageFile('blank_blk.jpg');
                            // now the player specific items.
                            $F = new Template(MG_getTemplatePath(0));
                            $F->set_file(array('player' => 'flvfp.thtml'));
                            if ($autoplay == 1) {
                                // auto start
                                $playButton = '';
                            } else {
                                if ($row['media_tn_attached'] == 1) {
                                    foreach ($_MG_CONF['validExtensions'] as $ext) {
                                        if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) {
                                            $playImage = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                                            break;
                                        }
                                    }
                                }
                                $playButton = "{ url: '" . $playImage . "', overlayId: 'play' },";
                            }
                            if ($row['remote_media'] == 1) {
                                $urlParts = array();
                                $urlParts = parse_url($row['remote_url']);
                                $pathParts = array();
                                $pathParts = explode('/', $urlParts['path']);
                                $ppCount = count($pathParts);
                                $pPath = '';
                                for ($row = 1; $row < $ppCount - 1; $row++) {
                                    $pPath .= '/' . $pathParts[$row];
                                }
                                $videoFile = $pathParts[$ppCount - 1];
                                $pos = strrpos($videoFile, '.');
                                if ($pos === false) {
                                    $basefilename = $videoFile;
                                } else {
                                    $basefilename = substr($videoFile, 0, $pos);
                                }
                                $videoFile = $basefilename;
                                $streamingServerURL = "streamingServerURL: '" . $urlParts['scheme'] . '://' . $urlParts['host'] . $pPath . "',";
                                $streamingServer = "streamingServer: 'fms',";
                            } else {
                                $streamingServerURL = '';
                                $streamingServer = '';
                                $videoFile = urlencode($_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']);
                            }
                            $width = $videowidth;
                            $height = $videoheight + 22;
                            $resolution_x = $videowidth;
                            $resolution_y = $videoheight;
                            $id = 'id_' . rand();
                            $id2 = 'id2_' . rand();
                            $F->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'play' => $autoplay ? 'true' : 'false', 'menu' => $playback_options['menu'] ? 'true' : 'false', 'loop' => $playback_options['loop'] ? 'true' : 'false', 'scale' => $playback_options['scale'], 'wmode' => $playback_options['wmode'], 'width' => $width, 'height' => $height, 'streamingServerURL' => $streamingServerURL, 'streamingServer' => $streamingServer, 'videoFile' => $videoFile, 'playButton' => $playButton, 'id' => $id, 'id2' => $id2, 'resolution_x' => $resolution_x, 'resolution_y' => $resolution_y));
                            $F->parse('output', 'player');
                            $flv_player = $F->finish($F->get_var('output'));
                            $V->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'id' => $id, 'id2' => $id2, 'width' => $resolution_x, 'height' => $resolution_y, 'flv_player' => $flv_player));
                            $V->parse('output', 'video');
                            if ($align != '' && $align != "center") {
                                $u_image .= '<span class="' . $classes . '" style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                            } else {
                                if ($align == "center") {
                                    $u_image .= '<span class="' . $classes . '" style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                                } else {
                                    $u_image .= '<span class="' . $classes . '" style="padding:5px;">' . $V->finish($V->get_var('output')) . '</span>';
                                }
                            }
                            break;
                    }
                    $link = $u_image;
                    if ($destination != 'block') {
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    } else {
                        $autoTagCount = $mgAutoTagArray['count'];
                        $mgAutoTagArray['tags'][$autoTagCount] = $link;
                        $mgAutoTagArray['count']++;
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    }
                    return $content;
                } else {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                }
                break;
            case 'audio':
                $sql = "SELECT ma.album_id,m.media_title,m.mime_type,m.media_tn_attached,m.media_filename,m.media_mime_ext FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'";
                $result = DB_query($sql);
                if (DB_numRows($result) > 0) {
                    $row = DB_fetchArray($result);
                    $aid = $row['album_id'];
                    if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) {
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                        return $content;
                    }
                    switch ($row['mime_type']) {
                        case 'audio/mpeg':
                            $playback_options['height'] = 50;
                            $playback_options['width'] = 300;
                            $V = new Template(MG_getTemplatePath(0));
                            if ($mp3_type == 'ribbon') {
                                $tfile = 'mp3_podcast.thtml';
                            } else {
                                $tfile = 'view_mp3_flv.thtml';
                            }
                            $autostart = $autoplay ? 'play' : 'stop';
                            if ($row['media_tn_attached'] == 1) {
                                foreach ($_MG_CONF['validExtensions'] as $ext) {
                                    if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) {
                                        $u_tn = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                                        $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext);
                                        break;
                                    }
                                }
                                $border_width = $media_size_disp[0] + 15;
                                $u_pic = '<img src="' . $u_tn . '" alt="" style="border:none;" />';
                                $playback_options['width'] = 200;
                            } else {
                                $u_pic = '';
                                $playback_options['width'] = 200;
                            }
                            $V->set_file(array('audio' => $tfile));
                            $V->set_var(array('autostart' => $autostart, 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'true', 'uimode' => 'mini', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => '#FFFFFF', 'loop' => 'true', 'u_pic' => $u_pic, 'title' => urlencode($row['media_title']), 'id' => 'mp3' . rand(), 'id2' => 'mp3' . rand(), 'site_url' => $_MG_CONF['site_url'], 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'], 'mp3_file' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']));
                            $V->parse('output', 'audio');
                            if ($align != '' && $align != "center") {
                                $u_image = '<span style="float:' . $align . ';padding:5px;text-align:center;">' . $V->finish($V->get_var('output')) . '</span>';
                            } else {
                                if ($align == "center") {
                                    $u_image = '<span style="text-align:center;padding:5px;text-align:center;">' . $V->finish($V->get_var('output')) . '</span>';
                                } else {
                                    $u_image = '<span style="padding:5px;text-align:center;">' . $V->finish($V->get_var('output')) . '</span>';
                                }
                            }
                            break;
                        case 'audio/x-ms-wma':
                        case 'audio/x-ms-wax':
                        case 'audio/x-ms-wmv':
                            $playback_options['height'] = 50;
                            $playback_options['width'] = 300;
                            $V = new Template(MG_getTemplatePath(0));
                            $tfile = 'view_mp3_wmp.thtml';
                            $autostart = $autoplay ? '1' : '0';
                            if ($row['media_tn_attached'] == 1) {
                                foreach ($_MG_CONF['validExtensions'] as $ext) {
                                    if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) {
                                        $u_tn = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                                        $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext);
                                        break;
                                    }
                                }
                                $border_width = $media_size_disp[0] + 15;
                                $u_pic = '<div class=out style="width:' . $border_width . 'px"><div class="in ltin tpin"><img src="' . $u_tn . '" alt="" /></div></div>';
                                $playback_options['height'] = 50;
                                $playback_options['width'] = 200;
                            } else {
                                $u_pic = '';
                                $playback_options['height'] = 50;
                                $playback_options['width'] = 200;
                            }
                            $V->set_file(array('audio' => $tfile));
                            $V->set_var(array('autostart' => $autostart, 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'true', 'uimode' => 'mini', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => '#FFFFFF', 'loop' => 'true', 'u_pic' => $u_pic, 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']));
                            $V->parse('output', 'audio');
                            if ($align != '' && $align != "center") {
                                $u_image = '<div class="' . $classes . '" style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                            } else {
                                if ($align == "center") {
                                    $u_image = '<div class="' . $classes . '" style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                                } else {
                                    $u_image = '<div class="' . $classes . '" style="padding:5px;">' . $V->finish($V->get_var('output')) . '</div>';
                                }
                            }
                            break;
                    }
                    $link = $u_image;
                    if ($destination != 'block') {
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    } else {
                        $autoTagCount = $mgAutoTagArray['count'];
                        $mgAutoTagArray['tags'][$autoTagCount] = $link;
                        $mgAutoTagArray['count']++;
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    }
                    return $content;
                } else {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                }
                break;
            case 'fslideshow':
                if ($parm1 == '' || $parm1 == 0) {
                    return $content;
                }
                $aid = $parm1;
                if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0) {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                }
                if ($width > 0 && $height == 0) {
                    $height = $width * 0.75;
                } else {
                    if ($width == 0 && $height == 0) {
                        $height = $width = 200;
                    } else {
                        if ($width == 0 && $height > 0) {
                            $width = $height * 1.3333;
                        }
                    }
                }
                // if none of the above, assume height and width both specified.
                if ($caption == '' && $_MG_CONF['autotag_caption'] && isset($aid)) {
                    $caption = $MG_albums[$aid]->title;
                }
                $captionHTML = '<br /><span style="width:' . $width . 'px;font-style:italic;font-size: smaller;text-indent:0;">' . $caption . '</span>' . LB;
                $ss_count++;
                $T = new Template(MG_getTemplatePath(0));
                $T->set_file(array('fslideshow' => 'fsat.thtml'));
                $T->set_var(array('site_url' => $_MG_CONF['site_url']));
                $T->set_var(array('id' => 'mms' . $ss_count, 'id2' => 'fsid' . $ss_count, 'movie' => $_MG_CONF['site_url'] . '/xml.php?aid=' . $parm1 . '%26src=' . trim($src), 'dropshadow' => 'true', 'delay' => $delay, 'nolink' => $MG_albums[$parm1]->hidden || $enable_link == 0 ? 'true' : 'false', 'showtitle' => $showtitle == 'bottom' || $showtitle == 'top' ? '&showTitle=' . $showtitle : '', 'width' => $width, 'height' => $height));
                $T->parse('output', 'fslideshow');
                $swfobject = $T->finish($T->get_var('output'));
                $link = $swfobject . $captionHTML;
                if ($align != '' && $align != "center") {
                    $link = '<span class="' . $classes . '" style="float:' . $align . ';padding:5px;text-align:center;">' . $link . '</span>';
                } else {
                    if ($align == "center") {
                        $link = '<center><span class="' . $classes . '" style="padding:5px;text-align:center;">' . $link . '</span></center>';
                    } else {
                        $link = '<span class="' . $classes . '" style="padding:5px;text-align:center;">' . $link . '</span>';
                    }
                }
                if ($destination != 'block') {
                    $content = str_replace($autotag['tagstr'], $link, $content);
                } else {
                    $autoTagCount = $mgAutoTagArray['count'];
                    $mgAutoTagArray['tags'][$autoTagCount] = $link;
                    $mgAutoTagArray['count']++;
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                }
                return $content;
                break;
            case 'slideshow':
                if ($parm1 == '' || $parm1 == 0) {
                    return $content;
                }
                if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0) {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                }
                if ($caption == '' && $_MG_CONF['autotag_caption']) {
                    $caption = $MG_albums[$parm1]->title;
                }
                $T->set_file(array('tag' => 'autotag_ss.thtml'));
                $aid = $parm1;
                $pics = '';
                $counter = 0;
                $maxwidth = 0;
                $maxheight = 0;
                $ss_count++;
                $sql = "SELECT m.media_filename,m.media_mime_ext,m.remote_url 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='" . DB_escapeString($aid) . "' AND m.media_type=0 AND m.include_ss=1 ORDER BY ma.media_order DESC";
                $result = DB_query($sql);
                $T->set_block('tag', 'slides', 'ss');
                while ($row = DB_fetchArray($result)) {
                    switch ($src) {
                        case 'orig':
                            $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']);
                            $ext = $row['media_mime_ext'];
                            break;
                        case 'disp':
                            foreach ($_MG_CONF['validExtensions'] as $tnext) {
                                if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $tnext)) {
                                    $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $tnext);
                                    $ext = substr($tnext, 1, 3);
                                    break;
                                }
                            }
                            break;
                        default:
                            foreach ($_MG_CONF['validExtensions'] as $tnext) {
                                if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $tnext)) {
                                    $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $tnext);
                                    $ext = substr($tnext, 1, 3);
                                    break;
                                }
                            }
                            $src = 'tn';
                            break;
                    }
                    if ($media_size == false) {
                        continue;
                    }
                    $counter++;
                    if ($width > 0 && $height == 0) {
                        if ($media_size[0] > $media_size[1]) {
                            // landscape
                            $ratio = $media_size[0] / $width;
                            $newwidth = $width;
                            $newheight = round($media_size[1] / $ratio);
                        } else {
                            // portrait
                            $ratio = $media_size[1] / $width;
                            $newheight = $width;
                            $newwidth = round($media_size[0] / $ratio);
                        }
                    } else {
                        if ($width == 0 && $height == 0) {
                            if ($media_size[0] > $media_size[1]) {
                                // landscape
                                $ratio = $media_size[0] / 200;
                                $newwidth = 200;
                                $newheight = round($media_size[1] / $ratio);
                            } else {
                                // portrait
                                $ratio = $media_size[1] / 200;
                                $newheight = 200;
                                $newwidth = round($media_size[0] / $ratio);
                            }
                        } else {
                            if ($width == 0 && $height > 0) {
                                if ($height > $media_size[1]) {
                                    $newheight = $media_size[1];
                                    $newwidth = $media_size[0];
                                } else {
                                    $ratio = $height / $media_size[1];
                                    $newheight = $height;
                                    $newwidth = round($media_size[0] * $ratio);
                                }
                            } else {
                                $newwidth = $width;
                                $newheight = $height;
                            }
                        }
                    }
                    if ($newheight > $maxheight) {
                        $maxheight = $newheight;
                    }
                    if ($newwidth > $maxwidth) {
                        $maxwidth = $newwidth;
                    }
                    $active = '';
                    if ($counter == 1) {
                        $active = ' active ';
                    }
                    if ($MG_albums[$parm1]->hidden == 1 || $enable_link == 0) {
                        $pics .= '<img class="slideshowThumbnail' . $ss_count . $active . ' ' . $classes . '" src="' . $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext . '" alt="" style="width:' . $newwidth . 'px;height:' . $newheight . 'px;border:none;position:absolute;left:0px;top:0px;" />' . LB;
                    } else {
                        $pics .= '<img class="slideshowThumbnail' . $ss_count . $active . ' ' . $classes . '". src="' . $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext . '" alt="" style="width:' . $newwidth . 'px;height:' . $newheight . 'px;border:none;position:absolute;left:0px;top:0px;" />' . LB;
                    }
                    $T->set_var(array('img_url' => $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext, 'img_width' => $newwidth, 'img_height' => $newheight));
                    $T->parse('ss', 'slides', true);
                }
                if ($delay <= 0) {
                    $delay = 10;
                }
                if ($MG_albums[$parm1]->hidden == 1 || $enable_link == 0) {
                    $ss_url = '';
                } else {
                    $ss_url = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>';
                    $ss_url = $_MG_CONF['site_url'] . '/album.php?aid=' . $aid;
                }
                if ($counter != 0) {
                    $T->set_var(array('align' => $align, 'pics' => $pics, 'caption' => $caption, 'maxheight' => $maxheight, 'maxwidth' => $maxwidth, 'width' => $maxwidth, 'framewidth' => $maxwidth + 10, 'ss_count' => $ss_count, 'delay' => $delay * 1000, 'border' => $border ? 'border: silver solid;border-width: 1px;' : '', 'sslink' => $ss_url));
                    if ($align == 'left' || $align == 'right') {
                        $T->set_var('float', 'float: ' . $align . ';');
                    } else {
                        $T->set_var('float', 'float:left;');
                        $align = 'left';
                    }
                    if ($align == 'left') {
                        $T->set_var('margin-right', 'margin-right:15px;');
                    } else {
                        $T->set_var('margin-right', '');
                    }
                    $T->parse('output', 'tag');
                    $link = $T->finish($T->get_var('output'));
                } else {
                    $link = '';
                }
                if ($destination != 'block') {
                    $content = str_replace($autotag['tagstr'], $link, $content);
                } else {
                    $autoTagCount = $mgAutoTagArray['count'];
                    $mgAutoTagArray['tags'][$autoTagCount] = $link;
                    $mgAutoTagArray['count']++;
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                }
                return $content;
                break;
            case 'album':
                if ($parm1 == '' || $parm1 == 0) {
                    $side_count--;
                    return $content;
                }
                if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0) {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    $side_count--;
                    return $content;
                }
                $ss_count++;
                if ($border == 0) {
                    $T->set_file(array('tag' => 'autotag_nb.thtml'));
                } else {
                    $T->set_file(array('tag' => 'autotag.thtml'));
                }
                if ($tag != '') {
                    $alttag = ' alt="' . $tag . '" title="' . $tag . '"';
                } else {
                    $alttag = ' alt=""';
                    if ($_MG_CONF['autotag_caption']) {
                        $caption = $MG_albums[$parm1]->title;
                    }
                }
                $aid = $parm1;
                if ($MG_albums[$parm1]->tn_attached == 1) {
                    foreach ($_MG_CONF['validExtensions'] as $ext) {
                        if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $parm1 . $ext)) {
                            $tnImage = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $parm1 . $ext;
                            $tnFileName = $_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $parm1 . $ext;
                            break;
                        }
                    }
                } else {
                    $filename = $MG_albums[$aid]->findCover();
                    if ($filename != '') {
                        foreach ($_MG_CONF['validExtensions'] as $ext) {
                            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) {
                                $tnImage = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext;
                                $tnFileName = $_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext;
                                break;
                            }
                        }
                    } else {
                        $tnImage = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                        $tnFileName = $_MG_CONF['path_mediaobjects'] . 'placeholder.svg';
                    }
                }
                $media_size = @getimagesize($tnFileName);
                if ($media_size == false) {
                    $tnImage = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg';
                    $tnFileName = $_MG_CONF['path_mediaobjects'] . 'placeholder.svg';
                    $media_size = array(200, 200);
                }
                if ($width > 0 && $height == 0) {
                    $ratio = $media_size[0] / $width;
                    $newwidth = $width;
                    $newheight = round($media_size[1] / $ratio);
                } else {
                    if ($width == 0 && $height == 0) {
                        if ($media_size[0] > $media_size[1]) {
                            // landscape
                            $ratio = $media_size[0] / 200;
                            $newwidth = 200;
                            $newheight = round($media_size[1] / $ratio);
                        } else {
                            // portrait
                            $ratio = $media_size[1] / 200;
                            $newheight = 200;
                            $newwidth = round($media_size[0] / $ratio);
                        }
                    } else {
                        if ($width == 0 && $height > 0) {
                            $ratio = $height / $media_size[1];
                            $newheight = $height;
                            $newwidth = round($media_size[0] * $ratio);
                        } else {
                            $newwidth = $width;
                            $newheight = $height;
                        }
                    }
                }
                $album_image = '<img src="' . $tnImage . '" ' . $alttag . ' style="';
                if ($nosize == 0 && $height != -1 && $width != -1) {
                    $album_image .= 'width:' . $newwidth . 'px;height:' . $newheight . 'px;';
                }
                $album_image .= 'border:none;" />';
                $tagtext = $album_image;
                if ($linkID == 0) {
                    $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $parm1;
                } else {
                    if ($linkID < 1000000) {
                        $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $linkID;
                    } else {
                        $url = $_MG_CONF['site_url'] . '/media.php?s=' . $linkID;
                    }
                }
                if ($enable_link == 0) {
                    $link = $tagtext;
                } else {
                    $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                }
                $T->set_var(array('ss_count' => $ss_count, 'align' => $align, 'autotag' => $link, 'caption' => $caption, 'width' => $newwidth, 'framewidth' => $newwidth + 10));
                if ($align == 'left' || $align == 'right') {
                    $T->set_var('float', 'float:' . $align . ';');
                } else {
                    $T->set_var('float', '');
                }
                if ($align == 'left') {
                    $T->set_var('margin-right', 'margin-right:15px;');
                } else {
                    $T->set_var('margin-right', '');
                }
                $T->parse('output', 'tag');
                $link = $T->finish($T->get_var('output'));
                if ($align == 'center') {
                    $link = '<center>' . $link . '</center>';
                }
                if ($destination != 'block') {
                    $content = str_replace($autotag['tagstr'], $link, $content);
                } else {
                    $autoTagCount = $mgAutoTagArray['count'];
                    $mgAutoTagArray['tags'][$autoTagCount] = $link;
                    $mgAutoTagArray['count']++;
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                }
                return $content;
                break;
            case 'alink':
                if ($parm1 == '' || $parm1 == 0) {
                    $side_count--;
                    return $content;
                }
                if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0) {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    $side_count--;
                    return $content;
                }
                if ($caption == '') {
                    $caption = $MG_albums[$parm1]->title;
                }
                $link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$parm1]->id . '">' . $caption . '</a>';
                $content = str_replace($autotag['tagstr'], $link, $content);
                return $content;
                break;
            case 'media':
                /* image, oimage and img are depreciated */
            /* image, oimage and img are depreciated */
            case 'image':
            case 'oimage':
            case 'img':
                if ($parm1 == '' || $parm1 == 0) {
                    return $content;
                }
                $direct_link = '';
                $ss_count++;
                if ($border == 0) {
                    $T->set_file(array('tag' => 'autotag_nb.thtml'));
                } else {
                    $T->set_file(array('tag' => 'autotag.thtml'));
                }
                if ($tag != '') {
                    $alttag = ' alt="' . $tag . '" title="' . $tag . '"';
                } else {
                    $alttag = ' alt=""';
                }
                $sql = "SELECT ma.album_id,m.media_title,m.media_type,m.media_filename,m.media_mime_ext,m.mime_type,m.media_tn_attached,m.remote_url FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'";
                $result = DB_query($sql);
                if (DB_numRows($result) > 0) {
                    $row = DB_fetchArray($result);
                    $aid = $row['album_id'];
                    if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) {
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                        return $content;
                    }
                    if ($caption == '' && $_MG_CONF['autotag_caption']) {
                        $caption = $row['media_title'];
                    }
                    switch ($row['media_type']) {
                        case 0:
                            // standard image
                            if ($autotag['tag'] == 'oimage') {
                                if ($_MG_CONF['discard_originals'] == 1) {
                                    $default_thumbnail = 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
                                } else {
                                    $default_thumbnail = 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
                                }
                            } else {
                                switch ($src) {
                                    case 'orig':
                                        if ($_MG_CONF['discard_originals'] == 1) {
                                            $default_thumbnail = 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
                                        } else {
                                            $default_thumbnail = 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
                                        }
                                        break;
                                    case 'disp':
                                        $default_thumbnail = 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'];
                                        break;
                                    case 'tn':
                                        foreach ($_MG_CONF['validExtensions'] as $ext) {
                                            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) {
                                                $default_thumbnail = 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext;
                                                break;
                                            }
                                        }
                                        break;
                                    default:
                                        foreach ($_MG_CONF['validExtensions'] as $ext) {
                                            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) {
                                                $default_thumbnail = 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext;
                                                break;
                                            }
                                        }
                                        break;
                                }
                                foreach ($_MG_CONF['validExtensions'] as $ext) {
                                    if (file_exists($_MG_CONF['path_mediaobjects'] . $link_src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) {
                                        $direct_link = $_MG_CONF['mediaobjects_url'] . '/' . $link_src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext;
                                        break;
                                    }
                                }
                            }
                            break;
                        case 1:
                            // video file
                            switch ($row['mime_type']) {
                                case 'application/x-shockwave-flash':
                                    $default_thumbnail = 'flash.png';
                                    break;
                                case 'video/quicktime':
                                case 'video/mpeg':
                                case 'video/x-m4v':
                                    $default_thumbnail = 'quicktime.png';
                                    break;
                                case 'video/x-ms-asf':
                                case 'video/x-ms-wvx':
                                case 'video/x-ms-wm':
                                case 'video/x-ms-wmx':
                                case 'video/x-msvideo':
                                case 'application/x-ms-wmz':
                                case 'application/x-ms-wmd':
                                    $default_thumbnail = 'wmp.png';
                                    break;
                                default:
                                    $default_thumbnail = 'video.png';
                                    break;
                            }
                            $src = 'tn';
                            break;
                        case 2:
                            // music file
                            $src = 'tn';
                            $default_thumbnail = 'audio.png';
                            break;
                    }
                    if ($row['media_tn_attached'] == 1 && ($src != 'orig' && $src != 'disp')) {
                        foreach ($_MG_CONF['validExtensions'] as $ext) {
                            if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) {
                                $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                                $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                                break;
                            }
                        }
                    } else {
                        $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail;
                        $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail;
                    }
                    if ($autotag['tag'] == 'img') {
                        if ($align != '' && $align != 'center') {
                            $album_image = '<span class="' . $classes . '" style="float:' . $align . ';padding:5px;"><img src="' . $media_thumbnail . '" ' . $alttag . 'style="border:none;" /></span>';
                        } else {
                            $album_image = '<img class="' . $classes . '" src="' . $media_thumbnail . '" ' . $alttag . 'style="border:none;" />';
                        }
                    } else {
                        $album_image = '<img class="' . $classes . '" src="' . $media_thumbnail . '" ' . $alttag . 'style="border:none;" />';
                    }
                } else {
                    return $content;
                    // no image found
                }
                $mediaSize = @getimagesize($media_thumbnail_file);
                if ($mediaSize == false) {
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                    return $content;
                }
                if ($autotag['tag'] == 'oimage' || $src == 'orig') {
                    $newwidth = $mediaSize[0];
                    $newheight = $mediaSize[1];
                } else {
                    if ($width > 0) {
                        $tn_height = $width;
                    } else {
                        switch ($src) {
                            case 'orig':
                                $tn_height = $mediaSize[0];
                                break;
                            case 'disp':
                                $tn_height = $mediaSize[0];
                                break;
                            case 'tn':
                                $tn_height = 200;
                                break;
                            default:
                                $tn_height = 200;
                                break;
                        }
                    }
                    if ($mediaSize[0] > $mediaSize[1]) {
                        $ratio = $mediaSize[0] / $tn_height;
                        $newwidth = $tn_height;
                        $newheight = round($mediaSize[1] / $ratio);
                    } else {
                        $ratio = $mediaSize[1] / $tn_height;
                        $newheight = $tn_height;
                        $newwidth = round($mediaSize[0] / $ratio);
                    }
                }
                $album_image = '<img class="' . $classes . '" src="' . $media_thumbnail . '" ' . $alttag . ' style=';
                if ($nosize == 0 && $height != -1 && $width != -1) {
                    $album_image .= '"width:' . $newwidth . 'px;height:' . $newheight . 'px;';
                }
                $album_image .= 'border:none;" />';
                $tagtext = $album_image;
                $link = '';
                if ($alt == 1 && $row['remote_url'] != '') {
                    $url = $row['remote_url'];
                    if ($autotag['tag'] != 'image' && $enable_link != 0) {
                        $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                    } else {
                        $link = $tagtext;
                    }
                } else {
                    if ($linkID == 0) {
                        $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1;
                    } else {
                        if ($linkID < 1000000) {
                            if (isset($MG_albums[$linkID]->id)) {
                                $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $linkID;
                                if ($autotag['tag'] != 'image' && $MG_albums[$linkID]->hidden != 1 && $enable_link != 0) {
                                    $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                                } else {
                                    $link = $tagtext;
                                }
                            } else {
                                $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1;
                            }
                        } else {
                            $linkAID = (int) DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($linkID) . '"');
                            if ($linkAID != 0) {
                                $url = $_MG_CONF['site_url'] . '/media.php?s=' . $linkID;
                                if ($autotag['tag'] != 'image' && $MG_albums[$linkAID]->hidden != 1 && $enable_link != 0) {
                                    $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                                } else {
                                    $link = $tagtext;
                                }
                            } else {
                                $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1;
                            }
                        }
                    }
                }
                if ($link == '') {
                    if ($autotag['tag'] != 'image' && ($MG_albums[$aid]->hidden != 1 || $enable_link == 2) && $enable_link != 0) {
                        if ($enable_link == 2 && $direct_link != '') {
                            if ($_MG_CONF['disable_lightbox'] == true) {
                                $link = $tagtext;
                            } else {
                                $link = '<a href="' . $direct_link . '" rel="lightbox" data-uk-lightbox title="' . strip_tags(str_replace('$', '&#36;', $caption)) . '">' . $tagtext . '</a>';
                            }
                        } else {
                            $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>';
                        }
                    } else {
                        $link = $tagtext;
                    }
                }
                if ($autotag['tag'] == 'img') {
                    if ($align != '' && $align != 'center') {
                        $link = '<span class="' . $classes . '" style="float:' . $align . ';padding:5px;">' . $link . '</span>';
                    }
                    if ($destination != 'block') {
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    } else {
                        $autoTagCount = $mgAutoTagArray['count'];
                        $mgAutoTagArray['tags'][$autoTagCount] = $link;
                        $mgAutoTagArray['count']++;
                        $link = '';
                        $content = str_replace($autotag['tagstr'], $link, $content);
                    }
                    return $content;
                }
                $T->set_var(array('ss_count' => $ss_count, 'align' => $align, 'autotag' => $link, 'caption' => $caption, 'width' => $newwidth, 'framewidth' => $newwidth + 10));
                if ($align == 'left' || $align == 'right') {
                    $T->set_var('float', 'float:' . $align . ';');
                } else {
                    $T->set_var('float', '');
                }
                if ($align == 'left') {
                    $T->set_var('margin-right', 'margin-right:15px;');
                } else {
                    $T->set_var('margin-right', '');
                }
                $T->parse('output', 'tag');
                $link = $T->finish($T->get_var('output'));
                if ($align == 'center') {
                    $link = '<center>' . $link . '</center>';
                }
                if ($destination != 'block') {
                    $content = str_replace($autotag['tagstr'], $link, $content);
                } else {
                    $autoTagCount = $mgAutoTagArray['count'];
                    $mgAutoTagArray['tags'][$autoTagCount] = $link;
                    $mgAutoTagArray['count']++;
                    $link = '';
                    $content = str_replace($autotag['tagstr'], $link, $content);
                }
                return $content;
                break;
        }
    }
}
Beispiel #19
0
    $mode = COM_applyFilter($_POST['mode']);
    $bquota = COM_applyFilter($_POST['bquota'], true);
    $bquota = $bquota * 1048576;
    $numItems = count($_POST['uid']);
    for ($i = 0; $i < $numItems; $i++) {
        DB_change($_TABLES['mg_userprefs'], 'quota', $bquota, 'uid', $_POST['uid'][$i]);
        if (DB_error()) {
            $sql = "INSERT INTO {$_TABLES['mg_userprefs']} (uid, active, display_rows, display_columns, mp3_player, playback_mode, tn_size, quota, member_gallery) " . "VALUES (" . $uid . ",1,0,0,-1,-1,-1," . $bquota . ",0)";
            DB_query($sql, 1);
        }
    }
}
$page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0;
if ($page <= 0) {
    $page = 0;
} else {
    $page--;
}
$quota = isset($_POST['quota']) ? COM_applyFilter($_POST['quota'], true) : 0;
$used = isset($_POST['used']) ? COM_applyFilter($_POST['used'], true) : 0;
$T = new Template($_MG_CONF['template_path']);
$T->set_file('admin', 'administration.thtml');
$T->set_var(array('site_admin_url' => $_MG_CONF['admin_url'], 'site_url' => $_MG_CONF['site_url'], 'lang_admin' => $LANG_MG00['admin'], 'xhtml' => XHTML));
$T->set_var(array('admin_body' => MG_quotaReport($page, $quota, $used), 'title' => $LANG_MG01['quota_report'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" border="0" alt="?">', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Member_Album_User_list'));
$T->parse('output', 'admin');
$display = COM_startBlock($LANG_MG00['admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
$display .= MG_showAdminMenu('member_albums');
$display .= $T->finish($T->get_var('output'));
$display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
$display = COM_createHTMLDocument($display, array('pagetitle' => $LANG_MG01['quota_report']));
COM_output($display);
Beispiel #20
0
}
/**
* Main
*/
$mode = isset($_REQUEST['mode']) ? COM_applyFilter($_REQUEST['mode']) : '';
$display = '';
$mode = '';
if (isset($_POST['mode'])) {
    $mode = $_POST['mode'];
} else {
    if (isset($_GET['mode'])) {
        $mode = $_GET['mode'];
    }
}
$T = new Template($_MG_CONF['template_path'] . '/admin');
$T->set_file(array('admin' => 'administration.thtml'));
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'mg_navigation' => MG_navigation(), 'lang_admin' => $LANG_MG00['admin'], 'version' => $_MG_CONF['pi_version']));
if ($mode == $LANG_MG01['save'] && !empty($LANG_MG01['save'])) {
    $T->set_var(array('admin_body' => MG_staticSortMediaSave(), 'mg_navigation' => MG_navigation()));
} elseif ($mode == $LANG_MG01['cancel']) {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    $T->set_var(array('admin_body' => MG_staticSortMediaOptions(), 'title' => $LANG_MG01['static_sort_media'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" border="0" alt="?">', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Static_Sort_Media'));
}
$T->parse('output', 'admin');
$display = COM_siteHeader();
$display .= $T->finish($T->get_var('output'));
$display .= COM_siteFooter();
echo $display;
exit;
Beispiel #21
0
$start = $page * $media_per_page;
$current_print_page = floor($start / $media_per_page) + 1;
if ($current_print_page == 0) {
    $current_print_page = 1;
}
$total_print_pages = $total_pages;
if ($total_print_pages == 0) {
    $total_print_pages = 1;
}
$birdseed = MG_getBirdseed(0, 0, 0, $total_print_pages);
$ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($root_album->owner_id));
$album_last_update = MG_getUserDateTimeFormat($root_album->last_update);
$pagination = COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, $total_pages);
$rsslink = '';
if ($_MG_CONF['rss_full_enabled']) {
    $rsslink = COM_createLink(COM_createImage(MG_getImageFile('feed.png'), '', array('class' => 'mg_rssimg')), MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'), array('type' => 'application/rss+xml'));
}
$T = COM_newTemplate(MG_getTemplatePath_byName($root_album->skin));
$T->set_file('page', 'album_page.thtml');
$T->set_var(array('site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'album_title' => PLG_replaceTags($root_album->title), 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => $pagination, 'bottom_pagination' => $pagination, 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => MG_buildAlbumJumpbox($root_album, $album_id, 1, -1), 'album_id' => $album_id, 'album_description' => $root_album->display_album_desc ? PLG_replaceTags($root_album->description) : '', 'album_id_display' => $root_album->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => COM_isAnonUser() ? '' : MG_buildAdminbox($root_album), 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $root_album->getMediaCount(), 'lang_menulabel' => $LANG_MG03['menulabel'], 'lang_search' => $LANG_MG01['search'], 'rsslink' => $rsslink, 'list_title' => $LANG_MG03['list_title'], 'list_desc' => $LANG_MG03['list_desc'], 'list_size' => $LANG_MG03['list_size'], 'list_user' => $LANG_MG03['list_user'], 'list_updated' => $LANG_MG03['list_updated']));
// completed setting header / footer vars, parse them
PLG_templateSetVars('mediagallery', $T);
// main processing of the album contents.
if ($total_media > 0) {
    $k = 0;
    $col = 0;
    $T->set_block('page', 'ImageColumn', 'IColumn');
    $T->set_block('page', 'ImageRow', 'IRow');
    for ($i = 0; $i < $media_per_page; $i += $columns_per_page) {
        $next_columns = $i + $columns_per_page;
        for ($j = $i; $j < $next_columns; $j++) {
Beispiel #22
0
    $retval .= $T->finish($T->parse('output', 'admin'));
    return $retval;
}
/**
* Main
*/
$mode = '';
if (isset($_POST['mode'])) {
    $mode = COM_applyFilter($_POST['mode']);
} else {
    if (isset($_GET['mode'])) {
        $mode = COM_applyFilter($_GET['mode']);
    }
}
$T = new Template($_MG_CONF['template_path']);
$T->set_file('admin', 'administration.thtml');
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'lang_admin' => $LANG_MG00['admin'], 'xhtml' => XHTML));
if ($mode == $LANG_MG01['submit'] && !empty($LANG_MG01['submit'])) {
    $T->set_var(array('admin_body' => MG_usageReport(), 'title' => $LANG_MG01['usage_reports']));
} elseif ($mode == $LANG_MG01['cancel']) {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    $T->set_var(array('admin_body' => MG_usageReportMenu(), 'title' => $LANG_MG01['usage_reports'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"' . XHTML . '>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Usage_Reports'));
}
$display = COM_startBlock($LANG_MG00['admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
$display .= MG_showAdminMenu('miscellaneous');
$display .= $T->finish($T->parse('output', 'admin'));
$display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
$display = COM_createHTMLDocument($display);
COM_output($display);
Beispiel #23
0
/**
* Main
*/
$mode = isset($_REQUEST['mode']) ? COM_applyFilter($_REQUEST['mode']) : '';
$display = '';
$mode = '';
if (isset($_POST['mode'])) {
    $mode = $_POST['mode'];
} else {
    if (isset($_GET['mode'])) {
        $mode = $_GET['mode'];
    }
}
$T = new Template($_MG_CONF['template_path'] . '/admin');
$T->set_file(array('admin' => 'administration.thtml'));
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'mg_navigation' => MG_navigation(), 'lang_admin' => $LANG_MG00['admin'], 'version' => $_MG_CONF['pi_version']));
if ($mode == $LANG_MG01['delete'] && !empty($LANG_MG01['delete'])) {
    $T->set_var(array('admin_body' => MG_massDeleteAlbums(0)));
    echo COM_refresh($_MG_CONF['admin_url'] . '/index.php?msg=15');
} elseif ($mode == $LANG_MG01['cancel']) {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    $T->set_var(array('admin_body' => MG_massDelete(), 'title' => $LANG_MG01['mass_delete_help'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" border="0" alt="?">', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Batch_Delete_Albums'));
}
$T->parse('output', 'admin');
$display = COM_siteHeader();
$display .= $T->finish($T->get_var('output'));
$display .= COM_siteFooter();
echo $display;
exit;
Beispiel #24
0
     // auto start
     $playButton = '';
     $autoplay = 'true';
 } else {
     if ($row['media_tn_attached'] == 1) {
         $playImage = MG_getImageFile('blank_blk.jpg');
         $playButtonMG = '';
         foreach ($_MG_CONF['validExtensions'] as $ext) {
             if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) {
                 $playImage = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext;
                 $playButtonMG = 'flashvars.thumbUrl="' . $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext . '";';
                 break;
             }
         }
     } else {
         $playImage = MG_getImageFile('blank_blk.jpg');
         $playButtonMG = '';
     }
     $playButton = "{ url: '" . $playImage . "', overlayId: 'play' },";
     $playButtonMG = '';
     $autoplay = 'false';
 }
 if ($row['remote_media'] == 1) {
     $urlParts = array();
     $urlParts = parse_url($row['remote_url']);
     $pathParts = array();
     $pathParts = explode('/', $urlParts['path']);
     $ppCount = count($pathParts);
     $pPath = '';
     for ($row = 1; $row < $ppCount - 1; $row++) {
         $pPath .= '/' . $pathParts[$row];
Beispiel #25
0
    $retval .= $T->finish($T->parse('output', 'sessions'));
    return $retval;
}
/**
* Main
*/
$mode = '';
if (isset($_POST['mode'])) {
    $mode = COM_applyFilter($_POST['mode']);
} else {
    if (isset($_GET['mode'])) {
        $mode = COM_applyFilter($_GET['mode']);
    }
}
$T = new Template($_MG_CONF['template_path']);
$T->set_file('admin', 'administration.thtml');
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'lang_admin' => $LANG_MG00['admin'], 'xhtml' => XHTML));
if ($mode == $LANG_MG01['cancel']) {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} elseif ($mode == $LANG_MG01['delete'] && !empty($LANG_MG01['delete'])) {
    MG_batchDeleteSession();
} else {
    $T->set_var(array('admin_body' => MG_displaySessions(), 'title' => $LANG_MG01['batch_sessions'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"' . XHTML . '>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Paused_Sessions'));
}
$display = COM_startBlock($LANG_MG00['admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
$display .= MG_showAdminMenu('batch_sessions');
$display .= $T->finish($T->parse('output', 'admin'));
$display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
$display = COM_createHTMLDocument($display);
COM_output($display);
Beispiel #26
0
        // Insert default configuration
        COM_errorLog("Media Gallery: Restoring system defaults", 1);
        for ($i = 1; $i <= count($_SQL_DEF); $i++) {
            DB_query(current($_SQL_DEF));
            if (DB_error()) {
                COM_errorLog("Error inserting Media Gallery Defaults: " . curent($_SQL_DEF), 1);
            }
            next($_SQL_DEF);
        }
        COM_errorLog("Media Gallery: Success - default data added to Media Gallery tables", 1);
        echo COM_refresh($_MG_CONF['admin_url'] . 'index.php?msg=9');
        exit;
    default:
        $T = new Template($_MG_CONF['template_path'] . '/admin');
        $T->set_file(array('admin' => 'administration.thtml'));
        $B = new Template($_MG_CONF['template_path'] . '/admin');
        $B->set_file(array('admin' => 'thumbs.thtml'));
        $B->set_var('site_url', $_CONF['site_url']);
        $B->set_var('site_admin_url', $_CONF['site_admin_url']);
        // display the album list...
        $B->set_var(array('lang_title' => $LANG_MG01['reset_defaults'], 's_form_action' => $_MG_CONF['admin_url'] . 'resetdefaults.php?step=two', 'lang_next' => $LANG_MG01['next'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_details' => $LANG_MG01['reset_defaults_details']));
        $B->parse('output', 'admin');
        $T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'admin_body' => $B->finish($B->get_var('output')), 'mg_navigation' => MG_navigation(), 'title' => $LANG_MG01['reset_defaults'], 'lang_admin' => $LANG_MG00['admin'], 'version' => $_MG_CONF['pi_version'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"/>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Reset_System_Options'));
        $T->parse('output', 'admin');
        $display = COM_siteHeader();
        $display .= $T->finish($T->get_var('output'));
        $display .= COM_siteFooter();
        echo $display;
        exit;
        break;
}
    if (isset($_GET['mode'])) {
        $mode = COM_applyFilter($_GET['mode']);
    }
}
$T = new Template($_MG_CONF['template_path']);
$T->set_file('admin', 'administration.thtml');
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'lang_admin' => $LANG_MG00['admin'], 'xhtml' => XHTML));
if ($mode == $LANG_MG01['save'] && !empty($LANG_MG01['save'])) {
    MG_createUsers();
    exit;
} elseif ($mode == $LANG_MG01['cancel']) {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    if (isset($_REQUEST['page'])) {
        $page = COM_applyFilter($_REQUEST['page'], true) - 1;
        if ($page < 0) {
            $page = 0;
        }
    } else {
        $page = 0;
    }
    $T->set_var(array('admin_body' => MG_selectUsers($page), 'title' => $LANG_MG01['batch_create_members'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"' . XHTML . '>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Batch_Create_Member_Albums'));
}
$T->parse('output', 'admin');
$display = COM_startBlock($LANG_MG00['admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
$display .= MG_showAdminMenu('member_albums');
$display .= $T->finish($T->get_var('output'));
$display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
$display = COM_createHTMLDocument($display);
COM_output($display);
Beispiel #28
0
}
/**
* Main
*/
$mode = '';
if (isset($_POST['mode'])) {
    $mode = COM_applyFilter($_POST['mode']);
} else {
    if (isset($_GET['mode'])) {
        $mode = COM_applyFilter($_GET['mode']);
    }
}
$T = new Template($_MG_CONF['template_path']);
$T->set_file('admin', 'administration.thtml');
$T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_MG_CONF['site_url'], 'lang_admin' => $LANG_MG00['admin'], 'xhtml' => XHTML));
if ($mode == $LANG_MG01['delete'] && !empty($LANG_MG01['delete'])) {
    require_once $_CONF['path'] . 'plugins/mediagallery/include/batch.php';
    MG_purgeMemberAlbums();
    exit;
} elseif ($mode == $LANG_MG01['cancel']) {
    echo COM_refresh($_MG_CONF['admin_url'] . 'index.php');
    exit;
} else {
    $T->set_var(array('admin_body' => MG_selectAlbums(), 'title' => $LANG_MG01['purge_member_albums'], 'status_msg' => $LANG_MG01['purge_mem_albums_help'], 'lang_help' => '<img src="' . MG_getImageFile('button_help.png') . '" style="border:none;" alt="?"' . XHTML . '>', 'help_url' => $_MG_CONF['site_url'] . '/docs/usage.html#Purge_Member_Albums'));
}
$display = COM_startBlock($LANG_MG00['admin'], '', COM_getBlockTemplate('_admin_block', 'header'));
$display .= MG_showAdminMenu('member_albums');
$display .= $T->finish($T->parse('output', 'admin'));
$display .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
$display = COM_createHTMLDocument($display);
COM_output($display);