Subversion-Projekte lars-tiefland.openvz_admin

Revision

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

Revision 124 Revision 125
Zeile 1... Zeile 1...
1
<?php
1
<?php
2
	//$Id: load.php 124 2008-05-22 13:50:21Z lars $
2
	//$Id: load.php 125 2008-05-22 14:59:39Z lars $
3
	/**
3
	/**
4
	 * 	@package	openvz_admin
4
	 * 	@package	openvz_admin
5
	 * 	@author		Lars Tiefland <ltiefland@gmail.com> 
5
	 * 	@author		Lars Tiefland <ltiefland@gmail.com> 
6
	 **/
6
	 **/
7
	require ("include/common.php");
7
	require ("include/common.php");
Zeile 37... Zeile 37...
37
	}
37
	}
Zeile 38... Zeile 38...
38
 
38
 
39
	function update_db($hn_id, $cfgs)
39
	function update_db($hn_id, $cfgs)
40
	{
40
	{
-
 
41
		global $db;
41
		global $db;
42
 
42
		foreach ($cfgs as $config)
43
		foreach ($cfgs as $config)
43
		{
-
 
44
			$sql = "SELECT * FROM distributions WHERE dist_name='" . $config["DISTRIBUTION"] .
-
 
45
				"'";
-
 
46
			$res = $db->query($sql);
44
		{
47
			if (!PEAR::isError($res))
45
			if (isset($config["DISTRIBUTION"]))
-
 
46
			{
-
 
47
				$sql = "SELECT * FROM distributions WHERE dist_name='" . $config["DISTRIBUTION"] .
-
 
48
					"'";
48
			{
49
				$res = $db->query($sql);
49
				if ($res->numRows())
50
				if (!PEAR::isError($res))
-
 
51
				{
-
 
52
					if ($res->numRows())
50
				{
53
					{
51
					$row = $res->fetchRow();
54
						$row = $res->fetchRow();
-
 
55
						$dist_id = $row["dist_id"];
-
 
56
					}
-
 
57
					else
-
 
58
					{
-
 
59
						$sql = "INSERT INTO distributions (dist_name, dist_template) VALUES('" . $config["DISTRIBUTION"] .
-
 
60
							"', '" . $config["OSTEMPLATE"] . "')";
-
 
61
						$res = $db->query($sql);
-
 
62
						$dist_id = $res->lastinsertID();
52
					$dist_id = $row["dist_id"];
63
					}
53
				}
64
				}
54
				else
65
				else
55
				{
-
 
56
					$sql = "INSERT INTO distributions (dist_name, dist_template) VALUES('" . $config["DISTRIBUTION"] .
-
 
57
						"', '" . $config["OSTEMPLATE"] . "')";
-
 
58
					$res = $db->query($sql);
66
				{
59
					$dist_id = $res->lastinsertID();
67
					die($res->getUserInfo());
-
 
68
				}
60
				}
69
			}
61
				$sql = "SELECT * FROM vservers WHERE v_id=" . $config["v_id"] . " AND hn_id=$hn_id";
70
			$sql = "SELECT * FROM vservers WHERE v_id=" . $config["v_id"] . " AND hn_id=$hn_id";
62
				$res = $db->query($sql);
71
			$res = $db->query($sql);
-
 
72
			if (!PEAR::isError($res))
-
 
73
			{
63
				if (!PEAR::isError($res))
74
				if (!$res->numRows())
-
 
75
				{
-
 
76
					$sql = "INSERT INTO vservers (v_id, v_name, v_dist, hn_id) VALUES (" . $config["v_id"] .
-
 
77
						", '" . $config["HOSTNAME"] . "', $dist_id, $hn_id)";
64
				{
78
					$res = $db->query($sql);
65
					if (!$res->numRows())
79
					if (PEAR::isError($res))
66
					{
-
 
67
						$sql = "INSERT INTO vservers (v_id, v_name, v_dist, hn_id) VALUES (" . $config["v_id"] .
-
 
68
							", '" . $config["HOSTNAME"] . "', $dist_id, $hn_id)";
-
 
69
						$res = $db->query($sql);
-
 
70
						if (PEAR::isError($res))
-
 
71
						{
80
					{
72
							echo $res->getUserInfo();
-
 
73
						}
81
						echo $res->getUserInfo();
74
					}
82
					}
-
 
83
				}
-
 
84
			}
-
 
85
			else
-
 
86
			{
-
 
87
				die($res->getUserInfo());
75
				}
88
			}
-
 
89
			foreach ($config as $field => $value)
-
 
90
			{
-
 
91
				$sql = "SELECT * FROM vserver_config WHERE vc_name='$field' AND v_id=" . $config["v_id"] .
-
 
92
					" AND hn_id=$hn_id";
-
 
93
				$res = $db->query($sql);
76
				foreach ($conf as $field => $value)
94
				if (!PEAR::isError($res))
77
				{
-
 
78
					$sql = "SELECT * FROM vserver_config WHERE vc_name='$field' AND v_id=" . $config["v_id"] .
-
 
79
						" AND hn_id=$hn_id";
-
 
80
					$res = $db->query($sql);
95
				{
81
					if (!PEAR::isError($res))
96
					if ($res->numRows())
82
					{
-
 
83
						if ($res->numRows())
-
 
84
						{
97
					{
85
							$sql = "UPDATE vserver_config SET vc_value='$value' WHERE vc_name='$field' AND v_id=" .
98
						$sql = "UPDATE vserver_config SET vc_value='$value' WHERE vc_name='$field' AND v_id=" .
86
								$config["v_id"] . " AND hn_id=$hn_id";
-
 
87
						}
-
 
88
						else
-
 
89
						{
-
 
90
							$sql = "INSERT INTO vserver_config VALUES (" . $config["v_id"] . ", $hn_id, '$field', '$value')";
-
 
91
						}
-
 
92
						$res = $db->query($sql);
-
 
93
						if (PEAR::isError($res))
-
 
94
						{
-
 
95
							echo $res->getUserInfo();
-
 
96
						}
99
							$config["v_id"] . " AND hn_id=$hn_id";
97
					}
100
					}
98
					else
101
					else
-
 
102
					{
-
 
103
						$sql = "INSERT INTO vserver_config VALUES (" . $config["v_id"] . ", $hn_id, '$field', '$value')";
-
 
104
					}
-
 
105
					$res = $db->query($sql);
-
 
106
					if (PEAR::isError($res))
99
					{
107
					{
100
						echo $res->getUserInfo();
108
						echo $res->getUserInfo();
101
					}
109
					}
102
				}
-
 
103
			}
110
				}
104
			else
111
				else
105
			{
112
				{
-
 
113
					echo $res->getUserInfo();
106
				echo $res->getUserInfo();
114
				}
107
			}
115
			}
108
		}
116
		}
109
	}
117
	}