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 pathlibrary.php
337 lines (314 loc) · 23.9 KB
/
library.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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?php
include('class.token.php');
require 'inc/head.php';
global $re;
?>
<div class="row">
<div class="col-md-12">
<h2> کتێبخانە</h2>
<h5>دەستکاریکردنی کتابەکان و خوێندنەوەیان</h5>
<?php if (!isset($_GET['id'])) { ?>
<a href="library.php?id" style="float: left;" class="btn btn-primary"><i class="fa icon-library"></i> زیادکردنی کتێب </a>
<?php }elseif(isset($_GET['id']) && !isset($_GET['edit'])) { ?>
<a href="library.php" style="float: left;" class="btn btn-info"><i class="fa icon-library"></i> گەڕانەوە </a>
<?php } ?>
</div>
</div>
<!-- /. ROW -->
<hr />
<div class="row">
<div class="col-md-12">
<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
$type=@output($_POST['type']);
$bn=@output($_POST['bn']);
$ba=@output($_POST['ba']);
$ab=@output($_POST['ab']);
$type=@output($_POST['type']);
if (isset($_POST['sub2'])) {
if(Token::check($_POST['token']) AND !empty($_POST['token'])){
upload();
pdf();
checkInput();
if($pdfOk==1 AND (!isset($ab) OR $feilds['book_ab']=="") AND !empty($type) AND !empty($bn) AND !empty($ba)){
// $stm = $db->prepare("SELECT * FROM sub WHERE cl=:cl AND tea=:tea");
// $stm->bindParam(":cl", $cl, PDO::PARAM_STR);
// $stm->bindParam(":tea", $tea, PDO::PARAM_STR);
// $stm->execute();
// $rowCount = $stm->rowCount();
// if($rowCount == 0){
$stm = $db->prepare("INSERT INTO lib (id, pdf, bn, ba, type, ab,img) VALUES (NULL, :pdf, :bn, :ba, :type, :ab,:img);");
$stm->bindParam(":bn", $bn, PDO::PARAM_STR);
$stm->bindParam(":ba", $ba, PDO::PARAM_STR);
$stm->bindParam(":pdf", $pdf, PDO::PARAM_STR);
$stm->bindParam(":ab", $ab, PDO::PARAM_STR);
$stm->bindParam(":type", $type, PDO::PARAM_STR);
$stm->bindParam(":img", $img, PDO::PARAM_STR);
$stm->execute();
AddtoHistory("زیادکردنی کتێب",home);
re("success"," سوپاس "," وانە بەسەرکەوتویی زیادکرا. ");
$db = null;
direct("./library.php");
// }else {
// re("info"," ببورە "," هەمان مامۆستا بەهمان بابەت پێشتر زیاد کراوە.");
// }
}else {
re("danger"," کێشە! "," تکایە خانەکان بە دروستی پڕبکەوە، وێنەی دروست هەڵبژێرە.");
}
}else {
re("danger"," کێشە! "," کێشەیەک ڕویدا تکایە دووبارە هەوڵ بدەوە.");
}
}
?>
<form action="" method="post" enctype="multipart/form-data">
<div class="form-group">
<label class="req">ناوی کتاب</label>
<input type="text" name="bn" value="<?=@$bn;?>" placeholder="" class="form-control">
</div>
<div class="form-group">
<label class="req">ناوی نوسەری کتاب</label>
<input type="text" name="ba" value="<?=@$ba;?>" placeholder="" class="form-control">
</div>
<div class="form-group">
<label class="req">PDF</label>
<input data-label="دیاریکردن" class="filepicker form-control" type="file" accept="application/pdf" name="uploadpdf" >
</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="<?=@$type;?>" type="text" name="type" class="form-control">
</div>
<div class="form-group">
<label <?php echo $feilds["book_ab"] != "" ? ' class="req"' : ''; ?>>کورتەیەک دەربارەی کتاب</label>
<textarea rows="6" type="text" name="ab" class="form-control"><?=@$ab;?></textarea>
</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
}elseif(isset($_GET['edit'])){ ?>
<div class="panel panel-default">
<div class="panel-heading">دەستکاریکردنی وانە</div>
<div class="panel-body">
<?php
$type=@output($_POST['type']);
$bn=@output($_POST['bn']);
$ba=@output($_POST['ba']);
$pdf=@output($_POST['pdf']);
$ab=@output($_POST['ab']);
$id=@output($_GET['edit']);
if (isset($_POST['sub2'])) {
if(Token::check($_POST['token']) AND !empty($_POST['token'])){
upload();
pdf();
checkInput();
if($pdfOk==1 AND (!empty($ab) OR $feilds['book_ab']=="") AND !empty($type) AND !empty($bn) AND !empty($ba)){
// $stm = $db->prepare("SELECT * FROM sub WHERE cl=:cl AND tea=:tea AND id!=:id");
// $stm->bindParam(":cl", $cl, PDO::PARAM_STR);
// $stm->bindParam(":tea", $tea, PDO::PARAM_STR);
// $stm->bindParam(":id", $id, PDO::PARAM_STR);
// $stm->execute();
// $rowCount = $stm->rowCount();
// if ($rowCount==0) {
$stm = $db->prepare("UPDATE lib SET bn=:bn,ba=:ba,ab=:ab,type=:type WHERE id=:id");
if ($uploadOk==1 AND $pdfOk!=1) {
$stm = $db->prepare("UPDATE lib SET bn=:bn,ba=:ba,ab=:ab,type=:type,img=:img WHERE id=:id");
$stm->bindParam(":img", $img, PDO::PARAM_STR);
}
if ($uploadOk!=1 AND $pdfOk==1) {
$stm = $db->prepare("UPDATE lib SET bn=:bn,ba=:ba,ab=:ab,type=:type,pdf=:pdf WHERE id=:id");
$stm->bindParam(":pdf", $pdf, PDO::PARAM_STR);
}
if ($uploadOk==1 AND $pdfOk==1) {
$stm = $db->prepare("UPDATE lib SET pdf=:pdf,bn=:bn,ba=:ba,ab=:ab,type=:type,img=:img WHERE id=:id");
$stm->bindParam(":img", $img, PDO::PARAM_STR);
$stm->bindParam(":pdf", $pdf, PDO::PARAM_STR);
}
$stm->bindParam(":bn", $bn, PDO::PARAM_STR);
$stm->bindParam(":ba", $ba, PDO::PARAM_STR);
$stm->bindParam(":ab", $ab, PDO::PARAM_STR);
$stm->bindParam(":type", $type, PDO::PARAM_STR);
$stm->bindParam(":id", $id, PDO::PARAM_STR);
$stm->execute();
AddtoHistory("دەستکاریکردنی کتێب",home);
re("success"," سوپاس "," وانە بەسەرکەوتویی نوێکرایەوە. ");
//$db = null;
direct("");
// }else{
// re("info"," ببورە "," ئەم وانەیە بەهەمان مامۆستاوە بونی هەیە. ");
// }
}else {
re("danger"," کێشە! "," تکایە خانەکان بە دروستی پڕبکەوە، وێنەی دروست هەڵبژێرە.");
}
}else {
re("danger"," کێشە! "," کێشەیەک ڕویدا تکایە دووبارە هەوڵ بدەوە.");
}
}
// Select data
$stm = $db->prepare("SELECT * FROM lib WHERE id=:id");
$stm->bindParam(":id", $id, PDO::PARAM_STR);
$stm->execute();
$fetch = $stm->fetch(PDO::FETCH_OBJ);
$rowCount = $stm->rowCount();
if($rowCount > 0){
if ($fetch->user!=$un) {
dh("library.php");
}
?>
<form action="" method="post" enctype="multipart/form-data">
<div class="col-md-8">
<div class="form-group">
<label class="req">ناوی کتاب</label>
<input type="text" name="bn" value="<?php echo $fetch->bn; ?>" placeholder="" class="form-control">
</div>
<div class="form-group">
<label class="req">ناوی نوسەری کتاب</label>
<input type="text" name="ba" value="<?php echo $fetch->ba; ?>" placeholder="" class="form-control">
</div>
<div class="form-group">
<label class="req">PDF</label>
<input type="file" accept="application/pdf" name="uploadpdf" data-label="دیاریکردن" class="filepicker 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="<?php echo $fetch->ba; ?>" type="text" name="type" class="form-group">
</div>
<div class="form-group">
<label <?php echo $feilds["book_ab"] != "" ? ' class="req"' : ''; ?>>کورتەیەک دەربارەی کتاب</label>
<textarea rows="6" type="text" name="ab" class="form-control"><?php echo $fetch->ab; ?></textarea>
</div>
</div>
<div class="col-md-4">
<img style=" max-height: 525px; width: 100%; height: 100%; " src="uploads/<?php echo $fetch->img; ?>" alt="">
</div>
</div>
<input type="hidden" name="token" value="<?php echo Token::create(); ?>">
<button type="submit" name="sub2" class="btn btn-default">دەستکاری</button>
</form>
<?php }else {
e4();
} ?>
</div>
</div>
<?php }else{
$del = output(@$_GET['del']);
if (isset($del) && $del!="") {
// Check User
$stm = $db->prepare("SELECT * FROM lib WHERE id=:id");
$stm->bindParam(":id", $del, PDO::PARAM_STR);
$stm->execute();
$fetch = $stm->fetch(PDO::FETCH_OBJ);
//
if ($un==$fetch->user) {
$stm = $db->prepare("DELETE FROM lib WHERE id=:id");
$stm->bindParam(":id", $del, PDO::PARAM_STR);
$stm->execute();
AddtoHistory("سڕینەوەی کتێب",home);
re("danger"," کتاب ","بەسەرکەوتویی سڕایەوە.");
//direct("library.php");
}
}
?>
<!-- Advanced Tables -->
<div class="panel panel-default">
<div class="panel-heading">
کتێبخانە
</div>
<div class="panel-body">
<?php
$stm = $db->prepare("SELECT * FROM lib");
$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="70px">وێنە</th>
<th>ناوی کتاب</th>
<th>نوسەری کتاب</th>
<th>هاوپۆل</th>
<th width="130px">کردار</th>
</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['bn']; ?></td>
<td><?php echo $row['ba']; ?></td>
<td><?php echo $row['type']; ?></td>
<td>
<span data-toggle="modal" data-target="#about<?php echo $row['id']; ?>">
<a data-toggle="tooltip" data-placement="top" class="btn btn-success btn-xs mrg" title="کورتەیەک لەبارەی کتابەکە"><i class="fa fa-info-circle"></i></a>
</span>
<div class="modal fade" id="about<?php echo $row['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">کورتەیەک دەربارەی <?php echo $row['bn']; ?></h4>
</div>
<div class="modal-body">
<img src="uploads/<?php echo $row['img']; ?>" alt="">
<?php echo $row['ab']; ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">داخستن</button>
</div>
</div>
</div>
</div>
<a href="uploads/pdf/<?php echo $row['pdf']; ?>" data-toggle="tooltip" data-placement="top" class="btn btn-primary btn-xs mrg" title="داگرتن بە PDF"><i class="glyphicon glyphicon-download"></i></a>
<?php if($das==1 OR ($row['user']==$un AND $das==2)){ ?>
<a href="library.php?edit=<?php echo $row['id']; ?>" data-toggle="tooltip" data-placement="top" class="btn btn-info btn-xs mrg" title="دەستکاری"><i class="fa fa-edit"></i></a>
<a href="library.php?del=<?php echo $row['id']; ?>" 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>
<?php } ?>
</td>
</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'; ?>