changed file headers & added AUTHORS file
[PHP-P10.git] / main.php
1 <?php
2 /******************************* PHP-P10 v2 *****************************
3  * Copyright (C) 2011  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
33 if(function_exists("pcntl_signal")) {
34         pcntl_signal(SIGINT, 'shutdown');
35         pcntl_signal(SIGTERM, 'shutdown');
36 }
37
38 //basicly here is nothing, yet :D
39 $uplink = new Uplink();
40 require_once("config.inc.php");
41
42 $uplink->setEventHandler(ModCMD::getEventHandler());
43
44 $uplink->initialize();
45
46 $botloader = new BotLoader($uplink);
47 $botloader->loadBots();
48 BotLoader::load("ModManager", "ModManager.class.php");
49
50 function shutdown($signal = 0) {
51         global $botloader;
52         global $uplink;
53         echo "\n\nrecived shutdown instruction...\n";
54         $botloader->unloadBots();
55         $botloader->save();
56         $uplink->shutdown();
57         exit;
58 }
59
60 while(true) {
61         $uplink->loop();
62         $botloader->loop();
63         timer_loop();
64         if(function_exists("pcntl_signal_dispatch"))
65                 pcntl_signal_dispatch();
66 }
67
68 ?>