Subversion-Projekte lars-tiefland.openvz_admin

Revision

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

Revision 162 Revision 165
Zeile 1... Zeile 1...
1
<?php
1
<?php
2
    //$Id: load.php 162 2010-03-12 23:25:46Z lars $
2
    //$Id: load.php 165 2011-07-10 19:03:44Z 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" );
8
    $hns = HN::getHNs();
8
    $hns = HN::getHNs();
9
    unset( $hns[-1] );
9
    unset( $hns[-1] );
10
    foreach ( $hns as $hn_id => $hn_name )
10
    foreach ( $hns as $hn_id => $hn_name )
Zeile 81... Zeile 81...
81
            else
81
            else
82
            {
82
            {
83
                $dist_name = "centos";
83
                $dist_name = "centos";
84
            }
84
            }
85
            $sql = "
85
            $sql = "
86
				SELECT 
86
                SELECT 
87
					* 
87
                    * 
88
				FROM 
88
                FROM 
89
					distributions 
89
                    distributions 
90
				WHERE 
90
                WHERE 
91
					dist_name='$dist_name'
91
                    dist_name='$dist_name'
92
			";
92
            ";
93
            $res = $db->query( $sql );
93
            $res = $db->query( $sql );
94
            if ( ! PEAR::isError( $res ) )
94
            if ( ! PEAR::isError( $res ) )
95
            {
95
            {
96
                if ( $res->numRows() )
96
                if ( $res->numRows() )
97
                {
97
                {
98
                    $row = $res->fetchRow();
98
                    $row = $res->fetchRow();
99
                    $dist_id = $row["dist_id"];
99
                    $dist_id = $row["dist_id"];
100
                    $sql_v = "
100
                    $sql_v = "
101
						SELECT 
101
                        SELECT 
102
							v_dist, 
102
                            v_dist, 
103
							dist_name 
103
                            dist_name 
104
						FROM 
104
                        FROM 
105
							distributions, 
105
                            distributions, 
106
							vservers 
106
                            vservers 
107
						WHERE 
107
                        WHERE 
108
							v_id=" . $config["v_id"] . "
108
                            v_id=" . $config["v_id"] . "
109
						AND 
109
                        AND 
110
							dist_id=v_dist 
110
                            dist_id=v_dist 
111
					";
111
                    ";
112
                    $res_v = $db->query( $sql_v );
112
                    $res_v = $db->query( $sql_v );
113
                    if ( PEAR::isError( $res_v ) )
113
                    if ( PEAR::isError( $res_v ) )
114
                    {
114
                    {
115
                        die( $res_v->getUserInfo() );
115
                        die( $res_v->getUserInfo() );
116
                    }
116
                    }
117
                    $row_v = $res_v->fetchRow();
117
                    $row_v = $res_v->fetchRow();
118
                    $dist_name = $row_v["dist_name"];
118
                    $dist_name = $row_v["dist_name"];
119
                    if ( $dist_name != $config["DISTRIBUTION"] )
119
                    if ( $dist_name != $config["DISTRIBUTION"] )
120
                    {
120
                    {
121
                        $sql = "
121
                        $sql = "
122
							UPDATE 
122
                            UPDATE 
123
								vservers 
123
                                vservers 
124
							SET 
124
                            SET 
125
								v_dist=$dist_id 
125
                                v_dist=$dist_id 
126
							WHERE 
126
                            WHERE 
127
								v_id=" . $config["v_id"] . "
127
                                v_id=" . $config["v_id"] . "
128
						";
128
                        ";
129
                        $res = $db->query( $sql );
129
                        $res = $db->query( $sql );
130
                        if ( PEAR::isError( $res ) )
130
                        if ( PEAR::isError( $res ) )
131
                        {
131
                        {
132
                            die( $res->getUserInfo() );
132
                            die( $res->getUserInfo() );
133
                        }
133
                        }
134
                    }
134
                    }
135
                }
135
                }
136
                else
136
                else
137
                {
137
                {
138
                    $sql = "
138
                    $sql = "
139
						INSERT INTO 
139
                        INSERT INTO 
140
							distributions 
140
                            distributions 
141
						(
141
                        (
142
							dist_name, 
142
                            dist_name, 
143
							dist_template
143
                            dist_template
144
						)
144
                        )
145
						VALUES
145
                        VALUES
146
						(
146
                        (
147
							'" . $config["DISTRIBUTION"] . "', 
147
                            '" . $config["DISTRIBUTION"] . "', 
148
							'" . $config["OSTEMPLATE"] . "'
148
                            '" . $config["OSTEMPLATE"] . "'
149
						)
149
                        )
150
					";
150
                    ";
151
                    $res = $db->query( $sql );
151
                    $res = $db->query( $sql );
152
                    $dist_id = $db->lastinsertID();
152
                    $dist_id = $db->lastinsertID();
153
                }
153
                }
154
            }
154
            }
155
            else
155
            else
156
            {
156
            {
157
                die( $res->getUserInfo() );
157
                die( $res->getUserInfo() );
158
            }
158
            }
159
            $sql = "
159
            $sql = "
160
				SELECT 
160
                SELECT 
161
					* 
161
                    * 
162
				FROM 
162
                FROM 
163
					vservers 
163
                    vservers 
164
				WHERE 
164
                WHERE 
165
					v_id=" . $config["v_id"] . " 
165
                    v_id=" . $config["v_id"] . " 
166
				AND 
166
                AND 
167
					hn_id=$hn_id
167
                    hn_id=$hn_id
