Subversion-Projekte lars-tiefland.content-management

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?
2
	$self=basename($PHP_SELF);
3
	define ("modul_name", "domain_admin");
4
	define ("tool_name", "webserverad");
5
	require_once "../Online-Shop/connect2.php";
6
 
7
	if (!isset($web_rechte[modul_name][tool_name][websadmin]))
8
	{
9
		echo "<p>&nbsp;&nbsp;&nbsp;FEHLER: kein Recht !.</p>";
10
		exit;
11
	}
12
 
13
	if (!$web_rechte[modul_name][tool_name][include_file])
14
	{
15
		echo "<p>&nbsp;&nbsp;&nbsp;FEHLER: keine Zieldatei (include_file) !.</p>";
16
		exit;
17
	}
18
 
19
	if (!$web_rechte[modul_name][tool_name][define_tab])
20
	{
21
		echo "<p>&nbsp;&nbsp;&nbsp;FEHLER: keine Trafficdatei (define_tab) !.</p>";
22
		exit;
23
	}
24
 
25
	$DB="Apache_Domains";
26
	$newline=chr(13).chr(10);
27
 
28
	if ($action=="update")
29
	{
30
		if (!$ID)
31
		{	// insert Dummy-Entry
32
			$query = "insert into $DB (ID,erstellt_am,erstellt_von,letzte_Aenderung_am,letzte_Aenderung_von) VALUES (0,NOW(),'$PHP_AUTH_USER',NOW(),'$PHP_AUTH_USER')";
33
			$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>".$query."<hr>");
34
			$ID=mysql_insert_id();
35
		}
36
 
37
		unset($HTTP_POST_VARS[action]);
38
		unset($HTTP_POST_VARS[ID]);
39
 
40
		foreach(array_keys($HTTP_POST_VARS) as $elem)
41
		{
42
			if ($elem[0] == "_")
43
			{
44
				unset($HTTP_POST_VARS[$elem]);
45
				$button=$$elem;
46
				$elem=substr($elem,1);
47
				$Pfad=$HTTP_POST_VARS[$elem."_Pfad"];
48
				unset($HTTP_POST_VARS[$elem."_Pfad"]);
49
				$image=$$elem;
50
				$image_name=$elem."_name";
51
				$image_name=urlencode($$image_name);
52
				switch ($button)
53
				{
54
					case 0:
55
						break;
56
					case 1:
57
						$HTTP_POST_VARS[$elem]='';
58
	   					break;
59
	   				case 2:
60
						//$image_name=$ID."_".$image_name;
61
						$image_name=$ID.strrchr($image_name,".");
62
						$HTTP_POST_VARS[$elem]=$image_name;
63
						copy($image,$Pfad.$image_name);
64
				        break;
65
				    default:
66
				        break;
67
			    }
68
			}
69
		}
70
		$names=array();
71
		foreach(array_keys($HTTP_POST_VARS) as $elem)
72
		{
73
			array_push($names,"$elem='$HTTP_POST_VARS[$elem]'");
74
		}
75
		$query="update $DB set ".join($names,', ');
76
		$query=$query." ,letzte_Aenderung_am=NOW(), letzte_Aenderung_von='$PHP_AUTH_USER' where ID = '$ID'";
77
		$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error()."<hr>$query<hr>");
78
 
79
// ==========================================================================================================
80
/*
81
		// Verzeichnisse erstellen
82
		//mkdir($document_root, 0755);
83
		//mkdir ($alias_error, 0755);
84
		//mkdir ($cgi_bin, 0755);
85
		//mkdir (dirname($custom_log), 0755);
86
*/
87
 
88
		$include_file = $web_rechte[modul_name][tool_name][include_file];
89
		$include_file = fopen ($include_file, "w+");
90
 
91
		$define_tab = $web_rechte[modul_name][tool_name][define_tab];
92
		$define_tab = fopen ($define_tab, "w+");
93
 
94
 
95
		$query="SELECT * FROM $DB order by IP,Zones";
96
		$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
97
		while ($zeile=mysql_fetch_array($result))
