Links
[ class tree: Links ] [ index: Links ] [ all elements ]

Source for file index.php

Documentation is available at index.php

  1. <?php
  2.  
  3. // Reminder: always indent with 4 spaces (no tabs).
  4. // +---------------------------------------------------------------------------+
  5. // | Links Plugin 2.1                                                          |
  6. // +---------------------------------------------------------------------------+
  7. // | index.php                                                                 |
  8. // |                                                                           |
  9. // | Geeklog Links Plugin administration page.                                 |
  10. // +---------------------------------------------------------------------------+
  11. // | Copyright (C) 2000-2010 by the following authors:                         |
  12. // |                                                                           |
  13. // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
  14. // |          Mark Limburg      - mlimburg AT users DOT sourceforge DOT net    |
  15. // |          Jason Whittenburg - jwhitten AT securitygeeks DOT com            |
  16. // |          Dirk Haun         - dirk AT haun-online DOT de                   |
  17. // +---------------------------------------------------------------------------+
  18. // |                                                                           |
  19. // | This program is free software; you can redistribute it and/or             |
  20. // | modify it under the terms of the GNU General Public License               |
  21. // | as published by the Free Software Foundation; either version 2            |
  22. // | of the License, or (at your option) any later version.                    |
  23. // |                                                                           |
  24. // | This program is distributed in the hope that it will be useful,           |
  25. // | but WITHOUT ANY WARRANTY; without even the implied warranty of            |
  26. // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             |
  27. // | GNU General Public License for more details.                              |
  28. // |                                                                           |
  29. // | You should have received a copy of the GNU General Public License         |
  30. // | along with this program; if not, write to the Free Software Foundation,   |
  31. // | Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           |
  32. // |                                                                           |
  33. // +---------------------------------------------------------------------------+
  34.  
  35. /**
  36.  * Geeklog links administration page.
  37.  *
  38.  * @package Links
  39.  * @subpackage admin
  40.  * @filesource
  41.  * @version 2.0
  42.  * @since GL 1.4.0
  43.  * @copyright Copyright &copy; 2005-2007
  44.  * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
  45.  * @author Trinity Bays <trinity93@gmail.com>
  46.  * @author Tony Bibbs <tony@tonybibbs.com>
  47.  * @author Tom Willett <twillett@users.sourceforge.net>
  48.  * @author Blaine Lang <langmail@sympatico.ca>
  49.  * @author Dirk Haun <dirk@haun-online.de>
  50.  */
  51.  
  52. /** 
  53. * Geeklog common function library and Admin authentication
  54. */
  55. require_once '../../../lib-common.php';
  56. require_once '../../auth.inc.php';
  57.  
  58. // Uncomment the lines below if you need to debug the HTTP variables being passed
  59. // to the script.  This will sometimes cause errors but it will allow you to see
  60. // the data being passed in a POST operation
  61. // echo COM_debug($_POST);
  62. // exit;
  63.  
  64. $display '';
  65.  
  66. if (!SEC_hasRights('links.edit')) {
  67.     $display .= COM_siteHeader('menu'$MESSAGE[30])
  68.              . COM_showMessageText($MESSAGE[29]$MESSAGE[30])
  69.              . COM_siteFooter();
  70.     COM_accessLog("User {$_USER['username']} tried to illegally access the links administration screen.");
  71.     COM_output($display);
  72.     exit;
  73. }
  74.  
  75. /**
  76. * Shows the links editor
  77. *
  78. @param  string  $mode   Used to see if we are moderating a link or simply editing one
  79. @param  string  $lid    ID of link to edit
  80. @global array core config vars
  81. @global array core group data
  82. @global array core table data
  83. @global array core user data
  84. @global array links plugin config vars
  85. @global array links plugin lang vars
  86. @global array core lang access vars
  87. @return string HTML for the link editor form
  88. *
  89. */
  90. function editlink ($mode$lid '')
  91. {
  92.     global $_CONF$_GROUPS$_TABLES$_USER$_LI_CONF,
  93.            $LANG_LINKS_ADMIN$LANG_ACCESS$LANG_ADMIN$MESSAGE;
  94.  
  95.     $retval '';
  96.  
  97.     $link_templates COM_newTemplate($_CONF['path''plugins/links/templates/admin/');
  98.     $link_templates->set_file('editor','linkeditor.thtml');
  99.  
  100.     $link_templates->set_var('lang_pagetitle'$LANG_LINKS_ADMIN[28]);
  101.     $link_templates->set_var('lang_link_list'$LANG_LINKS_ADMIN[53]);
  102.     $link_templates->set_var('lang_new_link'$LANG_LINKS_ADMIN[51]);
  103.     $link_templates->set_var('lang_validate_links'$LANG_LINKS_ADMIN[26]);
  104.     $link_templates->set_var('lang_list_categories'$LANG_LINKS_ADMIN[50]);
  105.     $link_templates->set_var('lang_new_category'$LANG_LINKS_ADMIN[52]);
  106.     $link_templates->set_var('lang_admin_home'$LANG_ADMIN['admin_home']);
  107.     $link_templates->set_var('instructions'$LANG_LINKS_ADMIN[29]);
  108.  
  109.     if ($mode <> 'editsubmission' AND !empty($lid)) {
  110.         $result DB_query("SELECT * FROM {$_TABLES['links']} WHERE lid ='$lid'");
  111.         if (DB_numRows($result!== 1{
  112.             $msg COM_startBlock ($LANG_LINKS_ADMIN[24]'',
  113.                 COM_getBlockTemplate ('_msg_block''header'));
  114.             $msg .= $LANG_LINKS_ADMIN[25];
  115.             $msg .= COM_endBlock (COM_getBlockTemplate ('_msg_block''footer'));
  116.             return $msg;
  117.         }
  118.         $A DB_fetchArray($result);
  119.         $access SEC_hasAccess($A['owner_id'],$A['group_id'],$A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']);
  120.         if ($access == OR $access == 2{
  121.             $retval .= COM_startBlock($LANG_LINKS_ADMIN[16]'',
  122.                                COM_getBlockTemplate ('_msg_block''header'));
  123.             $retval .= $LANG_LINKS_ADMIN[17];
  124.             $retval .= COM_endBlock (COM_getBlockTemplate ('_msg_block''footer'));
  125.             COM_accessLog("User {$_USER['username']} tried to illegally submit or edit link $lid.");
  126.             return $retval;
  127.         }
  128.     else {
  129.         if ($mode == 'editsubmission'{
  130.             $result DB_query ("SELECT * FROM {$_TABLES['linksubmission']} WHERE lid = '$lid'");
  131.             $A DB_fetchArray($result);
  132.         else {
  133.             $A['lid'COM_makesid();
  134.             $A['cid''';
  135.             $A['url''';
  136.             $A['description''';
  137.             $A['title']'';
  138.             $A['owner_id'$_USER['uid'];
  139.         }
  140.         $A['hits'0;
  141.         if (isset ($_GROUPS['Links Admin'])) {
  142.             $A['group_id'$_GROUPS['Links Admin'];
  143.         else {
  144.             $A['group_id'SEC_getFeatureGroup ('links.edit');
  145.         }
  146.         SEC_setDefaultPermissions ($A$_LI_CONF['default_permissions']);
  147.         $access 3;
  148.     }
  149.  
  150.     $token SEC_createToken();
  151.  
  152.     $retval .= COM_startBlock($LANG_LINKS_ADMIN[1]'',
  153.                               COM_getBlockTemplate('_admin_block''header'));
  154.     $retval .= SEC_getTokenExpiryNotice($token);
  155.  
  156.     $link_templates->set_var('link_id'$A['lid']);
  157.     if (!empty($lid&& SEC_hasRights('links.edit')) {
  158.         $delbutton '<input type="submit" value="' $LANG_ADMIN['delete']
  159.                    . '" name="mode"%s' XHTML '>';
  160.         $jsconfirm ' onclick="return confirm(\'' $MESSAGE[76'\');"';
  161.         $link_templates->set_var ('delete_option',
  162.                                   sprintf ($delbutton$jsconfirm));
  163.         $link_templates->set_var ('delete_option_no_confirmation',
  164.                                   sprintf ($delbutton''));
  165.         if ($mode == 'editsubmission'{
  166.             $link_templates->set_var('submission_option',
  167.                 '<input type="hidden" name="type" value="submission"'
  168.                 . XHTML '>');
  169.         }
  170.     }
  171.     $link_templates->set_var('lang_linktitle'$LANG_LINKS_ADMIN[3]);
  172.     $link_templates->set_var('link_title',
  173.                              htmlspecialchars (stripslashes ($A['title'])));
  174.     $link_templates->set_var('lang_linkid'$LANG_LINKS_ADMIN[2]);
  175.     $link_templates->set_var('lang_linkurl'$LANG_LINKS_ADMIN[4]);
  176.     $link_templates->set_var('max_url_length'255);
  177.     $link_templates->set_var('link_url'$A['url']);
  178.     $link_templates->set_var('lang_includehttp'$LANG_LINKS_ADMIN[6]);
  179.     $link_templates->set_var('lang_category'$LANG_LINKS_ADMIN[5]);
  180.     $othercategory links_select_box (3,$A['cid']);
  181.     $link_templates->set_var('category_options'$othercategory);
  182.     $link_templates->set_var('lang_ifotherspecify'$LANG_LINKS_ADMIN[20]);
  183.     $link_templates->set_var('category'$othercategory);
  184.     $link_templates->set_var('lang_linkhits'$LANG_LINKS_ADMIN[8]);
  185.     $link_templates->set_var('link_hits'$A['hits']);
  186.     $link_templates->set_var('lang_linkdescription'$LANG_LINKS_ADMIN[9]);
  187.     $link_templates->set_var('link_description'stripslashes($A['description']));
  188.     $allowed COM_allowedHTML('links.edit');
  189.     $link_templates->set_var('lang_allowed_html'$allowed);
  190.     $link_templates->set_var('lang_save'$LANG_ADMIN['save']);
  191.     $link_templates->set_var('lang_cancel'$LANG_ADMIN['cancel']);
  192.  
  193.     // user access info
  194.     $link_templates->set_var('lang_accessrights'$LANG_ACCESS['accessrights']);
  195.     $link_templates->set_var('lang_owner'$LANG_ACCESS['owner']);
  196.     $ownername COM_getDisplayName ($A['owner_id']);
  197.     $link_templates->set_var('owner_username'DB_getItem($_TABLES['users'],
  198.                              'username'"uid = {$A['owner_id']}"));
  199.     $link_templates->set_var('owner_name'$ownername);
  200.     $link_templates->set_var('owner'$ownername);
  201.     $link_templates->set_var('link_ownerid'$A['owner_id']);
  202.     $link_templates->set_var('lang_group'$LANG_ACCESS['group']);
  203.     $link_templates->set_var('group_dropdown',
  204.                              SEC_getGroupDropdown ($A['group_id']$access));
  205.     $link_templates->set_var('lang_permissions'$LANG_ACCESS['permissions']);
  206.     $link_templates->set_var('lang_permissionskey'$LANG_ACCESS['permissionskey']);
  207.     $link_templates->set_var('lang_perm_key'$LANG_ACCESS['permissionskey']);
  208.     $link_templates->set_var('permissions_editor'SEC_getPermissionsHTML($A['perm_owner'],$A['perm_group'],$A['perm_members'],$A['perm_anon']));
  209.     $link_templates->set_var('lang_permissions_msg'$LANG_ACCESS['permmsg']);
  210.     $link_templates->set_var('lang_lockmsg'$LANG_ACCESS['permmsg']);
  211.     $link_templates->set_var('gltoken_name'CSRF_TOKEN);
  212.     $link_templates->set_var('gltoken'$token);
  213.     $link_templates->parse('output''editor');
  214.     $retval .= $link_templates->finish($link_templates->get_var('output'));
  215.  
  216.     $retval .= COM_endBlock (COM_getBlockTemplate ('_admin_block''footer'));
  217.  
  218.     return $retval;
  219. }
  220.  
  221. /**
  222. * Saves link to the database
  223. *
  224. @param    string  $lid            ID for link
  225. @param    string  $old_lid        old ID for link
  226. @param    string  $cid            cid of category link belongs to
  227. @param    string  $categorydd     Category links belong to
  228. @param    string  $url            URL of link to save
  229. @param    string  $description    Description of link
  230. @param    string  $title          Title of link
  231. @param    int     $hits           Number of hits for link
  232. @param    int     $owner_id       ID of owner
  233. @param    int     $group_id       ID of group link belongs to
  234. @param    int     $perm_owner     Permissions the owner has
  235. @param    int     $perm_group     Permissions the group has
  236. @param    int     $perm_members   Permissions members have
  237. @param    int     $perm_anon      Permissions anonymous users have
  238. @return   string                  HTML redirect or error message
  239. @global array core config vars
  240. @global array core group data
  241. @global array core table data
  242. @global array core user data
  243. @global array core msg data
  244. @global array links plugin lang admin vars
  245. *
  246. */
  247. function savelink ($lid$old_lid$cid$categorydd$url$description$title$hits$owner_id$group_id$perm_owner$perm_group$perm_members$perm_anon)
  248. {
  249.     global $_CONF$_GROUPS$_TABLES$_USER$MESSAGE$LANG_LINKS_ADMIN$_LI_CONF;
  250.  
  251.     $retval '';
  252.  
  253.     // Convert array values to numeric permission values
  254.     if (is_array($perm_ownerOR is_array($perm_groupOR is_array($perm_membersOR is_array($perm_anon)) {
  255.         list($perm_owner,$perm_group,$perm_members,$perm_anonSEC_getPermissionValues($perm_owner,$perm_group,$perm_members,$perm_anon);
  256.     }
  257.  
  258.  
  259.     // Remove any autotags the user doesn't have permission to use
  260.     $description PLG_replaceTags($description''true);
  261.     
  262.     // clean 'em up
  263.     $description addslashes(COM_checkHTML(COM_checkWords($description),
  264.                               'links.edit'));
  265.     $title addslashes(strip_tags(COM_checkWords($title)));
  266.     $cid addslashes($cid);
  267.  
  268.     if (empty ($owner_id)) {
  269.         // this is new link from admin, set default values
  270.         $owner_id $_USER['uid'];
  271.         if (isset ($_GROUPS['Links Admin'])) {
  272.             $group_id $_GROUPS['Links Admin'];
  273.         else {
  274.             $group_id SEC_getFeatureGroup ('links.edit');
  275.         }
  276.         $perm_owner 3;
  277.         $perm_group 2;
  278.         $perm_members 2;
  279.         $perm_anon 2;
  280.     }
  281.  
  282.     $lid COM_sanitizeID($lid);
  283.     $old_lid COM_sanitizeID($old_lid);
  284.     if (empty($lid)) {
  285.         if (empty($old_lid)) {
  286.             $lid COM_makeSid();
  287.         else {
  288.             $lid $old_lid;
  289.         }
  290.     }
  291.  
  292.     // check for link id change
  293.     if (!empty($old_lid&& ($lid != $old_lid)) {
  294.         // check if new lid is already in use
  295.         if (DB_count($_TABLES['links']'lid'$lid0{
  296.             // TBD: abort, display editor with all content intact again
  297.             $lid $old_lid// for now ...
  298.         }
  299.     }
  300.  
  301.     $access 0;
  302.     $old_lid addslashes ($old_lid);
  303.     if (DB_count ($_TABLES['links']'lid'$old_lid0{
  304.         $result DB_query ("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['links']} WHERE lid = '{$old_lid}'");
  305.         $A DB_fetchArray ($result);
  306.         $access SEC_hasAccess ($A['owner_id']$A['group_id'],
  307.                 $A['perm_owner']$A['perm_group']$A['perm_members'],
  308.                 $A['perm_anon']);
  309.     else {
  310.         $access SEC_hasAccess ($owner_id$group_id$perm_owner$perm_group,
  311.                 $perm_members$perm_anon);
  312.     }
  313.     if (($access 3|| !SEC_inGroup($group_id)) {
  314.         $display .= COM_siteHeader('menu'$MESSAGE[30])
  315.                  . COM_showMessageText($MESSAGE[29]$MESSAGE[30])
  316.                  . COM_siteFooter();
  317.         COM_accessLog("User {$_USER['username']} tried to illegally submit or edit link $lid.");
  318.         COM_output($display);
  319.         exit;
  320.     elseif (!empty($title&& !empty($description&& !empty($url)) {
  321.  
  322.         if ($categorydd != $LANG_LINKS_ADMIN[7&& !empty($categorydd)) {
  323.             $cid addslashes ($categorydd);
  324.         else if ($categorydd != $LANG_LINKS_ADMIN[7]{
  325.             echo COM_refresh($_CONF['site_admin_url''/plugins/links/index.php');
  326.         }
  327.  
  328.         DB_delete ($_TABLES['linksubmission']'lid'$old_lid);
  329.         DB_delete ($_TABLES['links']'lid'$old_lid);
  330.  
  331.         DB_save ($_TABLES['links']'lid,cid,url,description,title,date,hits,owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon'"'$lid','$cid','$url','$description','$title',NOW(),'$hits',$owner_id,$group_id,$perm_owner,$perm_group,$perm_members,$perm_anon");
  332.  
  333.         if (empty($old_lid|| ($old_lid == $lid)) {
  334.             PLG_itemSaved($lid'links');
  335.         else {
  336.             PLG_itemSaved($lid'links'$old_lid);
  337.         }
  338.  
  339.         // Get category for rdf check
  340.         $category DB_getItem ($_TABLES['linkcategories'],"category","cid='{$cid}'");
  341.         COM_rdfUpToDateCheck ('links'$category$lid);
  342.  
  343.         return PLG_afterSaveSwitch (
  344.             $_LI_CONF['aftersave'],
  345.             COM_buildURL ("{$_CONF['site_url']}/links/portal.php?what=link&item=$lid"),
  346.             'links',
  347.             2
  348.         );
  349.  
  350.     else // missing fields
  351.         $retval .= COM_siteHeader('menu'$LANG_LINKS_ADMIN[1]);
  352.         $retval .= COM_errorLog($LANG_LINKS_ADMIN[10],2);
  353.         if (DB_count ($_TABLES['links']'lid'$old_lid0{
  354.             $retval .= editlink ('edit'$old_lid);
  355.         else {
  356.             $retval .= editlink ('edit''');
  357.         }
  358.         $retval .= COM_siteFooter();
  359.  
  360.         return $retval;
  361.     }
  362. }
  363.  
  364. /**
  365.  * List links
  366.  * @global array core config vars
  367.  * @global array core table data
  368.  * @global array core user data
  369.  * @global array core lang admin vars
  370.  * @global array links plugin lang vars
  371.  * @global array core lang access vars
  372.  */
  373. function listlinks ()
  374. {
  375.     global $_CONF$_TABLES$LANG_ADMIN$LANG_LINKS_ADMIN$LANG_ACCESS,
  376.            $_IMAGE_TYPE;
  377.  
  378.     require_once $_CONF['path_system''lib-admin.php';
  379.  
  380.     $retval '';
  381.  
  382.     $header_arr array(      # display 'text' and use table field 'field'
  383.         array('text' => $LANG_ADMIN['edit']'field' => 'edit''sort' => false),
  384.         array('text' => $LANG_LINKS_ADMIN[2]'field' => 'lid''sort' => true),
  385.         array('text' => $LANG_ADMIN['title']'field' => 'title''sort' => true),
  386.         array('text' => $LANG_ACCESS['access']'field' => 'access''sort' => false),
  387.         array('text' => $LANG_LINKS_ADMIN[14]'field' => 'category''sort' => true)
  388.     );
  389.  
  390.     $menu_arr array (
  391.         array('url' => $_CONF['site_admin_url''/plugins/links/index.php?mode=edit',
  392.               'text' => $LANG_LINKS_ADMIN[51])
  393.     );
  394.  
  395.     $validate '';
  396.     if (isset($_GET['validate'])) {
  397.         $token SEC_createToken();
  398.         $menu_arr[array('url' => $_CONF['site_admin_url''/plugins/links/index.php',
  399.             'text' => $LANG_LINKS_ADMIN[53]);
  400.         $dovalidate_url $_CONF['site_admin_url''/plugins/links/index.php?validate=validate' '&amp;'.CSRF_TOKEN.'='.$token;
  401.         $dovalidate_text $LANG_LINKS_ADMIN[58];
  402.         $form_arr['top'COM_createLink($dovalidate_text$dovalidate_url);
  403.         if ($_GET['validate'== 'enabled'{
  404.             $header_arr[array('text' => $LANG_LINKS_ADMIN[27]'field' => 'beforevalidate''sort' => false);
  405.             $validate '?validate=enabled';
  406.         else if ($_GET['validate'== 'validate'{
  407.             $header_arr[array('text' => $LANG_LINKS_ADMIN[27]'field' => 'dovalidate''sort' => false);
  408.             $validate '?validate=validate&amp;'.CSRF_TOKEN.'='.$token;
  409.         }
  410.         $validate_help $LANG_LINKS_ADMIN[59];
  411.     else {
  412.         $menu_arr[array('url' => $_CONF['site_admin_url''/plugins/links/index.php?validate=enabled',
  413.               'text' => $LANG_LINKS_ADMIN[26]);
  414.         $form_arr array();
  415.         $validate_help '';
  416.     }
  417.  
  418.     $defsort_arr array('field' => 'title''direction' => 'asc');
  419.  
  420.     $menu_arr[array('url' => $_CONF['site_admin_url''/plugins/links/category.php',
  421.               'text' => $LANG_LINKS_ADMIN[50]);
  422.     $menu_arr[array('url' => $_CONF['site_admin_url''/plugins/links/category.php?mode=edit',
  423.               'text' => $LANG_LINKS_ADMIN[52]);
  424.     $menu_arr[array('url' => $_CONF['site_admin_url'],
  425.               'text' => $LANG_ADMIN['admin_home']);
  426.  
  427.     $retval .= COM_startBlock($LANG_LINKS_ADMIN[11]'',
  428.                               COM_getBlockTemplate('_admin_block''header'));
  429.  
  430.     $retval .= ADMIN_createMenu($menu_arr$LANG_LINKS_ADMIN[12$validate_helpplugin_geticon_links());
  431.  
  432.     $text_arr array(
  433.         'has_extras' => true,
  434.         'form_url' => $_CONF['site_admin_url'"/plugins/links/index.php$validate"
  435.     );
  436.  
  437.     $query_arr array('table' => 'links',
  438.         'sql' => "SELECT l.lid AS lid, l.cid as cid, l.title AS title, "
  439.             . "c.category AS category, l.url AS url, l.description AS description, "
  440.             . "l.owner_id, l.group_id, l.perm_owner, l.perm_group, l.perm_members, l.perm_anon "
  441.             . "FROM {$_TABLES['links']} AS l "
  442.             . "LEFT JOIN {$_TABLES['linkcategories']} AS c "
  443.             . "ON l.cid=c.cid WHERE 1=1",
  444.         'query_fields' => array('title''category''url''l.description'),
  445.         'default_filter' => COM_getPermSql ('AND'03'l')
  446.     );
  447.  
  448.     $retval .= ADMIN_list('links''plugin_getListField_links'$header_arr,
  449.                     $text_arr$query_arr$defsort_arr''''''$form_arr);
  450.     $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block''footer'));
  451.  
  452.     return $retval;
  453. }
  454.  
  455. /**
  456. * Delete a link
  457. *
  458. @param    string  $lid    id of link to delete
  459. @param    string  $type   'submission' when attempting to delete a submission
  460. @return   string          HTML redirect
  461. *
  462. */
  463. function deleteLink($lid$type '')
  464. {
  465.     global $_CONF$_TABLES$_USER;
  466.  
  467.     if (empty($type)) // delete regular link
  468.         $result DB_query("SELECT owner_id,group_id,perm_owner,perm_group,perm_members,perm_anon FROM {$_TABLES['links']} WHERE lid ='$lid'");
  469.         $A DB_fetchArray($result);
  470.         $access SEC_hasAccess($A['owner_id']$A['group_id'],
  471.                     $A['perm_owner']$A['perm_group']$A['perm_members'],
  472.                     $A['perm_anon']);
  473.         if ($access 3{
  474.             COM_accessLog("User {$_USER['username']} tried to illegally delete link $lid.");
  475.             return COM_refresh($_CONF['site_admin_url']
  476.                                . '/plugins/links/index.php');
  477.         }
  478.  
  479.         DB_delete($_TABLES['links']'lid'$lid);
  480.  
  481.         PLG_itemDeleted($lid'links');
  482.  
  483.         return COM_refresh($_CONF['site_admin_url']
  484.                            . '/plugins/links/index.php?msg=3');
  485.     elseif ($type == 'submission'{
  486.         if (plugin_ismoderator_links()) {
  487.             DB_delete($_TABLES['linksubmission']'lid'$lid);
  488.  
  489.             return COM_refresh($_CONF['site_admin_url']
  490.                                . '/plugins/links/index.php?msg=3');
  491.         else {
  492.             COM_accessLog("User {$_USER['username']} tried to illegally delete link submission $lid.");
  493.         }
  494.     else {
  495.         COM_accessLog("User {$_USER['username']} tried to illegally delete link $lid of type $type.");
  496.     }
  497.  
  498.     return COM_refresh($_CONF['site_admin_url''/plugins/links/index.php');
  499. }
  500.  
  501. // MAIN
  502. $mode '';
  503. if (isset ($_REQUEST['mode'])) {
  504.     $mode $_REQUEST['mode'];
  505. }
  506.  
  507. if (($mode == $LANG_ADMIN['delete']&& !empty ($LANG_ADMIN['delete'])) {
  508.     $lid COM_applyFilter ($_POST['lid']);
  509.     if (!isset ($lid|| empty ($lid)) {  // || ($lid == 0)
  510.         COM_errorLog ('Attempted to delete link lid=' $lid );
  511.         $display .= COM_refresh ($_CONF['site_admin_url''/plugins/links/index.php');
  512.     elseif (SEC_checkToken()) {
  513.         $type '';
  514.         if (isset($_POST['type'])) {
  515.             $type COM_applyFilter($_POST['type']);
  516.         }
  517.         $display .= deleteLink($lid$type);
  518.     else {
  519.         COM_accessLog("User {$_USER['username']} tried to illegally delete link $lid and failed CSRF checks.");
  520.         echo COM_refresh($_CONF['site_admin_url''/index.php');
  521.     }
  522. elseif (($mode == $LANG_ADMIN['save']&& !empty($LANG_ADMIN['save']&& SEC_checkToken()) {
  523.     $cid '';
  524.     if (isset($_POST['cid'])) {
  525.         $cid $_POST['cid'];
  526.     }
  527.     $display .= savelink (COM_applyFilter ($_POST['lid']),
  528.             COM_applyFilter ($_POST['old_lid']),
  529.             $cid$_POST['categorydd'],
  530.             $_POST['url']$_POST['description']$_POST['title'],
  531.             COM_applyFilter ($_POST['hits']true),
  532.             COM_applyFilter ($_POST['owner_id']true),
  533.             COM_applyFilter ($_POST['group_id']true),
  534.             $_POST['perm_owner']$_POST['perm_group'],
  535.             $_POST['perm_members']$_POST['perm_anon']);
  536. else if ($mode == 'editsubmission'{
  537.     $display .= COM_siteHeader ('menu'$LANG_LINKS_ADMIN[1]);
  538.     $display .= editlink ($modeCOM_applyFilter ($_GET['id']));
  539.     $display .= COM_siteFooter ();
  540. else if ($mode == 'edit'{
  541.     $display .= COM_siteHeader ('menu'$LANG_LINKS_ADMIN[1]);
  542.     if (empty ($_GET['lid'])) {
  543.         $display .= editlink ($mode);
  544.     else {
  545.         $display .= editlink ($modeCOM_applyFilter ($_GET['lid']));
  546.     }
  547.     $display .= COM_siteFooter ();
  548. else // 'cancel' or no mode at all
  549.     $display .= COM_siteHeader('menu'$LANG_LINKS_ADMIN[11]);
  550.     if (isset($_GET['msg'])) {
  551.         $msg COM_applyFilter($_GET['msg']true);
  552.         if ($msg 0{
  553.             $display .= COM_showMessage($msg'links');
  554.         }
  555.     }
  556.     $display .= listlinks();
  557.     $display .= COM_siteFooter();
  558. }
  559.  
  560. COM_output($display);
  561.  
  562. ?>

Documentation generated on Fri, 25 May 2012 02:08:55 -0400 by phpDocumentor 1.4.3