2 /********************************* PHP-P10 ******************************
3 * P10 uplink class by pk910 (c)2011 pk910 *
4 ************************************************************************
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. *
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. *
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. *
21 ************************************************************************
23 * Uplink/P10Formatter.class.php
25 * This file contains the command formatter.
27 ************************************************************************
30 * static String formatCMD(String $numeric, String $command, String[] $args)
31 * builds the command with the given arguments
37 private static $commands = array(
39 "SERVER" => "SERVER %s 1 %s %s J10 %s]]] +s6 :%s",
40 "ERROR" => "ERROR :%s",
42 "N" => "{num} N %s 1 %s %s %s %s %s %s :%s",
45 "B" => "{num} B %s %s %s",
47 "D" => "{num} D %s :%s (%s)",
48 "J" => "%s J %s %s %s",
49 "K" => "%s K %s %s :%s",
53 "SM" => "%s SM %s %s",
54 "OM" => "%s OM %s %s",
55 "311" => "{num} 311 %s %s %s %s * :%s",
56 "319" => "{num} 319 %s %s :%s",
57 "312" => "{num} 312 %s %s %s :%s",
58 "313" => "{num} 313 %s %s :%s",
59 "330" => "{num} 330 %s %s %s :is logged in as",
60 "318" => "{num} 318 %s %s :End of /WHOIS list.",
61 "401" => "{num} 401 %s %s :No such nick",
62 "SQ" => "{num} SQ :%s",
66 public static function formatCMD($numeric, $command, $args) {
67 if(array_key_exists($command, self::$commands)) {
68 $command = self::$commands[$command];
69 $command = vsprintf($command, $args);
71 $command = vsprintf($command, $args);
73 return str_replace("{num}", $numeric, $command);