98
		{
99
			$zeile[Zones] = preg_split("/$newline/", $zeile[Zones]);
100
			foreach ($zeile[Zones] as $elem)
101
			{
102
				if ($elem != "")
103
				{
104
//----------------------------------------------------------------------
105
					$buffer=preg_split("/\./", $elem);
106
					if (count($buffer) == 2)
107
					{
108
						fwrite ($define_tab,"$elem:$zeile[global_log]\n");
109
					}
110
//----------------------------------------------------------------------
111
 
112
					$content = array (
113
						"<VirtualHost $zeile[IP]>",
114
						"DocumentRoot" => "DocumentRoot $zeile[document_root]",
115
						"Alias" => "Alias /_errors $zeile[alias_error]",
116
						"ScriptAlias" => "ScriptAlias /cgi-bin/ \"".$zeile[cgi_bin]."\"",
117
						"ServerName" => "ServerName $elem",
118
						"ErrorLog" => "ErrorLog $zeile[error_log]",
119
						"CustomLog" => "CustomLog \"|/usr/local/sbin/cronolog $zeile[custom_log]\" common",
120
						"sonstiges" => "$zeile[sonstiges]",
121
						"</VirtualHost>\n\n"
122
					);
123
					if ($zeile[custom_log_trigger] == 0) {unset($content[CustomLog]);}
124
					if ($zeile[error_log_trigger] == 0) {unset($content[ErrorLog]);}
125
					if (!$zeile[sonstiges]) {unset($content[sonstiges]);}
126
 
127
					$content=join("\n",$content);
128
					fwrite ($include_file,$content,strlen($content));
129
				}
130
			}
131
		}
132
 
133
		fclose ($define_tab);
134
		fclose ($include_file);
135
// ==========================================================================================================
136
		header("Location: ".$self);
137
	}
138
 
139
	if ($action=="delete")
140
	{
141
		if ($ID)
142
		{
143
			$condition=array();
144
			foreach ($ID as $elem)
145
			{
146
				array_push($condition," ID = '$elem'");
147
			}
148
			$cond=join(" or ",$condition);
149
			$query = "DELETE FROM $DB WHERE $cond";
150
			$result = mysql_query ("$query") or die (mysql_errno().": ".mysql_error());
151
			header("Location: ".$self);
152
		}
153
	}
154
	if (!$action)
155
	{
156
		$action="select_edit";
157
	}
158
	if (!$sort) {$sort='Zones';}
159
?>
160
<html>
161
<head>
162
<title>Domain - Eintrag</title>
163
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
164
<link rel=stylesheet type="text/css" href="redaktion.css">
165
<style type="text/css"><? require_once "redaktion.css"; ?></style>
166
<meta name="description" content="Redaktionssystem">
167
<meta name="author" content="Webagentur Niewerth">
168
<meta name="robots" content="noindex">
169
</head>
170
<body bgcolor="#FFFFFF" leftmargin="20" topmargin="10" marginwidth="20" marginheight="10" alink="#999999">
171
<form method="post" action="#" name="form" enctype="multipart/form-data">
172
  <table width="676" border="0" cellspacing="0" cellpadding="0">
173
    <tr valign="top">
174
      <td width="597" bgcolor="#FFFFFF">
175
        <!--  Auswahl Löschen START  -->
176
        <?
177
	if ($action=="delete")
