瀏覽代碼

Add security tokens to change password plugin

pdontthink 15 年之前
父節點
當前提交
0154fca83f
共有 2 個文件被更改,包括 7 次插入1 次删除
  1. 1 1
      plugins/change_password/functions.php
  2. 6 0
      plugins/change_password/options.php

+ 1 - 1
plugins/change_password/functions.php

@@ -105,7 +105,7 @@ function cpw_do_change()
 
 
     /* make sure we write the session data before we redirect */
     /* make sure we write the session data before we redirect */
     session_write_close();
     session_write_close();
-    header('Location: '.SM_PATH. 'src/options.php?optmode=submit&optpage=change_password&plugin_change_password=1');
+    header('Location: '.SM_PATH. 'src/options.php?optmode=submit&optpage=change_password&plugin_change_password=1&smtoken=' . sm_generate_security_token());
     exit;
     exit;
 }
 }
 
 

+ 6 - 0
plugins/change_password/options.php

@@ -53,6 +53,11 @@ if (file_exists(SM_PATH . 'plugins/change_password/backend/'.$cpw_backend.'.php'
 
 
 /* the form was submitted, go for it */
 /* the form was submitted, go for it */
 if(sqgetGlobalVar('cpw_go', $cpw_go, SQ_POST)) {
 if(sqgetGlobalVar('cpw_go', $cpw_go, SQ_POST)) {
+
+    // security check
+    sqgetGlobalVar('smtoken', $submitted_token, SQ_POST, '');
+    sm_validate_security_token($submitted_token, 3600, TRUE);
+
     /* perform basic checks */
     /* perform basic checks */
     $Messages = cpw_check_input();
     $Messages = cpw_check_input();
 
 
@@ -83,6 +88,7 @@ if (isset($Messages) && count($Messages) > 0) {
 
 
 ?><tr><td>
 ?><tr><td>
     <?php echo addForm($_SERVER['PHP_SELF'], 'post'); ?>
     <?php echo addForm($_SERVER['PHP_SELF'], 'post'); ?>
+    <input type="hidden" name="smtoken" value="<?php echo sm_generate_security_token() ?>" />
     <table>
     <table>
       <tr>
       <tr>
         <th align="right"><?php echo _("Current Password:")?></th>
         <th align="right"><?php echo _("Current Password:")?></th>