Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?
        $self=basename($PHP_SELF);
        $DB="webs";
        
        // -------------------------
        // Email config file
        $emailConfig = "emailconfig.inc.php";
        $stdConfig   = "/web/apache/content-management/includes/system/emailconfig.default.inc.php";
        // -------------------------
        
        require_once "connect.php";
        // -------------------------
        // Sonderrechte abchecken
        if
        (
                ($site == "weban.de")
                or
                ($_SERVER[SERVER_NAME] == "server")
        )
        {
        }
        else
        {
                exit;
        }
        // -------------------------
        
        function pre($arr) {
                print("<pre>");
                print_r($arr);
                print("</pre>");
        }
        
        function getTables($db="mediaran_de")
        {
                $buffer=array();
                $result=mysql_query("show tables from $db");    
                while ($zeile=mysql_fetch_assoc($result))
                {
                        $buffer[] = $db.".".$zeile[Tables_in_mediaran_de];
                }
                return $buffer;
        }
        
        function getCreateCmd($table)
        {
                $result=mysql_query("SHOW CREATE TABLE $table");        
                if ($zeile=mysql_fetch_assoc($result))
                {
                        return $zeile["Create Table"];
                }
        }
        
        // Get the Webs and check all for configuration files
        function getWebs() {
        
                $entrys = array();
                
                $query="SELECT * FROM ".$GLOBALS['database_name'].".".$GLOBALS['DB']." ";
                $result = mysql_query ($query) or die ($query. " -/- ".mysql_errno().": ".mysql_error());
        
                $entrys = array();
                
                while($entry = mysql_fetch_assoc($result)) {
                        $entrys[] = $entry;
                        $entrys[(sizeof($entrys)-1)]['confExists'] = file_exists($entrys[(sizeof($entrys)-1)]['verzeichnis']."/".$GLOBALS['emailConfig']);
                }
                
                return $entrys;
                
        }
        // Get the Webs and check all for configuration files
        function getWebsById($mixed=NULL) {

                if($mixed==NULL) 
                        return false;
                        
                $names = array();
                        
                if (is_array($mixed)) {
                        foreach (array_keys($mixed) AS $elem) {
                                array_push($names,"ID='".$mixed[$elem]."'");
                        }
                        $cond = join($names,' OR ');
                } elseif(is_int($mixed)) {
                        $cond = "ID='".$mixed."'";
                } else {
                        return false;
                }
                
                $query="SELECT * FROM ".$GLOBALS['database_name'].".".$GLOBALS['DB']." WHERE ".$cond;
                $result = mysql_query ($query) or die ($query. " -/- ".mysql_errno().": ".mysql_error());
                $entrys = array();
                
                while($db = mysql_fetch_assoc($result)) {
                        $entrys[] = $db;
                        $entrys[(sizeof($entrys)-1)]['confExists'] = file_exists($entrys[(sizeof($entrys)-1)]['verzeichnis']."/".$GLOBALS['emailConfig']);
                }
                return $entrys;
                
        }
        
        function copyConfig($web) {
                if (!is_dir($web['verzeichnis'])) {
                        return false;
                }
                $stdConf        = readStdConfig();
                $filler = array
                (
                        'file'          => $web['verzeichnis']."/".$GLOBALS['emailConfig'],
                        'date'          => date("Y/m/d h:i:s"),
                        'web'           => $web['verzeichnis'],
                        'domain'    => $web['domain'],
                        'config'        => "%s"
                );
                $newConf = sprintf
                (
                        $stdConf,
                        $filler['file'],
                        $filler['date'],
                        $filler['web'],
                        $filler['domain'],
                        $filler['config']
                );
                // --------
                // Temporaere Datei erzeugen
                // Und config schreiben
                $tmpf   = tempnam ("/tmp", "EMAIL_CONF");
                $hnd    = fopen($tmpf, "w");
                fwrite($hnd, $newConf);
                fclose($hnd);
                
                if (!copy($tmpf,$filler['file'])) {
                        unlink($tmpf);
                        return false;
                }
                
                unlink($tmpf);
                // --------
                return true;
        }
        
        function checkAllConfigFiles() {
        
                $webs           = getWebs();
                $stdConf        = readStdConfig();
                
                foreach (array_keys($webs) AS $tmpID) {
                        if (!$webs[$tmpID]['confExists']) {
                                // unlink($webs[$tmpID]['verzeichnis']."/".$GLOBALS['emailConfig']);
                                // --------
                                if (!copyConfig($webs[$tmpID]))
                                        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";
                                // --------
                        }
                }
                echo "<br>\n";
        }
        
        function readConfig ($confFile) {
                require_once $confFile;
                if (is_array($_emails)) {
                        foreach (array_keys($_emails) AS $emailID) {
                                echo $_emails[$emailID]."<br>";
                        }
                }
                return $_emails;
        }
        
        function readStdConfig() {
                return file_get_contents($GLOBALS['stdConfig']);
        }
        
        function appendEmail ($emailString, $confFile, $webID) {
                require_once $confFile;
                if (is_array($_emails)) {
                        foreach (array_keys($_emails) AS $emailID) {
                                echo $_emails[$emailID]."<br>";
                        }
                }
                unlink($confFile);
                copyConfig($web);
        }
        
        function prependEmail ($emailString, $confFile, $webID) {
                require_once $confFile;
        }

        function writeConfig ($emailArray, $confFile,   $webID) {
                require_once $confFile;
        }
        
        // -------------------------
        unset($HTTP_POST_VARS['pwdcheck']);
        if ($action=="update")
        {       
                
                header("Location: ".$self);  
        }

        if ($action=="delete")
        {

        }
        if (!$action) 
        {
                $action="select_edit";
        }
        if (!$sort) {$sort='Name';}
        $sort='domain';