178
	{
179
		$query="SELECT * FROM $DB ";
180
		$query=$query."order by $sort";
181
		$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
182
		if (mysql_num_rows($result) == 0)
183
		{
184
?>
185
        <p class="error">Es sind keine Daten eingetragen !</p>
186
<p></p>
187
<?
188
		}
189
		else
190
		{
191
?>
192
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
193
          <tr bgcolor="#CCCCCC">
194
            <td colspan="4" class="headline">Domain-Eintrag: L&ouml;schen</td>
195
          </tr>
196
          <tr>
197
            <td width="63%" bgcolor="#666666"><a href="<? echo $self?>?action=delete&sort=Zones"><font color="#FFFFFF"><b>Server
198
              Name </b></font></a></td>
199
            <td bgcolor="#666666" width="23%"><a href="<? echo $self?>?action=delete&sort=IP"><font color="#FFFFFF"><b>IP</b></font></a></td>
200
            <td bgcolor="#666666" width="7%" align="center"><font color="#FFFFFF"><b>Logs</b></font></td>
201
            <td bgcolor="#666666" width="7%">&nbsp;</td>
202
          </tr>
203
          <?
204
	while ($zeile=mysql_fetch_array($result))
205
	{
206
	$von=date2human($zeile[von]);
207
	$bis=date2human($zeile[bis]);
208
?>
209
          <tr>
210
            <td width="63%">
211
              <?
212
				$zeile[Zones] = preg_split("/$newline/", $zeile[Zones]);
213
				echo $zeile[Zones][0];
214
			?>
215
            </td>
216
            <td width="23%">
217
              <? echo $zeile[IP] ?>
218
            </td>
219
            <td width="7%" align="center" nowrap>
220
			&nbsp;
221
              <? if ($zeile[custom_log_trigger] == 1) { ?>
222
              C
223
              <? } ?>
224
              <? if ($zeile[error_log_trigger] == 1) { ?>
225
              E
226
              <? } ?>
227
			&nbsp;
228
              </td>
229
            <td width="7%" align="center">
230
              <input type="checkbox" name="ID[]" value="<?  echo $zeile[ID] ?>">
231
            </td>
232
          </tr>
233
          <?
234
	} // end of while
235
?>
236
          <tr bgcolor="#CCCCCC">
237
            <td colspan="4" align="right">
238
              <input type="hidden" name="action" value='delete'>
239
              <input type="submit" value="LÖSCHEN">
240
              <input type="reset" name="Button22" value="Zur&uuml;cksetzen">
241
            </td>
242
          </tr>
243
        </table>
244
        <?
245
		} // end of else
246
?>
247
        <?
248
 	} // end of action = delete
249
?>
250
        <!--  Auswahl Löschen ENDE  -->
251
        <!--  Auswahl SELECT_EDIT START  -->
252
<?
253
  if ($action=="select_edit")
254
	{
255
	$query="SELECT * FROM $DB ";
256
	$query=$query."order by $sort";
257
 
258
	$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
259
	if (mysql_num_rows($result) == 0)
260
	{
261
	?>
262
        <p class="error">Es sind keine
263
            Daten eingetragen !</p>
264
          <p></p>
265
	<?
266
	}
267
	else
268
	{
269
	?>
270
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
271
          <tr bgcolor="#339999">
272
            <td class="headline" colspan="4" bgcolor="#CCCCCC">Domain-Eintrag:
273
              Bearbeiten</td>
274
          </tr>
275
          <tr>
276
            <td width="63%" bgcolor="#666666"><a href="<? echo $self?>?action=select_edit&sort=Zones"><font color="#FFFFFF"><b>Domain</b></font></a></td>
277
            <td bgcolor="#666666" width="23%"><a href="<? echo $self?>?action=select_edit&sort=IP"><font color="#FFFFFF"><b>IP</b></font></a></td>
278
            <td bgcolor="#666666" width="14%" align="center"><font color="#FFFFFF"><b>Logs</b></font></td>
279
          </tr>
280
          <?
281
	while ($zeile=mysql_fetch_array($result))
282
	{
283
		$von=date2human($zeile[von]);
284
		$bis=date2human($zeile[bis]);
285
 
286
?>
287
<tr>
288
	<td width="63%"><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>"><? $zeile[Zones] = preg_split("/$newline/", $zeile[Zones]); echo $zeile[Zones][0]; ?></a></td>
289
	<td><? echo $zeile[IP] ?></td><td align="center">&nbsp;<? if ($zeile[custom_log_trigger] == 1) { ?>C <? } ?><? if ($zeile[error_log_trigger] == 1) { ?>E<? } ?>&nbsp;</td>
290
</tr>
291
<?
292
	} // end of while
293
?>
294
          <tr bgcolor="#339999">
295
            <td colspan="4" bgcolor="#CCCCCC">
296
              <div align="right">&nbsp;
297
                <input type="hidden" name="action" value='edit'>
298
              </div>
299
            </td>
300
          </tr>
301
        </table>
302
        <?
303
	} // end of else
304
?>
305
        <?
306
 	} // end of select_edit
307
?>
308
        <!--  Auswahl SELECT_EDIT ENDE  -->
309
        <?
310
	if ($action=="edit")
