Changeset 4503


Ignore:
Timestamp:
Dec 16, 2009, 12:22:49 AM (15 years ago)
Author:
plg
Message:

bug 1328: first specific implementation of the check_pwg_token for the
admin/tags page (all actions : add/edit/delete).

The "check_token" function was renammed into check_pwg_token because the
word "token" is too much generic.

Location:
branches/2.0/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/admin/include/functions.php

    r4502 r4503  
    3131 * @return void access denied if token given is not equal to server token
    3232 */
    33 function check_token()
     33function check_pwg_token()
     34{
     35  $valid_token = get_pwg_token();
     36  $given_token = null;
     37
     38  if (!empty($_POST['pwg_token']))
     39  {
     40    $given_token = $_POST['pwg_token'];
     41  }
     42  elseif (!empty($_GET['pwg_token']))
     43  {
     44    $given_token = $_GET['pwg_token'];
     45  }
     46  if ($given_token != $valid_token)
     47  {
     48    access_denied();   
     49  }
     50}
     51
     52function get_pwg_token()
    3453{
    3554  global $conf;
    3655
    37   $valid_token = hash_hmac('md5', session_id(), $conf['secret_key']);
    38   $given_token = null;
    39 
    40   if (!empty($_POST['pwg_token']))
    41   {
    42     $given_token = $_POST['pwg_token'];
    43   }
    44   elseif (!empty($_GET['pwg_token']))
    45   {
    46     $given_token = $_GET['pwg_token'];
    47   }
    48   if ($given_token != $valid_token)
    49   {
    50     access_denied();   
    51   }
     56  return hash_hmac('md5', session_id(), $conf['secret_key']);
    5257}
    5358
  • branches/2.0/admin/tags.php

    r3046 r4503  
    2929include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    3030check_status(ACCESS_ADMINISTRATOR);
     31
     32if (!empty($_POST))
     33{
     34  check_pwg_token();
     35}
    3136
    3237// +-----------------------------------------------------------------------+
     
    190195$template->assign(
    191196  array(
    192     'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=tags'
     197    'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=tags',
     198    'PWG_TOKEN' => get_pwg_token(),
    193199    )
    194200  );
  • branches/2.0/admin/template/goto/tags.tpl

    r2531 r4503  
    55
    66<form action="{$F_ACTION}" method="post">
     7  <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}" />
    78
    89  {if isset($EDIT_TAGS_LIST)}
Note: See TracChangeset for help on using the changeset viewer.