syntax & bug fixes (first startable version)
authorpk910 <philipp@zoelle1.de>
Tue, 26 Jul 2011 08:49:39 +0000 (10:49 +0200)
committerpk910 <philipp@zoelle1.de>
Tue, 26 Jul 2011 08:49:39 +0000 (10:49 +0200)
Uplink/Numerics.class.php
Uplink/P10_ModeSets.class.php
Uplink/P10_Server.class.php
Uplink/P10_User.class.php
Uplink/Uplink.class.php
main.php

index cb555fb2efad07008a5cb36d333282e5a03d2c23..2af7132f404dfd473298188d8f82aa94eeb3802f 100644 (file)
@@ -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 {
index 7f58c7dd05edcb277eec8c17c5258e5a3c1fda27..83611b8df4fb1039156292acf415dba4b866ea08 100644 (file)
@@ -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) {
index 207b66379147dc2ace2fcd211470657b99163b52..1b65ed95e79e2731ca448ee04dc14c289a5270ff 100644 (file)
 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) {
index bdc84e3bf157bd2e79430907831a7c782b83fcdc..a05f40bb664dded9c99a15c0e02b7ce08db4053d 100644 (file)
 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;
index 0095445030321de298caf5bafc0a64d26ef4689c..f0637b03d41ef32f7522f3643c626da4966b2204 100644 (file)
@@ -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);
index 123ccaeb18eeef5a36c4f858273de602756d1155..42fa0cdfb917e663276b89f590419ba02efabd02 100644 (file)
--- 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();
 }