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
|
/*
* (C) 2003-2019 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*/
#include "../../webcpanel.h"
#include "utils.h"
WebCPanel::ChanServ::Set::Set(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u)
{
}
bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements)
{
const Anope::string &chname = message.get_data["channel"];
bool can_set = false;
TemplateFileServer page("chanserv/set.html");
BuildChanList(na, replacements);
if (chname.empty())
{
page.Serve(server, page_name, client, message, reply, replacements);
return true;
}
ChannelInfo *ci = ChannelInfo::Find(chname);
if (!ci)
{
page.Serve(server, page_name, client, message, reply, replacements);
return true;
}
replacements["OKAY"];
if (ci->AccessFor(na->nc).HasPriv("SET"))
{
replacements["CAN_SET"];
can_set = true;
}
if (can_set && message.post_data.empty() == false)
{
if (ci->HasExt("KEEPTOPIC") != message.post_data.count("keeptopic"))
{
if (!ci->HasExt("KEEPTOPIC"))
ci->Extend<bool>("KEEPTOPIC");
else
ci->Shrink<bool>("KEEPTOPIC");
replacements["MESSAGES"] = "Secure updated";
}
if (ci->HasExt("PEACE") != message.post_data.count("peace"))
{
if (!ci->HasExt("PEACE"))
ci->Extend<bool>("PEACE");
else
ci->Shrink<bool>("PEACE");
replacements["MESSAGES"] = "Peace updated";
}
if (ci->HasExt("CS_PRIVATE") != message.post_data.count("private"))
{
if (!ci->HasExt("CS_PRIVATE"))
ci->Extend<bool>("CS_PRIVATE");
else
ci->Shrink<bool>("CS_PRIVATE");
replacements["MESSAGES"] = "Private updated";
}
if (ci->HasExt("RESTRICTED") != message.post_data.count("restricted"))
{
if (!ci->HasExt("RESTRICTED"))
ci->Extend<bool>("RESTRICTED");
else
ci->Shrink<bool>("RESTRICTED");
replacements["MESSAGES"] = "Restricted updated";
}
if (ci->HasExt("CS_SECURE") != message.post_data.count("secure"))
{
if (!ci->HasExt("CS_SECURE"))
ci->Extend<bool>("CS_SECURE");
else
ci->Shrink<bool>("CS_SECURE");
replacements["MESSAGES"] = "Secure updated";
}
if (ci->HasExt("SECUREOPS") != message.post_data.count("secureops"))
{
if (!ci->HasExt("SECUREOPS"))
ci->Extend<bool>("SECUREOPS");
else
ci->Shrink<bool>("SECUREOPS");
replacements["MESSAGES"] = "Secureops updated";
}
if (ci->HasExt("TOPICLOCK") != message.post_data.count("topiclock"))
{
if (!ci->HasExt("TOPICLOCK"))
ci->Extend<bool>("TOPICLOCK");
else
ci->Shrink<bool>("TOPICLOCK");
replacements["MESSAGES"] = "Topiclock updated";
}
}
replacements["CHANNEL"] = ci->name;
replacements["CHANNEL_ESCAPED"] = HTTPUtils::URLEncode(ci->name);
if (ci->GetFounder())
replacements["FOUNDER"] = ci->GetFounder()->display;
if (ci->GetSuccessor())
replacements["SUCCESSOR"] = ci->GetSuccessor()->display;
replacements["TIME_REGISTERED"] = Anope::strftime(ci->time_registered, na->nc);
replacements["LAST_USED"] = Anope::strftime(ci->last_used, na->nc);
replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname);
if (!ci->last_topic.empty())
{
replacements["LAST_TOPIC"] = ci->last_topic;
replacements["LAST_TOPIC_SETTER"] = ci->last_topic_setter;
}
if (can_set)
{
if (ci->HasExt("KEEPTOPIC"))
replacements["KEEPTOPIC"];
if (ci->HasExt("PEACE"))
replacements["PEACE"];
if (ci->HasExt("CS_PRIVATE"))
replacements["PRIVATE"];
if (ci->HasExt("RESTRICTED"))
replacements["RESTRICTED"];
if (ci->HasExt("CS_SECURE"))
replacements["SECURE"];
if (ci->HasExt("SECUREOPS"))
replacements["SECUREOPS"];
if (ci->HasExt("TOPICLOCK"))
replacements["TOPICLOCK"];
}
page.Serve(server, page_name, client, message, reply, replacements);
return true;
}
std::set<Anope::string> WebCPanel::ChanServ::Set::GetData()
{
std::set<Anope::string> v;
v.insert("channel");
return v;
}
|