<?
########## Confixx(R) 3.0 Professional ############
####### Copyright SWsoft, Inc. 2004-2005 ##########
#### http://www.sw-soft.com - info@sw-soft.com ####

include_once( "../include/class.SQLString.php" );
include_once("auth.php");

## mysql verbindung aufbauen
db_connect($db_host, $db_user, $db_pass);
## /mysql verbindung aufbauen

$kunde_unsecure = new SQLString( $PHP_AUTH_USER);
$id = safe_query( "SELECT COUNT(domain) as domain_numb FROM domains WHERE kunde = ? AND richtigedomain = '1'", TRUE, $kunde_unsecure);
$werte = db_fetch_array($id);
$domain_numb = $werte["domain_numb"];

if ($domain_numb > 0 ) {

$id = safe_query( "SELECT domain FROM domains WHERE kunde = ?  AND richtigedomain='1' ORDER BY domain", TRUE, $kunde_unsecure );
while ($werte = db_fetch_array($id))
	{
	 $domain = $werte["domain"];
	 if ($i < 1)
		{
		 $domainliste[] = "<option value=\"$domain\" selected>.$domain</option>\n";
		 $i++;
		}
	 else 
		{
		 $domainliste[] = "<option value=\"$domain\">.$domain</option>\n";
		}
	}

## so viel darf noch eingerichtet werden
$id = safe_query( "SELECT maxftp, webmail, webftp, pwschutz, fehlerseiten, maxsubdomains, wildcard, perl FROM kunden WHERE kunde = ? ", TRUE, $kunde_unsecure );
$werte = db_fetch_array($id);
$maxsubdomains = $werte["maxsubdomains"];
$maxftp = $werte["maxftp"];
$skwebmail = $werte["webmail"];
$skwebftp = $werte["webftp"];
$skfehlerseiten = $werte["fehlerseiten"];
$skpwschutz = $werte["pwschutz"];
$skperl = $werte["perl"];
$wildcard = $werte["wildcard"];

$id = safe_query( "SELECT domain FROM domains WHERE richtigedomain='0' AND kunde = ? ", TRUE, $kunde_unsecure );
$genutztesubdomains = db_num_rows($id);
if ($maxsubdomains != "-1") { $freiesubdomains = $maxsubdomains - $genutztesubdomains; }
else { $freiesubdomains = -1; }
## /so viel darf noch eingerichtet werden

}
?>

<HTML>
<HEAD>
<META content="text/html; charset=<? echo $lang_html_charset; ?>" http-equiv=Content-Type>
<LINK href="<?=$strSkinName?>/style.css" rel=stylesheet type=text/css>
</HEAD>