311
	{
312
		if ($ID)
313
		{
314
			$result = mysql_query ("SELECT * FROM $DB where ID = '$ID'") or die (mysql_errno().": ".mysql_error());
315
			$zeile=mysql_fetch_array($result);
316
			$erstellt_am=datetime2human($zeile[erstellt_am]);
317
			$letzte_Aenderung_am=datetime2human($zeile[letzte_Aenderung_am]);
318
		}
319
	?>
320
<script language="javascript">
321
	function Vorlage(wert)
322
	{
323
<? if (!$ID) { ?>
324
		wert = wert.split("\n");
325
		wert = wert[0];
326
		document.form.document_root.value="/web/apache/"+wert;
327
		document.form.alias_error.value="/web/apache/_errors";
328
		document.form.cgi_bin.value="/web/apache/"+wert+"/cgi-bin/";
329
 		document.form.global_log.value=wert;
330
		wert = wert.replace(/\./,"_");
331
 		document.form.error_log.value="/web/logs/"+wert+"_error.log";
332
 		document.form.custom_log.value="/web/logs/"+wert+"/custom%Y%m.log";
333
<? } ?>
334
	}
335
</script>
336
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
337
          <tr>
338
            <td colspan="2" class="headline" bgcolor="#CCCCCC">Domain-Eintrag:
339
              <?
340
				if ($ID)
341
				{
342
					?>
343
              Bearbeiten
344
              <?
345
				}
346
				else
347
				{
348
			?>
349
              Neueintrag
350
              <?
351
				}
352
			?>
353
            </td>
354
          </tr>
355
          <tr>
356
            <td bgcolor="#CCCCCC" class="headline" width="20%" valign="top">Server
357
              Name(n):</td>
358
            <td class="headline">
359
              <textarea cols="40" name="Zones" rows="4" onChange="Vorlage(this.value)"><? echo $zeile[Zones] ?></textarea>
360
            </td>
361
          </tr>
362
          <tr>
363
            <td bgcolor="#CCCCCC" class="headline" width="20%">Virtual Host:</td>
364
            <td>
365
              <select name="IP">
366
                <option<? if ($zeile[IP] == "195.126.140.57:80") {echo " selected";} ?>>195.126.140.57:80</option>
367
                <option<? if ($zeile[IP] == "195.126.140.58:80") {echo " selected";} ?>>195.126.140.58:80</option>
368
                <option<? if ($zeile[IP] == "195.126.140.59:80") {echo " selected";} ?>>195.126.140.59:80</option>
369
                <option<? if (($zeile[IP] == "195.126.140.60:80") or (!$zeile[IP])) {echo " selected";} ?>>195.126.140.60:80</option>
370
                <option<? if ($zeile[IP] == "195.126.140.61:80") {echo " selected";} ?>>195.126.140.61:80</option>
371
                <option<? if ($zeile[IP] == "195.126.140.62:80") {echo " selected";} ?>>195.126.140.62:80</option>
372
                <option<? if ($zeile[IP] == "195.126.140.63:80") {echo " selected";} ?>>195.126.140.63:80</option>
373
                <option<? if ($zeile[IP] == "195.126.140.64:80") {echo " selected";} ?>>195.126.140.64:80</option>
374
              </select>
375
            </td>
376
          </tr>
377
          <tr>
378
            <td bgcolor="#CCCCCC" class="headline" width="20%">Document Root:</td>
379
            <td>
380
              <input type="text" name="document_root" size=25 value="<? echo $zeile[document_root] ?>">
381
            </td>
382
          </tr>
383
          <tr>
384
            <td bgcolor="#CCCCCC" class="headline">Alias/_Errors:</td>
385
            <td class="headline">
386
              <input type="text" size="25" name="alias_error" value="<? echo $zeile[alias_error] ?>">
387
            </td>
388
          </tr>
389
          <tr>
390
            <td bgcolor="#CCCCCC" class="headline">Script Alias:</td>
391
            <td class="headline">
392
              <input type="text" size="25" name="cgi_bin" value="<? echo $zeile[cgi_bin] ?>">
393
            </td>
394
          </tr>
395
          <tr>
396
            <td bgcolor="#CCCCCC" class="headline">Error Log:</td>
397
            <td class="headline">
398
              <input type="text" size="25" name="error_log" value="<? echo $zeile[error_log] ?>">
399
              <input type="hidden" name="error_log_trigger" value="0">
400
              <input type="checkbox" name="error_log_trigger" value="1"<? if ($zeile[error_log_trigger] == 1) {echo " checked";} ?>>
401
              Eigene Error-Log-Datei verwenden</td>
402
          </tr>
403
          <tr>
404
            <td bgcolor="#CCCCCC" class="headline">Custom Log:</td>
405
            <td class="headline">
406
              <input type="text" size="25" name="custom_log" value="<? echo $zeile[custom_log] ?>">
407
              <input type="radio" name="custom_log_trigger" value="1"<? if ($zeile[custom_log_trigger] == 1) {echo " checked";} ?>>
408
              Eigene Custom-Log-Datei verwenden
409
             </td>
410
          </tr>
411
          <tr>
412
            <td bgcolor="#CCCCCC" class="headline">Global-Log</td>
413
            <td class="headline">
414
              <input type="text" size="25" name="global_log" value="<? echo $zeile[global_log] ?>">
415
              <input type="radio" name="custom_log_trigger" value="0"<? if ($zeile[custom_log_trigger] == 0) {echo " checked";} ?>>
416
              Daten in Global-Logdatei schreiben. </td>
417
          </tr>
418
          <tr>
419
            <td bgcolor="#CCCCCC" class="headline" valign="top">
420
              <p>sonstiges:</p>
421
            </td>
422
            <td class="headline">
423
              <textarea cols="100" name="sonstiges" rows="10" wrap="OFF"><? echo $zeile[sonstiges] ?></textarea>
424
            </td>
425
          </tr>
426
          <? if ($ID) { ?>
427
          <tr>
428
            <td bgcolor="#CCCCCC" class="headline" colspan="2">&nbsp;</td>
429
          </tr>
430
          <tr>
431
            <td bgcolor="#CCCCCC" class="headline" width="20%">erstellt:</td>
432
            <td>am:
433
              <? echo $erstellt_am[Datum] ?>
434
              &nbsp;&nbsp;um:
435
              <? echo $erstellt_am[Zeit] ?>
436
              &nbsp;&nbsp;von:
437
              <? echo $zeile[erstellt_von] ?>
438
            </td>
439
          </tr>
440
          <tr>
441
            <td bgcolor="#CCCCCC" class="headline" width="20%" nowrap>letzte &Auml;nderung:</td>
442
            <td>am:
443
              <? echo $letzte_Aenderung_am[Datum] ?>
444
              &nbsp;&nbsp;um:
445
              <? echo $letzte_Aenderung_am[Zeit] ?>
446
              &nbsp;&nbsp;von:
447
              <? echo $zeile[letzte_Aenderung_von] ?>
448
            </td>
449
          </tr>
450
          <? } ?>
451
          <tr>
452
            <td align="right" colspan="2" bgcolor="#CCCCCC">
453
              <input type="hidden" name="ID" value="<? echo $ID ?>">
454
              <input type="hidden" name="action" value="update">
455
              <input type="submit" value="     OK     ">
456
              <input type="reset" name="Button" value="Zur&uuml;cksetzen">
457
            </td>
458
          </tr>
459
        </table>
460
        <?
461
	}
