forked from chriszhou1992/ABCD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodifyTag.php
More file actions
41 lines (34 loc) · 1.13 KB
/
modifyTag.php
File metadata and controls
41 lines (34 loc) · 1.13 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
<?php
session_start();
require_once "classes/connecToDB.php";
$con = connectToDB();
if($con === false):
return;
endif;
//check correct data is in POST
if ( !isset($_POST["type"]) || !isset($_POST["id"])) {
echo "Wrong! Type not set.";
return;
}
require_once("classes/Tags.php");
if ( isset($_POST["content"]) ) { //insert tag
//escape tag content
$content = addslashes($_POST['content']);
$table = $_POST["type"] . "_tags";
$newTagID = Tags::insertNewTag($con, $_POST["content"], $table, $_POST["id"]);
//inserted tag
echo '<div class="tag gradient' . Tags::$currentColor;
echo '" tag_id=' . $newTagID . ' author=true likes=0>' . $_POST["content"];
echo '<div class="tagLikes"></div><i></i>';
echo "</div>";
//empty tag
echo '<div class="emptyTag"><i class="fa fa-plus"></i>Add Tag</div>';
}
else if ( isset($_POST["likes"]) ) { //update likes
$table = $_POST["type"] . "_tags";
echo Tags::updateTagLikes($con, $table, $_POST["likes"], $_POST["id"] );
}
else { //delete tag
$table = $_POST["type"] . "_tags";
echo Tags::deleteTag($con, $_POST["id"], $table);
}