Source for file index.php
Documentation is available at index.php
/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// +---------------------------------------------------------------------------+
// | This is the main page for the Geeklog Links Plugin |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2010 by the following authors: |
// | Authors: Tony Bibbs - tony AT tonybibbs DOT com |
// | Mark Limburg - mlimburg AT users DOT sourceforge DOT net |
// | Jason Whittenburg - jwhitten AT securitygeeks DOT com |
// | Tom Willett - tomw AT pigstye DOT net |
// | Trinity Bays - trinity93 AT gmail DOT com |
// | Dirk Haun - dirk AT haun-online DOT de |
// +---------------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public License |
// | as published by the Free Software Foundation; either version 2 |
// | of the License, or (at your option) any later version. |
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software Foundation, |
// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// +---------------------------------------------------------------------------+
* @subpackage public_html
* @copyright Copyright © 2005-2010
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
* @author Tony Bibbs, tony AT tonybibbs DOT com
* @author Mark Limburg, mlimburg AT users DOT sourceforge DOT net
* @author Jason Whittenburg, jwhitten AT securitygeeks DOT com
* @author Tom Willett, tomw AT pigstye DOT net
* @author Trinity Bays, trinity93 AT gmail DOT com
* @author Dirk Haun, dirk AT haun-online DOT de
* Geeklog common function library
require_once '../lib-common.php';
* Create the links list depending on the category given
* @param array $message message(s) to display
* @return string the links page
global $_CONF, $_TABLES, $_LI_CONF, $LANG_LINKS_ADMIN, $LANG_LINKS,
$cid = $_LI_CONF['root'];
if (isset ($_GET['category'])) {
} elseif (isset ($_POST['category'])) {
if (isset ($_GET['page'])) {
$page_title = sprintf ($LANG_LINKS[114] . ' (%d)', $page);
$page_title = $LANG_LINKS[114];
if ($cid == $_LI_CONF['root']) {
$category = $LANG_LINKS['root'];
$category = DB_getItem($_TABLES['linkcategories'], 'category',
$page_title = sprintf ($LANG_LINKS[114] . ': %s (%d)', $category,
$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}'");
if (SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) < 2) {
if ( !isset ($A['owner_id']) ) {
if (is_array($message) && !empty($message[0])) {
} else if (isset ($_REQUEST['msg'])) {
$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'));
if ($_LI_CONF['linkcols'] > 0) {
// Create breadcrumb trail
$linklist->set_var('breadcrumbs',
// Set dropdown for category jump
$linklist->set_var('lang_go', $LANG_LINKS[124]);
$sql = "SELECT cid,pid,category,description FROM {$_TABLES['linkcategories']} WHERE pid='{$cat}'";
$linklist->set_var ('lang_categories', $LANG_LINKS_ADMIN[14]);
for ($i = 1; $i <= $nrows; $i++ ) {
// Get number of child links user can see in this category
$result1 = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$ccid}'" . COM_getPermSQL('AND'));
// 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'));
// Format numbers for display
if (($E['count']> 0) && ($D['count']> 0)) {
// 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'] ));
$linklist->set_var ('category_description', '');
$linklist->set_var ('category_link', $_CONF['site_url'] .
$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);
$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);
$linklist->set_var ('category_navigation', '');
$linklist->set_var ('category_navigation', '');
if ($_LI_CONF['linkcols'] == 0) {
$linklist->set_var('category_dropdown', '');
$linklist->parse('category_dropdown', 'catdrop', true);
$linklist->set_var('cid', $cid);
$linklist->set_var('cid_plain', $cid);
$linklist->set_var('lang_addalink', $LANG_LINKS[116]);
$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) {
$from_where .= " WHERE cid='" . addslashes($cid) . "'";
$from_where .= " WHERE cid=''";
$order = ' ORDER BY cid ASC,title';
if ($_LI_CONF['linksperpage'] > 0) {
$start = ($page - 1) * $_LI_CONF['linksperpage'];
$limit = ' LIMIT ' . $start . ',' . $_LI_CONF['linksperpage'];
$result = DB_query ($sql . $from_where . $order . $limit);
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");
$linklist->set_var ('link_details', '');
$linklist->set_var ('link_category',
$LANG_LINKS_STATS['stats_headline']);
for ($i = 0; $i < $nrows; $i++ ) {
$linklist->parse ('link_details', 'link', true);
$linklist->parse ('category_links', 'catlinks', true);
$linklist->set_var ('page_navigation', '');
for ($i = 0; $i < $nrows; $i++ ) {
// print the category and link
$linklist->parse('category_links', 'catlinks', true);
$linklist->set_var('link_details', '');
$currentcategory = DB_getItem($_TABLES['linkcategories'],
'category', "cid = '" . addslashes($currentcid) . "'");
if ($A['cid'] == $_LI_CONF['root']) {
$linklist->set_var('link_category', $LANG_LINKS['root']);
$linklist->set_var('link_category', $currentcategory);
$linklist->parse('link_details', 'link', true);
$linklist->parse('category_links', 'catlinks', true);
$result = DB_query ('SELECT COUNT(*) AS count ' . $from_where);
if ($_LI_CONF['linksperpage'] > 0) {
$pages = (int) ($numlinks / $_LI_CONF['linksperpage']);
if (($numlinks % $_LI_CONF['linksperpage']) > 0 ) {
if (($_LI_CONF['linkcols'] > 0) && !empty($currentcid)) {
$linklist->set_var('page_navigation',
. '/links/index.php' . $catlink, $page, $pages));
$linklist->set_var ('page_navigation', '');
$linklist->parse ('output', 'linklist');
$display .= $linklist->finish ($linklist->get_var ('output'));
* Prepare a link item for rendering
* @param array $A link details
* @param ref $template reference of the links template
global $_CONF, $_LI_CONF, $LANG_ADMIN, $LANG_LINKS, $LANG_DIRECTION,
$url = COM_buildUrl($_CONF['site_url']
. '/links/portal.php?what=link&item=' . $A['lid']);
$template->set_var('link_url', $url);
$template->set_var('link_actual_url', $actualUrl);
$template->set_var('link_actual_url_encoded', rawurlencode($actualUrl));
$template->set_var('link_name', $title);
$template->set_var('link_name_encoded', rawurlencode($title));
$template->set_var('link_description',
$attr = array('title' => $actualUrl);
if (substr($actualUrl, 0, strlen($_CONF['site_url'])) != $_CONF['site_url']) {
if ((!empty($LANG_DIRECTION)) && ($LANG_DIRECTION == 'rtl')) {
if ($_LI_CONF['new_window']) {
$attr['target'] = '_blank';
$template->set_var('link_html', $html);
$reporturl = $_CONF['site_url']
. '/links/index.php?mode=report&lid=' . $A['lid'];
$template->set_var('link_broken',
array('class' => 'pluginSmallText',
$template->set_var('link_broken', '');
if ((SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'],
$A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) &&
$editurl = $_CONF['site_admin_url']
. '/plugins/links/index.php?mode=edit&lid=' . $A['lid'];
$template->set_var('link_edit',
$edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.$_IMAGE_TYPE\" "
. "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\"" . XHTML . ">";
$template->set_var('edit_icon', COM_createLink($edit_icon, $editurl));
$template->set_var('link_edit', '');
$template->set_var('edit_icon', '');
$root = $_LI_CONF['root'];
if (isset ($_REQUEST['mode'])) {
$mode = $_REQUEST['mode'];
if (isset ($_GET['lid'])) {
$result = DB_query("SELECT url, title FROM {$_TABLES['links']} WHERE lid = '$lidsl'");
$editurl = $_CONF['site_admin_url']
. '/plugins/links/index.php?mode=edit&lid=' . $lid;
$msg = $LANG_LINKS[119] . LB . LB . "$title, <$url>". LB . LB
. $LANG_LINKS[120] . LB . '<' . $editurl . '>' . LB . LB
. $LANG_LINKS[121] . $_USER['username'] . ', IP: '
. $_SERVER['REMOTE_ADDR'];
COM_mail($_CONF['site_mail'], $LANG_LINKS[118], $msg);
$message = array($LANG_LINKS[123], $LANG_LINKS[122]);
(($_CONF['loginrequired'] == 1) || ($_LI_CONF['linksloginrequired'] == 1))) {
|