function MG_MassdeleteAlbum($album_id) { global $MG_albums, $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01; // need to check perms here... if ($MG_albums[$album_id]->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 MG_genericError($LANG_MG00['access_denied_msg']); } MG_MassdeleteChildAlbums($album_id); if ($_MG_CONF['member_albums'] == 1 && $MG_albums[$album_id]->parent == $_MG_CONF['member_album_root']) { $result = DB_query("SELECT * FROM {$_TABLES['mg_albums']} WHERE owner_id=" . $MG_albums[$album_id]->owner_id . " AND album_parent=" . $MG_albums[$album_id]->parent); $numRows = DB_numRows($result); if ($numRows == 0) { DB_query("UPDATE {$_TABLES['mg_userprefs']} SET member_gallery=0 WHERE uid=" . $MG_albums[$album_id]->owner_id, 1); } } MG_initAlbums(); require_once $_CONF['path'] . 'plugins/mediagallery/include/rssfeed.php'; MG_buildFullRSS(); }
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software Foundation, | // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | // | | // +--------------------------------------------------------------------------+ // require_once '../../../lib-common.php'; require_once '../../auth.inc.php'; require_once $_CONF['path'] . 'plugins/mediagallery/include/init.php'; require_once $_MG_CONF['path_admin'] . 'navigation.php'; require_once $_CONF['path'] . 'plugins/mediagallery/include/classFrame.php'; MG_initAlbums(); // Only let admin users access this page if (!SEC_hasRights('mediagallery.config')) { // Someone is trying to illegally access this page COM_errorLog("Someone has tried to illegally access the Media Gallery Configuration page. User id: {$_USER['uid']}, Username: {$_USER['username']}", 1); $display = COM_siteHeader(); $display .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_MG00['access_denied'], true); $display .= COM_siteFooter(true); echo $display; exit; } function MG_editConfig($msgString = '') { global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $LANG_DIRECTION, $LANG04; $retval = ''; $T = new Template($_MG_CONF['template_path'] . '/admin');
function MG_mediaEdit($album_id, $media_id, $actionURL = '', $mqueue = 0, $view = 0, $back = '') { global $MG_albums, $_USER, $_CONF, $_MG_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG07, $_POST, $_DB_dbms; MG_initAlbums(); if ($actionURL == '') { $actionURL = $_MG_CONF['site_url'] . '/index.php'; } $retval = ''; $preview = ''; $preview_end = ''; $srcURL = ''; if ($view) { $srcURL = '&s=1'; } $T = new Template(MG_getTemplatePath($album_id)); $T->set_file(array('admin' => 'mediaedit.thtml', 'asf_options' => 'edit_asf_options.thtml', 'mp3_options' => 'edit_mp3_options.thtml', 'swf_options' => 'edit_swf_options.thtml', 'mov_options' => 'edit_mov_options.thtml', 'flv_options' => 'edit_flv_options.thtml')); $T->set_var('album_id', $album_id); // a little sanity check, make sure the media item really belongs to the passed album. $match = 0; // Find which albums this image is already in... $sql = "SELECT album_id FROM " . ($mqueue ? $_TABLES['mg_media_album_queue'] : $_TABLES['mg_media_albums']) . " WHERE media_id='" . DB_escapeString($media_id) . "'"; $result = DB_query($sql); $nRows = DB_numRows($result); $albums = array(); for ($i = 0; $i < $nRows; $i++) { $row = DB_fetchArray($result); $albums[$i] = $row['album_id']; if ($row['album_id'] == $album_id) { $match = 1; } } // pull the media information from the database... $sql = "SELECT * FROM " . ($mqueue ? $_TABLES['mg_mediaqueue'] : $_TABLES['mg_media']) . " WHERE media_id='" . DB_escapeString($media_id) . "'"; $result = DB_query($sql); $row = DB_fetchArray($result); if ($MG_albums[$album_id]->access != 3 && !SEC_inGroup($MG_albums[$album_id]->mod_group_id) && $row['media_user_id'] != $_USER['uid']) { COM_errorLog("Someone has tried to illegally sort albums in Media Gallery. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return MG_genericError($LANG_MG00['access_denied_msg']); } // Build Album List $level = 0; $album_jumpbox = '<select name="albums" width="40">'; $MG_albums[0]->buildJumpBox($album_id); $album_jumpbox .= '</select>'; // should check the above for errors, etc... if ($row['media_type'] == 0) { if (!function_exists('MG_readEXIF')) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php'; } $exif_info = MG_readEXIF($row['media_id'], 1, $mqueue); if ($exif_info == '') { $exif_info = ''; } } else { $exif_info = ''; } $dtObject = new Date($row['media_time'], $_USER['tzid']); $media_time_month = $dtObject->month; $media_time_day = $dtObject->day; $media_time_year = $dtObject->year; $media_time_hour = $dtObject->hour; $media_time_minute = $dtObject->minute; $month_select = '<select name="media_month">'; $month_select .= COM_getMonthFormOptions($media_time_month); $month_select .= '</select>'; $day_select = '<select name="media_day">'; for ($i = 1; $i < 32; $i++) { $day_select .= '<option value="' . $i . '"' . ($media_time_day == $i ? 'selected="selected"' : "") . '>' . $i . '</option>'; } $day_select .= '</select>'; $current_year = (int) date("Y"); $end_year = $current_year + 10; $year_select = '<select name="media_year">'; for ($i = 1998; $i < $end_year; $i++) { $year_select .= '<option value="' . $i . '"' . ($media_time_year == $i ? 'selected="selected"' : "") . '>' . $i . '</option>'; } $year_select .= '</select>'; $hour_select = '<select name="media_hour">'; for ($i = 0; $i < 24; $i++) { $hour_select .= '<option value="' . $i . '"' . ($media_time_hour == $i ? 'selected="selected"' : "") . '>' . $i . '</option>'; } $hour_select .= '</select>'; $minute_select = '<select name="media_minute">'; for ($i = 0; $i < 60; $i++) { $minute_select .= '<option value="' . $i . '"' . ($media_time_minute == $i ? 'selected="selected"' : "") . '>' . ($i < 10 ? '0' : '') . $i . '</option>'; } $minute_select .= '</select>'; $i = 0; switch ($row['media_type']) { case 0: if (!file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'])) { $pThumbnail = $row['media_filename'][0] . '/' . $row['media_filename'] . '.jpg'; } else { $pThumbnail = $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; } $thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $pThumbnail; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $pThumbnail); if ($_CONF['image_lib'] == 'gdlib' && !function_exists("imagerotate")) { $rotate_right = ''; $rotate_left = ''; } else { $rotate_right = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=rotate&action=right' . $srcURL . '&queue=' . $mqueue . '&media_id=' . $row['media_id'] . '&album_id=' . $album_id . '">' . '<img src="' . $_MG_CONF['site_url'] . '/images/rotate_right_icon.gif" alt="' . $LANG_MG01['rotate_left'] . '" style="border:none;"/></a>'; $rotate_left = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=rotate&action=left' . $srcURL . '&queue=' . $mqueue . '&media_id=' . $row['media_id'] . '&album_id=' . $album_id . '">' . '<img src="' . $_MG_CONF['site_url'] . '/images/rotate_left_icon.gif" alt="' . $LANG_MG01['rotate_right'] . '" style="border:none;"/></a>'; } break; case 1: switch ($row['mime_type']) { case 'video/x-flv': $thumbnail = $_MG_CONF['mediaobjects_url'] . '/flv.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'flv.png'); $preview = "<a href=\"javascript:showVideo('" . $_MG_CONF['site_url'] . "/video.php?n=" . $row['media_id'] . ($mqueue ? "&s=q" : '') . "',415,540)\">"; $preview_end = "</a>"; break; case 'application/x-shockwave-flash': $thumbnail = $_MG_CONF['mediaobjects_url'] . '/flash.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'flash.png'); $preview = "<a href=\"javascript:showVideo('" . $_MG_CONF['site_url'] . "/video.php?n=" . $row['media_id'] . ($mqueue ? "&s=q" : '') . "',415,540)\">"; $preview_end = "</a>"; break; case 'video/mpeg': case 'video/x-mpeg': case 'video/x-mpeq2a': if ($_MG_CONF['use_wmp_mpeg'] == 1) { $thumbnail = $_MG_CONF['mediaobjects_url'] . '/wmp.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'wmp.png'); $preview = "<a href=\"javascript:showVideo('" . $_MG_CONF['site_url'] . "/video.php?n=" . $row['media_id'] . ($mqueue ? "&s=q" : '') . "',415,540)\">"; $preview_end = "</a>"; break; } case 'video/x-motion-jpeg': case 'video/quicktime': case 'video/x-qtc': case 'audio/mpeg': $thumbnail = $_MG_CONF['mediaobjects_url'] . '/quicktime.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'quicktime.png'); $preview = "<a href=\"javascript:showVideo('" . $_MG_CONF['site_url'] . "/video.php?n=" . $row['media_id'] . ($mqueue ? "&s=q" : '') . "',415,540)\">"; $preview_end = "</a>"; 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': $thumbnail = $_MG_CONF['mediaobjects_url'] . '/wmp.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'wmp.png'); $preview = "<a href=\"javascript:showVideo('" . $_MG_CONF['site_url'] . "/video.php?n=" . $row['media_id'] . ($mqueue ? "&s=q" : '') . "',415,540)\">"; $preview_end = "</a>"; break; default: $thumbnail = $_MG_CONF['mediaobjects_url'] . '/video.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'video.png'); break; } $rotate_right = ''; $rotate_left = ''; break; case 2: $thumbnail = $_MG_CONF['mediaobjects_url'] . '/audio.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'audio.png'); $preview = "<a href=\"javascript:showVideo('" . $_MG_CONF['site_url'] . "/video.php?n=" . $row['media_id'] . ($mqueue ? "&s=q" : '') . "',325,330)\">"; $preview_end = "</a>"; $rotate_right = ''; $rotate_left = ''; break; case 4: switch ($row['mime_type']) { case 'application/zip': $thumbnail = $_MG_CONF['mediaobjects_url'] . '/zip.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'zip.png'); break; case 'application/pdf': $thumbnail = $_MG_CONF['mediaobjects_url'] . '/pdf.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'pdf.png'); break; default: $thumbnail = $_MG_CONF['mediaobjects_url'] . '/generic.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'generic.png'); break; } $rotate_right = ''; $rotate_left = ''; break; case 5: $thumbnail = $_MG_CONF['mediaobjects_url'] . '/remote.png'; $size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'remote.png'); $rotate_left = ''; $rotate_right = ''; break; } $media_time = MG_getUserDateTimeFormat($row['media_time']); if ($row['media_tn_attached'] == 1) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) { $pAttachedThumbnail = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; $iAttachedThumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; break; } } $atnsize = @getimagesize($pAttachedThumbnail); if ($atnsize != FALSE) { if ($atnsize[0] > $atnsize[1]) { $ratio = $atnsize[0] / 200; $newwidth = 200; $newheight = round($atnsize[1] / $ratio); } else { $ratio = $atnsize[1] / 200; $newheight = 200; $newwidth = round($atnsize[0] / $ratio); } $atnsize = 'height="' . $newheight . '" width="' . $newwidth . '"'; } else { $atnsize = ''; } $T->set_var(array('attached_thumbnail' => '<img src="' . $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext . '" alt="" ' . $atnsize . '/>')); } // playback options, if needed... if ($row['mime_type'] == 'video/x-ms-asf' || $row['mime_type'] == 'video/x-ms-wvx' || $row['mime_type'] == 'video/x-ms-wm' || $row['mime_type'] == 'video/x-ms-wmx' || $row['mime_type'] == 'video/x-ms-wmv' || $row['mime_type'] == 'audio/x-ms-wma' || $row['mime_type'] == 'video/x-msvideo') { // pull defaults, then override... $playback_options['autostart'] = $_MG_CONF['asf_autostart']; $playback_options['enablecontextmenu'] = $_MG_CONF['asf_enablecontextmenu']; $playback_options['stretchtofit'] = $_MG_CONF['asf_stretchtofit']; $playback_options['uimode'] = $_MG_CONF['asf_uimode']; $playback_options['showstatusbar'] = $_MG_CONF['asf_showstatusbar']; $playback_options['playcount'] = $_MG_CONF['asf_playcount']; $playback_options['height'] = $_MG_CONF['asf_height']; $playback_options['width'] = $_MG_CONF['asf_width']; $playback_options['bgcolor'] = $_MG_CONF['asf_bgcolor']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($row['media_id']) . "'"); $poNumRows = DB_numRows($poResult); for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $uimode_select = '<select name="uimode">'; $uimode_select .= '<option value="none" ' . ($playback_options['uimode'] == 'none' ? ' selected="selected"' : '') . '>' . $LANG_MG07['none'] . '</option>'; $uimode_select .= '<option value="mini" ' . ($playback_options['uimode'] == 'mini' ? ' selected="selected"' : '') . '>' . $LANG_MG07['mini'] . '</option>'; $uimode_select .= '<option value="full" ' . ($playback_options['uimode'] == 'full' ? ' selected="selected"' : '') . '>' . $LANG_MG07['full'] . '</option>'; $uimode_select .= '</select>'; $T->set_var(array('autostart_enabled' => $playback_options['autostart'] ? ' checked="checked"' : '', 'autostart_disabled' => $playback_options['autostart'] ? '' : ' checked="checked"', 'enablecontextmenu_enabled' => $playback_options['enablecontextmenu'] ? ' checked="checked"' : '', 'enablecontextmenu_disabled' => $playback_options['enablecontextmenu'] ? '' : ' checked="checked"', 'stretchtofit_enabled' => $playback_options['stretchtofit'] ? ' checked="checked"' : '', 'stretchtofit_disabled' => $playback_options['stretchtofit'] ? '' : ' checked="checked"', 'showstatusbar_enabled' => $playback_options['showstatusbar'] ? ' checked="checked"' : '', 'showstatusbar_disabled' => $playback_options['showstatusbar'] ? '' : ' checked="checked"', 'uimode_select' => $uimode_select, 'uimode' => $playback_options['uimode'], 'playcount' => $playback_options['playcount'], 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => $playback_options['bgcolor'], 'lang_playcount' => $LANG_MG07['playcount'], 'lang_playcount_help' => $LANG_MG07['playcount_help'], 'lang_playback_options' => $LANG_MG07['playback_options'], 'lang_option' => $LANG_MG07['option'], 'lang_description' => $LANG_MG07['description'], 'lang_on' => $LANG_MG07['on'], 'lang_off' => $LANG_MG07['off'], 'lang_auto_start' => $LANG_MG07['auto_start'], 'lang_auto_start_help' => $LANG_MG07['auto_start_help'], 'lang_enable_context_menu' => $LANG_MG07['enable_context_menu'], 'lang_enable_context_menu_help' => $LANG_MG07['enable_context_menu_help'], 'lang_stretch_to_fit' => $LANG_MG07['stretch_to_fit'], 'lang_stretch_to_fit_help' => $LANG_MG07['stretch_to_fit_help'], 'lang_status_bar' => $LANG_MG07['status_bar'], 'lang_status_bar_help' => $LANG_MG07['status_bar_help'], 'lang_ui_mode' => $LANG_MG07['ui_mode'], 'lang_ui_mode_help' => $LANG_MG07['ui_mode_help'], 'lang_height' => $LANG_MG07['height'], 'lang_width' => $LANG_MG07['width'], 'lang_height_help' => $LANG_MG07['height_help'], 'lang_width_help' => $LANG_MG07['width_help'], 'lang_bgcolor' => $LANG_MG07['bgcolor'], 'lang_resolution' => $LANG_MG07['resolution'], 'resolution' => $row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0 ? $row['media_resolution_x'] . 'x' . $row['media_resolution_y'] : 'unknown', 'lang_bgcolor_help' => $LANG_MG07['bgcolor_help'])); $T->parse('playback_options', 'asf_options'); } if ($row['mime_type'] == 'audio/mpeg') { // pull defaults, then override... $playback_options['autostart'] = $_MG_CONF['mp3_autostart']; $playback_options['enablecontextmenu'] = $_MG_CONF['mp3_enablecontextmenu']; $playback_options['uimode'] = $_MG_CONF['mp3_uimode']; $playback_options['showstatusbar'] = $_MG_CONF['mp3_showstatusbar']; $playback_options['loop'] = $_MG_CONF['mp3_loop']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($row['media_id']) . "'"); $poNumRows = DB_numRows($poResult); for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $uimode_select = '<select name="uimode">'; $uimode_select .= '<option value="none" ' . ($playback_options['uimode'] == 'none' ? ' selected="selected"' : '') . '>' . $LANG_MG07['none'] . '</option>'; $uimode_select .= '<option value="mini" ' . ($playback_options['uimode'] == 'mini' ? ' selected="selected"' : '') . '>' . $LANG_MG07['mini'] . '</option>'; $uimode_select .= '<option value="full" ' . ($playback_options['uimode'] == 'full' ? ' selected="selected"' : '') . '>' . $LANG_MG07['full'] . '</option>'; $uimode_select .= '</select>'; $T->set_var(array('audio_tab' => true, 'autostart_enabled' => $playback_options['autostart'] ? ' checked="checked"' : '', 'autostart_disabled' => $playback_options['autostart'] ? '' : ' checked="checked"', 'enablecontextmenu_enabled' => $playback_options['enablecontextmenu'] ? ' checked="checked"' : '', 'enablecontextmenu_disabled' => $playback_options['enablecontextmenu'] ? '' : ' checked="checked"', 'showstatusbar_enabled' => $playback_options['showstatusbar'] ? ' checked="checked"' : '', 'showstatusbar_disabled' => $playback_options['showstatusbar'] ? '' : ' checked="checked"', 'loop_enabled' => $playback_options['loop'] ? ' checked="checked"' : '', 'loop_disabled' => $playback_options['loop'] ? '' : ' checked="checked"', 'uimode_select' => $uimode_select, 'uimode' => $playback_options['uimode'], 'lang_playback_options' => $LANG_MG07['playback_options'], 'lang_option' => $LANG_MG07['option'], 'lang_description' => $LANG_MG07['description'], 'lang_on' => $LANG_MG07['on'], 'lang_off' => $LANG_MG07['off'], 'lang_auto_start' => $LANG_MG07['auto_start'], 'lang_auto_start_help' => $LANG_MG07['auto_start_help'], 'lang_enable_context_menu' => $LANG_MG07['enable_context_menu'], 'lang_enable_context_menu_help' => $LANG_MG07['enable_context_menu_help'], 'lang_stretch_to_fit' => $LANG_MG07['stretch_to_fit'], 'lang_stretch_to_fit_help' => $LANG_MG07['stretch_to_fit_help'], 'lang_status_bar' => $LANG_MG07['status_bar'], 'lang_status_bar_help' => $LANG_MG07['status_bar_help'], 'lang_ui_mode' => $LANG_MG07['ui_mode'], 'lang_ui_mode_help' => $LANG_MG07['ui_mode_help'], 'lang_loop' => $LANG_MG07['loop'], 'lang_loop_help' => $LANG_MG07['loop_help'])); $T->parse('playback_options', 'mp3_options'); } if ($row['mime_type'] == 'application/x-shockwave-flash' || $row['mime_type'] == 'video/x-flv') { // pull defaults, then override... $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']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($row['media_id']) . "'"); $poNumRows = DB_numRows($poResult); for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $quality_select = '<select name="quality">'; $quality_select .= '<option value="low" ' . ($playback_options['quality'] == 'low' ? ' selected="selected"' : '') . '>' . $LANG_MG07['low'] . '</option>'; $quality_select .= '<option value="high" ' . ($playback_options['quality'] == 'high' ? ' selected="selected"' : '') . '>' . $LANG_MG07['high'] . '</option>'; $quality_select .= '</select>'; $scale_select = '<select name="scale">'; $scale_select .= '<option value="showall" ' . ($playback_options['scale'] == 'showall' ? ' selected="selected"' : '') . '>' . $LANG_MG07['showall'] . '</option>'; $scale_select .= '<option value="noborder" ' . ($playback_options['scale'] == 'noborder' ? ' selected="selected"' : '') . '>' . $LANG_MG07['noborder'] . '</option>'; $scale_select .= '<option value="exactfit" ' . ($playback_options['scale'] == 'exactfit' ? ' selected="selected"' : '') . '>' . $LANG_MG07['exactfit'] . '</option>'; $scale_select .= '</select>'; $wmode_select = '<select name="wmode">'; $wmode_select .= '<option value="window" ' . ($playback_options['wmode'] == 'window' ? ' selected="selected"' : '') . '>' . $LANG_MG07['window'] . '</option>'; $wmode_select .= '<option value="opaque" ' . ($playback_options['wmode'] == 'opaque' ? ' selected="selected"' : '') . '>' . $LANG_MG07['opaque'] . '</option>'; $wmode_select .= '<option value="transparent" ' . ($playback_options['wmode'] == 'transparent' ? ' selected="selected"' : '') . '>' . $LANG_MG07['transparent'] . '</option>'; $wmode_select .= '</select>'; $asa_select = '<select name="allowscriptaccess">'; $asa_select .= '<option value="always" ' . ($playback_options['allowscriptaccess'] == 'always' ? ' selected="selected"' : '') . '>' . $LANG_MG07['always'] . '</option>'; $asa_select .= '<option value="sameDomain" ' . ($playback_options['allowscriptaccess'] == 'sameDomain' ? ' selected="selected"' : '') . '>' . $LANG_MG07['sameDomain'] . '</option>'; $asa_select .= '<option value="never" ' . ($playback_options['allowscriptaccess'] == 'never' ? ' selected="selected"' : '') . '>' . $LANG_MG07['never'] . '</option>'; $asa_select .= '</select>'; $T->set_var(array('play_enabled' => $playback_options['play'] ? ' checked="checked"' : '', 'play_disabled' => $playback_options['play'] ? '' : ' checked="checked"', 'menu_enabled' => $playback_options['menu'] ? ' checked="checked"' : '', 'menu_disabled' => $playback_options['menu'] ? '' : ' checked="checked"', 'loop_enabled' => $playback_options['loop'] ? ' checked="checked"' : '', 'loop_disabled' => $playback_options['loop'] ? '' : ' checked="checked"', 'quality_select' => $quality_select, 'scale_select' => $scale_select, 'wmode_select' => $wmode_select, 'asa_select' => $asa_select, 'flashvars' => isset($playback_options['flashvars']) ? $playback_options['flashvars'] : '', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => $playback_options['bgcolor'], 'swf_version' => $playback_options['swf_version'], 'lang_playback_options' => $LANG_MG07['playback_options'], 'lang_option' => $LANG_MG07['option'], 'lang_description' => $LANG_MG07['description'], 'lang_on' => $LANG_MG07['on'], 'lang_off' => $LANG_MG07['off'], 'lang_height' => $LANG_MG07['height'], 'lang_width' => $LANG_MG07['width'], 'lang_height_help' => $LANG_MG07['height_help'], 'lang_width_help' => $LANG_MG07['width_help'], 'lang_auto_start' => $LANG_MG07['auto_start'], 'lang_auto_start_help' => $LANG_MG07['auto_start_help'], 'lang_menu' => $LANG_MG07['menu'], 'lang_menu_help' => $LANG_MG07['menu_help'], 'lang_scale' => $LANG_MG07['scale'], 'lang_swf_scale_help' => $LANG_MG07['swf_scale_help'], 'lang_wmode' => $LANG_MG07['wmode'], 'lang_wmode_help' => $LANG_MG07['wmode_help'], 'lang_loop' => $LANG_MG07['loop'], 'lang_loop_help' => $LANG_MG07['loop_help'], 'lang_quality' => $LANG_MG07['quality'], 'lang_quality_help' => $LANG_MG07['quality_help'], 'lang_flash_vars' => $LANG_MG07['flash_vars'], 'lang_asa' => $LANG_MG07['asa'], 'lang_asa_help' => $LANG_MG07['asa_help'], 'lang_bgcolor' => $LANG_MG07['bgcolor'], 'lang_bgcolor_help' => $LANG_MG07['bgcolor_help'], 'lang_swf_version_help' => $LANG_MG07['swf_version_help'])); if ($row['mime_type'] == 'application/x-shockwave-flash') { $T->parse('playback_options', 'swf_options'); } else { $T->parse('playback_options', 'flv_options'); } } if ($row['media_mime_ext'] == 'mov' || $row['media_mime_ext'] == 'mp4' || $row['mime_type'] == 'video/quicktime' || $row['mime_type'] == 'video/mpeg') { // pull defaults, then override... $playback_options['autoref'] = $_MG_CONF['mov_autoref']; $playback_options['autoplay'] = $_MG_CONF['mov_autoplay']; $playback_options['controller'] = $_MG_CONF['mov_controller']; $playback_options['kioskmode'] = isset($_MG_CONF['mov_kioskmod']) ? $_MG_CONF['mov_kiokmode'] : ''; $playback_options['scale'] = $_MG_CONF['mov_scale']; $playback_options['loop'] = $_MG_CONF['mov_loop']; $playback_options['height'] = $_MG_CONF['mov_height']; $playback_options['width'] = $_MG_CONF['mov_width']; $playback_options['bgcolor'] = $_MG_CONF['mov_bgcolor']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . DB_escapeString($row['media_id']) . "'"); $poNumRows = DB_numRows($poResult); for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $scale_select = '<select name="scale">'; $scale_select .= '<option value="tofit" ' . ($playback_options['scale'] == 'tofit' ? ' selected="selected"' : '') . '>' . $LANG_MG07['to_fit'] . '</option>'; $scale_select .= '<option value="aspect" ' . ($playback_options['scale'] == 'aspect' ? ' selected="selected"' : '') . '>' . $LANG_MG07['aspect'] . '</option>'; $scale_select .= '<option value="1" ' . ($playback_options['scale'] == '1' ? ' selected="selected"' : '') . '>' . $LANG_MG07['normal_size'] . '</option>'; $scale_select .= '</select>'; $T->set_var(array('autoref_enabled' => $playback_options['autoref'] ? ' checked="checked"' : '', 'autoref_disabled' => $playback_options['autoref'] ? '' : ' checked="checked"', 'autoplay_enabled' => $playback_options['autoplay'] ? ' checked="checked"' : '', 'autoplay_disabled' => $playback_options['autoplay'] ? '' : ' checked="checked"', 'controller_enabled' => $playback_options['controller'] ? ' checked="checked"' : '', 'controller_disabled' => $playback_options['controller'] ? '' : ' checked="checked"', 'kioskmode_enabled' => $playback_options['kioskmode'] ? ' checked="checked"' : '', 'kioskmode_disabled' => $playback_options['kioskmode'] ? '' : ' checked="checked"', 'scale_select' => $scale_select, 'loop_enabled' => $playback_options['loop'] ? ' checked="checked"' : '', 'loop_disabled' => $playback_options['loop'] ? '' : ' checked="checked"', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => $playback_options['bgcolor'], 'lang_playback_options' => $LANG_MG07['playback_options'], 'lang_option' => $LANG_MG07['option'], 'lang_description' => $LANG_MG07['description'], 'lang_on' => $LANG_MG07['on'], 'lang_off' => $LANG_MG07['off'], 'lang_height' => $LANG_MG07['height'], 'lang_width' => $LANG_MG07['width'], 'lang_height_help' => $LANG_MG07['height_help'], 'lang_width_help' => $LANG_MG07['width_help'], 'lang_auto_start' => $LANG_MG07['auto_start'], 'lang_auto_start_help' => $LANG_MG07['auto_start_help'], 'lang_auto_ref' => $LANG_MG07['auto_ref'], 'lang_auto_ref_help' => $LANG_MG07['auto_ref_help'], 'lang_controller' => $LANG_MG07['controller'], 'lang_controller_help' => $LANG_MG07['controller_help'], 'lang_kiosk_mode' => $LANG_MG07['kiosk_mode'], 'lang_kiosk_mode_help' => $LANG_MG07['kiosk_mode_help'], 'lang_scale' => $LANG_MG07['scale'], 'lang_scale_help' => $LANG_MG07['scale_help'], 'lang_loop' => $LANG_MG07['loop'], 'lang_loop_help' => $LANG_MG07['loop_help'], 'lang_bgcolor' => $LANG_MG07['bgcolor'], 'lang_bgcolor_help' => $LANG_MG07['bgcolor_help'])); $T->parse('playback_options', 'mov_options'); } $T->set_var(array('original_filename' => $row['media_original_filename'], 'attach_tn' => $row['media_tn_attached'], 'at_tn_checked' => $row['media_tn_attached'] == 1 ? ' checked="checked"' : '', 'album_id' => $album_id, 'media_thumbnail' => $thumbnail, 'nocache' => time(), 'media_id' => $row['media_id'], 'media_title' => $row['media_title'], 'media_desc' => $row['media_desc'], 'media_time' => $media_time[0], 'media_views' => $row['media_views'], 'media_comments' => $row['media_comments'], 'media_exif_info' => $exif_info, 'media_rating_max' => 5, 'height' => $size[1] + 50, 'width' => $size[0] + 40, 'queue' => $mqueue, 'month_select' => $month_select, 'day_select' => $day_select, 'year_select' => $year_select, 'hour_select' => $hour_select, 'minute_select' => $minute_select, 'user_ip' => $row['media_user_ip'], 'album_select' => $album_jumpbox, 'media_rating' => $row['media_rating'] / 2, 'media_votes' => $row['media_votes'], 's_mode' => 'edit', 's_title' => $LANG_MG01['edit_media'], 's_rotate_right' => $rotate_right, 's_rotate_left' => $rotate_left, 's_form_action' => $actionURL, 'allowed_html' => COM_allowedHTML(SEC_getUserPermissions(), false, 'mediagallery', 'media_title'), 'site_url' => $_MG_CONF['site_url'], 'preview' => $preview, 'preview_end' => $preview_end)); if ($row['remote_media'] == 1) { $T->set_var(array('remoteurl' => $row['remote_url'], 'lang_remote_url' => $LANG_MG01['remote_url'])); } else { $T->set_var(array('remoteurl' => $row['remote_url'], 'lang_remote_url' => $LANG_MG01['alternate_url'])); } if ($row['media_type'] == 1) { $T->set_var(array('lang_resolution' => $LANG_MG07['resolution'], 'resolution' => $row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0 ? $row['media_resolution_x'] . 'x' . $row['media_resolution_y'] : 'unknown')); } else { $T->set_var(array('lang_resolution' => '', 'resolution' => '')); } // Pull user information now if ($row['media_user_id'] != '') { if ($_CONF['show_fullname']) { $displayname = 'fullname'; } else { $displayname = 'username'; } $username = DB_getItem($_TABLES['users'], $displayname, "uid={$row['media_user_id']}"); } else { $username = ''; } $userselect = '<select name="owner_name"> '; $sql = "SELECT * FROM {$_TABLES['users']} WHERE status=3 AND uid > 1 ORDER BY username ASC"; $result = DB_query($sql); while ($userRow = DB_fetchArray($result)) { $userselect .= '<option value="' . $userRow['uid'] . '"' . ($userRow['uid'] == $row['media_user_id'] ? ' selected="selected"' : '') . '>' . $userRow['username'] . '</option>' . LB; } $userselect .= '</select>'; if (SEC_hasRights('mediagallery.admin')) { $T->set_var('username', $userselect); } else { $T->set_var('username', $username); } $cat_select = '<select name="cat_id" id="cat_id">'; $cat_select .= '<option value="">' . $LANG_MG01['no_category'] . '</option>'; $result = DB_query("SELECT * FROM {$_TABLES['mg_category']} ORDER BY cat_id ASC"); while ($catRow = DB_fetchArray($result)) { $cat_select .= '<option value="' . $catRow['cat_id'] . '" ' . ($catRow['cat_id'] == $row['media_category'] ? ' selected="selected"' : '') . '>' . $catRow['cat_name'] . '</option>'; } $cat_select .= '</select>'; // keywords $keywords = $row['media_keywords']; if ($back != '') { $T->set_var(array('rpath' => htmlentities($back, ENT_QUOTES, COM_getEncodingt()))); } else { $T->set_var(array('rpath' => '')); } $artist = $row['artist']; $musicalbum = $row['album']; $genre = $row['genre']; // language items... $T->set_var(array('lang_original_filename' => $LANG_MG01['original_filename'], 'lang_media_item' => $LANG_MG00['media_col_header'], 'lang_media_attributes' => $LANG_MG01['media_attributes'], 'lang_mediaattributes' => $LANG_MG01['mediaattributes'], 'lang_attached_thumbnail' => $LANG_MG01['attached_thumbnail'], 'lang_category' => $LANG_MG01['category'], 'lang_keywords' => $LANG_MG01['keywords'], 'lang_rating' => $LANG_MG03['rating'], 'lang_comments' => $LANG_MG03['comments'], 'lang_votes' => $LANG_MG03['votes'], 'media_edit_title' => $LANG_MG01['media_edit'], 'media_edit_help' => $LANG_MG01['media_edit_help'], 'rotate_left' => $LANG_MG01['rotate_left'], 'rotate_right' => $LANG_MG01['rotate_right'], 'lang_title' => $LANG_MG01['title'], 'albums' => $LANG_MG01['albums'], 'description' => $LANG_MG01['description'], 'capture_time' => $LANG_MG01['capture_time'], 'views' => $LANG_MG03['views'], 'uploaded_by' => $LANG_MG01['uploaded_by'], 'submit' => $LANG_MG01['submit'], 'cancel' => $LANG_MG01['cancel'], 'reset' => $LANG_MG01['reset'], 'lang_save' => $LANG_MG01['save'], 'lang_reset' => $LANG_MG01['reset'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_reset_rating' => $LANG_MG01['reset_rating'], 'lang_reset_views' => $LANG_MG01['reset_views'], 'cat_select' => $cat_select, 'media_keywords' => $keywords, 'lang_replacefile' => $LANG_MG01['replace_file'], 'artist' => $artist, 'musicalbum' => $musicalbum, 'genre' => $genre, 'lang_artist' => $LANG_MG01['artist'], 'lang_genre' => $LANG_MG01['genre'], 'lang_music_album' => $LANG_MG01['music_album'])); $T->parse('output', 'admin'); $retval .= $T->finish($T->get_var('output')); return $retval; }
function MG_editMemberDefaults() { global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_ACCESS, $LANG_DIRECTION; global $album_jumpbox, $album_selectbox, $MG_albums, $LANG04; MG_initAlbums(); $retval = ''; $T = new Template($_MG_CONF['template_path'] . '/admin'); $T->set_file(array('admin' => 'editmember.thtml', 'admin_formats' => 'editalbum_formats.thtml')); include_once $_CONF['path_system'] . "classes/navbar.class.php"; $navbar = new navbar(); $navbar->add_menuitem($LANG_MG01['member_albums'], 'showhideMGAdminEditorDiv("members",0);return false;', true); $navbar->add_menuitem($LANG_MG01['allowed_media_formats'], 'showhideMGAdminEditorDiv("media",1);return false;', true); $navbar->add_menuitem($LANG_MG01['album_attributes'], 'showhideMGAdminEditorDiv("attributes",2);return false;', true); $navbar->add_menuitem($LANG_MG01['anonymous_uploads_prompt'], 'showhideMGAdminEditorDiv("useruploads",3);return false;', true); $navbar->add_menuitem($LANG_ACCESS['accessrights'], 'showhideMGAdminEditorDiv("access",4);return false;', true); $navbar->set_selected($LANG_MG01['member_albums']); $T->set_var('navbar', $navbar->generate()); $T->set_var('no_javascript_warning', $LANG04[150]); $T->set_var(array('jpg_checked' => $_MG_CONF['member_valid_formats'] & MG_JPG ? ' checked="checked"' : '', 'png_checked' => $_MG_CONF['member_valid_formats'] & MG_PNG ? ' checked="checked"' : '', 'tif_checked' => $_MG_CONF['member_valid_formats'] & MG_TIF ? ' checked="checked"' : '', 'gif_checked' => $_MG_CONF['member_valid_formats'] & MG_GIF ? ' checked="checked"' : '', 'bmp_checked' => $_MG_CONF['member_valid_formats'] & MG_BMP ? ' checked="checked"' : '', 'tga_checked' => $_MG_CONF['member_valid_formats'] & MG_TGA ? ' checked="checked"' : '', 'psd_checked' => $_MG_CONF['member_valid_formats'] & MG_PSD ? ' checked="checked"' : '', 'mp3_checked' => $_MG_CONF['member_valid_formats'] & MG_MP3 ? ' checked="checked"' : '', 'ogg_checked' => $_MG_CONF['member_valid_formats'] & MG_OGG ? ' checked="checked"' : '', 'asf_checked' => $_MG_CONF['member_valid_formats'] & MG_ASF ? ' checked="checked"' : '', 'swf_checked' => $_MG_CONF['member_valid_formats'] & MG_SWF ? ' checked="checked"' : '', 'mov_checked' => $_MG_CONF['member_valid_formats'] & MG_MOV ? ' checked="checked"' : '', 'mp4_checked' => $_MG_CONF['member_valid_formats'] & MG_MP4 ? ' checked="checked"' : '', 'mpg_checked' => $_MG_CONF['member_valid_formats'] & MG_MPG ? ' checked="checked"' : '', 'zip_checked' => $_MG_CONF['member_valid_formats'] & MG_ZIP ? ' checked="checked"' : '', 'flv_checked' => $_MG_CONF['member_valid_formats'] & MG_FLV ? ' checked="checked"' : '', 'rflv_checked' => $_MG_CONF['member_valid_formats'] & MG_RFLV ? ' checked="checked"' : '', 'emb_checked' => $_MG_CONF['member_valid_formats'] & MG_EMB ? ' checked="checked"' : '', 'other_checked' => $_MG_CONF['member_valid_formats'] & MG_OTHER ? ' checked="checked"' : '', 'lang_jpg' => $LANG_MG01['jpg'], 'lang_png' => $LANG_MG01['png'], 'lang_tif' => $LANG_MG01['tif'], 'lang_gif' => $LANG_MG01['gif'], 'lang_bmp' => $LANG_MG01['bmp'], 'lang_tga' => $LANG_MG01['tga'], 'lang_psd' => $LANG_MG01['psd'], 'lang_mp3' => $LANG_MG01['mp3'], 'lang_ogg' => $LANG_MG01['ogg'], 'lang_asf' => $LANG_MG01['asf'], 'lang_swf' => $LANG_MG01['swf'], 'lang_mov' => $LANG_MG01['mov'], 'lang_mp4' => $LANG_MG01['mp4'], 'lang_mpg' => $LANG_MG01['mpg'], 'lang_zip' => $LANG_MG01['zip'], 'lang_flv' => $LANG_MG01['flv'], 'lang_rflv' => $LANG_MG01['rflv'], 'lang_emb' => $LANG_MG01['emb'], 'lang_other' => $LANG_MG01['other'], 'lang_allowed_formats' => $LANG_MG01['allowed_media_formats'], 'lang_image' => $LANG_MG01['image'], 'lang_audio' => $LANG_MG01['audio'], 'lang_video' => $LANG_MG01['video'])); $T->parse('valid_formats', 'admin_formats'); $member_albums = '<input type="checkbox" name="member_albums" value="1" ' . ($_MG_CONF['member_albums'] ? ' checked="checked"' : '') . '/>'; $auto_create = '<input type="checkbox" name="auto_create" value="1" ' . ($_MG_CONF['member_auto_create'] ? ' checked="checked"' : '') . '/>'; $allow_create = '<input type="checkbox" name="allow_create" value="1" ' . ($_MG_CONF['member_create_new'] ? ' checked="checked"' : '') . '/>'; $album_jumpbox = ''; $MG_albums[0]->buildJumpBox($_MG_CONF['member_album_root']); $album_list_root = '<select name="member_root">'; $album_list_root .= '<option value="0">' . $LANG_MG01['root_album'] . '</option>'; $album_list_root .= $album_jumpbox; $album_list_root .= '</select>'; $MG_albums[0]->buildAlbumBox($_MG_CONF['member_album_archive'], 3, -1, 'upload'); $member_archive = '<select name="member_archive">'; $member_archive .= '<option value="0">' . $LANG_MG01['do_not_archive'] . '</option>'; $member_archive .= $album_selectbox; $member_archive .= '</select>'; $T->set_var('site_url', $_CONF['site_url']); $T->set_var('site_admin_url', $_CONF['site_admin_url']); $ri_select = '<input type="checkbox" name="enable_random" value="1" ' . ($_MG_CONF['member_enable_random'] ? ' checked="checked"' : '') . '/>'; $max_image_height_input = '<input type="text" size="4" name="max_image_height" value="' . $_MG_CONF['member_max_height'] . '"' . '/>'; $max_image_width_input = '<input type="text" size="4" name="max_image_width" value="' . $_MG_CONF['member_max_width'] . '"' . '/>'; $max_filesize_input = '<input type="text" size="10" name="max_filesize" value="' . $_MG_CONF['member_max_filesize'] . '"' . '/>'; $email_mod_select = '<input type="checkbox" name="email_mod" value="1" ' . ($_MG_CONF['member_email_mod'] ? ' checked="checked"' : '') . '/>'; // permission template $usergroups = SEC_getUserGroups(); $groupdd = ''; $moddd = ''; $gresult = DB_query("SELECT grp_id FROM {$_TABLES['groups']} WHERE grp_name LIKE 'mediagallery Admin'"); $grow = DB_fetchArray($gresult); $grp_id = $grow['grp_id']; if (!isset($_MG_CONF['ad_group_id'])) { $_MG_CONF['ad_group_id'] = $grp_id; } if (!isset($_MG_CONF['member_mod_group_id'])) { $_MG_CONF['member_mod_group_id'] = $grp_id; } $groupdd .= '<select name="group_id">'; $moddd .= '<select name="mod_id">'; for ($i = 0; $i < count($usergroups); $i++) { $groupdd .= '<option value="' . $usergroups[key($usergroups)] . '"'; $moddd .= '<option value="' . $usergroups[key($usergroups)] . '"'; if ($_MG_CONF['ad_group_id'] == $usergroups[key($usergroups)]) { $groupdd .= ' selected="selected"'; $groupname = key($usergroups); } if ($_MG_CONF['member_mod_group_id'] == $usergroups[key($usergroups)]) { $moddd .= ' selected="selected"'; } $groupdd .= '>' . key($usergroups) . '</option>'; $moddd .= '>' . key($usergroups) . '</option>'; next($usergroups); } $groupdd .= '</select>'; $moddd .= '</select>'; $upload_select = '<input type="checkbox" name="uploads" value="1" ' . ($_MG_CONF['member_uploads'] ? ' checked="checked"' : '') . '/>'; $moderate_select = '<input type="checkbox" name="moderate" value="1" ' . ($_MG_CONF['member_moderate'] ? ' checked="checked"' : '') . '/>'; if (!isset($_MG_CONF['member_use_fullname'])) { $_MG_CONF['member_use_fullname'] = 0; } $fullname_select = '<input type="checkbox" name="member_use_fullname" value="1" ' . ($_MG_CONF['member_use_fullname'] ? ' checked="checked"' : '') . '/>'; if (!isset($_MG_CONF['feature_member_album'])) { $_MG_CONF['feature_member_album'] = 0; } $feature_select = '<input type="checkbox" name="feature_member_album" value="1" ' . ($_MG_CONF['feature_member_album'] ? ' checked="checked"' : '') . '/>'; if (!isset($_MG_CONF['allow_remote'])) { $_MG_CONF['allow_remote'] = 0; } $allow_remote = '<input type="checkbox" name="allow_remote" value="1" ' . ($_MG_CONF['allow_remote'] ? ' checked="checked"' : '') . '/>'; $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'member_albums' => $member_albums, 'album_list_root' => $album_list_root, 'member_archive' => $member_archive, 'auto_create' => $auto_create, 'allow_create' => $allow_create, 'ri_select' => $ri_select, 'height_input' => $max_image_height_input, 'width_input' => $max_image_width_input, 'email_mod_select' => $email_mod_select, 'uploads' => $upload_select, 'moderate' => $moderate_select, 'member_quota' => $_MG_CONF['member_quota'] / 1048576, 'max_filesize' => $_MG_CONF['member_max_filesize'] / 1024, 'member_use_fullname' => $fullname_select, 'feature_member_album' => $feature_select, 'allow_remote' => $allow_remote, 'lang_uploads' => $LANG_MG01['anonymous_uploads_prompt'], 'lang_accessrights' => $LANG_ACCESS['accessrights'], 'lang_owner' => $LANG_ACCESS['owner'], 'lang_group' => $LANG_ACCESS['group'], 'lang_permissions' => $LANG_ACCESS['permissions'], 'lang_perm_key' => $LANG_ACCESS['permissionskey'], 'permissions_editor' => SEC_getPermissionsHTML($_MG_CONF['member_perm_owner'], $_MG_CONF['member_perm_group'], $_MG_CONF['member_perm_members'], $_MG_CONF['member_perm_anon']), 'permissions_msg' => $LANG_ACCESS['permmsg'], 'group_dropdown' => $groupdd, 'mod_dropdown' => $moddd, 'lang_member_upload' => $LANG_MG01['member_upload'], 'lang_moderate_album' => $LANG_MG01['mod_album'], 'lang_mod_group' => $LANG_MG01['moderation_group'], 'lang_zero_unlimited' => $LANG_MG01['zero_unlimited'], 'lang_ri_enable' => $LANG_MG01['ri_enable'], 'lang_max_image_height' => $LANG_MG01['max_image_height'], 'lang_max_image_width' => $LANG_MG01['max_image_width'], 'lang_max_filesize' => $LANG_MG01['max_filesize'], 'lang_display_image_size' => $LANG_MG01['display_image_size'], 'lang_email_mods_on_submission' => $LANG_MG01['email_mods_on_submission'], 'lang_album_attributes' => $LANG_MG01['album_attributes'], 'lang_member_albums' => $LANG_MG01['member_albums'], 'lang_enable_member_albums' => $LANG_MG01['enable_member_albums'], 'lang_member_quota' => $LANG_MG01['default_member_quota'], 'lang_auto_create' => $LANG_MG01['auto_create'], 'lang_allow_create' => $LANG_MG01['allow_create'], 'lang_member_root' => $LANG_MG01['member_root'], 'lang_member_archive' => $LANG_MG01['member_archive'], 'lang_member_use_fullname' => $LANG_MG01['member_use_fullname'], 'lang_feature_member_album' => $LANG_MG01['feature_member_album'], 'lang_allow_remote' => $LANG_MG01['allow_remote'], 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 's_form_action' => $_MG_CONF['admin_url'] . 'member.php', 'rtl' => $LANG_DIRECTION == "rtl" ? "rtl" : "")); $T->parse('output', 'admin'); $retval .= $T->finish($T->get_var('output')); return $retval; }
function parse($p1, $p2 = '', $fulltag) { global $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG03, $_PLUGINS, $MG_albums, $_DB_dbms, $mg_installed_version; $retval = ''; $skip = 0; $itemsToDisplay = 15; if (!in_array('mediagallery', $_PLUGINS)) { return $retval; } // defaults: $itemsToDisplay = $p1; $uniqueID = md5($p1); if ($mg_installed_version != $_MG_CONF['pi_version']) { return $retval; } $truncate = 1; $caption = 0; $px = explode(' ', trim($p2)); if (is_array($px)) { foreach ($px as $part) { if (substr($part, 0, 9) == 'truncate:') { $a = explode(':', $part); $truncate = (int) $a[1]; $skip++; } elseif (substr($part, 0, 8) == 'caption:') { $a = explode(':', $part); $caption = (int) $a[1]; $skip++; } else { break; } } } if ($truncate == 1) { $truncate_word = 'true'; } else { $truncate_word = 'false'; } $outputHandle = outputHandler::getInstance(); $outputHandle->addLinkScript($_CONF['site_url'] . '/mediagallery/js/jquery.flex-images.js'); $outputHandle->addLinkStyle($_CONF['site_url'] . '/mediagallery/js/jquery.flex-images.css'); $hash = CACHE_security_hash(); $instance_id = 'whatsnew_newimages_' . $uniqueID . '_' . $hash . '_' . $_USER['theme']; if (($cache = CACHE_check_instance($instance_id, 0)) !== FALSE) { return $cache; } $imageArray = array(); require_once $_CONF['path'] . 'plugins/mediagallery/include/init.php'; MG_initAlbums(); $sql = "SELECT ma.album_id,m.media_user_id,m.media_id,m.media_filename,m.media_title,\n u.fullname FROM {$_TABLES['mg_albums']} as a\n LEFT JOIN {$_TABLES['mg_media_albums']} as ma\n on a.album_id=ma.album_id LEFT JOIN {$_TABLES['mg_media']} as m\n on ma.media_id=m.media_id\n LEFT JOIN {$_TABLES['users']} as u ON m.media_user_id=u.uid\n WHERE\n m.media_type=0 AND a.enable_random=1 AND a.hidden=0 " . COM_getPermSQL('and') . " ORDER BY m.media_upload_time DESC LIMIT " . (int) $itemsToDisplay; $result = DB_query($sql, 1); $nRows = DB_numRows($result); for ($x = 0; $x < $nRows; $x++) { $row = DB_fetchArray($result); $url_media = $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id']; $url_album = $_MG_CONF['site_url'] . '/album.php?aid=' . $row['album_id'] . '&s=' . $row['media_id'] . '#' . $row['media_id']; $msize = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; $msize = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext); $media_url = $_MG_CONF['site_url'] . '/mediaobjects/' . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; break; } } if ($msize == false) { continue; } $imageArray[] = array('url' => $media_url, 'height' => $msize[1], 'width' => $msize[0], 'link' => $url_media, 'caption' => $row['media_title']); } $retval .= '<div class="flex-images uk-panel uk-panel-box">'; foreach ($imageArray as $image) { $retval .= '<div class="item" data-w="' . $image['width'] . '" data-h="' . $image['height'] . '">'; if ($caption) { $retval .= '<div class="over uk-hidden-small">' . $image['caption'] . '</div>'; } $retval .= '<a href="' . $image['url'] . '" data-uk-lightbox>'; $retval .= '<img class="uk-thumbnail" src="' . $image['url'] . '">'; $retval .= '</a>'; $retval .= '</div>'; } $retval .= '</div>'; $retval .= '<script>$(\'.flex-images\').flexImages({rowHeight: 200, truncate:' . $truncate_word . '});</script>'; CACHE_create_instance($instance_id, $retval, 0); return $retval; }
function parse($p1, $p2 = '', $fulltag) { global $_CONF, $_TABLES, $_MG_CONF, $MG_albums; $retval = ''; $skip = 0; $template = 'mgslider.thtml'; $overlayPosition = 'top'; // top, bottom, left, right, center $kenBurns = false; $autoPlay = false; $px = explode(' ', trim($p2)); if (is_array($px)) { foreach ($px as $part) { if (substr($part, 0, 9) == 'autoplay:') { $a = explode(':', $part); $autoPlay = $a[1]; $skip++; } elseif (substr($part, 0, 9) == 'kenburns:') { $a = explode(':', $part); $kenBurns = $a[1]; $skip++; } elseif (substr($part, 0, 8) == 'overlay:') { $a = explode(':', $part); $overlayPosition = $a[1]; $skip++; } elseif (substr($part, 0, 9) == 'template:') { $a = explode(':', $part); $template = $a[1]; $skip++; } else { break; } } } MG_initAlbums(); if ($p1 == '' || $p1 == 0) { return $content; } if (!isset($MG_albums[$p1]->id) || $MG_albums[$p1]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } $T = new Template($_CONF['path'] . 'system/autotags/'); $T->set_file('page', $template); switch ($overlayPosition) { case 'center': $overlay_position = 'uk-flex uk-flex-center uk-flex-middle uk-text-center'; break; case 'top': $overlay_position = 'uk-overlay-top'; break; case 'bottom': $overlay_position = 'uk-overlay-bottom'; break; default: $overlay_position = 'uk-overlay-top'; break; } $options = ''; $T->set_var('overlay_position', $overlay_position); if ($kenBurns == true) { $options .= 'kenburns:true,'; } else { $options .= 'kenburns:false,'; } if ($autoPlay == true) { $options .= 'autoplay:true'; } $T->set_var('options', $options); $T->set_block('page', 'slides', 'sl'); $T->set_block('page', 'dotnav', 'dn'); $aid = (int) $p1; $counter = 0; $sql = "SELECT m.* FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id='" . DB_escapeString($aid) . "' AND m.media_type=0 AND m.include_ss=1 ORDER BY ma.media_order DESC"; $result = DB_query($sql); while ($row = DB_fetchArray($result)) { $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']); $ext = $row['media_mime_ext']; if ($media_size == false) { continue; } $T->set_var('image_url', $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext); $T->set_var('image_title', $row['media_title']); $T->set_var('image_desc', $row['media_desc']); $T->parse('sl', 'slides', true); $T->set_var('image_counter', $counter); $T->parse('dn', 'dotnav', true); $counter++; } $retval = $T->finish($T->parse('output', 'page')); return $retval; }
function _mg_autotags($op, $content = '', $autotag = '') { global $MG_albums, $_MG_CONF, $_CONF, $_MG_USERPREFS, $_TABLES, $LANG_MG00, $LANG_MG03, $side_count, $swfjsinclude; global $mgAutoTagArray, $mg_installed_version; static $ss_count = 0; if ($mg_installed_version != $_MG_CONF['pi_version']) { return $content; } $default_thumbnail = 'placeholder.svg'; if ($op == 'parse') { if (!isset($mgAutoTagArray['count']) || empty($mgAutoTagArray['count'])) { $mgAutoTagArray['count'] = 0; } /* * Process the auto tag to remove any embedded */ $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 */ $T = new Template($_MG_CONF['template_path']); // see if we have an alignment option included $caption = $autotag['parm2']; $aSet = 0; $skip = 0; // default values for parameters $border = $_MG_CONF['at_border']; $align = $_MG_CONF['at_align']; $width = $_MG_CONF['at_width']; $height = $_MG_CONF['at_height']; $src = $_MG_CONF['at_src']; $autoplay = $_MG_CONF['at_autoplay']; $enable_link = $_MG_CONF['at_enable_link']; $delay = $_MG_CONF['at_delay']; $transition = 'Fade'; $showtitle = $_MG_CONF['at_showtitle']; $destination = 'content'; $target = ''; $linkID = 0; $alt = 0; $link_src = 'disp'; $classes = ''; $nosize = 0; $tag = ''; if ($align != '') { $aSet = 1; } // parameter processing - logic borrowed from // Dirk Haun's Flickr plugin $px = explode(' ', trim($autotag['parm2'])); if (is_array($px)) { foreach ($px as $part) { if (substr($part, 0, 6) == 'width:') { $a = explode(':', $part); $width = $a[1]; $skip++; } elseif (substr($part, 0, 7) == 'height:') { $a = explode(':', $part); $height = $a[1]; $skip++; } elseif (substr($part, 0, 7) == 'border:') { $a = explode(':', $part); $border = $a[1]; $skip++; } elseif (substr($part, 0, 6) == 'align:') { $a = explode(':', $part); $align = $a[1]; $skip++; $aSet = 1; } elseif (substr($part, 0, 4) == 'src:') { $a = explode(':', $part); $src = $a[1]; $skip++; } elseif (substr($part, 0, 9) == 'autoplay:') { $a = explode(':', $part); $autoplay = $a[1]; $skip++; } elseif (substr($part, 0, 5) == 'link:') { $a = explode(':', $part); $enable_link = $a[1]; $skip++; } elseif (substr($part, 0, 6) == 'delay:') { $a = explode(':', $part); $delay = $a[1]; $skip++; } elseif (substr($part, 0, 11) == 'transition:') { $a = explode(':', $part); $transition = $a[1]; $skip++; } elseif (substr($part, 0, 6) == 'title:') { $a = explode(':', $part); $showtitle = $a[1]; $skip++; } elseif (substr($part, 0, 5) == 'dest:') { $a = explode(':', $part); $destination = $a[1]; $skip++; if ($destination != 'content' && $destination != 'block') { $destination = 'content'; } } elseif (substr($part, 0, 7) == 'linkid:') { $a = explode(':', $part); $linkID = $a[1]; $skip++; } elseif (substr($part, 0, 4) == 'alt:') { $a = explode(':', $part); $alt = $a[1]; $skip++; } elseif (substr($part, 0, 7) == 'target:') { $a = explode(':', $part); $target = $a[1]; $skip++; } elseif (substr($part, 0, 5) == 'type:') { $a = explode(':', $part); $mp3_type = $a[1]; $skip++; } elseif (substr($part, 0, 6) == 'class:') { $a = explode(':', $part); $c = explode(',', $a[1]); foreach ($c as $class) { $classes .= ' ' . $class; } $skip++; } elseif (substr($part, 0, 7) == 'nosize:') { $a = explode(':', $part); $nosize = $a[1]; $skip++; } elseif (substr($part, 0, 4) == 'tag:') { $a = explode(':', $part); $tag = str_replace('_', ' ', $a[1]); $skip++; } elseif (substr($part, 0, 8) == 'linksrc:') { $a = explode(':', $part); $link_src = $a[1]; if (!in_array($link_src, array('tn', 'disp', 'orig'))) { $link_src = 'disp'; } $skip++; } else { break; } } if ($skip != 0) { if (count($px) > $skip) { for ($i = 0; $i < $skip; $i++) { array_shift($px); } $caption = trim(implode(' ', $px)); } else { $caption = ''; } } } else { $caption = trim($autotag['parm2']); } if ($tag == '') { $tag = $caption; } if (!is_numeric($autotag['parm1'][0])) { switch ($autotag['parm1'][0]) { case 'n': $align = ''; $aSet = 1; break; case 'c': $align = "center"; $aSet = 1; break; case 'l': $align = "left"; $aSet = 1; break; case 'r': $align = "right"; $aSet = 1; break; case 'a': $align = !($side_count % 2) ? "left" : "right"; $side_count++; $aSet = 1; break; default: $align = !($side_count % 2) ? "left" : "right"; $side_count++; break; } $parm1 = COM_applyFilter(substr($autotag['parm1'], 1, strlen($autotag['parm1']) - 1)); } else { $parm1 = COM_applyFilter($autotag['parm1']); if ($aSet == 0 || $align == 'auto') { $align = !($side_count % 2) ? "left" : "right"; $side_count++; } } if ($align == 'none') { $align = ''; } if (!in_array($autotag['tag'], array('album', 'media', 'img', 'slideshow', 'fslideshow', 'video', 'audio', 'download', 'image', 'oimage', 'mlink', 'alink', 'playall'))) { return $content; } MG_initAlbums(); // sanity check incase the album has been deleted or something... if ($autotag['tag'] != 'media' && $autotag['tag'] != 'image' && $autotag['tag'] != 'video' && $autotag['tag'] != 'audio' && $autotag['tag'] != 'download' && $autotag['tag'] != 'oimage' && $autotag['tag'] != 'img' && $autotag['tag'] != 'mlink' && $autotag['tag'] != 'alink' && $autotag['tag'] != 'playall') { if (!isset($MG_albums[$parm1]->id)) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } } $ss_count = mt_rand(0, 32768); switch ($autotag['tag']) { case 'download': $side_count--; $sql = "SELECT ma.album_id FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'"; $result = DB_query($sql); if (DB_numRows($result) > 0) { $row = DB_fetchArray($result); $aid = $row['album_id']; if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } $link = '<a href="' . $_MG_CONF['site_url'] . '/download.php?mid=' . $parm1 . '">'; if ($caption != "") { $link .= $caption; } else { $link .= 'download'; } $link .= '</a>'; if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; } else { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } break; case 'mlink': $side_count--; $sql = "SELECT m.remote_url,ma.album_id FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'"; $result = DB_query($sql); if (DB_numRows($result) > 0) { $row = DB_fetchArray($result); $aid = $row['album_id']; if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } if ($alt == 1 && $row['remote_url'] != '') { $link = '<a href="' . $row['remote_url'] . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>'; } else { $link = '<a href="' . $_MG_CONF['site_url'] . '/media.php?f=0&sort=0&s=' . $parm1 . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>'; } if ($caption != "") { $link .= $caption; } else { $link .= $LANG_MG03['click_here']; } $link .= '</a>'; if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } $content = str_replace($autotag['tagstr'], $link, $content); return $content; } else { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } break; case 'playall': if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0 || COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } $V = new Template(MG_getTemplatePath(0)); $V->set_file(array('xspf' => 'xspf_radio.thtml')); $V->set_var(array('aid' => $parm1, 'site_url' => $_MG_CONF['site_url'], 'autoplay' => $autoplay ? 'play' : 'stop', 'id' => 'mp3radio' . rand(), 'id2' => 'mp3radio' . rand())); $V->parse('output', 'xspf'); if ($align != '' && $align != "center") { $link = '<span style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } else { if ($align == "center") { $link = '<span style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } else { $link = '<span style="padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } } if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } $content = str_replace($autotag['tagstr'], $link, $content); return $content; break; case 'video': $sql = "SELECT ma.album_id,m.media_id,m.mime_type,m.remote_url,m.media_filename,m.media_mime_ext,m.media_original_filename,m.media_tn_attached,m.media_resolution_x,m.media_resolution_y,m.remote_media FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'"; $result = DB_query($sql); if (DB_numRows($result) > 0) { $row = DB_fetchArray($result); $aid = $row['album_id']; if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } $meta_file_name = $_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; $meta = IMG_getMediaMetaData($meta_file_name); if ($meta['mime_type'] == 'video/quicktime' || $meta['mime_type'] == 'video/mp4') { if ($meta['fileformat'] == 'mp4') { $row['mime_type'] = 'video/mp4'; } } // determine height / width and aspect if (($width == 'auto' || $width == 0 || $width == -1 || $height == -1) && $row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0) { $videoheight = $row['media_resolution_y']; $videowidth = $row['media_resolution_x']; } else { if ($row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0) { if ($row['media_resolution_x'] >= $row['media_resolution_y']) { // landscape $ratio = $row['media_resolution_y'] / $row['media_resolution_x']; $orientation = 0; } else { // portrait $ratio = $row['media_resolution_x'] / $row['media_resolution_y']; $orientation = 1; } } else { $ratio = 0.75; $orientation = 0; } if ($orientation == 0) { if ($width > 0 && $height == 0) { $videoheight = round($width * $ratio); $videowidth = $width; } else { if ($width == 0 && $height == 0) { $videoheight = 200 * $ratio; $videowidth = 200; } else { if ($width == 0 && $height > 0) { $videowidth = round($height / $ratio); $videoheight = $height; } else { if ($width > 0 && $height > 0) { $videowidth = $width; $videoheight = $height; } } } } } else { if ($width > 0 && $height == 0) { $videoheight = round($width / $ratio); $videowidth = $width; } else { if ($width == 0 && $height == 0) { $videoheight = 200; $videowidth = round(200 / $ratio); } else { if ($width == 0 && $height > 0) { $videowidth = round($height * $ratio); $videoheight = $height; } else { if ($width > 0 && $height > 0) { $videowidth = $width; $videoheight = $height; } } } } } } switch ($row['mime_type']) { case 'embed': if (preg_match("/vimeo/i", $row['remote_url'])) { $vimeo = 'vimeo, '; } else { $vimeo = ''; } if ($align != '' && $align != "center") { $link = '<div class="js-video [' . $vimeo . 'widescreen] ' . $classes . '"><span style="float:' . $align . ';padding:5px;">' . $row['remote_url'] . '</span></div>'; } else { if ($align == 'center') { $link = '<div class="js-video [' . $vimeo . 'widescreen] ' . $classes . '"><span style="text-align:center;padding:5px;">' . $row['remote_url'] . '</span></div>'; } else { $link = '<div class="js-video [' . $vimeo . 'widescreen] ' . $classes . '"><span style="padding:5px;">' . $row['remote_url'] . '</span></div>'; } } if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; break; case 'video/x-ms-asf': case 'video/x-ms-asf-plugin': case 'video/avi': case 'video/msvideo': case 'video/x-msvideo': case 'video/avs-video': case 'video/x-ms-wmv': case 'video/x-ms-wvx': case 'video/x-ms-wm': case 'application/x-troff-msvideo': case 'application/x-ms-wmz': case 'application/x-ms-wmd': $V = new Template(MG_getTemplatePath(0)); $V->set_file('video', 'view_asf.thtml'); $V->set_var(array('autostart' => $autoplay ? 'true' : 'false', 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'false', 'showcontrols' => 'true', 'showdisplay' => 'false', 'height' => $videoheight, 'width' => $videowidth, 'bgcolor' => '#FFFFFF', 'playcount' => '9999', 'loop' => 'true', 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'], 'autostart0' => $autoplay ? '1' : '0', 'enablecontextmenu0' => '1', 'stretchtofit0' => '0', 'showstatusbar0' => '0', 'uimode0' => 'none', 'showcontrols0' => '1', 'showdisplay0' => '0')); $V->parse('output', 'video'); if ($align != '' && $align != "center") { $u_image = '<span style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } else { if ($align == 'center') { $u_image = '<span style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } else { $u_image = '<span style="padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } } break; case 'video/mp4': if ($row['media_tn_attached'] == 1) { $foundTN = 0; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . '/orig/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) { $thumb = $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; $media_size_orig = $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . '/orig/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext); $foundTN = 1; break; } } if ($foundTN == 0) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) { $thumb = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; $media_size_orig = $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext); break; } } } } else { $thumb = ''; //$_MG_CONF['mediaobjects_url'] . '/video-placeholder.png'; // $thumb = $_MG_CONF['mediaobjects_url'].'/placeholder_video_w.svg'; } $V = new Template(MG_getTemplatePath(0)); $V->set_file(array('video' => 'view_mp4.thtml')); $V->set_var(array('mime_type' => 'video/mp4', 'autoref' => 'true', 'autoplay' => $autoplay ? 'true' : 'false', 'autoplay_text' => $autoplay ? ' autoplay ' : '', 'controller' => 'true', 'kioskmode' => 'true', 'scale' => 'aspect', 'height' => $videoheight, 'width' => $videowidth, 'bgcolor' => '#F0F0F0', 'loop' => 'true', 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'], 'thumbnail' => $thumb, 'site_url' => $_MG_CONF['site_url'], 'player_url' => $_CONF['site_url'] . '/javascript/addons/mediaplayer/')); if ($align != '' && $align != "center") { $V->set_var('alignment', 'float:' . $align . ';'); } else { if ($align == 'center') { $V->set_var('alignment', 'text-align:center;'); } else { $V->set_var('alignment', 'text-align:center;'); } } $V->parse('output', 'video'); $u_image = $V->finish($V->get_var('output')); break; case 'video/mpeg': case 'video/x-motion-jpeg': case 'video/quicktime': case 'video/mpeg': case 'video/x-mpeg': case 'video/x-mpeq2a': case 'video/x-qtc': case 'video/x-m4v': $V = new Template(MG_getTemplatePath(0)); $V->set_file(array('video' => 'view_quicktime.thtml')); $V->set_var(array('autoref' => 'true', 'autoplay' => $autoplay ? 'true' : 'false', 'controller' => 'true', 'kioskmode' => 'true', 'scale' => 'aspect', 'height' => $videoheight, 'width' => $videowidth, 'bgcolor' => '#F0F0F0', 'loop' => 'true', 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'])); $V->parse('output', 'video'); if ($align != '' && $align != "center") { $u_image = '<div style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } else { if ($align == 'center') { $u_image = '<div style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } else { $u_image = '<div style="padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } } break; case 'application/x-shockwave-flash': // set the default playback options... $playback_options['play'] = $_MG_CONF['swf_play']; $playback_options['menu'] = $_MG_CONF['swf_menu']; $playback_options['quality'] = $_MG_CONF['swf_quality']; $playback_options['height'] = $_MG_CONF['swf_height']; $playback_options['width'] = $_MG_CONF['swf_width']; $playback_options['loop'] = $_MG_CONF['swf_loop']; $playback_options['scale'] = $_MG_CONF['swf_scale']; $playback_options['wmode'] = $_MG_CONF['swf_wmode']; $playback_options['allowscriptaccess'] = $_MG_CONF['swf_allowscriptaccess']; $playback_options['bgcolor'] = $_MG_CONF['swf_bgcolor']; $playback_options['swf_version'] = $_MG_CONF['swf_version']; $playback_options['flashvars'] = $_MG_CONF['swf_flashvars']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . $row['media_id'] . "'"); while ($poRow = DB_fetchArray($poResult)) { $playback_options[$poRow['option_name']] = $poRow['option_value']; } if ($swfjsinclude > 0) { $u_image = ''; } else { $S = new Template(MG_getTemplatePath(0)); $S->set_file(array('swf' => 'swfobject.thtml')); $S->set_var(array('site_url' => $_MG_CONF['site_url'])); $S->parse('output', 'swf'); $u_image = $S->finish($S->get_var('output')); $swfjsinclude++; } $V = new Template(MG_getTemplatePath(0)); $V->set_file(array('video' => 'view_swf.thtml')); $V->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'play' => $autoplay ? 'true' : 'false', 'menu' => $playback_options['menu'] ? 'true' : 'false', 'loop' => $playback_options['loop'] ? 'true' : 'false', 'scale' => $playback_options['scale'], 'wmode' => $playback_options['wmode'], 'flashvars' => $playback_options['flashvars'], 'quality' => $playback_options['quality'], 'height' => $videoheight, 'width' => $videowidth, 'asa' => $playback_options['allowscriptaccess'], 'bgcolor' => $playback_options['bgcolor'], 'swf_version' => $playback_options['swf_version'], 'filename' => $row['media_original_filename'], 'id' => $row['media_filename'] . rand(), 'id2' => $row['media_filename'] . rand(), 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'])); $V->parse('output', 'video'); if ($align != '' && $align != "center") { $u_image = '<div style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } else { if ($align == "center") { $u_image = '<div style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } else { $u_image = '<div style="padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } } break; case 'video/x-flv': // set the default playback options... $playback_options['play'] = $_MG_CONF['swf_play']; $playback_options['menu'] = $_MG_CONF['swf_menu']; $playback_options['quality'] = $_MG_CONF['swf_quality']; $playback_options['height'] = $_MG_CONF['swf_height']; $playback_options['width'] = $_MG_CONF['swf_width']; $playback_options['loop'] = $_MG_CONF['swf_loop']; $playback_options['scale'] = $_MG_CONF['swf_scale']; $playback_options['wmode'] = $_MG_CONF['swf_wmode']; $playback_options['allowscriptaccess'] = $_MG_CONF['swf_allowscriptaccess']; $playback_options['bgcolor'] = $_MG_CONF['swf_bgcolor']; $playback_options['swf_version'] = $_MG_CONF['swf_version']; $playback_options['flashvars'] = $_MG_CONF['swf_flashvars']; $poResult = DB_query("SELECT * FROM {$_TABLES['mg_playback_options']} WHERE media_id='" . $row['media_id'] . "'"); while ($poRow = DB_fetchArray($poResult)) { $playback_options[$poRow['option_name']] = $poRow['option_value']; } if ($swfjsinclude > 0) { $u_image = ''; } else { $S = new Template(MG_getTemplatePath(0)); $S->set_file(array('swf' => 'swfobject.thtml')); $S->set_var(array('site_url' => $_MG_CONF['site_url'])); $S->parse('output', 'swf'); $u_image = $S->finish($S->get_var('output')); $swfjsinclude++; } $V = new Template(MG_getTemplatePath(0)); $V->set_file('video', 'view_flv_light.thtml'); $playImage = MG_getImageFile('blank_blk.jpg'); // now the player specific items. $F = new Template(MG_getTemplatePath(0)); $F->set_file(array('player' => 'flvfp.thtml')); if ($autoplay == 1) { // auto start $playButton = ''; } else { if ($row['media_tn_attached'] == 1) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) { $playImage = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; break; } } } $playButton = "{ url: '" . $playImage . "', overlayId: 'play' },"; } if ($row['remote_media'] == 1) { $urlParts = array(); $urlParts = parse_url($row['remote_url']); $pathParts = array(); $pathParts = explode('/', $urlParts['path']); $ppCount = count($pathParts); $pPath = ''; for ($row = 1; $row < $ppCount - 1; $row++) { $pPath .= '/' . $pathParts[$row]; } $videoFile = $pathParts[$ppCount - 1]; $pos = strrpos($videoFile, '.'); if ($pos === false) { $basefilename = $videoFile; } else { $basefilename = substr($videoFile, 0, $pos); } $videoFile = $basefilename; $streamingServerURL = "streamingServerURL: '" . $urlParts['scheme'] . '://' . $urlParts['host'] . $pPath . "',"; $streamingServer = "streamingServer: 'fms',"; } else { $streamingServerURL = ''; $streamingServer = ''; $videoFile = urlencode($_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']); } $width = $videowidth; $height = $videoheight + 22; $resolution_x = $videowidth; $resolution_y = $videoheight; $id = 'id_' . rand(); $id2 = 'id2_' . rand(); $F->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'play' => $autoplay ? 'true' : 'false', 'menu' => $playback_options['menu'] ? 'true' : 'false', 'loop' => $playback_options['loop'] ? 'true' : 'false', 'scale' => $playback_options['scale'], 'wmode' => $playback_options['wmode'], 'width' => $width, 'height' => $height, 'streamingServerURL' => $streamingServerURL, 'streamingServer' => $streamingServer, 'videoFile' => $videoFile, 'playButton' => $playButton, 'id' => $id, 'id2' => $id2, 'resolution_x' => $resolution_x, 'resolution_y' => $resolution_y)); $F->parse('output', 'player'); $flv_player = $F->finish($F->get_var('output')); $V->set_var(array('site_url' => $_MG_CONF['site_url'], 'lang_noflash' => $LANG_MG03['no_flash'], 'id' => $id, 'id2' => $id2, 'width' => $resolution_x, 'height' => $resolution_y, 'flv_player' => $flv_player)); $V->parse('output', 'video'); if ($align != '' && $align != "center") { $u_image .= '<span class="' . $classes . '" style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } else { if ($align == "center") { $u_image .= '<span class="' . $classes . '" style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } else { $u_image .= '<span class="' . $classes . '" style="padding:5px;">' . $V->finish($V->get_var('output')) . '</span>'; } } break; } $link = $u_image; if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; } else { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } break; case 'audio': $sql = "SELECT ma.album_id,m.media_title,m.mime_type,m.media_tn_attached,m.media_filename,m.media_mime_ext FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'"; $result = DB_query($sql); if (DB_numRows($result) > 0) { $row = DB_fetchArray($result); $aid = $row['album_id']; if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } switch ($row['mime_type']) { case 'audio/mpeg': $playback_options['height'] = 50; $playback_options['width'] = 300; $V = new Template(MG_getTemplatePath(0)); if ($mp3_type == 'ribbon') { $tfile = 'mp3_podcast.thtml'; } else { $tfile = 'view_mp3_flv.thtml'; } $autostart = $autoplay ? 'play' : 'stop'; if ($row['media_tn_attached'] == 1) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) { $u_tn = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext); break; } } $border_width = $media_size_disp[0] + 15; $u_pic = '<img src="' . $u_tn . '" alt="" style="border:none;" />'; $playback_options['width'] = 200; } else { $u_pic = ''; $playback_options['width'] = 200; } $V->set_file(array('audio' => $tfile)); $V->set_var(array('autostart' => $autostart, 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'true', 'uimode' => 'mini', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => '#FFFFFF', 'loop' => 'true', 'u_pic' => $u_pic, 'title' => urlencode($row['media_title']), 'id' => 'mp3' . rand(), 'id2' => 'mp3' . rand(), 'site_url' => $_MG_CONF['site_url'], 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'], 'mp3_file' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'])); $V->parse('output', 'audio'); if ($align != '' && $align != "center") { $u_image = '<span style="float:' . $align . ';padding:5px;text-align:center;">' . $V->finish($V->get_var('output')) . '</span>'; } else { if ($align == "center") { $u_image = '<span style="text-align:center;padding:5px;text-align:center;">' . $V->finish($V->get_var('output')) . '</span>'; } else { $u_image = '<span style="padding:5px;text-align:center;">' . $V->finish($V->get_var('output')) . '</span>'; } } break; case 'audio/x-ms-wma': case 'audio/x-ms-wax': case 'audio/x-ms-wmv': $playback_options['height'] = 50; $playback_options['width'] = 300; $V = new Template(MG_getTemplatePath(0)); $tfile = 'view_mp3_wmp.thtml'; $autostart = $autoplay ? '1' : '0'; if ($row['media_tn_attached'] == 1) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) { $u_tn = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; $media_size_disp = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext); break; } } $border_width = $media_size_disp[0] + 15; $u_pic = '<div class=out style="width:' . $border_width . 'px"><div class="in ltin tpin"><img src="' . $u_tn . '" alt="" /></div></div>'; $playback_options['height'] = 50; $playback_options['width'] = 200; } else { $u_pic = ''; $playback_options['height'] = 50; $playback_options['width'] = 200; } $V->set_file(array('audio' => $tfile)); $V->set_var(array('autostart' => $autostart, 'enablecontextmenu' => 'true', 'stretchtofit' => 'false', 'showstatusbar' => 'true', 'uimode' => 'mini', 'height' => $playback_options['height'], 'width' => $playback_options['width'], 'bgcolor' => '#FFFFFF', 'loop' => 'true', 'u_pic' => $u_pic, 'movie' => $_MG_CONF['mediaobjects_url'] . '/orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext'])); $V->parse('output', 'audio'); if ($align != '' && $align != "center") { $u_image = '<div class="' . $classes . '" style="float:' . $align . ';padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } else { if ($align == "center") { $u_image = '<div class="' . $classes . '" style="text-align:center;padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } else { $u_image = '<div class="' . $classes . '" style="padding:5px;">' . $V->finish($V->get_var('output')) . '</div>'; } } break; } $link = $u_image; if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; } else { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } break; case 'fslideshow': if ($parm1 == '' || $parm1 == 0) { return $content; } $aid = $parm1; if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } if ($width > 0 && $height == 0) { $height = $width * 0.75; } else { if ($width == 0 && $height == 0) { $height = $width = 200; } else { if ($width == 0 && $height > 0) { $width = $height * 1.3333; } } } // if none of the above, assume height and width both specified. if ($caption == '' && $_MG_CONF['autotag_caption'] && isset($aid)) { $caption = $MG_albums[$aid]->title; } $captionHTML = '<br /><span style="width:' . $width . 'px;font-style:italic;font-size: smaller;text-indent:0;">' . $caption . '</span>' . LB; $ss_count++; $T = new Template(MG_getTemplatePath(0)); $T->set_file(array('fslideshow' => 'fsat.thtml')); $T->set_var(array('site_url' => $_MG_CONF['site_url'])); $T->set_var(array('id' => 'mms' . $ss_count, 'id2' => 'fsid' . $ss_count, 'movie' => $_MG_CONF['site_url'] . '/xml.php?aid=' . $parm1 . '%26src=' . trim($src), 'dropshadow' => 'true', 'delay' => $delay, 'nolink' => $MG_albums[$parm1]->hidden || $enable_link == 0 ? 'true' : 'false', 'showtitle' => $showtitle == 'bottom' || $showtitle == 'top' ? '&showTitle=' . $showtitle : '', 'width' => $width, 'height' => $height)); $T->parse('output', 'fslideshow'); $swfobject = $T->finish($T->get_var('output')); $link = $swfobject . $captionHTML; if ($align != '' && $align != "center") { $link = '<span class="' . $classes . '" style="float:' . $align . ';padding:5px;text-align:center;">' . $link . '</span>'; } else { if ($align == "center") { $link = '<center><span class="' . $classes . '" style="padding:5px;text-align:center;">' . $link . '</span></center>'; } else { $link = '<span class="' . $classes . '" style="padding:5px;text-align:center;">' . $link . '</span>'; } } if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; break; case 'slideshow': if ($parm1 == '' || $parm1 == 0) { return $content; } if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } if ($caption == '' && $_MG_CONF['autotag_caption']) { $caption = $MG_albums[$parm1]->title; } $T->set_file(array('tag' => 'autotag_ss.thtml')); $aid = $parm1; $pics = ''; $counter = 0; $maxwidth = 0; $maxheight = 0; $ss_count++; $sql = "SELECT m.media_filename,m.media_mime_ext,m.remote_url FROM {$_TABLES['mg_media_albums']} as ma INNER JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE ma.album_id='" . DB_escapeString($aid) . "' AND m.media_type=0 AND m.include_ss=1 ORDER BY ma.media_order DESC"; $result = DB_query($sql); $T->set_block('tag', 'slides', 'ss'); while ($row = DB_fetchArray($result)) { switch ($src) { case 'orig': $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']); $ext = $row['media_mime_ext']; break; case 'disp': foreach ($_MG_CONF['validExtensions'] as $tnext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $tnext)) { $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $tnext); $ext = substr($tnext, 1, 3); break; } } break; default: foreach ($_MG_CONF['validExtensions'] as $tnext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $tnext)) { $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $tnext); $ext = substr($tnext, 1, 3); break; } } $src = 'tn'; break; } if ($media_size == false) { continue; } $counter++; if ($width > 0 && $height == 0) { if ($media_size[0] > $media_size[1]) { // landscape $ratio = $media_size[0] / $width; $newwidth = $width; $newheight = round($media_size[1] / $ratio); } else { // portrait $ratio = $media_size[1] / $width; $newheight = $width; $newwidth = round($media_size[0] / $ratio); } } else { if ($width == 0 && $height == 0) { if ($media_size[0] > $media_size[1]) { // landscape $ratio = $media_size[0] / 200; $newwidth = 200; $newheight = round($media_size[1] / $ratio); } else { // portrait $ratio = $media_size[1] / 200; $newheight = 200; $newwidth = round($media_size[0] / $ratio); } } else { if ($width == 0 && $height > 0) { if ($height > $media_size[1]) { $newheight = $media_size[1]; $newwidth = $media_size[0]; } else { $ratio = $height / $media_size[1]; $newheight = $height; $newwidth = round($media_size[0] * $ratio); } } else { $newwidth = $width; $newheight = $height; } } } if ($newheight > $maxheight) { $maxheight = $newheight; } if ($newwidth > $maxwidth) { $maxwidth = $newwidth; } $active = ''; if ($counter == 1) { $active = ' active '; } if ($MG_albums[$parm1]->hidden == 1 || $enable_link == 0) { $pics .= '<img class="slideshowThumbnail' . $ss_count . $active . ' ' . $classes . '" src="' . $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext . '" alt="" style="width:' . $newwidth . 'px;height:' . $newheight . 'px;border:none;position:absolute;left:0px;top:0px;" />' . LB; } else { $pics .= '<img class="slideshowThumbnail' . $ss_count . $active . ' ' . $classes . '". src="' . $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext . '" alt="" style="width:' . $newwidth . 'px;height:' . $newheight . 'px;border:none;position:absolute;left:0px;top:0px;" />' . LB; } $T->set_var(array('img_url' => $_MG_CONF['mediaobjects_url'] . '/' . $src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $ext, 'img_width' => $newwidth, 'img_height' => $newheight)); $T->parse('ss', 'slides', true); } if ($delay <= 0) { $delay = 10; } if ($MG_albums[$parm1]->hidden == 1 || $enable_link == 0) { $ss_url = ''; } else { $ss_url = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>'; $ss_url = $_MG_CONF['site_url'] . '/album.php?aid=' . $aid; } if ($counter != 0) { $T->set_var(array('align' => $align, 'pics' => $pics, 'caption' => $caption, 'maxheight' => $maxheight, 'maxwidth' => $maxwidth, 'width' => $maxwidth, 'framewidth' => $maxwidth + 10, 'ss_count' => $ss_count, 'delay' => $delay * 1000, 'border' => $border ? 'border: silver solid;border-width: 1px;' : '', 'sslink' => $ss_url)); if ($align == 'left' || $align == 'right') { $T->set_var('float', 'float: ' . $align . ';'); } else { $T->set_var('float', 'float:left;'); $align = 'left'; } if ($align == 'left') { $T->set_var('margin-right', 'margin-right:15px;'); } else { $T->set_var('margin-right', ''); } $T->parse('output', 'tag'); $link = $T->finish($T->get_var('output')); } else { $link = ''; } if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; break; case 'album': if ($parm1 == '' || $parm1 == 0) { $side_count--; return $content; } if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); $side_count--; return $content; } $ss_count++; if ($border == 0) { $T->set_file(array('tag' => 'autotag_nb.thtml')); } else { $T->set_file(array('tag' => 'autotag.thtml')); } if ($tag != '') { $alttag = ' alt="' . $tag . '" title="' . $tag . '"'; } else { $alttag = ' alt=""'; if ($_MG_CONF['autotag_caption']) { $caption = $MG_albums[$parm1]->title; } } $aid = $parm1; if ($MG_albums[$parm1]->tn_attached == 1) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $parm1 . $ext)) { $tnImage = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $parm1 . $ext; $tnFileName = $_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $parm1 . $ext; break; } } } else { $filename = $MG_albums[$aid]->findCover(); if ($filename != '') { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) { $tnImage = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext; $tnFileName = $_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext; break; } } } else { $tnImage = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $tnFileName = $_MG_CONF['path_mediaobjects'] . 'placeholder.svg'; } } $media_size = @getimagesize($tnFileName); if ($media_size == false) { $tnImage = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $tnFileName = $_MG_CONF['path_mediaobjects'] . 'placeholder.svg'; $media_size = array(200, 200); } if ($width > 0 && $height == 0) { $ratio = $media_size[0] / $width; $newwidth = $width; $newheight = round($media_size[1] / $ratio); } else { if ($width == 0 && $height == 0) { if ($media_size[0] > $media_size[1]) { // landscape $ratio = $media_size[0] / 200; $newwidth = 200; $newheight = round($media_size[1] / $ratio); } else { // portrait $ratio = $media_size[1] / 200; $newheight = 200; $newwidth = round($media_size[0] / $ratio); } } else { if ($width == 0 && $height > 0) { $ratio = $height / $media_size[1]; $newheight = $height; $newwidth = round($media_size[0] * $ratio); } else { $newwidth = $width; $newheight = $height; } } } $album_image = '<img src="' . $tnImage . '" ' . $alttag . ' style="'; if ($nosize == 0 && $height != -1 && $width != -1) { $album_image .= 'width:' . $newwidth . 'px;height:' . $newheight . 'px;'; } $album_image .= 'border:none;" />'; $tagtext = $album_image; if ($linkID == 0) { $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $parm1; } else { if ($linkID < 1000000) { $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $linkID; } else { $url = $_MG_CONF['site_url'] . '/media.php?s=' . $linkID; } } if ($enable_link == 0) { $link = $tagtext; } else { $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>'; } $T->set_var(array('ss_count' => $ss_count, 'align' => $align, 'autotag' => $link, 'caption' => $caption, 'width' => $newwidth, 'framewidth' => $newwidth + 10)); if ($align == 'left' || $align == 'right') { $T->set_var('float', 'float:' . $align . ';'); } else { $T->set_var('float', ''); } if ($align == 'left') { $T->set_var('margin-right', 'margin-right:15px;'); } else { $T->set_var('margin-right', ''); } $T->parse('output', 'tag'); $link = $T->finish($T->get_var('output')); if ($align == 'center') { $link = '<center>' . $link . '</center>'; } if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; break; case 'alink': if ($parm1 == '' || $parm1 == 0) { $side_count--; return $content; } if (!isset($MG_albums[$parm1]->id) || $MG_albums[$parm1]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); $side_count--; return $content; } if ($caption == '') { $caption = $MG_albums[$parm1]->title; } $link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$parm1]->id . '">' . $caption . '</a>'; $content = str_replace($autotag['tagstr'], $link, $content); return $content; break; case 'media': /* image, oimage and img are depreciated */ /* image, oimage and img are depreciated */ case 'image': case 'oimage': case 'img': if ($parm1 == '' || $parm1 == 0) { return $content; } $direct_link = ''; $ss_count++; if ($border == 0) { $T->set_file(array('tag' => 'autotag_nb.thtml')); } else { $T->set_file(array('tag' => 'autotag.thtml')); } if ($tag != '') { $alttag = ' alt="' . $tag . '" title="' . $tag . '"'; } else { $alttag = ' alt=""'; } $sql = "SELECT ma.album_id,m.media_title,m.media_type,m.media_filename,m.media_mime_ext,m.mime_type,m.media_tn_attached,m.remote_url FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_id='" . DB_escapeString($parm1) . "'"; $result = DB_query($sql); if (DB_numRows($result) > 0) { $row = DB_fetchArray($result); $aid = $row['album_id']; if (!isset($MG_albums[$aid]->id) || $MG_albums[$aid]->access == 0) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } if ($caption == '' && $_MG_CONF['autotag_caption']) { $caption = $row['media_title']; } switch ($row['media_type']) { case 0: // standard image if ($autotag['tag'] == 'oimage') { if ($_MG_CONF['discard_originals'] == 1) { $default_thumbnail = 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; } else { $default_thumbnail = 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; } } else { switch ($src) { case 'orig': if ($_MG_CONF['discard_originals'] == 1) { $default_thumbnail = 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; } else { $default_thumbnail = 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; } break; case 'disp': $default_thumbnail = 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; break; case 'tn': foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) { $default_thumbnail = 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; break; } } break; default: foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) { $default_thumbnail = 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; break; } } break; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . $link_src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) { $direct_link = $_MG_CONF['mediaobjects_url'] . '/' . $link_src . '/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; break; } } } break; case 1: // video file switch ($row['mime_type']) { case 'application/x-shockwave-flash': $default_thumbnail = 'flash.png'; break; case 'video/quicktime': case 'video/mpeg': case 'video/x-m4v': $default_thumbnail = 'quicktime.png'; break; case 'video/x-ms-asf': case 'video/x-ms-wvx': case 'video/x-ms-wm': case 'video/x-ms-wmx': case 'video/x-msvideo': case 'application/x-ms-wmz': case 'application/x-ms-wmd': $default_thumbnail = 'wmp.png'; break; default: $default_thumbnail = 'video.png'; break; } $src = 'tn'; break; case 2: // music file $src = 'tn'; $default_thumbnail = 'audio.png'; break; } if ($row['media_tn_attached'] == 1 && ($src != 'orig' && $src != 'disp')) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext)) { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/tn_' . $row['media_filename'] . $ext; break; } } } else { $media_thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $default_thumbnail; $media_thumbnail_file = $_MG_CONF['path_mediaobjects'] . $default_thumbnail; } if ($autotag['tag'] == 'img') { if ($align != '' && $align != 'center') { $album_image = '<span class="' . $classes . '" style="float:' . $align . ';padding:5px;"><img src="' . $media_thumbnail . '" ' . $alttag . 'style="border:none;" /></span>'; } else { $album_image = '<img class="' . $classes . '" src="' . $media_thumbnail . '" ' . $alttag . 'style="border:none;" />'; } } else { $album_image = '<img class="' . $classes . '" src="' . $media_thumbnail . '" ' . $alttag . 'style="border:none;" />'; } } else { return $content; // no image found } $mediaSize = @getimagesize($media_thumbnail_file); if ($mediaSize == false) { $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); return $content; } if ($autotag['tag'] == 'oimage' || $src == 'orig') { $newwidth = $mediaSize[0]; $newheight = $mediaSize[1]; } else { if ($width > 0) { $tn_height = $width; } else { switch ($src) { case 'orig': $tn_height = $mediaSize[0]; break; case 'disp': $tn_height = $mediaSize[0]; break; case 'tn': $tn_height = 200; break; default: $tn_height = 200; break; } } if ($mediaSize[0] > $mediaSize[1]) { $ratio = $mediaSize[0] / $tn_height; $newwidth = $tn_height; $newheight = round($mediaSize[1] / $ratio); } else { $ratio = $mediaSize[1] / $tn_height; $newheight = $tn_height; $newwidth = round($mediaSize[0] / $ratio); } } $album_image = '<img class="' . $classes . '" src="' . $media_thumbnail . '" ' . $alttag . ' style='; if ($nosize == 0 && $height != -1 && $width != -1) { $album_image .= '"width:' . $newwidth . 'px;height:' . $newheight . 'px;'; } $album_image .= 'border:none;" />'; $tagtext = $album_image; $link = ''; if ($alt == 1 && $row['remote_url'] != '') { $url = $row['remote_url']; if ($autotag['tag'] != 'image' && $enable_link != 0) { $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>'; } else { $link = $tagtext; } } else { if ($linkID == 0) { $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1; } else { if ($linkID < 1000000) { if (isset($MG_albums[$linkID]->id)) { $url = $_MG_CONF['site_url'] . '/album.php?aid=' . $linkID; if ($autotag['tag'] != 'image' && $MG_albums[$linkID]->hidden != 1 && $enable_link != 0) { $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>'; } else { $link = $tagtext; } } else { $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1; } } else { $linkAID = (int) DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($linkID) . '"'); if ($linkAID != 0) { $url = $_MG_CONF['site_url'] . '/media.php?s=' . $linkID; if ($autotag['tag'] != 'image' && $MG_albums[$linkAID]->hidden != 1 && $enable_link != 0) { $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>'; } else { $link = $tagtext; } } else { $url = $_MG_CONF['site_url'] . '/media.php?s=' . $parm1; } } } } if ($link == '') { if ($autotag['tag'] != 'image' && ($MG_albums[$aid]->hidden != 1 || $enable_link == 2) && $enable_link != 0) { if ($enable_link == 2 && $direct_link != '') { if ($_MG_CONF['disable_lightbox'] == true) { $link = $tagtext; } else { $link = '<a href="' . $direct_link . '" rel="lightbox" data-uk-lightbox title="' . strip_tags(str_replace('$', '$', $caption)) . '">' . $tagtext . '</a>'; } } else { $link = '<a href="' . $url . '"' . ($target == '' ? '' : ' target="' . $target . '"') . '>' . $tagtext . '</a>'; } } else { $link = $tagtext; } } if ($autotag['tag'] == 'img') { if ($align != '' && $align != 'center') { $link = '<span class="' . $classes . '" style="float:' . $align . ';padding:5px;">' . $link . '</span>'; } if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; } $T->set_var(array('ss_count' => $ss_count, 'align' => $align, 'autotag' => $link, 'caption' => $caption, 'width' => $newwidth, 'framewidth' => $newwidth + 10)); if ($align == 'left' || $align == 'right') { $T->set_var('float', 'float:' . $align . ';'); } else { $T->set_var('float', ''); } if ($align == 'left') { $T->set_var('margin-right', 'margin-right:15px;'); } else { $T->set_var('margin-right', ''); } $T->parse('output', 'tag'); $link = $T->finish($T->get_var('output')); if ($align == 'center') { $link = '<center>' . $link . '</center>'; } if ($destination != 'block') { $content = str_replace($autotag['tagstr'], $link, $content); } else { $autoTagCount = $mgAutoTagArray['count']; $mgAutoTagArray['tags'][$autoTagCount] = $link; $mgAutoTagArray['count']++; $link = ''; $content = str_replace($autotag['tagstr'], $link, $content); } return $content; break; } } }
/** * saves the specified album information * * @param int album_id album_id to edit * @return string HTML * */ function MG_saveAlbum($album_id, $actionURL = '') { global $_DB_dbms, $MG_albums, $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $_POST; $update = 0; if (isset($_POST['album_id'])) { $aid = COM_applyFilter($_POST['album_id'], true); } else { $aid = 0; } if (isset($_POST['force_child_update'])) { $forceChildPermUpdate = COM_applyFilter($_POST['force_child_update'], true); } else { $forceChildPermUpdate = 0; } $thumb = $_FILES['thumbnail']; $thumbnail = $thumb['tmp_name']; if (isset($_POST['attach_tn'])) { $att = COM_applyFilter($_POST['attach_tn']); } else { $att = 0; } if ($aid > 0) { // should be 0 or negative 1 for create $album = $MG_albums[$aid]; $oldparent = $album->parent; $old_tn_attached = $album->tn_attached; $old_featured = $album->featured; $update = 1; } else { $album = new mgAlbum(); $album->id = $aid; $update = 0; $old_tn_attached = 0; } if ($_MG_CONF['htmlallowed'] == 1) { $album->title = COM_checkHTML(COM_killJS($_POST['album_name'])); $album->description = COM_checkHTML(COM_killJS($_POST['album_desc'])); } else { $album->title = htmlspecialchars(strip_tags(COM_checkWords(COM_killJS($_POST['album_name'])))); $album->description = htmlspecialchars(strip_tags(COM_checkWords(COM_killJS($_POST['album_desc'])))); } if ($album->title == "") { return MG_errorHandler("You must enter an Album Name"); } $album->parent = COM_applyFilter($_POST['parentaid'], true); // we should not need this if (isset($_POST['hidden'])) { $album->hidden = COM_applyFilter($_POST['hidden'], true); } else { $album->hidden = 0; } $album->cover = COM_applyFilter($_POST['cover']); $album->cover_filename = COM_applyFilter($_POST['album_cover_filename']); if (isset($_POST['enable_album_views'])) { $album->enable_album_views = COM_applyFilter($_POST['enable_album_views'], true); } else { $album->enable_album_views = 0; } $album->image_skin = COM_applyFilter($_POST['skin']); $album->album_skin = COM_applyFilter($_POST['askin']); $album->display_skin = COM_applyFilter($_POST['dskin']); if (isset($_POST['display_album_desc'])) { $album->display_album_desc = COM_applyFilter($_POST['display_album_desc'], true); } else { $album->display_album_desc = 0; } if (isset($_POST['enable_comments'])) { $album->enable_comments = COM_applyFilter($_POST['enable_comments'], true); } else { $album->enable_comments = 0; } $album->exif_display = COM_applyFilter($_POST['enable_exif'], true); if (isset($_POST['enable_rating'])) { $album->enable_rating = COM_applyFilter($_POST['enable_rating'], true); } else { $album->enable_rating = 0; } $album->playback_type = COM_applyFilter($_POST['playback_type'], true); $album->tn_attached = isset($_POST['attach_tn']) ? COM_applyFilter($_POST['attach_tn'], true) : 0; $album->enable_slideshow = COM_applyFilter($_POST['enable_slideshow'], true); if (isset($_POST['enable_random'])) { $album->enable_random = COM_applyFilter($_POST['enable_random'], true); } else { $album->enable_random = 0; } if (isset($_POST['enable_shutterfly'])) { $album->enable_shutterfly = COM_applyFilter($_POST['enable_shutterfly'], true); } else { $album->enable_shutterfly = 0; } if (isset($_POST['enable_views'])) { $album->enable_views = COM_applyFilter($_POST['enable_views'], true); } else { $album->enable_views = 0; } if (isset($_POST['enable_keywords'])) { $album->enable_keywords = COM_applyFilter($_POST['enable_keywords'], true); } else { $album->enable_keywords = 0; } if (isset($_POST['enable_sort'])) { $album->enable_sort = COM_applyFilter($_POST['enable_sort'], true); } else { $album->enable_sort = 0; } if (isset($_POST['enable_rss'])) { $album->enable_rss = COM_applyFilter($_POST['enable_rss'], true); } else { $album->enable_rss = 0; } $album->enable_postcard = COM_applyFilter($_POST['enable_postcard'], true); if (isset($_POST['albums_first'])) { $album->albums_first = COM_applyFilter($_POST['albums_first'], true); } else { $album->albums_first = 0; } if (isset($_POST['allow_download'])) { $album->allow_download = COM_applyFilter($_POST['allow_download'], true); } else { $album->allow_download = 0; } if (isset($_POST['usealternate'])) { $album->useAlternate = COM_applyFilter($_POST['usealternate'], true); } else { $album->useAlternate = 0; } $album->full = COM_applyFilter($_POST['full_display'], true); $album->tn_size = COM_applyFilter($_POST['tn_size'], true); $album->max_image_height = COM_applyFilter($_POST['max_image_height'], true); $album->max_image_width = COM_applyFilter($_POST['max_image_width'], true); $album->max_filesize = COM_applyFilter($_POST['max_filesize'], true); if ($album->max_filesize != 0) { $album->max_filesize = $album->max_filesize * 1024; } $album->display_image_size = COM_applyFilter($_POST['display_image_size'], true); $album->display_rows = COM_applyFilter($_POST['display_rows'], true); $album->display_columns = COM_applyFilter($_POST['display_columns'], true); $album->skin = COM_applyFilter($_POST['album_theme']); if (isset($_POST['filename_title'])) { $album->filename_title = COM_applyFilter($_POST['filename_title'], true); } else { $album->filename_title = 0; } $album->shopping_cart = 0; if (isset($_POST['wm_auto'])) { $album->wm_auto = COM_applyFilter($_POST['wm_auto'], true); } else { $album->wm_auto = 0; } $album->wm_id = COM_applyFilter($_POST['wm_id']); $album->wm_opacity = COM_applyFilter($_POST['wm_opacity'], true); $album->wm_location = COM_applyFilter($_POST['wm_location'], true); $album->album_sort_order = COM_applyFilter($_POST['album_sort_order'], true); if (isset($_POST['uploads'])) { $album->member_uploads = COM_applyFilter($_POST['uploads'], true); } else { $album->member_uploads = 0; } if (isset($_POST['moderate'])) { $album->moderate = COM_applyFilter($_POST['moderate'], true); } else { $album->moderate = 0; } if (isset($_POST['email_mod'])) { $album->email_mod = COM_applyFilter($_POST['email_mod'], true); } else { $album->email_mod = 0; } if (isset($_POST['podcast'])) { $album->podcast = COM_applyFilter($_POST['podcast'], true); } else { $album->podcast = 0; } if (isset($_POST['mp3ribbon'])) { $album->mp3ribbon = COM_applyFilter($_POST['mp3ribbon'], true); } else { $album->mp3ribbon = 0; } if (isset($_POST['rsschildren'])) { $album->rssChildren = COM_applyFilter($_POST['rsschildren'], true); } else { $album->rssChildren = 0; } if (isset($_POST['tnheight'])) { $album->tnHeight = COM_applyFilter($_POST['tnheight'], true); if ($album->tnHeight == 0) { $album->tnHeight = 200; } } else { $album->tnHeight = 200; } if (isset($_POST['tnwidth'])) { $album->tnWidth = COM_applyFilter($_POST['tnwidth'], true); if ($album->tnWidth == 0) { $album->tnWidth = 200; } } else { $album->tnWidth = 200; } if (SEC_hasRights('mediagallery.admin')) { $format_jpg = isset($_POST['format_jpg']) ? COM_applyFilter($_POST['format_jpg'], true) : 0; $format_png = isset($_POST['format_png']) ? COM_applyFilter($_POST['format_png'], true) : 0; $format_tif = isset($_POST['format_tif']) ? COM_applyFilter($_POST['format_tif'], true) : 0; $format_gif = isset($_POST['format_gif']) ? COM_applyFilter($_POST['format_gif'], true) : 0; $format_bmp = isset($_POST['format_bmp']) ? COM_applyFilter($_POST['format_bmp'], true) : 0; $format_tga = isset($_POST['format_tga']) ? COM_applyFilter($_POST['format_tga'], true) : 0; $format_psd = isset($_POST['format_psd']) ? COM_applyFilter($_POST['format_psd'], true) : 0; $format_mp3 = isset($_POST['format_mp3']) ? COM_applyFilter($_POST['format_mp3'], true) : 0; $format_ogg = isset($_POST['format_ogg']) ? COM_applyFilter($_POST['format_ogg'], true) : 0; $format_asf = isset($_POST['format_asf']) ? COM_applyFilter($_POST['format_asf'], true) : 0; $format_swf = isset($_POST['format_swf']) ? COM_applyFilter($_POST['format_swf'], true) : 0; $format_mov = isset($_POST['format_mov']) ? COM_applyFilter($_POST['format_mov'], true) : 0; $format_mp4 = isset($_POST['format_mp4']) ? COM_applyFilter($_POST['format_mp4'], true) : 0; $format_mpg = isset($_POST['format_mpg']) ? COM_applyFilter($_POST['format_mpg'], true) : 0; $format_zip = isset($_POST['format_zip']) ? COM_applyFilter($_POST['format_zip'], true) : 0; $format_other = isset($_POST['format_other']) ? COM_applyFilter($_POST['format_other'], true) : 0; $format_flv = isset($_POST['format_flv']) ? COM_applyFilter($_POST['format_flv'], true) : 0; $format_rflv = isset($_POST['format_rflv']) ? COM_applyFilter($_POST['format_rflv'], true) : 0; $format_emb = isset($_POST['format_emb']) ? COM_applyFilter($_POST['format_emb'], true) : 0; $album->valid_formats = $format_jpg + $format_png + $format_tif + $format_gif + $format_bmp + $format_tga + $format_psd + $format_mp3 + $format_ogg + $format_asf + $format_swf + $format_mov + $format_mp4 + $format_mpg + $format_zip + $format_other + $format_flv + $format_rflv + $format_emb; if (isset($_POST['featured'])) { $album->featured = COM_applyFilter($_POST['featured'], true); // admin only } else { $album->featured = 0; } $album->cbposition = COM_applyFilter($_POST['featureposition'], true); // admin only $album->cbpage = COM_applyFilter($_POST['featurepage']); // admin only $album->group_id = isset($_POST['group_id']) ? COM_applyFilter($_POST['group_id']) : 0; // admin only $album->mod_group_id = isset($_POST['mod_id']) ? COM_applyFilter($_POST['mod_id'], true) : 0; // admin only $perm_owner = isset($_POST['perm_owner']) ? $_POST['perm_owner'] : 0; // admin only $perm_group = isset($_POST['perm_group']) ? $_POST['perm_group'] : 0; // admin only $perm_members = isset($_POST['perm_members']) ? $_POST['perm_members'] : 0; $perm_anon = isset($_POST['perm_anon']) ? $_POST['perm_anon'] : 0; list($album->perm_owner, $album->perm_group, $album->perm_members, $album->perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon); } else { $perm_owner = $album->perm_owner; // already set by existing album? $perm_group = $album->perm_group; // already set by existing album? if ($update == 0) { if (isset($MG_albums[$album->parent]->group_id)) { $grp_id = $MG_albums[$album->parent]->group_id; $album->group_id = $grp_id; } else { $gresult = DB_query("SELECT grp_id FROM {$_TABLES['groups']} WHERE grp_name LIKE 'mediagallery Admin'"); $grow = DB_fetchArray($gresult); $grp_id = $grow['grp_id']; $album->group_id = $grp_id; // only do these two if create.... } $album->mod_group_id = $_MG_CONF['member_mod_group_id']; if ($album->mod_group_id == '' || $album->mod_group_id < 1) { $album->mod_group_id = $grp_id; } } $perm_members = $_POST['perm_members']; $perm_anon = $_POST['perm_anon']; list($junk1, $junk2, $album->perm_members, $album->perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon); } if (isset($_POST['owner_id'])) { $album->owner_id = COM_applyFilter($_POST['owner_id']); } else { $album->owner_id = 2; } // simple check to see if we can create off the album root... if (!SEC_hasRights('mediagallery.admin')) { if ($album->parent == $_MG_CONF['member_album_root'] && $update == 0) { if ($_MG_CONF['member_create_new'] == 0) { return MG_errorHandler("Cannot create a new album off the member root, please select a new parent album"); } } } // final permission check to make sure we have the proper rights to create here.... if ($album->parent == 0 && $update == 0 && !$_MG_CONF['member_albums'] == 1 && !$_MG_CONF['member_album_root'] == 0) { // see if we are mediagallery.admin if (!SEC_hasRights('mediagallery.admin')) { COM_errorLog("MediaGallery: Someone has tried to illegally save a Media Gallery Album in Root. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return MG_genericError($LANG_MG00['access_denied_msg']); } } elseif ($album->parent != 0) { if (!isset($MG_albums[$album->parent]->id)) { // does not exist... COM_errorLog("MediaGallery: Someone has tried to save a album to non-existent parent album. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return MG_genericError($LANG_MG00['access_denied_msg']); } else { if ($MG_albums[$album->parent]->access != 3 && !SEC_hasRights('mediagallery.admin') && !$_MG_CONF['member_albums'] && !($_MG_CONF['member_album_root'] == $MG_album[$album->parent]->id)) { COM_errorLog("MediaGallery: Someone has tried to illegally save a Media Gallery Album. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return MG_genericError($LANG_MG00['access_denied_msg']); } } } if ($old_tn_attached == 0 && $album->tn_attached == 1 && $thumb['tmp_name'] == '') { $album->tn_attached = 0; } if ($old_tn_attached == 1 && $album->tn_attached == 0) { $remove_old_tn = 1; } else { $remove_old_tn = 0; } if ($thumb['tmp_name'] != '' && $album->tn_attached == 1) { $thumbnail = $thumb['tmp_name']; $attachtn = 1; } else { $attachtn = 0; } // pull the watermark id associated with the filename... if ($album->wm_id == 'blank.png') { $wm_id = 0; } else { $wm_id = DB_getItem($_TABLES['mg_watermarks'], 'wm_id', 'filename="' . DB_escapeString($album->wm_id) . '"'); } if ($wm_id == '') { $wm_id = 0; } if ($wm_id == 0) { $album->wm_auto = 0; } $album->wm_id = $wm_id; // handle new featured albums if (SEC_hasRights('mediagallery.admin')) { if ($album->featured) { // check for other featured albums, we can only have one $sql = "SELECT album_id FROM {$_TABLES['mg_albums']} WHERE featured=1 AND cbpage='" . DB_escapeString($album->cbpage) . "'"; $result = DB_query($sql); $nRows = DB_numRows($result); if ($nRows > 0) { $row = DB_fetchArray($result); $sql = "UPDATE {$_TABLES['mg_albums']} SET featured=0 WHERE album_id=" . $row['album_id']; DB_query($sql); } } } else { // if a new album, set the member album defaults since we are a non-admin if ($album->isMemberAlbum() && update == 0) { $album->perm_owner = $_MG_CONF['member_perm_owner']; $album->perm_group = $_MG_CONF['member_perm_group']; $album->enable_random = $_MG_CONF['member_enable_random']; $album->max_image_height = $_MG_CONF['member_max_height']; $album->max_image_width = $_MG_CONF['member_max_width']; $album->max_filesize = $_MG_CONF['member_max_filesize']; $album->member_uploads = $_MG_CONF['member_uploads']; $album->moderate = $_MG_CONF['member_moderate']; $album->email_mod = $_MG_CONF['member_email_mod']; $album->valid_formats = $_MG_CONF['member_valid_formats']; } } $album->title = substr($album->title, 0, 254); if ($_DB_dbms == "mssql") { $album->description = substr($album->description, 0, 1500); } if ($album->last_update == '') { $album->last_update = 0; } $album->last_update = intval($album->last_update); if ($album->id < 1) { $album->id = $album->createAlbumID(); $aid = $album->id; $album->order = $album->getNextSortOrder(); } if ($album->id == 0) { COM_errorLog("MediaGallery: Internal Error - album_id = 0 - Contact mark@glfusion.org "); return MG_genericError($LANG_MG00['access_denied_msg']); } $album->saveAlbum(); $album->updateChildPermissions($forceChildPermUpdate); // now handle the attached cover... if ($attachtn == 1) { if (!function_exists('MG_getFile')) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-upload.php'; } $media_filename = $_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $album->id; MG_attachThumbnail($album->id, $thumbnail, $media_filename); } if ($remove_old_tn == 1) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $album->id . $ext)) { @unlink($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $album->id . $ext); break; } } } MG_initAlbums(1); // do any album sorting here... if (isset($MG_albums[$aid]) && $MG_albums[$aid]->parent == 0) { switch ($MG_albums[$aid]->album_sort_order) { case 0: break; case 3: // upload, asc MG_staticSortAlbum($aid, 2, 1, 0); break; case 4: // upload, desc MG_staticSortAlbum($aid, 2, 0, 0); break; case 5: // title, asc MG_staticSortAlbum($aid, 0, 1, 0); break; case 6: // title, desc MG_staticSortAlbum($aid, 0, 0, 0); break; case 7: // rating, desc MG_staticSortAlbum($aid, 3, 0, 0); break; case 8: // rating, desc MG_staticSortAlbum($aid, 3, 1, 0); break; default: // skip it... break; } } else { // not a root album... switch ($MG_albums[$MG_albums[$aid]->parent]->album_sort_order) { case 0: break; case 3: // upload, asc MG_staticSortAlbum($MG_albums[$aid]->parent, 2, 1, 0); break; case 4: // upload, desc MG_staticSortAlbum($MG_albums[$aid]->parent, 2, 0, 0); break; case 5: // title, asc MG_staticSortAlbum($MG_albums[$aid]->parent, 0, 1, 0); break; case 6: // title, desc MG_staticSortAlbum($MG_albums[$aid]->parent, 0, 0, 0); break; case 7: // rating, desc MG_staticSortAlbum($MG_albums[$aid]->parent, 3, 0, 0); break; case 8: // rating, desc MG_staticSortAlbum($MG_albums[$aid]->parent, 3, 1, 0); break; default: // skip it... break; } // now call it for myself to sort my subs switch ($MG_albums[$aid]->album_sort_order) { case 0: break; case 3: // upload, asc MG_staticSortAlbum($aid, 2, 1, 0); break; case 4: // upload, desc MG_staticSortAlbum($aid, 2, 0, 0); break; case 5: // title, asc MG_staticSortAlbum($aid, 0, 1, 0); break; case 6: // title, desc MG_staticSortAlbum($aid, 0, 0, 0); break; case 7: // rating, desc MG_staticSortAlbum($aid, 3, 0, 0); break; case 8: // rating, desc MG_staticSortAlbum($aid, 3, 1, 0); break; default: // skip it... break; } } if (!function_exists('MG_buildFullRSS')) { require_once $_CONF['path'] . 'plugins/mediagallery/include/rssfeed.php'; } MG_buildFullRSS(); MG_buildAlbumRSS($album->id); $actionURL = $_MG_CONF['site_url'] . '/album.php?aid=' . $album->id; echo COM_refresh($actionURL); exit; }
function _mg_centerblock($where = 1, $page = 1, $topic = '') { global $_CONF, $_MG_CONF, $MG_albums, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $LANG_MG03, $mg_installed_version; $pi_name = 'mediagallery'; // Plugin name $retval = ''; if ($_MG_CONF['gallery_only'] == 1 && $topic == '') { MG_galleryOnly(); } if ($mg_installed_version != $_MG_CONF['pi_version']) { return $retval; } if (COM_isAnonUser() && $_MG_CONF['loginrequired'] == 1) { return ''; } if ($topic == '') { $sTopic = "none"; } else { $sTopic = $topic; } if (!isset($_MG_CONF['feature_member_album'])) { $_MG_CONF['feature_member_album'] = 1; } if ($_MG_CONF['feature_member_album'] == 1 && $_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $where == 1) { $cbpos = CENTERBLOCK_TOP; //top of page $cbpage = 'none'; if ($cbpage == 'none' && ($page > 1 or $topic != "")) { $cbenable = 0; } elseif ($cbpage == 'all' && $page > 1) { $cbenable = 0; } elseif ($cbpage != 'none' && $cbpage != 'all' && $cbpage != $topic) { // $cbpage != $topic) { $cbenable = 0; } else { $cbenable = 1; } if ($cbenable == 1) { MG_initAlbums(); $sql = "SELECT album_id FROM {$_TABLES['mg_albums']} WHERE owner_id=" . (int) $_USER['uid'] . " AND album_parent='" . $_MG_CONF['member_album_root'] . "' LIMIT 1"; $result = DB_query($sql); $numRows = DB_numRows($result); if ($numRows > 0) { $A = DB_fetchArray($result); $album_id = $A['album_id']; $T = new Template(MG_getTemplatePath(0)); $T->set_file('page', 'cb_featured_album.thtml'); require_once $_CONF['path'] . 'plugins/mediagallery/include/classAlbum.php'; if ($MG_albums[$album_id]->last_update > 0) { $album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update); } else { $album_last_update = ''; } $cover = $MG_albums[$album_id]->findCover(); if ($cover != '') { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $cover[0] . '/' . $cover . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $cover[0] . '/' . $cover . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $cover[0] . '/' . $cover . $ext); break; } } } else { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); //$media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'empty.png'); } $album_media_count = $MG_albums[$album_id]->getMediaCount(); $updated_prompt = $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt']; $album_title = $MG_albums[$album_id]->title; $album_desc = $MG_albums[$album_id]->description; if ($MG_albums[$album_id]->tn_attached == 1) { $media_size = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$album_id]->id . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $MG_albums[$album_id]->id . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$album_id]->id . $ext); break; } } } if ($media_size == false) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); // @getimagesize($_MG_CONF['path_mediaobjects'] . 'missing.png'); } if (!empty($MG_albums[$album_id]->children)) { $saRows = 0; $SAchildren = $MG_albums[$album_id]->getChildren(); if (isset($_MG_CONF['subalbum_select']) && $_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay = '<form name="subalbums' . $MG_albums[$achild[$indexCounter]]->id . '" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0">'; $subAlbumDisplay .= '<select name="aid" onchange="forms[\'subalbums' . $MG_albums[$achild[$indexCounter]]->id . '\'].submit()">'; $subAlbumDisplay .= '<optgroup label="' . $LANG_MG01['select_subalbum'] . '">' . LB; } else { $subAlbumDisplay = ''; } foreach ($SAchildren as $SAchild) { if ($MG_albums[$SAchild]->access > 0) { if ($MG_albums[$SAchild]->hidden) { if ($MG_albums[$SAchild]->access == 3) { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } else { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } } if ($_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay .= '</optgroup></select>'; $subAlbumDisplay .= ' <input type="submit" value="' . $LANG_MG03['go'] . '" />'; $subAlbumDisplay .= '<input type="hidden" name="page" value="1" />'; $subAlbumDisplay .= '</form>'; } if ($saRows > 0 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('saulstart' => '<ul>', 'saulend' => '</ul>')); } else { $T->set_var(array('saulstart' => '', 'saulend' => '')); } $T->set_var(array('lang_subalbums' => $LANG_MG01['subalbums'], 'subalbumcount' => '(' . $saRows . ')', 'subalbumlist' => $subAlbumDisplay)); } else { $T->set_var(array('lang_subalbums' => '', 'subalbumcount' => '', 'subalbumlist' => '', 'saulstart' => '', 'saulend' => '')); } switch ($_MG_CONF['gallery_tn_size']) { case '0': //small $tn_height = 100; break; case '1': //medium $tn_height = 150; break; case '2': $tn_height = 200; break; default: $tn_height = 150; break; } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / $tn_height; $newwidth = $tn_height; $newheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; $newheight = $tn_height; $newwidth = round($media_size[0] / $ratio); } $T->set_var(array('site_url' => $_CONF['site_url'], 'album_id' => $album_id, 'album_title' => $album_title, 'album_desc' => $album_desc, 'album_media_count' => $album_media_count, 'subalbum_media_count' => $album_media_count, 'album_last_update' => $album_last_update[0], 'updated_prompt' => $MG_albums[$album_id]->last_update > 0 ? $updated_prompt : '', 'album_last_image' => $album_last_image, 'img_height' => $newheight, 'img_width' => $newwidth, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'column_width' => $newwidth + 30, 'u_viewalbum' => $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&page=1', 'lang_album' => $LANG_MG00['album'], 'featured_album' => $LANG_MG03['your_member_album'])); $T->parse('output', 'page'); $retval = $T->finish($T->get_var('output')); return $retval; } } } $result = DB_query("SELECT album_id, cbpage, cbposition FROM {$_TABLES['mg_albums']} WHERE featured='1' AND (cbpage='" . DB_escapeString($sTopic) . "' OR cbpage='all' OR cbpage='allnhp') " . COM_getPermSQL('and') . " LIMIT 1"); if (DB_numRows($result) == 1) { list($album_id, $cbpage, $cbpos) = DB_fetchArray($result); // If enabled only for homepage and this is not page 1 or a topic page, then set disable flag if ($cbpage == 'none' && ($page > 1 or $topic != "")) { $cbenable = 0; } elseif ($cbpage == 'all' && $page > 1) { $cbenable = 0; } elseif ($cbpage == 'allnhp' && COM_onFrontpage()) { $cbenable = 0; } elseif ($cbpage != 'allnhp' && $cbpage != 'none' && $cbpage != 'all' && $cbpage != $topic) { $cbenable = 0; } else { $cbenable = 1; } if ($cbenable and $cbpos == $where) { MG_initAlbums(); $T = new Template(MG_getTemplatePath(0)); $T->set_file('page', 'cb_featured_album.thtml'); if ($MG_albums[$album_id]->last_update > 0) { $album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update); } else { $album_last_update = ''; } $cover = $MG_albums[$album_id]->findCover(); if ($cover != '') { $media_size = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $cover[0] . '/' . $cover . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $cover[0] . '/' . $cover . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $cover[0] . '/' . $cover . $ext); break; } } } else { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); // $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'empty.png'); } $album_media_count = $MG_albums[$album_id]->getMediaCount(); $updated_prompt = $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt']; $album_title = $MG_albums[$album_id]->title; $album_desc = $MG_albums[$album_id]->description; if ($MG_albums[$album_id]->tn_attached == 1) { $media_size = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$album_id]->id . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $MG_albums[$album_id]->id . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$album_id]->id . $ext); break; } } } if ($media_size == false) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); // @getimagesize($_MG_CONF['path_mediaobjects'] . 'missing.png'); } if (!empty($MG_albums[$album_id]->children)) { $saRows = 0; $SAchildren = $MG_albums[$album_id]->getChildren(); if (isset($_MG_CONF['subalbum_select']) && $_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay = '<form name="subalbums' . $MG_albums[$achild[$indexCounter]]->id . '" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0">'; $subAlbumDisplay .= '<select name="aid" onchange="forms[\'subalbums' . $MG_albums[$achild[$indexCounter]]->id . '\'].submit()">'; $subAlbumDisplay .= '<optgroup label="' . $LANG_MG01['select_subalbum'] . '">' . LB; } else { $subAlbumDisplay = ''; } foreach ($SAchildren as $SAchild) { if ($MG_albums[$SAchild]->access > 0) { if ($MG_albums[$SAchild]->hidden) { if ($MG_albums[$SAchild]->access == 3) { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } else { $mediaCount = $MG_albums[$SAchild]->getMediaCount(); if ($_MG_CONF['subalbum_select'] == 1) { if (strlen($MG_albums[$SAchild]->title) > 50) { $aTitle = substr($MG_albums[$SAchild]->title, 0, 50) . '...'; } else { $aTitle = $MG_albums[$SAchild]->title; } $subAlbumDisplay .= '<option value="' . $MG_albums[$SAchild]->id . '">' . $aTitle . ' (' . $mediaCount . ')</option>'; } else { $subAlbumDisplay .= '<li><a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$SAchild]->id . '&page=1' . '">' . $MG_albums[$SAchild]->title . ' (' . $mediaCount . ')</a></li>'; } $saRows++; } } } if ($_MG_CONF['subalbum_select'] == 1) { $subAlbumDisplay .= '</optgroup></select>'; $subAlbumDisplay .= ' <input type="submit" value="' . $LANG_MG03['go'] . '" />'; $subAlbumDisplay .= '<input type="hidden" name="page" value="1" />'; $subAlbumDisplay .= '</form>'; } if ($saRows > 0 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('saulstart' => '<ul>', 'saulend' => '</ul>')); } else { $T->set_var(array('saulstart' => '', 'saulend' => '')); } $T->set_var(array('lang_subalbums' => $LANG_MG01['subalbums'], 'subalbumcount' => '(' . $saRows . ')', 'subalbumlist' => $subAlbumDisplay)); } else { $T->set_var(array('lang_subalbums' => '', 'subalbumcount' => '', 'subalbumlist' => '')); } switch ($_MG_CONF['gallery_tn_size']) { case '0': //small $tn_height = 100; break; case '1': //medium $tn_height = 150; break; case '2': $tn_height = 200; break; default: $tn_height = 150; break; } if ($media_size[0] > $media_size[1]) { $ratio = $media_size[0] / $tn_height; $newwidth = $tn_height; $newheight = round($media_size[1] / $ratio); } else { $ratio = $media_size[1] / $tn_height; $newheight = $tn_height; $newwidth = round($media_size[0] / $ratio); } $T->set_var(array('album_id' => $album_id, 'album_title' => $album_title, 'album_desc' => $album_desc, 'album_media_count' => $album_media_count, 'subalbum_media_count' => $album_media_count, 'album_last_update' => $album_last_update[0], 'updated_prompt' => $MG_albums[$album_id]->last_update > 0 ? $updated_prompt : '', 'album_last_image' => $album_last_image, 'img_height' => $newheight, 'img_width' => $newwidth, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'column_width' => $newwidth + 30, 'u_viewalbum' => $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&page=1', 'lang_album' => $LANG_MG00['album'], 'featured_album' => $LANG_MG03['featured_album'])); $T->parse('output', 'page'); $retval = $T->finish($T->get_var('output')); return $retval; } } }
function MG_purgeMemberAlbums() { global $MG_albums, $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01, $_POST; $numItems = count($_POST['album']); for ($i = 0; $i < $numItems; $i++) { // grab owner ID $result = DB_query("SELECT owner_id FROM {$_TABLES['mg_albums']} WHERE album_id=" . (int) COM_applyFilter($_POST['album'][$i], true)); $numRows = DB_numRows($result); if ($numRows > 0) { list($owner_id) = DB_fetchArray($result); DB_query("UPDATE {$_TABLES['mg_userprefs']} SET member_gallery=0 WHERE uid=" . $owner_id, 1); } MG_deleteChildAlbums((int) COM_applyFilter($_POST['album'][$i], true)); } MG_initAlbums(); require_once $_CONF['path'] . 'plugins/mediagallery/include/rssfeed.php'; MG_buildFullRSS(); echo COM_refresh($_MG_CONF['admin_url'] . 'index.php?msg=8'); exit; }