?>
<html>
<head>
<title>Content-Management-System - Webagentur Niewerth</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel=stylesheet type="text/css" href="buttons.css">
<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}
p {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color: #000000}
p.error {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold}
span {font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
span.blue {font-family: Arial, Helvetica, sans-serif; color: #FFFFFF; background-color:#0000A0; font-size: 10pt}
span.small {font-family: Arial, Helvetica, sans-serif; font-size: 8pt; text-decoration: none}
td {font-family: Arial, Helvetica, sans-serif; font-size: 10pt}
td.timeout {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color: #FF0000;}
td.small {font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
td.headline {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; color: #FFFFFF; font-weight: bold}
td.haupt {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; font-weight: bold}
input {font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
select {font-family: Arial, Helvetica, sans-serif; font-size: 8pt}
textarea {font-family: Arial, Helvetica, sans-serif; font-size: 8pt}a {  text-decoration: none}
</style><MM:EndLock></style>
<script language="javascript" src="Farb_Assistent.js"></script>
<script language="JavaScript">
<!--

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function addAttach(obj)
{
        source=document.getElementById(obj)
        clone=source.cloneNode(true);
        clone.removeAttribute("id");
        
        source.parentNode.appendChild(clone);
}

function removeAttach(obj)
{
        div = obj.parentNode;
        td = obj.parentNode.parentNode;
        if (!div.id)  { td.removeChild(div); }
}

function removeEmail(obj)
{
        obj=document.getElementById(obj)
        div = obj.parentNode;
        td = obj.parentNode.parentNode;
        if (!div.id)  { td.removeChild(div); }
}
//-->
</script>

<meta name="description" content="Redaktionssystem">
<meta name="author" content="Webagentur Niewerth">
<meta name="robots" content="noindex">
</head>

<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">
<form method="post" action="#" name="formname" enctype="multipart/form-data">
  <table width="662" border="0" cellspacing="0" cellpadding="0">
    <tr valign="top"> 
      <td width="585"> 
<!--  Auswahl Löschen START  -->
<?php  
        if ($action=="check") {
?>
<p class="error">Pr&uuml;fe Web Konfigurationen</p>
<hr>
<?php
                checkAllConfigFiles(); 
        }
        if ($action=="delete") 
        {
                $query="SELECT * FROM $DB ";
                $query=$query."order by $sort";
                $result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
                if (mysql_num_rows($result) == 0)
                {
?>
<p class="error">Es sind keine Daten eingetragen !</p>
<p></p>
<?
                }
                else
                {
?>
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
          <tr bgcolor="#000099"> 
            <td colspan="2" class="headline">Web: L&ouml;schen</td>
          </tr>
          <?
        while ($zeile=mysql_fetch_array($result))
        {
?>
          <tr> 
            <td><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>"><? echo $zeile[domain]?> </a>&nbsp;</td>
            <td width="5%" align="center"> 
              <input type="checkbox" name="ID[]" value="<?  echo $zeile[ID] ?>">
            </td>
          </tr>
          <?
        }
?>
          <tr bgcolor="#000099"> 
            <td colspan="2" align="right"> 
              <input type="hidden" name="action" value='delete'>
              <input type="submit" value="LÖSCHEN">
              <input type="reset" name="Button22" value="Zur&uuml;cksetzen">
            </td>
          </tr>
        </table>
        <?
                }
?>
        <?
        }
?>
        <!--  Auswahl Löschen ENDE  -->
        <!--  Auswahl SELECT_EDIT START  -->
        <?

  if ($action=="select_edit") 
  {
        $query="SELECT * FROM $DB ";
        $query=$query."order by $sort";

        $result = mysql_query ($query) or die (mysql_errno().": ".mysql_error());
        if (mysql_num_rows($result) == 0)
        {
        ?>
        <p class="error">Es sind keine 
            Daten eingetragen !</p>
          <p></p>
        <?
        }
        else
        {
        ?>
        <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
          <tr bgcolor="#000099"> 
            <td class="headline" colspan="2">Web: Bearbeiten</td>
          </tr>
          <?
        while ($zeile=mysql_fetch_array($result))
        {
?>
          <tr> 
            <td><a href="<? echo $self?>?action=edit&ID=<? echo $zeile[ID]; ?>"> 
              <? echo $zeile[ID]?> <? echo $zeile[domain]?></a> </td>
          </tr>
          <?
        }
?>
          <tr bgcolor="#000099"> 
            <td colspan="2"> 
              <div align="right">&nbsp; 
                <input type="hidden" name="action" value='edit'>
              </div>
            </td>
          </tr>
        </table>
 <?
        }
?> 
        <?
        }
?> 
<!--  Auswahl SELECT_EDIT ENDE  -->

<?
        if ($action=="edit")
        {
                if ($ID)
                {
                        $result = mysql_query ("SELECT * FROM $DB where ID = $ID") or die (mysql_errno().": ".mysql_error());
                        $zeile=mysql_fetch_array($result);
                }
        ?> 
            <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolorlight="#FFFFFF" bordercolordark="#999999">
          <tr bgcolor="#000099"> 
            <td colspan="2" class="headline">Web: 
              <?
                                        if ($ID)
                                        {
                                         ?>
              Bearbeiten 
              <?
                                        }
                                        else
                                        {
                                         ?>
              Neueintrag 
              <?
                                        }
                                ?>
            </td>
          </tr>
          <tr> 
            <td bgcolor="#000099" class="headline" valign="top" width="13%">Kunde:</td>
            <td> 
              <table border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td width="18%">Name:</td>
                  <td width="82%"> 
                    <input type="text" name="kunde" value="<? echo $zeile[kunde] ?>">
                  </td>
                </tr>
                <tr> 
                  <td width="18%">Bezeichnung:</td>
                  <td width="82%"> 
                    <input type="text" name="kunde_bezeichnung" value="<? echo $zeile[kunde_bezeichnung] ?>">
                  </td>
                </tr>
                <tr> 
                  <td width="18%">Begr&uuml;ssung:</td>
                  <td width="82%"> 
                    <input type="text" name="kunde_begruessung" value="<? echo $zeile[kunde_begruessung] ?>">
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td bgcolor="#000099" class="headline" valign="top">Konfiguration:</td>
            <td>
                          <?php
                                $webs = getWebs();
                                if ($ID) {
                                        $eMails = readConfig($zeile['verzeichnis']."/".$GLOBALS['emailConfig']);
                                }
                          ?>
              <input name="configPath" type="text" id="configPath" value="<? echo $zeile['verzeichnis']."/".$GLOBALS['emailConfig'] ?>" size="40">
              <? if (!$ID) { ?>
              <br>
              <input name="create_config" type="checkbox" id="create_config" value="create">
              Konfig neu erstellen auf Basis von 
              <select name="sourceConfig" id="sourceConfig">
                <?php
                                        foreach (array_keys($webs) AS $webID) {
                                ?>
                <option>
                  <?= $webs[$webID]['domain'] ?>
                </option>
                <?php
                                        }
                                ?>
              </select>
              <? } ?>
            </td>
          </tr>
                  <!-- Emails -->
                  <?php
                                if (is_array($eMails) && sizeof($eMails) > 0) {
                                        foreach (array_keys($eMails) AS $emailID) {
                  ?>
                  <div id="mailList">
          <tr> 
            <td bgcolor="#000099" class="headline" valign="top" width="13%">Email:</td>
                        <td>
                        
                          <input name="attach[]" type="text" id="attach[]" value="<?= $eMails[$emailID] ?>">
                          <input type="button" value=" - " onClick="removeMail('mailList')">
                        
                        </td>
          </tr>
                  </div>
                  <?php
                                        }
                                }
                  ?>
          <tr> 
            <td bgcolor="#000099" class="headline" valign="top" width="13%">Add Email:</td>
                        <td>
                        <div id="mailAttach">
                          <input name="attach[]" type="text" id="attach[]">
                          <input type="button" value=" + " onClick="addAttach('mailAttach')">
                          <input type="button" value=" - " onClick="removeAttach(this)">
                        </div>
                        </td>
          </tr>
                  
                  <!-- Emails -->
                  
          <tr bgcolor="#000099"> 
            <td align="right" colspan="2"> 
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr> 
                  <td> 
                    <? if ($ID) { ?>
                    <input type="button" value="Rechte verwalten" onClick="document.location='admin_web_rechte.php?ID=<? echo $ID ?>'">
                    <? } ?>
                    &nbsp;</td>
                  <td align="right"> 
                    <input type="hidden" name="ID" value="<? echo $ID ?>">
                    <input type="hidden" name="action" value="update">
                    <input type="submit" value="OK">
                    <input type="reset" name="Button" value="Zur&uuml;cksetzen">
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
        <?
        }
?> </td>
      <td width="77" align="right"> 
        <table width="67" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#FFFFFF" bordercolordark="#999999">
                <tr> 
            <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>
                </tr>
                <tr> 
            <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>
                </tr>
                <tr> 
            <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>
                </tr>
                <tr>
                  <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>
                  </tr>
                </table>
      </td>
</tr>
</table>
</form>
</body>