-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethod.php
More file actions
57 lines (46 loc) · 1.46 KB
/
method.php
File metadata and controls
57 lines (46 loc) · 1.46 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
52
53
54
55
56
57
<?php
$path = "pass.json";
$code = $_POST['code'];
$found = false;
if (!is_null($code)){
echo($code."\n");
// Read the JSON file
$json = file_get_contents($path);
// Decode the JSON file
$json_data = json_decode($json, true);
for($i = 0; $i < count($json_data); ++$i) {
if($json_data[$i]['code']==trim($code)){
$found = true;
echo("code existe\n");
if($json_data[$i]['lu']==true){
echo("deja lu\n");
}else{
//show link
echo( $json_data[$i]['lien']."\n");
//change statut
$json_data[$i]['lu']=true;
// save data after edition
// Convert JSON data from an array to a string
$jsonString = json_encode($json_data, JSON_PRETTY_PRINT);
// Write in the file
$fp = fopen($path, 'w');
fwrite($fp, $jsonString);
fclose($fp);
}
break;
}
}
if($found == false){
echo("Nous n'avons pas ce code");
}
// save data after edition
// Convert JSON data from an array to a string
// $jsonString = json_encode($json_data, JSON_PRETTY_PRINT);
// Write in the file
// $fp = fopen($path, 'w');
// fwrite($fp, $jsonString);
// fclose($fp);
// send to pass link
}else{
header("form.php");
}