-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.php
More file actions
59 lines (54 loc) · 1.33 KB
/
Copy pathhandler.php
File metadata and controls
59 lines (54 loc) · 1.33 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
<?php
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == "xmlhttprequest"){
require_once "classes/Post.php";
require_once "classes/Comment.php";
$post = new Post();
$comment = new Comment();
if(isset($_POST['type'])){
$type = $_POST['type'];
switch ($type) {
case "new-post":
$post->newPost();
break;
case "add-new-post":
if((isset($_POST['author']) && isset($_POST['text'])) && isset($_POST['title'])){
$author = $_POST['author'];
$text = $_POST['text'];
$title = $_POST['title'];
$author = trim($author);
$text = trim($text);
$title = trim($title);
if((!empty($author) && !empty($text)) && !empty($title)){
$post->addPost($author, $text, $title);
}else{
echo "Error!";
}
}else{
echo "Error!";
}
break;
case "loadAllPost":
$post->showPosts();
break;
case 'check-new-posts':
$post->checkNewsPosts();
break;
case 'open-post':
$post->open_post();
break;
case 'load-post-for-edit':
$post->load_post_forEdit();
break;
case 'edit-post':
$post->editPost();
break;
case 'send-comment':
$comment->send_comment();
break;
default:
# code...
break;
}
}
}
?>