-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetting.php
More file actions
51 lines (37 loc) · 1.11 KB
/
setting.php
File metadata and controls
51 lines (37 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
session_start();
if(isset($_POST["content"]) && isset($_POST["name"]) && isset($_SESSION["id"]) && isset($_GET["csrf_token"])){
if(isset($_GET["csrf_token"]) && isset($_SESSION["csrf_token"])){
if($_GET["csrf_token"] !== $_SESSION["csrf_token"]){
echo("403 Error");
http_response_code(403);
exit();
}
}else{
echo("403 Error");
http_response_code(403);
exit();
}
$user_id = $_SESSION["id"];
$name = $_POST["name"];
$content = $_POST["content"];
if(strpos($name,',') === true || strpos($name,"\n") === true){
exit();
}
$all_content = "";
//検索結果を更新
$lines = file("./setting/".$user_id.".csv");
foreach($lines as $line){
$data = explode(',',$line);
if($data[0] === $name){
$all_content .= $name.",".$content."\n";
}else{
$all_content .= $line;
}
}
$filename = './setting/'.$user_id.'.csv';
$fp = fopen($filename, 'w');
fputs($fp, $all_content);
fclose($fp);
}
?>