mirror of
https://github.com/Mibew/design.git
synced 2025-01-23 02:20:34 +03:00
format the code; remove comments in the client code; move csrfchecktoken() right after check_login()
This commit is contained in:
parent
2d04bbe4ee
commit
dd6632ffdf
@ -689,7 +689,8 @@ function jspath()
|
||||
}
|
||||
|
||||
/* authorization token check for CSRF attack */
|
||||
function csrfchecktoken(){
|
||||
function csrfchecktoken()
|
||||
{
|
||||
setcsrftoken();
|
||||
|
||||
// check the turing code for post requests and del requests
|
||||
@ -708,21 +709,24 @@ function csrfchecktoken(){
|
||||
}
|
||||
|
||||
/* print csrf token as a hidden field*/
|
||||
function print_csrf_token_input(){
|
||||
function print_csrf_token_input()
|
||||
{
|
||||
setcsrftoken();
|
||||
|
||||
echo "<input name='csrf_token' type='hidden' value='" . $_SESSION['csrf_token'] . "' />";
|
||||
}
|
||||
|
||||
/* print csrf token in url format */
|
||||
function print_csrf_token_in_url(){
|
||||
function print_csrf_token_in_url()
|
||||
{
|
||||
setcsrftoken();
|
||||
|
||||
echo "&csrf_token=" . $_SESSION['csrf_token'];
|
||||
}
|
||||
|
||||
/* set csrf token */
|
||||
function setcsrftoken(){
|
||||
function setcsrftoken()
|
||||
{
|
||||
if (!isset($_SESSION['csrf_token'])) {
|
||||
$_SESSION['csrf_token'] = sha1(rand(10000000, 99999999));
|
||||
}
|
||||
|
@ -23,9 +23,8 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/operator_settings.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
|
||||
$opId = verifyparam("op", "/^\d{1,9}$/");
|
||||
$page = array('opid' => $opId, 'avatar' => '');
|
||||
|
@ -25,9 +25,8 @@ require_once('../libs/settings.php');
|
||||
require_once('../libs/groups.php');
|
||||
require_once('../libs/pagination.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
loadsettings();
|
||||
|
||||
$errors = array();
|
||||
|
@ -23,8 +23,6 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/pagination.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
function load_message($key)
|
||||
{
|
||||
global $mysqlprefix;
|
||||
@ -54,6 +52,7 @@ function add_message($locale, $groupid, $message)
|
||||
}
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
loadsettings();
|
||||
|
||||
$stringid = verifyparam("key", "/^\d{0,9}$/", "");
|
||||
|
@ -23,9 +23,8 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/settings.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
|
||||
$page = array('agentId' => '');
|
||||
$errors = array();
|
||||
|
@ -23,9 +23,8 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/operator_settings.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
|
||||
$page = array('opid' => '');
|
||||
$errors = array();
|
||||
|
@ -22,9 +22,8 @@
|
||||
require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
|
||||
if (isset($_GET['act']) && $_GET['act'] == 'del') {
|
||||
$operatorid = isset($_GET['id']) ? $_GET['id'] : "";
|
||||
|
@ -23,9 +23,8 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/settings.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
|
||||
$page = array('agentId' => '');
|
||||
$errors = array();
|
||||
|
@ -23,8 +23,8 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/operator_settings.php');
|
||||
|
||||
csrfchecktoken();
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
|
||||
function update_operator_permissions($operatorid, $newvalue)
|
||||
{
|
||||
|
@ -23,9 +23,8 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/settings.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
|
||||
$page = array('agentId' => '');
|
||||
$errors = array();
|
||||
|
@ -23,8 +23,6 @@ require_once('../libs/common.php');
|
||||
require_once('../libs/operator.php');
|
||||
require_once('../libs/pagination.php');
|
||||
|
||||
csrfchecktoken();
|
||||
|
||||
function compare_localization_by_l1($a, $b)
|
||||
{
|
||||
if ($a == $b) {
|
||||
@ -121,6 +119,7 @@ function get_auxiliary($s)
|
||||
}
|
||||
|
||||
$operator = check_login();
|
||||
csrfchecktoken();
|
||||
|
||||
$source = verifyparam("source", "/^[\w-]{2,5}$/", $default_locale);
|
||||
$target = verifyparam("target", "/^[\w-]{2,5}$/", $current_locale);
|
||||
|
@ -50,10 +50,7 @@ require_once('inc_errors.php');
|
||||
|
||||
<?php if( $page['opid'] || $page['canmodify'] ) { ?>
|
||||
<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'] ?>"/>
|
||||
<div>
|
||||
<?php if(!$page['needChangePassword']) { print_tabbar(); } ?>
|
||||
|
@ -36,10 +36,7 @@ require_once('inc_errors.php');
|
||||
?>
|
||||
|
||||
<form name="avatarForm" method="post" action="<?php echo $webimroot ?>/operator/avatar.php" enctype="multipart/form-data">
|
||||
|
||||
<!-- add csrf token -->
|
||||
<?php print_csrf_token_input() ?>
|
||||
|
||||
<input type="hidden" name="op" value="<?php echo $page['opid'] ?>"/>
|
||||
<div>
|
||||
<?php print_tabbar(); ?>
|
||||
|
@ -44,10 +44,7 @@ require_once('inc_errors.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'] ?>"/>
|
||||
<?php if(!$page['key']) { ?>
|
||||
<input type="hidden" name="lang" value="<?php echo $page['locale'] ?>"/>
|
||||
|
@ -73,10 +73,7 @@ require_once('inc_errors.php');
|
||||
<?php } ?>
|
||||
|
||||
<form name="features" method="post" action="<?php echo $webimroot ?>/operator/features.php">
|
||||
|
||||
<!-- add auth token -->
|
||||
<?php print_csrf_token_input() ?>
|
||||
|
||||
<input type="hidden" name="sent" value="true"/>
|
||||
<div>
|
||||
<?php print_tabbar(); ?>
|
||||
|
@ -39,10 +39,7 @@ require_once('inc_errors.php');
|
||||
<?php } ?>
|
||||
|
||||
<form name="performance" method="post" action="<?php echo $webimroot ?>/operator/performance.php">
|
||||
|
||||
<!-- add auth token -->
|
||||
<?php print_csrf_token_input() ?>
|
||||
|
||||
<div>
|
||||
<?php print_tabbar(); ?>
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
|
@ -39,10 +39,7 @@ require_once('inc_errors.php');
|
||||
<?php } ?>
|
||||
|
||||
<form name="permissionsForm" method="post" action="<?php echo $webimroot ?>/operator/permissions.php">
|
||||
|
||||
<!-- add csrf token -->
|
||||
<?php print_csrf_token_input() ?>
|
||||
|
||||
<input type="hidden" name="op" value="<?php echo $page['opid'] ?>"/>
|
||||
<div>
|
||||
<?php print_tabbar(); ?>
|
||||
|
@ -39,10 +39,7 @@ require_once('inc_errors.php');
|
||||
<?php } ?>
|
||||
|
||||
<form name="settings" method="post" action="<?php echo $webimroot ?>/operator/settings.php">
|
||||
|
||||
<!-- add auth token -->
|
||||
<?php print_csrf_token_input() ?>
|
||||
|
||||
<div>
|
||||
<?php print_tabbar(); ?>
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
|
@ -44,10 +44,7 @@ require_once('inc_errors.php');
|
||||
?>
|
||||
|
||||
<form name="translateForm" method="post" action="<?php echo $webimroot ?>/operator/translate.php">
|
||||
|
||||
<!-- add auth token -->
|
||||
<?php print_csrf_token_input() ?>
|
||||
|
||||
<input type="hidden" name="key" value="<?php echo $page['key'] ?>"/>
|
||||
<input type="hidden" name="target" value="<?php echo $page['target'] ?>"/>
|
||||
<div class="mform"><div class="formtop"><div class="formtopi"></div></div><div class="forminner">
|
||||
|
Loading…
Reference in New Issue
Block a user