-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes.php
52 lines (51 loc) · 1.37 KB
/
classes.php
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
<?php
class link {
//Link erstellen
public function create ($title, $url, $folder) {
if(!empty($title) && !empty($url) && !empty($folder)) {
$file = file("data.json");
$list = json_decode($file[0]);
$new_title = htmlspecialchars($title, ENT_QUOTES);
$new_url = htmlspecialchars($url, ENT_QUOTES);
$new_folder = htmlspecialchars($folder, ENT_QUOTES);
array_push($list->links, array("title"=>$new_title, "url"=>$new_url, "folder"=>$new_folder));
$jsonlist = json_encode($list);
$data = fopen("data.json", "w");
fwrite($data, $jsonlist);
fclose($data);
}
}
//Link löschen
public function delete ($title) {
$file = file("data.json");
$list = json_decode($file[0]);
$i = 0;
foreach($list->links as $link) {
if($link->title == $title) {
$x = $i;
}
$i++;
}
unset($list->links[$x]);
$jsonlist = json_encode($list);
$data = fopen("data.json", "w");
fwrite($data, $jsonlist);
fclose($data);
}
}
class folder {
//Ordner erstllen
public function create ($name) {
if(!empty($name)) {
$file = file("data.json");
$list = json_decode($file[0]);
$new_name = htmlspecialchars($name, ENT_QUOTES);
array_push($list->folders, array("name"=>$new_name));
$jsonlist = json_encode($list);
$data = fopen("data.json", "w");
fwrite($data, $jsonlist);
fclose($data);
}
}
}
?>