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