function MG_exportAlbums($aid, $path, $srcRoot, $destRoot) { global $_TABLES, $fp, $mvorcopy, $unix; $sep = '/'; $begin = "'"; $end = "'"; if ($unix == 0) { $sep = '\\'; $begin = '"'; $end = '"'; } if ($mvorcopy == 0) { $cpyCmd = $unix == 1 ? 'mv' : 'move'; } else { $cpyCmd = $unix == 1 ? 'cp' : 'copy'; } $album = new mgAlbum($aid); $children = $album->getChildren(); $nrows = count($children); if ($aid != 0) { $file_name = stripslashes($album->title); $file_name = MG_replace_accents($file_name); if ($unix == 1) { $file_name = preg_replace("#[ ]#", "_", $file_name); // change spaces to underscore $file_name = preg_replace('#[^()\\.\\-,\\w]#', '_', $file_name); //only parenthesis, underscore, letters, numbers, comma, hyphen, period - others to underscore } else { $file_name = preg_replace('#[^()\\.\\- \',\\w]#', '_', $file_name); //only parenthesis, underscore, letters, numbers, comma, hyphen, period - others to underscore } $file_name = preg_replace('#(_)+#', '_', $file_name); //eliminate duplicate underscore $path = $path . $file_name . $sep; } if ($aid != 0) { fputs($fp, 'mkdir ' . $begin . $destRoot . $path . $end . "\n"); } $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} AS ma INNER JOIN {$_TABLES['mg_media']} AS m " . " ON ma.media_id=m.media_id WHERE ma.album_id=" . intval($aid); $result = DB_query($sql); while ($M = DB_fetchArray($result)) { if ($M['media_original_filename'] != '') { $destFile = $M['media_original_filename']; } else { $destFile = $M['media_filename'] . '.' . $M['media_mime_ext']; } fputs($fp, $cpyCmd . " " . $begin . $srcRoot . $M['media_filename'][0] . $sep . $M['media_filename'] . '.' . $M['media_mime_ext'] . $end . " " . $begin . $destRoot . $path . $destFile . $end . "\n"); } fputs($fp, "\n\n"); for ($i = 0; $i < $nrows; $i++) { MG_exportAlbums($children[$i], $path, $srcRoot, $destRoot); } }
function MG_selectAlbums() { global $glversion, $_CONF, $_MG_CONF, $_TABLES, $LANG_MG01, $LANG_MG07; // start by building an array of all site users (active) if ($glversion[1] < 4) { $result = DB_query("SELECT * FROM {$_TABLES['users']} AS users LEFT JOIN {$_TABLES['userinfo']} AS userinfo ON users.uid=userinfo.uid"); } else { $result = DB_query("SELECT * FROM {$_TABLES['users']} AS users LEFT JOIN {$_TABLES['userinfo']} AS userinfo ON users.uid=userinfo.uid WHERE users.status=3"); } while ($U = DB_fetchArray($result)) { $siteUsers[$U['uid']]['lastlogin'] = $U['lastlogin']; $siteUsers[$U['uid']]['username'] = $U['username']; $siteUsers[$U['uid']]['fullname'] = $U['fullname']; } $retval = ''; $T = new Template($_MG_CONF['template_path']); $T->set_file('admin', 'purgealbums.thtml'); $T->set_var('site_url', $_CONF['site_url']); $T->set_var('site_admin_url', $_CONF['site_admin_url']); $T->set_var('xhtml', XHTML); $T->set_block('admin', 'UserRow', 'uRow'); $rowcounter = 0; $rowclass = 0; // now process all the albums directly off the album_root // we will not call this recursively, we only care about those off the root $album = new mgAlbum($_MG_CONF['member_album_root']); $children = $album->getChildren(); $numItems = count($children); for ($x = 0; $x < $numItems; $x++) { $child_album = new mgAlbum($children[$x]); if ($child_album->getMediaCount() == 0) { if ($siteUsers[$child_album->owner_id]['lastlogin'] == 0) { $lastlogin[0] = $LANG_MG07['never']; } else { $lastlogin = MG_getUserDateTimeFormat($siteUsers[$child_album->owner_id]['lastlogin']); } $T->set_var(array('select' => '<input type="checkbox" name="album[]" value="' . $child_album->id . '">', 'aid' => $child_album->id, 'title' => $child_album->title, 'owner' => $siteUsers[$child_album->owner_id]['username'] . '/' . $siteUsers[$child_album->owner_id]['fullname'], 'lastlogin' => $lastlogin[0], 'rowclass' => $rowclass % 2 ? '1' : '2')); $T->parse('uRow', 'UserRow', true); $rowcounter++; } } $T->set_var(array('lang_last_login' => $LANG_MG01['last_login'], 'lang_album_title' => $LANG_MG01['album_title'], 'lang_userid' => $LANG_MG01['userid'], 'lang_username' => $LANG_MG01['username'], 'lang_select' => $LANG_MG01['select'], 'lang_checkall' => $LANG_MG01['check_all'], 'lang_uncheckall' => $LANG_MG01['uncheck_all'], 'lang_delete' => $LANG_MG01['delete'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_reset' => $LANG_MG01['reset'], 's_form_action' => $_MG_CONF['admin_url'] . 'purgealbums.php')); $retval .= $T->finish($T->parse('output', 'admin')); return $retval; }
function _showSelectTree($aid = 0, $level = 0) { $album = new mgAlbum($aid); $retval = ''; $children = $album->getChildren(); if ($album->id != 0 && $album->access > 0) { $block = ''; if (!empty($children)) { $retval .= "<script type=\"text/javascript\"><!--" . LB . "function enableBlock" . $album->id . "() {" . LB . " if (document.galselect.elements['album[" . $album->id . "]'].checked) {" . LB; foreach ($children as $child) { $retval .= " document.galselect.elements['album[" . $child . "]'].disabled = true;" . LB; $retval .= " document.galselect.elements['album[" . $child . "]'].checked = true;" . LB; } $retval .= " } else {" . LB; foreach ($children as $child) { $retval .= " document.galselect.elements['album[" . $child . "]'].disabled = false;" . LB; $retval .= " document.galselect.elements['album[" . $child . "]'].checked = false;" . LB; } $retval .= " }" . LB; foreach ($children as $child) { $child_of_child = $album->getChildren($child); if (!empty($child_of_child)) { $retval .= ' enableBlock' . $child . '();' . LB; } } $retval .= "}" . LB . "// -->" . LB . "</script>" . LB; $block = 'onclick="enableBlock' . $album->id . '()" onchange="enableBlock' . $album->id . '()"'; } if ($album->parent != 0) { $block = ''; } $px = ($level - 1) * 15; $retval .= '<div style="margin-left:' . $px . 'px;">' . '<input type="checkbox" name="album[' . $album->id . ']" id="album_' . $album->id . '" value="1" ' . $block . XHTML . '> ' . strip_tags($album->title) . ' (' . COM_numberFormat($album->album_disk_usage / 1024) . ' Kb)</div>' . LB; } $level++; foreach ($children as $child) { $retval .= _showSelectTree($child, $level); } return $retval; }
function _mg_user_create($uid, $force = 0) { global $_TABLES, $_MG_CONF, $LANG_MG01; $sql = "INSERT INTO {$_TABLES['mg_userprefs']} (uid, active, display_rows, display_columns, mp3_player, playback_mode, tn_size, quota, member_gallery) VALUES (" . (int) $uid . ",1,0,0,-1,-1,-1," . $_MG_CONF['member_quota'] . ",0)"; DB_query($sql, 1); $retval = -1; if ($force == 1 || $_MG_CONF['member_albums'] == 1 && $_MG_CONF['member_auto_create'] == 1) { $username = DB_getItem($_TABLES['users'], 'username', 'uid=' . (int) $uid); $fullname = DB_getItem($_TABLES['users'], 'fullname', 'uid=' . (int) $uid); $grp_id = DB_getItem($_TABLES['groups'], 'grp_id', 'grp_name="mediagallery Admin"'); if ($grp_id == NULL || $grp_id == '' || $grp_id < 2) { $grp_id = 2; } $album = new mgAlbum(); //$_MG_CONF['member_use_fullname'] does not seem to be set.. $title = $username . $LANG_MG01['member_album_postfix']; if (!empty($fullname) && (isset($_MG_CONF['member_use_fullname']) && $_MG_CONF['member_use_fullname'] == 1)) { $title = $fullname . $LANG_MG01['member_album_postfix']; } $album->title = htmlspecialchars(strip_tags(COM_checkWords($title))); $album->parent = $_MG_CONF['member_album_root']; $album->group_id = $grp_id; $album->mod_group_id = $grp_id; $album->owner_id = $uid; $album->moderate = $_MG_CONF['member_moderate']; $album->email_mod = $_MG_CONF['member_email_mod']; $album->perm_owner = $_MG_CONF['member_perm_owner']; $album->perm_group = $_MG_CONF['member_perm_group']; $album->perm_members = $_MG_CONF['member_perm_members']; $album->perm_anon = $_MG_CONF['member_perm_anon']; $album->id = $album->createAlbumID(); $retval = $album->id; $album->saveAlbum(); $result = DB_query("UPDATE {$_TABLES['mg_userprefs']} SET member_gallery=1 WHERE uid=" . (int) $uid, 1); } return $retval; }
function MG_mediaEdit($album_id, $media_id, $actionURL = '', $mqueue = 0, $view = 0, $back = '') { global $_USER, $_CONF, $_MG_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG07, $_DB_dbms; $album = new mgAlbum($album_id); if ($actionURL == '') { $actionURL = $_MG_CONF['site_url'] . '/index.php'; } $retval = ''; $T = COM_newTemplate(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')); // pull the media information from the database... $sql = "SELECT * FROM "; if ($_DB_dbms == "mssql") { $sql = "SELECT *,CAST(media_desc AS TEXT) AS media_desc FROM "; } $sql .= ($mqueue ? $_TABLES['mg_mediaqueue'] : $_TABLES['mg_media']) . " WHERE media_id='" . addslashes($media_id) . "'"; $result = DB_query($sql); $row = DB_fetchArray($result); if ($album->access != 3 && !SEC_inGroup($album->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 COM_showMessageText($LANG_MG00['access_denied_msg']); } // Build Album List $album_jumpbox = '<select name="albums" width="40">'; $root_album = new mgAlbum(0); $root_album->buildJumpBox($album_jumpbox, $album_id); $album_jumpbox .= '</select>'; // should check the above for errors, etc... $exif_info = ''; 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 (empty($exif_info)) { $exif_info = ''; } } $media_time_month = date("m", $row['media_time']); $media_time_day = date("d", $row['media_time']); $media_time_year = date("Y", $row['media_time']); $media_time_hour = date("H", $row['media_time']); $media_time_minute = date("i", $row['media_time']); $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>'; $media_time = MG_getUserDateTimeFormat($row['media_time']); $tn_size = 1; list($thumbnail, $pThumbnail, $size) = Media::getThumbInfo($row, $tn_size); $attached_thumbnail = ''; if ($row['media_tn_attached'] == 1) { $atnsize = ''; if ($size != false) { list($newwidth, $newheight) = Media::getImageWH($size[0], $size[1], 150, 150); $atnsize = 'width="' . $newwidth . '" height="' . $newheight . '"'; } $attached_thumbnail = '<img src="' . $thumbnail . '" alt="" ' . $atnsize . XHTML . '>'; $tmpthumb = Media::getDefaultThumbnail($row, $tn_size); $thumbnail = $_MG_CONF['mediaobjects_url'] . '/' . $tmpthumb; $size = getimagesize($_MG_CONF['path_mediaobjects'] . $tmpthumb); } $preview = ''; $preview_end = ''; if ($row['media_type'] == 0 || $row['media_type'] == 1 || $row['media_type'] == 2) { // image, video and music file if ($row['media_type'] == 2) { $win_width = 540; $win_height = 320; } elseif ($row['media_type'] == 1) { $win_width = 660; $win_height = 525; } elseif ($row['media_type'] == 0) { $path = Media::getFilePath('disp', $row['media_filename'], $row['media_mime_ext']); $media_size_disp = @getimagesize($path); $win_width = $media_size_disp[0] + 20; $win_height = $media_size_disp[1] + 20; } else { $win_width = 800; $win_height = 600; } $url = Media::getHref_showvideo($row['media_id'], $win_height, $win_width, $mqueue); $preview = "<a href=\"" . $url . "\">"; $preview_end = "</a>"; } $rotate_right = ''; $rotate_left = ''; if ($row['media_type'] == 0 && ($_CONF['image_lib'] != 'gdlib' || function_exists("imagerotate"))) { $rotate_right = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=rotate&action=right&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;"' . XHTML . '></a>'; $rotate_left = '<a href="' . $_MG_CONF['site_url'] . '/admin.php?mode=rotate&action=left&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;"' . XHTML . '></a>'; } $resolution = ''; $lang_resolution = ''; if ($row['media_type'] == 1) { // video file $resolution = 'unknown'; if ($row['media_resolution_x'] > 0 && $row['media_resolution_y'] > 0) { $resolution = $row['media_resolution_x'] . 'x' . $row['media_resolution_y']; } $lang_resolution = $LANG_MG07['resolution']; } $sql = "SELECT * FROM {$_TABLES['mg_playback_options']} " . "WHERE media_id='" . addslashes($row['media_id']) . "'"; $poResult = DB_query($sql); $poNumRows = DB_numRows($poResult); // 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']; for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $uimode_select = MG_optionlist(array('name' => 'uimode', 'current' => $playback_options['uimode'], 'values' => array('none' => $LANG_MG07['none'], 'mini' => $LANG_MG07['mini'], 'full' => $LANG_MG07['full']))); $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_resolution' => $lang_resolution, 'resolution' => $resolution)); $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']; for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $uimode_select = MG_optionlist(array('name' => 'uimode', 'current' => $playback_options['uimode'], 'values' => array('none' => $LANG_MG07['none'], 'mini' => $LANG_MG07['mini'], 'full' => $LANG_MG07['full']))); $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"', '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'])); $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']; for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $quality_select = MG_optionlist(array('name' => 'quality', 'current' => $playback_options['quality'], 'values' => array('low' => $LANG_MG07['low'], 'high' => $LANG_MG07['high']))); $scale_select = MG_optionlist(array('name' => 'scale', 'current' => $playback_options['scale'], 'values' => array('showall' => $LANG_MG07['showall'], 'noborder' => $LANG_MG07['noborder'], 'exactfit' => $LANG_MG07['exactfit']))); $wmode_select = MG_optionlist(array('name' => 'wmode', 'current' => $playback_options['wmode'], 'values' => array('window' => $LANG_MG07['window'], 'opaque' => $LANG_MG07['opaque'], 'transparent' => $LANG_MG07['transparent']))); $asa_select = MG_optionlist(array('name' => 'allowscriptaccess', 'current' => $playback_options['allowscriptaccess'], 'values' => array('always' => $LANG_MG07['always'], 'sameDomain' => $LANG_MG07['sameDomain'], 'never' => $LANG_MG07['never']))); $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'])); 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']; for ($i = 0; $i < $poNumRows; $i++) { $poRow = DB_fetchArray($poResult); $playback_options[$poRow['option_name']] = $poRow['option_value']; } $scale_select = MG_optionlist(array('name' => 'scale', 'current' => $playback_options['scale'], 'values' => array('tofit' => $LANG_MG07['to_fit'], 'aspect' => $LANG_MG07['aspect'], '1' => $LANG_MG07['normal_size']))); $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"', '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'])); $T->parse('playback_options', 'mov_options'); } $remoteurl = $row['remote_url']; $lang_remote_url = $row['remote_media'] == 1 ? $LANG_MG01['remote_url'] : $LANG_MG01['alternate_url']; // user information $username = ''; if (SEC_hasRights('mediagallery.admin')) { $username = '******'; $sql = "SELECT * FROM {$_TABLES['users']} WHERE status=3 AND uid > 1 ORDER BY username ASC"; $result = DB_query($sql); while ($userRow = DB_fetchArray($result)) { $username .= '<option value="' . $userRow['uid'] . '"' . ($userRow['uid'] == $row['media_user_id'] ? ' selected="selected"' : '') . '>' . $userRow['username'] . '</option>' . LB; } $username .= '</select>'; } else { if ($row['media_user_id'] != '') { $displayname = $_CONF['show_fullname'] ? 'fullname' : 'username'; $username = DB_getItem($_TABLES['users'], $displayname, "uid={$row['media_user_id']}"); } } $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>'; $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"' : '', 'attached_thumbnail' => $attached_thumbnail, 'album_id' => $album_id, 'media_thumbnail' => $thumbnail, '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(), 'site_url' => $_MG_CONF['site_url'], 'preview' => $preview, 'preview_end' => $preview_end, 'rpath' => htmlentities($back, ENT_QUOTES, COM_getCharset()), 'remoteurl' => $remoteurl, 'lang_remote_url' => $lang_remote_url, 'resolution' => $resolution, 'lang_resolution' => $lang_resolution, 'username' => $username, 'cat_select' => $cat_select, 'media_keywords' => $row['media_keywords'], 'artist' => $row['artist'], 'musicalbum' => $row['album'], 'genre' => $row['genre'])); // language items $T->set_var(array('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_height' => $LANG_MG07['height'], 'lang_width' => $LANG_MG07['width'], 'lang_height_help' => $LANG_MG07['height_help'], 'lang_width_help' => $LANG_MG07['width_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_bgcolor' => $LANG_MG07['bgcolor'], 'lang_bgcolor_help' => $LANG_MG07['bgcolor_help'], 'lang_loop' => $LANG_MG07['loop'], 'lang_loop_help' => $LANG_MG07['loop_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_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_swf_version_help' => $LANG_MG07['swf_version_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_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_delete' => $LANG_MG01['delete'], 'lang_delete_confirm' => $LANG_MG01['delete_item_confirm'], 'lang_reset_rating' => $LANG_MG01['reset_rating'], 'lang_reset_views' => $LANG_MG01['reset_views'], 'lang_replacefile' => $LANG_MG01['replace_file'], 'lang_artist' => $LANG_MG01['artist'], 'lang_genre' => $LANG_MG01['genre'], 'lang_music_album' => $LANG_MG01['music_album'])); $retval .= $T->finish($T->parse('output', 'admin')); return $retval; }
$retval = ''; $retval .= '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" class="uk-form"><div>' . LB; $retval .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB; $retval .= '<option label="Options" value="">' . $LANG_MG01['options'] . '</option>' . LB; $retval .= $options; $retval .= '</select>' . LB; $retval .= '<input type="hidden" name="album_id" value="0"' . XHTML . '>' . LB; $retval .= '<input type="submit" value="' . $LANG_MG03['go'] . '"' . XHTML . '>' . LB; $retval .= '</div></form>' . LB; return $retval; } /* * Main */ $album_id = 0; $root_album = new mgAlbum(0); // root album if ($root_album->access == 0 || $root_album->hidden == 1 && $root_album->access != 3) { COM_errorLog("Media Gallery Error - User attempted to view an album that does not exist."); $display = COM_showMessageText($LANG_MG02['albumaccessdeny']); $display = MG_createHTMLDocument($display); COM_output($display); exit; } if ($_MG_CONF['usage_tracking']) { MG_updateUsage('MediaGallery', 'Main Menu', '', 0); } // initialize variables $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0; $columns_per_page = $root_album->display_columns; $rows_per_page = $root_album->display_rows;
/** * Displays pick list of files to process... * * @param int album_id album_id save uploaded media * @return string HTML * */ function MG_FTPpickFiles($album_id, $dir, $purgefiles, $recurse) { global $_CONF, $_MG_CONF, $LANG_MG01, $LANG_MG03, $destDirCount, $pCount; $destDirCount = 0; $pCount = 0; $retval = ''; $T = COM_newTemplate(MG_getTemplatePath($album_id)); $T->set_file('admin', 'ftpimport.thtml'); $T->set_var(array('start_block' => COM_startBlock($LANG_MG03['upload_media']), 'end_block' => COM_endBlock(), 'navbar' => MG_navbar($LANG_MG01['ftp_media'], $album_id), 'lang_title' => $LANG_MG01['title'], 'lang_description' => $LANG_MG01['description'], 'lang_parent_album' => $LANG_MG01['parent_album'], 'lang_filelist' => $LANG_MG01['file_list'], 'lang_quick_create' => $LANG_MG01['quick_create'], 'lang_checkall' => $LANG_MG01['check_all'], 'lang_uncheckall' => $LANG_MG01['uncheck_all'], 'dir' => $dir, 'purgefiles' => $purgefiles, 'recurse' => $recurse, 'album_id' => $album_id)); $filelist = MG_listDir($dir, $album_id, $purgefiles, $recurse, $session_id); $album_jumpbox = '<select name="parentaid">'; if (SEC_hasRights('mediagallery.admin')) { $album_jumpbox .= '<option value="0">' . $LANG_MG01['root_album'] . '</option>'; } else { $album_jumpbox .= '<option disabled value="0">' . $LANG_MG01['root_level'] . '</option>'; } $root_album = new mgAlbum(0); $root_album->buildJumpBox($album_jumpbox, 0, 3); $album_jumpbox .= '</select>'; $T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/admin.php', 'action' => 'ftpprocess', 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'parent_select' => $album_jumpbox, 'filelist' => $filelist)); $retval .= $T->finish($T->parse('output', 'admin')); return $retval; }
function MG_showTree($aid = 0, $depth = 0, $level = 0) { global $_CONF, $_MG_CONF; require_once $_CONF['path'] . 'plugins/mediagallery/include/classAlbum.php'; $album = new mgAlbum($aid); if ($album->hidden == 1 && $album->access != 3) { return ''; } $retval = ''; if ($album->access > 0) { $px = $level * 15; if ($depth == 0 || $level <= $depth) { $retval .= '<div style="margin-left:' . $px . 'px;">' . '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $album->id . '&page=1">' . strip_tags($album->title) . '</a></div>'; } } $children = $album->getChildren(); $level++; foreach ($children as $child) { $retval .= MG_showTree($child, $depth, $level); } return $retval; }
/** * 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_GlobalrebuildAllAlbumsRSS($aid) { MG_buildAlbumRSS($aid); $album = new mgAlbum($aid); $children = $album->getChildren(); foreach ($children as $child) { MG_GlobalrebuildAllAlbumsRSS($child); } }
function MG_deleteAlbumConfirm($album_id, $actionURL = '') { global $_USER, $_CONF, $LANG_MG00, $LANG_MG01; $album = new mgAlbum($album_id); if ($actionURL == '') { $actionURL = $_CONF['site_admin_url'] . '/plugins/mediagallery/index.php'; } $retval = ''; $retval .= COM_startBlock($LANG_MG01['delete_album'], '', COM_getBlockTemplate('_admin_block', 'header')); $T = COM_newTemplate(MG_getTemplatePath($album_id)); $T->set_file('admin', 'deletealbum.thtml'); $T->set_var('site_url', $_CONF['site_url']); $T->set_var('site_admin_url', $_CONF['site_admin_url']); $T->set_var('album_id', $album_id); if ($album->access != 3) { COM_errorLog("MediaGallery: Someone has tried to delete a album they do not have permissions. " . "User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return COM_showMessageText($LANG_MG00['access_denied_msg']); } if (!isset($album->id)) { COM_errorLog("MediaGallery: Someone has tried to delete a album to non-existent parent album. " . "User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return COM_showMessageText($LANG_MG00['access_denied_msg']); } $album_selectbox = '<select name="target"><option value="0">' . $LANG_MG01['delete_all_media'] . '</option>'; $root_album = new mgAlbum(0); $root_album->buildAlbumBox($album_selectbox, -1, 3, $album_id, 'upload'); $album_selectbox .= '</select>'; $T->set_var(array('album_id' => $album_id, 'album_title' => strip_tags($album->title), 'album_desc' => $album->description, 's_form_action' => $actionURL, 'select_destination' => $album_selectbox, 'lang_delete' => $LANG_MG01['delete'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete_album' => $LANG_MG01['delete_album'], 'lang_title' => $LANG_MG01['title'], 'lang_description' => $LANG_MG01['description'], 'lang_move_all_media' => $LANG_MG01['move_all_media'], 'lang_album_delete_help' => $LANG_MG01['album_delete_help'])); $retval .= $T->finish($T->parse('output', 'admin')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
function MG_staticSortChildAlbum($startaid, $sql_order, $sql_sort_by) { global $_TABLES; $sql = "SELECT album_id,album_order FROM {$_TABLES['mg_albums']} " . "WHERE album_parent=" . intval($startaid) . $sql_sort_by . $sql_order; $order = 10; $result = DB_query($sql); $numRows = DB_numRows($result); $album_id = array(); $album_order = array(); for ($x = 0; $x < $numRows; $x++) { $row = DB_fetchArray($result); $album_id[$x] = $row['album_id']; $album_order[$x] = $order; $order += 10; } $album_count = $numRows; for ($x = 0; $x < $album_count; $x++) { DB_change($_TABLES['mg_albums'], 'album_order', $album_order[$x], 'album_id', $album_id[$x]); } $album = new mgAlbum($startaid); $children = $album->getChildren(); foreach ($children as $child) { MG_staticSortChildAlbum($child, $sql_order, $sql_sort_by); } }
function MG_staticSortAlbumOptions() { global $_CONF, $_MG_CONF, $_TABLES, $LANG_MG01, $LANG_MG03; $retval = ''; $T = new Template($_MG_CONF['template_path']); $T->set_file('admin', 'staticsortalbums.thtml'); $T->set_var('site_url', $_CONF['site_url']); $T->set_var('site_admin_url', $_CONF['site_admin_url']); // build album list for starting point... $root_album = new mgAlbum(0); $album_jumpbox = '<select name="startaid">'; $album_jumpbox .= '<option value="0">------</option>'; $root_album->buildJumpBox($album_jumpbox, 0, 3); $album_jumpbox .= '</select>'; // build sort fields select $sort_field = '<select name="sortfield">'; $sort_field .= '<option value="0">' . $LANG_MG01['album_title'] . '</option>'; $sort_field .= '<option value="1">' . $LANG_MG01['media_count'] . '</option>'; $sort_field .= '<option value="2">' . $LANG_MG01['last_update'] . '</option>'; $sort_field .= '</select>'; $T->set_var(array('s_form_action' => $_MG_CONF['admin_url'] . 'staticsortalbums.php', 'album_select' => $album_jumpbox, 'sort_field_select' => $sort_field, 'lang_starting_album' => $LANG_MG01['starting_album'], 'lang_sort_by' => $LANG_MG03['sort_by'], 'lang_sort_order' => $LANG_MG01['order'], 'lang_ascending' => $LANG_MG01['ascending'], 'lang_descending' => $LANG_MG01['descending'], 'lang_process_subs' => $LANG_MG01['process_subs'], 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_static_album_sort' => $LANG_MG01['static_sort_albums'])); $retval .= $T->finish($T->parse('output', 'admin')); return $retval; }
function MG_displayMedia($id, $full = 0, $sortOrder = 0, $comments = 0, $spage = 0) { global $_TABLES, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03, $LANG_MG04, $LANG_ACCESS, $_USER; $retval = ''; $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . addslashes($id) . '"'); require_once $_CONF['path'] . 'plugins/mediagallery/include/classAlbum.php'; $mg_album = new mgAlbum($aid); $root_album = new mgAlbum(0); $pid = 0; if (isset($mg_album->pid)) { $pid = $mg_album->pid; } $aOffset = -1; $aOffset = $mg_album->getOffset(); if ($aOffset == -1 || $mg_album->access == 0) { $retval = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); return array($LANG_MG00['access_denied_msg'], $retval); } $sql = MG_buildMediaSql(array('album_id' => $aid, 'sortorder' => $mg_album->enable_sort ? $sortOrder : 0)); $result = DB_query($sql); $nRows = DB_numRows($result); $total_media = $nRows; $media_array = array(); while ($row = DB_fetchArray($result)) { $media_array[] = $row; $id_array[] = $row['media_id']; } $key = array_search($id, $id_array); if ($key === false) { $retval = COM_startBlock($LANG_ACCESS['accessdenied'], '', COM_getBlockTemplate('_msg_block', 'header')) . '<br' . XHTML . '>' . $LANG_MG00['access_denied_msg'] . COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); return array($LANG_MG00['access_denied_msg'], $retval); } $media = $media_array[$key]; if ($mg_album->full == 2 || $_MG_CONF['discard_original'] == 1 || $mg_album->full == 1 && $_USER['uid'] > 1) { $full = 0; } $disp = $full ? 'orig' : 'disp'; if ($mg_album->enable_comments == 0) { $comments = 0; } $display_skin = $mg_album->display_skin; MG_getCSS($display_skin); // construct the album jumpbox... $album_jumpbox = ''; if (!$_MG_CONF['hide_jumpbox_on_mediaview']) { $album_jumpbox = MG_buildAlbumJumpbox($root_album, $aid, 1, -1); } // Update the views count... But only for non-admins if (!$root_album->owner_id) { $media_views = $media['media_views'] + 1; DB_change($_TABLES['mg_media'], 'media_views', $media_views, 'media_id', addslashes($media['media_id'])); } $columns_per_page = $mg_album->display_columns == 0 ? $_MG_CONF['ad_display_columns'] : $mg_album->display_columns; $rows_per_page = $mg_album->display_rows == 0 ? $_MG_CONF['ad_display_rows'] : $mg_album->display_rows; $_MG_USERPREFS = MG_getUserPrefs(); if (isset($_MG_USERPREFS['display_rows']) && $_MG_USERPREFS['display_rows'] > 0) { $rows_per_page = $_MG_USERPREFS['display_rows']; } if (isset($_MG_USERPREFS['display_columns']) && $_MG_USERPREFS['display_columns'] > 0) { $columns_per_page = $_MG_USERPREFS['display_columns']; } $media_per_page = $columns_per_page * $rows_per_page; if ($mg_album->albums_first) { $childCount = $mg_album->getChildCount(); $page = intval(($key + $childCount) / $media_per_page) + 1; } else { $page = intval($key / $media_per_page) + 1; } /* * check to see if the original image exists, if not fall back to full image */ $media_size_orig = @getimagesize(Media::getFilePath('orig', $media['media_filename'], $media['media_mime_ext'])); if ($media_size_orig == false) { $full = 0; $disp = 'disp'; } $aPage = intval($aOffset / ($root_album->display_columns * $root_album->display_rows)) + 1; $birdseed = MG_getBirdseed($mg_album->id, 1, $sortOrder, $aPage); $album_link = '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $aid . '&page=' . $page . '&sort=' . $sortOrder . '">'; if ($_MG_CONF['usage_tracking']) { MG_updateUsage('media_view', $mg_album->title, $media['media_title'], $media['media_id']); } // hack for tga files... if ($media['mime_type'] == 'image/x-targa' || $media['mime_type'] == 'image/tga') { $full = 0; $disp = 'disp'; } $prevLink = ''; $nextLink = ''; $pagination = ''; $base_url = $_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '1' : '0') . "&sort=" . $sortOrder; list($prevLink, $nextLink) = MG_getNextandPrev($base_url, $nRows, $key, $media_array); // generate pagination routine if (!empty($prevLink)) { $pagination .= '<a href="' . $prevLink . '">' . $LANG_MG03['previous'] . '</a>'; } if (!empty($nextLink)) { $pagination .= !empty($prevLink) ? ' ' : ''; $pagination .= '<a href="' . $nextLink . '">' . $LANG_MG03['next'] . '</a>'; } $pagination .= LB; // hack for testing...>>> $media_id = $media['media_id']; if ($_MG_CONF['click_image_and_go_next'] && !$_MG_CONF['full_in_popup']) { $nextkey = MG_getNextitem($nRows, $key); if ($nextkey !== '') { $media_id = $media_array[$nextkey]['media_id']; } } $vf = $full; if ($media['media_type'] == '0') { // image $switch_size = $_MG_CONF['site_url'] . "/media.php?f=" . ($full ? '0' : '1') . '&sort=' . $sortOrder . '&s=' . $media['media_id']; $lang_switch_size = $full ? $LANG_MG03['normal_size'] : $LANG_MG03['full_size']; $switch_viewsize_link = '<a href="' . $switch_size . '">' . $lang_switch_size . '</a>'; } // hack for testing...<<< $opt = array('full' => $full, 'media_id' => $media_id, 'sortOrder' => $sortOrder, 'spage' => $spage, 'playback_type' => $mg_album->playback_type, 'skin' => $mg_album->skin, 'display_skin' => $mg_album->display_skin, 'allow_download' => $mg_album->allow_download, 'full_display' => $mg_album->full); list($u_image, $raw_image, $raw_image_width, $raw_image_height, $raw_link_url) = MG_buildContent($media, $opt); $mid = $media['media_id']; if ($_MG_CONF['use_upload_time'] == 1) { $media_date = MG_getUserDateTimeFormat($media['upload_time']); } else { $media_date = MG_getUserDateTimeFormat($media['media_time']); } $rating_box = ''; if ($mg_album->enable_rating > 0) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-rating.php'; $rating_box = MG_getRatingBar($mg_album->enable_rating, $media['media_user_id'], $media['media_id'], $media['media_votes'], $media['media_rating'], ''); } $download_link = ''; $download = ''; if ($mg_album->allow_download) { $download_link = $_MG_CONF['site_url'] . '/download.php?mid=' . $media['media_id']; $download = '<a href="' . $download_link . '">' . $LANG_MG01['download'] . '</a>'; } $edit_item_link = ''; $edit_item = ''; if ($mg_album->access == 3 || $_MG_CONF['allow_user_edit'] == true && isset($_USER['uid']) && $media['media_user_id'] == $_USER['uid']) { $edit_item_link = $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&s=1&album_id=' . $aid . '&mid=' . $mid; $edit_item = '<a href="' . $edit_item_link . '">' . $LANG_MG01['edit'] . '</a>'; } $media_desc = PLG_replaceTags(nl2br($media['media_desc'])); if (strlen($media_desc) > 0) { $media_desc = '<p style="margin:5px">' . $media_desc . '</p>'; } $getid3link = ''; $getid3linkend = ''; $media_properties = $getid3link != '' ? $LANG_MG03['media_properties'] : ''; $kwText = ''; $lang_keywords = ''; if ($mg_album->enable_keywords == 1 && !empty($media['media_keywords'])) { $lang_keywords = $LANG_MG01['keywords']; $keyWords = array(); $keyWords = explode(' ', $media['media_keywords']); $numKeyWords = count($keyWords); for ($i = 0; $i < $numKeyWords; $i++) { $keyWords[$i] = str_replace('"', ' ', $keyWords[$i]); $searchKeyword = $keyWords[$i]; $keyWords[$i] = str_replace('_', ' ', $keyWords[$i]); $kwText .= '<a href="' . $_MG_CONF['site_url'] . '/search.php?mode=search&swhere=1&keywords=' . $searchKeyword . '&keyType=any">' . $keyWords[$i] . '</a>'; } } $media_user_id = $media['media_user_id']; if (empty($media_user_id)) { $media_user_id = 0; } $displayname = $_CONF['show_fullname'] ? 'fullname' : 'username'; $owner_name = DB_getItem($_TABLES['users'], $displayname, "uid = {$media_user_id}"); if (empty($owner_name)) { $owner_name = DB_getItem($_TABLES['users'], 'username', "uid = {$media_user_id}"); if (empty($owner_name)) { $owner_name = 'unknown'; } } $owner_link = $owner_name; if ($owner_name != 'unknown') { $owner_link = '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $media_user_id . '">' . $owner_name . '</a>'; } $property = ''; if (($mg_album->exif_display == 2 || $mg_album->exif_display == 3) && $media['media_type'] == 0) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php'; $haveEXIF = MG_haveEXIF($media['media_id']); if ($haveEXIF) { $property = $_MG_CONF['site_url'] . '/property.php?mid=' . $media['media_id']; } } $media_id = ''; if ($root_album->owner_id || $_MG_CONF['enable_media_id'] == 1) { $media_id = $media['media_id']; } $exif_info = ''; if (($mg_album->exif_display == 1 || $mg_album->exif_display == 3) && $media['media_type'] == 0) { require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-exif.php'; $haveEXIF = MG_haveEXIF($media['media_id']); if ($haveEXIF) { $exif_info = MG_readEXIF($media['media_id'], 2); } } $T = COM_newTemplate(MG_getTemplatePath_byName($mg_album->skin)); switch ($media['media_type']) { case '0': // image $T->set_file('page', 'view_image.thtml'); break; case '1': // video // video case '5': // embedded video $T->set_file('page', 'view_video.thtml'); break; case '2': // audio $T->set_file('page', 'view_audio.thtml'); break; default: $T->set_file('page', 'view_image.thtml'); break; } $T->set_var(array('header' => $LANG_MG00['plugin'], 'site_url' => $_MG_CONF['site_url'], 'plugin' => 'mediagallery', 'birdseed' => $birdseed, 'lang_slideshow_link' => $LANG_MG03['slide_show'], 'image_detail' => $u_image, 'media_title' => isset($media['media_title']) && $media['media_title'] != ' ' ? PLG_replaceTags($media['media_title']) : '', 'album_title' => $mg_album->title, 'media_desc' => isset($media['media_desc']) && $media['media_desc'] != ' ' ? $media_desc : '', 'media_time' => $media_date[0], 'media_views' => $mg_album->enable_views ? $media['media_views'] : '', 'media_comments' => $mg_album->enable_comments ? $media['media_comments'] : '', 'pagination' => $pagination, 'media_number' => sprintf("%s %d %s %d", $LANG_MG03['image'], $key + 1, $LANG_MG03['of'], $total_media), 'jumpbox' => $album_jumpbox, 'rating_box' => $rating_box, 'download' => $download, 'download_link' => $download_link, 'lang_download' => $LANG_MG01['download'], 'edit_item' => $edit_item, 'edit_item_link' => $edit_item_link, 'lang_edit' => $LANG_MG01['edit'], 'lang_prev' => $LANG_MG03['previous'], 'lang_next' => $LANG_MG03['next'], 'next_link' => $nextLink, 'prev_link' => $prevLink, 'image_height' => $raw_image_height, 'image_width' => $raw_image_width, 'left_side' => intval($raw_image_width / 2) - 1, 'right_side' => intval($raw_image_width / 2), 'raw_image' => $raw_image, 'raw_link_url' => $raw_link_url, 'item_number' => $key + 1, 'total_items' => $total_media, 'lang_of' => $LANG_MG03['of'], 'album_link' => $album_link, 'switch_size' => $switch_size, 'lang_switch_size' => $lang_switch_size, 'switch_size_link' => $switch_viewsize_link, 'getid3' => $getid3link, 'getid3end' => $getid3linkend, 'media_properties' => $media_properties, 'media_keywords' => $kwText, 'lang_keywords' => $lang_keywords, 'owner_username' => $owner_link, 'property' => $property, 'lang_property' => $LANG_MG04['exif_header'], 'media_id' => $media_id, 'exif_info' => $exif_info, 'lang_comments' => $mg_album->enable_comments ? $LANG_MG03['comments'] : '', 'lang_views' => $mg_album->enable_views ? $LANG_MG03['views'] : '', 'lang_title' => $LANG_MG01['title'], 'lang_uploaded_by' => $LANG_MG01['uploaded_by'], 'album_id' => $aid, 'lang_search' => $LANG_MG01['search'])); MG_buildSlideshow($mg_album, $T, $sortOrder); PLG_templateSetVars('mediagallery', $T); $retval .= $T->finish($T->parse('output', 'page')); if ($comments) { // Geeklog Comment support $sid = $media['media_id']; require_once $_CONF['path_system'] . 'lib-comment.php'; $delete_option = false; if ($mg_album->access == 3 || $root_album->owner_id) { $delete_option = true; } $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0; $comorder = ''; if (isset($_POST['order'])) { $comorder = COM_applyFilter($_POST['order']); } elseif (isset($_GET['order'])) { $comorder = COM_applyFilter($_GET['order']); } $commode = ''; if (isset($_POST['mode'])) { $commode = COM_applyFilter($_POST['mode']); } elseif (isset($_GET['mode'])) { $commode = COM_applyFilter($_GET['mode']); } $commentcode = 0; // 今のところ無条件にコメント投稿を許可。 $retval .= CMT_userComments($sid, $media['media_title'], 'mediagallery', $comorder, $commode, 0, $page, false, $delete_option, $commentcode); } return array(strip_tags($media['media_title']), $retval, $aid); }
function buildAlbumBox(&$album_selectbox, $selected, $access = 1, $hide = 0, $type = 'upload', $level = 0) { global $_USER, $_MG_CONF; $_MG_USERPREFS = MG_getUserPrefs(); $mgadmin = SEC_hasRights('mediagallery.admin'); $count = 0; $indent = ''; $z = 0; while ($z < $level) { $indent .= " "; $z++; } if ($type == 'upload') { if ($_MG_CONF['member_albums'] && $this->isMemberAlbum() && $this->owner_id == $_USER['uid'] && $_MG_USERPREFS['active'] || $this->member_uploads && $this->access >= 2 || $this->access >= $access || $mgadmin) { if ($this->id != $hide) { if (!$this->hidden || $this->hidden && $mgadmin) { if ($this->id != 0) { $album_selectbox .= '<option value="' . $this->id . '"' . ($this->id == $selected ? ' selected="selected" ' : '') . '>' . $indent; $tatitle = strip_tags($this->title); if (strlen($tatitle) > 50) { $aTitle = COM_truncate($tatitle, 50) . '...'; } else { $aTitle = $tatitle; } $album_selectbox .= $aTitle . '</option>'; $count++; } } } } } if ($type == 'edit') { if ($this->id == $selected || $_MG_CONF['member_albums'] && $_MG_CONF['member_album_root'] == $this->id && $_MG_CONF['member_create_new'] && $_MG_USERPREFS['active'] || $this->access >= $access) { if ($this->id != $hide) { if (!$this->hidden || $mgadmin) { $album_selectbox .= '<option value="' . $this->id . '"' . ($this->id == $selected ? ' selected="selected" ' : '') . '>' . $indent; $tatitle = strip_tags($this->title); if (strlen($tatitle) > 50) { $aTitle = COM_truncate($tatitle, 50) . '...'; } else { $aTitle = $tatitle; } //$aTitle = $tatitle; // . '(' . $this->access . ')'; $album_selectbox .= $aTitle . '</option>'; $count++; } } } } if ($type == 'create') { if ($_MG_CONF['member_albums'] && $_MG_CONF['member_album_root'] == $this->id && $_MG_CONF['member_create_new'] && $_MG_USERPREFS['active'] || $this->access >= $access) { if ($this->id != $hide) { if (!$this->hidden || $this->hidden && $mgadmin) { if ($this->id != 0 || ($mgadmin || $_MG_CONF['member_albums'] == 1 && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new'])) { $album_selectbox .= '<option value="' . $this->id . '"' . ($this->id == $selected ? ' selected="selected" ' : '') . '>' . $indent; $tatitle = strip_tags($this->title); if (strlen($tatitle) > 50) { $aTitle = COM_truncate($tatitle, 50) . '...'; } else { $aTitle = $tatitle; } $album_selectbox .= $aTitle . '</option>'; $count++; } } } } } if ($type == 'manage') { if ($this->access >= $access) { if (!$this->hidden || $this->hidden && $mgadmin) { if ($this->id != 0 || ($mgadmin || $_MG_CONF['member_albums'] == 1 && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new'])) { $album_selectbox .= '<option ' . ($this->id == $hide ? 'disabled="disabled" ' : '') . ' value="' . $this->id . '"' . ($this->id == $selected && $this->id != $hide ? ' selected="selected" ' : '') . '>' . $indent; $tatitle = strip_tags($this->title); if (strlen($tatitle) > 50) { $aTitle = COM_truncate($tatitle, 50) . '...'; } else { $aTitle = $tatitle; } $album_selectbox .= $aTitle . '</option>'; $count++; } } } } if ($this->id != $hide || $this->id == $hide && $type == 'manage') { $children = $this->getChildren(); foreach ($children as $child) { $child_album = new mgAlbum($child); $count += $child_album->buildAlbumBox($album_selectbox, $selected, $access, $hide, $type, $level + 1); } } return $count; }