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
	$DB="webs";
4
 
5
	// -------------------------
6
	// Email config file
7
	$emailConfig = "emailconfig.inc.php";
8
	$stdConfig   = "/web/apache/content-management/includes/system/emailconfig.default.inc.php";
9
	// -------------------------
10
 
11
	require_once "connect.php";
12
	// -------------------------
13
	// Sonderrechte abchecken
14
	if
15
	(
16
		($site == "weban.de")
17
		or
18
		($_SERVER[SERVER_NAME] == "server")
19
	)
20
	{
21
	}
22
	else
23
	{
24
		exit;
25
	}
26
	// -------------------------
27
 
28
	function pre($arr) {
29
		print("<pre>");
30
		print_r($arr);
31
		print("</pre>");
32
	}
33
 
34
	function getTables($db="mediaran_de")
35
	{
36
		$buffer=array();
37
		$result=mysql_query("show tables from $db");
38
		while ($zeile=mysql_fetch_assoc($result))
39
		{
40
			$buffer[] = $db.".".$zeile[Tables_in_mediaran_de];
41
		}
42
		return $buffer;
43
	}
44
 
45
	function getCreateCmd($table)
46
	{
47
		$result=mysql_query("SHOW CREATE TABLE $table");
48
		if ($zeile=mysql_fetch_assoc($result))
49
		{
50
			return $zeile["Create Table"];
51
		}
52
	}
53
 
54
	// Get the Webs and check all for configuration files
55
	function getWebs() {
56
 
57
		$entrys = array();
58
 
59
		$query="SELECT * FROM ".$GLOBALS['database_name'].".".$GLOBALS['DB']." ";
60
		$result = mysql_query ($query) or die ($query. " -/- ".mysql_errno().": ".mysql_error());
61
 
62
		$entrys = array();
63
 
64
		while($entry = mysql_fetch_assoc($result)) {
65
			$entrys[] = $entry;
66
			$entrys[(sizeof($entrys)-1)]['confExists'] = file_exists($entrys[(sizeof($entrys)-1)]['verzeichnis']."/".$GLOBALS['emailConfig']);
67
		}
68
 
69
		return $entrys;
70
 
71
	}
72
	// Get the Webs and check all for configuration files
73
	function getWebsById($mixed=NULL) {
74
 
75
		if($mixed==NULL)
76
			return false;
77
 
78
		$names = array();
79
 
80
		if (is_array($mixed)) {
81
			foreach (array_keys($mixed) AS $elem) {
82
				array_push($names,"ID='".$mixed[$elem]."'");
83
			}
84
			$cond = join($names,' OR ');
85
		} elseif(is_int($mixed)) {
86
			$cond = "ID='".$mixed."'";
87
		} else {
88
			return false;
89
		}
90
 
91
		$query="SELECT * FROM ".$GLOBALS['database_name'].".".$GLOBALS['DB']." WHERE ".$cond;
92
		$result = mysql_query ($query) or die ($query. " -/- ".mysql_errno().": ".mysql_error());
93
		$entrys = array();
94
 
95
		while($db = mysql_fetch_assoc($result)) {
96
			$entrys[] = $db;
97
			$entrys[(sizeof($entrys)-1)]['confExists'] = file_exists($entrys[(sizeof($entrys)-1)]['verzeichnis']."/".$GLOBALS['emailConfig']);
98
		}
99
		return $entrys;
100
 
101
	}
102
 
