} if (COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) { $display = SEC_loginRequiredForm(); $display = MG_createHTMLDocument($display); COM_output($display); exit; } require_once $_CONF['path'] . 'plugins/mediagallery/include/common.php'; /* * Main Function */ COM_setArgNames(array('aid', 'f', 'sort')); $album_id = COM_applyFilter(COM_getArgument('aid'), true); $full = COM_applyFilter(COM_getArgument('f'), true); $sortOrder = COM_applyFilter(COM_getArgument('sort'), true); $album_data = MG_getAlbumData($album_id, array('skin', 'album_title', 'album_desc', 'album_parent', 'full_display', 'display_image_size'), true); MG_getThemePublicJSandCSS($album_data['skin']); $T = COM_newTemplate(MG_getTemplatePath($album_id)); $T->set_file('page', 'slideshow.thtml'); $T->set_block('page', 'slideItems', 'sItems'); $T->set_block('page', 'noItems', 'nItems'); $T->set_var('header', $LANG_MG00['plugin']); $T->set_var('site_url', $_MG_CONF['site_url']); $T->set_var('plugin', 'mediagallery'); $T->set_var('using_jquery', 'jquery'); if ($album_data['access'] == 0) { $display = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); $title = strip_tags($album_data['album_title']); $display = MG_createHTMLDocument($display, $title); COM_output($display); exit;
} // -- get the movie info... if ($mediaQueue == 'q') { $sql = "SELECT * FROM {$_TABLES['mg_mediaqueue']} AS m " . "LEFT JOIN {$_TABLES['mg_media_album_queue']} AS ma "; } else { $sql = "SELECT * FROM {$_TABLES['mg_media']} AS m " . "LEFT JOIN {$_TABLES['mg_media_albums']} AS ma "; } $sql .= "ON m.media_id=ma.media_id WHERE m.media_id='" . addslashes($media_id) . "'"; $result = DB_query($sql); $nRows = DB_numRows($result); if ($nRows <= 0) { exit; } $row = DB_fetchArray($result); $aid = $row['album_id']; $album_data = MG_getAlbumData($aid, array('skin', 'display_skin', 'album_id', 'playback_type', 'allow_download', 'full_display'), true); if ($album_data['access'] == 0) { $display = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); $display = MG_createHTMLDocument($display); COM_output($display); exit; } $themeCSS = ''; if (!empty($album_data['skin'])) { $skin = $album_data['skin']; if (file_exists($_MG_CONF['path_html'] . 'themes/' . $skin . '/javascript.js')) { $themeCSS .= '<script type="text/javascript" src="' . $_MG_CONF['site_url'] . '/themes/' . $skin . '/javascript.js"></script>' . LB; } if (file_exists($_MG_CONF['path_html'] . 'themes/' . $skin . '/style.css')) { $themeCSS .= '<link rel="stylesheet" type="text/css" href="' . $_MG_CONF['site_url'] . '/themes/' . $skin . '/style.css"' . XHTML . '>' . LB; }
function MG_getBirdseed($album_id, $hot = 0, $sortOrder = 0, $page = 0) { global $_CONF, $_MG_CONF, $LANG_MG03; $items = array(); $aid = $album_id; while ($aid != 0) { $album_data = MG_getAlbumData($aid, array('album_title', 'album_parent')); $url = NULL; if ($hot == 1) { $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '&sort=' . $sortOrder; if ($aid == $album_id && $page > 1) { $url .= '&page=' . $page; } } $title = strip_tags($album_data['album_title']); if ($_MG_CONF['truncate_breadcrumb'] > 0) { $title = COM_truncate($title, $_MG_CONF['truncate_breadcrumb'], '...'); } $items[] = array('href' => $url, 'title' => $title); $hot = 1; $aid = $album_data['album_parent']; } if ($_MG_CONF['gallery_only'] != 1) { $url = NULL; if ($hot == 1) { $url = $_MG_CONF['site_url'] . '/index.php'; if ($album_id == 0 && $page > 1) { $url .= '?page=' . $page; } } $items[] = array('href' => $url, 'title' => $_MG_CONF['root_album_name']); } $items[] = array('href' => $_CONF['site_url'] . '/index.php', 'title' => $LANG_MG03['home']); $retval = ''; $count = count($items) - 1; foreach ($items as $key => $item) { $birdseed = ''; if ($key < $count) { } if ($item['href'] !== NULL) { $birdseed .= "<li>" . COM_createLink($item['title'], $item['href']) . "</li>"; } else { $birdseed .= "<li>" . $item['title'] . "</li>"; } $retval = $birdseed . $retval; } return $retval; }
function MG_profileblocksdisplay($uid) { global $_TABLES, $_MG_CONF, $_CONF, $LANG_MG10, $_USER; $retval = ''; if ($_MG_CONF['profile_hook'] != 1) { return ''; } if ((!isset($_USER['uid']) || $_USER['uid'] < 2) && $_MG_CONF['loginrequired'] == 1) { return ''; } if (empty($uid)) { return ''; } $username = DB_getItem($_TABLES['users'], 'username', 'uid=' . intval($uid)); if (empty($username)) { return ''; } $T = COM_newTemplate(MG_getTemplatePath(0)); $T->set_file('mblock', 'profile_media.thtml'); $T->set_block('mblock', 'itemRow', 'iRow'); $T->set_var('start_block_last10mediaitems', COM_startBlock($LANG_MG10['last_10'] . $username)); $T->set_var('start_block_useralbums', COM_startBlock($LANG_MG10['albums_owned'] . $username)); $T->set_var('lang_thumbnail', $LANG_MG10['thumbnail']); $T->set_var('lang_title', $LANG_MG10['title']); $T->set_var('lang_album', $LANG_MG10['album']); $T->set_var('lang_album_description', $LANG_MG10['album_desc']); $T->set_var('lang_upload_date', $LANG_MG10['upload_date']); $T->set_var('end_block', COM_endBlock()); $sql = "SELECT a.album_id,m.media_upload_time,m.media_id,m.media_filename,m.mime_type," . "m.media_mime_ext,m.media_title,m.remote_media,m.media_type,m.media_tn_attached " . "FROM {$_TABLES['mg_albums']} AS a LEFT JOIN {$_TABLES['mg_media_albums']} AS ma " . "ON a.album_id=ma.album_id LEFT JOIN {$_TABLES['mg_media']} AS m ON ma.media_id=m.media_id " . "WHERE m.media_user_id=" . intval($uid) . " AND a.hidden=0 " . COM_getPermSQL('and') . " ORDER BY m.media_upload_time DESC LIMIT 5"; $result = DB_query($sql); $class = 0; $mCount = 0; while ($row = DB_fetchArray($result)) { $album_id = $row['album_id']; $album_data = MG_getAlbumData($album_id, array('album_title')); $album_title = strip_tags($album_data['album_title']); $upload_time = MG_getUserDateTimeFormat($row['media_upload_time']); $url_media = $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id']; $url_album = $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id; $tn_size = 10; list($url_thumb, $p_thumb, $msize) = Media::getThumbInfo($row, $tn_size); $atnsize = ''; if ($msize != false) { list($newwidth, $newheight) = Media::getImageWH($msize[0], $msize[1], 50, 50); $atnsize = 'width="' . $newwidth . '" height="' . $newheight . '" '; } $T->set_var('mediaitem_image', '<img src="' . $url_thumb . '" alt="" ' . $atnsize . 'style="border:none;vertical-align:bottom;"' . XHTML . '>'); $T->set_var('mediaitem_begin_href', '<a href="' . $url_media . '">'); $T->set_var('mediaitem_title', strip_tags($row['media_title'])); $T->set_var('mediaitem_end_href', '</a>'); $T->set_var('mediaitem_album_begin_href', '<a href="' . $url_album . '">'); $T->set_var('mediaitem_album_title', $album_title); $T->set_var('mediaitem_date', $upload_time[0]); $T->set_var('rowclass', $class % 2 ? '1' : '2'); $T->parse('iRow', 'itemRow', true); $class++; $mCount++; } if ($mCount != 0) { $retval .= $T->finish($T->parse('output', 'mblock')); } $T = COM_newTemplate(MG_getTemplatePath(0)); $T->set_file('ablock', 'profile_album.thtml'); $T->set_block('ablock', 'itemRow', 'iRow'); $T->set_var('start_block_useralbums', COM_startBlock($LANG_MG10['albums_owned'] . $username)); $T->set_var('lang_thumbnail', $LANG_MG10['thumbnail']); $T->set_var('lang_album', $LANG_MG10['album']); $T->set_var('lang_album_description', $LANG_MG10['album_desc']); $T->set_var('end_block', COM_endBlock()); $sql = "SELECT album_id,album_title,album_desc,tn_attached " . "FROM " . $_TABLES['mg_albums'] . " WHERE owner_id=" . intval($uid) . " AND hidden=0 " . COM_getPermSQL('and') . " ORDER BY last_update DESC LIMIT 10"; $result = DB_query($sql); $class = 0; $aCount = 0; while ($row = DB_fetchArray($result)) { $aid = $row['album_id']; $url_album = $_MG_CONF['site_url'] . '/album.php?aid=' . $row['album_id']; $url_thumb = ''; $msize = false; if ($row['tn_attached'] == 1) { list($url_thumb, $msize) = MG_getImageUrl('covers/cover_' . $row['album_id']); } else { $cover_file = MG_getAlbumCover($aid); if ($cover_file != '') { $offset = substr($cover_file, 0, 3) == 'tn_' ? 3 : 0; list($url_thumb, $msize) = MG_getImageUrl('tn/' . $cover_file[$offset] . '/' . $cover_file); } } if ($msize == false || $url_thumb == '') { $url_thumb = $_MG_CONF['mediaobjects_url'] . '/empty.png'; $msize = getimagesize($_MG_CONF['path_mediaobjects'] . 'empty.png'); } $atnsize = ''; if ($msize != false) { list($newwidth, $newheight) = Media::getImageWH($msize[0], $msize[1], 50, 50); $atnsize = 'width="' . $newwidth . '" height="' . $newheight . '" '; } $T->set_var('album_cover', '<img src="' . $url_thumb . '" alt="" ' . $atnsize . 'style="border:none;vertical-align:bottom;"' . XHTML . '>'); $T->set_var('album_begin_href', '<a href="' . $url_album . '">'); $T->set_var('album_title', strip_tags($row['album_title'])); $T->set_var('album_end_href', '</a>'); $T->set_var('album_desc', strip_tags($row['album_desc'])); $T->set_var('rowclass', $class % 2 ? '1' : '2'); $T->parse('iRow', 'itemRow', true); $class++; $aCount++; } if ($aCount != 0) { $retval .= $T->finish($T->parse('output', 'ablock')); } return $retval; }
function MG_MassdeleteAlbum($album_id) { global $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00; // need to check perms here... $album_data = MG_getAlbumData($album_id, array('album_parent'), true); if ($album_data['access'] != 3) { COM_errorLog("MediaGallery: Someone has tried to illegally delete an album in Media Gallery. " . "User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: " . $_SERVER['REMOTE_ADDR'], 1); return COM_showMessageText($LANG_MG00['access_denied_msg']); } MG_MassdeleteChildAlbums($album_id); if ($_MG_CONF['member_albums'] == 1 && $album_data['parent'] == $_MG_CONF['member_album_root']) { $result = DB_query("SELECT * FROM {$_TABLES['mg_albums']} WHERE owner_id=" . $album_data['owner_id'] . " AND album_parent=" . $album_data['parent']); $numRows = DB_numRows($result); if ($numRows == 0) { DB_change($_TABLES['mg_userprefs'], 'member_gallery', 0, 'uid', $album_data['owner_id']); } } require_once $_CONF['path'] . 'plugins/mediagallery/include/rssfeed.php'; MG_buildFullRSS(); echo COM_refresh($_MG_CONF['admin_url'] . 'index.php?msg=15'); }
* Main */ function MG_access_denied() { global $LANG_MG00, $LANG_ACCESS; $display = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); $display = MG_createHTMLDocument($display); COM_output($display); exit; } if (!isset($_USER['uid'])) { $_USER['uid'] = 1; } $s = COM_applyFilter($_GET['s']); $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . addslashes($s) . '"'); $album_data = MG_getAlbumData($aid, array('full_display'), true); if ($album_data['access'] == 0) { MG_access_denied(); exit; } if ($album_data['full_display'] == 2 || $_MG_CONF['discard_original'] == 1 || $album_data['full_display'] == 1 && $_USER['uid'] < 2) { MG_access_denied(); exit; } $sql = "SELECT media_filename, media_mime_ext, media_title " . "FROM {$_TABLES['mg_media']} WHERE media_id='" . addslashes($s) . "'"; $result = DB_query($sql); $A = DB_fetchArray($result); if (empty($A)) { exit; } $src = MG_getFileUrl('orig', $A['media_filename'], $A['media_mime_ext']);
// +--------------------------------------------------------------------------+ require_once '../lib-common.php'; if (COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) { exit; } require_once $_CONF['path'] . 'plugins/mediagallery/include/common.php'; if ($_MG_CONF['verbose']) { COM_errorLog('album_rpc.php: invocation ------------------------'); } if (!isset($_REQUEST['aid'])) { COM_errorLog('album_rpc.php: invocation with no album parameter'); exit(0); } // retrieve the album_id passed $album_id = COM_applyFilter($_REQUEST['aid'], true); $album_data = MG_getAlbumData($album_id, array('album_id'), false); // check to ensure we have a valid album_id if (isset($album_data['album_id']) && $album_data['album_id'] == $album_id) { // retrieve the upload filesize limit $size_limit = MG_getUploadLimit($album_id); // retrieve the valid filetypes $valid_types = MG_getValidFileTypes($album_id); if ($_MG_CONF['verbose']) { COM_errorLog('album_id = ' . $album_id); COM_errorLog('size_limit = ' . $size_limit); COM_errorLog('valid_types = ' . $valid_types); COM_errorLog('album_rpc.php: normal termination ----------------'); } } else { COM_errorLog('album_rpc.php: invalid album id = ' . $album_id); $size_limit = 0;
$retval .= " <identifier>" . $row['media_id'] . "</identifier>\n"; $retval .= " <location>" . $PhotoURL . "</location>\n"; if ($media_thumbnail != '') { $retval .= " <image>" . $media_thumbnail . "</image>\n"; } else { if ($image != '') { $retval .= " <image>" . $image . "</image>\n"; } } $retval .= " </track>\n"; } } return $retval; } } /* * Main processing */ $aid = isset($_REQUEST['aid']) ? COM_applyFilter($_REQUEST['aid'], true) : 0; $album_data = MG_getAlbumData($aid, array('skin', 'album_id', 'album_title', 'tn_attached'), true); $xml = ''; $charset = COM_getCharset(); $xml .= "<?xml version=\"1.0\" encoding=\"" . $charset . "\"?>\n"; $xml .= "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"; $xml .= "<title>" . MG_escape($album_data['album_title']) . "</title>"; $xml .= " <trackList>\n"; $xml .= MG_getMP3Items($album_data); $xml .= " </trackList>\n"; $xml .= "</playlist>\n"; header("Content-type: text/xml; charset=" . $charset); echo $xml;
/** * Shows the statistics for the plugin on stats.php. If * $showsitestats is 1 then we are to only print the overall stats in the 'site * statistics' box otherwise we show the detailed stats for the plugin * * Universal Plugin: Modify/uncomment use it * * @param int showsitestate Flag to let us know which stats to get * @return string returns formatted HTML to insert in stats page * */ function MG_showstats($showsitestats) { global $_CONF, $_MG_CONF, $_TABLES, $LANG_MG00, $_USER; if (COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) { return; } $retval = ''; $sql = "SELECT a.album_id,m.media_original_filename,m.media_title,m.media_id,m.media_rating " . "FROM {$_TABLES['mg_albums']} AS a " . "LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON a.album_id=ma.album_id " . "LEFT JOIN {$_TABLES['mg_media']} AS m ON ma.media_id=m.media_id " . "WHERE m.media_rating <> 0 AND a.hidden=0 " . COM_getPermSQL('and') . " ORDER BY m.media_rating DESC LIMIT 10"; $result = DB_query($sql); $numrows = DB_numRows($result); if ($numrows > 0) { $header_arr = array(array('text' => $LANG_MG00['media_col_header'], 'field' => 'title', 'header_class' => 'stats-header-title'), array('text' => $LANG_MG00['rating'], 'field' => 'rating', 'field_class' => 'stats-list-count')); $data_arr = array(); $text_arr = array('has_menu' => false, 'title' => $LANG_MG00['stats_rate_title']); for ($i = 0; $i < $numrows; $i++) { $A = DB_fetchArray($result); if ($A['media_title'] == '' || $A['media_title'] == " ") { if ($A['media_original_filename'] == '') { $album_data = MG_getAlbumData($A['album_id'], array('album_title')); $title = '<b>' . $LANG_MG00['album'] . '</b>' . '<em>' . strip_tags($album_data['album_title']) . ' - ' . $LANG_MG00['no_title'] . '</em>'; } else { $title = $A['media_original_filename']; } } else { $title = strip_tags($A['media_title']); } $S['title'] = '<a href="' . $_MG_CONF['site_url'] . '/media.php?s=' . $A['media_id'] . '">' . $title . '</a>'; $S['rating'] = @number_format($A['media_rating'] / 2, 2) . '/5.00'; $data_arr[] = $S; } $retval .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr); } $sql = "SELECT DISTINCT m.media_id,m.media_title,ma.album_id,m.media_original_filename,m.media_views " . "FROM {$_TABLES['mg_media']} AS m " . "LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id " . "WHERE m.media_views > 0 " . "ORDER BY m.media_views DESC LIMIT 10"; $result = DB_query($sql); $numrows = DB_numRows($result); if ($numrows > 0) { $header_arr = array(array('text' => $LANG_MG00['media_col_header'], 'field' => 'title', 'header_class' => 'stats-header-title'), array('text' => $LANG_MG00['hitsmsg'], 'field' => 'views', 'field_class' => 'stats-list-count')); $data_arr = array(); $text_arr = array('has_menu' => false, 'title' => $LANG_MG00['stats_title']); for ($i = 0; $i < $numrows; $i++) { $A = DB_fetchArray($result); $album_data = MG_getAlbumData($A['album_id'], array('album_title'), true); if ($A['media_id'] != '' && $album_data['access'] > 0) { if ($A['media_title'] == '' || $A['media_title'] == " ") { if ($A['media_original_filename'] == '') { $title = '<b>' . $LANG_MG00['album'] . '</b>' . '<em>' . strip_tags($album_data['album_title']) . ' - ' . $LANG_MG00['no_title'] . '</em>'; } else { $title = $A['media_original_filename']; } } else { $title = strip_tags($A['media_title']); } $S['title'] = '<a href="' . $_MG_CONF['site_url'] . '/media.php?s=' . $A['media_id'] . '">' . $title . '</a>'; $S['views'] = $A['media_views']; $data_arr[] = $S; } } $retval .= ADMIN_simpleList("", $header_arr, $text_arr, $data_arr); } return $retval; }
echo COM_refresh($_CONF['site_url'] . '/index.php'); exit; } if (COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) { $display = SEC_loginRequiredForm(); $display = MG_createHTMLDocument($display); COM_output($display); exit; } require_once $_CONF['path'] . 'plugins/mediagallery/include/common.php'; /* * Main */ COM_setArgNames(array('aid', 'f', 'sort')); $album_id = COM_applyFilter(COM_getArgument('aid'), true); $album_data = MG_getAlbumData($album_id, array('skin', 'album_title', 'album_desc'), true); if ($album_data['access'] == 0) { $display = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); $title = strip_tags($album_data['album_title']); $display = MG_createHTMLDocument($display, $title); COM_output($display); exit; } if ($_MG_CONF['usage_tracking']) { MG_updateUsage('playalbum', $album_data['album_title'], '', ''); } $pagination = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&page=1&sort=' . '0' . '">' . $LANG_MG03['return_to_album'] . '</a>'; $T = COM_newTemplate(MG_getTemplatePath($album_id)); $T->set_file('page', 'playall_xspf.thtml'); $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'pagination' => $pagination, 'album_title' => $album_data['album_title'], 'album_desc' => $album_data['album_desc'], 'aid' => $album_id, 'home' => $LANG_MG03['home'], 'return_to_album' => $LANG_MG03['return_to_album'])); /*
$xml .= " <link>" . $_MG_CONF['site_url'] . "</link>\n"; $xml .= " <description>XML Mini SlideShow for Media Gallery</description>\n"; $xml .= " <language>en-us</language>\n"; $xml .= " <generator>Media Gallery</generator>\n"; $xml .= " <lastBuildDate>" . date('r', time()) . "</lastBuildDate>\n"; $xml .= " <ttl>120</ttl>\n"; if (isset($album_data['album_id'])) { $xml .= " <album>\n"; $xml .= " <title><![CDATA[" . $album_data['album_title'] . "]]></title>\n"; $xml .= " <parentId><![CDATA[" . $album_data['album_parent'] . "]]></parentId>\n"; $xml .= " <owner><![CDATA[" . $album_data['owner_id'] . "]]></owner>\n"; $xml .= " <id><![CDATA[" . $album_data['album_id'] . "]]></id>\n"; $xml .= " </album>\n"; $children = MG_getAlbumChildren($aid); foreach ($children as $child) { $child_data = MG_getAlbumData($child, array('album_id', 'album_title', 'album_parent'), true); if ($child_data['access'] >= 1) { $xml .= " <album>\n"; $xml .= " <title><![CDATA[" . $child_data['album_title'] . "]]></title>\n"; $xml .= " <parentId><![CDATA[" . $child_data['album_parent'] . "]]></parentId>\n"; $xml .= " <owner><![CDATA[" . $child_data['owner_id'] . "]]></owner>\n"; $xml .= " <id><![CDATA[" . $child_data['album_id'] . "]]></id>\n"; $xml .= " </album>\n"; } } } if (isset($album_data['album_id']) && $album_data['access'] >= 1) { $sql = MG_buildMediaSql(array('album_id' => $aid, 'fields' => array('media_type', 'media_filename', 'remote_url', 'media_id', 'media_title', 'mime_type', 'media_upload_time'), 'where' => 'm.include_ss = 1')); $result = DB_query($sql); while ($row = DB_fetchArray($result)) { if ($row['media_type'] == 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 */ $tag = str_replace(' ', ' ', $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&sort=0&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('$', '$', $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); }
function MG_albumRebuildThumbs($aid, $actionURL) { global $_CONF, $_TABLES, $_MG_CONF, $LANG_MG01; $album_data = MG_getAlbumData($aid, array('album_title'), true); if ($album_data['access'] != 3) { echo COM_refresh($actionURL); exit; } require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-upload.php'; $sql = MG_buildMediaSql(array('album_id' => $aid, 'where' => "m.media_type = 0", 'sortorder' => -1)); $result = DB_query($sql); $nRows = DB_numRows($result); if ($nRows <= 0) { echo COM_refresh($actionURL); exit; } $session_description = sprintf($LANG_MG01['batch_rebuild_thumbs'], $album_data['album_title']); $session_id = MG_beginSession('rebuildthumb', $actionURL, $session_description); for ($x = 0; $x < $nRows; $x++) { $row = DB_fetchArray($result); $srcImage = ''; $imageDisplay = ''; $mfn = $row['media_filename'][0] . '/' . $row['media_filename']; if ($_MG_CONF['discard_original'] == 1) { $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . 'disp/' . $mfn); if (!empty($ext)) { $srcImage = $_MG_CONF['path_mediaobjects'] . 'disp/' . $mfn . $ext; $imageDisplay = $_MG_CONF['path_mediaobjects'] . 'tn/' . $mfn . $ext; $row['mime_type'] = ''; } } else { $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . 'orig/' . $mfn); if (!empty($ext)) { $srcImage = $_MG_CONF['path_mediaobjects'] . 'orig/' . $mfn . $ext; $imageDisplay = $_MG_CONF['path_mediaobjects'] . 'tn/' . $mfn . $ext; } } if ($srcImage == '' || !file_exists($srcImage)) { $ext = MG_getMediaExt($_MG_CONF['path_mediaobjects'] . 'disp/' . $mfn); if (!empty($ext)) { $srcImage = $_MG_CONF['path_mediaobjects'] . 'disp/' . $mfn . $ext; $imageDisplay = $_MG_CONF['path_mediaobjects'] . 'tn/' . $mfn . $ext; $row['mime_type'] = ''; $row['media_mime_ext'] = $ext; } } if ($srcImage == '') { continue; } MG_registerSession(array('session_id' => $session_id, 'mid' => $row['mime_type'], 'aid' => $row['album_id'], 'data' => $srcImage, 'data2' => $imageDisplay, 'data3' => $row['media_mime_ext'])); } $display = MG_continueSession($session_id, 0, $_MG_CONF['def_refresh_rate']); $display = MG_createHTMLDocument($display, 'album_rebuild_thumbs'); echo $display; exit; }
function mg_batch_session_ftpimport($row) { global $_CONF, $_TABLES, $LANG_MG02; require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-upload.php'; require_once $_CONF['path'] . 'plugins/mediagallery/include/sort.php'; $srcFile = $row['data']; // full path $album_id = $row['aid']; $purgefiles = intval($row['data2']); $baseSrcFile = $row['data3']; // basefilename $directory = $row['mid']; $album_data = MG_getAlbumData($album_id, array('max_filesize')); $session_id = $row['session_id']; if ($directory == 1) { require_once $_CONF['path'] . 'plugins/mediagallery/include/albumedit.php'; $new_aid = MG_quickCreate($album_id, $baseSrcFile); $dir = $srcFile; // COM_stripslashes($srcFile); if (!($dh = @opendir($dir))) { COM_errorLog("Media Gallery: Error - unable process FTP import directory " . $dir); } else { while (($file = readdir($dh)) != false) { if ($file == '..' || $file == '.') { continue; } if ($file == 'Thumbs.db' || $file == 'thumbs.db') { continue; } $filetmp = $dir . '/' . $file; $mid = is_dir($filetmp) ? 1 : 0; $filename = basename($file); MG_registerSession(array('session_id' => $session_id, 'mid' => $mid, 'aid' => $new_aid, 'data' => $filetmp, 'data2' => $purgefiles, 'data3' => $filename)); if (DB_error()) { COM_errorLog("Media Gallery: Error - SQL error on inserting record into session_items table"); } } } } else { if ($album_data['max_filesize'] != 0 && filesize($srcFile) > $album_data['max_filesize']) { COM_errorLog("MediaGallery: File " . $baseSrcFile . " exceeds maximum filesize for this album."); $statusMsg = addslashes(sprintf($LANG_MG02['upload_exceeds_max_filesize'], $baseSrcFile)); MG_setSessionLog($session_id, $statusMsg); continue; } $filetype = "application/force-download"; $opt = array('upload' => 0, 'purgefiles' => $purgefiles, 'filetype' => $filetype); list($rc, $msg) = MG_getFile($srcFile, $baseSrcFile, $album_id, $opt); $statusMsg = addslashes($baseSrcFile . " " . $msg); MG_setSessionLog($session_id, $statusMsg); MG_SortMedia($album_id); @set_time_limit($time_limit + 20); } return; }
$PhotoPath = MG_getFilePath($src, $A['media_filename']); $ext = pathinfo($PhotoPath, PATHINFO_EXTENSION); $RelativePath = $_MG_CONF['mediaobjects_url'] . "/{$src}/"; $RelativeTNPath = $_MG_CONF['mediaobjects_url'] . '/tn/'; $RelativePath .= $A['media_filename'][0] . '/' . $A['media_filename'] . '.' . $ext; $RelativeTNPath .= $A['media_filename'][0] . '/' . $A['media_filename'] . '_150x150.' . $ext; $imgsize = @getimagesize($PhotoPath); if ($imgsize == false) { continue; } $title = '<p><b><font color="#ffffff" size="20">' . strip_tags($A['media_title']) . '</font></b></p>'; $desc = '<p>' . strip_tags($A['media_desc']) . '</p>'; $retval .= '<image ' . 'imageURL="' . $RelativePath . '" ' . 'thumbURL="' . $RelativeTNPath . '" ' . 'linkURL="' . $RelativePath . '" linkTarget="" >' . LB; $retval .= '<caption><![CDATA[' . $title . $desc . ']]></caption>' . LB; $retval .= '</image>' . LB; } return $retval; } $aid = isset($_REQUEST['aid']) ? COM_applyFilter($_REQUEST['aid'], true) : 0; $album_data = MG_getAlbumData($aid, array('album_id', 'display_image_size', 'album_title'), true); list($dImageWidth, $dImageHeight) = MG_getImageSize($album_data['display_image_size']); $dImageWidth = $dImageWidth - 70; $title = strip_tags($album_data['album_title']); $xml = ''; $charset = COM_getCharset(); $xml .= '<?xml version="1.0" encoding="' . $charset . '"?>' . LB; $xml .= '<simpleviewergallery title="' . $title . '" galleryStyle="' . $_MG_CONF['simpleviewer']['galleryStyle'] . '" maxImageWidth="' . $_MG_CONF['simpleviewer']['maxImageWidth'] . '" maxImageHeight="' . $_MG_CONF['simpleviewer']['maxImageHeight'] . '" textColor="' . $_MG_CONF['simpleviewer']['textColor'] . '" frameColor="' . $_MG_CONF['simpleviewer']['frameColor'] . '" frameWidth="' . $_MG_CONF['simpleviewer']['frameWidth'] . '" thumbColumns="' . $_MG_CONF['simpleviewer']['thumbColumns'] . '" thumbRows="' . $_MG_CONF['simpleviewer']['thumbRows'] . '" thumbPosition="' . $_MG_CONF['simpleviewer']['thumbPosition'] . '" showOpenButton="' . $_MG_CONF['simpleviewer']['showOpenButton'] . '" showFullscreenButton="' . $_MG_CONF['simpleviewer']['showFullscreenButton'] . '">' . LB; $xml .= MG_getItems($album_data); $xml .= '</simpleviewergallery>' . LB; header("Content-type: text/xml; charset=" . $charset); echo $xml;
if ($referrer == '') { $allowed = 1; } else { if (strpos($referrer, $_CONF['site_url']) !== false) { $allowed = 1; } } if ($allowed == 0) { return; } $mid = isset($_GET['mid']) ? COM_applyFilter($_GET['mid']) : ''; if (empty($mid)) { return; } $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . addslashes($mid) . '"'); $album_data = MG_getAlbumData($aid, array('album_id'), true); if ($album_data['access'] == 0) { $display = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); $display = MG_createHTMLDocument($display); COM_output($display); exit; } $sql = "SELECT * FROM {$_TABLES['mg_media']} WHERE media_id='" . addslashes($mid) . "'"; $result = DB_query($sql); while ($A = DB_fetchArray($result)) { $filename = $A['media_original_filename']; if (empty($filename)) { $filename = $A['media_filename'] . '.' . $A['media_mime_ext']; } $mime_type = $A['mime_type']; if ($mime_type == 'application/octet-stream' && strtolower($A['media_mime_ext']) == 'pdf') {
function MG_parseAlbumsRSS(&$rss, $aid) { global $_MG_CONF, $_CONF, $_TABLES; if ($aid == 0) { // root_album $children = MG_getAlbumChildren($aid); foreach ($children as $child) { MG_parseAlbumsRSS($rss, $child); } return; } $album_data = MG_getAlbumData($aid, array('hidden', 'last_update', 'media_count', 'perm_anon', 'album_title', 'album_desc', 'owner_id')); if ($album_data['hidden'] != 1) { if ($_MG_CONF['rss_ignore_empty'] == 1 && $album_data['last_update'] != 0 && $album_data['last_update'] != '' && $album_data['media_count'] > 0) { if ($_MG_CONF['rss_anonymous_only'] == 1 && $album_data['perm_anon'] > 0) { $item = new FeedItem(); $item->title = $album_data['album_title']; $item->link = $_MG_CONF['site_url'] . '/album.php?aid=' . $aid; $description = ''; $childCount = MG_getAlbumChildCount($aid); $description = 'Album contains ' . $album_data['media_count'] . ' item and ' . $childCount . ' sub-albums.<br' . XHTML . '><br' . XHTML . '>'; $filename = MG_getAlbumCover($aid); if (substr($filename, 0, 3) == 'tn_') { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[3] . '/' . $filename . $ext)) { $description .= '<img src="' . $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[3] . '/' . $filename . $ext . '" align="left"' . XHTML . '>'; break; } } // $description .= '<img src="' . $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[3] . '/' . $filename . '.jpg" align="left"' . XHTML . '>'; } elseif ($filename != '') { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) { $description .= '<img src="' . $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext . '" align="left"' . XHTML . '>'; break; } } // $description .= '<img src="' . $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . '.jpg" align="left"' . XHTML . '>'; } $description .= $album_data['album_desc']; $item->description = $description; //optional $item->descriptionTruncSize = 500; $item->descriptionHtmlSyndicated = true; $item->date = strftime("%a, %d %b %Y %H:%M:%S %z", $album_data['last_update']); $item->source = $_CONF['site_url']; if ($album_data['owner_id'] != '') { $username = DB_getItem($_TABLES['users'], 'username', "uid={$album_data['owner_id']}"); $item->author = $username; } $rss->addItem($item); } } } $children = MG_getAlbumChildren($aid); foreach ($children as $child) { MG_parseAlbumsRSS($rss, $child); } }