168
			";
168
            ";
169
            $res = $db->query( $sql );
169
            $res = $db->query( $sql );
170
            if ( ! PEAR::isError( $res ) )
170
            if ( ! PEAR::isError( $res ) )
171
            {
171
            {
172
                if ( ! $res->numRows() )
172
                if ( ! $res->numRows() )
173
                {
173
                {
174
                    $sql = "
174
                    $sql = "
175
						INSERT INTO 
175
                        INSERT INTO 
176
							vservers 
176
                            vservers 
177
						(
177
                        (
178
							v_id, 
178
                            v_id, 
179
							v_name, 
179
                            v_name, 
180
							v_dist, 
180
                            v_dist, 
181
							hn_id
181
                            hn_id
182
						) 
182
                        ) 
183
						VALUES 
183
                        VALUES 
184
						(
184
                        (
185
							" . $config["v_id"] . ", 
185
                            " . $config["v_id"] . ", 
186
							'" . $config["HOSTNAME"] . "', 
186
                            '" . $config["HOSTNAME"] . "', 
187
							$dist_id, 
187
                            $dist_id, 
188
							$hn_id
188
                            $hn_id
189
						)
189
                        )
190
					";
190
                    ";
191
                    $res = $db->query( $sql );
191
                    $res = $db->query( $sql );
192
                    if ( PEAR::isError( $res ) )
192
                    if ( PEAR::isError( $res ) )
193
                    {
193
                    {
194
                        die( $res->getUserInfo() );
194
                        die( $res->getUserInfo() );
195
                    }
195
                    }
196
                } elseif ( $config["HOSTNAME"] )
196
                } elseif ( $config["HOSTNAME"] )
197
                {
197
                {
198
                    $sql = "
198
                    $sql = "
199
						UPDATE 
199
                        UPDATE 
200
							vservers 
200
                            vservers 
201
						SET 
201
                        SET 
202
							v_name='" . $config["HOSTNAME"] . "' 
202
                            v_name='" . $config["HOSTNAME"] . "' 
203
						WHERE 
203
                        WHERE 
204
							v_id=" . $config["v_id"] . " 
204
                            v_id=" . $config["v_id"] . " 
205
						AND 
205
                        AND 
206
							hn_id=$hn_id
206
                            hn_id=$hn_id
207
					";
207
                    ";
208
                    $res = $db->query( $sql );
208
                    $res = $db->query( $sql );
209
                    if ( PEAR::isError( $res ) )
209
                    if ( PEAR::isError( $res ) )
210
                    {
210
                    {
211
                        die( $res->getUserInfo() );
211
                        die( $res->getUserInfo() );
212
                    }
212
                    }
Zeile 217... Zeile 217...
217
                die( $res->getUserInfo() );
217
                die( $res->getUserInfo() );
218
            }
218
            }
219
            foreach ( $config as $field => $value )
219
            foreach ( $config as $field => $value )
220
            {
220
            {
221
                $sql = "
221
                $sql = "
222
					SELECT 
222
                    SELECT 
223
						* 
223
                        * 
224
					FROM 
224
                    FROM 
225
						vserver_config 
225
                        vserver_config 
226
					WHERE 
226
                    WHERE 
227
						vc_name='$field' 
227
                        vc_name='$field' 
228
					AND 
228
                    AND 
229
						v_id=" . $config["v_id"] . " 
229
                        v_id=" . $config["v_id"] . " 
230
					AND 
230
                    AND 
231
						hn_id=$hn_id
231
                        hn_id=$hn_id
232
				";
232
                ";
233
                $res = $db->query( $sql );
233
                $res = $db->query( $sql );
234
                if ( ! PEAR::isError( $res ) )
234
                if ( ! PEAR::isError( $res ) )
235
                {
235
                {
236
                    if ( $res->numRows() )
236
                    if ( $res->numRows() )
237
                    {
237
                    {
238
                        $sql = "
238
                        $sql = "
239
							UPDATE 
239
                            UPDATE 
240
								vserver_config 
240
                                vserver_config 
241
							SET 
241
                            SET 
242
								vc_value='$value' 
242
                                vc_value='$value' 
243
							WHERE 
243
                            WHERE 
244
								vc_name='$field' 
244
                                vc_name='$field' 
245
							AND 
245
                            AND 
246
								v_id=" . $config["v_id"] . " 
246
                                v_id=" . $config["v_id"] . " 
247
							AND 
247
                            AND 
248
								hn_id=$hn_id
248
                                hn_id=$hn_id
249
						";
249
                        ";
250
                    }
250
                    }
251
                    else
251
                    else
252
                    {
252
                    {
253
                        $sql = "
253
                        $sql = "
254
							INSERT INTO 
254
                            INSERT INTO 
255
								vserver_config 
255
                                vserver_config 
256
							VALUES 
256
                            VALUES 
257
							(
257
                            (
258
								" . $config["v_id"] . ", 
258
                                " . $config["v_id"] . ", 
259
								$hn_id, 
259
                                $hn_id, 
260
								'$field', 
260
                                '$field', 
261
								'$value'
261
                                '$value'
262
							)
262
                            )
263
						";
263
                        ";
264
                    }
264
                    }
265
                    $res = $db->query( $sql );
265
                    $res = $db->query( $sql );
266
                    if ( PEAR::isError( $res ) )
266
                    if ( PEAR::isError( $res ) )
267
                    {
267
                    {
268
                        die( $res->getUserInfo() );
268
                        die( $res->getUserInfo() );