api.php (3277B)
1 <?php
2
3 function api_error(
4 string $format,
5 string $message
6 ) {
7
8 /* if return format is html, return a HTML page */
9 if ($format == "html") {
10 header('Content-Type: text/html');
11
12 ?>
13
14 <!DOCTYPE html>
15 <html>
16
17 <head>
18 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
19 <title>Rememori</title>
20 <link rel="icon" type="image/png" href="/assets/img/favicon.png">
21 <link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon_16.png">
22 <link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon_32.png">
23 <link rel="icon" type="image/png" sizes="64x64" href="/assets/img/favicon_64.png">
24 <link rel="icon" type="image/png" sizes="128x128" href="/assets/img/favicon_128.png">
25 <link rel="icon" type="x-image/ico" sizes="32x32" href="/assets/img/favicon.ico">
26 <link rel="apple-touch-icon" type="image/png" href="/assets/img/favicon.png">
27 <link rel=stylesheet href=/assets/css/simple.min.css media=all>
28 <link rel=stylesheet href=/assets/css/custom.css>
29 <meta name="viewport" content="width=device-width, initial-scale=1.0">
30 </head>
31
32 <body>
33 <header>
34 <h1><?php echo $GLOBALS["i18n_error"]; ?></h1>
35 </header>
36 <p><?php echo $message; ?></p>
37 </body>
38 </html>
39
40 <?php
41
42 } else {
43 /* Use JSON as fallback */
44 header('Content-Type: application/json');
45 echo json_encode(array(
46 "status" => "error",
47 "message" => $message
48 ));
49 } // if-statement
50 } // function
51
52 function api_write_success(
53 string $format,
54 string $path
55 ) {
56
57 /* if return format is html, return a HTML page */
58 if ($format == "html") {
59 header('Content-Type: text/html');
60
61 ?>
62
63 <!DOCTYPE html>
64 <html>
65
66 <head>
67 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
68 <title>Rememori</title>
69 <link rel="icon" type="image/png" href="/assets/img/favicon.png">
70 <link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon_16.png">
71 <link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon_32.png">
72 <link rel="icon" type="image/png" sizes="64x64" href="/assets/img/favicon_64.png">
73 <link rel="icon" type="image/png" sizes="128x128" href="/assets/img/favicon_128.png">
74 <link rel="icon" type="x-image/ico" sizes="32x32" href="/assets/img/favicon.ico">
75 <link rel="apple-touch-icon" type="image/png" href="/assets/img/favicon.png">
76 <link rel=stylesheet href=/assets/css/simple.min.css media=all>
77 <link rel=stylesheet href=/assets/css/custom.css>
78 <meta name="viewport" content="width=device-width, initial-scale=1.0">
79 </head>
80
81 <body>
82 <header>
83 <h1><?php echo $GLOBALS["i18n_success"]; ?></h1>
84 </header>
85 <p><?php echo $GLOBALS["i18n_note_written_to"] . " " . $path; ?></p>
86 </body>
87 </html>
88
89 <?php
90
91 } else {
92 /* Use JSON as fallback */
93 header('Content-Type: application/json');
94 echo json_encode(array(
95 "status" => "success",
96 "message" => $GLOBALS["i18n_note_written_to"] . " " . $path
97 ));
98 } // if-state
99 }
100
101 ?>