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

/*
  -------------------- Name conventions --------------------
  Function names (except methods):

  ff_DescriptionOfFunction


  Constant names:

  cc_DescriptionOfConstant


  Variable names:

  $ST_DescriptionOfVariable

  where S is a scope, T is a type.

  The following scopes should be used:
  g - global
  s - static
  l - local
  m - member of class
  p - parameter

  The following types should be used:
  s - scalar
  a - array
  r - resource
  o - object
  m - mixed

  -------------------- end Name conventions --------------------
*/





include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "class.Pager.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "class.InputTextColumn.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "class.InputHtmlColumn.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "class.InputHiddenColumn.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "class.SelectColumn.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "class.InputCheckboxColumn.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "class.TextColumn.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "class.HtmlColumn.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "module.Genlib.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "module.Database.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.ResellerDomainLink.php" );
include_once ( dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.ResellerDNRColumn.php" );





class ResellerDomainsPager extends Pager
{
    /* -------------------- Members -------------------- */
    /* -------------------- end Members -------------------- */





    /* -------------------- Constructor -------------------- */
    function ResellerDomainsPager ( &$po_Source )
    {
			global $formAction, $fehlertext;
			$this->Pager ( $po_Source );
			$this->assign ( "formAction", $formAction );
			if ( strlen($fehlertext) )
				$this->addMessage( ERROR, $fehlertext );
			$this->setText ( "delquest", ltext("ed_delquest") );
			$this->setText ( "whichip", ltext("ed_whichip") );
			$this->setText ( "exclusive", ltext("kune4_cell_text3") );
			$this->setText ( "ok", ltext("ed_ok") );
			$this->setText ( "delete", ltext("ed_select") );
			$this->setText ( "apply", ltext("ed_delete") );
			$this->setText ( "noresults", ltext("ed_nodomains") );
			$this->InitializeIP();
    }
    /* -------------------- end Constructor -------------------- */





    /* -------------------- definitions of "abstract" methods -------------------- */
    function ShouldShowSummary()
    {
	return TRUE;
    }

    function ShouldShowAddForm()
    {
	return TRUE;
    }

    function GetSummary()
    {
			return ltext ( "ed_summary",
										 array (htmlspecialchars( $_SERVER["REQUEST_METHOD"] == "POST" ? $_POST["kunde"] : $_GET["kunde"] )) );
    }

    function GetAddColumns()
    {
			global $skdns, $skdnr;
			$la_Result = array( new InputHtmlColumn( "domainToAdd", ltext("ed_domain"), "", array( "style"=>"width:320" ) ) );
			if ( $skdns==1 )
				{
					$la_Result[] = new InputCheckboxColumn ( 1, "dnsToAdd", ltext("kune4_cell_dns1"), 1,
																									 array( "onClick"=>"AddDNROff()" ) );
					if ( $skdnr==1 )
						$la_Result[] = new ResellerDNRColumn ( 0, "dnrToAdd", "DNR", 1, array( "onClick"=>"AddDNSOn()" ) );
				}
			return $la_Result;
    }

    function GetBrowseColumns()
    {
			global $skdns, $skdnr;
			$la_Result = array( new InputHtmlColumn( "domain", ltext("ed_domain"), "", array( "style"=>"width:320" ) ) );
			//	$la_Result[] = new InputHiddenColumn("idndomain", "", ff_GetFromPostGet("kunde"));
			//	$la_Result[] = new HtmlColumn("idndomain", '', "");
			if ( $skdns==1 )
				{
	    $la_Result[] = new InputCheckboxColumn ( 1, "domdns", ltext("kune4_cell_dns1"), "",
																							 array( "onClick"=>"DNROff(this,this.name)" ) );
	    if ( $skdnr==1 )
				$la_Result[] = new ResellerDNRColumn ( 1, "domdnr", "DNR", "",
																							 array( "onClick"=>"DNSOn(this,this.name)" ) );
				}
	$la_Result[] = new ResellerDomainLink ( "", NULL, ltext("ed_view"), "domain", ltext("ed_view"), "",
		array( "target"=>"_blank" ) );
	return $la_Result;
    }

    function GetSearchColumns()
    {
	return array();
    }

    function GetHiddenFields()
    {
			$la_Result = array();
			$la_Result[] = new InputHiddenColumn ( "kunde", "", ff_GetFromPostGet ( "kunde" ) );
			$la_Result[] = new InputHiddenColumn ( "aktion", "", ff_GetFromPostGet ( "aktion" ) );

			global $cIP;
			if ( $cIP ) {
				$la_Result[] = new InputHiddenColumn ( "old_ip", "", $cIP );
			}

			global $kunde, $ident, $maxkb, $kbtyp, $maxpop, $maxemail, $maxautoresponder, $maxftp, $maxtransfer, $transfertyp,
				$maxsubdomains, $maxmysql, $maxcronjobs, $php, $ftp, $wildcard, $atdomains, $perl, $modpython, $ssi,
				$shell, $scponly, $statistik, $pwschutz, $fehlerseiten, $webftp, $webmail, $stdcgi, $phpupload, $wap,
				$coldfusion, $dirlist, $name, $firma, $anschrift, $ort, $plz, $firstname, $frontpage, $gender, $land,
				$telefon, $fax, $kundennummer, $emailadresse, $freifeldname1, $freifeldname2, $freifeldname3,
				$freifeldwert1, $freifeldwert2, $freifeldwert3, $kundendatenanzeigen, $spamfilter, $maxidn, $maxmaillist;
			if ( istleer($kunde) ) {
				$la_Result[] = new InputHiddenColumn ( "ident", "", $ident );
				$la_Result[] = new InputHiddenColumn ( "maxkb", "", $maxkb );
				$la_Result[] = new InputHiddenColumn ( "kbtyp", "", $kbtyp );
				$la_Result[] = new InputHiddenColumn ( "maxpop", "", $maxpop );
				$la_Result[] = new InputHiddenColumn ( "maxemail", "", $maxemail );
				$la_Result[] = new InputHiddenColumn ( "maxautoresponder", "", $maxautoresponder );
				$la_Result[] = new InputHiddenColumn ( "maxftp", "", $maxftp );
				$la_Result[] = new InputHiddenColumn ( "maxtransfer", "", $maxtransfer );
				$la_Result[] = new InputHiddenColumn ( "transfertyp", "", $transfertyp );
				$la_Result[] = new InputHiddenColumn ( "maxsubdomains", "", $maxsubdomains );
				$la_Result[] = new InputHiddenColumn ( "maxmysql", "", $maxmysql );
				$la_Result[] = new InputHiddenColumn ( "maxcronjobs", "", $maxcronjobs );
				$la_Result[] = new InputHiddenColumn ( "php", "", $php );
				$la_Result[] = new InputHiddenColumn ( "ftp", "", $ftp );
				$la_Result[] = new InputHiddenColumn ( "wildcard", "", $wildcard );
				$la_Result[] = new InputHiddenColumn ( "atdomains", "", $atdomains );
				$la_Result[] = new InputHiddenColumn ( "perl", "", $perl );
				$la_Result[] = new InputHiddenColumn ( "modpython", "", $modpython );
				$la_Result[] = new InputHiddenColumn ( "ssi", "", $ssi );
				$la_Result[] = new InputHiddenColumn ( "shell", "", $shell );
				$la_Result[] = new InputHiddenColumn ( "scponly", "", $scponly );
				$la_Result[] = new InputHiddenColumn ( "statistik", "", $statistik );
				$la_Result[] = new InputHiddenColumn ( "pwschutz", "", $pwschutz );
				$la_Result[] = new InputHiddenColumn ( "fehlerseiten", "", $fehlerseiten );
				$la_Result[] = new InputHiddenColumn ( "webftp", "", $webftp );
				$la_Result[] = new InputHiddenColumn ( "webmail", "", $webmail );
				$la_Result[] = new InputHiddenColumn ( "stdcgi", "", $stdcgi );
				$la_Result[] = new InputHiddenColumn ( "phpupload", "", $phpupload );
				$la_Result[] = new InputHiddenColumn ( "wap", "", $wap );
				$la_Result[] = new InputHiddenColumn ( "coldfusion", "", $coldfusion );
				$la_Result[] = new InputHiddenColumn ( "dirlist", "", $dirlist );
				$la_Result[] = new InputHiddenColumn ( "name", "", $name );
				$la_Result[] = new InputHiddenColumn ( "firma", "", $firma );
				$la_Result[] = new InputHiddenColumn ( "anschrift", "", $anschrift );
				$la_Result[] = new InputHiddenColumn ( "ort", "", $ort );
				$la_Result[] = new InputHiddenColumn ( "plz", "", $plz );
				$la_Result[] = new InputHiddenColumn ( "firstname", "", $firstname );
				$la_Result[] = new InputHiddenColumn ( "frontpage", "", $frontpage );
				$la_Result[] = new InputHiddenColumn ( "gender", "", $gender );
				$la_Result[] = new InputHiddenColumn ( "land", "", $land );
				$la_Result[] = new InputHiddenColumn ( "telefon", "", $telefon );
				$la_Result[] = new InputHiddenColumn ( "fax", "", $fax );
				$la_Result[] = new InputHiddenColumn ( "kundennummer", "", $kundennummer );
				$la_Result[] = new InputHiddenColumn ( "emailadresse", "", $emailadresse );
				$la_Result[] = new InputHiddenColumn ( "freifeldname1", "", $freifeldname1 );
				$la_Result[] = new InputHiddenColumn ( "freifeldname2", "", $freifeldname2 );
				$la_Result[] = new InputHiddenColumn ( "freifeldname3", "", $freifeldname3 );
				$la_Result[] = new InputHiddenColumn ( "freifeldwert1", "", $freifeldwert1 );
				$la_Result[] = new InputHiddenColumn ( "freifeldwert2", "", $freifeldwert2 );
				$la_Result[] = new InputHiddenColumn ( "freifeldwert3", "", $freifeldwert3 );
				$la_Result[] = new InputHiddenColumn ( "kundendatenanzeigen", "", $kundendatenanzeigen );
				$la_Result[] = new InputHiddenColumn ( "spamfilter", "", $spamfilter );
				$la_Result[] = new InputHiddenColumn ( "maxidn", "", -1 );
				$la_Result[] = new InputHiddenColumn ( "maxmaillist", "", $maxmaillist );
			}
			
			return $la_Result;
    }

    function AddElement()
    {
	$ls_Domain = trim($_POST["domainToAdd"]);

	if (!strlen($ls_Domain))
		return;
	
/*
	// check if international and then translate
	include_once('class.InputDecode.php');
	$ls_DomainTranslated = InputDecode::decode($ls_DomainOrig);
	if ($ls_DomainTranslated != $ls_DomainOrig) {
		// has national characters

		$ls_DomainName = escapeshellarg($ls_DomainTranslated);
		global $bindir;
		$exec = "$bindir/idn_translate.pl UTF8 $ls_DomainName";
		exec($exec, $list, $return);
		if ($return != 0) {
			// error
			echo "<p><b>Error:</b> idn_translate.pl returned with non-zero status:<pre>".implode("\n", $list)."</pre></p>";
			return 0;
		}
		if (sizeof($list) < 1) {
			// error
			echo "<p><b>Error:</b> idn_translate.pl returned with zero output:<pre>".implode("\n", $list)."</pre></p>";
			return 0;
		}
		if (!preg_match("/^to_idn:\s+([a-zA-Z0-9\.-]+)$/", $list[0], $matches)) {
			// error
			echo "<p><b>Error:</b> Can not parse output of the idn_translate.pl utility:<pre>".implode("\n", $list)."</pre></p>";
			return 0;
		} 
		$ls_Domain = $matches[1]; 	
	} else {
		$ls_Domain = $ls_DomainOrig;
	}
*/
	global $domain;
	$domain[$this->mo_Source->TotalElements( $this->ma_SearchColumns )+1] = $ls_Domain;
	$ls_DNS = array_key_exists( "dnsToAdd", $_POST ) ? $_POST["dnsToAdd"] : 0;
	$ls_DNR = array_key_exists( "dnrToAdd", $_POST ) ? $_POST["dnrToAdd"] : 0;
	$this->mo_Source->AddElement (
		array(
			0 => $this->mo_Source->TotalElements( $this->ma_SearchColumns )+1
		,	"domain" => $ls_Domain
		,	"domdnr" => $ls_DNR
		,	"domdns" => $ls_DNS
//		,	'idndomain' => $ls_DomainOrig
		)
	);
	
    }

    function EditElements()
    {
    }

    function DeleteElements ( &$pa_IDs )
    {
	$this->mo_Source->DeleteElements ( $pa_IDs );
    }
    /* -------------------- end definitions "abstract" methods -------------------- */





    /* -------------------- MaybePerformAction & related ------------------ */
    function DeleteFieldName()
    {
	return "domdel";
    }
    /* -------------------- end MaybePerformAction & related ------------------ */





    /* -------------------- InitializeIP -------------------- */
    function InitializeIP()
    {
			global $stdip, $cIP, $PHP_AUTH_USER, $exklusiv;
			
			$la_IPs = array( "standard" => ltext("kune4_cell_select_stdip") );
			$lo_DB =& get_db_connection();
			$lo_Query =& $lo_DB->Select ( "SELECT ip FROM ipadressen WHERE anbieter=" . db_full_quote($PHP_AUTH_USER) .
																		" AND ip <> " . db_full_quote($stdip) . " AND kunde='' OR ip=" . db_full_quote($cIP) );
			while ( $la_Row = $lo_Query->nextrow() )
				if ( $la_Row["ip"] != $stdip )
					$la_IPs[ $la_Row["ip"] ] = $la_Row["ip"];

			$this->assign ( "ipoptions", $la_IPs );
			$this->assign ( "selectedip", $cIP );
			$this->assign ( "exclusive", array( "1" ) );
			if ( $exklusiv==1 )
				$this->assign ( "checkedex", "checked" );
    }
    /* -------------------- end InitializeIP -------------------- */

}
?>
