-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplug_base.php
executable file
·426 lines (371 loc) · 12 KB
/
plug_base.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
<?php
////////////////////////////////////////
// Encodage du fichier : UTF-8
// Utilisation des tabulations : Oui
// 1 tabulation = 4 caractères
// Fins de lignes = LF (Unix)
////////////////////////////////////////
///////////////////////////////
// LICENCE
///////////////////////////////
//
// QOpServ is a PHP program with which you can publish any project
// or sources files of any type supported you want.
//
// International Copyright © 2000 - 2012 CRDF All Rights Reserved.
//
// Contact @ http://www.crdf.fr - clients@crdf.fr
//
// QOpServ is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// QOpServ is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with QOpServ; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
///////////////////////////////
/**
* QOpServ - Application PHP Bots PHP
*
* @author G. Jocelyn
* @copyright CRDF France
* @license GNU GPL (http://www.gnu.org/copyleft/gpl.html)
* @link http://www.crdf.fr
* @name QOpServ
* @since 17/08/2008
* @version 4.0.1
*/
class plug_base implements plugin {
private $main;
public function __construct($main) {
$this->main = $main;
}
/**
* Déclaration des fonctions
*
* @param unknown_type $IRCtext
*/
public function start($IRCtext)
{
$this->PreCommandActive($IRCtext);
$this->PluginsAdmin($IRCtext);
$this->Deco($IRCtext);
$this->Ok($IRCtext);
$this->Pong($IRCtext);
$this->kick($IRCtext);
$this->NickUsed($IRCtext);
$this->IllegalChNick($IRCtext);
$this->CTCP($IRCtext);
}
/**
* Active an different precomand
*
* @param unknown_type $IRCtxt
*/
private function PreCommandActive ($IRCtxt)
{
if(preg_match('`^:(NickServ)!.*?@.*? NOTICE (.*)`', $IRCtxt, $T))
{
if(eregi("enregistré et protégé", $IRCtxt))
{
/**
* NickServ
*/
sleep(1);
$this->main->MyConn->put("PRIVMSG NickServ IDENTIFY vTJrhsDb1XJHGZv");
/**
* Server
*/
sleep(1);
$this->main->MyConn->put("OPER QOpServ VXLWaOAtfUDSsSHOpdzem0w3gLl1Cw48zajTSVRV");
/**
* StatServ
*/
sleep(1);
$this->main->MyConn->put("PRIVMSG StatServ LOGIN QOpServ 4BonR2IH");
/**
* MODES
*/
$this->main->MyConn->put("MODE " . IRCConn::$myBotName . " +BqHp");
$this->main->MyConn->put("MODE " . IRCConn::$myBotName . " +s +F");
$this->main->MyConn->put("MODE #IRCOPS +Os");
$this->main->MyConn->put("AWAY Je suis un robot. Vos messages sont ignorés.");
/**
* Channels
*/
sleep(1);
$dir = opendir(dirname(__FILE__) . '/data/channels/');
$i = 0;
while ($fread = readdir($dir))
{
if($fread != "." && $fread != "..")
{
$this->main->MyConn->put('JOIN ' . $fread);
}
}
}
}
}
/**
* Administrate different plugins
*
* @param unknown_type $IRCtxt
*/
private function PluginsAdmin ($IRCtxt)
{
/**
*
* List of plugins available
*
*/
$Plugs[] = "plug_base : QOpServ Plugins Base (CTCP Answer, etc)";
$Plugs[] = "plug_IRCOps : QOpServ Plugins IRCOps (command !ircops)";
$Plugs[] = "plug_vHost : QOpServ Plugins vHost QuiteNet";
$Plugs[] = "plug_Flood : QOpServ Plugins Anti-Flood";
$Plugs[] = "plug_Admin : QOpServ Plugins Administration";
$Plugs[] = "plug_RSSNEWS : Read News RSS in channel";
$Plugs[] = "plug_Google : QOpServ Plugin Google Search";
$Plugs[] = "plug_Tools : QOpServ Plugin Various tools";
$Plugs[] = "plug_Fansubs : QOpServ Plugin Fansubs Tools";
$Plugs[] = "plug_Help : QOpServ Plugin Help Menu";
$Plugs[] = "plug_Archiver : QOpServ Plugin Logs Channel";
/**
*
* List of Plugins
*
*/
if(preg_match('`^:(.*?)!(.*?) PRIVMSG (.*?) :(.*?)(!plugin|!plugins)`', $IRCtxt, $T) && !file_exists(dirname(__FILE__) . '/data/ignore/' . $T[2]))
{
if(file_exists(dirname(__FILE__) . '/data/admin.host/' . $T[2]))
{
$this->main->MyConn->put("NOTICE ".$T[1]." =================== QOpServ Plugins ===================");
foreach ($Plugs as $PlugLine)
{
$PlugArray = explode(":", $PlugLine);
$PlugName = trim($PlugArray[0]);
if($this->main->IsPlugLoad($PlugName) === true)
{
$this->main->MyConn->put("NOTICE ".$T[1]." " . $PlugLine . " (plugin chargé) ;");
} else
{
$this->main->MyConn->put("NOTICE ".$T[1]." " . $PlugLine . " (plugin non chargé) ;");
}
unset($PlugArray, $PlugName);
}
$this->main->MyConn->put("NOTICE ".$T[1]." ========================================================");
$this->main->MyConn->put("NOTICE ".$T[1]." Il y a actuellement ".count($Plugs)." plugins disponibles.");
$this->main->MyConn->put("NOTICE ".$T[1]." ========================================================");
$this->main->MyConn->put("NOTICE ".$T[1]." Charger un plugin : !load <nom_du_plugin> ;");
$this->main->MyConn->put("NOTICE ".$T[1]." Décharger un plugin : !unload <nom_du_plugin> ;");
$this->main->MyConn->put("NOTICE ".$T[1]." Recharger un plugin : !rehash <nom_du_plugin> ;");
$this->main->MyConn->put("NOTICE ".$T[1]." ========================================================");
}
}
/**
*
* Load an plugin
*
*/
if(preg_match('`^:(.*?)!(.*?) PRIVMSG (.*?) :(.*?)(!load) (.*)`', $IRCtxt, $T) && !file_exists(dirname(__FILE__) . '/data/ignore/' . $T[2]))
{
if(file_exists(dirname(__FILE__) . '/data/admin.host/' . $T[2]))
{
$T[6] = trim($T[6]);
if(!file_exists(dirname(__FILE__) . '/' . $T[6] . '.php') || $T[6] == "plug_base")
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' n'existe pas ou n'est plus disponible.");
} else
{
if(!is_readable(dirname(__FILE__) . '/' . $T[6] . '.php'))
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' n'est pas accessible en lecture/écriture.");
} else
{
if($this->main->IsPlugLoad($T[6]) === true)
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' est déjà chargé.");
} else
{
$this->main->AddPlug($T[6]);
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' a bien été chargé.");
$this->main->MyConn->put("PRIVMSG #IRCOPS ADMIN -> Load Plugin -> ".trim($T[2]).".");
}
}
}
}
}
/**
*
* Unload an plugin
*
*/
if(preg_match('`^:(.*?)!(.*?) PRIVMSG (.*?) :(.*?)(!unload) (.*)`', $IRCtxt, $T) && !file_exists(dirname(__FILE__) . '/data/ignore/' . $T[2]))
{
if(file_exists(dirname(__FILE__) . '/data/admin.host/' . $T[2]))
{
$T[6] = trim($T[6]);
if(!file_exists(dirname(__FILE__) . '/' . $T[6] . '.php') || $T[6] == "plug_base")
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' n'existe pas ou n'est plus disponible.");
} else
{
if(!is_readable(dirname(__FILE__) . '/' . $T[6] . '.php'))
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' n'est pas accessible en lecture/écriture.");
} else
{
if($this->main->IsPlugLoad($T[6]) === false)
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' n'est pas chargé.");
} else
{
$this->main->UnloadPlug($T[6]);
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' a bien été déchargé.");
$this->main->MyConn->put("PRIVMSG #IRCOPS ADMIN -> Unload Plugin -> ".trim($T[2]).".");
}
}
}
}
}
/**
*
* Rehash an plugin
*
*/
if(preg_match('`^:(.*?)!(.*?) PRIVMSG (.*?) :(.*?)(!rehash) (.*)`', $IRCtxt, $T) && !file_exists(dirname(__FILE__) . '/data/ignore/' . $T[2]))
{
if(file_exists(dirname(__FILE__) . '/data/admin.host/' . $T[2]))
{
$T[6] = trim($T[6]);
if(!file_exists(dirname(__FILE__) . '/' . $T[6] . '.php') || $T[6] == "plug_base")
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' n'existe pas ou n'est plus disponible.");
} else
{
if(!is_readable(dirname(__FILE__) . '/' . $T[6] . '.php'))
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' n'est pas accessible en lecture/écriture.");
} else
{
if($this->main->IsPlugLoad($T[6]) === false)
{
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' doit être chargé pour être rechargé.");
} else
{
$this->main->UnloadPlug($T[6]);
sleep(1);
$this->main->AddPlug($T[6]);
$this->main->MyConn->put("NOTICE ".$T[1]." Le plugin '".$T[6]."' a bien été rechargé.");
}
}
}
}
}
}
/**
* Detect an logout
*
* @param unknown_type $IRCtext
*/
private function Deco($IRCtext)
{
if(preg_match("`^ERROR :(Closing Link: )?(.*)\r?$`i", $IRCtext))
{
@fclose($this->main->MyConn->C);
sleep(3);
die('Closing Link'."\n");
}
}
/**
* Join an channel
*
* @param unknown_type $IRCtext
*/
private function Ok($IRCtext)
{
if(preg_match("`^:[^ ]+ 001 .*?\r?\n`", $IRCtext))
{
$this->main->MyConn->joinChannel(IRCConn::$channel);
}
}
/**
* Answer at ping server
*
* @param unknown_type $IRCtext
*/
private function Pong($IRCtext)
{
if(preg_match("`^PING :(.*)\r?\n`", $IRCtext, $T))
{
$this->main->MyConn->put("PONG " . $T[1]);
}
}
/**
* Detect an kick to auto-rejoin channel
*
* @param unknown_type $IRCtext
*/
private function kick($IRCtext)
{
if(preg_match('`^:(.*?)!(.*?) KICK (.*) '.preg_quote(IRCConn::$myBotName, '`').' :(.*?)`', $IRCtext, $T))
{
sleep(1);
$this->main->MyConn->put("INVITE " . preg_quote(IRCConn::$myBotName, '`') . " " . $T[3]);
$this->main->MyConn->put("JOIN " . $T[3]);
}
}
/**
* Illegals characters in Nickname
*
* @param unknown_type $IRCtext
*/
private function IllegalChNick ($IRCtext)
{
if(preg_match('`^:[^ ]+ 432 (.*?)\r?\n`', $IRCtext))
{
IRCConn::$myBotName = "QOpServ";
$this->main->MyConn->put("NICK :" . IRCConn::$myBotName);
}
}
/**
* Nick already in use
*
* @param unknown_type $IRCtext
*/
private function NickUsed ($IRCtext)
{
if(preg_match('`^:[^ ]+ 433 (.*?)\r?\n`', $IRCtext))
{
$this->main->MyConn->newNick();
$this->main->MyConn->put("NICK :" . IRCConn::$myBotName);
}
}
/**
* Detect an CTCP
*
* @param unknown_type $IRCtext
*/
private function CTCP ($IRCtext)
{
if(preg_match('`^:(.*?)!(.*?) PRIVMSG '.preg_quote(IRCConn::$myBotName, '`').'(.*?)(VERSION|USERINFO|CLIENTINFO)`', $IRCtext, $T) && !file_exists(dirname(__FILE__) . '/data/ignore/' . $T[2]))
{
$this->main->MyConn->put("NOTICE ".$T[1]." QOpServ QuiteNet Network IRC v3.6 [www.quitenet.org]. QOpServ powered by CRDF, Inc. Technologies [www.crdf.fr].");
}
if(preg_match('`^:(.*?)!(.*?) PRIVMSG '.preg_quote(IRCConn::$myBotName, '`').'(.*?)PING (.*?)\r?\n`', $IRCtext, $T) && !file_exists(dirname(__FILE__) . '/data/ignore/' . $T[2]))
{
$this->main->MyConn->put('NOTICE '.$T[1]." PING\1".time()."\1");
}
if(preg_match('`^:(.*?)!(.*?) PRIVMSG '.preg_quote(IRCConn::$myBotName,'`').'(.*?)(TIME)`', $IRCtext, $T) && !file_exists(dirname(__FILE__) . '/data/ignore/' . $T[2]))
{
$this->main->MyConn->put('NOTICE '.$T[1].' '.date('d-m-Y H:i:s'));
}
}
}
?>