Subversion-Projekte lars-tiefland.openvz_admin

Revision

Revision 109 | Revision 165 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 109 Revision 162
Zeile 1... Zeile 1...
1
<?php
1
<?php
2
	//$Id: ip.class.php 109 2008-05-09 22:19:52Z lars $
2
    //$Id: ip.class.php 162 2010-03-12 23:25:46Z lars $
3
	/**
3
    /**
4
 	* @author Lars Tiefland
4
     * @author Lars Tiefland
5
 	* @copyright 2007
5
     * @copyright 2007
6
 	* @package	openvz_admin
6
     * @package	openvz_admin
7
 	**/
7
     **/
8
	class IP
8
    class IP
9
	{
9
    {
10
		protected $ip;
10
        protected $ip;
11
		protected $hn;
11
        protected $hn;
12
		protected $dns;
12
        protected $dns;
13
		protected $gw;
13
        protected $gw;
14
		function __construct($ip=NULL, $hn=0, $dns=0, $gw=0)
14
        function __construct( $ip = null, $hn = 0, $dns = 0, $gw = 0 )
15
		{
15
        {
16
			global $db;
16
            global $db;
17
			if(!is_null($ip))
17
            if ( ! is_null( $ip ) )
18
			{
18
            {
19
				$sql="SELECT * FROM ips WHERE ip='$ip'";
19
                $sql = "SELECT * FROM ips WHERE ip='$ip'";
20
				$res=$db->query($sql);
20
                $res = $db->query( $sql );
21
				$row=$res->fetchRow();
21
                $row = $res->fetchRow();
22
				$this->ip=$row["ip"];
22
                $this->ip = $row["ip"];
23
				$this->hn=$row["hn"];
23
                $this->hn = $row["hn"];
24
				$this->dns=$row["dns"];
24
                $this->dns = $row["dns"];
25
				$this->gw=$row["gs"];
25
                $this->gw = $row["gs"];
26
			}
26
            }
27
			else
27
            else
28
			{
28
            {
29
				$this->ip=$ip;
29
                $this->ip = $ip;
30
				$this->hn=$hn;
30
                $this->hn = $hn;
31
				$this->dns=$dns;
31
                $this->dns = $dns;
32
				$this->gw=$gw;
32
                $this->gw = $gw;
33
			}
-
 
34
		}
-
 
35
		
-
 
36
		function toArray()
-
 
37
		{
-
 
38
			$out["ip"]=$this->ip;
-
 
39
			$out["dns"]=$this->dns;
-
 
40
			$out["gw"]=$this->gw;
-
 
41
			$out["hn"]=$this->hn;
-
 
42
			return $out;
33
            }
43
		}
34
        }
Zeile -... Zeile 35...
-
 
35
 
-
 
36
        function toArray()
-
 
37
        {
-
 
38
            $out["ip"] = $this->ip;
-
 
39
            $out["dns"] = $this->dns;
-
 
40
            $out["gw"] = $this->gw;
-
 
41
            $out["hn"] = $this->hn;
-
 
42
            return $out;
-
 
43
        }
44
 
44
 
45
		static function getIP($ip_id)
45
        static function getIP( $ip_id )
46
		{
46
        {
47
			global $db;
47
            global $db;
48
			$sql="SELECT * FROM ips WHERE id=$ip_id";
48
            $sql = "SELECT * FROM ips WHERE id=$ip_id";
49
			$res=$db->query($sql);
49
            $res = $db->query( $sql );
50
			$row=$res->fetchRow();
50
            $row = $res->fetchRow();
51
			$ip=new IP($row["ip"]);
51
            $ip = new IP( $row["ip"] );
52
			return $ip->toArray();
52
            return $ip->toArray();
53
		}
53
        }
54
		
54
 
55
		static function getIPs($hn=1, $used=0, $dns=0, $gw=0)		
55
        static function getIPs( $hn = 1, $used = 0, $dns = 0, $gw = 0 )
56
		{
56
        {
57
			global $db;
57
            global $db;
58
			$sql="SELECT id, ip FROM ips WHERE dns=$dns AND gw=$gw AND hn=$hn";
58
            $sql = "SELECT id, ip FROM ips WHERE dns=$dns AND gw=$gw AND hn=$hn";
59
			$res=$db->query($sql);
59
            $res = $db->query( $sql );
60
			$out[-1]="Bitte w&auml;hlen!";
60
            $out[-1] = "Bitte w&auml;hlen!";
61
			while($row=$res->fetchRow())
61
            while ( $row = $res->fetchRow() )
62
			{
62
            {
63
				if(!$used)
63
                if ( ! $used )
64
				{
64
                {
-
 
65
                    $sql2 = "SELECT * FROM host_2_ip WHERE ip='" . $row["id"] .
65
					$sql2="SELECT * FROM host_2_ip WHERE ip='".$row["id"]."'";
66
                        "'";
66
					$res2=$db->query($sql2);
67
                    $res2 = $db->query( $sql2 );
67
					if(!$res2->numRows())
68
                    if ( ! $res2->numRows() )
68
					{
69
                    {
69
						$out[$row["id"]]=$row["ip"];
70
                        $out[$row["id"]] = $row["ip"];
70
					}
71
                    }
71
				}
72
                }
72
			}
73
            }
73
			return $out;
74
            return $out;
74
		}
75
        }
75
	}
76
    }
76
?>
77
?>