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

include_once("auth.php");

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

$loUser = new SQLString($PHP_AUTH_USER);
$id = safe_query2( "SELECT cssl FROM anbieter WHERE anbieter=?", $loUser);
$werte = db_fetch_array($id);
$skssl = $werte["cssl"];


if ($skssl < 1) {
	 $fehlertext = ltext("kusser_error1");
	 db_close();
	 include("kunden_start.php");
	 exit();
}

$loKunde = new SQLString($kunde);
## prüfen, ob kunde eigene ip adresse hat
$id = safe_query2( "SELECT * FROM ipadressen WHERE kunde = ? and anbieter = ?", $loKunde, $loUser);
if (db_num_rows($id) < 1){
	 $fehlertext = ltext("kusser_error2", array($kunde));
	 include("kunden_ssl.php");
	 db_close();
	 exit();
}
## //

if ( $vorhanden == 1 ){
	$id = safe_query2( "select privatekey, crt from cssl where kunde = ? and anbieter = ? and loeschen = 0",
										 $loKunde, $loUser );
	$werte = db_fetch_array($id);
	$privatekey = $werte["privatekey"];
	$crt = $werte["crt"];

	$id = db_query("select domain from domains where kunde=? and anbieter=? and cssl=1", $loKunde, $loUser);
	if (db_num_rows($id) < 1) {
		$satz = ltext("kusser2_error3");
	} else 		{
		$werte = db_fetch_array($id);
		$domain = $werte["domain"];
		$satz = ltext("kusser2_error4",array($domain));
	}
}
?>
<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"); ?>
<script>
function doChange(formIndex)
{
	if(!formIndex){
		formIndex=0;
	}
	document.forms[formIndex].submit();
}
</script>
<table class="tblbgcolor" align="left" border="1" cellpadding="3" cellspacing="0" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">

<script>
<?
echo js_f_call_help('kusser2_title1', "kusser2_descr$vorhanden");
?>
</script>

      <? if ($vorhanden == 0) { ?>
      <form action="kunden_ssl_erstellen3.php" method="post">
          <tr > 
            <td height="15" class="titel-3" >
              <? echo ltext("kusser2_cell_key"); ?>
              </td>
            <td height="15" class="titel-3" >
              <? echo ltext("kusser2_cell_value"); ?>
              </td>
          </tr>
          <tr > 
            <td height="15">
              <? echo ltext("kusser2_cell_firm"); ?>
              </td>
            <td height="15"> 
              <input type="text" name="firm" value="<? echo $firm; ?>">
            </td>
          </tr>
          <tr > 
            <td height="15">
              <? echo ltext("kusser2_cell_unit"); ?>
              </td>
            <td height="15"> 
              <input type="text" name="unit" value="<? echo $unit; ?>">
            </td>
          </tr>
          <tr > 
            <td height="15">
              <? echo ltext("kusser2_cell_city"); ?>
              </td>
            <td height="15"> 
              <input type="text" name="city" value="<? echo $city; ?>">
            </td>
          </tr>
          <tr > 
            <td height="15">
              <? echo ltext("kusser2_cell_state"); ?>
              </td>
            <td height="15"> 
              <input type="text" name="state" value="<? echo $state; ?>">
            </td>
          </tr>
          <tr > 
            <td height="15">
              <? echo ltext("kusser2_cell_countrycode"); ?>
              </td>
            <td height="15"> 
              <input type="text" name="countrycode" value="<? echo $countrycode; ?>">
            </td>
          </tr>
          <tr > 
            <td height="15">
              <? echo ltext("kusser2_cell_email"); ?>
              </td>
            <td height="15"> 
              <input type="text" name="email" value="<? echo $email; ?>">
            </td>
          </tr>
          <tr > 
            <td height="15">
              <? echo ltext("kusser2_cell_common"); ?>
              </td>
            <td height="15"> 
              <input type="text" name="common" value="<? echo $common; ?>">
            </td>
          </tr>
          <tr>
          <td height="15"><? echo ltext("kusser2_cell_selfsigned"); ?>
          </td>
          <td height="15">
          <input type="checkbox" name="selfsigned" value="1" <?if ($selfsigned) echo "checked"?> >
          </td>
          </tr>
          <tr > 
            <td height="15">&nbsp;</td>
            <td height="15">
              <input type="hidden" name="kunde" value="<? echo $kunde; ?>">
              <input type="hidden" name="vorhanden" value="<? echo $vorhanden; ?>">
	      <? echo std_button(ltext("kusser2_btn_next"), "javascript:doChange(0)"); ?></td>
          </tr>
      </form>
      <? } else { ?>
      <form action="kunden_ssl_aktivieren.php" method="post">
          <tr> 
            <td height="15" colspan="2" class="titel-3" >
              <? echo ltext("kusser2_cell_privatekey"); ?>
              </td>
          </tr>
          <tr> 
            <td height="15" colspan="2" > 
              <textarea name="privatekey" cols="50" rows="10"><? echo $privatekey; ?></textarea>
            </td>
          </tr>
          <tr> 
            <td height="15" colspan="2" >&nbsp;</td>
          </tr>
          <tr> 
            <td height="15" colspan="2" class="titel-3" >
              <? echo ltext("kusser2_cell_crt"); ?>
              </td>
          </tr>
          <tr> 
            <td height="15" colspan="2" > 
              <textarea name="crt" cols="50" rows="10"><? echo $crt; ?></textarea>
            </td>
          </tr>
          <tr> 
            <td height="15" colspan="2" >&nbsp;</td>
          </tr>
          <tr> 
            <td height="15" colspan="2" class="titel-3" >
              <? echo ltext("kusser2_cell_domain"); ?>
              </td>
          </tr>
          <tr> 
            <td height="15" > 
              <select name="domain">
<?
	$id = safe_query2( "select domain, cssl from domains where kunde=? and anbieter=? and richtigedomain <> 3", 
										 $loKunde, $loUser);
	while ($werte = db_fetch_array($id)){
		$domain = $werte["domain"];
		$ssl = $werte["cssl"];
?>
  <option value="<? echo $domain; ?>" <? if ($ssl > 0) { echo " selected"; } ?>><? echo $domain; ?></option>
<? 
} 
?>
              </select>
            </td>
            <td height="15" >
            <input type="hidden" name="kunde" value="<? echo $kunde; ?>">
<? 
	echo std_button(ltext("kusser2_btn_save"), "javascript:doChange(0)"); 
?></td>
          </tr>
      </form>
      <form method="post" action="kunden_ssl_loeschen.php">
          <tr> 
            <td height="15" colspan="2" class="titel-3" >
              <? echo ltext("kusser2_cell_delete"); ?>
              </td>
          </tr>
          <tr> 
            <td height="15" colspan="2"><input type="hidden" name="kunde" value="<? echo $kunde; ?>">
<?
		echo std_button(ltext("kusser2_btn_del"), "javascript:doChange(1)"); 
?></td>
          </tr>
        </form>
      <? } ?>
</TABLE>
</BODY>
</HTML>
<?
db_close();
?>
