This repository was archived by the owner on Jun 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteacher.php
312 lines (292 loc) · 21.9 KB
/
teacher.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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
include('class.token.php');
require 'inc/head.php';
global $re;
?>
<div class="row">
<div class="col-md-12">
<h2> مامۆستایان</h2>
<?php if($das==1){ ?>
<h5>دەستکاریکردنی زانیاری مامۆستایان و ڕێکخستنیان</h5>
<?php if (!isset($_GET['add'])) { ?>
<a href="user.php?multi" style="float: left;margin-right: 5px;" class="btn btn-info"><i class="fa fa-users"></i> زیادکردن بەکۆمەڵ </a>
<a href="teacher.php?add" style="float: left;" class="btn btn-success"><i class="fa icon-teacher"></i> زیادکردنی مامۆستا </a>
<?php }elseif(isset($_GET['add']) && !isset($_GET['id'])) { ?>
<a href="teacher.php" style="float: left;" class="btn btn-info"><i class="fa icon-teacher"></i> گەڕانەوە </a>
<?php }} ?>
</div>
</div>
<!-- /. ROW -->
<hr />
<div class="row">
<div class="col-md-12">
<?php if (isset($_GET['add'])) { ?>
<div class="col-xs-12">
<?php
if (!isset($_GET['id'])) {
?>
<div class="panel panel-default">
<div class="panel-heading">زیادکردنی هەژمار بۆ مامۆستا</div>
<div class="panel-body">
<?php
if (isset($_POST['sub2'])) {
if(Token::check($_POST['token']) AND !empty($_POST['token'])){
$user=@output($_POST['user']);
$pass=@output($_POST['np']);
$p=password_hash($pass, PASSWORD_BCRYPT);
$rnp=@output($_POST['rnp']);
if (preg_match('/^[A-Za-z0-9_-]*$/', $user)){
if(user($user)==0){
if(!empty($user) && !empty($pass) && !empty($rnp) ){
if ($pass==$rnp) {
$stm = $db->prepare("INSERT INTO account (id, user, pass,r) VALUES (NULL, :user, :pass,2);");
$stm->bindParam(":user", $user, PDO::PARAM_STR);
$stm->bindParam(":pass", $p, PDO::PARAM_STR);
$stm->execute();
AddtoHistory("زیادکردنی هەژمار بۆ مامۆستا",home);
re("success"," سوپاس "," هەژماری مامۆستا بەسەرکەوتویی زیادکرا. ");
direct("./teacher.php?add&id&u=$user");
}else{
re("danger"," هەڵە! "," پێویستە وشە نهێنیەکانت وەکو یەکبن.");
}
}else {
re("danger"," کێشە! "," تکایە خانەکان بە دروستی پڕبکەوە.");
}
}else {
re("info","ناوی بەکارهێنەر "," پێشتر بەکاربراوە لەلایەن کەسێکی تر.");
}
}else {
re("info","پێویستە "," ناوی بەکارهێنەر تەنها زمانی ئینگلیزی بەکار بهێنیت.");
}
}else {
re("danger"," کێشە! "," کێشەیەک ڕویدا تکایە دووبارە هەوڵ بدەوە.");
}
}
?>
<form action="" method="post">
<div class="form-group">
<label class="req">ناوی بەکارهێنەر</label>
<input type="text" name="user" id="user" class="form-control user" autocomplete="off">
<small style="display: none" class="help-block">ناوی بەکارهێنەر پێشتر بەکارهێنراوە!</small>
</div>
<div class="form-group">
<label class="req">وشەی نهێنی </label>
<input type="password" name="np" class="form-control">
</div>
<div class="form-group">
<label class="req">دووبارە وشەی نهێنی </label>
<input type="password" name="rnp" class="form-control">
</div>
<input type="hidden" name="token" value="<?php echo Token::create(); ?>">
<button type="submit" name="sub2" class="btn btn-default">زیادکردن</button>
</form>
</div>
</div>
<?php }else{ ?>
<div class="panel panel-default">
<div class="panel-heading">زانیاریەکانی مامۆستا</div>
<div class="panel-body">
<?php
global $user;
$u= output(@$_GET['u']);
if (isset($_POST['sub'])) {
if(Token::check($_POST['token']) AND !empty($_POST['token'])){
$fname=output(@$_POST['fname']);
$gen=output(@$_POST['gen']);
$relig=output(@$_POST['relig']);
$num=output(@$_POST['num']);
$birth=output(@$_POST['birth']);
$desig=output(@$_POST['desig']);
$email=output(@$_POST['email']);
$addr=output(@$_POST['addr']);
$sd=output(@$_POST['sd']);
upload();
checkInput();
if(!empty($fname) && !empty($gen) && (!empty($desig) OR $feilds["tea_desig"]=="") && !empty($birth) && !empty($email) && !empty($sd) && (!empty($num) OR $feilds["tea_num"]=="") && (!empty($addr) OR $feilds["tea_loc"]=="")){
$stm = $db->prepare("INSERT INTO tea (id,user , fname, gen, relig, num, birth, desig, email, addr, img, sdate) VALUES (NULL, :user,:fn, :g, :re, :n, :b, :desig, :e, :ad, :img, :sd);");
$stm->bindParam(":fn", $fname, PDO::PARAM_STR);
$stm->bindParam(":g", $gen, PDO::PARAM_STR);
$stm->bindParam(":re", $relig, PDO::PARAM_STR);
$stm->bindParam(":n", $num, PDO::PARAM_STR);
$stm->bindParam(":b", $birth, PDO::PARAM_STR);
$stm->bindParam(":desig", $desig, PDO::PARAM_STR);
$stm->bindParam(":e", $email, PDO::PARAM_STR);
$stm->bindParam(":ad", $addr, PDO::PARAM_STR);
$stm->bindParam(":img", $img, PDO::PARAM_STR);
$stm->bindParam(":sd", $sd, PDO::PARAM_STR);
$stm->bindParam(":user", $u, PDO::PARAM_STR);
$stm->execute();
AddtoHistory("زیادکردنی مامۆستا",home);
re("success"," سوپاس "," زانیاری مامۆستا بەسەرکەوتویی زیادکرا. ");
direct("./teacher.php");
$db = null;
}else {
re("danger"," کێشە! "," تکایە خانەکان بە دروستی پڕبکەوە، وێنەی دروست هەڵبژێرە.");
}
}else {
re("danger"," کێشە! "," کێشەیەک ڕویدا تکایە دووبارە هەوڵ بدەوە.");
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<div class="col-md-6">
<div class="form-group">
<label>ناوی بەکارهێنەر</label>
<input disabled="" value="<?php echo $u; ?>" name="user" class="form-control">
</div>
<div class="form-group">
<label>وێنە</label>
<input type="file" accept="image/png, image/jpeg, image/gif, image/jpg" name="fileToUpload" data-label="دیاریکردن" class="filepicker form-control">
</div>
<div class="form-group">
<label class="req">ناوی تەواوەتی</label>
<input value="<?=@$fname;?>" name="fname" class="form-control">
</div>
<div class="form-group">
<label class="req">ڕەگەز</label>
<select class="selectpicker" data-width="100%" name="gen" class="form-control">
<option value="1">نێر</option>
<option value="2">مێ</option>
</select>
</div>
<div class="form-group">
<label <?php echo $feilds["tea_relig"] != "" ? ' class="req"' : ''; ?>>بیرو باوەڕ (دین)</label>
<input value="<?=@$relig;?>" name="relig" class="form-control">
</div>
<div class="form-group">
<label <?php echo $feilds["tea_num"] != "" ? ' class="req"' : ''; ?>>ژمارە مۆبایل</label>
<input value="<?=@$num;?>" name="num" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label <?php echo $feilds["stu_loc"] != "" ? ' class="req"' : ''; ?>>ناونیشان</label>
<div class="typeahead__container">
<div class="typeahead__field">
<span class="typeahead__query">
<input type="text" value="<?=@$addr;?>" name="addr" type="search" autocomplete="off" class="form-control" id="loc">
</span>
</div>
</div>
</div><br>
<div class="form-group">
<label class="req">بەرواری لەدایک بوون</label>
<input value="<?=@$birth;?>" type="text" id="date" autocomplete="off" value="01/01/1985" name="birth" class="form-control">
</div>
<div class="form-group">
<label <?php echo $feilds["tea_desig"] != "" ? ' class="req"' : ''; ?>>پسپۆڕی</label>
<input value="<?=@$desig;?>" type="text" name="desig" class="form-control" autocomplete="off">
</div>
<div class="form-group">
<label class="req">ئیمەیڵ</label>
<input name="email" value="<?=@$email;?>" class="form-control">
</div>
<div class="form-group">
<label class="req">بەرواری دەستپێکردن</label>
<input type="text" value="<?=@$sd;?>" id="date1" autocomplete="off" name="sd" class="form-control">
</div>
<br><br><br><br>
</div>
<input type="hidden" name="token" value="<?php echo Token::create(); ?>">
<button type="submit" name="sub" class="btn btn-default">زیادکردن</button>
</form>
</div>
</div>
<?php } ?>
</div>
<!-- PART -->
</div>
<?php
}else{
$del = output(@$_GET['del']);
if (isset($del) && $del!="") {
$stm = $db->prepare("DELETE FROM tea WHERE user=:id");
$stm->bindParam(":id", $del, PDO::PARAM_STR);
$stm->execute();
AddtoHistory("سڕئنەوەی مامۆستا",home);
re("danger"," مامۆستا ","بەسەرکەوتویی سڕایەوە.");
//direct("teacher.php");
}
?>
<!-- Advanced Tables -->
<div class="panel panel-default">
<div class="panel-heading">
لیستی مامۆستایان
</div>
<div class="panel-body">
<?php
$stm = $db->prepare("SELECT * FROM tea");
$stm->execute();
$rowCount = $stm->rowCount();
if($rowCount > 0){
?>
<div class="table-responsive">
<table id="advance" class="table table-striped table-bordered table-hover" data-id="dataTables-example">
<thead>
<tr>
<th width="50px">#</th>
<th width="50px">وێنە</th>
<th>ناوی تەواوەتی</th>
<th>وانەکان</th>
<?php if($das==1){ ?>
<th width="110px">کردار</th>
<?php } ?>
</tr>
</thead>
<tbody>
<?php
$nu = 0;
while($row = $stm->fetch(PDO::FETCH_ASSOC)) {
?>
<tr class="<?php if($nu % 2==0){echo 'odd';}else{echo 'even';} ?>">
<td><?php echo $row['id']; ?></td>
<td><img class="atach" src="uploads/<?php echo $row['img']; ?>" alt=""></td>
<td><?php echo $row['fname']; ?></td>
<td><?php
$n=$r=$i="";
$stm1 = $db->prepare("SELECT * FROM sub WHERE tea=:id");
$stm1->bindParam(":id", $row['id'], PDO::PARAM_STR);
$stm1->execute();
$rowCount1 = $stm1->rowCount();
if ($rowCount1>0) {
while($row1 = $stm1->fetch(PDO::FETCH_ASSOC)) {
if($rowCount1!=1 AND $i!=0){$n=" , ";}
$r = $r.$n.$row1['sn'];
$i++;
}
echo $r;
}
?></td>
<?php if($das==1){ ?>
<td>
<a href="profile.php?user=<?php echo $row['user']; if($das==1){echo "&r=2";} ?>" class="btn btn-success btn-xs mrg" data-toggle="tooltip" data-placement="top" title="بینین"><i class="fa fa-check-square-o"></i></a>
<a href="profile.php?user=<?php echo $row['user']; if($das==1){echo "&r=2";} ?>#edit" data-toggle="tooltip" data-placement="top" class="btn btn-warning btn-xs mrg" title="دەستکاری"><i class="fa fa-edit"></i></a>
<a href="teacher.php?del=<?php echo $row['user']; ?>" value="#go" id="btn-confirm" data-toggle="tooltip" data-placement="top" class="btn btn-danger btn-xs mrg confirmation" title="سڕینەوە"><i class="fa fa-trash-o"></i></a>
</td>
<?php } ?>
</tr>
<?php
$nu++;
}
?>
</tbody>
</table>
</div>
<?php
} else {
echo 'هیچ ئەنجامێك نەدۆزراوە!';
}
?>
</div>
</div>
<!--End Advanced Tables -->
<?php } ?>
</div>
</div>
<!-- /. ROW -->
</div>
<!-- /. ROW -->
<div class="alert" role="alert" id="result"></div>
<?php
$db = null;
include 'inc/foot.php'; ?>