-
Notifications
You must be signed in to change notification settings - Fork 14
/
action_news.php
executable file
·197 lines (197 loc) · 7.13 KB
/
action_news.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
<!--
// =========================================================================
// ______
// / __/ /____ ________ ____ ___ _ ___ ___
// _\ \/ __/ _ `/ __/ _ `/ _ `/ ' \/ -_|_-<
// /___/\__/\_,_/_/ \_, /\_,_/_/_/_/\__/___/
// _____ /___/ __ ___ __
// / ___/__ ___ / /________ / / / _ \___ ____ ___ / /
// / /__/ _ \/ _ \/ __/ __/ _ \/ / / ___/ _ `/ _ \/ -_) /
// \___/\___/_//_/\__/_/ \___/_/ /_/ \_,_/_//_/\__/_/
// =========================================================================
// Copyright (c) Stargames Control Panel - Licensed under GNU GPL.
// See LICENSE File
// =========================================================================
// Project Lead by: Mysterious
// =========================================================================
-->
<?php
if(!$SERVER['system_safe']) exit();
$GET_post_id = (int)$GET_post_id;
if ($GET_code==01) {
if(checkprivilege_action($CP[login_id],g_add_news)) {
opmain_body("Add News Form");
echo "<TABLE width=\"100%\" cellspacing=\"1\" cellpadding=\"5\" align=\"center\" class=\"emptytable\">
<TBODY>
<form action=\"index.php?act=action_news&code=02\" method=\"post\" enctype=\"multipart/form-data\" name=\"t_post_form\" id=\"t_post_form\" onsubmit=\"return CheckAddnews()\">
<TR class=\"topic_title5\">
<TD width=\"100%\" colspan=\"2\">
<div class=\"title_face3\"><B>News Settings</B></div>
</TD>
</TR>
<TR class=\"topic_title6\">
<TD width=\"30%\">
<div class=\"title_face4\">$lang[Title]:</div>
</TD>
<TD width=\"70%\">
<input name=\"title\" type=\"text\" size=\"50\" class=\"textinput\">
</TD>
</TR>
<TR class=\"topic_title5\">
<TD colspan=\"2\">
<div class=\"title_face3\"><B>Code Buttons</B></div>
</TD>
</TR>
<TR class=\"topic_title6\">
<TD></TD>
<TD>
";
get_bbcode('t_post_form');
echo "
</TD>
</TR>
<TR class=\"topic_title6\">
<TD vAlign=\"top\">
";
emotions_select('t_post_form');
echo " </TD>
<TD vAlign=\"top\">
<textarea style=\"width:100%\" name=\"t_mes\" cols=\"60\" rows=\"15\" wrap=\"VIRTUAL\" class=\"textinput\"></textarea>
</TD>
</TR>
<TR class=topic_title5>
<TD colspan=\"2\" align=\"center\">
<input name=\"Submit\" type=\"submit\" value=\"$lang[Sentnews]\" class=\"textinput\">
<input name=\"Reset\" type=\"reset\" value=\"$lang[Resetnews]\" class=\"textinput\">
</TD>
</TR>
</form>
</TBODY>
</TABLE>
";
clmain_body();
}
}
else if ($GET_code==02) {
if(checkprivilege_action($CP[login_id],g_add_news)) {
if (!length($POST_title,1) || !length($POST_t_mes,5) || empty($STORED_loginname)) {
$display ="$lang[Error]";
} else {
$POST_title = checkstring($POST_title,1);
$POST_t_mes = checkstring($POST_t_mes,1);
$sql->execute_query("INSERT INTO $CONFIG_sql_cpdbname.mainnews (title,message,poster,date) VALUES (\"".$POST_title."\",\"".$POST_t_mes."\",\"".$CP['login_name']."\",\"".$CP['time']."\")",'action_news.php');$sql->total_query++;
$display ="$lang[Success_addnews]";
}
redir("index.php?act=readnews","$display",3);
} else {
redir("index.php?act=idx","$lang[No_privilege]",3);
}
}
else if ($GET_code==03) {
if(checkprivilege_action($CP[login_id],g_edit_news)) {
if(!$GET_post_id){
$display = "$lang[Error]";
redir("index.php?act=idx","$display",3);
} else {
$query = "SELECT post_id,message,title FROM $CONFIG_sql_cpdbname.mainnews WHERE post_id = \"".mysql_res($GET_post_id)."\" LIMIT 0,1";
$sql->result = $sql->execute_query($query,'action_news.php');$sql->total_query++;
$row = $sql->fetch_row();
$message = my_br2nl($row[message]);
opmain_body("Edit News Form");
echo "
<TABLE width=\"100%\" cellspacing=\"1\" cellpadding=\"5\" align=\"center\" class=\"emptytable\">
<TBODY>
<form action=\"index.php?act=action_news&code=04&post_id=$row[post_id]\" method=\"post\" enctype=\"multipart/form-data\" name=\"t_post_form\" id=\"t_post_form\" onsubmit=\"return CheckAddnews()\">
<TR class=\"topic_title5\">
<TD width=\"100%\" colspan=\"2\">
<div class=\"title_face3\"><B>News Settings</B></div>
</TD>
</TR>
<TR class=\"topic_title6\">
<TD width=\"30%\">
<div class=\"title_face4\">$lang[Title]</div>
</TD>
<TD width=\"70%\">
<input name=\"title\" type=\"text\" id=\"title\" size=\"65\" value=\"$row[title]\" class=\"textinput\">
</TD>
</TR>
<TR class=\"topic_title5\">
<TD colspan=\"2\">
<div class=\"title_face3\"><B>Code Buttons</B></div>
</TD>
</TR>
<TR class=\"topic_title6\">
<TD></TD>
<TD>
";
get_bbcode('t_post_form');
echo " </TD>
</TR>
<TR class=\"topic_title6\">
<TD vAlign=\"top\">
";
emotions_select('t_post_form');
echo " </TD>
<TD vAlign=\"top\">
<textarea style=\"width:100%\" name=\"t_mes\" cols=\"65\" rows=\"15\" wrap=\"VIRTUAL\" class=\"textinput\">$message</textarea>
</TD>
</TR>
<TR class=\"topic_title5\">
<TD colspan=\"2\" align=\"center\">
<input name=\"Submit\" type=\"submit\" value=\"$lang[Edit]\" class=\"textinput\">
<input name=\"Reset\" type=\"reset\" value=\"$lang[Restore]\" class=\"textinput\">
</TD>
</TR>
</form>
</TBODY>
</TABLE>
";
clmain_body();
}
} else {
redir("index.php?act=idx","$lang[No_privilege]",3);
}
}
else if ($GET_code==04) {
if(checkprivilege_action($CP[login_id],g_edit_news)) {
if (!$GET_post_id || !length($POST_title,1) || !length($POST_t_mes,5))
$display = "$lang[Fail_editnews]";
else {
$POST_title = checkstring($POST_title,1);
$POST_t_mes = checkstring($POST_t_mes,1);
$query = "SELECT COUNT(*) FROM $CONFIG_sql_cpdbname.mainnews WHERE post_id = \"".mysql_res($GET_post_id)."\" LIMIT 0,1";
$sql->result = $sql->execute_query($query,'action_news.php');$sql->total_query++;
if (!$sql->result()) {
$display = $lang[Fail_editnews];
} else {
$sql->execute_query("UPDATE $CONFIG_sql_cpdbname.mainnews SET title = \"$POST_title\", message = \"$POST_t_mes\", poster = \"".$CP['login_name']."\", date = \"".$CP['time']."\" WHERE post_id = \"".mysql_res($GET_post_id)."\" ;",'action_news.php');$sql->total_query++;
$display = $lang[Success_editnews];
}
}
redir("index.php?act=readnews","$display",3);
} else {
redir("index.php?act=idx","$lang[No_privilege]",3);
}
}
else if ($GET_code==05) {
if(checkprivilege_action($CP[login_id],g_delete_news)) {
if (!$GET_post_id)
$display = $lang[Fail_delnews];
else {
$query = "SELECT COUNT(*) FROM $CONFIG_sql_cpdbname.mainnews WHERE post_id = \"".mysql_res($GET_post_id)."\" LIMIT 0,1";
$sql->result = $sql->execute_query($query,'action_news.php');$sql->total_query++;
if (!$sql->result()) {
$display = $lang[Fail_delnews];
} else {
$sql->execute_query("DELETE FROM $CONFIG_sql_cpdbname.mainnews WHERE post_id = \"".mysql_res($GET_post_id)."\"",'action_news.php');$sql->total_query++;
$display = $lang[Success_delnews];
}
}
redir("index.php?act=readnews","$display",3);
} else {
redir("index.php?act=idx","$lang[No_privilege]",3);
}
}
else
header("location:index.php?act=idx");
?>