[geeklog-cvs] Geeklog-1.x/public_html/links index.php, 1.22, 1.23 portal.php, 1.3, 1.4

Oliver ospiess at qs1489.pair.com
Wed Aug 29 00:27:36 EDT 2007


Update of /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/links
In directory qs1489.pair.com:/tmp/cvs-serv5171

Modified Files:
	index.php portal.php 
Log Message:
new version from Euan (2nd try)

Index: portal.php
===================================================================
RCS file: /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/links/portal.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** portal.php	15 May 2006 04:10:38 -0000	1.3
--- portal.php	29 Aug 2007 04:27:34 -0000	1.4
***************
*** 73,76 ****
--- 73,83 ----
          }
      }
+ } elseif ($what == 'category') {
+ 
+     $item = COM_applyFilter (COM_getArgument ('item'));
+ 
+     if (!empty ($item)) {
+         $url = COM_buildURL("{$_CONF['site_url']}/links/index.php?cid={$item}");
+     }
  }
  
***************
*** 78,82 ****
      $url = $_CONF['site_url'];
  }
- 
  header ('HTTP/1.1 301 Moved');
  header ('Location: ' . $url);
--- 85,88 ----

Index: index.php
===================================================================
RCS file: /usr/home/geeklog2/cvsroot/geeklog/Geeklog-1.x/public_html/links/index.php,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** index.php	28 Aug 2007 07:34:25 -0000	1.22
--- index.php	29 Aug 2007 04:27:34 -0000	1.23
***************
*** 9,13 ****
  // | This is the main page for the Geeklog Links Plugin                        |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2006 by the following authors:                         |
  // |                                                                           |
  // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
--- 9,13 ----
  // | This is the main page for the Geeklog Links Plugin                        |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2007 by the following authors:                         |
  // |                                                                           |
  // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
***************
*** 35,41 ****
  // +---------------------------------------------------------------------------+
  //
! /** 
!  * This is the links page   
!  * 
   * @package Links
   * @subpackage public_html
--- 35,41 ----
  // +---------------------------------------------------------------------------+
  //
! /**
!  * This is the links page
!  *
   * @package Links
   * @subpackage public_html
***************
*** 44,48 ****
   * @since GL 1.4.0
   * @copyright Copyright © 2005-2006
!  * @license http://opensource.org/licenses/gpl-license.php GNU Public License 
   * @author Tony Bibbs <tony AT tonybibbs DOT com>
   * @author Mark Limburg <mlimburg AT users DOT sourceforge DOT net>
--- 44,48 ----
   * @since GL 1.4.0
   * @copyright Copyright © 2005-2006
!  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
   * @author Tony Bibbs <tony AT tonybibbs DOT com>
   * @author Mark Limburg <mlimburg AT users DOT sourceforge DOT net>
***************
*** 51,55 ****
   * @author Trinity Bays <trinity AT steubentech DOT com>
   * @author Dirk Haun <dirk AT haun-online DOT de>
!  * 
   */
  // $Id$
--- 51,55 ----
   * @author Trinity Bays <trinity AT steubentech DOT com>
   * @author Dirk Haun <dirk AT haun-online DOT de>
!  *
   */
  // $Id$
***************
*** 58,121 ****
  
  /**
! * Prepare a link item for rendering
! *
! * @param    array   $A          link details
! * @param    ref     $template   reference of the links template
  *
  */
