-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathedit.php
More file actions
159 lines (146 loc) · 4.81 KB
/
edit.php
File metadata and controls
159 lines (146 loc) · 4.81 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
/**
*
* BUGGY Deadline... (EDIT MODUL)
* ------------------------------
*
* Alle rights reserved - (c) 2018 mahid_hm
*
*/
// START & CONFIG
ob_start();
require 'setup/config.php';
// SET LANGUAGE
if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) and
file_exists('lang/'.substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2).'.php')
) {
@include_once('lang/'.substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2).'.php');
} else {
@include_once('lang/'.$LANG.'.php');
}
// INI VARs
$file = 'data/'.$TYPE.'.json'; // DATA FILE NAME
// LOGIN CHECK
session_start();
$sessionname = md5($USER.$SALT);
if(!@$_SESSION[$sessionname]){
header('location: login.php');
exit;
}
// READ DATA
$jsonString = file_get_contents( $file );
$data = json_decode( $jsonString, true );
// GENERATE LIST FOR DATA-LIST IN NAME INPUT FIELD
foreach ( $data as $key => $values ) {
$list .= '<option value="'.$values['name'].'">';
}
// DEFAULT DATE IF NOT SET
if ( $data[@$_GET['id']]['date'] == '' ) {
$data[@$_GET['id']]['date'] = date( $DATE );
}
// SAVE NEW ENTRY IF FORM POSTED
if ( $_SERVER['REQUEST_METHOD'] == 'POST' and
@$_POST['name'] != '' and
@$_POST['text'] != '' and
@$_POST['status'] != '' ) {
$jsonString = file_get_contents( $file );
$data = json_decode( $jsonString, true );
foreach ( $data as $key => $entry ) {
if ( $key == $_GET['id'] ) {
$data[$key]['date'] = $_POST['date'];
$data[$key]['name'] = $_POST['name'];
$data[$key]['text'] = $_POST['text'];
$data[$key]['status'] = $_POST['status'];
}
}
$newJsonString = json_encode( $data );
file_put_contents( $file, $newJsonString );
header( 'location: index.php?msg='.$i18n['Entry successfully edited!'] );
} else if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
$_GET['msg'] = $i18n['All fields are required!'];
}
// HEADER
ob_end_flush();
include 'tpl/header.php';
// FORM FOR EDIT ENTRY
?>
<div class="badge grey lighten-3 hoverable" style="padding:1em">
<h3 class="grey-text text-darken-2"><?php echo $i18n['Edit Issue']; ?></h3>
<form method="POST">
<div class="row">
<div class="input-field col s4">
<input
value="<?php echo $data[@$_GET['id']]['date']; ?>"
id="date"
name="date"
type="text"
class="datepicker"
maxlength="<?php strlen($PICK); ?>"
data-length="<?php strlen($PICK); ?>"
required="required"
placeholder="<?php echo $data[@$_GET['id']]['date']; ?>"
>
<label class="active" for="date"><?php echo $i18n['Date']; ?></label>
<span class="helper-text" data-error="Error" data-success="OK">
<?php echo $i18n['Creation date or deadline!']; ?>
</span>
</div>
<div class="input-field col s8">
<input
value="<?php echo $data[@$_GET['id']]['name']; ?>"
id="name"
name="name"
type="text"
class="validate"
maxlength="32"
data-length="32"
required="required"
autocomplete="off"
list="list"
placeholder="<?php echo $data[@$_GET['id']]['name']; ?>"
>
<datalist id="list">
<?php echo $list; ?>
</datalist>
<label class="active" for="name"><?php echo $i18n['Name']; ?></label>
<span class="helper-text" data-error="Error" data-success="OK">
<?php echo $i18n['Quick summary or projectname.']; ?>
</span>
</div>
<div class="input-field col s12">
<textarea
id="text"
name="text"
class="materialize-textarea validate"
maxlength="128"
data-length="128"
required="required"
placeholder="<?php echo $data[@$_GET['id']]['text']; ?>"
><?php echo $data[@$_GET['id']]['text']; ?></textarea>
<label class="active" for="text"><?php echo $i18n['Text']; ?></label>
<span class="helper-text" data-error="Error" data-success="OK">
<?php echo $i18n['Describe the issue in detail.']; ?>
</span>
</div>
<div class="input-field col s12">
<select name="status" id="status">
<option selected><?php echo $data[@$_GET['id']]['status'];?></option>
<option value="" disabled><?php echo $i18n['Choose']; ?></option>
<?php require 'types/'.$TYPE.'/status.txt'; ?>
</select>
<label for="status"><?php echo $i18n['Label']; ?></label>
<span class="helper-text" data-error="Error" data-success="OK">
<?php echo $i18n['Select one label.']; ?>
</span>
</div>
</div>
<button class="black btn waves-effect waves-light" type="submit" name="action">
<?php echo $i18n['Save Issue']; ?>
<i class="material-icons right">save</i>
</button>
</form>
</div>
<br>
<?php
// FOOTER
include 'tpl/footer.php';