From 7b82a138057d641a0ce2205b611fba2079f7500e Mon Sep 17 00:00:00 2001 From: pk910 Date: Tue, 26 Jul 2011 10:49:39 +0200 Subject: [PATCH] syntax & bug fixes (first startable version) --- Uplink/Numerics.class.php | 4 ++-- Uplink/P10_ModeSets.class.php | 16 ++++++++-------- Uplink/P10_Server.class.php | 4 ++-- Uplink/P10_User.class.php | 6 +++--- Uplink/Uplink.class.php | 9 +++++---- main.php | 2 ++ 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Uplink/Numerics.class.php b/Uplink/Numerics.class.php index cb555fb..2af7132 100644 --- a/Uplink/Numerics.class.php +++ b/Uplink/Numerics.class.php @@ -136,7 +136,7 @@ class Numerics { //thats a little bit complicated :D (we may only have one _) $ipv6 = array(); $ip = explode(":",$ip); - $last_zero = false; $zero_sequence = 0; $biggest_zero_sequence = 0, $max_start = -1; + $last_zero = false; $zero_sequence = 0; $biggest_zero_sequence = 0; $max_start = -1; foreach($ip as $i => $v) { if($v == "") { $skipBlocks = (8 - count($ip)); @@ -169,7 +169,7 @@ class Numerics { for($i = 0; $i < 8; $i++) { if($i == $max_start) { //merge the biggest sequence of _'s $ip .= "_"; - $i += ($biggest_zero_sequence-1) + $i += ($biggest_zero_sequence-1); } elseif($ipv6[$i] == "_") { $ip .= "AAA"; } else { diff --git a/Uplink/P10_ModeSets.class.php b/Uplink/P10_ModeSets.class.php index 7f58c7d..83611b8 100644 --- a/Uplink/P10_ModeSets.class.php +++ b/Uplink/P10_ModeSets.class.php @@ -75,7 +75,7 @@ class P10_ChannelModeSet { private $modeflags = 0; private $modeparams = array(); - public __construct($modes) { + public function __construct($modes) { if(self::$modevalues == null) { //build modevalues array $flag = 1; @@ -88,7 +88,7 @@ class P10_ChannelModeSet { $this->parseModes($modes); } - public parseModes($modes) { + public function parseModes($modes) { $args = explode(" ",$modes); $c = 1; for($i = 0; $i < strlen($args[0]); $i++) { @@ -111,7 +111,7 @@ class P10_ChannelModeSet { } } - public setModes($modes, $returndiff = false) { + public function setModes($modes, $returndiff = false) { $args = explode(" ",$modes); $c = 1; $add = true; @@ -167,7 +167,7 @@ class P10_ChannelModeSet { } } - public getModeString() { + public function getModeString() { $modestr = "+"; $paramstr = ""; foreach(self::$modevalues as $mode => $flag) { @@ -211,7 +211,7 @@ class P10_UserModeSet { private $modeflags = 0; private $modeparams = array(); - public __construct($modes) { + public function __construct($modes) { if(self::$modevalues == null) { //build modevalues array $flag = 1; @@ -224,7 +224,7 @@ class P10_UserModeSet { $this->parseModes($modes); } - public parseModes($modes) { + public function parseModes($modes) { $args = explode(" ",$modes); $c = 1; for($i = 0; $i < strlen($args[0]); $i++) { @@ -246,7 +246,7 @@ class P10_UserModeSet { } } - public setModes($modes, $returndiff = false) { + public function setModes($modes, $returndiff = false) { $args = explode(" ",$modes); $c = 1; $add = true; @@ -294,7 +294,7 @@ class P10_UserModeSet { } } - public getModeString() { + public function getModeString() { $modestr = "+"; $paramstr = ""; foreach(self::$modevalues as $mode => $flag) { diff --git a/Uplink/P10_Server.class.php b/Uplink/P10_Server.class.php index 207b663..1b65ed9 100644 --- a/Uplink/P10_Server.class.php +++ b/Uplink/P10_Server.class.php @@ -70,14 +70,14 @@ class P10_Server { private static $static_servers = array(); - public static getServerByNum($numeric) { + public static function getServerByNum($numeric) { if(array_key_exists($numeric, self::$static_servers)) { return self::$static_servers[$numeric]; } return NULL; } - public static getServerByName($name) { + public static function getServerByName($name) { $name = strtolower($name); foreach(self::$static_servers as $server) { if(strtolower($server->getName()) == $name) { diff --git a/Uplink/P10_User.class.php b/Uplink/P10_User.class.php index bdc84e3..a05f40b 100644 --- a/Uplink/P10_User.class.php +++ b/Uplink/P10_User.class.php @@ -38,14 +38,14 @@ class P10_User { private static $static_users = array(); - public static getUserByNum($numeric) { + public static function getUserByNum($numeric) { if(array_key_exists($numeric, self::$static_servers)) { return self::$static_servers[$numeric]; } return NULL; } - public static getUserByNick($nick) { + public static function getUserByNick($nick) { $nick = strtolower($nick); foreach(self::$static_users as $user) { if(strtolower($user->getNick()) == $nick) { @@ -65,7 +65,7 @@ class P10_User { private $modes; private $realname; - public __construct($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes) { + public function __construct($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes) { $this->nick = $nick; $this->numeric = $numeric; $this->server = $server; diff --git a/Uplink/Uplink.class.php b/Uplink/Uplink.class.php index 0095445..f0637b0 100644 --- a/Uplink/Uplink.class.php +++ b/Uplink/Uplink.class.php @@ -55,7 +55,7 @@ require_once("P10_User.class.php"); require_once("P10_ModeSets.class.php"); class Uplink { - private $client = new Client(); + private $client; private $settings = array(); private $server; @@ -66,7 +66,8 @@ class Uplink { private $flags = 0; public function __construct() { - $this->setSettings("recv_timeout", 1000); + $this->client = new Client(); + $this->setSetting("recv_timeout", 1000); } public function initialize() { @@ -104,7 +105,7 @@ class Uplink { if(($this->flags & self::FLAG_SECURITY_QUIT) || ($this->flags & self::FLAG_NOT_CONNECTABLE)) { sleep(1); } - $state = $this->client->connect($host, $port, $this->getSettings("bind"), $this->getSettings("ssl"), $this->getSettings("recv_timeout")); + $state = $this->client->connect($host, $port, $this->getSetting("bind"), $this->getSetting("ssl"), $this->getSetting("recv_timeout")); if(!$state) { usleep($this->getSetting("recv_timeout") / 1000); $this->flags |= self::FLAG_NOT_CONNECTABLE; @@ -121,7 +122,7 @@ class Uplink { } } - public function setUplink($host, $port, $ssl = false, $bind = null) { + public function setUplinkHost($host, $port, $ssl = false, $bind = null) { $this->setSetting("host", $host); $this->setSetting("port", $port); $this->setSetting("ssl", $ssl); diff --git a/main.php b/main.php index 123ccae..42fa0cd 100644 --- a/main.php +++ b/main.php @@ -32,6 +32,8 @@ $uplink = new Uplink(); $uplink->setUplinkHost("localhost", 4402); $uplink->setUplinkServer(5, "php.local.TestNet", "very_weak_password", "Test Server"); +$uplink->initialize(); + while(true) { $uplink->loop(); } -- 2.20.1