-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsave_forum.php
More file actions
82 lines (55 loc) · 1.69 KB
/
save_forum.php
File metadata and controls
82 lines (55 loc) · 1.69 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
<?php
@session_start();
date_default_timezone_set("UTC");
if (isset($_SESSION['login_expiration']) && $_SESSION["login_expiration"] != date("Y-m-d"))
{
echo '>> login expired <<';
return;
}
if (!isset($_SESSION["id"])) {
echo '>> user is not logged in <<';
return;
}
// VALIDATION^
require_once('general.php');
if (!isset($_POST['forum_name'])) {
echo "error2343";
return;
}
if (isset($_POST['forum_id'])) {
$category_id = intval($_POST['forum_id']);
if ($category_id == 0) {
unset($category_id);
}
}
$db = new dbase();
$db->connect_sqlite();
if (isset($category_id)) {
// UPDATE
$sql = 'update categories set cat_name = :cat_name, cat_private = :cat_private, cat_order = :cat_order where cat_id = :cat_id';
$stmt = $db->getConnection()->prepare($sql);
$stmt->bindValue(':cat_id' , $category_id);
}
else
{ // INSERT
$sql = 'INSERT INTO categories (cat_name, cat_parent_id, cat_private, cat_order) VALUES (:cat_name, :cat_parent_id, :cat_private, :cat_order)';
$stmt = $db->getConnection()->prepare($sql);
$stmt->bindValue(':cat_parent_id' , $_POST['parent_forum_id']);
}
$stmt->bindValue(':cat_name' , $_POST['forum_name']);
$stmt->bindValue(':cat_private' , $_POST['forum_private']);
$stmt->bindValue(':cat_order' , $_POST['forum_order']);
$stmt->execute();
//if ($stmt->errorCode()!='00000')
if ( $stmt->rowCount() != 1 )
{
echo 'couldnt insert the record to forums';
return;
} else {
if (isset($category_id)) // UPDATE
echo json_encode(array('status' => '1'));
else {
$new_rec_id = $db->getConnection()->lastInsertId();
echo json_encode(array('status' => '1', 'rec_id' => $new_rec_id));
}
}