Example #1
0
/**
* Flash upload form
*
* @param    int     album_id    album_id upload media
* @return   string              HTML
*
*/
function MG_SWFUpload($album_id)
{
    global $_USER, $_CONF, $_MG_CONF, $LANG_MG01, $LANG_MG03;
    $retval = '';
    if ($_MG_CONF['verbose']) {
        COM_errorLog('***Inside MG_SWFUpload()***');
    }
    $root_album = new mgAlbum(0);
    // construct the album selectbox ...
    $album_selectbox = MG_buildAlbumBox($root_album, $album_id, 3, -1, 'upload');
    if (empty($album_selectbox)) {
        return '';
    }
    // construct the album jumpbox...
    $album_jumpbox = MG_buildAlbumJumpbox($root_album, $album_id);
    // tell the flash uploader what the maximum file size can be.
    $file_size_limit = MG_getUploadLimit($album_id) . ' bytes';
    if ($_MG_CONF['verbose']) {
        COM_errorLog('file_size_limit=' . $file_size_limit);
    }
    // determine the valid filetypes for the current album
    $allowed_file_types = MG_getValidFileTypes($album_id);
    if ($_MG_CONF['verbose']) {
        COM_errorLog('allowed_file_types=' . $allowed_file_types);
    }
    // the flash uploader does not play nice with cookies, therefore we need to pass the uid
    // and a token to use as a second authentication factor.  let's make the token good for 4 hours
    // if the token expires, then the user will have to visit the swfupload page again, but
    // unfortunately because the upload handler runs in the background, there is really no way
    // to inform the users that the upload(s) failed (yet).
    $user_id = $_USER['uid'];
    //    $user_token = SEC_createTokenGeneral( 'swfupload', 14400 );//////////////////////////////////////////
    $T = COM_newTemplate(MG_getTemplatePath($album_id));
    $T->set_file('mupload', 'swfupload.thtml');
    $T->set_var(array('start_block' => COM_startBlock($LANG_MG03['upload_media']), 'end_block' => COM_endBlock(), 'navbar' => MG_navbar($LANG_MG01['swfupload_media'], $album_id), 'site_url' => $_CONF['site_url'], 'album_id' => $album_id, 'album_select' => $album_selectbox, 'jumpbox' => $album_jumpbox, 'lang_destination' => $LANG_MG01['destination_album'], 'upload_url' => 'swfupload/swfupload.php', 'flash_url' => 'swfupload/swfupload.swf', 'user_id' => $user_id, 'user_token' => $user_token, 'swfupload_usage' => $LANG_MG01['swfupload_usage'], 'swfupload_allowed_types' => $LANG_MG01['swfupload_allowed_types'], 'swfupload_file_types' => $allowed_file_types, 'swfupload_file_size_limit' => $LANG_MG01['swfupload_file_size_limit'], 'swfupload_size_limit' => $file_size_limit, 'swfupload_pending' => $LANG_MG01['swfupload_pending'], 'swfupload_q_too_many' => $LANG_MG01['swfupload_q_too_many'], 'sfwupload_q_limit' => $LANG_MG01['swfupload_q_limit'], 'swfupload_q_select' => $LANG_MG01['swfupload_q_select'], 'swfupload_q_up_to' => $LANG_MG01['swfupload_q_up_to'], 'swfupload_files' => $LANG_MG01['swfupload_files'], 'swfupload_one_file' => $LANG_MG01['swfupload_one_file'], 'swfupload_err_filesize' => $LANG_MG01['swfupload_err_filesize'], 'swfupload_err_zerosize' => $LANG_MG01['swfupload_err_zerosize'], 'swfupload_err_filetype' => $LANG_MG01['swfupload_err_filetype'], 'swfupload_err_general' => $LANG_MG01['swfupload_err_general'], 'swfupload_uploading' => $LANG_MG01['swfupload_uploading'], 'swfupload_complete' => $LANG_MG01['swfupload_complete'], 'swfupload_error' => $LANG_MG01['swfupload_error'], 'swfupload_failed' => $LANG_MG01['swfupload_failed'], 'swfupload_io_error' => $LANG_MG01['swfupload_io_error'], 'swfupload_sec_error' => $LANG_MG01['swfupload_sec_error'], 'swfupload_limit_exceeded' => $LANG_MG01['swfupload_limit_exceeded'], 'swfupload_fail_validation' => $LANG_MG01['swfupload_fail_validation'], 'swfupload_cancelled' => $LANG_MG01['swfupload_cancelled'], 'swfupload_stopped' => $LANG_MG01['swfupload_stopped'], 'swfupload_unhandled' => $LANG_MG01['swfupload_unhandled'], 'swfupload_file' => $LANG_MG01['swfupload_file'], 'swfupload_uploaded' => $LANG_MG01['swfupload_uploaded'], 'swfupload_types_desc' => $LANG_MG01['swfupload_types_desc'], 'swfupload_queue' => $LANG_MG01['swfupload_queue'], 'swfupload_continue' => $LANG_MG01['swfupload_continue'], 'swfupload_cancel_all' => $LANG_MG01['swfupload_cancel_all'], 'swfupload_noscript' => $LANG_MG01['swfupload_noscript'], 'swfupload_is_loading' => $LANG_MG01['swfupload_is_loading'], 'swfupload_not_loading' => $LANG_MG01['swfupload_not_loading'], 'swfupload_didnt_load' => $LANG_MG01['swfupload_didnt_load'], 'save_exit' => $LANG_MG01['save_exit'], 'title' => $LANG_MG01['title'], 'description' => $LANG_MG01['description']));
    $T->parse('output', 'mupload');
    $retval .= $T->finish($T->get_var('output'));
    return $retval;
}
Example #2
0
}
$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++) {
            if ($j >= $total_media) {
                $T->parse('IRow', 'ImageRow', true);
                $T->set_var('IColumn', '');
                break 2;
Example #3
0
function MG_displayMedia($id, $full = 0, $sortOrder = 0, $comments = 0, $spage = 0)
{
    global $_TABLES, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG04, $LANG_ACCESS, $_USER;
    $retval = '';
    $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . addslashes($id) . '"');
    require_once $_CONF['path'] . 'plugins/mediagallery/include/classAlbum.php';
    $mg_album = new mgAlbum($aid);
    $root_album = new mgAlbum(0);
    $pid = 0;
    if (isset($mg_album->pid)) {
        $pid = $mg_album->pid;
    }
    $aOffset = -1;
    $aOffset = $mg_album->getOffset();
    if ($aOffset == -1 || $mg_album->access == 0) {
        $retval = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
        return array($LANG_MG00['access_denied_msg'], $retval);
    }
    $sql = MG_buildMediaSql(array('album_id' => $aid, 'sortorder' => $mg_album->enable_sort ? $sortOrder : 0));
    $result = DB_query($sql);
    $nRows = DB_numRows($result);
    $total_media = $nRows;
    $media_array = array();
    while ($row = DB_fetchArray($result)) {
        $media_array[] = $row;
        $id_array[] = $row['media_id'];
    }
    $key = array_search($id, $id_array);
    if ($key === false) {
        $retval = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer'));
        return array($LANG_MG00['access_denied_msg'], $retval);
    }
    $media = $media_array[$key];
    if ($mg_album->full == 2 || $_MG_CONF['discard_original'] == 1 || $mg_album->full == 1 && $_USER['uid'] > 1) {
        $full = 0;
    }
    $disp = $full ? 'orig' : 'disp';
    if ($mg_album->enable_comments == 0) {
        $comments = 0;
    }
    $display_skin = $mg_album->display_skin;
    MG_getCSS($display_skin);
    // construct the album jumpbox...
    $album_jumpbox = '';
    if (!$_MG_CONF['hide_jumpbox_on_mediaview']) {
        $album_jumpbox = MG_buildAlbumJumpbox($root_album, $aid, 1, -1);
    }
    // Update the views count... But only for non-admins
    if (!$root_album->owner_id) {
        $media_views = $media['media_views'] + 1;
        DB_change($_TABLES['mg_media'], 'media_views', $media_views, 'media_id', addslashes($media['media_id']));
    }
    $columns_per_page = $mg_album->display_columns == 0 ? $_MG_CONF['ad_display_columns'] : $mg_album->display_columns;
    $rows_per_page = $mg_album->display_rows == 0 ? $_MG_CONF['ad_display_rows'] : $mg_album->display_rows;
    $_MG_USERPREFS = MG_getUserPrefs();
    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_album->albums_first) {
        $childCount = $mg_album->getChildCount();
        $page = intval(($key + $childCount) / $media_per_page) + 1;
    } else {
        $page = intval($key / $media_per_page) + 1;
    }
    /*
     * check to see if the original image exists, if not fall back to full image
     */
    $media_size_orig = @getimagesize(Media::getFilePath('orig', $media['media_filename'], $media['media_mime_ext']));
    if ($media_size_orig == false) {
        $full = 0;
        $disp = 'disp';
    }
    $aPage = intval($aOffset / ($root_album->display_columns * $root_album->display_rows)) + 1;
    $birdseed = MG_getBirdseed($mg_album->id, 1, $sortOrder, $aPage);
    $album_link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '&amp;page=' . $page . '&amp;sort=' . $sortOrder . '">';
    if ($_MG_CONF['usage_tracking']) {
        MG_updateUsage('media_view', $mg_album->title, $media['media_title'], $media['media_id']);
    }
    // hack for tga files...
    if ($media['mime_type'] == 'image/x-targa' || $media['mime_type'] == 'image/tga') {
        $full = 0;
        $disp = 'disp';
    }
    $prevLink = '';
    $nextLink = '';
    $pagination = '';
    $base_url = $_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&amp;sort=" . $sortOrder;
    list($prevLink, $nextLink) = MG_getNextandPrev($base_url, $nRows, $key, $media_array);
    // generate pagination routine
    if (!empty($prevLink)) {
        $pagination .= '<a href="' . $prevLink . '">' . $LANG_MG03['previous'] . '</a>';
    }
    if (!empty($nextLink)) {
        $pagination .= !empty($prevLink) ? '&nbsp;&nbsp;&nbsp;' : '';
        $pagination .= '<a href="' . $nextLink . '">' . $LANG_MG03['next'] . '</a>';
    }
    $pagination .= LB;
    // hack for testing...>>>
    $media_id = $media['media_id'];
    if ($_MG_CONF['click_image_and_go_next'] && !$_MG_CONF['full_in_popup']) {
        $nextkey = MG_getNextitem($nRows, $key);
        if ($nextkey !== '') {
            $media_id = $media_array[$nextkey]['media_id'];
        }
    }
    $vf = $full;
    if ($media['media_type'] == '0') {
        // image
        $switch_size = $_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '0' : '1') . '&amp;sort=' . $sortOrder . '&amp;s=' . $media['media_id'];
        $lang_switch_size = $full ? $LANG_MG03['normal_size'] : $LANG_MG03['full_size'];
        $switch_viewsize_link = '<a href="' . $switch_size . '">' . $lang_switch_size . '</a>';
    }
    // hack for testing...<<<
    $opt = array('full' => $full, 'media_id' => $media_id, 'sortOrder' => $sortOrder, 'spage' => $spage, 'playback_type' => $mg_album->playback_type, 'skin' => $mg_album->skin, 'display_skin' => $mg_album->display_skin, 'allow_download' => $mg_album->allow_download, 'full_display' => $mg_album->full);
    list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_buildContent($media, $opt);
    $mid = $media['media_id'];
    if ($_MG_CONF['use_upload_time'] == 1) {
        $media_date = MG_getUserDateTimeFormat($media['upload_time']);
    } else {
        $media_date = MG_getUserDateTimeFormat($media['media_time']);
    }
    $rating_box = '';
    if ($mg_album->enable_rating > 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-rating.php';
        $rating_box = MG_getRatingBar($mg_album->enable_rating, $media['media_user_id'], $media['media_id'], $media['media_votes'], $media['media_rating'], '');
    }
    $download_link = '';
    $download = '';
    if ($mg_album->allow_download) {
        $download_link = $_MG_CONF['site_url'] . '/download.php?mid=' . $media['media_id'];
        $download = '<a href="' . $download_link . '">' . $LANG_MG01['download'] . '</a>';
    }
    $edit_item_link = '';
    $edit_item = '';
    if ($mg_album->access == 3 || $_MG_CONF['allow_user_edit'] == true && isset($_USER['uid']) && $media['media_user_id'] == $_USER['uid']) {
        $edit_item_link = $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&amp;s=1&amp;album_id=' . $aid . '&amp;mid=' . $mid;
        $edit_item = '<a href="' . $edit_item_link . '">' . $LANG_MG01['edit'] . '</a>';
    }
    $media_desc = PLG_replaceTags(nl2br($media['media_desc']));
    if (strlen($media_desc) > 0) {
        $media_desc = '<p style="margin:5px">' . $media_desc . '</p>';
    }
    $getid3link = '';
    $getid3linkend = '';
    $media_properties = $getid3link != '' ? $LANG_MG03['media_properties'] : '';
    $kwText = '';
    $lang_keywords = '';
    if ($mg_album->enable_keywords == 1 && !empty($media['media_keywords'])) {
        $lang_keywords = $LANG_MG01['keywords'];
        $keyWords = array();
        $keyWords = explode(' ', $media['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>';
        }
    }
    $media_user_id = $media['media_user_id'];
    if (empty($media_user_id)) {
        $media_user_id = 0;
    }
    $displayname = $_CONF['show_fullname'] ? 'fullname' : 'username';
    $owner_name = DB_getItem($_TABLES['users'], $displayname, "uid = {$media_user_id}");
    if (empty($owner_name)) {
        $owner_name = DB_getItem($_TABLES['users'], 'username', "uid = {$media_user_id}");
        if (empty($owner_name)) {
            $owner_name = 'unknown';
        }
    }
    $owner_link = $owner_name;
    if ($owner_name != 'unknown') {
        $owner_link = '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&amp;uid=' . $media_user_id . '">' . $owner_name . '</a>';
    }
    $property = '';
    if (($mg_album->exif_display == 2 || $mg_album->exif_display == 3) && $media['media_type'] == 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
        $haveEXIF = MG_haveEXIF($media['media_id']);
        if ($haveEXIF) {
            $property = $_MG_CONF['site_url'] . '/property.php?mid=' . $media['media_id'];
        }
    }
    $media_id = '';
    if ($root_album->owner_id || $_MG_CONF['enable_media_id'] == 1) {
        $media_id = $media['media_id'];
    }
    $exif_info = '';
    if (($mg_album->exif_display == 1 || $mg_album->exif_display == 3) && $media['media_type'] == 0) {
        require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php';
        $haveEXIF = MG_haveEXIF($media['media_id']);
        if ($haveEXIF) {
            $exif_info = MG_readEXIF($media['media_id'], 2);
        }
    }
    $T = COM_newTemplate(MG_getTemplatePath_byName($mg_album->skin));
    switch ($media['media_type']) {
        case '0':
            // image
            $T->set_file('page', 'view_image.thtml');
            break;
        case '1':
            // video
        // video
        case '5':
            // embedded video
            $T->set_file('page', 'view_video.thtml');
            break;
        case '2':
            // audio
            $T->set_file('page', 'view_audio.thtml');
            break;
        default:
            $T->set_file('page', 'view_image.thtml');
            break;
    }
    $T->set_var(array('header' => $LANG_MG00['plugin'], 'site_url' => $_MG_CONF['site_url'], 'plugin' => 'mediagallery', 'birdseed' => $birdseed, 'lang_slideshow_link' => $LANG_MG03['slide_show'], 'image_detail' => $u_image, 'media_title' => isset($media['media_title']) && $media['media_title'] != ' ' ? PLG_replaceTags($media['media_title']) : '', 'album_title' => $mg_album->title, 'media_desc' => isset($media['media_desc']) && $media['media_desc'] != ' ' ? $media_desc : '', 'media_time' => $media_date[0], 'media_views' => $mg_album->enable_views ? $media['media_views'] : '', 'media_comments' => $mg_album->enable_comments ? $media['media_comments'] : '', 'pagination' => $pagination, 'media_number' => sprintf("%s %d %s %d", $LANG_MG03['image'], $key + 1, $LANG_MG03['of'], $total_media), 'jumpbox' => $album_jumpbox, 'rating_box' => $rating_box, 'download' => $download, 'download_link' => $download_link, 'lang_download' => $LANG_MG01['download'], 'edit_item' => $edit_item, 'edit_item_link' => $edit_item_link, 'lang_edit' => $LANG_MG01['edit'], '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, 'raw_link_url' => $raw_link_url, 'item_number' => $key + 1, 'total_items' => $total_media, 'lang_of' => $LANG_MG03['of'], 'album_link' => $album_link, 'switch_size' => $switch_size, 'lang_switch_size' => $lang_switch_size, 'switch_size_link' => $switch_viewsize_link, 'getid3' => $getid3link, 'getid3end' => $getid3linkend, 'media_properties' => $media_properties, 'media_keywords' => $kwText, 'lang_keywords' => $lang_keywords, 'owner_username' => $owner_link, 'property' => $property, 'lang_property' => $LANG_MG04['exif_header'], 'media_id' => $media_id, 'exif_info' => $exif_info, 'lang_comments' => $mg_album->enable_comments ? $LANG_MG03['comments'] : '', 'lang_views' => $mg_album->enable_views ? $LANG_MG03['views'] : '', 'lang_title' => $LANG_MG01['title'], 'lang_uploaded_by' => $LANG_MG01['uploaded_by'], 'album_id' => $aid, 'lang_search' => $LANG_MG01['search']));
    MG_buildSlideshow($mg_album, $T, $sortOrder);
    PLG_templateSetVars('mediagallery', $T);
    $retval .= $T->finish($T->parse('output', 'page'));
    if ($comments) {
        // Geeklog Comment support
        $sid = $media['media_id'];
        require_once $_CONF['path_system'] . 'lib-comment.php';
        $delete_option = false;
        if ($mg_album->access == 3 || $root_album->owner_id) {
            $delete_option = true;
        }
        $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0;
        $comorder = '';
        if (isset($_POST['order'])) {
            $comorder = COM_applyFilter($_POST['order']);
        } elseif (isset($_GET['order'])) {
            $comorder = COM_applyFilter($_GET['order']);
        }
        $commode = '';
        if (isset($_POST['mode'])) {
            $commode = COM_applyFilter($_POST['mode']);
        } elseif (isset($_GET['mode'])) {
            $commode = COM_applyFilter($_GET['mode']);
        }
        $commentcode = 0;
        // 今のところ無条件にコメント投稿を許可。
        $retval .= CMT_userComments($sid, $media['media_title'], 'mediagallery', $comorder, $commode, 0, $page, false, $delete_option, $commentcode);
    }
    return array(strip_tags($media['media_title']), $retval, $aid);
}