function MG_saveEnroll() { global $_CONF, $_MG_CONF, $_MG_USERPREFS, $_TABLES, $_USER, $LANG_MG03; if ($_MG_CONF['member_albums'] != 1) { echo COM_refresh($_MG_CONF['site_url'] . '/index.php'); exit; } if (!isset($_MG_CONF['member_quota'])) { $_MG_CONF['member_quota'] = 0; } $sql = "SELECT album_id FROM {$_TABLES['mg_albums']} WHERE owner_id=" . (int) $_USER['uid'] . " AND album_parent=" . $_MG_CONF['member_album_root']; $result = DB_query($sql); $nRows = DB_numRows($result); if ($nRows > 0) { $display = MG_siteHeader(); $display .= COM_showMessageText($LANG_MG03['existing_member_album'], '', true); $display .= MG_siteFooter(); echo $display; exit; } $uid = (int) $_USER['uid']; $aid = plugin_user_create_mediagallery($uid, 1); $result = DB_query("UPDATE {$_TABLES['mg_userprefs']} SET member_gallery=1,quota=" . $_MG_CONF['member_quota'] . " WHERE uid=" . $uid, 1); $affected = DB_affectedRows($result); if (DB_error()) { $sql = "INSERT INTO {$_TABLES['mg_userprefs']} (uid, active, display_rows, display_columns, mp3_player, playback_mode, tn_size, quota, member_gallery) VALUES (" . $uid . ",1,0,0,-1,-1,-1," . $_MG_CONF['member_quota'] . ",1)"; DB_query($sql, 1); } CACHE_remove_instance('menu'); echo COM_refresh($_MG_CONF['site_url'] . '/album.php?aid=' . $aid); exit; }
function handleSubscribe($album_id) { global $_CONF, $_TABLES, $_USER, $MG_albums, $LANG_MG02; $referer = isset($_SERVER['HTTP_REFERER']) ? COM_sanitizeUrl($_SERVER['HTTP_REFERER']) : $_CONF['site_url']; if ($referer == '') { $referer = $_CONF['site_url']; } $sLength = strlen($_CONF['site_url']); if (substr($referer, 0, $sLength) != $_CONF['site_url']) { $referer = $_CONF['site_url']; } $hasargs = strstr($referer, '?'); if ($hasargs) { $sep = '&'; } else { $sep = '?'; } if (COM_isAnonUser()) { echo COM_refresh($referer . $sep . 'msg=518'); exit; } $errorMessage = ''; if (!isset($MG_albums[$album_id]->id)) { $errorMessage = $LANG_MG02['albumaccessdeny']; } else { if ($MG_albums[$album_id]->access == 0 || $MG_albums[$album_id]->hidden == 1 && $MG_albums[$album_id]->access != 3) { $errorMessage = $LANG_MG02['albumaccessdeny']; } } if (!empty($errorMessage)) { echo MG_siteHeader(); echo $errorMessage; echo MG_siteFooter(); exit; } $uid = $_USER['uid']; $id_desc = $MG_albums[$album_id]->title; $rc = PLG_subscribe('mediagallery', '', $album_id, $uid, '', $id_desc); if ($rc === false) { echo COM_refresh($referer . $sep . 'msg=519'); exit; } echo COM_refresh($referer . $sep . 'msg=520'); exit; }
$sort_user = $_USER['uid']; } $sort_datetime = time(); $referer = DB_escapeString($referer); $keywords = DB_escapeString($keywords); $sql = "INSERT INTO {$_TABLES['mg_sort']} (sort_id,sort_user,sort_query,sort_results,sort_datetime,referer,keywords)\n VALUES ('{$sort_id}',{$sort_user},'{$sqltmp}',{$numresults},{$sort_datetime},'{$referer}','{$keywords}')"; $result = DB_query($sql); if (DB_error()) { COM_errorLog("Media Gallery: Error placing sort query into database"); } $sort_purge = time() - 3660; // 43200; DB_query("DELETE FROM {$_TABLES['mg_sort']} WHERE sort_datetime < " . $sort_purge); $pageBody .= MG_search($sort_id, 1); } elseif ($mode == $LANG_MG01['cancel']) { echo COM_refresh($_MG_CONF['site_url'] . '/index.php'); exit; } elseif (isset($_GET['id'])) { $id = COM_applyFilter($_GET['id']); $page = COM_applyFilter($_GET['page'], true); if ($page < 1) { $page = 1; } $pageBody .= MG_search($id, $page); } else { $pageBody .= MG_displaySearchBox(''); } $display = MG_siteHeader($LANG_MG00['results']); $display .= $pageBody; $display .= MG_siteFooter(); echo $display;
} $full = 0; if (isset($_REQUEST['f'])) { $full = COM_applyFilter($_REQUEST['f'], true); } $mediaObject = 0; if (isset($_REQUEST['s'])) { $mediaObject = COM_applyFilter($_REQUEST['s'], true); } $sortOrder = 0; if (isset($_REQUEST['sort'])) { $sortOrder = COM_applyFilter($_REQUEST['sort'], true); } $sortID = 0; if (isset($_REQUEST['i'])) { $sortID = COM_applyFilter($_REQUEST['i'], true); } $page = 0; if (isset($_REQUEST['p'])) { $page = COM_applyFilter($_REQUEST['p'], true); } list($ptitle, $retval, $themeCSS, $album_id) = MG_displayMediaImage($mediaObject, $full, $sortOrder, 1, $sortID, $page); $themeStyle = MG_getThemeCSS($album_id); $display = MG_siteHeader($ptitle); if ($msg != '') { $display .= COM_showMessage($msg, 'mediagallery'); } $display .= $retval; $display .= MG_siteFooter(); echo $display; exit;
function MG_index() { global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle; $display = ''; $media_size = false; $page = 0; if (isset($_GET['page'])) { $page = COM_applyFilter($_GET['page'], true); } if ($page != 0) { $page = $page - 1; } $themeStyle = MG_getThemeCSS(0); if (!isset($_MG_CONF['album_display_columns']) || $_MG_CONF['album_display_columns'] < 1) { $_MG_CONF['album_display_columns'] = 1; } switch ($_MG_CONF['album_display_columns']) { case 1: $albumListTemplate = 'gallery_page_body_1.thtml'; $albumColumnWidth = "100%"; break; case 2: $albumListTemplate = 'gallery_page_body_2.thtml'; $albumColumnWidth = "50%"; break; default: $albumListTemplate = 'gallery_page_body_3.thtml'; $albumColumnWidth = @intval(100 / $_MG_CONF['album_display_columns']) . '%'; if ($albumColumnWidth == 0) { $albumColumnWidth = "25%"; } break; } $T = new Template(MG_getTemplatePath(0)); $T->set_file(array('page' => 'gallery_page.thtml', 'body' => $albumListTemplate, 'noitems' => 'gallery_page_noitems.thtml')); $T->set_var(array('lang_menulabel' => $_MG_CONF['menulabel'], 'lang_search' => $LANG_MG01['search'], 'site_url' => $_MG_CONF['site_url'])); if ($_MG_CONF['rss_full_enabled']) { $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'); $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">'; $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>'; $T->set_var('rsslink', $rsslink); $T->set_var('rsslink_url', $feedUrl); } else { $T->set_var('rsslink', ''); } $nFrame = new mgFrame(); $nFrame->constructor($_MG_CONF['indexskin']); $MG_albums[0]->albumFrameTemplate = $nFrame->getTemplate(); $MG_albums[0]->afrWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $MG_albums[0]->afrHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; // Let's build our admin menu options $showAdminBox = 0; $admin_box_item = ''; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB; $admin_box .= '<div>'; $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB; $admin_box_item .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) { $admin_box_item .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB; $showAdminBox = 1; } if ($MG_albums[0]->owner_id) { $admin_box_item .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB; $admin_box_item .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB; $admin_box_item .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_box_item .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB; $admin_box_item .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB; $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($MG_albums[0]->access == 3) { $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_box_item .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } $admin_box .= $admin_box_item; $admin_box .= '</select>' . LB; $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB; $admin_box .= '</div>'; $admin_box .= '</form>'; // build ul $admin_menu = ''; $showAdminMenu = 0; $admin_url = $_MG_CONF['site_url'] . '/admin.php?album_id=0'; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && !COM_isAnonUser()) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=upload">' . $LANG_MG01['add_media'] . '</a></li>'; $showAdminMenu = 1; } if ($MG_albums[0]->owner_id) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=albumsort">' . $LANG_MG01['sort_albums'] . '</a></li>'; $admin_menu .= '<li><a href="' . $admin_url . '&mode=globalattr">' . $LANG_MG01['globalattr'] . '</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=globalperm">' . $LANG_MG01['globalperm'] . '</a></li>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_menu .= '<li><a href="' . $admin_url . '&mode=moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=wmmanage">' . $LANG_MG01['wm_management'] . '</a></li>' . LB; $admin_menu .= '<li><a href="' . $admin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } elseif ($MG_albums[0]->access == 3) { $admin_Menu .= '<li><a href="' . $abmin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } elseif ($_MG_CONF['member_albums'] == 1 && !COM_isAnonUser() && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_menu .= '<li><a href="' . $admin_url . '&mode=create">' . $LANG_MG01['create_album'] . '</a></li>' . LB; $showAdminMenu = 1; } // end of ul if ($showAdminBox == 0) { $admin_box = ''; $admin_box_item = ''; } if ($showAdminMenu == 1) { $T->set_var('admin_menu', $admin_menu); } $T->set_var('select_adminbox', $admin_box); $T->set_var('select_box_items', $admin_box_item); $album_count = 0; $width = intval(100 / $_MG_CONF['album_display_columns']); $rowcounter = 0; $albumCount = 0; $indexCounter = 0; if (COM_isAnonUser()) { $lastlogin = time(); } else { if (!COM_isAnonUser()) { $lastlogin = $_USER['lastlogin']; } else { $lastlogin = time(); } } $children = $MG_albums[0]->getChildren(); $nrows = count($children); $checkCounter = 0; $aCount = 0; $achild = array(); for ($i = 0; $i < $nrows; $i++) { $access = $MG_albums[$children[$i]]->access; if ($access == 0 || $MG_albums[$children[$i]]->hidden == 1 && $access != 3) { // no op } else { $achild[] = $MG_albums[$children[$i]]->id; $aCount++; } } if ($_MG_CONF['album_display_rows'] < 1) { $_MG_CONF['album_display_rows'] = 9; } $items_per_page = $_MG_CONF['album_display_columns'] * $_MG_CONF['album_display_rows']; $begin = $items_per_page * $page; $end = $items_per_page; $nrows = count($achild); $indexCounter = $begin; $noParse = 0; $needFinalParse = 0; if ($nrows > 0) { $k = 0; $T->set_block('body', 'AlbumColumn', 'AColumn'); $T->set_block('body', 'AlbumRow', 'ARow'); for ($i = $begin; $i < $begin + $items_per_page; $i += $_MG_CONF['album_display_columns']) { for ($j = $i; $j < $i + $_MG_CONF['album_display_columns']; $j++) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; if ($j >= $nrows) { $k = $i + $_MG_CONF['album_display_columns'] - $j; $m = $k % $_MG_CONF['album_display_columns']; for ($z = $m; $z > 0; $z--) { $needFinalParse = 1; } if ($needFinalParse == 1) { $T->parse('ARow', 'AlbumRow', true); $T->set_var('AColumn', ''); } $noParse = 1; break; } $access = $MG_albums[$achild[$indexCounter]]->access; if ($access == 0 || $MG_albums[$achild[$indexCounter]]->hidden == 1 && $access != 3) { $j--; $indexCounter++; continue; } $albumCount++; if ($MG_albums[$achild[$indexCounter]]->media_count > 0) { if ($MG_albums[$achild[$indexCounter]]->cover_filename != '' && $MG_albums[$achild[$indexCounter]]->cover_filename != '0') { $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update); if (substr($MG_albums[$achild[$indexCounter]]->cover_filename, 0, 3) == 'tn_') { $offset = 3; } else { $offset = 0; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $MG_albums[$achild[$indexCounter]]->cover_filename[$offset] . '/' . $MG_albums[$achild[$indexCounter]]->cover_filename . $ext); break; } } $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count; if (!COM_isAnonUser()) { if ($MG_albums[$achild[$indexCounter]]->last_update > $lastlogin) { $album_last_update[0] = '<font color="red">' . $album_last_update[0] . '</font>'; } } $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'])); } else { $album_media_count = $MG_albums[$achild[$indexCounter]]->media_count; $album_last_update = MG_getUserDateTimeFormat($MG_albums[$achild[$indexCounter]]->last_update); $filename = $MG_albums[$achild[$indexCounter]]->findCover(); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } else { if (substr($filename, 0, 3) == 'tn_') { $offset = 3; } else { $offset = 0; } foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[$offset] . '/' . $filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[$offset] . '/' . $filename . $ext); break; } } } $T->set_var(array('updated_prompt' => $_MG_CONF['dfid'] == '99' ? '' : $LANG_MG03['updated_prompt'])); } } else { // nothing in the album yet... // here we need to search the sub-albums if any and see if we can find a picture.... $album_media_count = 0; $album_last_update[0] = ""; $filename = $MG_albums[$achild[$indexCounter]]->findCover(); if ($filename == '') { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } else { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/tn/' . $filename[0] . '/' . $filename . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $filename[0] . '/' . $filename . $ext); break; } } } $T->set_var('updated_prompt', ''); } $T->clear_var(array('lang_views', 'views')); if ($MG_albums[$achild[$indexCounter]]->enable_album_views) { $T->set_var(array('lang_views' => $LANG_MG03['views'], 'views' => $MG_albums[$achild[$indexCounter]]->views)); } if ($MG_albums[$achild[$indexCounter]]->tn_attached == 1) { $media_size = false; foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext)) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext; $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'covers/cover_' . $MG_albums[$achild[$indexCounter]]->id . $ext); break; } } } // a little fail safe here to make sure we don't show empty boxes... if ($media_size === false || $media_size[0] == 0 || $media_size[1] == 0) { $album_last_image = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $media_size = array(200, 200); } // set the image size here... switch ($_MG_CONF['gallery_tn_size']) { case '0': //small $tn_height = 100; $tn_width = 100; break; case '1': //medium $tn_height = 150; $tn_width = 150; break; case '2': $tn_height = 200; $tn_width = 200; break; case '3': $tn_height = $_MG_CONF['gallery_tn_height']; $tn_width = $_MG_CONF['gallery_tn_width']; break; default: $tn_height = 200; $tn_width = 200; 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); } // pull the sub-album info here $subAlbumDisplay = ''; 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; } $saRows = 0; $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist')); if (!empty($MG_albums[$achild[$indexCounter]]->children)) { $SAchildren = $MG_albums[$achild[$indexCounter]]->getChildren(); 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 ($_MG_CONF['album_display_columns'] > 1 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('subalbumlist' => '<span style="font-weight:bold;">' . $LANG_MG01['subalbums'] . '</span> (' . $saRows . ')')); } else { $T->set_var(array('lang_subalbums' => $LANG_MG01['subalbums'], 'subalbumcount' => '(' . $saRows . ')', 'subalbumlist' => $subAlbumDisplay)); } } if ($saRows == 0) { $T->clear_var(array('lang_subalbums', 'subalbumcount', 'subalbumlist')); } $T->clear_var(array('saulstart', 'saulend')); if ($saRows > 0 && $_MG_CONF['subalbum_select'] != 1) { $T->set_var(array('saulstart' => '<ul>', 'saulend' => '</ul>')); } // now pull the total image count for all sub albums... $total_images_subalbums = $MG_albums[$achild[$indexCounter]]->getMediaCount(); $owner_id = $MG_albums[$achild[$indexCounter]]->owner_id; if ($owner_id == '' || !isset($MG_albums[$achild[$indexCounter]]->owner_id)) { $owner_id = 0; } $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($owner_id)); $F = new Template($_MG_CONF['template_path']); $F->set_var('media_frame', $MG_albums[0]->albumFrameTemplate); $F->set_var(array('border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight)); $F->parse('media', 'media_frame'); $media_item_thumbnail = $F->finish($F->get_var('media')); $T->set_var(array('media_item_thumbnail' => $media_item_thumbnail, 'class' => $rowcounter % 2, 'table_column_width' => 'width="' . $width . '%"', 'album_id' => $MG_albums[$achild[$indexCounter]]->id, 'album_title' => PLG_replaceTags($MG_albums[$achild[$indexCounter]]->title, 'mediagallery', 'album_title'), 'album_desc' => $MG_albums[$achild[$indexCounter]]->description == '' ? '' : PLG_replaceTags($MG_albums[$achild[$indexCounter]]->description, 'mediagallery', 'album_description'), 'album_media_count' => $album_media_count, 'subalbum_media_count' => $total_images_subalbums, 'album_owner' => $ownername, 'album_last_update' => $album_last_update[0], 'column_width' => $albumColumnWidth, 'column_width2' => $tn_height + 35 . 'px', 'lang_album' => $LANG_MG00['album'], 'border_width' => $newwidth + 20, 'border_height' => $newheight + 20, 'media_link_start' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1' . '">', 'media_link_end' => '</a>', 'url_media_item' => $_MG_CONF['site_url'] . '/album.php?aid=' . $MG_albums[$achild[$indexCounter]]->id . '&page=1', 'media_thumbnail' => $album_last_image, 'media_size' => 'width="' . $newwidth . '" height="' . $newheight . '"', 'media_height' => $newheight, 'media_width' => $newwidth, 'media_tag' => strip_tags($MG_albums[$achild[$indexCounter]]->title), 'frWidth' => $newwidth - $MG_albums[0]->afrWidth, 'frHeight' => $newheight - $MG_albums[0]->afrHeight)); $T->parse('AColumn', 'AlbumColumn', true); $indexCounter++; } if ($noParse == 1) { break; } else { $T->parse('ARow', 'AlbumRow', true); $T->set_var('AColumn', ''); } } } $T->set_var(array('bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, ceil($aCount / $items_per_page)), 'table_columns' => $_MG_CONF['album_display_columns'])); if ($albumCount == 0) { $T->set_var(array('noitems' => $LANG_MG03['no_album_objects'])); $T->parse('gallery_noitems', 'noitems'); } else { $T->parse('gallery_body', 'body'); } $T->parse('output', 'page'); $nCSS = $nFrame->getCSS(); if ($nCSS != '') { $outputHandle = outputHandler::getInstance(); $outputHandle->addStyle($nCSS); } $display .= MG_siteHeader($LANG_MG00['plugin']); $display .= $T->finish($T->get_var('output')); $display .= MG_siteFooter(); echo $display; exit; }
function MG_indexAll() { global $_USER, $_MG_CONF, $_CONF, $_TABLES, $MG_albums, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $themeStyle, $ImageSkin, $sortOrder, $displayColumns, $displayRows, $tnSize, $level, $album_jumpbox; $album_id = 0; if (isset($_GET['aid'])) { $album_id = (int) COM_applyFilter($_GET['aid'], true); } $page = 0; if (isset($_GET['page'])) { $page = (int) COM_applyFilter($_GET['page'], true); } if ($page != 0) { $page = $page - 1; } $lbSlideShow = ''; $errorMessage = ''; $columns_per_page = $displayColumns; $rows_per_page = $displayRows; $media_per_page = $columns_per_page * $rows_per_page; // image frame setup $nFrame = new mgFrame(); $nFrame->constructor($ImageSkin); $imageFrameTemplate = $nFrame->getTemplate(); $frWidth = $nFrame->frame['wHL'] + $nFrame->frame['wHR']; $frHeight = $nFrame->frame['hVT'] + $nFrame->frame['hVB']; $fCSS = $nFrame->getCSS(); // Let's build our admin menu options $showAdminBox = 0; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0;">' . LB; $admin_box .= '<div>'; $admin_box .= '<select onchange="javascript:forms[\'adminbox\'].submit();" name="mode">' . LB; $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>' . LB; if (($MG_albums[0]->member_uploads || $MG_albums[0]->access == 3) && (isset($_USER['uid']) && $_USER['uid'] > 1)) { $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>' . LB; $showAdminBox = 1; } if ($MG_albums[0]->owner_id) { $admin_box .= '<option value="albumsort">' . $LANG_MG01['sort_albums'] . '</option>' . LB; $admin_box .= '<option value="globalattr">' . $LANG_MG01['globalattr'] . '</option>' . LB; $admin_box .= '<option value="globalperm">' . $LANG_MG01['globalperm'] . '</option>' . LB; $queue_count = DB_count($_TABLES['mg_media_album_queue']); $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>' . LB; $admin_box .= '<option value="wmmanage">' . $LANG_MG01['wm_management'] . '</option>' . LB; $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($MG_albums[0]->access == 3) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } elseif ($_MG_CONF['member_albums'] == 1 && (isset($_USER['uid']) && $_USER['uid'] > 1) && $_MG_CONF['member_album_root'] == 0 && $_MG_CONF['member_create_new']) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>' . LB; $showAdminBox = 1; } $admin_box .= '</select>' . LB; $admin_box .= '<input type="hidden" name="album_id" value="0"/>' . LB; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>' . LB; $admin_box .= '</div>'; $admin_box .= '</form>'; if ($showAdminBox == 0) { $admin_box = ''; } // construct the album jumpbox... $level = 0; $album_jumpbox = '<form name="jumpbox" id="jumpbox" action="' . $_MG_CONF['site_url'] . '/album.php' . '" method="get" style="margin:0;padding:0"><div>'; $album_jumpbox .= $LANG_MG03['jump_to'] . ': <select name="aid" onchange="forms[\'jumpbox\'].submit()">'; $MG_albums[0]->buildJumpBox(0); $album_jumpbox .= '</select>'; $album_jumpbox .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>'; $album_jumpbox .= '<input type="hidden" name="page" value="1"/>'; $album_jumpbox .= '</div></form>'; // initialize our variables $total_media = 0; $arrayCounter = 0; $total_object_count = 0; $mediaObject = array(); $begin = $media_per_page * $page; $end = $media_per_page; $MG_media = array(); // loop thru all the albums and build a list of valid albums that the user can see $first = 0; $albumList = getAlbumList($album_id, $first); $orderBy = ' ORDER BY m.media_upload_time ' . $sortOrder; if ($albumList != '') { $sql = "SELECT COUNT(*) AS total 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 IN (" . $albumList . ") " . $orderBy; $result = DB_query($sql); $row = DB_fetchArray($result); $cCount = $row['total']; } else { $cCount = 0; } if ($albumList != '') { $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 IN (" . $albumList . ") " . $orderBy; $sql .= ' LIMIT ' . $begin . ',' . $end; $result = DB_query($sql); $nRows = DB_numRows($result); } else { $nRows = 0; } $mediaRows = 0; $lbss_count = 0; $posCount = 0; if ($nRows > 0) { while ($row = DB_fetchArray($result)) { $media = new MediaItem(); $media->constructor($row, $row['album_id']); $MG_media[$arrayCounter] = $media; $MG_albums[$row['album_id']]->imageFrameTemplate = $imageFrameTemplate; $arrayCounter++; $mediaRows++; } } $total_media = $total_media + $mediaRows; $total_items_in_album = $cCount; $total_pages = ceil($total_items_in_album / $media_per_page); if ($page >= $total_pages) { $page = $total_pages - 1; } $start = $page * $media_per_page; $current_print_page = floor($start / $media_per_page) + 1; $total_print_pages = ceil($total_items_in_album / $media_per_page); if ($current_print_page == 0) { $current_print_page = 1; } if ($total_print_pages == 0) { $total_print_pages = 1; } // now build the admin select... $admin_box = ''; $admin_box = '<form name="adminbox" id="adminbox" action="' . $_MG_CONF['site_url'] . '/admin.php" method="get" style="margin:0;padding:0">'; $admin_box .= '<div><input type="hidden" name="album_id" value="' . $album_id . '"/>'; $admin_box .= '<select name="mode" onchange="forms[\'adminbox\'].submit()">'; $admin_box .= '<option label="' . $LANG_MG01['options'] . '" value="">' . $LANG_MG01['options'] . '</option>'; $admin_box .= '<option value="search">' . $LANG_MG01['search'] . '</option>'; $uploadMenu = 0; $adminMenu = 0; if ($MG_albums[0]->owner_id) { $uploadMenu = 1; $adminMenu = 1; } else { if ($MG_albums[$album_id]->access == 3) { $uploadMenu = 1; $adminMenu = 1; if ($_MG_CONF['member_albums']) { if ($_MG_USERPREFS['active'] != 1) { $uploadMenu = 0; $adminMenu = 0; } else { $uploadMenu = 1; $adminMenu = 1; } } } else { if ($MG_albums[$album_id]->member_uploads == 1 && isset($_USER['uid']) && $_USER['uid'] >= 2) { $uploadMenu = 1; $adminMenu = 0; } } } if ($uploadMenu == 1) { $admin_box .= '<option value="upload">' . $LANG_MG01['add_media'] . '</option>'; } if ($adminMenu == 1) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>'; } elseif ($_MG_CONF['member_albums'] == 1 && !empty($_USER['username']) && $_MG_CONF['member_create_new'] == 1 && $_MG_USERPREFS['active'] == 1 && $album_id == $_MG_CONF['member_album_root']) { $admin_box .= '<option value="create">' . $LANG_MG01['create_album'] . '</option>'; $adminMenu = 1; } // now check for moderation capabilities.... if ($MG_albums[$album_id]->member_uploads == 1 && $MG_albums[$album_id]->moderate == 1) { // check to see if we are in the album_mod_group if (SEC_inGroup($MG_albums[$album_id]->mod_group_id) || $MG_albums[0]->owner_id) { $queue_count = DB_count($_TABLES['mg_media_album_queue'], 'album_id', $album_id); $admin_box .= '<option value="moderate">' . $LANG_MG01['media_queue'] . ' (' . $queue_count . ')</option>'; $adminMenu = 1; } } $admin_box .= '</select>'; $admin_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '" style="padding:0px;margin:0px;"/>'; $admin_box .= '</div></form>'; if ($uploadMenu == 0 && $adminMenu == 0) { $admin_box = ''; } if ($MG_albums[$album_id]->enable_sort == 1) { $sort_box = '<form name="sortbox" id="sortbox" action="' . $_MG_CONF['site_url'] . '/album.php" method="get" style="margin:0;padding:0"><div>'; $sort_box .= '<input type="hidden" name="aid" value="' . $album_id . '"/>'; $sort_box .= '<input type="hidden" name="page" value="' . $page . '"/>'; $sort_box .= $LANG_MG03['sort_by'] . ' <select name="sort" onchange="forms[\'sortbox\'].submit()">'; $sort_box .= '<option value="0" ' . ($sortOrder == 0 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default'] . '</option>'; $sort_box .= '<option value="1" ' . ($sortOrder == 1 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_default_asc'] . '</option>'; $sort_box .= '<option value="2" ' . ($sortOrder == 2 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload'] . '</option>'; $sort_box .= '<option value="3" ' . ($sortOrder == 3 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_upload_asc'] . '</option>'; $sort_box .= '<option value="4" ' . ($sortOrder == 4 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture'] . '</option>'; $sort_box .= '<option value="5" ' . ($sortOrder == 5 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_capture_asc'] . '</option>'; $sort_box .= '<option value="6" ' . ($sortOrder == 6 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating'] . '</option>'; $sort_box .= '<option value="7" ' . ($sortOrder == 7 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_rating_asc'] . '</option>'; $sort_box .= '<option value="8" ' . ($sortOrder == 8 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views'] . '</option>'; $sort_box .= '<option value="9" ' . ($sortOrder == 9 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views_asc'] . '</option>'; $sort_box .= '<option value="10" ' . ($sortOrder == 10 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha'] . '</option>'; $sort_box .= '<option value="11" ' . ($sortOrder == 11 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha_asc'] . '</option>'; $sort_box .= '</select>'; $sort_box .= ' <input type="submit" value="' . $LANG_MG03['go'] . '"/>'; $sort_box .= '</div></form>'; } else { $sort_box = ''; } $owner_id = $MG_albums[$album_id]->owner_id; if ($owner_id == '' || !isset($MG_albums[$album_id]->owner_id)) { $owner_id = 0; } $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . (int) $owner_id); $album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update); $T = new Template($_MG_CONF['template_path']); $T->set_file(array('page' => 'index-all.thtml')); //@TODO fix language tag $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'album_title' => "All Photos - Sorted by Post Date", 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php?aid=' . $album_id, $page + 1, ceil($total_items_in_album / $media_per_page)), 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => $album_jumpbox, 'album_id' => $album_id, 'lbslideshow' => $lbSlideShow, 'album_description' => $MG_albums[$album_id]->display_album_desc ? PLG_replaceTags($MG_albums[$album_id]->description) : '', 'album_id_display' => $MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => $admin_box, 'select_sortbox' => $sort_box, 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $MG_albums[$album_id]->getMediaCount(), 'lang_search' => $LANG_MG01['search'], 'table_columns' => $displayColumns)); $T->set_var('select_adminbox', $admin_box); if ($_MG_CONF['rss_full_enabled']) { $feedUrl = MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'); $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">'; $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" alt="" style="border:none;"/></a>'; $T->set_var('rsslink', $rsslink); } else { $T->set_var('rsslink', ''); } // completed setting header / footer vars, parse them PLG_templateSetVars('mediagallery', $T); if ($total_media == 0) { $T->set_var(array('lang_no_image' => $LANG_MG03['no_media_objects'])); } // // main processing of the album contents. // $noParse = 0; $needFinalParse = 0; if ($total_media > 0) { $k = 0; $T->set_block('page', 'ImageColumn', 'IColumn'); $T->set_block('page', 'ImageRow', 'IRow'); for ($i = 0; $i < $media_per_page; $i += $columns_per_page) { for ($j = $i; $j < $i + $columns_per_page; $j++) { if ($j >= $total_media) { $k = $i + $columns_per_page - $j; $m = $k % $columns_per_page; for ($z = $m; $z > 0; $z--) { $T->set_var(array('CELL_DISPLAY_IMAGE' => '')); $T->parse('IColumn', 'ImageColumn', true); $needFinalParse = 1; } if ($needFinalParse == 1) { $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); } $noParse = 1; break; } $previous_image = $i - 1; if ($previous_image < 0) { $previous_image = -1; } $next_image = $i + 1; if ($next_image >= $total_media - 1) { $next_image = -1; } $z = $j + $start; $celldisplay = $MG_media[$j]->displayThumb($z, 0, $imageFrameTemplate); if ($MG_media[$j]->type == 1) { $PhotoURL = $_MG_CONF['mediaobjects_url'] . '/disp/' . $MG_media[$j]->filename[0] . '/' . $MG_media[$j]->filename . '.jpg'; $T->set_var(array('URL' => $PhotoURL)); } $T->set_var(array('CELL_DISPLAY_IMAGE' => $celldisplay)); $T->parse('IColumn', 'ImageColumn', true); } if ($noParse == 1) { break; } $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); } } $T->parse('output', 'page'); $fCSS = $nFrame->getCSS(); if ($fCSS != '') { $outputHandle = outputHandler::getInstance(); $outputHandle->addStyle($fCSS); } $display = MG_siteHeader(strip_tags($MG_albums[$album_id]->title)); $display .= $T->finish($T->get_var('output')); $display .= MG_siteFooter(); echo $display; }
if (isset($_GET['album_id']) && isset($_GET['media_id']) && isset($_GET['action'])) { require_once $_CONF['path'] . 'plugins/mediagallery/include/rotate.php'; $album_id = COM_applyFilter($_GET['album_id'], true); $media_id = COM_sanitizeID(COM_applyFilter($_GET['media_id'])); $direction = COM_applyFilter($_GET['action']); $queue = COM_applyFilter($_GET['queue'], true); $srcFrom = isset($_GET['s']) ? COM_applyFilter($_GET['s'], true) : 0; $srcURL = ''; if ($srcFrom) { $srcURL = '&s=1'; } $eMode = $queue == 0 ? 'mediaedit' : 'mediaeditq'; $actionURL = $_MG_CONF['site_url'] . '/admin.php?mode=' . $eMode . $srcURL . '&mid=' . $media_id . '&album_id=' . $album_id; MG_rotateMedia($album_id, $media_id, $direction, $actionURL); } else { $display = MG_siteHeader(); $display .= MG_invalidRequest(); } $display .= MG_siteFooter(); echo $display; } else { if ($mode == 'cancel') { if (isset($_POST['admin_menu']) && $_POST['admin_menu'] == 1) { echo COM_refresh($_MG_CONF['admin_url'] . '/index.php'); exit; } else { if (isset($_POST['album_id']) && $_POST['album_id'] > 0) { echo COM_refresh($_MG_CONF['site_url'] . '/album.php?aid=' . COM_applyFilter($_POST['album_id'])); } echo COM_refresh($_MG_CONF['site_url'] . '/index.php'); exit;
exit; } require_once $_CONF['path'] . 'plugins/mediagallery/include/init.php'; MG_initAlbums(); /* * Main Function */ COM_setArgNames(array('aid', 'f', 'sort')); $album_id = COM_applyFilter(COM_getArgument('aid'), true); $T = new Template(MG_getTemplatePath($album_id)); $T->set_file(array('page' => 'playall_xspf.thtml')); if ($MG_albums[$album_id]->access == 0) { $display .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true); $display .= MG_siteFooter(); echo $display; exit; } $album_title = $MG_albums[$album_id]->title; $album_desc = $MG_albums[$album_id]->description; MG_usage('playalbum', $album_title, '', ''); $birdseed = '<a href="' . $_CONF['site_url'] . '/index.php">' . $LANG_MG03['home'] . '</a> ' . ($_MG_CONF['gallery_only'] == 1 ? '' : $_MG_CONF['seperator'] . ' <a href="' . $_MG_CONF['site_url'] . '/index.php">' . $_MG_CONF['menulabel'] . '</a> ') . $MG_albums[$album_id]->getPath(1, 0, 1); $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'pagination' => '<a href="' . $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&page=1&sort=' . '0' . '">' . $LANG_MG03['return_to_album'] . '</a>', 'album_title' => $album_title, 'album_desc' => $album_desc, 'aid' => $album_id, 'home' => $LANG_MG03['home'], 'return_to_album' => $LANG_MG03['return_to_album'])); /* * Need to handle empty albums a little better */ $themeStyle = MG_getThemeCSS($album_id); $display = MG_siteHeader(strip_tags($MG_albums[$album_id]->title)); $T->parse('output', 'page'); $display .= $T->finish($T->get_var('output')); $display .= MG_siteFooter(); echo $display;
function MG_sendPostCard() { global $MG_albums, $_MG_CONF, $_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG02, $LANG_MG03, $LANG_ACCESS, $_POST; global $LANG_DIRECTION, $LANG_CHARSET; $mid = COM_sanitizeID(COM_applyFilter($_POST['mid'], true)); $toname = COM_applyFilter($_POST['toname']); $toemail = COM_applyFilter($_POST['toemail']); $fromname = COM_applyFilter($_POST['fromname']); $fromemail = COM_applyFilter($_POST['fromemail']); $subject = strip_tags(COM_checkWords($_POST['subject'])); $message = htmlspecialchars(strip_tags(COM_checkWords($_POST['message']))); $ccself = isset($_POST['ccself']) ? 1 : 0; $errCount = 0; $msg = ''; if (!COM_isEmail($toemail)) { $errCount++; } if (!COM_isEmail($fromemail)) { $errCount++; } if (empty($subject)) { $errCount++; } if (empty($message)) { $errCount++; } $captchaString = isset($_POST['captcha']) ? $_POST['captcha'] : ''; $msg = PLG_itemPreSave('mediagallery', $captchaString); if ($msg != '') { $errCount++; } if ($errCount > 0) { return MG_editPostCard('edit', $mid, $msg); } $retval = ''; $aid = DB_getItem($_TABLES['mg_media_albums'], 'album_id', 'media_id="' . DB_escapeString($mid) . '"'); if ($MG_albums[$aid]->access == 0 || $MG_albums[$aid]->enable_postcard == 0 || COM_isAnonUser() && $MG_albums[$aid]->enable_postcard != 2) { $retval = MG_siteHeader(); $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true); $retval .= MG_siteFooter(); echo $retval; exit; } $sql = "SELECT * FROM {$_TABLES['mg_media_albums']} as ma LEFT JOIN " . $_TABLES['mg_media'] . " as m " . " ON ma.media_id=m.media_id WHERE m.media_id='" . DB_escapeString($mid) . "'"; $result = DB_query($sql); $nRows = DB_numRows($result); if ($nRows < 1) { $retval = MG_siteHeader(); $retval .= COM_showMessageText($LANG_MG00['access_denied_msg'], $LANG_ACCESS['accessdenied'], true); $retval .= MG_siteFooter(); echo $retval; exit; } $M = DB_fetchArray($result); // trim the database $purgeDate = time() - $_MG_CONF['postcard_retention'] * 86400; DB_query("DELETE FROM {$_TABLES['mg_postcard']} WHERE pc_time < " . $purgeDate); // save this one in the database $newsubject = DB_escapeString($subject); $newmessage = DB_escapeString($message); $pcId = COM_makesid(); $pc_time = time(); if (COM_isAnonUser()) { $uid = 1; } else { $uid = (int) $_USER['uid']; } $sql = "INSERT INTO {$_TABLES['mg_postcard']} (pc_id,mid,to_name,to_email,from_name,from_email,subject,message,pc_time,uid) VALUES ('{$pcId}','" . DB_escapeString($mid) . "','" . DB_escapeString($toname) . "','" . DB_escapeString($toemail) . "','" . DB_escapeString($fromname) . "','" . DB_escapeString($fromemail) . "','{$newsubject}','{$newmessage}',{$pc_time},{$uid})"; $result = DB_query($sql); if (DB_error()) { COM_errorLog("Media Gallery: Error saving postcard"); } COM_clearSpeedlimit($_CONF['commentspeedlimit'], 'mgpostcard'); $last = COM_checkSpeedlimit('mgpostcard'); if ($last > 0) { $msg = sprintf($LANG_MG02['postcard_speedlimit'], $last); return MG_errorHandler($msg); } $alternate_link = $_MG_CONF['site_url'] . '/getcard.php?id=' . $pcId; // build the template... $T = new Template(MG_getTemplatePath($aid)); $T->set_file('postcard', 'postcard.thtml'); $media_size = @getimagesize($_MG_CONF['path_mediaobjects'] . 'tn/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg'); if (empty($LANG_DIRECTION)) { // default to left-to-right $direction = 'ltr'; } else { $direction = $LANG_DIRECTION; } if (empty($LANG_CHARSET)) { $charset = $_CONF['default_charset']; if (empty($charset)) { $charset = 'iso-8859-1'; } } else { $charset = $LANG_CHARSET; } $T->set_var(array('s_form_action' => $_MG_CONF['site_url'] . '/postcard.php', 'direction' => $direction, 'charset' => $charset, 'mid' => $mid, 'media_title' => $M['media_title'], 'alt_media_title' => htmlspecialchars(strip_tags($M['media_title'])), 'media_description' => isset($M['media_description']) ? $M['media_description'] : '', 'media_url' => $_MG_CONF['site_url'] . '/media.php?s=' . $mid, 'media_image' => $_MG_CONF['mediaobjects_url'] . '/disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . '.jpg', 'site_url' => $_MG_CONF['site_url'] . '/', 'postcard_subject' => $subject, 'postcard_message' => nl2br($message), 'from_email' => $fromemail, 'site_name' => $_CONF['site_name'], 'site_slogan' => $_CONF['site_slogan'], 'to_name' => $toname, 'from_name' => $fromname, 'pc_id' => $pcId, 'lang_to_name' => $LANG_MG03['to_name'], 'lang_to_email' => $LANG_MG03['to_email'], 'lang_from_name' => $LANG_MG03['from_name'], 'lang_from_email' => $LANG_MG03['from_email'], 'lang_subject' => $LANG_MG03['subject'], 'lang_send' => $LANG_MG03['send'], 'lang_cancel' => $LANG_MG03['cancel'], 'lang_preview' => $LANG_MG03['preview'], 'lang_unable_view' => $LANG_MG03['unable_to_view_postcard'], 'lang_postcard_from' => $LANG_MG03['postcard_from'], 'lang_to' => $LANG_MG03['to'], 'lang_from' => $LANG_MG03['from'], 'lang_visit' => $LANG_MG03['visit'])); $T->parse('output', 'postcard'); $retval .= $T->finish($T->get_var('output')); $msgData['subject'] = htmlspecialchars($subject); $msgData['htmlmessage'] = $retval; $msgData['textmessage'] = sprintf($LANG_MG03['text_body_email'], $fromname, $alternate_link); $msgData['from']['email'] = $fromemail; $msgData['from']['name'] = $fromname; $msgData['to'][] = array('email' => $toemail, 'name' => $toname); if ($ccself) { $msgData['to'][] = array('email' => $fromemail, 'name' => $fromname); } foreach ($_MG_CONF['validExtensions'] as $tnext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $tnext)) { $msgData['embeddedImage'][] = array('file' => $_MG_CONF['path_mediaobjects'] . 'disp/' . $M['media_filename'][0] . '/' . $M['media_filename'] . $tnext, 'name' => "pc-image", 'filename' => $M['media_original_filename'], 'encoding' => 'base64', 'mime' => $M['mime_type']); } } $msgData['embeddedImage'][] = array('file' => MG_getImageFilePath('stamp.gif'), 'name' => "stamp", 'filename' => 'stamp.gif', 'encoding' => 'base64', 'mime' => 'image/gif'); COM_emailNotification($msgData); $msgNo = 8; // update the sent post card database...Or maybe just log it in an error log? $logentry = $fromname . " sent a postcard to " . $toname . " (" . $toemail . ") using media id " . $mid; MG_postcardLog($logentry); COM_updateSpeedlimit('mgpostcard'); header("Location: " . $_MG_CONF['site_url'] . '/media.php?msg=' . $msgNo . '&s=' . $mid); exit; }
function MG_batchProcess($album_id, $action, $actionURL = '') { global $_CONF, $MG_albums, $_TABLES, $_MG_CONF, $LANG_MG01, $_POST, $_SERVER; $numItems = count($_POST['sel']); switch ($action) { case 'rrt': require_once $_CONF['path'] . 'plugins/mediagallery/include/rotate.php'; if ($numItems > 5) { $session_description = sprintf($LANG_MG01['batch_rotate_images'], $MG_albums[$album_id]->title); $session_id = MG_beginSession('rotate', $_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&mode=media', $session_description); for ($i = 0; $i < $numItems; $i++) { DB_query("INSERT INTO {$_TABLES['mg_session_items']} (session_id,mid,aid,data) VALUES('{$session_id}','" . DB_escapeString($_POST['sel'][$i]) . "'," . intval($album_id) . ",'right')"); } $display = MG_siteHeader(); $display .= MG_continueSession($session_id, 0, 30); $display .= MG_siteFooter(); echo $display; exit; } else { for ($i = 0; $i < $numItems; $i++) { MG_rotateMedia($album_id, COM_applyFilter($_POST['sel'][$i]), 'right', -1); } echo COM_refresh($_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&mode=media'); exit; } break; case 'rlt': require_once $_CONF['path'] . 'plugins/mediagallery/include/rotate.php'; if ($numItems > 5) { $session_description = sprintf($LANG_MG01['batch_rotate_images'], $MG_albums[$album_id]->title); $session_id = MG_beginSession('rotate', $_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&mode=media', $session_description); for ($i = 0; $i < $numItems; $i++) { DB_query("INSERT INTO {$_TABLES['mg_session_items']} (session_id,mid,aid,data) VALUES('{$session_id}','" . DB_escapeString($_POST['sel'][$i]) . "'," . intval($album_id) . ",'left')"); } $display = MG_siteHeader(); $display .= MG_continueSession($session_id, 0, 30); $display .= MG_siteFooter(); echo $display; exit; } else { for ($i = 0; $i < $numItems; $i++) { MG_rotateMedia($album_id, COM_applyFilter($_POST['sel'][$i]), 'left', -1); } echo COM_refresh($_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&mode=media'); exit; } break; case 'watermark': if ($MG_albums[$album_id]->wm_id != 0) { $session_description = sprintf($LANG_MG01['batch_watermark_images'], $MG_albums[$album_id]->title); $session_id = MG_beginSession('watermark', $_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&mode=media', $session_description); for ($i = 0; $i < $numItems; $i++) { // setup our new batch processor - fingers crossed... DB_query("INSERT INTO {$_TABLES['mg_session_items']} (session_id,mid,aid,data) VALUES('{$session_id}','" . DB_escapeString($_POST['sel'][$i]) . "'," . intval($album_id) . ",'')"); } $display = MG_siteHeader(); $display .= MG_continueSession($session_id, 0, 30); $display .= MG_siteFooter(); echo $display; exit; } break; } echo COM_refresh($actionURL . '&t=' . time()); exit; }
function MG_ftpProcess($album_id) { global $MG_albums, $_FILES, $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG02, $LANG_MG03, $_POST; $session_description = $LANG_MG01['ftp_media']; $origin = $album_id == 0 ? '/index.php' : '/album.php?aid=' . $album_id; $session_id = MG_beginSession('ftpimport2', $_MG_CONF['site_url'] . $origin, $session_description); $purgefiles = COM_applyFilter($_POST['purgefiles'], true); $count = count($_POST['pic']); if ($count < 1) { if ($album_id == 0) { echo COM_refresh($_MG_CONF['site_url'] . '/index.php'); } else { echo COM_refresh($_MG_CONF['site_url'] . '/album.php?aid=' . $album_id); } exit; } foreach ($_POST['pic'] as $pic_id) { $album_lb_id = COM_applyFilter($_POST['album_lb_id_' . $pic_id]); $aid = COM_applyFilter($_POST[$album_lb_id], true); $filename = COM_applyFilter($_POST['picfile_' . $pic_id]); // full path and name $file = basename($filename); // basefilename if (is_dir($filename)) { $mid = 1; } else { $mid = 0; } DB_query("INSERT INTO {$_TABLES['mg_session_items']} (session_id,mid,aid,data,data2,data3,status)\n VALUES('{$session_id}','{$mid}',{$aid},'" . DB_escapeString($filename) . "','" . $purgefiles . "','" . DB_escapeString($file) . "',0)"); } $display = MG_siteHeader(); $display .= MG_continueSession($session_id, 0, 30); $display .= MG_siteFooter(); echo $display; exit; }
function MG_albumRebuildThumbs($aid, $actionURL) { global $MG_albums, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG01; if ($MG_albums[$aid]->access != 3) { echo COM_refresh($_MG_CONF['site_url'] . '/album.php?aid=' . $aid); } require_once $_CONF['path'] . 'plugins/mediagallery/include/lib-upload.php'; $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) . " AND m.media_type=0"; $result = DB_query($sql); $nRows = DB_numRows($result); $session_description = sprintf($LANG_MG01['batch_rebuild_thumbs'], $MG_albums[$aid]->title); $session_id = MG_beginSession('rebuildthumb', $_MG_CONF['site_url'] . '/album.php?aid=' . $aid, $session_description); for ($x = 0; $x < $nRows; $x++) { $row = DB_fetchArray($result); $srcImage = ''; $imageDisplay = ''; if ($_MG_CONF['discard_original'] == 1) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) { $srcImage = $_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; $imageDisplay = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; $row['mime_type'] = ''; break; } } } else { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) { $srcImage = $_MG_CONF['path_mediaobjects'] . 'orig/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; $imageDisplay = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; break; } } } if ($srcImage == '' || !file_exists($srcImage)) { foreach ($_MG_CONF['validExtensions'] as $ext) { if (file_exists($_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext)) { $srcImage = $_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; $imageDisplay = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . $ext; $row['mime_type'] = ''; $row['media_mime_ext'] = $ext; break; } } if (!file_exists($srcImage)) { continue; } } $mimeExt = $row['media_mime_ext']; $mimeType = $row['mime_type']; DB_query("INSERT INTO {$_TABLES['mg_session_items']} (session_id,mid,aid,data,data2,data3,status) VALUES('{$session_id}','{$mimeType}',{$aid},'" . $srcImage . "','" . $imageDisplay . "','" . $mimeExt . "',0)"); } $display = MG_siteHeader('album_rebuild_thumbs'); $display .= MG_continueSession($session_id, 0, 30); $display .= MG_siteFooter(); echo $display; exit; }
function MG_processDir($dir, $album_id, $purgefiles, $recurse) { global $MG_albums, $_FILES, $_CONF, $_MG_CONF, $LANG_MG02, $_POST; if (!@is_dir($dir)) { $display = MG_siteHeader(); $display .= MG_errorHandler($LANG_MG02['invalid_directory']); $display .= MG_siteFooter(); echo $display; exit; } if (!($dh = @opendir($dir))) { $display = MG_siteHeader(); $display .= MG_errorHandler($LANG_MG02['directory_error']); $display .= MG_siteFooter(); echo $display; exit; } while (($file = readdir($dh)) != false) { if ($file == '..' || $file == '.') { continue; } set_time_limit(60); $filename = $file; if (PHP_OS == "WINNT") { $filetmp = $dir . "\\" . $file; } else { $filetmp = $dir . '/' . $file; } if (is_dir($filetmp)) { if ($recurse) { $statusMsg .= MG_processDir($filetmp, $album_id, $purgefiles, $recurse); } } else { $filename = basename($file); $file_extension = strtolower(substr(strrchr($filename, "."), 1)); if ($MG_albums[$album_id]->max_filesize != 0 && filesize($filetmp) > $MG_albums[$album_id]->max_filesize) { COM_errorLog("MG Upload: File " . $file . " exceeds maximum filesize for this album."); $statusMsg = sprintf($LANG_MG02['upload_exceeds_max_filesize'] . '<br/>', $file); continue; } //This will set the Content-Type to the appropriate setting for the file switch ($file_extension) { case "exe": $filetype = "application/octet-stream"; break; case "zip": $filetype = "application/zip"; break; case "mp3": $filetype = "audio/mpeg"; break; case "mpg": $filetype = "video/mpeg"; break; case "avi": $filetype = "video/x-msvideo"; break; default: $filetype = "application/force-download"; } list($rc, $msg) = MG_getFile($filetmp, $file, $album_id, '', '', 0, $purgefiles, $filetype, 0, '', '', 0, 0, 0); $statusMsg .= $file . " " . $msg . "<br/>"; } } closedir($dh); return $statusMsg; }