mirror of
https://github.com/Mibew/tray.git
synced 2025-01-22 18:10:34 +03:00
having token checks on POST forms
Conflicts: src/messenger/webim/operator/cannededit.php
This commit is contained in:
parent
2d793bcb94
commit
5e75270cd0
@ -765,4 +765,24 @@ function jspath()
|
|||||||
return "js/$jsver";
|
return "js/$jsver";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* authorization token check for CSRF attack */
|
||||||
|
function csrfchecktoken(){
|
||||||
|
if(!isset($_SESSION['csrf_token'])){
|
||||||
|
$_SESSION['csrf_token']=sha1(rand(10000000,99999999));
|
||||||
|
}
|
||||||
|
// check the turing code
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
|
||||||
|
//if token match
|
||||||
|
if(!isset($_POST['csrf_token']) || ($_POST['csrf_token'] != $_SESSION['csrf_token'])){
|
||||||
|
|
||||||
|
die("CSRF failure");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* print csrf token as a hidden field*/
|
||||||
|
function print_csrf_token_input(){
|
||||||
|
echo "<input name='csrf_token' type='hidden' value='".$_SESSION['csrf_token']."' />";
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@ -24,6 +24,8 @@ require_once('../libs/common.php');
|
|||||||
require_once('../libs/operator.php');
|
require_once('../libs/operator.php');
|
||||||
require_once('../libs/pagination.php');
|
require_once('../libs/pagination.php');
|
||||||
|
|
||||||
|
csrfchecktoken();
|
||||||
|
|
||||||
$operator = check_login();
|
$operator = check_login();
|
||||||
loadsettings();
|
loadsettings();
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ require_once('../libs/common.php');
|
|||||||
require_once('../libs/operator.php');
|
require_once('../libs/operator.php');
|
||||||
require_once('../libs/operator_settings.php');
|
require_once('../libs/operator_settings.php');
|
||||||
|
|
||||||
|
csrfchecktoken();
|
||||||
|
|
||||||
$operator = check_login();
|
$operator = check_login();
|
||||||
|
|
||||||
$page = array('opid' => '');
|
$page = array('opid' => '');
|
||||||
|
@ -24,6 +24,8 @@ require_once('../libs/operator.php');
|
|||||||
require_once('../libs/settings.php');
|
require_once('../libs/settings.php');
|
||||||
require_once('../libs/styles.php');
|
require_once('../libs/styles.php');
|
||||||
|
|
||||||
|
csrfchecktoken();
|
||||||
|
|
||||||
$operator = check_login();
|
$operator = check_login();
|
||||||
force_password($operator);
|
force_password($operator);
|
||||||
|
|
||||||
|
@ -50,6 +50,10 @@ require_once('inc_errors.php');
|
|||||||
|
|
||||||
<?php if( $page['opid'] || $page['canmodify'] ) { ?>
|
<?php if( $page['opid'] || $page['canmodify'] ) { ?>
|
||||||
<form name="agentForm" method="post" action="<?php echo $webimroot ?>/operator/operator.php">
|
<form name="agentForm" method="post" action="<?php echo $webimroot ?>/operator/operator.php">
|
||||||
|
|
||||||
|
<!-- add auth token -->
|
||||||
|
<?php print_csrf_token_input() ?>
|
||||||
|
|
||||||
<input type="hidden" name="opid" value="<?php echo $page['opid'] ?>"/>
|
<input type="hidden" name="opid" value="<?php echo $page['opid'] ?>"/>
|
||||||
<div>
|
<div>
|
||||||
<?php if(!$page['needChangePassword']) { print_tabbar(); } ?>
|
<?php if(!$page['needChangePassword']) { print_tabbar(); } ?>
|
||||||
|
@ -44,6 +44,10 @@ require_once('inc_errors.php');
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<form name="cannedForm" method="post" action="<?php echo $webimroot ?>/operator/cannededit.php">
|
<form name="cannedForm" method="post" action="<?php echo $webimroot ?>/operator/cannededit.php">
|
||||||
|
|
||||||
|
<!-- add auth token -->
|
||||||
|
<?php print_csrf_token_input() ?>
|
||||||
|
|
||||||
<input type="hidden" name="key" value="<?php echo $page['key'] ?>"/>
|
<input type="hidden" name="key" value="<?php echo $page['key'] ?>"/>
|
||||||
<?php if(!$page['key']) { ?>
|
<?php if(!$page['key']) { ?>
|
||||||
<input type="hidden" name="lang" value="<?php echo $page['locale'] ?>"/>
|
<input type="hidden" name="lang" value="<?php echo $page['locale'] ?>"/>
|
||||||
|
@ -40,6 +40,9 @@ require_once('inc_errors.php');
|
|||||||
|
|
||||||
<form name="settings" method="post" action="<?php echo $webimroot ?>/operator/settings.php">
|
<form name="settings" method="post" action="<?php echo $webimroot ?>/operator/settings.php">
|
||||||
|
|
||||||
|
<!-- add auth token -->
|
||||||
|
<?php print_csrf_token_input() ?>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<?php print_tabbar(); ?>
|
<?php print_tabbar(); ?>
|
||||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||||
|
Loading…
Reference in New Issue
Block a user