462
?> </td>
463
      <td width="79" align="right" bordercolor="#CCCCCC">
464
        <table width="67" border="1" cellspacing="2" cellpadding="3" bordercolorlight="#000000" bordercolordark="#000000" bordercolor="#000000">
465
          <tr>
466
            <td bgcolor="#CCCCCC" bordercolor="#000000"><a href="<? echo $self ?>?action=edit">NEU</a></td>
467
  		</tr>
468
 	 	<tr>
469
            <td bgcolor="#CCCCCC" bordercolor="#000000"><a href="<? echo $self ?>?action=select_edit">BEARBEITEN</a></td>
470
  		</tr>
471
  		<tr>
472
            <td bgcolor="#CCCCCC" bordercolor="#000000"><a href="<? echo $self ?>?action=delete">LÖSCHEN</a></td>
473
  		</tr>
474
<!--
475
  		<tr>
476
            <td bgcolor="#CCCCCC" bordercolor="#000000">&nbsp;</td>
477
  		</tr>
478
  		<tr>
479
            <td bgcolor="#CCCCCC" bordercolor="#000000"><a href="javascript:;">ANWENDEN</a></td>
480
  		</tr>
481
-->
482
		</table>
483
      </td>
484
</tr>
485
</table>
486
</form>
487
</body>