103
	function copyConfig($web) {
104
		if (!is_dir($web['verzeichnis'])) {
105
			return false;
106
		}
107
		$stdConf 	= readStdConfig();
108
		$filler = array
109
		(
110
			'file'	 	=> $web['verzeichnis']."/".$GLOBALS['emailConfig'],
111
			'date' 		=> date("Y/m/d h:i:s"),
112
			'web'  		=> $web['verzeichnis'],
113
			'domain'    => $web['domain'],
114
			'config' 	=> "%s"
115
		);
116
		$newConf = sprintf
117
		(
118
			$stdConf,
119
			$filler['file'],
120
			$filler['date'],
121
			$filler['web'],
122
			$filler['domain'],
123
			$filler['config']
124
		);
125
		// --------
126
		// Temporaere Datei erzeugen
127
		// Und config schreiben
128
		$tmpf 	= tempnam ("/tmp", "EMAIL_CONF");
129
		$hnd 	= fopen($tmpf, "w");
130
		fwrite($hnd, $newConf);
131
		fclose($hnd);
132
 
133
		if (!copy($tmpf,$filler['file'])) {
134
			unlink($tmpf);
135
			return false;
136
		}
137
 
138
		unlink($tmpf);
139
		// --------
140
		return true;
141
	}
142
 
143
	function checkAllConfigFiles() {
144
 
145
		$webs 		= getWebs();
146
		$stdConf 	= readStdConfig();
147
 
148
		foreach (array_keys($webs) AS $tmpID) {
149
			if (!$webs[$tmpID]['confExists']) {
150
				// unlink($webs[$tmpID]['verzeichnis']."/".$GLOBALS['emailConfig']);
151
				// --------
152
				if (!copyConfig($webs[$tmpID]))
153
					echo "<br>Fehler in Web: ".$webs[$tmpID]['domain']."<br>&nbsp;&nbsp;&nbsp;<font size=4>&raquo;&nbsp;</font><font size=2 color=red>Web-Verzeichnis: ".$webs[$tmpID]['verzeichnis']." existiert nicht!</font><div style='width: 100px; align:left;border-top: 1px #000000 solid;'></div>\n";
154
				// --------
155
			}
156
		}
157
		echo "<br>\n";
158
	}
159
 
160
	function readConfig ($confFile) {
161
		require_once $confFile;
162
		if (is_array($_emails)) {
163
			foreach (array_keys($_emails) AS $emailID) {
164
				echo $_emails[$emailID]."<br>";
165
			}
166
		}
167
		return $_emails;
168
	}
169
 
170
	function readStdConfig() {
171
		return file_get_contents($GLOBALS['stdConfig']);
172
	}
173
 
174
	function appendEmail ($emailString, $confFile, $webID) {
175
		require_once $confFile;
176
		if (is_array($_emails)) {
177
			foreach (array_keys($_emails) AS $emailID) {
178
				echo $_emails[$emailID]."<br>";
179
			}
180
		}
181
		unlink($confFile);
182
		copyConfig($web);
183
	}
184
 
185
	function prependEmail ($emailString, $confFile, $webID) {
186
		require_once $confFile;
187
	}
188
 
189
	function writeConfig ($emailArray, $confFile,   $webID) {
190
		require_once $confFile;
191
	}
192
 
193
	// -------------------------
194
	unset($HTTP_POST_VARS['pwdcheck']);
195
	if ($action=="update")
196
	{
197
 
198
		header("Location: ".$self);
199
	}
200
 
201
	if ($action=="delete")
202
	{
203
 
204
	}
205
	if (!$action)
206
	{
207
		$action="select_edit";
208
	}
209
	if (!$sort) {$sort='Name';}
210
	$sort='domain';
