Another year is about to end... So we have to update these damn copyright information :P
[PHP-P10.git] / Uplink / P10Formatter.class.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  *  Uplink/P10Formatter.class.php
21  *
22  * This file contains the command formatter.
23  *
24  */
25
26 class P10Formatter {
27         
28         private static $commands = array(
29                 "PASS"   => "PASS :%s",
30                 "SERVER" => "SERVER %s 1 %s %s J10 %s]]] +s6 :%s",
31                 "ERROR"  => "ERROR :%s",
32                 "Z"      => "{num} Z %s",
33                 "N"      => "{num} N %s 1 %s %s %s %s %s %s :%s",
34                 "EB"     => "{num} EB",
35                 "EA"     => "{num} EA",
36                 "B"      => "{num} B %s %s %s",
37                 "Q"      => "%s Q :%s",
38                 "D"      => "{num} D %s :%s (%s)",
39                 "J"      => "%s J %s %s %s",
40                 "K"      => "%s K %s %s :%s",
41                 "P"      => "%s P %s :%s",
42                 "O"      => "%s O %s :%s",
43                 "M"      => "%s M %s %s",
44                 "L"      => "%s L %s :%s",
45                 "SM"     => "%s SM %s %s",
46                 "OM"     => "%s OM %s %s",
47                 "311"    => "{num} 311 %s %s %s %s * :%s",
48                 "319"    => "{num} 319 %s %s :%s",
49                 "312"    => "{num} 312 %s %s %s :%s",
50                 "313"    => "{num} 313 %s %s :%s",
51                 "330"    => "{num} 330 %s %s %s :is logged in as",
52                 "318"    => "{num} 318 %s %s :End of /WHOIS list.",
53                 "401"    => "{num} 401 %s %s :No such nick",
54                 "SQ"     => "{num} SQ :%s",
55                 null     => null
56         );
57         
58         public static function formatCMD($numeric, $command, $args) {
59                 if(array_key_exists($command, self::$commands)) {
60                         $command = self::$commands[$command];
61                         $command = vsprintf($command, $args);
62                 } else {
63                         $command = vsprintf($command, $args);
64                 }
65                 return str_replace("{num}", $numeric, $command);
66         }
67 }
68
69 ?>