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

//
//  wws:debug
//
//
global $DEBUG;
$DEBUG = 0;
//
//
//

include_once("auth.php");

$dbdnr = array();

if (istleer($kunde)) { # update formular

## checken ob feldname angegeben, wenn feldwert angegeben

  if ( ((!istleer($freifeldwert1)) && (istleer($freifeldname1)))
       || ((!istleer($freifeldwert2)) && (istleer($freifeldname2)))
       || ((!istleer($freifeldwert3)) && (istleer($freifeldname3)))) {

    $fehlertext = ltext("kune4_error1");

    db_close();

    include("kunden_neu3.php");

    exit();

 }

## /checken ob feldname angegeben, wenn feldwert angegeben


## falls keine kundendaten angegeben wurden soll kundendatenanzeigen=nein sein

  if ((istleer($name))
      && (istleer($firma))
      && (istleer($anschrift))
      && (istleer($plzort))
      && (istleer($telefon))
      && (istleer($fax))
      && (istleer($emailadresse))
      && (istleer($kundennummer))
      && (istleer($freifeldname1))
      && (istleer($freifeldname2))
      && (istleer($freifeldname3)))
 {
   $kundendatenanzeigen = "0";
 }

## /falls keine kundendaten angegeben wurden soll kundendatenanzeigen=nein sein

} else {

## update werte aus db holen
	$loKunde = new SQLString($kunde);

  if ($datenausdbholen3 != "nein") {

    db_connect($db_host, $db_user, $db_pass);

    if ( !is_array($domain) && !$ListEdit ){
      $sql="select d.domain,d.dns,d.dnr,dns.neu,not(dns.kunde is null) as dns_exists from domains d";
      $sql.=" left join dns on dns.domain=d.domain and dns.kunde=d.kunde";
      $sql.=" where d.richtigedomain = 1 and d.kunde = ? order by d.id";

      if ($DEBUG){
	echo "sql: $sql<br>\n";
      }

      $id = safe_query2( $sql, $loKunde );


      $i=0;
      while ($werte = db_fetch_array($id)){

//      $domains .= $werte["domain"]."\n";

	$i++;
	$domain[$i]=trim($werte["domain"]);
	include_once("idn_functions.php");
	$idn_str = get_html_idn_name($domain[$i]);
//	echo "<h3>".$domain[]"</h3>"
	if ($idn_str) {
	  $domain[$i]=$idn_str;
	}
	$neu=$werte["neu"];
	if ($neu==2){
// wird geloescht
	  $domdns[$i]=0;
	  $domdnr[$i]=0;
	  $dbdnr[$domain[$i]] = $werte["dnr"];
	}
	else{
	  $domdns[$i] = $neu==1 ? 1 : $werte["dns"];
	  $dbdnr[$domain[$i]] = $domdnr[$i] = $werte["dnr"];
	}
      }

    }
    else{
      $id = safe_query2( "SELECT domain, dnr FROM domains WHERE kunde = ?", $loKunde);
      while ( $werte = db_fetch_array($id) )
	$dbdnr[ trim($werte["domain"]) ] = $werte["dnr"];
    }

    db_close();
  }
  if($DEBUG){
    echo "<br>domain:<br>\n";
    print_r($domain);
    echo "<br>domdns:<br>\n";
    print_r($domdns);
    echo "<br>domdnr:<br>\n";
    print_r($domdnr);
    echo "<br>domdel:<br>\n";
    print_r($domdel);
  }
} ## //


db_connect($db_host, $db_user, $db_pass);


$id = safe_query2( "select frontpage, cssl, maxmysql, dns, dnr from anbieter where anbieter=?", $loUser);

$werte = db_fetch_array($id);

$skfrontpage = 	$werte["frontpage"];
$skssl = 	$werte["cssl"];
$skdns = 	$werte["dns"];
$skdnr = 	$werte["dnr"];
$cmaxmysql = 	$werte["maxmysql"];

if ($cmaxmysql != 0) $skmysql = 1;

global $cIP;

if (!istleer($kunde)) {

  $id = safe_query2( "select ip from kunden where kunde = ?", $loKunde );

  $werte = db_fetch_array($id);

  $cIP = $werte["ip"];

  if (istleer($cIP)) safe_query2( "update ipadressen set kunde = '' where kunde = ?", $loKunde);

}

$id = safe_query2( "select standardip from anbieter where anbieter = ?", $loUser);

$werte = db_fetch_array($id);

$stdip = $werte["standardip"];

$id = safe_query2( "select kunde from ipadressen where ip = '$cIP' and kunde = ?", $loKunde);

if (db_num_rows($id) > 0) {

  $exklusiv = 1;

}

$formAction = istleer($kunde) ? "kunden_neu5.php" : "kunden_domain_upd.php";

if (is_array($domain)) {
	foreach ($domain as $dom_id => $domain_name) {
		if (empty($idndomain[$dom_id])) {
  			$idndomain[$dom_id] = $domain[$dom_id];
		}
	}
}



/* -------------------- template -------------------- */
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . "../include/pagers/class.ResellerDomainsPager.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . "../include/pagers/class.ResellerValuesSource.php" );

if ( $DEBUG ) {
	echo "domdnr:<br>\n";
	print_r($domdnr);
	echo "<br>\n";
}

$go_Values = new ResellerValuesSource ( $domain, $idndomain, $domdns, $domdnr );
$go_Pager = new ResellerDomainsPager ( $go_Values );
$go_Pager->MaybePerformAction ();
$go_Pager->show ( "reseller", "domains", "edit" );
/* -------------------- end template -------------------- */
?>