211
?>
212
<html>
213
<head>
214
<title>Content-Management-System - Webagentur Niewerth</title>
215
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
216
<link rel=stylesheet type="text/css" href="buttons.css">
217
<style type="text/css"><MM:BeginLock translatorClass="MM_SSI" type="ssi" orig="%3C? require_once %22buttons.css%22; ?%3E" fileRef="buttons.css" depFiles="file:///L|/content-management/buttons.css">span {text-decoration:underline; color:#000000}
218
p {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color: #000000}
219
p.error {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold}
220
span {font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
221
span.blue {font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; background-color:#0000A0; font-size: 10pt}
222
span.small {font-family: Arial, Helvetica, sans-serif; font-size: 8pt; text-decoration: none}
223
td {font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
224
td.timeout {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color: #FF0000;}
225
td.small {font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
226
td.headline {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color: #FFFFFF; font-weight: bold}
227
td.haupt {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold}
228
input {font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
229
select {font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
230
textarea {font-family: Arial, Helvetica, sans-serif; font-size: 8pt}a {  text-decoration: none}
231
</style><MM:EndLock></style>
232
<script language="javascript" src="Farb_Assistent.js"></script>
233
<script language="JavaScript">
234
<!--
235
 
236
function MM_swapImgRestore() { //v3.0
237
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
238
}
239
 
240
function MM_preloadImages() { //v3.0
241
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
242
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
243
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
244
}
245
 
246
function MM_swapImage() { //v3.0
247
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
248
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
249
}
250
 
251
function MM_findObj(n, d) { //v4.01
252
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
253
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
254
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
255
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
256
  if(!x && d.getElementById) x=d.getElementById(n); return x;
257
}
258
function addAttach(obj)
259
{
260
	source=document.getElementById(obj)
261
	clone=source.cloneNode(true);
262
	clone.removeAttribute("id");
263
 
264
	source.parentNode.appendChild(clone);
265
}
266
 
267
function removeAttach(obj)
268
{
269
	div = obj.parentNode;
270
	td = obj.parentNode.parentNode;
271
	if (!div.id)  { td.removeChild(div); }
272
}
273
 
274
function removeEmail(obj)
275
{
276
	obj=document.getElementById(obj)
277
	div = obj.parentNode;
278
	td = obj.parentNode.parentNode;
279
	if (!div.id)  { td.removeChild(div); }
280
}
281
//-->
282
</script>
283
 
284
<meta name="description" content="Redaktionssystem">
285
<meta name="author" content="Webagentur Niewerth">
286
<meta name="robots" content="noindex">
287
</head>
288
 
289
<body bgcolor="#FFFFFF" leftmargin="20" topmargin="10" marginwidth="20" marginheight="10" onLoad="MM_preloadImages('images/navigation/bt_neu_f2.gif','images/navigation/bt_bearbeiten_f2.gif','images/navigation/bt_delete_f2.gif')" text="#000096">
290
<form method="post" action="#" name="formname" enctype="multipart/form-data">
291
  <table width="662" border="0" cellspacing="0" cellpadding="0">
292
    <tr valign="top">
293
      <td width="585">
294
<!--  Auswahl Löschen START  -->
295
<?php
296
	if ($action=="check") {
297
?>
298
<p class="error">Pr&uuml;fe Web Konfigurationen</p>
299
<hr>
300
<?php
301
		checkAllConfigFiles();
302
	}
303
	if ($action=="delete")
304
	{
305
		$query="SELECT * FROM $DB ";
306
		$query=$query."order by $sort";
307
		$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
308
		if (mysql_num_rows($result) == 0)
309
		{
310
?>
311
<p class="error">Es sind keine Daten eingetragen !</p>
312
<p></p>
313
<?
314
		}
315
		else
316
		{
317
?>
318
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
319
          <tr bgcolor="#000099">
320
            <td colspan="2" class="headline">Web: L&ouml;schen</td>
321
          </tr>
322
          <?
323
	while ($zeile=mysql_fetch_array($result))
324
	{
325
?>
326
          <tr>
327
            <td><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>"><? echo $zeile[domain]?> </a>&nbsp;</td>
328
            <td width="5%" align="center">
329
              <input type="checkbox" name="ID[]" value="<?  echo $zeile[ID] ?>">
330
            </td>
331
          </tr>
332
          <?
333
	}
334
?>
335
          <tr bgcolor="#000099">
336
            <td colspan="2" align="right">
337
              <input type="hidden" name="action" value='delete'>
338
              <input type="submit" value="LÖSCHEN">
339
              <input type="reset" name="Button22" value="Zur&uuml;cksetzen">
340
            </td>
341
          </tr>
342
        </table>
343
        <?
344
		}
345
?>
346
        <?
347
 	}
348
?>
349
        <!--  Auswahl Löschen ENDE  -->
350
        <!--  Auswahl SELECT_EDIT START  -->
351
        <?
352
 
353
  if ($action=="select_edit")
354
  {
355
	$query="SELECT * FROM $DB ";
356
	$query=$query."order by $sort";
357
 
358
	$result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
359
	if (mysql_num_rows($result) == 0)
360
	{
361
	?>
362
        <p class="error">Es sind keine
363
            Daten eingetragen !</p>
364
          <p></p>
365
	<?
366
	}
367
	else
368
	{
369
	?>
370
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
371
          <tr bgcolor="#000099">
372
            <td class="headline" colspan="2">Web: Bearbeiten</td>
373
          </tr>
374
          <?
375
	while ($zeile=mysql_fetch_array($result))
376
	{
377
?>
378
          <tr>
379
            <td><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>">
380
              <? echo $zeile[ID]?> <? echo $zeile[domain]?></a> </td>
381
          </tr>
382
          <?
383
	}
384
?>
385
          <tr bgcolor="#000099">
386
            <td colspan="2">
387
              <div align="right">&nbsp;
388
                <input type="hidden" name="action" value='edit'>
389
              </div>
390
            </td>
391
          </tr>
392
        </table>
393
 <?
394
	}
395
?>
396
        <?
397
 	}
398
?>
399
<!--  Auswahl SELECT_EDIT ENDE  -->
400
 
401
<?
402
	if ($action=="edit")
403
	{
404
		if ($ID)
405
		{
406
			$result = mysql_query ("SELECT * FROM $DB where ID = $ID") or die (mysql_errno().": ".mysql_error());
407
			$zeile=mysql_fetch_array($result);
408
		}
409
	?>
410
	    <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
411
          <tr bgcolor="#000099">
412
            <td colspan="2" class="headline">Web:
413
              <?
414
					if ($ID)
415
					{
416
					 ?>
417
              Bearbeiten
418
              <?
419
					}
420
					else
421
					{
422
					 ?>
423
              Neueintrag
424
              <?
425
					}
426
				?>
427
            </td>
428
          </tr>
429
          <tr>
430
            <td bgcolor="#000099" class="headline" valign="top" width="13%">Kunde:</td>
431
            <td>
432
              <table border="0" cellspacing="0" cellpadding="0">
433
                <tr>
434
                  <td width="18%">Name:</td>
435
                  <td width="82%">
436
                    <input type="text" name="kunde" value="<? echo $zeile[kunde] ?>">
437
                  </td>
438
                </tr>
439
                <tr>
440
                  <td width="18%">Bezeichnung:</td>
441
                  <td width="82%">
442
                    <input type="text" name="kunde_bezeichnung" value="<? echo $zeile[kunde_bezeichnung] ?>">
443
                  </td>
444
                </tr>
445
                <tr>
446
                  <td width="18%">Begr&uuml;ssung:</td>
447
                  <td width="82%">
448
                    <input type="text" name="kunde_begruessung" value="<? echo $zeile[kunde_begruessung] ?>">
449
                  </td>
450
                </tr>
451
              </table>
452
            </td>
453
          </tr>
454
          <tr>
455
            <td bgcolor="#000099" class="headline" valign="top">Konfiguration:</td>
456
            <td>
457
			  <?php
458
			  	$webs = getWebs();
459
				if ($ID) {
460
			  		$eMails = readConfig($zeile['verzeichnis']."/".$GLOBALS['emailConfig']);
461
				}
462
			  ?>
463
              <input name="configPath" type="text" id="configPath" value="<? echo $zeile['verzeichnis']."/".$GLOBALS['emailConfig'] ?>" size="40">
464
              <? if (!$ID) { ?>
465
              <br>
466
              <input name="create_config" type="checkbox" id="create_config" value="create">
467
              Konfig neu erstellen auf Basis von
468
              <select name="sourceConfig" id="sourceConfig">
469
                <?php
470
					foreach (array_keys($webs) AS $webID) {
471
				?>
472
                <option>
473
                  <?= $webs[$webID]['domain'] ?>
474
                </option>
475
                <?php
476
					}
477
				?>
478
              </select>
479
              <? } ?>
480
            </td>
481
          </tr>
482
		  <!-- Emails -->
483
		  <?php
484
		  		if (is_array($eMails) && sizeof($eMails) > 0) {
485
					foreach (array_keys($eMails) AS $emailID) {
486
		  ?>
487
		  <div id="mailList">
488
          <tr>
489
            <td bgcolor="#000099" class="headline" valign="top" width="13%">Email:</td>
490
			<td>
491
 
492
			  <input name="attach[]" type="text" id="attach[]" value="<?= $eMails[$emailID] ?>">
493
			  <input type="button" value=" - " onClick="removeMail('mailList')">
494
 
495
			</td>
496
          </tr>
497
		  </div>
498
		  <?php
499
		  			}
500
		  		}
501
		  ?>
502
          <tr>
503
            <td bgcolor="#000099" class="headline" valign="top" width="13%">Add Email:</td>
504
			<td>
505
			<div id="mailAttach">
506
			  <input name="attach[]" type="text" id="attach[]">
507
			  <input type="button" value=" + " onClick="addAttach('mailAttach')">
508
			  <input type="button" value=" - " onClick="removeAttach(this)">
509
			</div>
510
			</td>
511
          </tr>
512
 
513
		  <!-- Emails -->
514
 
515
          <tr bgcolor="#000099">
516
            <td align="right" colspan="2">
517
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
518
                <tr>
519
                  <td>
520
                    <? if ($ID) { ?>
521
                    <input type="button" value="Rechte verwalten" onClick="document.location='admin_web_rechte.php?ID=<? echo $ID ?>'">
522
                    <? } ?>
523
                    &nbsp;</td>
524
                  <td align="right">
525
                    <input type="hidden" name="ID" value="<? echo $ID ?>">
526
                    <input type="hidden" name="action" value="update">
527
                    <input type="submit" value="OK">
528
                    <input type="reset" name="Button" value="Zur&uuml;cksetzen">
529
                  </td>
530
                </tr>
531
              </table>
532
            </td>
533
          </tr>
534
        </table>
535
        <?
536
	}
537
?> </td>
538
      <td width="77" align="right">
539
        <table width="67" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#FFFFFF" bordercolordark="#999999">
540
  		<tr>
541
            <td class="frame"><a href="<? echo $self ?>?action=edit" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','images/navigation/bt_neu_f2.gif',1)"><img name="Image5" border="0" src="images/navigation/bt_neu.gif" width="67" height="40"></a></td>
542
  		</tr>
543
 	 	<tr>
544
            <td class="frame"><a href="<? echo $self ?>?action=select_edit" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','images/navigation/bt_bearbeiten_f2.gif',1)"><img name="Image6" border="0" src="images/navigation/bt_bearbeiten.gif" width="67" height="40"></a></td>
545
  		</tr>
546
  		<tr>
547
            <td class="frame"><a href="<? echo $self ?>?action=delete" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','images/navigation/bt_delete_f2.gif',1)"><img name="Image7" border="0" src="images/navigation/bt_delete.gif" width="67" height="40"></a></td>
548
  		</tr>
549
  		<tr>
550
  		  <td class="frame"><a href="<? echo $self ?>?action=check" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('999','','images/navigation/bt_neu_f2.gif',1)"><img src="images/navigation/bt_neu.gif" alt="Check Webs" name="Image5" width="67" height="40" border="0"></a></td>
551
		  </tr>
552
		</table>
553
      </td>
554
</tr>
555
</table>
556
</form>
557
</body>