! function prepare_link_item ($A, &$template)
  {
!     global $_CONF, $LANG_ADMIN, $_IMAGE_TYPE;
! 
!     $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', $A['url']);
!     $template->set_var ('link_name', stripslashes ($A['title']));
!     $template->set_var ('link_hits', COM_numberFormat ($A['hits']));
!     $template->set_var ('link_description',
!                         nl2br (stripslashes ($A['description'])));
! 
!     if ((SEC_hasAccess ($A['owner_id'], $A['group_id'], $A['perm_owner'],
!             $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) &&
!             SEC_hasRights ('links.edit')) {
!         $editurl = $_CONF['site_admin_url']
!                  . '/plugins/links/index.php?mode=edit&lid=' . $A['lid'];
!         $template->set_var ('link_edit', '<a href="' . $editurl . '">'
!                  . $LANG_ADMIN['edit'] . '</a>');
!         $template->set_var ('edit_icon', '<a href="' . $editurl . '"><img src="'
!                  . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE
!                  . '" alt="' . $LANG_ADMIN['edit'] . '" title="'
!                  . $LANG_ADMIN['edit'] . '" border="0"></a>');
!     } else {
!         $template->set_var ('link_edit', '');
!         $template->set_var ('edit_icon', '');
!     }
! }
! 
! 
! // MAIN
! 
! $display = '';
! $root = 'site';
  
! if (empty ($_USER['username']) &&
!     (($_CONF['loginrequired'] == 1) || ($_LI_CONF['linksloginrequired'] == 1))) {
!     $display .= COM_siteHeader ('menu', $LANG_LINKS[114]);
!     $display .= COM_startBlock ($LANG_LOGIN[1], '',
!                                 COM_getBlockTemplate ('_msg_block', 'header'));
!     $login = new Template ($_CONF['path_layout'] . 'submit');
!     $login->set_file (array ('login' => 'submitloginrequired.thtml'));
!     $login->set_var ('login_message', $LANG_LOGIN[2]);
!     $login->set_var ('site_url', $_CONF['site_url']);
!     $login->set_var ('lang_login', $LANG_LOGIN[3]);
!     $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
!     $login->parse ('output', 'login');
!     $display .= $login->finish ($login->get_var ('output'));
!     $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
! } else {
!     $cid = '';
!     if (isset ($_REQUEST['cid'])) {
!         $cid = strip_tags (COM_stripslashes ($_REQUEST['cid']));
      }
      $page = 0;
--- 58,76 ----
  
  /**
! * create the links list depending on the category given
  *
+ *  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['cid'])) {
!         $cid = strip_tags (COM_stripslashes ($_GET['cid']));
!     } elseif (isset ($_POST['cid'])) {
!         $cid = strip_tags (COM_stripslashes ($_POST['cid']));
      }
      $page = 0;
***************
*** 128,133 ****
  
      if (empty ($cid)) {
-         // No category so set to root
-         $cid = $root;
          if ($page > 1) {
              $page_title = sprintf ($LANG_LINKS[114] . ' (%d)', $page);
--- 83,86 ----
***************
*** 136,146 ****
          }
      } else {
          if ($page > 1) {
!             $page_title = sprintf ($LANG_LINKS[114] . ': %s (%d)', $cid, $page);
          } else {
!             $page_title = sprintf ($LANG_LINKS[114] . ': %s', $cid);
          }
      }
! 
      // Check has access to this category
      if ($cid <> $root) {
--- 89,102 ----
          }
      } else {
+         $category = DB_getItem ($_TABLES['linkcategories'], 'category',
+                                                             "cid='{$cid}'");
          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 to this category
      if ($cid <> $root) {
***************
*** 156,163 ****
      }
  
- 
- 
      $display .= COM_siteHeader ('menu', $page_title);
  
  
      $linklist = new Template ($_CONF['path'] . 'plugins/links/templates/');
--- 112,123 ----
      }
  
      $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'));
+     }
  
      $linklist = new Template ($_CONF['path'] . 'plugins/links/templates/');
***************
*** 172,185 ****
      $linklist->set_var ('blockheader',COM_startBlock($LANG_LINKS[114]));
      $linklist->set_var ('layout_url',$_CONF['layout_url']);
! 
      // Create breadcrumb trail
!     $linklist->set_var('breadcrumbs', links_breadcrumbs ($root,$cid));
  
      // Set dropdown for category jump
!     $linklist->set_var ('lang_go', $LANG_LINKS[117]);
!     $linklist->set_var('link_dropdown', links_select_box(2));
  
-     if ($_LI_CONF['linkcols'] > 0) {
  
          // Show categories
          $sql = "SELECT cid,pid,category,description FROM {$_TABLES['linkcategories']} WHERE pid='{$cid}'";
--- 132,145 ----
      $linklist->set_var ('blockheader',COM_startBlock($LANG_LINKS[114]));
      $linklist->set_var ('layout_url',$_CONF['layout_url']);
!     
      // 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));
  
  
+     if ($_LI_CONF['linkcols'] > 0) {
          // Show categories
          $sql = "SELECT cid,pid,category,description FROM {$_TABLES['linkcategories']} WHERE pid='{$cid}'";
***************
*** 192,199 ****
          $nrows  = DB_numRows ($result);
          if ($nrows > 0) {
!             $linklist->set_var ('lang_categories', $LANG_LINKS[118]);
              for ($i = 1; $i <= $nrows; $i++) {
                  $C = DB_fetchArray ($result);
- 
                  // Get number of child links user can see in this category
                  $result1 = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$C['cid']}'" . COM_getPermSQL ('AND'));
--- 152,158 ----
          $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
                  $result1 = DB_query ("SELECT COUNT(*) AS count FROM {$_TABLES['links']} WHERE cid='{$C['cid']}'" . COM_getPermSQL ('AND'));
***************
*** 281,293 ****
      $result = DB_query ($sql . $from_where . $order . $limit);
      $nrows = DB_numRows ($result);
- 
-     // No links
      if ($nrows == 0) {
!         if (($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') . " 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);
--- 240,251 ----
      $result = DB_query ($sql . $from_where . $order . $limit);
      $nrows = DB_numRows ($result);
      if ($nrows == 0) {
!         if (empty ($category) && ($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') . " 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);
***************
*** 299,303 ****
          }
          $linklist->set_var ('page_navigation', '');
-     // Have links, so build the page
      } else {
          // Get current category name
--- 257,260 ----
***************
*** 313,317 ****
          $linklist->parse ('category_links', 'catlinks', true);
  
-         // Google paging
          $result = DB_query ('SELECT COUNT(*) AS count ' . $from_where);
          list($numlinks) = DB_fetchArray ($result);
--- 270,273 ----
***************
*** 339,344 ****
--- 295,403 ----
      $linklist->parse ('output', 'linklist');
      $display .= $linklist->finish ($linklist->get_var ('output'));
+     return $display;
  }
  
+ 
+ /**
+ * Prepare a link item for rendering
+ *
+ * @param    array   $A          link details
+ * @param    ref     $template   reference of the links template
+ *
+ */
+ function prepare_link_item ($A, &$template)
+ {
+     global $_CONF, $_USER, $LANG_ADMIN, $LANG_LINKS, $_IMAGE_TYPE;
+ 
+     $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', $A['url']);
+     $template->set_var ('link_name', stripslashes ($A['title']));
+     $template->set_var ('link_hits', COM_numberFormat ($A['hits']));
+     $template->set_var ('link_description',
+                         nl2br (stripslashes ($A['description'])));
+     $content = stripslashes ($A['title']);
+     $attr = array(
+         'title' => stripslashes ($A['title']),
+         'class' => 'ext-link');
+     $html = COM_createLink($content, $url, $attr);
+     $template->set_var ('link_html', $html);
+     if (isset ($_USER['uid']) && ($_USER['uid'] > 1)) {
+         $reporturl = $_CONF['site_url']
+                  . '/links/index.php?mode=report&lid=' . $A['lid'];
+         $template->set_var ('link_broken',
+                 COM_createLink($LANG_LINKS[117], $reporturl,
+                                array('class' => 'pluginSmallText',
+                                      'rel'   => 'nofollow'))
+         );
+     } else {
+         $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) &&
+             SEC_hasRights ('links.edit')) {
+         $editurl = $_CONF['site_admin_url']
+                  . '/plugins/links/index.php?mode=edit&lid=' . $A['lid'];
+         $template->set_var ('link_edit', COM_createLink($LANG_ADMIN['edit'],$editurl));
+         $edit_icon = "<img src=\"{$_CONF['layout_url']}/images/edit.$_IMAGE_TYPE\" "
+             . "alt=\"{$LANG_ADMIN['edit']}\" title=\"{$LANG_ADMIN['edit']}\">";
+         $template->set_var ('edit_icon', COM_createLink($edit_icon, $editurl));
+     } else {
+         $template->set_var ('link_edit', '');
+         $template->set_var ('edit_icon', '');
+     }
+ }
+ 
+ 
+ // MAIN
+ 
+ $display = '';
+ $mode = '';
+ $root = $_LI_CONF['root'];
+ if (isset ($_REQUEST['mode'])) {
+     $mode = $_REQUEST['mode'];
+ }
+ 
+ $message = array();
+ if (($mode == 'report') && (isset($_USER['uid']) && ($_USER['uid'] > 1))) {
+     if (isset ($_GET['lid'])) {
+         $lid = COM_applyFilter($_GET['lid']);
+     }
+     if (!empty($lid)) {
+         $lidsl = addslashes($lid);
+         $result = DB_query("SELECT url, title FROM {$_TABLES['links']} WHERE lid = '$lidsl'");
+         list($url, $title) = DB_fetchArray($result);
+ 
+         $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]);
+     }
+ }
+ 
+ if (empty ($_USER['username']) &&
+     (($_CONF['loginrequired'] == 1) || ($_LI_CONF['linksloginrequired'] == 1))) {
+     $display .= COM_siteHeader ('menu', $LANG_LINKS[114]);
+     $display .= COM_startBlock ($LANG_LOGIN[1], '',
+                                 COM_getBlockTemplate ('_msg_block', 'header'));
+     $login = new Template ($_CONF['path_layout'] . 'submit');
+     $login->set_file (array ('login' => 'submitloginrequired.thtml'));
+     $login->set_var ('login_message', $LANG_LOGIN[2]);
+     $login->set_var ('site_url', $_CONF['site_url']);
+     $login->set_var ('lang_login', $LANG_LOGIN[3]);
+     $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
+     $login->parse ('output', 'login');
+     $display .= $login->finish ($login->get_var ('output'));
+     $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
+ } else {
+     $display .= links_list($message);
+ 
+ }
  
  $display .= COM_siteFooter ();




More information about the geeklog-cvs mailing list