* This file is responsible for letting user enter a comment and saving the * comments to the DB. All comment display stuff is in lib-common.php * * @author Jason Whittenburg * @author Tony Bibbs <tonyAT tonybibbs DOT com> * @author Vincent Furia <vinny01 AT users DOT sourceforge DOT net> * */ /** * glFusion common function library */ require_once 'lib-common.php'; /** * glFusion comment function library */ USES_lib_comment(); // Uncomment the line below if you need to debug the HTTP variables being passed // to the script. This will sometimes cause errors but it will allow you to see // the data being passed in a POST operation // echo COM_debug($_POST); function _getReferer() { global $_CONF; if (isset($_POST['referer'])) { $referer = COM_sanitizeUrl($_POST['referer']); } else { if (isset($_SERVER['HTTP_REFERER'])) { $referer = COM_sanitizeUrl($_SERVER['HTTP_REFERER']); } else { $referer = ''; }
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'] . ': <select name="aid" onchange="forms[\'jumpbox\'].submit()">'; $MG_albums[0]->buildJumpBox($aid); $album_jumpbox .= '</select>'; $album_jumpbox .= ' <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 . '&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 . '&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 . '&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 . '&page=' . $page . '&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&s=1&album_id=' . $aid . '&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 . '&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 . '&src=disp"><b>' . $LANG_MG03['slide_show'] . '</b></a>'; break; case 4: $url_slideshow = '<a href="' . $_MG_CONF['site_url'] . '/fslideshow.php?aid=' . $aid . '&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') . "&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') . "&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&swhere=1&keywords=' . $searchKeyword . '&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&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&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 . '&title=' . $title . '&pid=0&type=mediagallery' . '">' . $LANG01[60] . '</a></center>'; } } } return array(strip_tags($media[$mediaObject]['media_title']), $retval, '', $aid); }
function MG_saveComment($title, $comment, $sid, $pid, $type, $postmode, $uid, $cmtdate, $ipaddress = '') { global $_CONF, $_TABLES, $_USER, $_SERVER, $LANG03; USES_lib_comment(); $ret = 0; // Sanity check if (empty($sid) || empty($title) || empty($comment) || empty($type)) { COM_errorLog("CMT_saveComment: {$uid} from {$_SERVER['REMOTE_ADDR']} tried " . 'to submit a comment with one or more missing values.'); return $ret = 1; } // Check that anonymous comments are allowed if ($uid == 1 && ($_CONF['loginrequired'] == 1 || $_CONF['commentsloginrequired'] == 1)) { COM_errorLog("CMT_saveComment: IP address {$_SERVER['REMOTE_ADDR']} " . 'attempted to save a comment with anonymous comments disabled for site.'); return $ret = 2; } // Let plugins have a chance to decide what to do before saving the comment, return errors. if ($someError = PLG_commentPreSave($uid, $title, $comment, $sid, $pid, $type, $postmode)) { return $someError; } if ($ipaddress == '') { $ipaddress = $_SERVER['REMOTE_ADDR']; } // Clean 'em up a bit! if ($postmode == 'html') { $comment = COM_checkWords(COM_checkHTML(DB_escapeString($comment))); } else { $comment = htmlspecialchars(COM_checkWords($comment)); $newcomment = COM_makeClickableLinks($comment); if (strcmp($comment, $newcomment) != 0) { $comment = nl2br($newcomment); $postmode = 'html'; } } $title = COM_checkWords(strip_tags($title)); // Get signature $sig = ''; if ($uid > 1) { $sig = DB_getItem($_TABLES['users'], 'sig', "uid = '{$uid}'"); } if (!empty($sig)) { if ($postmode == 'html') { $comment .= '<p>---<br>' . nl2br($sig); } else { $comment .= LB . LB . '---' . LB . $sig; } } // check for non-int pid's // this should just create a top level comment that is a reply to the original item if (!is_numeric($pid) || $pid < 0) { $pid = 0; } if (!empty($title) && !empty($comment)) { $title = DB_escapeString($title); $comment = DB_escapeString($comment); // Insert the comment into the comment table DB_query("LOCK TABLES {$_TABLES['comments']} WRITE"); if ($pid > 0) { $result = DB_query("SELECT rht, indent FROM {$_TABLES['comments']} WHERE cid = {$pid} " . "AND sid = '{$sid}'"); list($rht, $indent) = DB_fetchArray($result); if (!DB_error()) { DB_query("UPDATE {$_TABLES['comments']} SET lft = lft + 2 " . "WHERE sid = '{$sid}' AND type = '{$type}' AND lft >= {$rht}"); DB_query("UPDATE {$_TABLES['comments']} SET rht = rht + 2 " . "WHERE sid = '{$sid}' AND type = '{$type}' AND rht >= {$rht}"); DB_save($_TABLES['comments'], 'sid,uid,comment,date,title,pid,lft,rht,indent,type,ipaddress', "'{$sid}',{$uid},'{$comment}','{$cmtdate}','{$title}',{$pid},{$rht},{$rht}+1,{$indent}+1,'{$type}','{$ipaddress}'"); } else { //replying to non-existent comment or comment in wrong article COM_errorLog("CMT_saveComment: {$uid} from {$ipaddress} tried " . 'to reply to a non-existent comment or the pid/sid did not match'); $ret = 4; // Cannot return here, tables locked! } } else { $rht = DB_getItem($_TABLES['comments'], 'MAX(rht)', "sid = '{$sid}'"); if (DB_error()) { $rht = 0; } DB_save($_TABLES['comments'], 'sid,uid,comment,date,title,pid,lft,rht,indent,type,ipaddress', "'{$sid}',{$uid},'{$comment}','{$cmtdate}','{$title}',{$pid},{$rht}+1,{$rht}+2,0,'{$type}','{$ipaddress}'"); } $cid = DB_insertId(); DB_query('UNLOCK TABLES'); // Send notification of comment if no errors and notications enabled for comments if ($ret == 0 && isset($_CONF['notification']) && in_array('comment', $_CONF['notification'])) { CMT_sendNotification($title, $comment, $uid, $ipaddress, $type, $cid); } } else { COM_errorLog("CMT_saveComment: {$uid} from {$ipaddress} tried " . 'to submit a comment with invalid $title and/or $comment.'); return $ret = 5; } return $ret; }
function displayThumb($s, $sortOrder, $force = 0, $imageFrame = '') { global $_USER, $_CONF, $_MG_CONF, $MG_albums, $_TABLES, $_MG_USERPREFS, $LANG_MG03, $LANG_MG01, $glversion, $ratedIds; $retval = ''; $T = new Template(MG_getTemplatePath($this->album_id)); if ($MG_albums[$this->album_id]->display_columns == 1) { $media_cell_image_template = 'album_page_body_media_cell_1.thtml'; } else { $media_cell_image_template = 'album_page_body_media_cell.thtml'; } if ($force) { $media_cell_image_template = 'album_page_body_media_cell.thtml'; } $T->set_file(array('media_cell_image' => $media_cell_image_template, 'media_rate_results' => 'album_page_body_media_cell_rating.thtml', 'media_comments' => 'album_page_body_media_cell_comment.thtml', 'media_views' => 'album_page_body_media_cell_view.thtml', 'media_cell_keywords' => 'album_page_body_media_cell_keywords.thtml', 'mp3_podcast' => 'mp3_podcast.thtml')); $F = new Template($_MG_CONF['template_path']); $F->set_var('media_frame', $MG_albums[$this->album_id]->imageFrameTemplate); // --- set the default thumbnail $data_type = ''; $videoid = ''; $url_orig = ''; switch ($this->type) { case 0: // standard image $data_type = 'image'; $default_thumbnail = 'tn/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext; if (!file_exists($_MG_CONF['path_mediaobjects'] . $default_thumbnail)) { $default_thumbnail = 'tn/' . $this->filename[0] . '/' . $this->filename . '.jpg'; } if ($_MG_CONF['discard_original'] == 1) { $orig = 'disp'; } else { $orig = 'orig'; } $default_orig_file = $orig . '/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext; if (file_exists($_MG_CONF['path_mediaobjects'] . $default_orig_file)) { $url_orig = $_MG_CONF['site_url'] . '/mediaobjects/' . $default_orig_file; } else { $url_orig = ''; } break; case 1: // video file switch ($this->mime_type) { case 'video/x-flv': $default_thumbnail = 'placeholder_flv.svg'; if ($MG_albums[$this->album_id]->tnWidth > $MG_albums[$this->album_id]->tnHeight) { $default_thumbnail = 'placeholder_flv_w.svg'; } else { $default_thumbnail = 'placeholder_flv.svg'; } break; case 'application/x-shockwave-flash': if ($MG_albums[$this->album_id]->tnWidth > $MG_albums[$this->album_id]->tnHeight) { $default_thumbnail = 'placeholder_flash_w.svg'; } else { $default_thumbnail = 'placeholder_flash.svg'; } break; case 'video/mpeg': case 'video/x-mpeg': case 'video/x-mpeq2a': case 'video/webm': if ($MG_albums[$this->album_id]->tnWidth > $MG_albums[$this->album_id]->tnHeight) { $default_thumbnail = 'placeholder_video_w.svg'; } else { $default_thumbnail = 'placeholder_video.svg'; } $orig = 'orig'; $default_orig_file = $orig . '/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext; if (file_exists($_MG_CONF['path_mediaobjects'] . $default_orig_file)) { $url_orig = $_MG_CONF['site_url'] . '/mediaobjects/' . $default_orig_file; } else { $url_orig = ''; } $data_type = 'html5video'; break; case 'video/x-motion-jpeg': case 'video/quicktime': case 'video/x-qtc': case 'audio/mpeg': case 'video/x-m4v': if ($MG_albums[$this->album_id]->tnWidth > $MG_albums[$this->album_id]->tnHeight) { $default_thumbnail = 'placeholder_video_w.svg'; } else { $default_thumbnail = 'placeholder_video.svg'; } break; case 'asf': case 'video/x-ms-asf': case 'video/x-ms-asf-plugin': case 'video/avi': case 'video/msvideo': case 'video/x-msvideo': case 'video/avs-video': case 'video/x-ms-wmv': case 'video/x-ms-wvx': case 'video/x-ms-wm': case 'application/x-troff-msvideo': case 'application/x-ms-wmz': case 'application/x-ms-wmd': if ($MG_albums[$this->album_id]->tnWidth > $MG_albums[$this->album_id]->tnHeight) { $default_thumbnail = 'placeholder_video_w.svg'; } else { $default_thumbnail = 'placeholder_video.svg'; } break; default: if ($MG_albums[$this->album_id]->tnWidth > $MG_albums[$this->album_id]->tnHeight) { $default_thumbnail = 'placeholder_video_w.svg'; } else { $default_thumbnail = 'placeholder_video.svg'; } $orig = 'orig'; $default_orig_file = $orig . '/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext; if (file_exists($_MG_CONF['path_mediaobjects'] . $default_orig_file)) { $url_orig = $_MG_CONF['site_url'] . '/mediaobjects/' . $default_orig_file; } else { $url_orig = ''; } $data_type = 'html5video'; break; } break; case 2: // music file $default_thumbnail = 'placeholder_audio.svg'; if ($MG_albums[$this->album_id]->tnWidth > $MG_albums[$this->album_id]->tnHeight) { $default_thumbnail = 'placeholder_audio_w.svg'; } else { $default_thumbnail = 'placeholder_audio.svg'; } break; case 4: // other files switch ($this->mime_type) { case 'application/zip': case 'zip': case 'arj': case 'rar': case 'gz': $default_thumbnail = 'placeholder_zip.svg'; break; case 'pdf': case 'application/pdf': $default_thumbnail = 'placeholder_pdf.svg'; break; default: if (isset($_MG_CONF['dt'][$this->mime_ext])) { $default_thumbnail = $_MG_CONF['dt'][$this->mime_ext]; } else { switch ($this->mime_ext) { case 'pdf': $default_thumbnail = 'placeholder_pdf.svg'; break; case 'arj': $default_thumbnail = 'zip.png'; $default_thumbnail = 'placeholder_zip.svg'; break; case 'gz': $default_thumbnail = 'zip.png'; $default_thumbnail = 'placeholder_zip.svg'; break; default: $default_thumbnail = 'generic.png'; $default_thumbnail = 'placeholder.svg'; break; } } break; } break; case 5: case 'embed': require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-remotemedia.php'; if (preg_match("/youtube/i", $this->remote_url)) { $default_thumbnail = 'youtube.png'; $data_type = 'youtube'; $videoid = getYoutubeId($this->remote_url); } else { if (preg_match("/google/i", $this->remote_url)) { $default_thumbnail = 'googlevideo.png'; } else { if (preg_match("/vimeo/i", $this->remote_url)) { $default_thumbnail = 'placeholder_viemo.svg'; $data_type = 'vimeo'; $videoid = getVimeoId($this->remote_url); } else { $default_thumbnail = 'remote.png'; } } } if ($MG_albums[$this->album_id]->tnWidth > $MG_albums[$this->album_id]->tnHeight) { $default_thumbnail = 'placeholder_video_w.svg'; } else { $default_thumbnail = 'placeholder_video.svg'; } $url_orig = $this->remote_url; break; } if ($this->tn_attached == 1) { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $this->filename[0] . '/tn_' . $this->filename . $ext)) { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $this->filename[0] . '/tn_' . $this->filename . $ext; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . 'tn/' . $this->filename[0] . '/tn_' . $this->filename . $ext; break; } } } else { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; } // type == 1 video // type == 2 audio if (($this->type == 1 || $this->type == 2 || $this->type == 5) && ($MG_albums[$this->album_id]->playback_type == 0 || $MG_albums[$this->album_id]->playback_type == 1) && $_MG_CONF['popup_from_album'] == 1) { if ($MG_albums[$this->album_id]->playback_type == 0) { if ($this->type == 2) { // determine what type of player we will use (WMP, QT or Flash) $player = $_MG_CONF['mp3_player']; if (isset($_MG_USERPREFS['mp3_player']) && $_MG_USERPREFS['mp3_player'] != -1) { $player = $_MG_USERPREFS['mp3_player']; } switch ($player) { case 0: // WMP $new_y = 260; $new_x = 340; break; case 1: // QT $new_y = 25; $new_x = 350; break; case 2: $new_y = 360; $new_x = 580; break; } if ($this->mime_type == 'audio/mpeg') { $new_y = 360; $new_x = 580; } if ($this->tn_attached == 1 && $player != 2) { $tnsize = @getimagesize($media_thumbnail_file); $new_y += $tnsize[0]; if ($tnsize[1] > $new_x) { $new_x = $tnsize[1]; } } if ($MG_albums[$this->album_id]->playback_type == 0) { $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $this->id . "'," . $new_y . ',' . $new_x . ')'; } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id; } $resolution_x = $new_x; $resolution_y = $new_y; } else { // must be a video... // set the default playback options... $playback_options['play'] = $_MG_CONF['swf_play']; $playback_options['menu'] = $_MG_CONF['swf_menu']; $playback_options['quality'] = $_MG_CONF['swf_quality']; $playback_options['height'] = $_MG_CONF['swf_height']; $playback_options['width'] = $_MG_CONF['swf_width']; $playback_options['loop'] = $_MG_CONF['swf_loop']; $playback_options['scale'] = $_MG_CONF['swf_scale']; $playback_options['wmode'] = $_MG_CONF['swf_wmode']; $playback_options['allowscriptaccess'] = $_MG_CONF['swf_allowscriptaccess']; $playback_options['bgcolor'] = $_MG_CONF['swf_bgcolor']; $playback_options['swf_version'] = $_MG_CONF['swf_version']; $playback_options['flashvars'] = $_MG_CONF['swf_flashvars']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($this->id) . "'"); while ($poRow = DB_fetchArray($poResult)) { $playback_options[$poRow['option_name']] = $poRow['option_value']; } if ($this->resolution_x > 0) { $resolution_x = $this->resolution_x; $resolution_y = $this->resolution_y; } else { if ($this->media_resolution_x == 0 && $this->remote_media != 1) { $size = @filesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext); // skip files over 8M in size.. if ($size < 8388608) { $ThisFileInfo = IMG_getMediaMetaData($_MG_CONF['path_mediaobjects'] . 'orig/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext); if ($ThisFileInfo['video']['resolution_x'] < 1 || $ThisFileInfo['video']['resolution_y'] < 1) { if (isset($ThisFileInfo['meta']['onMetaData']['width']) && isset($ThisFileInfo['meta']['onMetaData']['height'])) { $resolution_x = $ThisFileInfo['meta']['onMetaData']['width']; $resolution_y = $ThisFileInfo['meta']['onMetaData']['height']; } else { $resolution_x = -1; $resolution_y = -1; } } else { $resolution_x = $ThisFileInfo['video']['resolution_x']; $resolution_y = $ThisFileInfo['video']['resolution_y']; } if ($resolution_x != 0) { $sql = "UPDATE " . $_TABLES['mg_media'] . " SET media_resolution_x=" . intval($resolution_x) . ",media_resolution_y=" . intval($resolution_y) . " WHERE media_id='" . DB_escapeString($this->id) . "'"; DB_query($sql, 1); } } } else { $resolution_x = $this->resolution_x; $resolution_y = $this->resolution_y; } } $resolution_x = $playback_options['width']; $resolution_y = $playback_options['height']; if ($resolution_x < 1 || $resolution_y < 1) { $resolution_x = 480; $resolution_y = 320; } else { $resolution_x = $resolution_x + 40; $resolution_y = $resolution_y + 40; } if ($this->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 ($this->type == 5) { $resolution_x = 460; $resolution_y = 380; } $url_display_item = "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $this->id . "'," . $resolution_y . ',' . $resolution_x . ')'; } } else { $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id; } // check to see if comments and rating are enabled, if not, put a link to edit... if ($MG_albums[$this->album_id]->access == 3) { $T->set_var(array('edit_link' => '<br/><a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $this->album_id . '&mid=' . $this->id . '">' . $LANG_MG01['edit'] . '</a>')); } else { $T->set_var(array('edit_link' => '')); } } else { if ($MG_albums[$this->album_id]->useAlternate == 1 && $this->type != 5 && !empty($this->remote_url)) { $url_display_item = $this->remote_url; } else { $url_display_item = $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id; } } if ($this->type == 4) { // other $url_display_item = $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id; } if (strstr($media_thumbnail_file, '.svg')) { $media_size = array($MG_albums[$this->album_id]->tnWidth, $MG_albums[$this->album_id]->tnHeight); } else { $media_size = @getimagesize($media_thumbnail_file); } if ($media_size == false) { if ($this->type == 2) { $default_thumbnail = 'placeholder_audio.svg'; } else { $default_thumbnail = 'placeholder_missing.svg'; } $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; $tn_height = $MG_albums[$this->album_id]->tnHeight; $tn_width = $MG_albums[$this->album_id]->tnWidth; $media_size = array($tn_width, $tn_height); //@getimagesize($media_thumbnail_file); } $media_time = MG_getUserDateTimeFormat($this->time); $upload_time = MG_getUserDateTimeFormat($this->upload_time); $url_media_item = $url_display_item; // -- decide what thumbnail size to use, small, medium, large... if (isset($_MG_USERPREFS['tn_size']) && $_MG_USERPREFS['tn_size'] != -1) { $tn_size = $_MG_USERPREFS['tn_size']; } else { $tn_size = $MG_albums[$this->album_id]->tn_size; } switch ($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': case '4': $tn_height = $MG_albums[$this->album_id]->tnHeight; $tn_width = $MG_albums[$this->album_id]->tnWidth; if ($tn_height == 0) { $tn_height = 200; } if ($tn_width == 0) { $tn_width = 200; } break; default: $tn_height = 150; $tn_width = 150; break; } if ($media_size[0] > $media_size[1]) { // landscape $ratio = $media_size[0] / $tn_width; $newwidth = $tn_width; $newheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; if ($ratio == 0) { $newheight = $tn_height; $newwidth = $tn_width; } else { $newheight = $tn_height; $newwidth = round($media_size[0] / $ratio); } } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / 50; $smallwidth = 50; $smallheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / 50; if ($ratio == 0) { $smallheight = 50; $smallwidth = 50; } else { $smallheight = 50; $smallwidth = round($media_size[0] / $ratio); } } if ($this->owner_id != "" && $this->owner_id > 1) { $username = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($this->owner_id)); } else { $username = '******'; } if (!isset($resolution_x)) { $resolution_x = $newwidth; } if (!isset($resolution_y)) { $resolution_y = $newheight; } if ($this->mime_type == 'audio/mpeg' && $MG_albums[$this->album_id]->mp3ribbon) { $T->set_var(array('mp3_file' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext, 'site_url' => $_MG_CONF['site_url'], 'id' => $this->mime_ext . rand())); $T->parse('mp3_podcast', 'mp3_podcast'); } else { $T->set_var(array('mp3_podcast' => '')); } /* * build the small rating bar * */ if ($MG_albums[$this->album_id]->enable_rating > 0) { $uid = COM_isAnonUser() ? 1 : $_USER['uid']; $static = false; // check to see if we are the owner, if so, no rating for us... if (isset($_USER['uid']) && $_USER['uid'] == $this->owner_id) { $static = true; $voted = 0; } else { if (in_array($this->id, $ratedIds)) { $static = true; $voted = 1; } else { $static = 0; $voted = 0; } } if ($MG_albums[$this->album_id]->enable_rating == 1 && COM_isAnonUser()) { $static = true; } if ($_MG_CONF['use_large_stars'] == 1) { $starSize = ''; } else { $starSize = 'sm'; } $rating_box = RATING_ratingBar('mediagallery', $this->id, $this->votes, $this->rating, $voted, 5, $static, $starSize); } else { $rating_box = ''; } $T->set_var('rating_box', '<center>' . $rating_box . '</center>'); $fs_bytes = @filesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext); $fileSize = MG_get_size($fs_bytes); $direct_url = 'disp/' . $this->filename[0] . '/' . $this->filename . '.' . $this->mime_ext; if (!file_exists($_MG_CONF['path_mediaobjects'] . $direct_url)) { $direct_url = 'disp/' . $this->filename[0] . '/' . $this->filename . '.jpg'; } if ($MG_albums[$this->album_id]->access == 3) { $edit_item = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $this->album_id . '&mid=' . $this->id . '">' . $LANG_MG01['edit'] . '</a>'; } else { $edit_item = ''; } $L = new Template(MG_getTemplatePath($this->album_id)); $L->set_file('media_link', 'medialink.thtml'); $L->set_var('href', $url_media_item); if ($this->type == 0) { if ($this->remote == 1) { $L->set_var('hrefdirect', $this->remote_url); } else { $L->set_var('hrefdirect', $_MG_CONF['mediaobjects_url'] . '/' . $direct_url); } } $caption = PLG_replaceTags(str_replace('$', '$', $this->title), 'mediagallery', 'media_description'); if ($this->owner_id == $_USER['uid'] || SEC_hasRights('mediagallery.admin')) { $caption .= '<br />(' . $this->id . ')'; } $L->set_var('caption', $caption); $L->set_var('id', 'id' . rand()); $L->parse('media_link_start', 'media_link'); $media_start_link = $L->finish($L->get_var('media_link_start')); $T->set_var(array('play_now' => '', 'download_now' => $_MG_CONF['site_url'] . '/download.php?mid=' . $this->id, 'play_in_popup' => "javascript:showVideo('" . $_MG_CONF['site_url'] . '/video.php?n=' . $this->id . "'," . $resolution_y . ',' . $resolution_x . ')', 'row_height' => $tn_height + 40, 'media_title' => PLG_replaceTags($this->title, 'mediagallery', 'media_title'), 'media_description' => PLG_replaceTags(nl2br($this->description), 'mediagallery', 'media_description'), 'media_tag' => strip_tags($this->title), 'media_time' => $media_time[0], 'upload_time' => $upload_time[0], 'media_owner' => $username, 'site_url' => $_MG_CONF['site_url'], 'lang_published' => $LANG_MG03['published'], 'lang_on' => $LANG_MG03['on'], 'lang_hyphen' => $this->album == '' ? '' : '-', 'media_link_start' => $media_start_link, 'media_link_end' => '</a>', 'artist' => $this->artist, 'musicalbum' => $this->album != '' ? $this->album : '', 'genre' => $this->genre != '' ? $this->genre : '', 'alt_edit_link' => $edit_item, 'filesize' => $fileSize, 'media_id' => $this->id, 'raw_media_thumbnail' => $media_thumbnail, 'display_url' => $url_media_item, 'orig_url' => $url_orig)); if ($data_type != '') { $T->set_var('data_type', $data_type); } else { $T->unset_var('data_type'); } if ($videoid != '') { $T->set_var('videoid', $videoid); } else { $T->unset_var('videoid'); } // frame template variables $F->set_var(array('media_id' => $this->id, 'media_link_start' => $media_start_link, 'media_link_end' => '</a>', 'url_media_item' => $url_media_item, 'url_display_item' => $url_display_item, 'media_thumbnail' => $media_thumbnail, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'border_width' => $newwidth + 15, 'border_height' => $newheight + 15, 'row_height' => $tn_height + 40, 'frWidth' => $newwidth - $MG_albums[$this->album_id]->frWidth, 'frHeight' => $newheight - $MG_albums[$this->album_id]->frHeight, 'media_tag' => strip_tags($this->description), 'filesize' => $fileSize)); $F->parse('media', 'media_frame'); $media_item_thumbnail = $F->finish($F->get_var('media')); $T->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'url_media_item' => $url_media_item, 'url_display_item' => $url_display_item, 'media_thumbnail' => $media_thumbnail, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"')); if ($MG_albums[$this->album_id]->enable_keywords) { if (!empty($this->keywords)) { $kwText = ''; $keyWords = array(); $keyWords = explode(' ', $this->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&swhere=1&keywords=' . $searchKeyword . '&keyType=any">' . $keyWords[$i] . '</a> '; } $T->set_var(array('media_keywords' => $kwText, 'lang_keywords' => $LANG_MG01['keywords'])); $T->parse('media_cell_keywords', 'media_cell_keywords'); } else { $T->set_var('lang_keywords', ''); } } else { $T->set_var(array('media_cell_keywords' => '', 'lang_keywords' => '')); } if ($MG_albums[$this->album_id]->enable_rating) { $rating = $LANG_MG03['rating'] . ': <strong> ' . $this->rating / 2 . '</strong>/5 (' . $this->votes . ' ' . $LANG_MG03['votes'] . ')'; $T->set_var('media_rating', $rating); $T->parse('media_rate_results', 'media_rate_results'); } if ($MG_albums[$this->album_id]->enable_comments) { USES_lib_comment(); $cmtLinkArray = CMT_getCommentLinkWithCount('mediagallery', $this->id, $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id, $this->comments, 0); if ($this->type == 4 || $this->type == 1 && $MG_albums[$this->album_id]->playback_type != 2 || $this->type == 2 && $MG_albums[$this->album_id]->playback_type != 2 || $this->type == 5 && $MG_albums[$this->album_id]->playback_type != 2) { $cmtLink_alt = $cmtLinkArray['link_with_count']; // '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id . '">' . $LANG_MG03['comments'] . '</a>'; $cmtLink = ''; } else { $cmtLink = ''; //$LANG_MG03['comments']; $cmtLink_alt = $cmtLinkArray['link_with_count']; //'<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0' . '&sort=' . $sortOrder . '&s=' . $this->id . '">' . $LANG_MG03['comments'] . '</a>'; } $T->set_var(array('comments_with_count' => $cmtLinkArray['link_with_count'], 'media_comments_count' => $cmtLinkArray['comment_count'], 'lang_comments' => $cmtLink, 'lang_comments_hot' => $cmtLink_alt)); $T->parse('media_comments', 'media_comments'); } if ($MG_albums[$this->album_id]->enable_views) { $T->set_var(array('media_views_count' => $this->views, 'lang_views' => $LANG_MG03['views'])); $T->parse('media_views', 'media_views'); } $T->set_var(array('max-width' => $tn_width)); PLG_templateSetVars('mediagallery', $T); $T->parse('media_cell', 'media_cell_image'); $retval = $T->finish($T->get_var('media_cell')); return $retval; }