<BODY bgColor=#ffffff bottomMargin=0 leftMargin=0 topMargin=0 MARGINHEIGHT="0" MARGINWIDTH="0">
<br><? include("../fehler.inc.php"); ?>
<? if ($domain_numb > 0) { ?>

<script>
function doChange()
{
document.forms[0].submit();
}
</script>
<table class="tblbgcolor" width="100%" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr>
    <td valign=top>
<table class="tblbgcolor" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
        <tr> 
          <td valign="top" colspan=3>
            <? if ($maxsubdomains <> 0) { ?>
            <p> 
              <? echo ltext("todo_desc1", array($genutztesubdomains)); ?>
              <? 
if ($freiesubdomains == "-1")
	{ echo ltext("todo_desc1a"); }
else 
	 { echo ltext("todo_desc1b", array($freiesubdomains)); }
?>
              </p>
            <? } ?>
          </td>
        </tr>
<tr><td colspan=3 class="titel-3" ><? echo ltext("todo_subtitle1"); ?></td></tr>
        <tr > 
          <td  class="titel-3" ><? echo ltext("todo_cell_domain"); ?></td>
          <td class="titel-3" ><? echo ltext("todo_cell_redirect"); ?></td>
          <td class="titel-3" ><? echo ltext("todo_cell_action"); ?></td>
        </tr>
        <?
$id = safe_query( "select domain, pfad, cssl from domains where kunde = ?  and richtigedomain='1' order by domain", TRUE, new SQLString( $PHP_AUTH_USER ) );
while ($werte = db_fetch_array($id)) {
$domain = $werte["domain"];
$domainpfad = $werte["pfad"];
$ssl = $werte["cssl"];

#www.domain.de soll direkt unter der domain stehen
$subdomain = "www.$domain";
$id2 = safe_query( "select domain, pfad, cssl from domains where kunde = ?  and richtigedomain='2' and domain = ? ", TRUE, new SQLString( $PHP_AUTH_USER ), new SQLString( $subdomain ) );
$werte2 = db_fetch_array($id2);
$subdomainpfad = $werte2["pfad"];
$subdomain = $werte2["domain"];
$subdomainssl = $werte2["cssl"];

?>
        <tr > 
          <td >
            <? echo $domain; ?>
            <? if ($ssl > 0) { echo " <b>[SSL]</b>"; $ssllink = "&ssl=$ssl"; } ?>
            </td>
          <td  >
            <? echo $domainpfad; ?>
            </td>
          <td ><a class=data href="tools_domains_aendern.php?domain=<? echo $domain; ?>&pfad=<? echo $domainpfad.$ssllink; ?>"><? echo ltext("todo_link_change"); ?></a> 
            </td>
        </tr>
        <tr > 
          <td >
            <? echo $subdomain; ?>
            <? if ($subdomainssl > 0) { echo " <b>[SSL]</b>"; $ssllink = "&ssl=$subdomainssl"; } ?> 
            </td>
          <td  >
            <? echo $subdomainpfad; ?>
            </td>
          <td >
            <? if ($subdomainsfrontpage == 0) { ?>
            <a class=data href="tools_domains_aendern.php?domain=<? echo $subdomain; ?>&pfad=<? echo $subdomainpfad.$ssllink; ?>"><? echo ltext("todo_link_change"); ?></a>
            <? } else { echo "<b>FrontPage</b>"; } ?>
            </td>
        </tr>
        <? } ?>
        <tr> 
          <td valign="top" colspan=3>
<? echo ltext("todo_desc2"); ?>
          </td>
        </tr>
        <?
$id = safe_query( "select domain, pfad, cssl from domains where kunde = ?  and richtigedomain='0' order by domain", TRUE, new SQLString( $PHP_AUTH_USER ) );

if (db_num_rows($id) > 0) { ?>
      <tr><td colspan=3 class="titel-3" ><? echo ltext("todo_subtitle2"); ?></td></tr>
        <tr > 
          <td class="titel-3" >
            <? echo ltext("todo_cell_subdomain"); ?>
            </td>
          <td class="titel-3" >
            <? echo ltext("todo_cell_redirect"); ?>
            </td>
          <td class="titel-3" >
            <? echo ltext("todo_cell_action"); ?>
            </td>
        </tr>
        <?
while ($werte = db_fetch_array($id)) {
$domain = $werte["domain"];
$domainpfad = $werte["pfad"];
$ssl = $werte["cssl"];
?>
        <tr > 
          <td > 
            <? echo $domain; ?>
            <? if ($ssl > 0) { echo " <b>[SSL]</b>"; } ?>
            </td>
          <td  > 
            <? echo $domainpfad; ?>
            </td>
          <td > 
            <? if ($ssl == 0) { ?>
            <a class=data onclick="return <?=js_confirm(ltext("todo_confirm_delete")) ?>" href="tools_domains_loeschen.php?domain=<? echo $domain; ?>"><? echo ltext("todo_link_del"); ?></a>&nbsp;
            <a class=data href="tools_domains_aendern.php?domain=<? echo $domain; ?>&pfad=<? echo $domainpfad; ?>"><? echo ltext("todo_link_change"); ?></a> 
            <? } else { ?>
            <a class=data href="tools_domains_aendern.php?domain=<? echo $domain; ?>&pfad=<? echo $domainpfad; ?>&ssl=1"> 
            <? echo ltext("todo_link_change"); ?>
            </a> 
            <? } ?>
            </td>
        </tr>
        <? } ?>
      <? } ?>    

      <p> <br>
        <? if (($freiesubdomains > 0) || ($freiesubdomains == "-1")) { ?>
      </p>
      <form action="tools_domains_neu.php" method="post">
      <b><i><? echo ltext("todo_subtitle3"); ?> 
      </i></b> 
        <tr> 
            <td class="titel-3" ><? echo ltext("todo_cell_domain"); ?></td>
            <td colspan=2 class="titel-3" ><? echo ltext("todo_cell_path"); ?> 
              </td>
        </tr>
        <tr > 
            <td > 
              <input type="text" name="prefix" size="20" value="<? echo $prefix; ?>">
            <select name="domain">

<?
for ($i = 0; $i < count($domainliste); $i++)
	{
	 echo $domainliste[$i];
	}
?>

            </select>
          </td>
            <td colspan=2>
              <input type="text" name="pfad" size="20" value="<? echo $pfad; ?>">
              </td>
        </tr>
        <tr> 
            <td>&nbsp;</td>
            <td colspan=2><? echo std_button(ltext('todo_btn_save'), 'javascript:doChange()') ?></td>
        </tr>
      </form>
      <? } ?> 
        <tr> 
          <td valign="top" colspan=3>

      <p><? echo ltext("todo_desc3"); ?></p>

<? if ($wildcard != 0) { ?>
	  <p><? echo ltext("todo_desc4"); ?></p><? } ?>
          </td>
        </tr>
      </table>
</td>
</TR>
</TABLE>
<? } else { ?>

<table class="tblbgcolor" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
<tr>
    <td colspan=4>
	  <? echo ltext("todo_nodomain"); ?>
	</td>
</tr>
</table>

<? } ?>

</BODY>
</HTML>

<?
db_close();
?>
