added isLocalAddress method to IPAddr.class.php to check for local addresses (RFC1918...
[PHP-P10.git] / main.php
1 <?php
2 /******************************* PHP-P10 v2 *****************************
3  * Copyright (C) 2011-2012  Philipp Kreil (pk910)                       *
4  *                                                                      *
5  * This program is free software: you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation, either version 3 of the License, or    *
8  * (at your option) any later version.                                  *
9  *                                                                      *
10  * This program is distributed in the hope that it will be useful,      *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
13  * GNU General Public License for more details.                         *
14  *                                                                      *
15  * You should have received a copy of the GNU General Public License    *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  *                                                                      *
18  ************************************************************************
19  *
20  *  main.php
21  *
22  * initial php file
23  *
24  */
25 declare(ticks = 1);
26 error_reporting(E_ALL & ~E_STRICT);
27
28 require_once("Uplink/Uplink.class.php");
29 require_once("ModCMD/ModCMD.class.php");
30 require_once("BotLoader/BotLoader.class.php");
31 require_once("Tools/timer.inc.php");
32 require_once("Tools/Table.class.php");
33
34 if(function_exists("pcntl_signal")) {
35         pcntl_signal(SIGINT, 'shutdown');
36         pcntl_signal(SIGTERM, 'shutdown');
37 }
38
39 //basicly here is nothing, yet :D
40 $uplink = new Uplink();
41 require_once("config.inc.php");
42
43 $uplink->setEventHandler(ModCMD::getEventHandler());
44
45 $uplink->initialize();
46
47 $botloader = new BotLoader($uplink);
48 $botloader->loadBots();
49 BotLoader::load("ModManager", "ModManager.class.php");
50
51 function shutdown($signal = 0) {
52         global $botloader;
53         global $uplink;
54         echo "\n\nrecived shutdown instruction...\n";
55         $botloader->unloadBots();
56         $botloader->save();
57         $uplink->shutdown();
58         exit;
59 }
60
61 while(true) {
62         $uplink->loop();
63         $botloader->loop();
64         timer_loop();
65         if(function_exists("pcntl_signal_dispatch"))
66         pcntl_signal_dispatch();
67 }
68
69 ?>