-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog_getPostTextFromServer.php
125 lines (81 loc) · 3.23 KB
/
blog_getPostTextFromServer.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
<?PHP
session_start();
require_once("blog_db.php");
$db = new DB();
if(isset($_SESSION["userID"])) {
$userID = $_SESSION["userID"];
} else {
$userID = 0;
}
$data = $_REQUEST["source"];
$type = $_REQUEST["type"];
$sources = explode(",", $data);
$post="";
$isUserCreator = "";
$alias = "";
$createDate="";
$edited = "";
for($i = 1; $i<count($sources); $i++) {
$src = $sources[$i];
//echo($src);
if ($type == "post") {
$SQL = "SELECT userID, createDate, postID, blogID FROM post WHERE source='$src'";
$matrix = $db->getData($SQL);
$creator = $matrix[0][0];
$createDate = $createDate."&".$matrix[0][1];
$postID = $matrix[0][2];
$blogID = $matrix[0][3];
//echo($postID."\n");
$SQL = "SELECT userID FROM blog WHERE blogID=$blogID";
$matrix = $db->getData($SQL);
$owner = $matrix[0][0];
$SQL = "SELECT alias FROM user WHERE userID=$creator";
$temp = $db->getData($SQL);
$alias = $alias."&".$temp[0][0];
$SQL = "SELECT oldID FROM postversion WHERE newID=$postID";
$temp = $db->getData($SQL);
if(count($temp)>0) {
$edited = $edited."&1";
} else {
$edited = $edited."&0";
}
$SQL = "SELECT admin FROM user WHERE userID=$userID";
$temp = $db->getData($SQL);
$admin = $temp[0][0];
} else if( $type == "comment") {
$SQL = "SELECT userID, postID, commentID FROM comment WHERE source='$src'";
$matrix = $db->getData($SQL);
$creator = $matrix[0][0];
$postID = $matrix[0][1];
$commentID = $matrix[0][2];
$SQL = "SELECT blogID FROM post WHERE postID=$postID";
//echo($SQL);
$matrix = $db->getData($SQL);
$blogID = $matrix[0][0];
$SQL = "SELECT userID FROM blog WHERE blogID=$blogID";
$matrix = $db->getData($SQL);
$owner = $matrix[0][0];
$SQL = "SELECT oldID FROM commentversion WHERE newID=$commentID";
$temp = $db->getData($SQL);
if(count($temp)>0) {
$edited = $edited."&1";
} else {
$edited = $edited."&0";
}
$SQL = "SELECT admin FROM user WHERE userID=$userID";
$temp = $db->getData($SQL);
$admin = $temp[0][0];
}
//echo("userID: ".$userID."\n");
//echo("creator:".$creator."\n");
if($creator != 0 && $userID == $creator || $owner == $userID || $admin == 1) {
$isUserCreator = $isUserCreator."&1";
} else {
$isUserCreator = $isUserCreator."&0";
}
$postFile = fopen($src, "r");
$post = $post."&".fread($postFile, filesize($src));
fclose($postFile);
}
echo($post."§".$isUserCreator."§".$alias."§".$createDate."§".$edited);
?>