Skip to content

Commit 9eadd7f

Browse files
stonebuzzcedric-anne
authored andcommitted
fix(core): fix CSRF check
1 parent 5e97c99 commit 9eadd7f

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

front/surveytranslation.form.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/*
3+
* @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $
4+
-------------------------------------------------------------------------
5+
satisfaction plugin for GLPI
6+
Copyright (C) 2016-2022 by the satisfaction Development Team.
7+
8+
https://github.com/pluginsglpi/satisfaction
9+
-------------------------------------------------------------------------
10+
11+
LICENSE
12+
13+
This file is part of satisfaction.
14+
15+
satisfaction is free software; you can redistribute it and/or modify
16+
it under the terms of the GNU General Public License as published by
17+
the Free Software Foundation; either version 2 of the License, or
18+
(at your option) any later version.
19+
20+
satisfaction is distributed in the hope that it will be useful,
21+
but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23+
GNU General Public License for more details.
24+
25+
You should have received a copy of the GNU General Public License
26+
along with satisfaction. If not, see <http://www.gnu.org/licenses/>.
27+
--------------------------------------------------------------------------
28+
*/
29+
30+
include('../../../inc/includes.php');
31+
32+
if (!isset($_POST['survey_id']) || !isset($_POST['action'])) {
33+
exit();
34+
}
35+
36+
$redirection = Plugin::getWebDir('satisfaction')."/front/survey.form.php?id=";
37+
$translation = new PluginSatisfactionSurveyTranslation();
38+
switch($_POST['action']){
39+
case 'NEW':
40+
$translation->newSurveyTranslation($_POST);
41+
Html::redirect($redirection.$_POST['survey_id']);
42+
break;
43+
44+
case 'EDIT':
45+
$translation->editSurveyTranslation($_POST);
46+
Html::redirect($redirection.$_POST['survey_id']);
47+
break;
48+
}

inc/surveytranslation.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ function getQuestionDropdown($surveyId){
368368
function getFormHeader($translationID, $surveyID){
369369

370370
global $CFG_GLPI;
371-
$target = Plugin::getWebDir('satisfaction')."/ajax/surveytranslation.form.php";
371+
$target = Plugin::getWebDir('satisfaction')."/front/surveytranslation.form.php";
372372

373373
$result = "<form name='form' method='post' action='$target' enctype='multipart/form-data'>";
374374
$result.= Html::hidden('survey_id', ['value' =>$surveyID]);

inc/surveytranslation.dao.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static function newSurveyTranslation($surveyId, $questionId, $language, $value){
115115
$query .= " VALUES(".$surveyId.",".$questionId.",'".$language."','".$value."')";
116116

117117
if($DB->query($query)){
118-
return $DB->insert_id();
118+
return $DB->insertId();
119119
}else{
120120
return null;
121121
}

0 commit comments

Comments
 (0)