function MG_selectUsers($page) { global $glversion, $_CONF, $_MG_CONF, $_TABLES, $_USER, $LANG_MG00, $LANG_MG01; $retval = ''; $T = new Template($_MG_CONF['template_path']); $T->set_file('admin', 'createmembers.thtml'); $T->set_var(array('site_admin_url' => $_CONF['site_admin_url'], 'site_url' => $_CONF['site_url'], 'xhtml' => XHTML)); $T->set_block('admin', 'UserRow', 'uRow'); $start = $page * 50; $end = 50; $sql = "SELECT COUNT(gl.uid) AS count " . "FROM {$_TABLES['users']} AS gl " . "LEFT JOIN {$_TABLES['mg_userprefs']} AS mg ON gl.uid=mg.uid " . "WHERE gl.status = 3 AND gl.uid > 2 AND (mg.member_gallery IS NULL OR mg.member_gallery < 1)"; $result = DB_query($sql); list($total_records) = DB_fetchArray($result); $sql = "SELECT gl.uid, gl.status, gl.username, gl.fullname, mg.member_gallery " . "FROM {$_TABLES['users']} AS gl " . "LEFT JOIN {$_TABLES['mg_userprefs']} AS mg ON gl.uid=mg.uid " . "WHERE gl.status = 3 AND gl.uid > 2 AND (mg.member_gallery IS NULL OR mg.member_gallery < 1) " . "ORDER BY gl.username ASC LIMIT {$start},{$end}"; $result = DB_query($sql); while ($row = DB_fetchArray($result)) { if ($glversion[1] < 4) { $row['status'] = 3; } $uid = $row['uid']; $remote = SEC_inGroup("Remote Users", $uid) ? '(r)' : ''; $username = $row['username']; $member_gallery = $row['member_gallery']; $T->set_var(array('uid' => $uid, 'username' => $username . ' ' . $remote . ' - ' . $row['fullname'], 'select' => '<input type="checkbox" name="user[]" value="' . $uid . '"' . XHTML . '>')); $T->parse('uRow', 'UserRow', true); } $T->set_var(array('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_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_reset' => $LANG_MG01['reset'], 's_form_action' => $_MG_CONF['admin_url'] . 'createmembers.php', 'pagenav' => COM_printPageNavigation($_MG_CONF['admin_url'] . 'createmembers.php', $page + 1, ceil($total_records / 50)))); $retval .= $T->finish($T->parse('output', 'admin')); return $retval; }
$articleCounter++; } // get plugin center blocks that follow articles $pageBody .= PLG_showCenterblock(CENTERBLOCK_BOTTOM, $page, $topic); // bottom blocks // Print Google-like paging navigation if (!isset($_CONF['hide_main_page_navigation']) || $_CONF['hide_main_page_navigation'] == 0) { if (empty($topic)) { $base_url = $_CONF['site_url'] . '/index.php'; if ($newstories) { $base_url .= '?display=new'; } } else { $base_url = $_CONF['site_url'] . '/index.php?topic=' . $topic; } $pageBody .= '<div class="aligncenter">' . COM_printPageNavigation($base_url, $page, $num_pages) . '</div>'; } } else { // no stories to display $cbDisplay = ''; $cbDisplay .= PLG_showCenterblock(CENTERBLOCK_AFTER_FEATURED, $page, $topic); $cbDisplay .= PLG_showCenterblock(CENTERBLOCK_BOTTOM, $page, $topic); // bottom blocks if ((!isset($_CONF['hide_no_news_msg']) || $_CONF['hide_no_news_msg'] == 0) && $cbDisplay == '') { // If there's still nothing to display, show any default centerblocks. $cbDisplay .= PLG_showCenterblock(CENTERBLOCK_NONEWS, $page, $topic); if ($cbDisplay == '') { // If there's *still* nothing to show, show the stock message $eMsg = $LANG05[2]; if (!empty($topic)) { $topicname = DB_getItem($_TABLES['topics'], 'topic', "tid = '" . DB_escapeString($topic) . "'");
$p->set_var('LANG_deleteafter', $LANG_GF01['DELETEAFTER']); $p->set_var('LANG_all', $LANG_GF01['ALL']); $p->set_var('LANG_topic', $LANG_GF01['TOPIC']); $p->set_var('LANG_title', $LANG_GF01['TITLE']); $p->set_var('LANG_date', $LANG_GF01['DATE']); $p->set_var('LANG_comments', $LANG_GF01['COMMENTS']); if ($numrows > 0) { $base_url = $_CONF['site_admin_url'] . '/plugins/forum/migrate.php?seltopic=' . $curtopic; for ($i = 0; $i < $numrows; $i++) { list($topic, $sid, $story, $date, $comments) = DB_fetchArray($result); $p->set_var('sid', $sid); $p->set_var('topic', $topic); if (isset($_POST['seltopic']) && $_POST['seltopic'] == "submissions") { $p->set_var('story_link', $_CONF['site_admin_url'] . '/story.php?moderate=x&sid=' . $sid); } else { $p->set_var('story_link', $_CONF['site_url'] . '/article.php?story=' . $sid); } $p->set_var('story_title', $story); $p->set_var('date', $date); $p->set_var('num_comments', $comments); $p->set_var('cssid', $i % 2 + 1); $p->parse('story_record', 'records', true); } $p->set_var('page_navigation', COM_printPageNavigation($base_url, $page, $numpages)); } $p->parse('output', 'page'); $display .= $p->finish($p->get_var('output')); $display .= COM_endBlock(); $display .= FF_adminfooter(); $display .= FF_siteFooter(); echo $display;
/** * Create the banner list depending on the category given * * @param array $message message(s) to display * @return string the banner page * */ function banner_list($message) { global $_CONF, $_TABLES, $_BAN_CONF, $LANG_BANNER_ADMIN, $LANG_BANNER, $LANG_BANNER_STATS; $cid = $_BAN_CONF['root']; $display = ''; if (isset($_GET['category'])) { $cid = strip_tags(COM_stripslashes($_GET['category'])); } elseif (isset($_POST['category'])) { $cid = strip_tags(COM_stripslashes($_POST['category'])); } $cat = addslashes($cid); $page = 0; if (isset($_GET['page'])) { $page = COM_applyFilter($_GET['page'], true); } if ($page == 0) { $page = 1; } if (empty($cid)) { if ($page > 1) { $page_title = sprintf($LANG_BANNER[114] . ' (%d)', $page); } else { $page_title = $LANG_BANNER[114]; } } else { if ($cid == $_BAN_CONF['root']) { $category = $LANG_BANNER['root']; } else { $category = DB_getItem($_TABLES['bannercategories'], 'category', "cid = '{$cat}'"); } if ($page > 1) { $page_title = sprintf($LANG_BANNER[114] . ': %s (%d)', $category, $page); } else { $page_title = sprintf($LANG_BANNER[114] . ': %s', $category); } } // Check has access to this category if ($cid != $_BAN_CONF['root']) { $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['bannercategories']} WHERE cid='{$cat}'"); $A = DB_fetchArray($result); if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) < 2) { $display .= COM_siteHeader('menu', $page_title); $display .= COM_showMessage(5, 'banner'); $display .= COM_siteFooter(); echo $display; exit; } } $display .= COM_siteHeader('menu', $page_title); if (is_array($message) && !empty($message[0])) { $display .= COM_startBlock($message[0], '', COM_getBlockTemplate('_msg_block', 'header')); $display .= $message[1]; $display .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); } else { if (isset($_REQUEST['msg'])) { $msg = COM_applyFilter($_REQUEST['msg'], true); if ($msg > 0) { $display .= COM_showMessage($msg, 'banner'); } } } $bannerlist = new Template($_CONF['path'] . 'plugins/banner/templates/'); $bannerlist->set_file(array('bannerlist' => 'banner.thtml', 'catbanner' => 'categorybanner.thtml', 'banner' => 'bannerdetails.thtml', 'catnav' => 'categorynavigation.thtml', 'catrow' => 'categoryrow.thtml', 'catcol' => 'categorycol.thtml', 'actcol' => 'categoryactivecol.thtml', 'pagenav' => 'pagenavigation.thtml', 'catdrop' => 'categorydropdown.thtml')); $bannerlist->set_var('xhtml', XHTML); $bannerlist->set_var('blockheader', COM_startBlock($LANG_BANNER[114])); $bannerlist->set_var('layout_url', $_CONF['layout_url']); if ($_BAN_CONF['bannercols'] > 0) { // Create breadcrumb trail $bannerlist->set_var('breadcrumbs', banner_breadcrumbs($_BAN_CONF['root'], $cid)); // Set dropdown for category jump $bannerlist->set_var('lang_go', $LANG_BANNER[124]); $bannerlist->set_var('banner_dropdown', banner_select_box(2, $cid)); // Show categories $sql = "SELECT cid,pid,category,description FROM {$_TABLES['bannercategories']} WHERE pid='{$cat}'"; $sql .= COM_getLangSQL('cid', 'AND'); $sql .= COM_getPermSQL('AND') . " ORDER BY category"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $bannerlist->set_var('lang_categories', $LANG_BANNER_ADMIN[14]); for ($i = 1; $i <= $nrows; $i++) { $C = DB_fetchArray($result); // Get number of child banner user can see in this category $ccid = addslashes($C['cid']); $result1 = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['banner']} WHERE cid='{$ccid}'" . COM_getPermSQL('AND')); $D = DB_fetchArray($result1); // Get number of child categories user can see in this category $result2 = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['bannercategories']} WHERE pid='{$ccid}'" . COM_getPermSQL('AND')); $E = DB_fetchArray($result2); // Format numbers for display $display_count = ''; // don't show zeroes if ($E['count'] > 0) { $display_count = COM_numberFormat($E['count']); } if ($E['count'] > 0 && $D['count'] > 0) { $display_count .= ', '; } if ($D['count'] > 0) { $display_count .= COM_numberFormat($D['count']); } // add brackets if child items exist if ($display_count != '') { $display_count = '(' . $display_count . ')'; } $bannerlist->set_var('category_name', $C['category']); if ($_BAN_CONF['show_category_descriptions']) { $bannerlist->set_var('category_description', $C['description']); } else { $bannerlist->set_var('category_description', ''); } $bannerlist->set_var('category_link', $_CONF['site_url'] . '/banner/index.php?category=' . urlencode($C['cid'])); $bannerlist->set_var('category_count', $display_count); $bannerlist->set_var('width', floor(100 / $_BAN_CONF['bannercols'])); if (!empty($cid) && $cid == $C['cid']) { $bannerlist->parse('category_col', 'actcol', true); } else { $bannerlist->parse('category_col', 'catcol', true); } if ($i % $_BAN_CONF['bannercols'] == 0) { $bannerlist->parse('category_row', 'catrow', true); $bannerlist->set_var('category_col', ''); } } if ($nrows % $_BAN_CONF['bannercols'] != 0) { $bannerlist->parse('category_row', 'catrow', true); } $bannerlist->parse('category_navigation', 'catnav', true); } else { $bannerlist->set_var('category_navigation', ''); } } else { $bannerlist->set_var('category_navigation', ''); } if ($_BAN_CONF['bannercols'] == 0) { $bannerlist->set_var('category_dropdown', ''); } else { $bannerlist->parse('category_dropdown', 'catdrop', true); } $bannerlist->set_var('site_url', $_CONF['site_url']); $bannerlist->set_var('cid', $cid); $bannerlist->set_var('cid_plain', $cid); $bannerlist->set_var('cid_encoded', urlencode($cid)); $bannerlist->set_var('lang_addabanner', $LANG_BANNER[116]); // Build SQL for banner $sql = 'SELECT bid,cid,url,description,title,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon'; $from_where = " FROM {$_TABLES['banner']}"; if ($_BAN_CONF['bannercols'] > 0) { if (!empty($cid)) { $from_where .= " WHERE cid='" . addslashes($cid) . "'"; } else { $from_where .= " WHERE cid=''"; } $from_where .= ' AND (publishstart IS NULL OR publishstart < NOW()) and (publishend IS NULL OR publishend > NOW())'; $from_where .= COM_getPermSQL('AND'); } else { $from_where .= COM_getPermSQL(); } $order = ' ORDER BY cid ASC,title'; $limit = ''; if ($_BAN_CONF['bannerperpage'] > 0) { if ($page < 1) { $start = 0; } else { $start = ($page - 1) * $_BAN_CONF['bannerperpage']; } $limit = ' LIMIT ' . $start . ',' . $_BAN_CONF['bannerperpage']; } $result = DB_query($sql . $from_where . $order . $limit); $nrows = DB_numRows($result); if ($nrows == 0) { if ($cid == $_BAN_CONF['root'] && $page <= 1 && $_BAN_CONF['show_top10']) { $result = DB_query("SELECT bid,url,title,description,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['banner']} WHERE (hits > 0) AND (publishstart IS NULL OR publishstart < NOW()) and (publishend IS NULL OR publishend > NOW())" . COM_getPermSQL('AND') . " ORDER BY hits DESC LIMIT 10"); $nrows = DB_numRows($result); if ($nrows > 0) { $bannerlist->set_var('banner_details', ''); $bannerlist->set_var('banner_category', $LANG_BANNER_STATS['stats_headline']); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); prepare_banner_item($A, $bannerlist); $bannerlist->parse('banner_details', 'banner', true); } $bannerlist->parse('category_banner', 'catbanner', true); } } $bannerlist->set_var('page_navigation', ''); } else { $currentcid = ''; for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); if (strcasecmp($A['cid'], $currentcid) != 0) { // print the category and banner if ($i > 0) { $bannerlist->parse('category_banner', 'catbanner', true); $bannerlist->set_var('banner_details', ''); } $currentcid = $A['cid']; $currentcategory = DB_getItem($_TABLES['bannercategories'], 'category', "cid = '" . addslashes($currentcid) . "'"); $bannerlist->set_var('banner_category', $currentcategory); } prepare_banner_item($A, $bannerlist); $bannerlist->parse('banner_details', 'banner', true); } $bannerlist->parse('category_banner', 'catbanner', true); $result = DB_query('SELECT COUNT(*) AS count ' . $from_where); list($numbanner) = DB_fetchArray($result); $pages = 0; if ($_BAN_CONF['bannerperpage'] > 0) { $pages = (int) ($numbanner / $_BAN_CONF['bannerperpage']); if ($numbanner % $_BAN_CONF['bannerperpage'] > 0) { $pages++; } } if ($pages > 0) { if ($_BAN_CONF['bannercols'] > 0 && !empty($currentcid)) { $catbanner = '?category=' . urlencode($currentcid); } else { $catbanner = ''; } $bannerlist->set_var('page_navigation', COM_printPageNavigation($_CONF['site_url'] . '/banner/index.php' . $catbanner, $page, $pages)); } else { $bannerlist->set_var('page_navigation', ''); } } $bannerlist->set_var('blockfooter', COM_endBlock()); $bannerlist->parse('output', 'bannerlist'); $display .= $bannerlist->finish($bannerlist->get_var('output')); return $display; }
$comments = 0; $linksf = 0; $days = Date('t', mktime(0, 0, 0, $month, 1, $year)); // special case for this month - don't show days in the future $today = getdate(); if ($today['year'] == $year and $today['mon'] == $month) { $days = min($days, $today['mday']); } $num_pages = ceil($days / $_GUS_days); if (!isset($_GET['page']) or empty($_GET['page'])) { $curpage = 1; } else { $curpage = (int) $_GET['page']; } $base_url = GUS_create_url('page'); $navlinks = COM_printPageNavigation($base_url, $curpage, $num_pages); $temp_table = GUS_create_temp_userstats_table($year, $month); for ($day = 1; $day <= $days; $day++) { if ($day > ($curpage - 1) * $_GUS_days and $day <= $curpage * $_GUS_days) { $day_of_week = date('l', mktime(0, 0, 0, $month, $day, $year)); $date_formatted = date('l d', mktime(0, 0, 0, $month, $day, $year)); $T->set_var('day_display', $date_formatted); $T->set_var(array('day' => $day, 'mon' => $month, 'year' => $year)); if ($day % 2) { $T->set_var('rowclass', 'row1'); } else { $T->set_var('rowclass', 'row2'); } $result = DB_query("SELECT COUNT( DISTINCT ip ) AS num_anon FROM {$temp_table['name']} WHERE uid = '1' AND DAYOFMONTH( date ) = {$day}"); $row = DB_fetchArray($result, FALSE); $anon += $row['num_anon'];
/** * List logged requests * * @param int $page page number * @return string HTML for list of entries * */ function _bb_listEntries($page = 1, $msg = '') { global $_CONF, $_USER, $_TABLES, $LANG_BAD_BEHAVIOR, $LANG_BB2_RESPONSE, $LANG_ADMIN; $retval = ''; if ($page < 1) { $page = 1; } $filter = 'all'; if (isset($_REQUEST['filter'])) { $filter = COM_applyFilter($_REQUEST['filter']); } $where = ''; if ($filter != 'all') { $where = ' WHERE ' . WP_BB_LOG . '.key="' . DB_escapeString($filter) . '"'; } $start = ($page - 1) * 50; if ($filter != 'all') { $entries = DB_count(WP_BB_LOG, WP_BB_LOG . '.key', DB_escapeString($filter)); } else { $entries = DB_count(WP_BB_LOG); } if ($start > $entries) { $start = 1; $page = 1; } $donate = $LANG_BAD_BEHAVIOR['description']; if (DB_getItem($_TABLES['vars'], 'value', "name = 'bad_behavior2.donate'") == 1) { $donate .= '<p>' . $LANG_BAD_BEHAVIOR['donate_msg'] . '</p>' . LB; } // writing the menu on top $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/plugins/bad_behavior2/ban.php', 'text' => 'List Banned IPs'), array('url' => $_CONF['site_admin_url'] . '/plugins/bad_behavior2/ban.php?mode=add', 'text' => 'Ban IPs'), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home'])); $retval .= COM_startBlock($LANG_BAD_BEHAVIOR['plugin_display_name'] . ' - ' . $LANG_BAD_BEHAVIOR['block_title_list'], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= ADMIN_createMenu($menu_arr, $donate, $_CONF['site_url'] . '/bad_behavior2/images/bad_behavior2.png'); $retval .= '<br />'; if (!empty($msg)) { $retval .= COM_showMessage($msg, 'bad_behavior2'); } $templates = new Template($_CONF['path'] . 'plugins/' . BAD_BEHAVIOR_PLUGIN . '/templates'); $templates->set_file('list', 'log.thtml'); $templates->set_var(array('lang_ip' => $LANG_BAD_BEHAVIOR['row_ip'], 'lang_user_agent' => $LANG_BAD_BEHAVIOR['row_user_agent'], 'lang_referer' => $LANG_BAD_BEHAVIOR['row_referer'], 'lang_reason' => $LANG_BAD_BEHAVIOR['row_reason'], 'lang_response' => $LANG_BAD_BEHAVIOR['row_response'], 'lang_method' => $LANG_BAD_BEHAVIOR['row_method'], 'lang_protocol' => $LANG_BAD_BEHAVIOR['row_protocol'], 'lang_date' => $LANG_BAD_BEHAVIOR['row_date'], 'lang_search' => $LANG_BAD_BEHAVIOR['search'], 'lang_ip_date' => $LANG_BAD_BEHAVIOR['ip_date'], 'lang_headers' => $LANG_BAD_BEHAVIOR['headers'], 'lang_filter_select' => $LANG_BAD_BEHAVIOR['filter'], 'lang_go' => $LANG_BAD_BEHAVIOR['go'])); $filter_select = '<option value="all"'; if ($filter == '') { $filter_select .= ' selected="selected" '; } $filter_select .= '>' . $LANG_BAD_BEHAVIOR['no_filter'] . '</option>'; foreach ($LANG_BB2_RESPONSE as $code => $text) { $filter_select .= '<option value="' . $code . '"'; if ($filter == $code) { $filter_select .= ' selected="selected" '; } $filter_select .= '>' . $text . '</option>'; } $templates->set_var('filter_select', $filter_select); $result = DB_query("SELECT id,ip,date,request_method,request_uri,server_protocol,http_headers,user_agent,request_entity,`key` FROM " . WP_BB_LOG . " " . $where . " ORDER BY date DESC LIMIT {$start},50"); $num = DB_numRows($result); $templates->set_block('list', 'logrow', 'lrow'); for ($i = 0; $i < $num; $i++) { $A = DB_fetchArray($result); $lcount = 50 * ($page - 1) + $i + 1; foreach ($A as $key => $val) { $A[$key] = htmlspecialchars($val, ENT_QUOTES, COM_getEncodingt()); } $dt = new Date($A['date'], $_USER['tzid']); $headers = str_replace("\n", "<br/>\n", $A['http_headers']); $headers = str_replace("User-Agent:", "<strong>User-Agent:</strong>", $headers); $headers = str_replace("Host:", "<strong>Host:</strong>", $headers); $headers = str_replace("POST ", "<strong>POST</strong> ", $headers); $headers = str_replace("GET ", "<strong>GET</strong> ", $headers); $headers = str_replace("Accept-Language:", "<strong>Accept-Language:</strong> ", $headers); $headers = str_replace("Accept-Encoding:", "<strong>Accept-Encoding:</strong> ", $headers); $headers = str_replace("Accept-Charset:", "<strong>Accept-Charset:</strong> ", $headers); $headers = str_replace("X-Forwarded-For:", "<strong>X-Forwarded-For:</strong> ", $headers); $headers = str_replace("Cookie:", "<strong>Cookie:</strong> ", $headers); $headers = str_replace("Via:", "<strong>Via:</strong> ", $headers); $headers = str_replace("Connection:", "<strong>Connection:</strong>", $headers); $headers = str_replace("Accept:", "<strong>Accept:</strong>", $headers); $headers = str_replace("Cache-Control:", "<strong>Cache-Control:</strong>", $headers); $headers = str_replace("Referer:", "<strong>Referer:</strong>", $headers); $headers = str_replace("Pragma:", "<strong>Pragma:</strong>", $headers); $headers = str_replace("Proxy-", "<strong>Proxy-</strong>", $headers); $headers = str_replace("Cf-Connecting-Ip", "<strong>Cf-Connecting-Ip</strong>", $headers); $headers = str_replace("Cf-Ipcountry", "<strong>Cf-Ipcountry</strong>", $headers); $headers = str_replace("X-Forwarded-Proto", "<strong>X-Forwarded-Proto</strong>", $headers); $headers = str_replace("Cf-Visitor", "<strong>Cf-Visitor</strong>", $headers); $headers = str_replace("X-Http-Proto", "<strong>X-Http-Proto</strong>", $headers); $headers = str_replace("X-Real-Ip", "<strong>X-Real-Ip</strong>", $headers); $headers = str_replace("Content-Length", "<strong>Content-Length</strong>", $headers); $headers = str_replace("Content-Type", "<strong>Content-Type</strong>", $headers); $headers = str_replace("Te:", "<strong>Te:</strong>", $headers); $headers = str_replace("Expect:", "<strong>Expect:</strong>", $headers); $headers = str_replace("Dnt:", "<strong>Dnt:</strong>", $headers); $entity = str_replace("\n", "<br/>\n", $A["request_entity"]); $templates->set_var(array('row_num' => $lcount, 'cssid' => $i % 2 + 1, 'id' => $A['id'], 'ip' => $A['ip'], 'request_method' => $A['request_method'], 'http_host' => $A['request_uri'], 'server_protocol' => $A['server_protocol'], 'http_referer' => $headers, 'reason' => $LANG_BB2_RESPONSE[$A['key']], 'http_user_agent' => $A['user_agent'], 'http_response' => $entity, 'date_and_time' => $dt->toRFC822(true))); $url = $_CONF['site_admin_url'] . '/plugins/' . BAD_BEHAVIOR_PLUGIN . '/index.php?mode=view&id=' . $A['id']; if ($page > 1) { $url .= '&page=' . $page; } $templates->set_var('start_headers_anchortag', '<a href="' . $url . '" title="' . $LANG_BAD_BEHAVIOR['title_show_headers'] . '">'); $templates->set_var('end_headers_anchortag', '</a>'); if (!empty($_CONF['ip_lookup'])) { $iplookup = str_replace('*', $A['ip'], $_CONF['ip_lookup']); $templates->set_var('start_ip_lookup_anchortag', '<a href="' . $iplookup . '" title="' . $LANG_BAD_BEHAVIOR['title_lookup_ip'] . '" target="_new">'); $templates->set_var('end_ip_lookup_anchortag', '</a>'); } else { $templates->set_var('start_ip_lookup_anchortag', ''); $templates->set_var('end_ip_lookup_anchortag', ''); } $templates->parse('lrow', 'logrow', true); } if ($entries > 50) { $baseurl = $_CONF['site_admin_url'] . '/plugins/' . BAD_BEHAVIOR_PLUGIN . '/index.php?mode=list&filter=' . $filter; $numpages = ceil($entries / 50); $templates->set_var('google_paging', COM_printPageNavigation($baseurl, $page, $numpages)); } else { $templates->set_var('google_paging', ''); } $templates->parse('output', 'list'); $retval .= $templates->finish($templates->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
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; }
$topiclisting->set_var('subject', $subject); $topiclisting->set_var('fullsubject', $record['subject']); $topiclisting->set_var('gotomsg', $gotomsg); $topiclisting->set_var('displaypageslink', $displaypageslink); $topiclisting->set_var('showuserlink', $showuserlink); $topiclisting->set_var('lastposter', $lastposter); $topiclisting->set_var('LANG_lastpost', $LANG_GF02['msg188']); $topiclisting->set_var('moved', $moved); $topiclisting->set_var('views', $record['views']); $topiclisting->set_var('replies', $record['replies']); $topiclisting->set_var('lastdate', $lastdate); $topiclisting->set_var('lastpostid', $lastreply['id']); $topiclisting->set_var('LANG_BY', $LANG_GF01['BY']); $topiclisting->parse('topic_record', 'topic_record', true); } $topiclisting->set_var('pagenavigation', COM_printPageNavigation($base_url, $page, $numpages)); if (empty($subscribelink)) { $topiclisting->set_var('forummenu_link', ''); } else { $topiclisting->parse('forummenu_link', 'forummenu_link'); } $topiclisting->parse('output', 'topiclisting'); $display .= $topiclisting->finish($topiclisting->get_var('output')); } $title = $LANG_GF01['FORUM']; $forum_id = COM_applyFilter($_REQUEST['forum'], true); if (isset($_REQUEST['forum'])) { $title = stripslashes(DB_getItem($_TABLES['forum_forums'], 'forum_name', "forum_id='{$forum_id}'")); } if (isset($_REQUEST['category'])) { $title = $A['cat_name'];
/** * Generates the HTML code based on the preset style * * @access public * @param array $rows_arr The rows to display in the list * @param string $title The title of the list * @param string $list_top HTML that will appear before the list is printed * @param string $list_bottom HTML that will appear after the list is printed * @param boolean $show_sort True to enable column sorting, false to disable * @param boolean $show_limit True to show page limits, false to hide * @param array $params_arr GET params array * @return string HTML output * */ function getFormattedOutput2($rows_arr, $title, $list_top = '', $list_bottom = '', $show_sort = true, $show_limit = true, $params_arr = null) { global $_CONF, $_IMAGE_TYPE, $LANG_ADMIN, $LANG09; $list_templates = COM_newTemplate($_CONF['path_layout'] . 'lists/'); $list_templates->set_file('list', $this->_style == 'inline' ? 'list_inline.thtml' : 'list_table.thtml'); $blocks = array('field', 'row', 'limit', 'sort', 'direction', 'input_hidden'); foreach ($blocks as $block) { $list_templates->set_block('list', $block); } $list_templates->set_var('lang_submit', $LANG09[73]); $list_templates->set_var('lang_sort', $LANG09[68]); $list_templates->set_var('lang_limit', $LANG09[74]); $list_templates->set_var('page_url', $_CONF['site_url'] . '/search.php'); if ($this->_style == 'table') { $params_arr = array_merge($params_arr, array('order' => $this->_sort_arr['field'], 'direction' => $this->_sort_arr['direction'])); } foreach ($params_arr as $key => $val) { $list_templates->set_var('hidden_name', $key); $list_templates->set_var('hidden_val', $val); $list_templates->parse('page_hidden', 'input_hidden', true); } if (count($rows_arr) == 0) { $list_templates->set_var('show_sort', 'display:none;'); $list_templates->set_var('show_limit', 'display:none;'); $list_templates->set_var('message', $LANG_ADMIN['no_results']); $list_templates->set_var('list_top', $list_top); $list_templates->set_var('list_bottom', $list_bottom); $list_templates->parse('output', 'list'); // No results to show so quickly print a message and exit $retval = ''; if (!empty($title)) { $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header')); } $retval .= $list_templates->finish($list_templates->get_var('output')); if (!empty($title)) { $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } return $retval; } // Draw the page limit select box if ($show_limit) { foreach ($this->_page_limits as $key => $val) { $text = is_numeric($key) ? $val : $key; $selected = $this->_per_page == $val ? ' selected="selected"' : ''; $list_templates->set_var('limit_val', $val); $list_templates->set_var('limit_text', $text); $list_templates->set_var('limit_selected', $selected); $list_templates->parse('page_limit', 'limit', true); } if (empty($text)) { $list_templates->set_var('show_limit', 'display:none;'); } } else { $list_templates->set_var('show_limit', 'display:none;'); } // Create how to display the sort field if ($this->_style == 'table') { $arrow = $this->_sort_arr['direction'] == 'asc' ? 'bararrowdown' : 'bararrowup'; $sort_selected = "{$_CONF['layout_url']}/images/{$arrow}.{$_IMAGE_TYPE}"; $sort_selected = ' ' . COM_createImage($sort_selected, $arrow); $sort_text = ''; } else { $sort_selected = ''; $sort_text = ''; if (!$show_sort) { $list_templates->set_var('show_sort', 'display:none;'); } } // Draw the sorting select box/table headings foreach ($this->_fields as $field) { if ($field['display'] == true && $field['title'] != '') { $text = $sort_text . $field['title']; $href = ''; $selected = ''; if ($this->_style == 'inline' && $show_sort && $field['sort'] != false) { if ($this->_sort_arr['field'] === $field['name']) { $selected = ' selected="selected"'; } // Write field $list_templates->set_var('sort_text', $text); $list_templates->set_var('sort_val', $field['name']); $list_templates->set_var('sort_selected', $selected); $list_templates->parse('page_sort', 'sort', true); } else { if ($this->_style == 'table') { $direction = $this->_sort_arr['direction'] == 'asc' ? 'desc' : 'asc'; $href = $this->_page_url . "results={$this->_per_page}&" . "order={$field['name']}&direction={$direction}"; if ($show_sort && $field['sort'] != false) { $text = "<a href=\"{$href}\">{$text}</a>"; if ($this->_sort_arr['field'] === $field['name']) { $selected = $sort_selected; } } // Write field $list_templates->set_var('sort_text', $text); $list_templates->set_var('sort_href', $href); $list_templates->set_var('sort_val', $field['name']); $list_templates->set_var('sort_selected', $selected); $list_templates->parse('page_sort', 'sort', true); } } } } // Draw the sort direction select box if ($this->_style == 'inline' && $show_sort) { foreach (array('desc', 'asc') as $direction) { $direction_text = $direction == 'asc' ? $LANG09[71] : $LANG09[72]; $list_templates->set_var('direction_text', $direction_text); $list_templates->set_var('direction_val', $direction); $direction_selected = ''; if ($this->_sort_arr['direction'] == $direction) { $direction_selected = ' selected="selected"'; } $list_templates->set_var('direction_selected', $direction_selected); $list_templates->parse('page_direction', 'direction', true); } } $offset = ($this->_page - 1) * $this->_per_page; $list_templates->set_var('show_message', 'display:none;'); // Run through all the results $r = 1; foreach ($rows_arr as $row) { if (is_callable($this->_function)) { $row = call_user_func_array($this->_function, array(false, $row)); } foreach ($this->_fields as $field) { if ($field['display'] == true) { $fieldvalue = ''; if ($field['name'] == LF_ROW_NUMBER) { $fieldvalue = $r + $offset; } else { if (!empty($row[$field['name']])) { $fieldvalue = $row[$field['name']]; } } if ($fieldvalue != 'LF_NULL') { $fieldvalue = sprintf($field['format'], $fieldvalue, $field['title']); // Write field $list_templates->set_var('field_text', $fieldvalue); $list_templates->parse('item_field', 'field', true); } else { // Write an empty field $list_templates->set_var('field_text', ' '); $list_templates->parse('item_field', 'field', true); } } } // Write row $r++; $list_templates->set_var('cssid', $r % 2 + 1); $list_templates->parse('item_row', 'row', true); $list_templates->clear_var('item_field'); } // Print page numbers $page_url = $this->_page_url . 'order=' . $this->_sort_arr['field'] . '&direction=' . $this->_sort_arr['direction'] . '&results=' . $this->_per_page; $num_pages = ceil($this->_total_found / $this->_per_page); if ($num_pages > 1) { $list_templates->set_var('google_paging', COM_printPageNavigation($page_url, $this->_page, $num_pages, 'page=', false, '', '')); } else { $list_templates->set_var('google_paging', ''); } $list_top = sprintf($list_top, $offset + 1, $r + $offset - 1, $this->_total_found); $list_templates->set_var('list_top', $list_top); $list_templates->set_var('list_bottom', $list_bottom); $list_templates->parse('output', 'list'); // Do the actual output $retval = ''; if (!empty($title)) { $retval .= COM_startBlock($title, '', COM_getBlockTemplate('_admin_block', 'header')); } $retval .= $list_templates->finish($list_templates->get_var('output')); if (!empty($title)) { $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } return $retval; }
$order = 'DESC'; } if ($page > 1) { $offset = ($page - 1) * $show; } else { $offset = 0; } $base_url = "{$_CONF['site_url']}/forum/viewtopic.php?showtopic={$showtopic}&mode={$mode}&show={$show}"; $forum_outline_header = COM_newTemplate($CONF_FORUM['path_layout'] . 'forum/layout'); $forum_outline_header->set_file(array('forum_outline_header' => 'forum_outline_header.thtml')); $forum_outline_header->set_var('imgset', $CONF_FORUM['imgset']); $forum_outline_header->parse('output', 'forum_outline_header'); $display .= $forum_outline_header->finish($forum_outline_header->get_var('output')); $pagenavigation = ''; if ($numpages > 1) { $pagenavigation = COM_printPageNavigation($base_url, $page, $numpages); } // Stop timer and print elapsed time //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Start Topic Display Time: $intervalTime"); if ($mode != 'preview') { $topicnavbar = COM_newTemplate($CONF_FORUM['path_layout'] . 'forum/layout'); $topicnavbar->set_file(array('topicnavbar' => 'topic_navbar.thtml', 'subscribe' => 'links/subscribe.thtml', 'print' => 'links/print.thtml', 'prev' => 'links/prevtopic.thtml', 'next' => 'links/nexttopic.thtml', 'new' => 'links/newtopic.thtml', 'reply' => 'links/replytopic.thtml')); $topicnavbar->set_var('layout_url', $CONF_FORUM['layout_url']); if ($topic_pid > 0) { $replytopic_id = $topic_pid; } else { $replytopic_id = $showtopic; } if ($viewtopic['is_readonly'] == 0 or forum_modPermission($viewtopic['forum'], $_USER['uid'], 'mod_edit')) { $newtopiclink = "{$_CONF['site_url']}/forum/createtopic.php?method=newtopic&forum={$forum}";
/** * Create the links list depending on the category given * * @param array $message message(s) to display * @return string the links page * */ function links_list($message) { global $_CONF, $_TABLES, $_LI_CONF, $LANG_LINKS_ADMIN, $LANG_LINKS, $LANG_LINKS_STATS; $cid = $_LI_CONF['root']; $display = ''; if (isset($_GET['category'])) { $cid = strip_tags(COM_stripslashes($_GET['category'])); } elseif (isset($_POST['category'])) { $cid = strip_tags(COM_stripslashes($_POST['category'])); } $cat = DB_escapeString($cid); $page = 0; if (isset($_GET['page'])) { $page = COM_applyFilter($_GET['page'], true); } if ($page == 0) { $page = 1; } if (empty($cid)) { if ($page > 1) { $page_title = sprintf($LANG_LINKS[114] . ' (%d)', $page); } else { $page_title = $LANG_LINKS[114]; } } else { if ($cid == $_LI_CONF['root']) { $category = $LANG_LINKS['root']; } else { $category = DB_getItem($_TABLES['linkcategories'], 'category', "cid = '{$cat}'"); } if ($page > 1) { $page_title = sprintf($LANG_LINKS[114] . ': %s (%d)', $category, $page); } else { $page_title = sprintf($LANG_LINKS[114] . ': %s', $category); } } // Check has access and existent to this category if ($cid != $_LI_CONF['root']) { $result = DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['linkcategories']} WHERE cid='{$cat}'"); $A = DB_fetchArray($result); if (SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) < 2) { $display .= COM_showMessage(5, 'links'); $display = COM_createHTMLDocument($display, array('pagetitle' => $page_title)); COM_output($display); exit; } // check existent if (!isset($A['owner_id'])) { $display .= COM_showMessage(16, 'links'); $display = COM_createHTMLDocument($display, array('pagetitle' => $page_title)); COM_output($display); exit; } } if (is_array($message) && !empty($message[0])) { $display .= COM_showMessageText($message[1], $message[0]); } else { if (isset($_REQUEST['msg'])) { $msg = COM_applyFilter($_REQUEST['msg'], true); if ($msg > 0) { $display .= COM_showMessage($msg, 'links'); } } } $linklist = COM_newTemplate(CTL_plugin_templatePath('links')); $linklist->set_file(array('linklist' => 'links.thtml', 'catlinks' => 'categorylinks.thtml', 'link' => 'linkdetails.thtml', 'catnav' => 'categorynavigation.thtml', 'catrow' => 'categoryrow.thtml', 'catcol' => 'categorycol.thtml', 'actcol' => 'categoryactivecol.thtml', 'pagenav' => 'pagenavigation.thtml', 'catdrop' => 'categorydropdown.thtml')); $linklist->set_var('blockheader', COM_startBlock($LANG_LINKS[114])); if ($_LI_CONF['linkcols'] > 0) { // Create breadcrumb trail $linklist->set_var('breadcrumbs', links_breadcrumbs($_LI_CONF['root'], $cid)); // Set dropdown for category jump $linklist->set_var('lang_go', $LANG_LINKS[124]); $linklist->set_var('link_dropdown', links_select_box(2, $cid)); // Show categories $sql = "SELECT cid,pid,category,description FROM {$_TABLES['linkcategories']} WHERE pid='{$cat}'"; $sql .= COM_getLangSQL('cid', 'AND'); $sql .= COM_getPermSQL('AND') . " ORDER BY category"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { $linklist->set_var('lang_categories', $LANG_LINKS_ADMIN[14]); for ($i = 1; $i <= $nrows; $i++) { $C = DB_fetchArray($result); // Get number of child links user can see in this category $ccid = DB_escapeString($C['cid']); $result1 = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$ccid}'" . COM_getPermSQL('AND')); $D = DB_fetchArray($result1); // Get number of child categories user can see in this category $result2 = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['linkcategories']} WHERE pid='{$ccid}'" . COM_getPermSQL('AND')); $E = DB_fetchArray($result2); // Format numbers for display $display_count = ''; // don't show zeroes if ($E['count'] > 0) { $display_count = COM_numberFormat($E['count']); } if ($E['count'] > 0 && $D['count'] > 0) { $display_count .= ', '; } if ($D['count'] > 0) { $display_count .= COM_numberFormat($D['count']); } // add brackets if child items exist if ($display_count != '') { $display_count = '(' . $display_count . ')'; } $linklist->set_var('category_name', $C['category']); if ($_LI_CONF['show_category_descriptions']) { $linklist->set_var('category_description', PLG_replaceTags($C['description'])); } else { $linklist->set_var('category_description', ''); } $linklist->set_var('category_link', $_CONF['site_url'] . '/links/index.php?category=' . rawurlencode($C['cid'])); $linklist->set_var('category_count', $display_count); $linklist->set_var('width', floor(100 / $_LI_CONF['linkcols'])); if (!empty($cid) && $cid == $C['cid']) { $linklist->parse('category_col', 'actcol', true); } else { $linklist->parse('category_col', 'catcol', true); } if ($i % $_LI_CONF['linkcols'] == 0) { $linklist->parse('category_row', 'catrow', true); $linklist->set_var('category_col', ''); } } if ($nrows % $_LI_CONF['linkcols'] != 0) { $linklist->parse('category_row', 'catrow', true); } $linklist->parse('category_navigation', 'catnav', true); } else { $linklist->set_var('category_navigation', ''); } } else { $linklist->set_var('category_navigation', ''); } if ($_LI_CONF['linkcols'] == 0) { $linklist->set_var('category_dropdown', ''); } else { $linklist->parse('category_dropdown', 'catdrop', true); } $linklist->set_var('cid', $cid); $linklist->set_var('cid_plain', $cid); $linklist->set_var('cid_encoded', rawurlencode($cid)); $linklist->set_var('lang_addalink', $LANG_LINKS[116]); // Build SQL for links $sql = 'SELECT lid,cid,url,description,title,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon'; $from_where = " FROM {$_TABLES['links']}"; if ($_LI_CONF['linkcols'] > 0) { if (!empty($cid)) { $from_where .= " WHERE cid='" . DB_escapeString($cid) . "'"; } else { $from_where .= " WHERE cid=''"; } $from_where .= COM_getPermSQL('AND'); } else { $from_where .= COM_getPermSQL(); } $order = ' ORDER BY cid ASC,title'; $limit = ''; if ($_LI_CONF['linksperpage'] > 0) { if ($page < 1) { $start = 0; } else { $start = ($page - 1) * $_LI_CONF['linksperpage']; } $limit = ' LIMIT ' . $start . ',' . $_LI_CONF['linksperpage']; } $result = DB_query($sql . $from_where . $order . $limit); $nrows = DB_numRows($result); if ($nrows == 0) { if ($cid == $_LI_CONF['root'] && $page <= 1 && $_LI_CONF['show_top10']) { $result = DB_query("SELECT lid,url,title,description,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['links']} WHERE (hits > 0)" . COM_getPermSQL('AND') . LINKS_getCategorySQL('AND') . " ORDER BY hits DESC LIMIT 10"); $nrows = DB_numRows($result); if ($nrows > 0) { $linklist->set_var('link_details', ''); $linklist->set_var('link_category', $LANG_LINKS_STATS['stats_headline']); for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); prepare_link_item($A, $linklist); $linklist->parse('link_details', 'link', true); } $linklist->parse('category_links', 'catlinks', true); } } $linklist->set_var('page_navigation', ''); } else { $currentcid = ''; for ($i = 0; $i < $nrows; $i++) { $A = DB_fetchArray($result); if (strcasecmp($A['cid'], $currentcid) != 0) { // print the category and link if ($i > 0) { $linklist->parse('category_links', 'catlinks', true); $linklist->set_var('link_details', ''); } $currentcid = $A['cid']; $currentcategory = DB_getItem($_TABLES['linkcategories'], 'category', "cid = '" . DB_escapeString($currentcid) . "'"); if ($A['cid'] == $_LI_CONF['root']) { $linklist->set_var('link_category', $LANG_LINKS['root']); } else { $linklist->set_var('link_category', $currentcategory); } } prepare_link_item($A, $linklist); $linklist->parse('link_details', 'link', true); } $linklist->parse('category_links', 'catlinks', true); $result = DB_query('SELECT COUNT(*) AS count ' . $from_where); list($numlinks) = DB_fetchArray($result); $pages = 0; if ($_LI_CONF['linksperpage'] > 0) { $pages = (int) ($numlinks / $_LI_CONF['linksperpage']); if ($numlinks % $_LI_CONF['linksperpage'] > 0) { $pages++; } } if ($pages > 0) { if ($_LI_CONF['linkcols'] > 0 && !empty($currentcid)) { $catlink = '?category=' . rawurlencode($currentcid); } else { $catlink = ''; } $linklist->set_var('page_navigation', COM_printPageNavigation($_CONF['site_url'] . '/links/index.php' . $catlink, $page, $pages)); } else { $linklist->set_var('page_navigation', ''); } } $linklist->set_var('blockfooter', COM_endBlock()); $linklist->parse('output', 'linklist'); $display .= $linklist->finish($linklist->get_var('output')); $display = COM_createHTMLDocument($display, array('pagetitle' => $page_title)); return $display; }
/** * Diaplay the product catalog items. * * @return string HTML for product catalog. */ function PAYPAL_ProductList($cat = 0, $search = '') { global $_TABLES, $_CONF, $_PP_CONF, $LANG_PP, $_USER, $_PLUGINS, $_IMAGE_TYPE, $_GROUPS; USES_paypal_class_product(); if (SEC_hasRights('paypal.admin')) { $isAdmin = true; } else { $isAdmin = false; } $my_groups = implode(',', $_GROUPS); $cat_name = ''; $breadcrumbs = ''; $img_url = ''; $display = ''; if ($cat != 0) { $breadcrumbs = PAYPAL_Breadcrumbs($cat); $cat = (int) $cat; $A = DB_fetchArray(DB_query("SELECT cat_name, image\n FROM {$_TABLES['paypal.categories']}\n WHERE cat_id='{$cat}' " . COM_getPermSQL('AND')), false); if (!empty($A)) { $cat_name = $A['cat_name']; if (!empty($A['image']) && is_file($_CONF['path_html'] . $_PP_CONF['pi_name'] . '/images/categories/' . $A['image'])) { $img_url = PAYPAL_URL . '/images/categories/' . $A['image']; } } } // Display categories if (isset($_PP_CONF['cat_columns']) && $_PP_CONF['cat_columns'] > 0) { $sql = "SELECT cat.cat_id, cat.cat_name, count(prod.id) AS cnt \n FROM {$_TABLES['paypal.categories']} cat\n LEFT JOIN {$_TABLES['paypal.products']} prod\n ON prod.cat_id = cat.cat_id\n WHERE cat.enabled = '1' AND cat.parent_id = '{$cat}' \n AND prod.enabled = '1' " . COM_getPermSQL('AND', 0, 2, 'cat') . " GROUP BY cat.cat_id\n ORDER BY cat.cat_name"; //HAVING cnt > 0 //echo $sql;die; $CT = new Template(PAYPAL_PI_PATH . '/templates'); $CT->set_file(array('table' => 'category_table.thtml', 'row' => 'category_row.thtml', 'category' => 'category.thtml')); $CT->set_var('width', floor(100 / $_PP_CONF['cat_columns'])); if ($breadcrumbs != '') { $CT->set_var('breadcrumbs', $breadcrumbs); } if ($img_url != '') { $CT->set_var('catimg_url', $img_url); } $res = DB_query($sql); $A = array(); while ($C = DB_fetchArray($res, false)) { $A[$C['cat_id']] = array($C['cat_name'], $C['cnt']); } // Now get categories from plugins foreach ($_PLUGINS as $pi_name) { $function = 'USES_' . $pi_name . '_paypal'; if (function_exists($function)) { $function(); $function = 'plugin_paypal_getcategories_' . $pi_name; if (function_exists($function)) { $pi_cats = $function(); foreach ($pi_cats as $catid => $data) { $A[$catid] = $data; } } } } $i = 1; $nrows = count($A); foreach ($A as $category => $info) { $CT->set_var(array('category_name' => $info[0], 'category_link' => PAYPAL_URL . '/index.php?category=' . urlencode($category))); /*if ($category == $cat) { $CT->set_var('curr', 'current'); $cat_name = $info[0]; } else { $CT->set_var('curr', 'other'); }*/ $CT->parse('catrow', 'category', true); if ($i % $_PP_CONF['cat_columns'] == 0) { $CT->parse('categories', 'row', true); $CT->set_var('catrow', ''); } $i++; } if ($nrows % $_PP_CONF['cat_columns'] != 0) { $CT->parse('categories', 'row', true); } $display .= $CT->parse('', 'table'); } /*$sortby_opts = array( 'name' => $LANG_PP['name'], 'price' => $LANG_PP['price'], 'dt_add' => $LANG_PP['dt_add'], ); switch ($_REQUEST['sortby']){ case 'name': case 'price': case 'dt_add': $sortby = $_REQUEST['sortby']; break; default: $sortby = $_PP_CONF['order']; break; } $sortby_options = ''; foreach ($sortby_opts as $value=>$text) { $sel = $value == $sortby ? ' selected="selected"' : ''; $sortby_options .= "<option value=\"$value\" $sel>$text</option>\n"; } $sortdir = $_REQUEST['sortdir'] == 'DESC' ? 'DESC' : 'ASC';*/ $sortby = $_PP_CONF['order']; $sortdir = 'ASC'; // Get products from database. "c.enabled is null" is to allow products // with no category defined $sql = " FROM {$_TABLES['paypal.products']} p\n LEFT JOIN {$_TABLES['paypal.categories']} c\n ON p.cat_id = c.cat_id\n WHERE p.enabled=1 \n AND (\n (c.enabled=1 " . COM_getPermSQL('AND', 0, 2, 'c') . ")\n OR c.enabled IS NULL\n )\n AND (\n p.track_onhand = 0 OR p.onhand > 0 OR p.oversell < 2\n )"; $pagenav_args = array(); // If applicable, limit by category if (!empty($_REQUEST['category'])) { $cat_list = $_REQUEST['category']; $cat_list .= PAYPAL_recurseCats('PAYPAL_callbackCatCommaList', 0, $_REQUEST['category']); if (!empty($cat_list)) { $sql .= " AND c.cat_id IN ({$cat_list})"; } $pagenav_args[] = 'category=' . urlencode($_REQUEST['category']); } else { $cat_list = ''; } // If applicable, limit by search string if (!empty($_REQUEST['search_name'])) { $srch = DB_escapeString($_REQUEST['search_name']); $sql .= " AND (p.name like '%{$srch}%' OR \n p.short_description like '%{$srch}%' OR\n p.description like '%{$srch}%' OR\n p.keywords like '%{$srch}%')"; //if (!$isAdmin) $sql .= " AND p.grp_access IN ($my_groups) "; $pagenav_args[] = 'search_name=' . urlencode($_REQUEST['search_name']); } // If applicable, order by $sql .= " ORDER BY {$sortby} {$sortdir}"; // If applicable, handle pagination of query if (isset($_PP_CONF['prod_per_page']) && $_PP_CONF['prod_per_page'] > 0) { // Count products from database $res = DB_query('SELECT COUNT(*) as cnt ' . $sql); $x = DB_fetchArray($res, false); if (isset($x['cnt'])) { $count = (int) $x['cnt']; } else { $count = 0; } // Make sure page requested is reasonable, if not, fix it if (!isset($_REQUEST['page']) || $_REQUEST['page'] <= 0) { $_REQUEST['page'] = 1; } $page = (int) $_REQUEST['page']; $start_limit = ($page - 1) * $_PP_CONF['prod_per_page']; if ($start_limit > $count) { $page = ceil($count / $_PP_CONF['prod_per_page']); } // Add limit for pagination (if applicable) if ($count > $_PP_CONF['prod_per_page']) { $sql .= " LIMIT {$start_limit}, {$_PP_CONF['prod_per_page']}"; } } // Re-execute query with the limit clause in place $res = DB_query('SELECT DISTINCT p.id ' . $sql); // Create product template $product = new Template(PAYPAL_PI_PATH . '/templates'); $product->set_file(array('start' => 'product_list_start.thtml', 'end' => 'product_list_end.thtml', 'product' => 'product_list_item.thtml', 'download' => 'buttons/btn_download.thtml', 'login_req' => 'buttons/btn_login_req.thtml', 'btn_details' => 'buttons/btn_details.thtml')); if ($nrows == 0 && COM_isAnonUser()) { $product->set_var('anon_and_empty', 'true'); } $product->set_var(array('pi_url' => PAYPAL_URL, 'user_id' => $_USER['uid'], 'currency' => $_PP_CONF['currency'])); if (!empty($cat_name)) { $product->set_var('title', $cat_name); } else { $product->set_var('title', $LANG_PP['blocktitle']); } /*$product->set_var('sortby_options', $sortby_options); if ($sortdir == 'DESC') { $product->set_var('sortdir_desc_sel', ' selected="selected"'); } else { $product->set_var('sortdir_asc_sel', ' selected="selected"'); } $product->set_var('sortby', $sortby); $product->set_var('sortdir', $sortdir);*/ $display .= $product->parse('', 'start'); // Create an empty product object $P = new Product(); if ($_PP_CONF['ena_ratings'] == 1) { $PP_ratedIds = RATING_getRatedIds('paypal'); } // Display each product while ($A = DB_fetchArray($res, false)) { $P->Read($A['id']); if ($_PP_CONF['ena_ratings'] == 1 && $P->rating_enabled == 1) { if (in_array($A['id'], $PP_ratedIds)) { $static = true; $voted = 1; } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) { $static = false; $voted = 0; } else { $static = true; $voted = 0; } $rating_box = RATING_ratingBar('paypal', $A['id'], $P->votes, $P->rating, $voted, 5, $static, 'sm'); $product->set_var('rating_bar', $rating_box); } else { $product->set_var('rating_bar', ''); } $product->set_var(array('id' => $A['id'], 'name' => $P->name, 'short_description' => PLG_replacetags($P->short_description), 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'encrypted' => '', 'item_url' => COM_buildURL(PAYPAL_URL . '/detail.php?id=' . $A['id']), 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'track_onhand' => $P->track_onhand ? 'true' : '', 'qty_onhand' => $P->onhand)); if ($P->price > 0) { //$product->set_var('price', COM_numberFormat($P->price, 2)); $product->set_var('price', $P->currency->Format($P->price)); } else { $product->clear_var('price'); } if ($isAdmin) { $product->set_var('is_admin', 'true'); $product->set_var('pi_admin_url', PAYPAL_ADMIN_URL); $product->set_var('edit_icon', "{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}"); } $pic_filename = DB_getItem($_TABLES['paypal.images'], 'filename', "product_id = '{$A['id']}'"); if ($pic_filename) { $product->set_var('small_pic', PAYPAL_ImageUrl($pic_filename)); } else { $product->set_var('small_pic', ''); } // FIXME: If a user purchased once with no expiration, this query // will not operate correctly /*$time = DB_getItem($_TABLES['paypal.purchases'], 'MAX(UNIX_TIMESTAMP(expiration))', "user_id = {$_USER['uid']} AND product_id ='{$A['id']}'"); */ $product->set_block('product', 'BtnBlock', 'Btn'); if (!$P->hasAttributes()) { // Buttons only show in the list if there are no options to select $buttons = $P->PurchaseLinks(); foreach ($buttons as $name => $html) { $product->set_var('button', $html); $product->parse('Btn', 'BtnBlock', true); } } else { if ($_PP_CONF['ena_cart']) { // If the product has attributes, then the cart must be // enabled to allow purchasing $button = $product->parse('', 'btn_details') . ' '; $product->set_var('button', $button); $product->parse('Btn', 'BtnBlock', true); } } $display .= $product->parse('', 'product'); $product->clear_var('Btn'); } // Get products from plugins. // For now, this hack shows plugins only on the first page, since // they're not included in the page calculation. if ($page == 1 && empty($cat_list)) { // Get the currency class for formatting prices USES_paypal_class_currency(); $Cur = new ppCurrency($_PP_CONF['currency']); $product->clear_var('rating_bar'); // no ratings for plugins (yet) foreach ($_PLUGINS as $pi_name) { $status = LGLIB_invokeService($pi_name, 'getproducts', array(), $plugin_data, $svc_msg); if ($status != PLG_RET_OK || empty($plugin_data)) { continue; } foreach ($plugin_data as $A) { // Reset button values $buttons = ''; $product->set_var(array('id' => $A['id'], 'name' => $A['name'], 'short_description' => $A['short_description'], 'display' => '; display: none', 'small_pic' => '', 'encrypted' => '', 'item_url' => $A['url'], 'track_onhand' => '')); if ($A['price'] > 0) { $product->set_var('price', $Cur->Format($A['price'])); } else { $product->clear_var('price'); } if ($A['price'] > 0 && $_USER['uid'] == 1 && !$_PP_CONF['anon_buy']) { $buttons .= $product->set_var('', 'login_req') . ' '; } elseif ($A['prod_type'] > PP_PROD_PHYSICAL && $A['price'] == 0) { // Free items or items purchases and not expired, download. $buttons .= $product->set_var('', 'download') . ' '; } elseif (is_array($A['buttons'])) { // Buttons for everyone else $product->set_block('product', 'BtnBlock', 'Btn'); foreach ($A['buttons'] as $type => $html) { $product->set_var('button', $html); $product->parse('Btn', 'BtnBlock', true); } } //$product->set_var('buttons', $buttons); $display .= $product->parse('', 'product'); $product->clear_var('Btn'); } // foreach plugin_data } // foreach $_PLUGINS } // if page == 1 $pagenav_args = empty($pagenav_args) ? '' : '?' . implode('&', $pagenav_args); // Display pagination if (isset($_PP_CONF['prod_per_page']) && $_PP_CONF['prod_per_page'] > 0 && $count > $_PP_CONF['prod_per_page']) { $product->set_var('pagination', COM_printPageNavigation(PAYPAL_URL . '/index.php' . $pagenav_args, $page, ceil($count / $_PP_CONF['prod_per_page']))); } else { $product->set_var('pagination', ''); } $display .= $product->parse('', 'end'); return $display; }
/** * This function displays the comments in a high level format. * * Begins displaying user comments for an item * * @param string $sid ID for item to show comments for * @param string $title Title of item * @param string $type Type of item (article, polls, etc.) * @param string $order How to order the comments 'ASC' or 'DESC' * @param string $mode comment mode (nested, flat, etc.) * @param int $pid id of parent comment * @param int $page page number of comments to display * @param boolean $cid true if $pid should be interpreted as a cid instead * @param boolean $delete_option if current user can delete comments * @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed * @return string HTML Formated Comments * @see CMT_commentBar * */ function CMT_userComments($sid, $title, $type = 'article', $order = '', $mode = '', $pid = 0, $page = 1, $cid = false, $delete_option = false, $ccode = 0) { global $_CONF, $_TABLES, $_USER, $LANG01; $retval = ''; if (!COM_isAnonUser()) { $result = DB_query("SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'"); $U = DB_fetchArray($result); if (empty($order)) { $order = $U['commentorder']; } if (empty($mode)) { $mode = $U['commentmode']; } $limit = $U['commentlimit']; } if ($order != 'ASC' && $order != 'DESC') { $order = $_CONF['comment_order']; } if (empty($mode)) { $mode = $_CONF['comment_mode']; } if (empty($limit)) { $limit = $_CONF['comment_limit']; } if (!is_numeric($page) || $page < 1) { $page = 1; } $start = $limit * ($page - 1); $template = COM_newTemplate($_CONF['path_layout'] . 'comment'); $template->set_file(array('commentarea' => 'startcomment.thtml')); $template->set_var('commentbar', CMT_commentBar($sid, $title, $type, $order, $mode, $ccode)); $template->set_var('sid', $sid); $template->set_var('comment_type', $type); $template->set_var('area_id', 'commentarea'); if ($mode == 'nested' || $mode == 'threaded' || $mode == 'flat') { // build query switch ($mode) { case 'flat': if ($cid) { $count = 1; $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u " . "WHERE c.uid = u.uid AND c.cid = {$pid} AND type='{$type}'"; } else { $count = DB_count($_TABLES['comments'], array('sid', 'type'), array($sid, $type)); $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u " . "WHERE c.uid = u.uid AND c.sid = '{$sid}' AND type='{$type}' " . "ORDER BY date {$order} LIMIT {$start}, {$limit}"; } break; case 'nested': case 'threaded': default: if ($order == 'DESC') { $cOrder = 'c.rht DESC'; } else { $cOrder = 'c.lft ASC'; } // We can simplify the query, and hence increase performance // when pid = 0 (when fetching all the comments for a given sid) if ($cid) { // pid refers to commentid rather than parentid // count the total number of applicable comments $q2 = "SELECT COUNT(*) " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2 " . "WHERE c.sid = '{$sid}' AND (c.lft >= c2.lft AND c.lft <= c2.rht) " . "AND c2.cid = {$pid} AND c.type='{$type}'"; $result = DB_query($q2); list($count) = DB_fetchArray($result); $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, c2.indent AS pindent, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, " . "{$_TABLES['users']} AS u " . "WHERE c.sid = '{$sid}' AND (c.lft >= c2.lft AND c.lft <= c2.rht) " . "AND c2.cid = {$pid} AND c.uid = u.uid AND c.type='{$type}' " . "ORDER BY {$cOrder} LIMIT {$start}, {$limit}"; } else { // pid refers to parentid rather than commentid if ($pid == 0) { // the simple, fast case // count the total number of applicable comments $count = DB_count($_TABLES['comments'], array('sid', 'type'), array($sid, $type)); $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, 0 AS pindent, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u " . "WHERE c.sid = '{$sid}' AND c.uid = u.uid AND type='{$type}' " . "ORDER BY {$cOrder} LIMIT {$start}, {$limit}"; } else { // count the total number of applicable comments $q2 = "SELECT COUNT(*) " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2 " . "WHERE c.sid = '{$sid}' AND (c.lft > c2.lft AND c.lft < c2.rht) " . "AND c2.cid = {$pid} AND c.type='{$type}'"; $result = DB_query($q2); list($count) = DB_fetchArray($result); $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, c2.indent + 1 AS pindent, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, " . "{$_TABLES['users']} AS u " . "WHERE c.sid = '{$sid}' AND (c.lft > c2.lft AND c.lft < c2.rht) " . "AND c2.cid = {$pid} AND c.uid = u.uid AND c.type='{$type}' " . "ORDER BY {$cOrder} LIMIT {$start}, {$limit}"; } } break; } $thecomments = ''; $result = DB_query($q); if (DB_numRows($result) == 0) { if ($page > 1) { list($plgurl, $plgid) = CMT_getCommentUrlId($type); $plglink = ''; if (!empty($plgurl)) { $plglink = "{$plgurl}?{$plgid}={$sid}"; } // Requested invalid page COM_handle404($plglink); } } $thecomments .= CMT_getComment($result, $mode, $type, $order, $delete_option, false, $ccode, $page); // Pagination $tot_pages = ceil($count / $limit); $is_comment_page = CMT_isCommentPage(); if ($is_comment_page) { $pLink[0] = "comment.php?sid={$sid}"; $pLink[0] .= "&" . CMT_TYPE . "={$type}&order={$order}&format={$mode}"; } else { list($plgurl, $plgid) = CMT_getCommentUrlId($type); $pLink[0] = "{$plgurl}?{$plgid}={$sid}"; $pLink[0] .= "&" . CMT_TYPE . "={$type}&order={$order}&mode={$mode}"; } $pLink[1] = "#comments"; $page_str = "cpage="; $template->set_var('pagenav', COM_printPageNavigation($pLink, $page, $tot_pages, $page_str, false)); $template->set_var('comments', $thecomments); if (COMMENT_ON_SAME_PAGE) { if ($ccode == 0) { $cmode = COM_applyFilter(COM_getArgument(CMT_MODE)); $html = CMT_handleComment($cmode, $type, $title, $sid, $mode); $template->set_var('commenteditor', $html); } } $retval = $template->finish($template->parse('output', 'commentarea')); } return $retval; }
/** * this searches for pages matching the user query and returns an array of * for the header and table rows back to search.php where it will be formated and * printed * * @query string Keywords user is looking for * @datestart date/time Start date to get results for * @dateend date/time End date to get results for * @topic string The topic they were searching in * @type string Type of items they are searching * @author string Get all results by this author * */ function MG_search($id, $page, $searchinfo = '') { global $_USER, $_TABLES, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03; $columns_per_page = $_MG_CONF['search_columns']; $rows_per_page = $_MG_CONF['search_rows']; if (!empty($searchinfo['numresults'])) { $rows_per_page = intval($searchinfo['numresults'] / $columns_per_page); } $media_per_page = $columns_per_page * $rows_per_page; $current_print_page = $page; // $alertmsg = '<div class="pluginAlert">' . $LANG_MG03['no_search_found'] . '</div>'; // pull the query from the search database... $result = DB_query("SELECT * FROM {$_TABLES['mg_sort']} WHERE sort_id='" . addslashes($id) . "'"); // $nrows = DB_numRows($result); // if ($nrows < 1) { // return $alertmsg; // } $S = DB_fetchArray($result); if (!isset($_USER['uid']) || $_USER['uid'] < 2) { $sort_user = 1; } else { $sort_user = $_USER['uid']; } // if ($sort_user != $S['sort_user'] && $S['sort_user'] != 1) { // return $alertmsg; // } $page = $page - 1; $begin = $media_per_page * $page; $end = $media_per_page; $root_album_owner_id = SEC_hasRights('mediagallery.admin'); $permsql = COM_getPermSQL('AND', $sort_user, 2, 'a'); $hiddensql = !$root_album_owner_id ? "AND a.hidden=0 " : ''; $sql = "SELECT DISTINCT count(*) AS c FROM {$_TABLES['mg_media']} AS m, " . $_TABLES['mg_media_albums'] . " AS ma, " . $_TABLES['mg_albums'] . " AS a " . $S['sort_query'] . " AND m.media_id=ma.media_id AND ma.album_id=a.album_id " . $hiddensql . $permsql; $result = DB_query($sql); $row = DB_fetchArray($result); $total_media = $row['c']; // if ($total_media < 1) { // return $alertmsg; // } $sql = "SELECT DISTINCT m.*,a.album_id FROM {$_TABLES['mg_media']} AS m, " . $_TABLES['mg_media_albums'] . " AS ma, " . $_TABLES['mg_albums'] . " AS a " . $S['sort_query'] . " AND m.media_id=ma.media_id AND ma.album_id=a.album_id " . $hiddensql . $permsql . " ORDER BY m.media_time DESC" . " LIMIT " . $begin . "," . intval($begin + $end); $result = DB_query($sql); $media_array = array(); while ($row = DB_fetchArray($result)) { $media_array[] = $row; } $total_print_pages = ceil($total_media / $media_per_page); $pagination = COM_printPageNavigation($_MG_CONF['site_url'] . '/search.php?id=' . $id, $page + 1, $total_print_pages, 'page='); $page_number = sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages); $return_url = $S['referer'] == '' ? $_MG_CONF['site_url'] : htmlentities($S['referer'], ENT_QUOTES, COM_getCharset()); // new stuff $T = COM_newTemplate(MG_getTemplatePath_byName()); $T->set_file('page', 'search_page.thtml'); $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => $pagination, 'bottom_pagination' => $pagination, 'page_number' => $page_number, 'lang_search_results' => $LANG_MG03['search_results'], 'lang_return_to_index' => $LANG_MG03['return_to_index'], 'return_url' => $return_url, 'search_keywords' => $searchinfo['keywords'] == '*' ? '*' : $S['keywords'], 'lang_search' => $LANG_MG01['search'])); MG_buildSearchBox($T, $searchinfo); $howmany = $total_media - $page * $media_per_page; if ($howmany > $total_media) { $howmany = $total_media; } if ($howmany > 0) { $k = 0; $col = 0; $opt = array('sortOrder' => 0, 'searchmode' => 1); $T->set_block('page', 'ImageColumn', 'IColumn'); $T->set_block('page', 'ImageRow', 'IRow'); for ($i = 0; $i < $media_per_page; $i += $columns_per_page) { $next_columns = $i + $columns_per_page; for ($j = $i; $j < $next_columns; $j++) { if ($j >= $total_media) { $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); break 2; } if ($j + $begin >= $total_media) { continue; } $media = new Media($media_array[$j], $media_array[$j]['album_id']); $celldisplay = $media->displayThumb($opt); if ($media->type == 1) { $PhotoURL = MG_getFileUrl('disp', $media->filename); $T->set_var('URL', $PhotoURL); } $T->set_var('clear_float', ''); if ($col == $columns_per_page) { $T->set_var('clear_float', ' clear:both;'); $col = 0; } $T->set_var('CELL_DISPLAY_IMAGE', $celldisplay); $T->parse('IColumn', 'ImageColumn', true); $col++; } $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); } $T->set_var('album_body', 1); } else { $T->set_var('lang_no_image', $LANG_MG03['no_media_objects']); } return $T->finish($T->parse('output', 'page')); }
$msg_row->set_var('buddylink', $buddylink); $msg_row->set_var('replylink', $replylink); $msg_row->set_var('LANG_reply', $LANG_MSG['REPLY']); $msg_row->set_var('deletelink', $deletelink); $msg_row->set_var('LANG_delete', $LANG_MSG['DELETE']); $msg_row->set_var('archivelink', $archivelink); $msg_row->set_var('LANG_archive', $LANG_MSG['ARCHIVE']); $msg_row->parse('output', 'msg_row'); $rows .= $msg_row->finish($msg_row->get_var('output')); echo $msg_row->finish($msg_row->get_var('output')); $cssid = $cssid == 1 ? 2 : 1; } } } } if ($action != 'newpm' and $mode != 'newpm') { $msg_footer = new Template($_CONF['path_layout'] . '/messenger'); $msg_footer->set_file(array('msg_footer' => 'msg_footer.thtml')); $msg_footer->set_var('pagenavigation', COM_printPageNavigation($base_url, $page, $numpages)); if ($footernote == '') { $msg_footer->set_var('show_footermsg', 'none'); } $msg_footer->set_var('footernote', $footernote); $msg_footer->set_var('endblock', COM_endBlock()); $msg_footer->set_var('imgset', $CONF_MSG['imgset']); $msg_footer->parse('output', 'msg_footer'); echo $msg_footer->finish($msg_footer->get_var('output')); } else { echo '</td></tr></table>'; } echo COM_siteFooter();
/** * Display an expanded ad listing. * @param string $pagename Name of page in index.php the called us * @param integer $cat_id Optional category ID to be appended to url * @param string $where_clause Additional SQL where clause * @param string $limit_clause Optional limit clause * @return string Page Content */ function adExpList($pagename = '', $cat_id = '', $where_clause = '', $limit_clause = '') { global $_TABLES, $LANG_ADVT, $_CONF, $_USER, $_CONF_ADVT; // Fix time to check ad expiration $time = time(); // Max number of ads per page $maxAds = isset($_CONF_ADVT['maxads_pg_exp']) ? (int) $_CONF_ADVT['maxads_pg_exp'] : 20; $T = new Template(CLASSIFIEDS_PI_PATH . '/templates'); $T->set_file('catlist', 'adExpList.thtml'); // Get the ads for this category, starting at the requested page $sql = "SELECT ad.*, ad.add_date as ad_add_date, cat.*\n FROM {$_TABLES['ad_ads']} ad ,\n {$_TABLES['ad_category']} cat \n WHERE cat.cat_id = ad.cat_id \n AND ad.exp_date > {$time} " . COM_getPermSQL('AND', 0, 2, 'ad') . COM_getPermSQL('AND', 0, 2, 'cat'); if ($where_clause != '') { $sql .= " AND {$where_clause} "; } $sql .= " ORDER BY ad.add_date DESC"; //echo $sql;die; // first execute the query with the supplied limit clause to get // the total number of ads eligible for viewing $sql1 = $sql . ' ' . $limit_clause; $result = DB_query($sql1); if (!$result) { return "Database Error"; } $totalAds = DB_numRows($result); // Figure out the page number, and execute the query // with the appropriate LIMIT clause. if ($totalAds <= $maxAds) { $totalPages = 1; } elseif ($totalAds % $maxAds == 0) { $totalPages = $totalAds / $maxAds; } else { $totalPages = ceil($totalAds / $maxAds); } $page = COM_applyFilter($_REQUEST['start'], true); if ($page < 1 || $page > $totalPages) { $page = 1; } if ($totalAds == 0) { $startEntry = 0; } else { $startEntry = $maxAds * $page - $maxAds + 1; } if ($page == $totalPages) { $endEntry = $totalAds; } else { $endEntry = $maxAds * $page; } //$prePage = $page - 1; //$nextPage = $page + 1; $initAds = $maxAds * ($page - 1); // Create the page menu string for display if there is more // than one page $pageMenu = ''; if ($totalPages > 1) { $baseURL = CLASSIFIEDS_URL . "/index.php?page={$pagename}"; if ($cat_id != '') { $baseURL .= "&id={$cat_id}"; } $pageMenu = COM_printPageNavigation($baseURL, $page, $totalPages, "start="); } $T->set_var('pagemenu', $pageMenu); $sql .= " LIMIT {$initAds}, {$maxAds}"; //echo $sql;die; $result = DB_query($sql); if (!$result) { return CLASSIFIEDS_errorMsg($LANG_ADVT['database_error'], 'alert'); } if ($totalAds == 0) { $T->set_block('catlist', 'No_Ads', 'NoAdBlk'); $T->set_var('no_ads', $LANG_ADVT['no_ads_listed_cat']); $T->parse('NoAdBlk', 'No_Ads', true); } $T->set_block('catlist', 'QueueRow', 'QRow'); while ($row = DB_fetchArray($result)) { $T->set_var('bgColor', $bgColor); $T->set_var('cat_id', $row['cat_id']); $T->set_var('subject', strip_tags($row['subject'])); $T->set_var('ad_id', $row['ad_id']); $T->set_var('ad_url', CLASSIFIEDS_makeURL('detail', $row['ad_id'])); //$T->set_var('add_date', date("m/d/y", $row['ad_add_date'])); $T->set_var('add_date', date($_CONF['shortdate'], $row['ad_add_date'])); //$T->set_var('ad_type', $row['forsale'] == 1 ? // $LANG_ADVT['forsale'] : $LANG_ADVT['wanted']); $T->set_var('ad_type', CLASSIFIEDS_getAdTypeString($row['ad_type'])); $T->set_var('cat_name', $row['cat_name']); $T->set_var('cat_url', CLASSIFIEDS_makeURL('home', $row['cat_id'])); $T->set_var('cmt_count', CLASSIFIEDS_commentCount($row['ad_id'])); $sql = "SELECT filename\n FROM {$_TABLES['ad_photo']}\n WHERE ad_id='{$row['ad_id']}'\n LIMIT 1"; $photo = DB_query($sql); if (!$photo) { return CLASSIFIEDS_errorMsg($LANG_ADVT['database_error'], 'alert'); } // Retrieve the first image. If it is define AND exists on the // filesystem, then use it. Otherwise display "not available". if (DB_numRows($photo) == 1) { $prow = DB_fetchArray($photo); $T->set_var('img_url', CLASSIFIEDS_dispUrl($prow['filename'])); $T->set_var('thumb_url', CLASSIFIEDS_thumbUrl($prow['filename'])); } else { $T->set_var('img_url', ''); } // $T->set_var('descript', htmlspecialchars(COM_stripslashes(substr(strip_tags($row['descript']), 0, 300)))); $T->set_var('descript', substr(strip_tags($row['descript']), 0, 300)); if (strlen($row['descript']) > 300) { $T->set_var('ellipses', "... ..."); } if ($row['price'] != '') { $T->set_var('price', COM_stripslashes($row['price'])); } else { $T->set_var('price', ''); } //Additional info for ($j = 0; $j < 5; $j++) { $T->set_var('name0' . $j, $row['name0' . $j]); $T->set_var('value0' . $j, $row['value0' . $j]); } $T->parse('QRow', 'QueueRow', true); } // while $T->set_var('totalAds', $totalAds); $T->set_var('adsStart', $startEntry); $T->set_var('adsEnd', $endEntry); $T->parse('output', 'catlist'); return $T->finish($T->get_var('output')); }
/** * This function displays the comments in a high level format. * * Begins displaying user comments for an item * * @param string $sid ID for item to show comments for * @param string $title Title of item * @param string $type Type of item (article, poll, etc.) * @param string $order How to order the comments 'ASC' or 'DESC' * @param string $mode comment mode (nested, flat, etc.) * @param int $pid id of parent comment * @param int $page page number of comments to display * @param boolean $cid true if $pid should be interpreted as a cid instead * @param boolean $delete_option if current user can delete comments * @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed * @return string HTML Formated Comments * @see CMT_commentBar * */ function CMT_userComments($sid, $title, $type = 'article', $order = '', $mode = '', $pid = 0, $page = 1, $cid = false, $delete_option = false, $ccode = 0) { global $_CONF, $_TABLES, $_USER, $LANG01; if (!empty($_USER['uid'])) { $result = DB_query("SELECT commentorder,commentmode,commentlimit FROM {$_TABLES['usercomment']} WHERE uid = '{$_USER['uid']}'"); $U = DB_fetchArray($result); if (empty($order)) { $order = $U['commentorder']; } if (empty($mode)) { $mode = $U['commentmode']; } $limit = $U['commentlimit']; } if ($order != 'ASC' && $order != 'DESC') { $order = 'ASC'; } if (empty($mode)) { $mode = $_CONF['comment_mode']; } if (empty($limit)) { $limit = $_CONF['comment_limit']; } if (!is_numeric($page) || $page < 1) { $page = 1; } $start = $limit * ($page - 1); $template = new Template($_CONF['path_layout'] . 'comment'); $template->set_file(array('commentarea' => 'startcomment.thtml')); $template->set_var('xhtml', XHTML); $template->set_var('site_url', $_CONF['site_url']); $template->set_var('site_admin_url', $_CONF['site_admin_url']); $template->set_var('layout_url', $_CONF['layout_url']); $template->set_var('commentbar', CMT_commentBar($sid, $title, $type, $order, $mode, $ccode)); $template->set_var('sid', $sid); $template->set_var('comment_type', $type); if ($mode == 'nested' || $mode == 'threaded' || $mode == 'flat') { // build query switch ($mode) { case 'flat': if ($cid) { $count = 1; $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u " . "WHERE c.uid = u.uid AND c.cid = {$pid} AND type='{$type}'"; } else { $count = DB_count($_TABLES['comments'], array('sid', 'type'), array($sid, $type)); $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u " . "WHERE c.uid = u.uid AND c.sid = '{$sid}' AND type='{$type}' " . "ORDER BY date {$order} LIMIT {$start}, {$limit}"; } break; case 'nested': case 'threaded': default: if ($order == 'DESC') { $cOrder = 'c.rht DESC'; } else { $cOrder = 'c.lft ASC'; } // We can simplify the query, and hence increase performance // when pid = 0 (when fetching all the comments for a given sid) if ($cid) { // pid refers to commentid rather than parentid // count the total number of applicable comments $q2 = "SELECT COUNT(*) " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2 " . "WHERE c.sid = '{$sid}' AND (c.lft >= c2.lft AND c.lft <= c2.rht) " . "AND c2.cid = {$pid} AND c.type='{$type}'"; $result = DB_query($q2); list($count) = DB_fetchArray($result); $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, c2.indent AS pindent, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, " . "{$_TABLES['users']} AS u " . "WHERE c.sid = '{$sid}' AND (c.lft >= c2.lft AND c.lft <= c2.rht) " . "AND c2.cid = {$pid} AND c.uid = u.uid AND c.type='{$type}' " . "ORDER BY {$cOrder} LIMIT {$start}, {$limit}"; } else { // pid refers to parentid rather than commentid if ($pid == 0) { // the simple, fast case // count the total number of applicable comments $count = DB_count($_TABLES['comments'], array('sid', 'type'), array($sid, $type)); $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, 0 AS pindent, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['users']} AS u " . "WHERE c.sid = '{$sid}' AND c.uid = u.uid AND type='{$type}' " . "ORDER BY {$cOrder} LIMIT {$start}, {$limit}"; } else { // count the total number of applicable comments $q2 = "SELECT COUNT(*) " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2 " . "WHERE c.sid = '{$sid}' AND (c.lft > c2.lft AND c.lft < c2.rht) " . "AND c2.cid = {$pid} AND c.type='{$type}'"; $result = DB_query($q2); list($count) = DB_fetchArray($result); $q = "SELECT c.*, u.username, u.fullname, u.photo, u.email, c2.indent + 1 AS pindent, " . "UNIX_TIMESTAMP(c.date) AS nice_date " . "FROM {$_TABLES['comments']} AS c, {$_TABLES['comments']} AS c2, " . "{$_TABLES['users']} AS u " . "WHERE c.sid = '{$sid}' AND (c.lft > c2.lft AND c.lft < c2.rht) " . "AND c2.cid = {$pid} AND c.uid = u.uid AND c.type='{$type}' " . "ORDER BY {$cOrder} LIMIT {$start}, {$limit}"; } } break; } $thecomments = ''; $result = DB_query($q); $thecomments .= CMT_getComment($result, $mode, $type, $order, $delete_option, false, $ccode); // Pagination $tot_pages = ceil($count / $limit); $pLink = $_CONF['site_url'] . "/article.php?story={$sid}&type={$type}&order={$order}&mode={$mode}"; $template->set_var('pagenav', COM_printPageNavigation($pLink, $page, $tot_pages)); $template->set_var('comments', $thecomments); $retval = $template->finish($template->parse('output', 'commentarea')); } return $retval; }
if ($page >= $total_pages) { $page = $total_pages - 1; } $start = $page * $media_per_page; $current_print_page = floor($start / $media_per_page) + 1; if ($current_print_page == 0) { $current_print_page = 1; } $total_print_pages = $total_pages; if ($total_print_pages == 0) { $total_print_pages = 1; } $birdseed = MG_getBirdseed(0, 0, 0, $total_print_pages); $ownername = DB_getItem($_TABLES['users'], 'username', "uid=" . intval($root_album->owner_id)); $album_last_update = MG_getUserDateTimeFormat($root_album->last_update); $pagination = COM_printPageNavigation($_MG_CONF['site_url'] . '/index.php', $page + 1, $total_pages); $rsslink = ''; if ($_MG_CONF['rss_full_enabled']) { $rsslink = COM_createLink(COM_createImage(MG_getImageFile('feed.png'), '', array('class' => 'mg_rssimg')), MG_getFeedUrl($_MG_CONF['rss_feed_name'] . '.rss'), array('type' => 'application/rss+xml')); } $T = COM_newTemplate(MG_getTemplatePath_byName($root_album->skin)); $T->set_file('page', 'album_page.thtml'); $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'album_title' => PLG_replaceTags($root_album->title), 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => $pagination, 'bottom_pagination' => $pagination, 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'jumpbox' => MG_buildAlbumJumpbox($root_album, $album_id, 1, -1), 'album_id' => $album_id, 'album_description' => $root_album->display_album_desc ? PLG_replaceTags($root_album->description) : '', 'album_id_display' => $root_album->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'select_adminbox' => COM_isAnonUser() ? '' : MG_buildAdminbox($root_album), 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $root_album->getMediaCount(), 'lang_menulabel' => $LANG_MG03['menulabel'], 'lang_search' => $LANG_MG01['search'], 'rsslink' => $rsslink, 'list_title' => $LANG_MG03['list_title'], 'list_desc' => $LANG_MG03['list_desc'], 'list_size' => $LANG_MG03['list_size'], 'list_user' => $LANG_MG03['list_user'], 'list_updated' => $LANG_MG03['list_updated'])); // completed setting header / footer vars, parse them PLG_templateSetVars('mediagallery', $T); // main processing of the album contents. if ($total_media > 0) { $k = 0; $col = 0; $T->set_block('page', 'ImageColumn', 'IColumn'); $T->set_block('page', 'ImageRow', 'IRow');
/** * Takes an article class and renders HTML in the specified template and style. * * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param object $story The story to display, an instance of the Story class. * @param string $index n = 'Compact display' for list of stories. p = 'Preview' mode. Else full display of article. * @param string $storytpl The template to use to render the story. * @param string $query A search query, if one was specified. * * @return string Article as formated HTML. * * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle(&$story, $index = '', $storytpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode; static $storycounter = 0; if (empty($storytpl)) { $storytpl = 'storytext.thtml'; } $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } $article = new Template($_CONF['path_layout']); $article->set_file(array('article' => $storytpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); $article->set_var('xhtml', XHTML); $article->set_var('layout_url', $_CONF['layout_url']); $article->set_var('site_url', $_CONF['site_url']); $article->set_var('site_admin_url', $_CONF['site_admin_url']); $article->set_var('site_name', $_CONF['site_name']); $article->set_var('story_date', $story->DisplayElements('date')); $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106]); $article->set_var('story_hits', $story->DisplayElements('hits')); } $article->set_var('story_id', $story->getSid()); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('contributedby_author', $authorname); $article->set_var('author', $authorname); if ($story->DisplayElements('uid') > 1) { $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); $article->set_var('start_contributedby_anchortag', '<a class="storybyline" href="' . $profileUrl . '">'); $article->set_var('end_contributedby_anchortag', '</a>'); $article->set_var('contributedby_url', $profileUrl); } $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $topicname = $story->DisplayElements('topic'); $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('story_topic_name', $topicname); $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid'); if ((!isset($_USER['noicons']) or $_USER['noicons'] != 1) and $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array('rel' => "category"))); $article->set_var('story_topic_image', $topicimage); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array('rel' => "category"))); $article->set_var('story_topic_image_no_align', $topicimage_noalign); } } $article->set_var('story_topic_url', $topicurl); $recent_post_anchortag = ''; $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('story_title', $story->DisplayElements('title')); $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = 'Compact display' for list of stories. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 and $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $pagelinks = COM_printPageNavigation($articleUrl, $story_page, count($article_array), 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $pagelinks); if ($_CONF['page_break_comments'] == 'last' and $story_page < count($article_array) or $_CONF['page_break_comments'] == 'first' and $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br' . XHTML . '><br' . XHTML . '>' . $bodytext); $article->set_var('story_text_no_br', $introtext . ' ' . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if (!empty($bodytext)) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $numwords = COM_numberFormat(count(explode(' ', COM_getTextContent($bodytext)))); $article->set_var('readmore_words', $numwords); $article->set_var('readmore_link', COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); } if ($story->DisplayElements('commentcode') >= 0 and $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . $story->getsid() . "' ORDER BY date desc LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $article->set_var('comments_with_count', COM_createLink($comments_with_count, $commentsUrl)); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getsid() . '&pid=0&type=article'); } if ($story->DisplayElements('commentcode') == 0) { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'; $article->set_var('post_comment_link', COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow'))); /* $article->set_var( 'subscribe_link', COM_createLink('Nubbies', '', array('rel' => 'nofollow')) ); */ $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } if ($story->DisplayElements('trackbacks') > 0) { $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); } else { $article->set_var('trackbacks_with_count', sprintf($LANG01[122], $num_trackbacks)); } } if ($_CONF['hideemailicon'] == 1 || empty($_USER['username']) && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '"' . XHTML . '>'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '"' . XHTML . '>'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('story_display', 'index'); $storycounter++; $article->set_var('story_counter', $storycounter); } $article->set_var('article_url', $articleUrl); $article->set_var('recent_post_anchortag', $recent_post_anchortag); if ($story->checkAccess() == 3 and SEC_hasrights('story.edit') and $index != 'p') { $article->set_var('edit_link', COM_createLink($LANG01[4], $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid())); $article->set_var('edit_url', $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid()); $article->set_var('lang_edit_text', $LANG01[4]); $editicon = $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE; $editiconhtml = '<img src="' . $editicon . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>'; $article->set_var('edit_icon', COM_createLink($editiconhtml, $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid())); $article->set_var('edit_image', $editiconhtml); } if ($story->DisplayElements('featured') == 1) { $article->set_var('lang_todays_featured_article', $LANG05[4]); $article->parse('story_bodyhtml', 'featuredbodytext', true); PLG_templateSetVars('featuredstorytext', $article); $article->parse('finalstory', 'featuredarticle'); } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE and $story->DisplayElements('expire') <= time()) { $article->parse('story_bodyhtml', 'archivestorybodytext', true); PLG_templateSetVars('archivestorytext', $article); $article->parse('finalstory', 'archivearticle'); } else { $article->parse('story_bodyhtml', 'bodytext', true); PLG_templateSetVars('storytext', $article); $article->parse('finalstory', 'article'); } return $article->finish($article->get_var('finalstory')); }
$display .= STORY_renderArticle($story, 'y'); } // get plugin center blocks that follow articles $display .= PLG_showCenterblock(3, $page, $topic); // bottom blocks // Print Google-like paging navigation if (!isset($_CONF['hide_main_page_navigation']) || $_CONF['hide_main_page_navigation'] == 0) { if (empty($topic)) { $base_url = $_CONF['site_url'] . '/index.php'; if ($newstories) { $base_url .= '?display=new'; } } else { $base_url = $_CONF['site_url'] . '/index.php?topic=' . $topic; } $display .= COM_printPageNavigation($base_url, $page, $num_pages); } } else { // no stories to display if (!isset($_CONF['hide_no_news_msg']) || $_CONF['hide_no_news_msg'] == 0) { $display .= COM_startBlock($LANG05[1], '', COM_getBlockTemplate('_msg_block', 'header')) . $LANG05[2]; if (!empty($topic)) { $topicname = DB_getItem($_TABLES['topics'], 'topic', "tid = '{$topic}'"); $display .= sprintf($LANG05[3], $topicname); } $display .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); } $display .= PLG_showCenterblock(3, $page, $topic); // bottom blocks } $display .= COM_siteFooter(true);
/** * Creates a list of data with a search, filter, clickable headers etc. * * @param string $component name of the list * @param string $fieldFunction name of the function that handles special entries * @param array $header_arr array of header fields with sortables and table fields * @param array $text_arr array with different text strings * @param array $query_arr array with sql-options * @param array $defSort_arr default sorting values * @param string $filter additional drop-down filters * @param string $extra additional values passed to fieldfunction * @param array $options array of options - intially just used for the Check-All feature * @param array $form_arr optional extra forms at top or bottom * @param bool $showSearch whether to show the search functionality * @param string $pageNavUrl additional url values that page navigation and sorting by columns may need for any * additional filters * @return string HTML output of function */ function ADMIN_list($component, $fieldFunction, $header_arr, $text_arr, $query_arr, $defSort_arr, $filter = '', $extra = '', $options = array(), $form_arr = array(), $showSearch = true, $pageNavUrl = '') { global $_CONF, $LANG_ADMIN, $LANG01, $_IMAGE_TYPE; // set all variables to avoid warnings $retval = ''; $filter_str = ''; $order_sql = ''; $group_by_sql = ''; $limit = ''; $prevOrder = ''; if (isset($_GET['prevorder'])) { # what was the last sorting? $prevOrder = COM_applyFilter($_GET['prevorder']); } $query = ''; if (isset($_REQUEST['q'])) { // get query (text-search) $query = strip_tags(COM_stripslashes($_REQUEST['q'])); } $query_limit = ''; if (isset($_REQUEST['query_limit'])) { // get query-limit (list-length) $query_limit = COM_applyFilter($_REQUEST['query_limit'], true); if ($query_limit == 0) { $query_limit = DEFAULT_ENTRIES_PER_PAGE; } } // we assume that the current page is 1 to set it. $currentPage = 1; $page = ''; // get the current page from the interface. The variable is linked to the // component, i.e. the plugin/function calling this here to avoid overlap if (isset($_REQUEST[$component . 'listpage'])) { $page = COM_applyFilter($_REQUEST[$component . 'listpage'], true); $currentPage = $page; } if ($currentPage <= 0) { $currentPage = 1; #current page has to be larger 0 } $help_url = ''; # do we have a help url for the block-header? if (!empty($text_arr['help_url'])) { $help_url = $text_arr['help_url']; } $form_url = ''; # what is the form-url for the search button and list sorters? if (!empty($text_arr['form_url'])) { $form_url = $text_arr['form_url']; } $title = ''; # what is the title of the page? if (!empty($text_arr['title'])) { $title = $text_arr['title']; } $inline_form = false; if (isset($text_arr['inline'])) { $inline_form = $text_arr['inline']; } # get all template fields. $admin_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/lists'); $template_files = array('list' => $inline_form ? 'inline.thtml' : 'list.thtml', 'header' => 'header.thtml', 'row' => 'listitem.thtml', 'field' => 'field.thtml'); if ($showSearch) { $template_files['search'] = 'searchmenu.thtml'; } $admin_templates->set_file($template_files); $admin_templates->set_var('form_url', $form_url); $admin_templates->set_var('lang_edit', $LANG_ADMIN['edit']); $admin_templates->set_var('lang_deleteall', $LANG01[124]); $admin_templates->set_var('lang_delconfirm', $LANG01[125]); if (isset($form_arr['top'])) { $admin_templates->set_var('formfields_top', $form_arr['top']); } if (isset($form_arr['bottom'])) { $admin_templates->set_var('formfields_bottom', $form_arr['bottom']); } // Check if the delete checkbox and support for the delete all feature should be displayed if (is_array($options) && isset($options['chkdelete']) && $options['chkdelete']) { $admin_templates->set_var('header_text', '<input type="checkbox" name="chk_selectall" title="' . $LANG01[126] . '" onclick="caItems(this.form);"' . XHTML . '>'); $admin_templates->set_var('class', "admin-list-field"); $admin_templates->set_var('show_deleteimage', ''); $admin_templates->parse('header_row', 'header', true); $admin_templates->clear_var('on_click'); } else { $admin_templates->set_var('show_deleteimage', 'display:none;'); } // define icon paths. Those will be transmitted to $fieldFunction. $icons_type_arr = array('edit', 'copy', 'list', 'addchild', 'deleteitem', 'enabled', 'disabled', 'unavailable', 'warning', 'info'); $icon_arr = array(); foreach ($icons_type_arr as $icon_type) { $icon_url = "{$_CONF['layout_url']}/images/{$icon_type}.{$_IMAGE_TYPE}"; $icon_arr[$icon_type] = COM_createImage($icon_url, $LANG_ADMIN[$icon_type], array('style' => 'vertical-align: middle;')); } $has_extras = ''; if (isset($text_arr['has_extras'])) { # does this one use extras? (search, google paging) $has_extras = $text_arr['has_extras']; } if ($has_extras) { // show search $admin_templates->set_var('lang_search', $LANG_ADMIN['search']); $admin_templates->set_var('lang_submit', $LANG_ADMIN['submit']); $admin_templates->set_var('lang_limit_results', $LANG_ADMIN['limit_results']); $admin_templates->set_var('last_query', htmlspecialchars($query)); $admin_templates->set_var('filter', $filter); } $sql_query = DB_escapeString($query); // replace quotes etc for security $sql = $query_arr['sql']; // get sql from array that builds data $order_var = ''; # number that is displayed in URL $order_var_link = ''; # Variable for google paging. // is the order set in the link (when sorting the list) if (!isset($_GET['order'])) { $order = $defSort_arr['field']; // no, get the default } else { $order_var = COM_applyFilter($_GET['order'], true); $order_var_link = "&order={$order_var}"; # keep the variable for the google paging $order = $header_arr[$order_var]['field']; # current order field name } if (isset($header_arr[$order_var]['sort_field'])) { // See if specific sort fields are set for the current field $order_for_query = $header_arr[$order_var]['sort_field']; } else { $order_for_query = $order; } // this code sorts only by the field if its in table.field style. // removing this however makes match for arrow-display impossible, so removed it. // maybe now for more fields the table has to be added to the sortfield? //$order = explode ('.', $order); //if (count ($order) > 1) { // $order = $order[1]; //} else { // $order = $order[0]; //} if (!isset($_GET['direction'])) { # get direction to sort after $direction = $defSort_arr['direction']; } else { $direction = COM_applyFilter($_GET['direction']); } $direction = strtoupper($direction); if ($order == $prevOrder) { #reverse direction if prev. order was the same $direction = $direction === 'DESC' ? 'ASC' : 'DESC'; } else { $direction = $direction === 'DESC' ? 'DESC' : 'ASC'; } if ($direction == 'ASC') { # assign proper arrow img name dep. on sort order $arrow = 'bararrowdown'; } else { $arrow = 'bararrowup'; } # make actual order arrow image $img_arrow_url = "{$_CONF['layout_url']}/images/{$arrow}.{$_IMAGE_TYPE}"; $img_arrow = ' ' . COM_createImage($img_arrow_url, $arrow); if (!empty($order_for_query)) { # concat order string $order_sql = "ORDER BY {$order_for_query} {$direction}"; } $th_subtags = ''; // other tags in the th, such as onclick and mouseover $header_text = ''; // title as displayed to the user // HEADER FIELDS array(text, field, sort, class) // this part defines the contents & format of the header fields for ($i = 0; $i < count($header_arr); $i++) { #iterate through all headers $header_text = $header_arr[$i]['text']; $th_subtags = ''; if ($header_arr[$i]['sort'] != false) { # is this sortable? if ($order == $header_arr[$i]['field']) { # is this currently sorted? $header_text .= $img_arrow; } # make the mouseover effect is sortable $th_subtags = " onmouseover=\"this.style.cursor='pointer';\""; $order_var = $i; # assign number to field so we know what to sort if (strpos($form_url, '?') > 0) { $separator = '&'; } else { $separator = '?'; } $th_subtags .= " onclick=\"window.location.href='{$form_url}{$separator}" . "order={$order_var}&prevorder={$order}&direction={$direction}"; if (!empty($page)) { $th_subtags .= '&' . $component . 'listpage=' . $page; } if (!empty($query)) { $th_subtags .= '&q=' . urlencode($query); } if (!empty($query_limit)) { $th_subtags .= '&query_limit=' . $query_limit; } if (!empty($pageNavUrl)) { // used for any additional filters $th_subtags .= $pageNavUrl; } $th_subtags .= "';\""; } if (!empty($header_arr[$i]['header_class'])) { $admin_templates->set_var('class', $header_arr[$i]['header_class']); } else { $admin_templates->set_var('class', "admin-list-headerfield"); } $admin_templates->set_var('header_text', $header_text); $admin_templates->set_var('th_subtags', $th_subtags); $admin_templates->parse('header_row', 'header', true); $admin_templates->clear_var('th_subtags'); // clear all for next header $admin_templates->clear_var('class'); $admin_templates->clear_var('header_text'); } if (!empty($query_arr['query_group'])) { # add group by to sql $group_by_sql = " GROUP BY {$query_arr['query_group']}"; } if ($has_extras && $showSearch) { /** * default query limit if no other ch osen. * * @todo maybe this could be a setting from the list? */ $limit = DEFAULT_ENTRIES_PER_PAGE; if (!empty($query_limit)) { $limit = $query_limit; } if ($query != '') { # set query into form after search $admin_templates->set_var('query', urlencode($query)); } else { $admin_templates->set_var('query', ''); } $admin_templates->set_var('query_limit', $query_limit); // choose proper dropdown field for query limit $admin_templates->set_var($limit . '_selected', 'selected="selected"'); if (!empty($query_arr['default_filter'])) { # add default filter to sql $filter_str = " {$query_arr['default_filter']}"; } if (!empty($query)) { # add query fields with search term $filter_str .= " AND ("; for ($f = 0; $f < count($query_arr['query_fields']); $f++) { $filter_str .= $query_arr['query_fields'][$f] . " LIKE '%{$sql_query}%'"; if ($f < count($query_arr['query_fields']) - 1) { $filter_str .= " OR "; } } $filter_str .= ")"; } $num_pages_sql = $sql . $filter_str . $group_by_sql; $num_pages_result = DB_query($num_pages_sql); $num_rows = DB_numRows($num_pages_result); $num_pages = ceil($num_rows / $limit); if ($num_pages < $currentPage) { # make sure we dont go beyond possible results $currentPage = 1; } $offset = ($currentPage - 1) * $limit; $limit = "LIMIT {$offset},{$limit}"; # get only current page data $admin_templates->set_var('lang_records_found', $LANG_ADMIN['records_found']); $admin_templates->set_var('records_found', COM_numberFormat($num_rows)); $admin_templates->parse('search_menu', 'search', true); } if (is_callable($fieldFunction)) { if (!empty($extra)) { $useFieldFunction = 2; } else { $useFieldFunction = 1; } } else { $useFieldFunction = 0; } // SQL $sql .= "{$filter_str} {$group_by_sql} {$order_sql} {$limit};"; $result = DB_query($sql); $numRows = DB_numRows($result); $r = 1; // r is the counter for the actual displayed rows for correct coloring for ($i = 0; $i < $numRows; $i++) { # now go through actual data $A = DB_fetchArray($result); $this_row = false; # as long as no fields are returned, dont print row if (is_array($options) && isset($options['chkdelete']) && $options['chkdelete']) { $admin_templates->set_var('class', "admin-list-field"); $admin_templates->set_var('itemtext', '<input type="checkbox" name="delitem[]" value="' . $A[$options['chkfield']] . '"' . XHTML . '>'); $admin_templates->parse('item_field', 'field', true); } for ($j = 0; $j < count($header_arr); $j++) { $fieldName = $header_arr[$j]['field']; # get field name from headers if (isset($A[$fieldName])) { $fieldValue = strval($A[$fieldName]); # yes, get its data } else { $fieldValue = ''; } switch ($useFieldFunction) { case 2: $fieldValue = call_user_func($fieldFunction, $fieldName, $fieldValue, $A, $icon_arr, $extra); break; case 1: $fieldValue = call_user_func($fieldFunction, $fieldName, $fieldValue, $A, $icon_arr); break; default: break; } if ($fieldValue !== false) { # return was there, so write line $this_row = true; } else { $fieldValue = ''; // dont give emtpy fields } if (!empty($header_arr[$j]['field_class'])) { $admin_templates->set_var('class', $header_arr[$j]['field_class']); } else { $admin_templates->set_var('class', "admin-list-field"); } $admin_templates->set_var('itemtext', $fieldValue); # write field $admin_templates->parse('item_field', 'field', true); } if ($this_row) { # there was data in at least one field, so print line $r++; # switch to next color $admin_templates->set_var('cssid', $r % 2 + 1); # make alternating table color $admin_templates->parse('item_row', 'row', true); # process the complete row } $admin_templates->clear_var('item_field'); # clear field } if ($numRows == 0) { # there is no data. return notification message. if (isset($text_arr['no_data'])) { $message = $text_arr['no_data']; # there is a user-message } else { $message = $LANG_ADMIN['no_results']; # take std. } $admin_templates->set_var('message', $message); } if ($has_extras && $showSearch) { $hasArgs = strstr($form_url, '?'); if ($hasArgs) { $sep = '&'; } else { $sep = '?'; } if (!empty($query)) { # port query to next page $base_url = $form_url . $sep . 'q=' . urlencode($query) . "&query_limit={$query_limit}{$order_var_link}&direction={$direction}{$pageNavUrl}"; } else { $base_url = $form_url . $sep . "query_limit={$query_limit}{$order_var_link}&direction={$direction}{$pageNavUrl}"; } if ($num_pages > 1) { # print actual google-paging $admin_templates->set_var('google_paging', COM_printPageNavigation($base_url, $currentPage, $num_pages, $component . 'listpage=')); } else { $admin_templates->set_var('google_paging', ''); } } $admin_templates->parse('output', 'list'); // Do the actual output if (!empty($title)) { $retval .= COM_startBlock($title, $help_url, COM_getBlockTemplate('_admin_block', 'header')); } $retval .= $admin_templates->finish($admin_templates->get_var('output')); if (!empty($title)) { $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); } return $retval; }
/** * this searches for pages matching the user query and returns an array of * for the header and table rows back to search.php where it will be formated and * printed * * @query string Keywords user is looking for * @datestart date/time Start date to get results for * @dateend date/time End date to get results for * @topic string The topic they were searching in * @type string Type of items they are searching * @author string Get all results by this author * */ function MG_search($id, $page) { global $MG_albums, $_USER, $_TABLES, $_CONF, $_MG_CONF, $LANG_MG00, $LANG_MG01, $LANG_MG03; $retval = ''; $columns_per_page = $_MG_CONF['search_columns']; $rows_per_page = $_MG_CONF['search_rows']; $media_per_page = $columns_per_page * $rows_per_page; $playback_type = $_MG_CONF['search_playback_type']; $current_print_page = $page; // pull the query from the search database... $result = DB_query("SELECT * FROM {$_TABLES['mg_sort']} WHERE sort_id='" . DB_escapeString($id) . "'"); $nrows = DB_numRows($result); if ($nrows < 1) { return MG_displaySearchBox('<div class="pluginAlert">' . $LANG_MG03['no_search_found'] . '</div>'); } $S = DB_fetchArray($result); if (COM_isAnonUser()) { $sort_user = 1; } else { $sort_user = $_USER['uid']; } if ($sort_user != $S['sort_user'] && $S['sort_user'] != 1) { return MG_displaySearchBox('<div class="pluginAlert">' . $LANG_MG03['no_search_found'] . '</div>'); } $sqltmp = $S['sort_query']; $numresults = $S['sort_results']; $numresults = $media_per_page; $sql = "SELECT DISTINCT * FROM " . $_TABLES['mg_media'] . " as m " . " INNER JOIN " . $_TABLES['mg_media_albums'] . " as ma " . " ON m.media_id=ma.media_id " . $sqltmp . " ORDER BY m.media_time DESC;"; $result = DB_query($sql); $mycount = DB_numRows($result); if ($mycount < 1) { return MG_displaySearchBox('<div class="pluginAlert">' . $LANG_MG03['no_search_found'] . '</div>'); } $arrayCounter = 0; $mediaRows = 0; if ($mycount > 0) { for ($i = 0; $i < $mycount; $i++) { $row = DB_fetchArray($result); if ($MG_albums[$row['album_id']]->access == 0 || $MG_albums[$row['album_id']]->hidden == 1 && $MG_albums[0]->owner_id != 1) { continue; } $media = new Media(); $media->constructor($row, $row['album_id']); $MG_media[$arrayCounter] = $media; $M[$arrayCounter] = $row; $arrayCounter++; $mediaRows++; } } if ($mediaRows == 0) { return MG_displaySearchBox('<div class="pluginAlert">' . $LANG_MG03['no_search_found'] . '</div>'); } $page = $page - 1; $begin = $page * $numresults; $end = $page * $numresults + ($numresults - 1); $total_print_pages = ceil($mediaRows / $numresults); // new stuff $T = new Template(MG_getTemplatePath(0)); $T->set_file(array('page' => 'search_results2.thtml')); $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/search.php?id=' . $id, $page + 1, ceil($mediaRows / $numresults), '&page='), 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/search.php?id=' . $id, $page + 1, ceil($mediaRows / $numresults), '&page='), 'page_number' => sprintf("%s %d %s %d", $LANG_MG03['page'], $current_print_page, $LANG_MG03['of'], $total_print_pages), 'lang_search_results' => $LANG_MG03['search_results'], 'lang_return_to_index' => $LANG_MG03['return_to_index'], 'return_url' => $S['referer'] == '' ? $_MG_CONF['site_url'] : htmlentities($S['referer'], ENT_QUOTES, COM_getEncodingt()), 'search_keywords' => $S['keywords'], 'lang_search' => $LANG_MG01['search'])); $howmany = $mediaRows - $page * $numresults; if ($howmany > $mediaRows) { $howmany = $mediaRows; } $total_media = $mediaRows; if ($howmany == 0) { $T->set_var(array('lang_no_image' => $LANG_MG03['no_media_objects'])); $T->parse('album_noimages', 'noitems'); } $noParse = 0; if ($howmany > 0) { $k = 0; $T->set_block('page', 'ImageColumn', 'IColumn'); $T->set_block('page', 'ImageRow', 'IRow'); for ($i = $begin; $i < $media_per_page + $begin; $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); } $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_searchDisplayThumb($M[$j], 0, $id, $page + 1); 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); } $T->parse('IRow', 'ImageRow', true); $T->set_var('IColumn', ''); if ($noParse == 1) { break; } } } $T->parse('output', 'page'); $retval .= $T->finish($T->get_var('output')); return $retval; }
function MG_imageAdmin($album_id, $page, $actionURL = '') { global $album_selectbox, $MG_albums, $_USER, $_CONF, $_TABLES, $_MG_CONF, $LANG_MG00, $LANG_MG01, $_POST, $_DB_dbms; $album_cover_check = ''; if ($actionURL == '') { $actionURL = $_MG_CONF['site_url'] . '/index.php'; } if ($page > 0) { $page = $page - 1; } $begin = $_MG_CONF['mediamanage_items'] * $page; $end = $_MG_CONF['mediamanage_items']; $retval = ''; $T = new Template(MG_getTemplatePath($album_id)); $T->set_file(array('admin' => 'mediamanage.thtml', 'empty' => 'album_page_noitems.thtml', 'media' => 'mediaitems.thtml')); $T->set_var('album_id', $album_id); // -- Get Album Cover Info.. if ($MG_albums[$album_id]->access != 3) { COM_errorLog("Someone has tried to illegally edit media in Media Gallery. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return MG_genericError($LANG_MG00['access_denied_msg']); } $album_cover = $MG_albums[$album_id]->cover; $album_selectbox = '<select name="album">'; $MG_albums[0]->buildAlbumBox($album_id, 3, $album_id, 'manage'); $album_selectbox .= '</select>'; $result = DB_query("SELECT * FROM {$_TABLES['mg_category']} ORDER BY cat_id ASC"); $nRows = DB_numRows($result); $catRow = array(); for ($i = 0; $i < $nRows; $i++) { $catRow[$i] = DB_fetchArray($result); } $result = DB_query("SELECT COUNT(*) as totalitems FROM {$_TABLES['mg_media_albums']} WHERE album_id=" . intval($album_id)); $row = DB_fetchArray($result); $totalAlbumItems = $row['totalitems']; if ($_DB_dbms == "mssql") { $sql = "SELECT *,CAST(media_desc AS TEXT) AS media_desc 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($album_id) . " ORDER BY ma.media_order DESC LIMIT " . $begin . "," . $end; } else { $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($album_id) . " ORDER BY ma.media_order DESC LIMIT " . $begin . "," . $end; } $result = DB_query($sql); $nRows = DB_numRows($result); $batchOptionSelect = '<select name="batchOption">'; if ($_CONF['image_lib'] == 'gdlib' && !function_exists("imagerotate")) { $batchOptionSelect .= ''; } else { $batchOptionSelect .= '<option value="rrt">' . $LANG_MG01['rotate_right'] . '</option>'; $batchOptionSelect .= '<option value="rlt">' . $LANG_MG01['rotate_left'] . '</option>'; } if ($MG_albums[$album_id]->wm_id != 0) { $batchOptionSelect .= '<option value="watermark">' . $LANG_MG01['watermark'] . '</option>'; } $batchOptionSelect .= '</select> '; $T->set_var(array('lang_albumsel' => $LANG_MG01['destination_album'], 'albumselect' => $album_selectbox, 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_move' => $LANG_MG01['move'], 'lang_select' => $LANG_MG01['select'], 'lang_item' => $LANG_MG01['item'], 'lang_order' => $LANG_MG01['order'], 'lang_cover' => $LANG_MG01['cover'], 'lang_title' => $LANG_MG01['title'], 'lang_description' => $LANG_MG01['description'], 'lang_checkall' => $LANG_MG01['check_all'], 'lang_uncheckall' => $LANG_MG01['uncheck_all'], 'lang_rotate_right' => $LANG_MG01['rotate_right'], 'lang_rotate_left' => $LANG_MG01['rotate_left'], 'lang_batch' => $LANG_MG01['batch_process'], 'lang_media_manage_help' => $LANG_MG01['media_manage_help'], 'lang_reset_cover' => $LANG_MG01['reset_cover'], 'lang_include_ss' => $LANG_MG01['include_ss'], 'lang_watermarked' => $LANG_MG01['watermarked'], 'lang_delete_confirm' => $LANG_MG01['delete_item_confirm'], 'batchoptionselect' => $batchOptionSelect, 'lang_batch_options' => $LANG_MG01['batch_options'], 'lang_keywords' => $LANG_MG01['keywords'], 'albumselect' => $album_selectbox, 'lang_batch' => $LANG_MG01['batch_process'], 'batchoptionselect' => $batchOptionSelect)); $rowclass = 0; $counter = 0; if ($nRows == 0) { // we have nothing in the album at this time... $T->set_var(array('lang_no_image' => $LANG_MG01['no_media_objects'])); $T->parse('noitems', 'empty'); } else { $mediaObject = array(); $T->set_block('media', 'ImageColumn', 'IColumn'); $T->set_block('media', 'ImageRow', 'IRow'); for ($x = 0; $x < $nRows; $x += 3) { $T->set_var('IColumn', ''); for ($j = $x; $j < $x + 3; $j++) { if ($j >= $nRows) { break; } $row = DB_fetchArray($result); $mediaObject[] = $row; if (($row['media_type'] == 0 || $row['media_tn_attached'] == 1) && $MG_albums[$album_id]->tn_attached == 0) { if ($album_cover == $row['media_id']) { $album_cover_check = ' checked="checked"'; } else { $album_cover_check = ""; } $radio_box = '<input type="radio" name="cover" value="' . $row['media_id'] . '" ' . $album_cover_check . '/>'; } else { $radio_box = ' '; } if ($row['media_type'] == 0) { if ($row['include_ss'] == 1) { $include_ss = '<input type="checkbox" name="ss[' . $counter . ']" value="1" checked="checked"/>'; } else { $include_ss = '<input type="checkbox" name="ss[' . $counter . ']" value="1"/>'; } } else { $include_ss = ' '; } switch ($row['media_type']) { case 0: $pThumbnail = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; if (!file_exists($pThumbnail)) { $pThumbnail = $_MG_CONF['path_mediaobjects'] . 'tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.jpg'; $thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.jpg'; } else { $thumbnail = $_MG_CONF['mediaobjects_url'] . '/tn/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; } $pDisplay = $_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; if (!file_exists($pDisplay)) { $pDisplay = $_MG_CONF['path_mediaobjects'] . 'disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.jpg'; $display = $_MG_CONF['mediaobjects_url'] . '/disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.jpg'; } else { $display = $_MG_CONF['mediaobjects_url'] . '/disp/' . $row['media_filename'][0] . '/' . $row['media_filename'] . '.' . $row['media_mime_ext']; } break; default: $mediaClass = new Media(); $mediaClass->Constructor($row, $album_id); list($thumbnail, $pThumbnail) = $mediaClass->displayRawThumb(1); break; } $media_time = MG_getUserDateTimeFormat($row['media_time']); $img_size = @getimagesize($pThumbnail); if ($img_size != false) { if ($img_size[0] > $img_size[1]) { $ratio = $img_size[0] / 100; $width = 100; $height = round($img_size[1] / $ratio); } else { $ratio = $img_size[1] / 100; $height = 100; $width = round($img_size[0] / $ratio); } } else { $width = 100; $height = 100; $thumbnail = $_MG_CONF['mediaobjects_url'] . '/placeholder.svg'; $pThumbnail = $_MG_CONF['path_mediaobjects'] . 'placeholder.svg'; } $cat_select = '<select name="cat_id[]">'; $cat_select .= '<option value="0">' . $LANG_MG01['no_category'] . '</option>'; $cRows = count($catRow); for ($i = 0; $i < $cRows; $i++) { $cat_select .= '<option value="' . $catRow[$i]['cat_id'] . '" ' . ($catRow[$i]['cat_id'] == $row['media_category'] ? ' selected="selected"' : '') . '>' . $catRow[$i]['cat_name'] . '</option>'; } $cat_select .= '</select>'; $T->set_var(array('lang_category' => '<br/>' . $LANG_MG01['category'] . ' ', 'cat_select' => $cat_select, 'row_class' => $rowclass % 2 ? '1' : '2', 'media_id' => $row['media_id'], 'mid' => $row['media_id'], 'order' => $row['media_order'], 'u_thumbnail' => $thumbnail, 'media_title' => $row['media_title'], 'media_desc' => $row['media_desc'], 'media_keywords' => $row['media_keywords'], 'media_time' => $media_time[0], 'media_views' => $row['media_views'], 'radio_box' => $radio_box, 'album_cover_check' => $album_cover_check, 'include_ss' => $include_ss, 'watermarked' => $row['media_watermarked'] ? '*' : '', 'height' => $height, 'width' => $width, 'counter' => $counter, 'media_edit' => $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&mid=' . $row['media_id'] . '&album_id=' . $album_id . '&t=' . time(), 'lang_edit' => $LANG_MG01['edit'])); if ($row['media_type'] == 0) { $disp_size = @getimagesize($pDisplay); $dWidth = $disp_size[0] + 15; $dHeight = $disp_size[1] + 15; $T->set_var(array('media_zoom' => "<a href=\"#\" onclick=\"javascript:jkpopimage('" . $display . "'," . $dWidth . ',' . $dHeight . ",''); return false\">")); } else { $T->set_var(array('media_zoom' => "")); } $rowclass++; $counter++; $T->parse('IColumn', 'ImageColumn', true); } $T->parse('IRow', 'ImageRow', true); } $T->parse('mediaitems', 'media'); } $T->set_var(array('album_id' => $album_id, 'url_album' => $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id, 's_mode' => 'cover', 's_form_action' => $actionURL, 'mode' => 'media', 'action' => 'cover', 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_media_manage_help' => $LANG_MG01['media_manage_help'], 'lang_delete_confirm' => $LANG_MG01['delete_item_confirm'], 'batchoptionselect' => $batchOptionSelect)); $T->set_var(array('bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&mode=media', $page + 1, ceil($totalAlbumItems / $_MG_CONF['mediamanage_items'])))); // set language items... $T->set_var(array('albums' => $LANG_MG01['albums'])); $T->parse('output', 'admin'); $retval .= $T->finish($T->get_var('output')); return $retval; }
/** * Get the Google-style page navigation for the list display * * @param string $start Starting date * @param string $end Ending date * @param integer $cat Category ID (optional) * @param integer $page Current page number * @param integer $range Range being displayed (upcoming, past, etc) * @return string HTML for page navigation */ function EVLIST_pagenav($start, $end, $cat = 0, $page = 0, $range = 0, $cal = 0) { global $_TABLES, $_EV_CONF; $cat = (int) $cat; $range = (int) $range; $cal = (int) $cal; $limit = (int) $_EV_CONF['limit_list']; if ($limit < 1) { return ''; } $base_url = EVLIST_URL . "/index.php?cat={$cat}&cal={$cal}&range={$range}&view=list"; if (!empty($cat)) { $cat_join = " LEFT JOIN {$_TABLES['evlist_lookup']} l\n ON l.eid = ev.id "; $cat_where = " AND l.cid = '{$cat}' "; } else { $cat_join = ''; $cat_where = ''; } if ($cal > 0) { $cal_where = ' AND cal.cal_id = ' . $cal; } else { $cal_where = ''; } $sql = "SELECT count(rep.rp_id) as cnt\n FROM {$_TABLES['evlist_repeat']} rep\n LEFT JOIN {$_TABLES['evlist_events']} ev\n ON ev.id = rep.rp_ev_id\n LEFT JOIN {$_TABLES['evlist_calendars']} cal\n ON cal.cal_id = ev.cal_id\n {$cat_join}\n WHERE ev.status = 1 \n AND (\n (rep.rp_date_start <= '{$end}' AND rep.rp_date_end >= '{$start}')\n OR\n (rep.rp_date_end >= '{$start}' AND rep.rp_date_start <= '{$start}')\n OR\n (rep.rp_date_end <= '{$end}' AND rep.rp_date_start >= '{$start}')\n ) " . COM_getPermSQL('AND', 0, 2, 'ev') . ' ' . COM_getPermSQL('AND', 0, 2, 'cal') . " {$cat_where} {$cal_where}\n ORDER BY rep.rp_date_start ASC"; //echo $sql;die; $res = DB_query($sql); list($numrows) = DB_fetchArray($res); if ($numrows > $limit) { $numpages = ceil($numrows / $limit); //$baseurl = EVLIST_URL . '/index.php?' . $range . $andcat; $retval = COM_printPageNavigation($base_url, $page, $numpages); } return $retval; }
if ($total_print_pages == 0) { $total_print_pages = 1; } //$T = new Template($_CONF['path_html'] . $mb_base_path . '/templates'); $T = new Template($_CONF['path'] . 'plugins/ckeditor/templates/mediagallery'); $T->set_file(array('page' => 'mb.thtml', 'body' => 'mb_body.thtml')); $birdseed = $MG_albums[$album_id]->getPath(0, ''); $refresh = isset($_REQUEST['refresh']) ? COM_applyFilter($_REQUEST['refresh'], true) : 0; if ($refresh != 1) { // initial call $T->set_var(array('border_yes' => $_mgMB_CONF['at_border'] == 1 ? ' selected="selected"' : '', 'border_no' => $_mgMB_CONF['at_border'] == 1 ? '' : ' selected="selected"', 'algin_none' => $_mgMB_CONF['at_align'] == 'none' ? ' selected="selected"' : '', 'align_auto' => $_mgMB_CONF['at_align'] == 'auto' ? ' selected="selected"' : '', 'align_right' => $_mgMB_CONF['at_align'] == 'right' ? ' selected="selected"' : '', 'align_left' => $_mgMB_CONF['at_align'] == 'left' ? ' selected="selected"' : '', 'width' => $_mgMB_CONF['at_width'], 'height' => $_mgMB_CONF['at_height'], 'delay' => $_mgMB_CONF['at_delay'], 'src_tn' => $_mgMB_CONF['at_src'] == 'tn' ? ' selected="selected"' : '', 'src_disp' => $_mgMB_CONF['at_src'] == 'disp' ? ' selected="selected"' : '', 'src_orig' => $_mgMB_CONF['at_src'] == 'orig' ? ' selected="selected"' : '', 'autoplay_yes' => $_mgMB_CONF['at_autoplay'] == 1 ? ' selected="selected"' : '', 'autoplay_no' => $_mgMB_CONF['at_autoplay'] == 1 ? '' : ' selected="selected"', 'link_yes' => $_mgMB_CONF['at_enable_link'] == 1 ? ' selected="selected"' : '', 'link_no' => $_mgMB_CONF['at_enable_link'] == 1 ? '' : ' selected="selected"', 'alturl_no' => isset($_mgMB_CONF['at_alt_url']) && $_mgMB_CONF['at_alt_url'] == 1 ? '' : ' selected="selected"', 'alturl_yes' => isset($_mgMB_CONF['at_alt_url']) && $_mgMB_CONF['at_alt_url'] == 1 ? ' selected="selected"' : '')); } else { $T->set_var(array('border_yes' => $_POST['border'] == 1 ? ' selected="selected"' : '', 'border_no' => $_POST['border'] == 1 ? '' : ' selected="selected"', 'align_none' => $_POST['alignment'] == 'none' ? ' selected="selected"' : '', 'align_auto' => $_POST['alignment'] == 'auto' ? ' selected="selected"' : '', 'align_right' => $_POST['alignment'] == 'right' ? ' selected="selected"' : '', 'align_left' => $_POST['alignment'] == 'left' ? ' selected="selected"' : '', 'width' => $_POST['width'], 'height' => $_POST['height'], 'delay' => isset($_POST['delay']) ? $_POST['delay'] : $_mgMB_CONF['at_delay'], 'src_tn' => $_POST['source'] == 'tn' ? ' selected="selected"' : '', 'src_disp' => $_POST['source'] == 'disp' ? ' selected="selected"' : '', 'src_orig' => $_POST['source'] == 'orig' ? ' selected="selected"' : '', 'autoplay_yes' => $_POST['autoplay'] == 1 ? ' selected="selected"' : '', 'autoplay_no' => $_POST['autoplay'] == 1 ? '' : ' selected="selected"', 'link_yes' => $_POST['link'] == 1 ? ' selected="selected"' : '', 'link_no' => $_POST['link'] == 1 ? '' : ' selected="selected"', 'alturl_yes' => $_POST['alturl'] == 1 ? ' selected="selected"' : '', 'alturl_no' => $_POST['alturl'] == 1 ? '' : ' selected="selected"', 'albumon' => $_POST['autotag'] == 'album' ? ' checked=checked' : '', 'slideshowon' => $_POST['autotag'] == 'slideshow' ? ' checked=checked' : '', 'fslideshowon' => $_POST['autotag'] == 'fslideshow' ? ' checked=checked' : '', 'mediaon' => $_POST['autotag'] == 'media' ? ' checked=checked' : '', 'mlinkon' => $_POST['autotag'] == 'mlink' ? ' checked=checked' : '', 'imgon' => $_POST['autotag'] == 'img' ? ' checked=checked' : '', 'videoon' => $_POST['autotag'] == 'video' ? ' checked=checked' : '', 'audioon' => $_POST['autotag'] == 'audio' ? 'checked=checked' : '', 'playallon' => $_POST['autotag'] == 'playall' ? 'checked=checked' : '', 'caption' => $_POST['caption'])); } $self_url = @htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, COM_getEncodingt()); $T->set_var(array('s_form_action' => $self_url, 'site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'album_title' => PLG_replaceTags($MG_albums[$album_id]->title), 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($self_url . '?aid=' . $album_id . '&i=' . $instance . '&refresh=1', $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($self_url . '?aid=' . $album_id . '&i=' . $instance . '&refresh=1', $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_full, 'jumpbox_raw' => $album_jumpbox_raw, 'album_id' => $album_id, 'instance' => $instance, 'lang_menulabel' => $LANG_mgMB['menulabel'], 'lang_select_album' => $LANG_mgMB['select_album'], 'lang_go' => $LANG_mgMB['go'], 'lang_error_header' => $LANG_mgMB['error_header'], 'lang_current_album' => $LANG_mgMB['current_album'], 'lang_autotag_attr' => $LANG_mgMB['autotag_attr'], 'lang_album' => $LANG_mgMB['album'], 'lang_playall' => $LANG_mgMB['playall'], 'lang_slideshow' => $LANG_mgMB['slideshow'], 'lang_fslideshow' => $LANG_mgMB['fslideshow'], 'lang_media' => $LANG_mgMB['media'], 'lang_mlink' => $LANG_mgMB['mlink'], 'lang_img' => $LANG_mgMB['img'], 'lang_video' => $LANG_mgMB['video'], 'lang_audio' => $LANG_mgMB['audio'], 'lang_width' => $LANG_mgMB['width'], 'lang_height' => $LANG_mgMB['height'], 'lang_delay' => $LANG_mgMB['delay'], 'lang_border' => $LANG_mgMB['border'], 'lang_alignment' => $LANG_mgMB['alignment'], 'lang_source' => $LANG_mgMB['source'], 'lang_link' => $LANG_mgMB['link'], 'lang_autoplay' => $LANG_mgMB['autoplay'], 'lang_caption' => $LANG_mgMB['caption'], 'lang_thumbnails' => $LANG_mgMB['thumbnails'], 'lang_navigation' => $LANG_mgMB['navigation'], 'lang_insert' => $LANG_mgMB['insert'], 'lang_cancel' => $LANG_mgMB['cancel'], 'lang_yes' => $LANG_mgMB['yes'], 'lang_no' => $LANG_mgMB['no'], 'lang_auto' => $LANG_mgMB['auto'], 'lang_none' => $LANG_mgMB['none'], 'lang_right' => $LANG_mgMB['right'], 'lang_left' => $LANG_mgMB['left'], 'lang_thumbnail' => $LANG_mgMB['thumbnail'], 'lang_display' => $LANG_mgMB['display'], 'lang_original' => $LANG_mgMB['original'], 'lang_alturl' => $LANG_mgMB['alturl'], 'lang_ribbon' => $LANG_mgMB['ribbon'], 'lang_link_src' => $LANG_mgMB['link_src'], 'lang_showtitle' => $LANG_mgMB['showtitle'], 'lang_top' => $LANG_mgMB['top'], 'lang_bottom' => $LANG_mgMB['bottom'], 'destination' => $_mgMB_CONF['enable_dest'] == 1 ? '<p>' . $LANG_mgMB['destination'] . ' <select name="dest"><option value="story">' . $LANG_mgMB['story'] . '</option><option value="block">' . $LANG_mgMB['block'] . '</option></select>' : '', 'lang_select_album' => $LANG_mgMB['select_album'])); if ($total_media == 0) { $T->set_var('lang_no_image', $LANG_MG03['no_media_objects']); $T->parse('album_noimages', 'noitems'); } if ($total_media > 0) { $k = 0; $T->set_block('body', 'ImageDetail', 'IDetail'); $T->set_block('body', 'ImageColumn', 'IColumn'); $T->set_block('body', 'ImageRow', 'IRow'); for ($i = 0; $i < $media_per_page; $i += $columns_per_page) { $T->set_var('IDetail', ''); $T->set_var('IColumn', ''); for ($j = $i; $j < $i + $columns_per_page; $j++) { if ($j >= $total_media) { $k = $i + $columns_per_page - $j;
function MG_imageAdmin($album_id, $page, $actionURL = '') { global $_CONF, $_TABLES, $_USER, $_MG_CONF, $LANG_MG00, $LANG_MG01; $album = new mgAlbum($album_id); if ($actionURL == '') { $actionURL = $_MG_CONF['site_url'] . '/index.php'; } if ($page > 0) { $page = $page - 1; } $begin = $_MG_CONF['mediamanage_items'] * $page; $end = $_MG_CONF['mediamanage_items']; $retval = ''; $T = COM_newTemplate(MG_getTemplatePath($album_id)); $T->set_file(array('admin' => 'mediamanage.thtml', 'media' => 'mediaitems.thtml')); // -- Get Album Cover Info.. if ($album->access != 3) { COM_errorLog("Someone has tried to illegally edit media in Media Gallery. " . "User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: {$REMOTE_ADDR}", 1); return COM_showMessageText($LANG_MG00['access_denied_msg']); } $album_cover = $album->cover; $album_selectbox = '<select name="album">'; $root_album = new mgAlbum(0); $root_album->buildAlbumBox($album_selectbox, $album_id, 3, $album_id, 'manage'); $album_selectbox .= '</select>'; $sql = "SELECT * FROM {$_TABLES['mg_category']} ORDER BY cat_id ASC"; $result = DB_query($sql); $nrows = DB_numRows($result); for ($i = 0; $i < $nrows; $i++) { $catRow[$i] = DB_fetchArray($result); } $sql = "SELECT COUNT(*) AS totalitems " . "FROM {$_TABLES['mg_media_albums']} " . "WHERE album_id=" . intval($album_id); $result = DB_query($sql); $row = DB_fetchArray($result); $totalAlbumItems = $row['totalitems']; $sql = MG_buildMediaSql(array('album_id' => $album_id, 'offset' => $begin, 'limit' => $end)); $result = DB_query($sql); $nrows = DB_numRows($result); $batchOptionSelect = '<select name="batchOption">'; if ($_CONF['image_lib'] == 'gdlib' && !function_exists("imagerotate")) { $batchOptionSelect .= ''; } else { $batchOptionSelect .= '<option value="rrt">' . $LANG_MG01['rotate_right'] . '</option>'; $batchOptionSelect .= '<option value="rlt">' . $LANG_MG01['rotate_left'] . '</option>'; } if ($album->wm_id != 0) { $batchOptionSelect .= '<option value="watermark">' . $LANG_MG01['watermark'] . '</option>'; } $batchOptionSelect .= '</select> '; $T->set_var(array('album_id' => $album_id, 'lang_albumsel' => $LANG_MG01['destination_album'], 'albumselect' => $album_selectbox, 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_move' => $LANG_MG01['move'], 'lang_select' => $LANG_MG01['select'], 'lang_item' => $LANG_MG01['item'], 'lang_order' => $LANG_MG01['order'], 'lang_cover' => $LANG_MG01['cover'], 'lang_title' => $LANG_MG01['title'], 'lang_description' => $LANG_MG01['description'], 'lang_checkall' => $LANG_MG01['check_all'], 'lang_uncheckall' => $LANG_MG01['uncheck_all'], 'lang_rotate_right' => $LANG_MG01['rotate_right'], 'lang_rotate_left' => $LANG_MG01['rotate_left'], 'lang_batch' => $LANG_MG01['batch_process'], 'lang_media_manage_title' => $LANG_MG01['manage_media'], 'lang_media_manage_help' => $LANG_MG01['media_manage_help'], 'lang_reset_cover' => $LANG_MG01['reset_cover'], 'lang_include_ss' => $LANG_MG01['include_ss'], 'lang_watermarked' => $LANG_MG01['watermarked'], 'lang_delete_confirm' => $LANG_MG01['delete_item_confirm'], 'batchoptionselect' => $batchOptionSelect, 'lang_batch_options' => $LANG_MG01['batch_options'], 'lang_keywords' => $LANG_MG01['keywords'], 'albumselect' => $album_selectbox, 'lang_batch' => $LANG_MG01['batch_process'], 'batchoptionselect' => $batchOptionSelect, 'val_reset_cover' => $album_cover == '-1' ? ' checked="checked"' : '')); $tn_size = 1; // include:150x150 $rowclass = 0; $counter = 0; if ($nrows == 0) { // we have nothing in the album at this time... $T->set_var('lang_no_image', $LANG_MG01['no_media_objects']); } else { $T->set_block('media', 'ImageColumn', 'IColumn'); $T->set_block('media', 'ImageRow', 'IRow'); for ($x = 0; $x < $nrows; $x += 3) { $T->set_var('IColumn', ''); for ($j = $x; $j < $x + 3; $j++) { if ($j >= $nrows) { break; } $row = DB_fetchArray($result); $album_cover_check = ''; $radio_box = ' '; if (($row['media_type'] == 0 || $row['media_tn_attached'] == 1) && $album->tn_attached == 0) { $checked = $album_cover == $row['media_id'] ? ' checked="checked"' : ''; $radio_box = '<input type="radio" name="cover" value="' . $row['media_id'] . '"' . $checked . XHTML . '>'; $album_cover_check = $checked; } $include_ss = ' '; if ($row['media_type'] == 0) { $checked = $row['include_ss'] == 1 ? ' checked="checked"' : ''; $include_ss = '<input type="checkbox" name="ss[' . $counter . ']" value="1"' . $checked . XHTML . '>'; } switch ($row['media_type']) { case 0: // standard image list($thumbnail, $pThumbnail, $img_size) = Media::getThumbInfo($row, $tn_size); $fname = $row['media_filename']; $ext = $row['media_mime_ext']; $pDisplay = Media::getFilePath('disp', $fname, $ext); $display = Media::getFileUrl('disp', $fname, $ext); break; default: $mediaClass = new Media($row, $album_id); list($thumbnail, $pThumbnail) = $mediaClass->displayRawThumb(1); $img_size = @getimagesize($pThumbnail); break; } $media_time = MG_getUserDateTimeFormat($row['media_time']); if ($img_size != false) { list($width, $height) = Media::getImageWH($img_size[0], $img_size[1], 150, 150); } else { //$width = 100; //$height = 75; $width = 150; $height = 112; $thumbnail = $_MG_CONF['mediaobjects_url'] . '/missing.png'; } $cat_select = '<select name="cat_id[]">'; $cat_select .= '<option value="0">' . $LANG_MG01['no_category'] . '</option>'; $cRows = count($catRow); for ($i = 0; $i < $cRows; $i++) { $cat_select .= '<option value="' . $catRow[$i]['cat_id'] . '" ' . ($catRow[$i]['cat_id'] == $row['media_category'] ? ' selected="selected"' : '') . '>' . $catRow[$i]['cat_name'] . '</option>'; } $cat_select .= '</select>'; $media_edit = $_MG_CONF['site_url'] . '/admin.php?mode=mediaedit&mid=' . $row['media_id'] . '&album_id=' . $album_id . '&t=' . time(); $opt = array('playback_type' => 0, 'skin' => 'default', 'display_skin' => 'default', 'full_display' => 0); $object = MG_buildContent($row, $opt); $media_zoom = '<a href="' . $object[4] . '">'; $T->set_var(array('lang_category' => $LANG_MG01['category'], 'cat_select' => $cat_select, 'row_class' => $rowclass % 2 ? '1' : '2', 'media_id' => $row['media_id'], 'mid' => $row['media_id'], 'order' => $row['media_order'], 'u_thumbnail' => $thumbnail, 'media_title' => $row['media_title'], 'media_desc' => $row['media_desc'], 'media_keywords' => $row['media_keywords'], 'media_time' => $media_time[0], 'media_views' => $row['media_views'], 'radio_box' => $radio_box, 'album_cover_check' => $album_cover_check, 'include_ss' => $include_ss, 'watermarked' => $row['media_watermarked'] ? '*' : '', 'height' => $height, 'width' => $width, 'counter' => $counter, 'media_edit' => $media_edit, 'media_zoom' => $media_zoom, 'lang_edit' => $LANG_MG01['edit'])); $rowclass++; $counter++; $T->parse('IColumn', 'ImageColumn', true); } $T->parse('IRow', 'ImageRow', true); } $T->parse('mediaitems', 'media'); } $T->set_var(array('album_id' => $album_id, 'url_album' => $_MG_CONF['site_url'] . '/album.php?aid=' . $album_id, 's_mode' => 'cover', 's_form_action' => $actionURL, 'mode' => 'media', 'action' => 'cover', 'lang_save' => $LANG_MG01['save'], 'lang_cancel' => $LANG_MG01['cancel'], 'lang_delete' => $LANG_MG01['delete'], 'lang_media_manage_help' => $LANG_MG01['media_manage_help'], 'lang_delete_confirm' => $LANG_MG01['delete_item_confirm'], 'albums' => $LANG_MG01['albums'], 'batchoptionselect' => $batchOptionSelect, 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/admin.php?album_id=' . $album_id . '&mode=media', $page + 1, ceil($totalAlbumItems / $_MG_CONF['mediamanage_items'])))); $retval .= $T->finish($T->parse('output', 'admin')); return $retval; }
function MG_quotaReport($page, $quotaquery, $usedquery) { global $glversion, $_TABLES, $_MG_CONF, $_CONF, $LANG_MG01, $LANG_MG03; $counter = 0; $rowcounter = 0; $retval = ''; $start = $page * 50; $end = 50; $T = new Template($_MG_CONF['template_path']); $T->set_file('report', 'quotareport.thtml'); $T->set_var(array('lang_username' => $LANG_MG01['username'], 'lang_active' => $LANG_MG01['active'], 'lang_quota' => $LANG_MG01['quota'], 'lang_used' => $LANG_MG01['used'], 'lang_select' => $LANG_MG01['select'], 'xhtml' => XHTML)); $T->set_block('report', 'UserRow', 'uRow'); if ($quotaquery > 0) { $quotaselect = $quotaquery * 1048676; } else { $quotaselect = 0; } $tres = DB_query("SELECT COUNT(gl.uid) AS count " . "FROM {$_TABLES['users']} AS gl LEFT JOIN {$_TABLES['mg_userprefs']} AS mg ON gl.uid=mg.uid " . "WHERE gl.status = 3 AND gl.uid > 2 AND mg.member_gallery=1 AND mg.quota >= " . $quotaselect); $trow = DB_fetchArray($tres); $total_records = $trow['count']; $sql = "SELECT gl.uid, gl.status, gl.username, gl.fullname, mg.member_gallery, mg.quota " . "FROM {$_TABLES['users']} AS gl LEFT JOIN {$_TABLES['mg_userprefs']} AS mg ON gl.uid=mg.uid " . "WHERE gl.status = 3 AND gl.uid > 2 AND mg.member_gallery=1 AND mg.quota >= " . $quotaselect . " ORDER BY gl.username ASC LIMIT {$start},{$end}"; $result = DB_query($sql); while ($userRow = DB_fetchArray($result)) { $uid = $userRow['uid']; $active = DB_getItem($_TABLES['mg_userprefs'], 'active', "uid=" . intval($uid)); $user_quota = DB_getItem($_TABLES['mg_userprefs'], 'quota', "uid=" . intval($uid)); $quota_mb = $user_quota / 1048676; $quota = number_format($quota_mb, 2); $used_mb = (double) MG_quotaUsage($uid) / 1048576; $used = number_format($used_mb, 2); $show = 1; if ($quotaquery > 0) { // limit based on quota $show = $quota_mb >= $quotaquery ? 1 : 0; } if ($show) { $T->set_var(array('result_row' => $rowcounter, 'rowclass' => $rowcounter % 2 ? '2' : '1', 'username' => '<a href="' . $_MG_CONF['admin_url'] . 'edituser.php?uid=' . $uid . '">' . $userRow['username'] . " (" . $userRow['fullname'] . ")</a>", 'uid' => $uid, 'quota' => $quota == 0 ? 'Unlimited' : $quota, 'used' => $used, 'active' => $active)); $T->parse('uRow', 'UserRow', true); $rowcounter++; $counter++; } } $T->set_var(array('site_admin_url' => $_MG_CONF['admin_url'], 'used' => $usedquery, 'quota' => $quotaquery, 'lang_go' => $LANG_MG03['go'], 'lang_quota' => $LANG_MG01['quota'], 'lang_used' => $LANG_MG01['used'], 'lang_batch_update' => $LANG_MG01['batch_quota_update'], 'lang_update' => $LANG_MG01['update'], 'pagenav' => COM_printPageNavigation($_MG_CONF['admin_url'] . 'quotareport.php', $page + 1, ceil($total_records / 50)))); $retval .= $T->finish($T->parse('output', 'report')); return $retval; }
/** * Takes an article class and renders HTML in the specified template and style. * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param Story $story The story to display, an instance of the Story class. * @param string $index n = Full display of article. p = 'Preview' mode. Else introtext only. * @param string $storyTpl The template to use to render the story. * @param string $query A search query, if one was specified. * @return string Article as formatted HTML. * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle($story, $index = '', $storyTpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode; static $storyCounter = 0; if ($story->DisplayElements('featured') == 1) { $article_filevar = 'featuredarticle'; } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $story->DisplayElements('expire') <= time()) { $article_filevar = 'archivearticle'; } else { $article_filevar = 'article'; } if (empty($storyTpl)) { $storyTpl = 'storytext.thtml'; } // Change article template file with the topic (feature request #275) $templateDir = $_CONF['path_layout']; $topicDir = $templateDir . 'topics/' . $story->DisplayElements('tid') . '/'; if (is_dir($topicDir) && file_exists($topicDir . $storyTpl)) { $templateDir = $topicDir; } $article = COM_newTemplate($templateDir); $article->set_file(array('article' => $storyTpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); // begin instance caching... $cache_time = $story->DisplayElements('cache_time'); $current_article_tid = $story->DisplayElements('tid'); $retval = false; // If stays false will rebuild article and not used cache (checks done below) if ($cache_time > 0 || $cache_time == -1) { $hash = CACHE_security_hash(); $cacheInstance = 'article__' . $story->getSid() . '_' . $index . $mode . '_' . $article_filevar . '_' . $current_article_tid . '_' . $hash . '_' . $_USER['theme']; if ($_CONF['cache_templates']) { $retval = $article->check_instance($cacheInstance, $article_filevar); } else { $retval = CACHE_check_instance($cacheInstance); } if ($retval && $cache_time == -1) { // Cache file found so use it since no time limit set to recreate } elseif ($retval && $cache_time > 0) { $lu = CACHE_get_instance_update($cacheInstance); $now = time(); if ($now - $lu < $cache_time) { // Cache file found so use it since under time limit set to recreate } else { // generate article and create cache file // Cache time is not built into template caching so need to delete it manually and reset $retval if ($_CONF['cache_templates']) { // Need to close and recreate template class since issues arise when theme templates are cached unset($article); // Close template class CACHE_remove_instance($cacheInstance); $article = COM_newTemplate($_CONF['path_layout']); $article->set_file(array('article' => $storyTpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); } else { // theme templates are not cache so can go ahead and delete story cache CACHE_remove_instance($cacheInstance); } $retval = false; } } else { // Need to reset especially if caching is disabled for a certain story but template caching has been enabled for the theme $retval = false; } } $articleUrl = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('article_url', $articleUrl); $article->set_var('story_title', $story->DisplayElements('title')); // Date formatting set by user therefore cannot be cached $article->set_var('story_date', $story->DisplayElements('date'), false, true); $article->set_var('story_datetime', $story->DisplayElements('datetime'), false, true); // Story views increase with every visit so cannot be cached if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106], false, true); $article->set_var('story_hits', $story->DisplayElements('hits'), false, true); } // Topic Icon is user configurable so do not cache $topicname = $story->DisplayElements('topic'); $topicurl = COM_buildURL($_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid')); if ((!isset($_USER['noicons']) || $_USER['noicons'] != 1) && $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl, false, true); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array()), false, true); $article->set_var('story_topic_image', $topicimage, false, true); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array()), false, true); $article->set_var('story_topic_image_no_align', $topicimage_noalign, false, true); } } // Main article content if ($index == 'p') { $introtext = $story->getPreviewText('introtext'); $bodytext = $story->getPreviewText('bodytext'); } else { $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); } $readmore = empty($bodytext) ? 0 : 1; $numwords = COM_numberFormat(count(explode(' ', COM_getTextContent($bodytext)))); if (COM_onFrontpage()) { $bodytext = ''; } if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } // Create article only if preview, or query not empty, or if no cache version or cache version is not required if ($index == 'p' || !empty($query) || !$retval) { $article->set_var('article_filevar', ''); $article->set_var('site_name', $_CONF['site_name']); //$article->set_var( 'story_date', $story->DisplayElements('date') ); $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); $article->set_var('story_id', $story->getSid()); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('contributedby_author', $authorname); $article->set_var('author', $authorname); $profileUrl = ''; if ($story->DisplayElements('uid') > 1) { $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); $article->set_var('start_contributedby_anchortag', '<a class="storybyline" href="' . $profileUrl . '" rel="author">'); $article->set_var('end_contributedby_anchortag', '</a>'); $article->set_var('contributedby_url', $profileUrl); } $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('story_topic_name', $topicname); $article->set_var('story_topic_url', $topicurl); $recent_post_anchortag = ''; $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = Full display of article. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } $related_topics = ''; if ($index == 'n') { if ($_CONF['supported_version_theme'] == '1.8.1') { $article->set_var('breadcrumb_trail', TOPIC_breadcrumbs('article', $story->getSid())); } if ($_CONF['related_topics'] > 0) { $related_topics = TOPIC_relatedTopics('article', $story->getSid(), $_CONF['related_topics_max']); $article->set_var('related_topics', $related_topics); } } elseif ($index != 'p') { if ($_CONF['related_topics'] > 1) { $related_topics = TOPIC_relatedTopics('article', $story->getSid(), $_CONF['related_topics_max']); $article->set_var('related_topics', $related_topics); } } $page_selector = ''; $readmore_link = ''; $post_comment_link = ''; $plugin_itemdisplay = ''; $comments_with_count = ''; $trackbacks_with_count = ''; if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 && $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $page_break_count = count($article_array); if ($story_page > $page_break_count) { // Can't have page count greater than actual number of pages $story_page = $page_break_count; } $page_selector = COM_printPageNavigation($articleUrl, $story_page, $page_break_count, 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $page_selector); if ($_CONF['page_break_comments'] == 'last' && $story_page < count($article_array) || $_CONF['page_break_comments'] == 'first' && $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br' . XHTML . '><br' . XHTML . '>' . $bodytext); $article->set_var('story_text_no_br', $introtext . ' ' . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if ($readmore) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $article->set_var('readmore_words', $numwords); $readmore_link = COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '; $article->set_var('readmore_link', $readmore_link); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); } if ($story->DisplayElements('commentcode') >= 0 && $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . $story->getSid() . "' ORDER BY date DESC LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $comments_with_count = COM_createLink($comments_with_count, $commentsUrl); $article->set_var('comments_with_count', $comments_with_count); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); if ($_CONF['comment_on_same_page'] == true) { $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '#commenteditform'); } else { $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'); if ($_CONF['show_comments_at_replying'] == true) { $recent_post_anchortag .= '#commenteditform'; } } } if ($story->DisplayElements('commentcode') == 0) { if ($_CONF['comment_on_same_page'] == true) { $postCommentUrl = $_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '#commenteditform'; } else { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'; if ($_CONF['show_comments_at_replying'] == true) { $postCommentUrl .= '#commenteditform'; } } $post_comment_link = COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow')); $article->set_var('post_comment_link', $post_comment_link); /* $article->set_var( 'subscribe_link', COM_createLink('Nubbies', '', array('rel' => 'nofollow')) ); */ $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } $trackbacks_with_count = sprintf($LANG01[122], $num_trackbacks); if ($story->DisplayElements('trackbacks') > 0) { $trackbacks_with_count = COM_createLink($trackbacks_with_count, $trackbacksUrl); } $article->set_var('trackbacks_with_count', $trackbacks_with_count); } if ($_CONF['hideemailicon'] == 1 || COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '"' . XHTML . '>'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '"' . XHTML . '>'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('story_display', 'index'); $storyCounter++; $article->set_var('story_counter', $storyCounter); } $article->set_var('recent_post_anchortag', $recent_post_anchortag); if ($index != 'p' && SEC_hasRights('story.edit') && $story->checkAccess() == 3 && TOPIC_hasMultiTopicAccess('article', $story->DisplayElements('sid')) == 3) { $editUrl = $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid(); $editiconhtml = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>'; $article->set_var('edit_link', COM_createLink($LANG01[4], $editUrl)); $article->set_var('edit_url', $editUrl); $article->set_var('lang_edit_text', $LANG01[4]); $article->set_var('edit_icon', COM_createLink($editiconhtml, $editUrl, array('class' => 'editlink'))); $article->set_var('edit_image', $editiconhtml); } $navi_list = true; $feedback_list = true; if ($index == 'p') { $navi_list = false; $feedback_list = false; } else { $navi_list = $page_selector !== '' || $readmore_link !== '' || $post_comment_link !== ''; $feedback_list = $plugin_itemdisplay !== '' || $comments_with_count !== '' || $trackbacks_with_count !== ''; } $story_footer = $navi_list || $feedback_list || $related_topics !== ''; $article->set_var('navi_list', $navi_list); $article->set_var('feedback_list', $feedback_list); $article->set_var('story_footer', $story_footer); if ($story->DisplayElements('featured') == 1) { $article->set_var('lang_todays_featured_article', $LANG05[4]); $article->parse('story_bodyhtml', 'featuredbodytext', true); PLG_templateSetVars('featuredstorytext', $article); } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $story->DisplayElements('expire') <= time()) { $article->parse('story_bodyhtml', 'archivestorybodytext', true); PLG_templateSetVars('archivestorytext', $article); } else { $article->parse('story_bodyhtml', 'bodytext', true); PLG_templateSetVars('storytext', $article); } // Add related articles if ($index === 'n') { $article->set_var('related_articles_by_keyword', Story::getRelatedArticlesByKeywords($story->getSid(), $story->DisplayElements('meta_keywords'))); } PLG_templateSetVars($article_filevar, $article); if ($index != 'p' && ($cache_time > 0 || $cache_time == -1)) { $article->create_instance($cacheInstance, $article_filevar); // CACHE_create_instance($cacheInstance, $article); } } else { PLG_templateSetVars($article_filevar, $article); if (!$_CONF['cache_templates']) { // Hack (see Geeklog Bug Tracker issue #0001817): Cannot set the template variable directly with set_var since // this template variable was set with set_file which uses the templatecode array (set_var uses varvals array) // so have to update the templatecode array directly. This array really shouldn't be accessed this way // and this hack should be changed in the future: either set_var or set_file functions need to allow update of the file template variable found in templatecode // $article->set_var($article_filevar, $retval); $article->templateCode[$article_filevar] = $retval; } } $article->parse('finalstory', $article_filevar); return $article->finish($article->get_var('finalstory')); }
$sort_box_raw .= '<option value="9" ' . ($sortOrder == 9 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_views_asc'] . '</option>'; $sort_box_raw .= '<option value="10" ' . ($sortOrder == 10 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha'] . '</option>'; $sort_box_raw .= '<option value="11" ' . ($sortOrder == 11 ? ' selected="selected" ' : '') . '>' . $LANG_MG03['sort_alpha_asc'] . '</option>'; } 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=" . intval($owner_id)); $album_last_update = MG_getUserDateTimeFormat($MG_albums[$album_id]->last_update); $T = new Template(MG_getTemplatePath($album_id)); $T->set_file(array('page' => 'album_page.thtml', 'noitems' => 'album_page_noitems.thtml')); SESS_setVar('mediagallery.album.page', $page + 1); $T->set_var(array('site_url' => $_MG_CONF['site_url'], 'birdseed' => $birdseed, 'birdseed_ul' => $birdseedUL, 'album_title' => PLG_replaceTags($MG_albums[$album_id]->title, 'mediagallery', 'album_title'), 'url_slideshow' => $url_slideshow, 'table_columns' => $columns_per_page, 'table_column_width' => intval(100 / $columns_per_page) . '%', 'top_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&sort=' . $sortOrder, $page + 1, ceil($total_items_in_album / $media_per_page)), 'bottom_pagination' => COM_printPageNavigation($_MG_CONF['site_url'] . '/album.php?aid=' . $album_id . '&sort=' . $sortOrder, $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_jumpbox_raw' => $album_jumpbox_raw, 'album_id' => $album_id, 'lbslideshow' => $lbSlideShow, 'album_description' => $MG_albums[$album_id]->display_album_desc ? PLG_replaceTags($MG_albums[$album_id]->description, 'mediagallery', 'album_description') : '', 'album_id_display' => $MG_albums[0]->owner_id || $_MG_CONF['enable_media_id'] == 1 ? $LANG_MG03['album_id_display'] . $album_id : '', 'lang_slideshow' => $lang_slideshow, 'select_adminbox' => $admin_box, 'admin_box_items' => $admin_box_items, 'admin_menu' => $admin_menu, 'select_sortbox' => $sort_box, 'select_sortbox_raw' => $sort_box_raw, 'album_last_update' => $album_last_update[0], 'album_owner' => $ownername, 'media_count' => $MG_albums[$album_id]->getMediaCount(), 'lang_search' => $LANG_MG01['search'])); if ($MG_albums[$album_id]->enable_rss) { $rssfeedname = sprintf($_MG_CONF['rss_feed_name'] . "%06d", $album_id); $feedUrl = MG_getFeedUrl($rssfeedname . '.rss'); $rsslink = '<a href="' . $feedUrl . '"' . ' type="application/rss+xml">'; $rsslink .= '<img src="' . MG_getImageFile('feed.png') . '" style="border:none;" alt=""/></a>'; $T->set_var('rsslink', $rsslink); } else { $T->set_var('rsslink', ''); } $subscribe = ''; if (!COM_isAnonUser()) { if (PLG_isSubscribed('mediagallery', '', $album_id, $_USER['uid'])) { $subscribe = '<a class="subscribelink" href="' . $_MG_CONF['site_url'] . '/subscription.php?op=unsubscribe&sid=' . $album_id . '">' . $LANG01['unsubscribe'] . '</a>'; $subscribe_url = $_MG_CONF['site_url'] . '/subscription.php?op=unsubscribe&sid=' . $album_id; $subscribe_text = $LANG01['unsubscribe'];