anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
set.cpp (4063B)
1 /* 2 * (C) 2003-2022 Anope Team 3 * Contact us at team@anope.org 4 * 5 * Please read COPYING and README for further details. 6 */ 7 8 #include "../../webcpanel.h" 9 #include "utils.h" 10 11 WebCPanel::ChanServ::Set::Set(const Anope::string &cat, const Anope::string &u) : WebPanelProtectedPage(cat, u) 12 { 13 } 14 15 bool WebCPanel::ChanServ::Set::OnRequest(HTTPProvider *server, const Anope::string &page_name, HTTPClient *client, HTTPMessage &message, HTTPReply &reply, NickAlias *na, TemplateFileServer::Replacements &replacements) 16 { 17 const Anope::string &chname = message.get_data["channel"]; 18 bool can_set = false; 19 TemplateFileServer page("chanserv/set.html"); 20 21 BuildChanList(na, replacements); 22 23 if (chname.empty()) 24 { 25 page.Serve(server, page_name, client, message, reply, replacements); 26 return true; 27 } 28 29 ChannelInfo *ci = ChannelInfo::Find(chname); 30 31 if (!ci) 32 { 33 page.Serve(server, page_name, client, message, reply, replacements); 34 return true; 35 } 36 37 replacements["OKAY"]; 38 39 if (ci->AccessFor(na->nc).HasPriv("SET")) 40 { 41 replacements["CAN_SET"]; 42 can_set = true; 43 } 44 45 if (can_set && message.post_data.empty() == false) 46 { 47 if (ci->HasExt("KEEPTOPIC") != message.post_data.count("keeptopic")) 48 { 49 if (!ci->HasExt("KEEPTOPIC")) 50 ci->Extend<bool>("KEEPTOPIC"); 51 else 52 ci->Shrink<bool>("KEEPTOPIC"); 53 replacements["MESSAGES"] = "Secure updated"; 54 } 55 if (ci->HasExt("PEACE") != message.post_data.count("peace")) 56 { 57 if (!ci->HasExt("PEACE")) 58 ci->Extend<bool>("PEACE"); 59 else 60 ci->Shrink<bool>("PEACE"); 61 replacements["MESSAGES"] = "Peace updated"; 62 } 63 if (ci->HasExt("CS_PRIVATE") != message.post_data.count("private")) 64 { 65 if (!ci->HasExt("CS_PRIVATE")) 66 ci->Extend<bool>("CS_PRIVATE"); 67 else 68 ci->Shrink<bool>("CS_PRIVATE"); 69 replacements["MESSAGES"] = "Private updated"; 70 } 71 if (ci->HasExt("RESTRICTED") != message.post_data.count("restricted")) 72 { 73 if (!ci->HasExt("RESTRICTED")) 74 ci->Extend<bool>("RESTRICTED"); 75 else 76 ci->Shrink<bool>("RESTRICTED"); 77 replacements["MESSAGES"] = "Restricted updated"; 78 } 79 if (ci->HasExt("CS_SECURE") != message.post_data.count("secure")) 80 { 81 if (!ci->HasExt("CS_SECURE")) 82 ci->Extend<bool>("CS_SECURE"); 83 else 84 ci->Shrink<bool>("CS_SECURE"); 85 replacements["MESSAGES"] = "Secure updated"; 86 } 87 if (ci->HasExt("SECUREOPS") != message.post_data.count("secureops")) 88 { 89 if (!ci->HasExt("SECUREOPS")) 90 ci->Extend<bool>("SECUREOPS"); 91 else 92 ci->Shrink<bool>("SECUREOPS"); 93 replacements["MESSAGES"] = "Secureops updated"; 94 } 95 if (ci->HasExt("TOPICLOCK") != message.post_data.count("topiclock")) 96 { 97 if (!ci->HasExt("TOPICLOCK")) 98 ci->Extend<bool>("TOPICLOCK"); 99 else 100 ci->Shrink<bool>("TOPICLOCK"); 101 replacements["MESSAGES"] = "Topiclock updated"; 102 } 103 } 104 105 replacements["CHANNEL"] = ci->name; 106 replacements["CHANNEL_ESCAPED"] = HTTPUtils::URLEncode(ci->name); 107 if (ci->GetFounder()) 108 replacements["FOUNDER"] = ci->GetFounder()->display; 109 if (ci->GetSuccessor()) 110 replacements["SUCCESSOR"] = ci->GetSuccessor()->display; 111 replacements["TIME_REGISTERED"] = Anope::strftime(ci->time_registered, na->nc); 112 replacements["LAST_USED"] = Anope::strftime(ci->last_used, na->nc); 113 replacements["ESCAPED_CHANNEL"] = HTTPUtils::URLEncode(chname); 114 115 if (!ci->last_topic.empty()) 116 { 117 replacements["LAST_TOPIC"] = ci->last_topic; 118 replacements["LAST_TOPIC_SETTER"] = ci->last_topic_setter; 119 } 120 121 if (can_set) 122 { 123 if (ci->HasExt("KEEPTOPIC")) 124 replacements["KEEPTOPIC"]; 125 126 if (ci->HasExt("PEACE")) 127 replacements["PEACE"]; 128 129 if (ci->HasExt("CS_PRIVATE")) 130 replacements["PRIVATE"]; 131 132 if (ci->HasExt("RESTRICTED")) 133 replacements["RESTRICTED"]; 134 135 if (ci->HasExt("CS_SECURE")) 136 replacements["SECURE"]; 137 138 if (ci->HasExt("SECUREOPS")) 139 replacements["SECUREOPS"]; 140 141 if (ci->HasExt("TOPICLOCK")) 142 replacements["TOPICLOCK"]; 143 } 144 145 page.Serve(server, page_name, client, message, reply, replacements); 146 return true; 147 } 148 149 std::set<Anope::string> WebCPanel::ChanServ::Set::GetData() 150 { 151 std::set<Anope::string> v; 152 v.insert("channel"); 153 return v; 154 }