Example #1
0
 function createUiContainers()
 {
     $isDefaultType = $this->values["type"] == "1" ? "checked" : "";
     $algorithmsMap = $this->algorithms();
     $algorithms = array_values($algorithmsMap);
     if (isset($algorithmsMap[$this->values["algorithm"]])) {
         $algorithmIndex = array_search($algorithmsMap[$this->values["algorithm"]], $algorithms);
         $customAlgorithm = "";
     } else {
         $algorithmIndex = count($algorithms) - 1;
         $customAlgorithm = $this->values["algorithm"];
     }
     $isCustomAlgorithm = $algorithmIndex == count($algorithms) - 1 ? "checked" : "";
     $algorithmComboBox = new ExtendedSelectItem($this->pn("algorithm"));
     $algorithmComboBox->setAdditionalParams("onkeyup=\"this.blur();this.focus();\" onchange=\"var state = (this.selectedIndex == this.length - 1) ? 'inline' : 'none'; changeObjectDisplay('" . $this->pn("algorithmdiv") . "',state);\"");
     $algorithmComboBox->setElements(array_values($algorithms));
     $algorithmComboBox->setElementsVal(array_keys($algorithms));
     $digestTextarea = new TextareaTpl($this->pn("digest"));
     $digestTextarea->setCols(43);
     $t1 = new Table();
     $t1->add($this->_createNameElement(_T("Domain name")), array("value" => $this->hostname, "required" => True));
     $t1->add(new TrFormElement(_T("SHA-1 digest"), new CheckboxTpl($this->pn("isdefaulttype"))), array("value" => $isDefaultType, "extraArg" => 'onclick="toggleVisibility(\'' . $this->pn("typediv") . '\');"'));
     $typeDiv = new Div(array("id" => $this->pn("typediv")));
     $typeDiv->setVisibility($isDefaultType ? "" : "checked");
     $t2 = new Table();
     $t2->add(new TrFormElement(_T("Custom digest type"), new InputTpl($this->pn("customtype"), '/^\\d+$/'), array("tooltip" => _T("Digest type ranges from 0 to 255"))), array("value" => $this->values["type"]));
     $t3 = new Table();
     $t3->add(new TrFormElement(_T("Algorithm"), $algorithmComboBox), array("value" => $algorithmIndex));
     $algorithmDiv = new Div(array("id" => $this->pn("algorithmdiv")));
     $algorithmDiv->setVisibility($isCustomAlgorithm);
     $t4 = new Table();
     $t4->add(new TrFormElement(_T("Custom algorithm"), new InputTpl($this->pn("customalgorithm"), '/^([01]?\\d?\\d|2[0-4]\\d|25[0-5])$/'), array("tooltip" => _T("Algorithm ranges from 0 to 255"))), array("value" => $customAlgorithm));
     $t5 = new Table();
     $t5->add(new TrFormElement(_T("Key tag"), new InputTpl($this->pn("keytag"), '/^([0-5]?\\d?\\d?\\d?\\d|6[0-4]\\d\\d\\d|65[0-4]\\d\\d|655[0-2]\\d|6553[0-5])$/'), array("tooltip" => _T("Key tag is a decimal number that ranges from 0 to 65535"))), array("value" => $this->values["keytag"], "required" => True));
     $t5->add(new TrFormElement(_T("Digest"), $digestTextarea, array("tooltip" => _T("The Digest MUST be represented as a sequence of case-insensitive hexadecimal digits"))), array("value" => $this->values["digest"]));
     return array($this->stackedUi($t1), $this->stackedUi($typeDiv, 0), $this->stackedUi($t2, 2), $this->stackedUi($t3), $this->stackedUi($algorithmDiv, 0), $this->stackedUi($t4, 2), $this->stackedUi($t5));
 }
Example #2
0
    function createUiContainers(){
                                                                                         
	$recordTypes = supportedRecordsTypes("all");
	$typeIndex = array_search(strtoupper($this->values["type"]),$recordTypes);
	if ($typeIndex === false){
    	    $typeIndex = count($recordTypes)-1;
            $customType = $this->values["type"];
        } else {
            $customType = "";
            //$typeIndex = 0;
        }
	$isCustomType = ($typeIndex == (count($recordTypes) - 1)) ? "checked" : ""; 
	
	$algorithmsMap = $this->algorithms();
	$algorithms = array_values($algorithmsMap);
	if (isset($algorithmsMap[$this->values["algorithm"]])){
	    $algorithmIndex = array_search($algorithmsMap[$this->values["algorithm"]], $algorithms);
	    $customAlgorithm = "";
	} else {
	    $algorithmIndex = count($algorithms) - 1;
	    $customAlgorithm = $this->values["algorithm"];
	}
	$isCustomAlgorithm = ($algorithmIndex == (count($algorithms) - 1)) ? "checked" : ""; 

	
        $typeComboBox = new ExtendedSelectItem($this->pn("type"));
 	$typeComboBox->setAdditionalParams("onkeyup=\"this.blur();this.focus();\" onchange=\"var state = (this.selectedIndex == this.length - 1) ? 'inline' : 'none'; changeObjectDisplay('" . $this->pn("typediv"). "',state);\"");
	$typeComboBox->setElements(array_values($recordTypes));
	$typeComboBox->setElementsVal(array_keys($recordTypes));
	
	$algorithmComboBox = new ExtendedSelectItem($this->pn("algorithm"));
 	$algorithmComboBox->setAdditionalParams("onkeyup=\"this.blur();this.focus();\" onchange=\"var state = (this.selectedIndex == this.length - 1) ? 'inline' : 'none'; changeObjectDisplay('" . $this->pn("algorithmdiv"). "',state);\"");
	$algorithmComboBox->setElements(array_values($algorithms));
	$algorithmComboBox->setElementsVal(array_keys($algorithms));
		
	$signatureTextarea = new TextareaTpl($this->pn("signature"));
	$signatureTextarea->setCols(43);
	
	
	$t1 = new Table();
	$t1->add($this->_createNameElement(_T("Domain name")),
		array("value" => $this->hostname, "required" => True));
	$t1->add(new TrFormElement(	_T("Domain name of the signer, generating this SIG"), 
					new InputTpl($this->pn("signer")), 
					$this->_dnRulesTooltip()),
		array("value" => $this->values["signer"], "required" => True));
	$t1->add(new TrFormElement(_T("Record type covered by this SIG"), $typeComboBox),
		array("value"=>$typeIndex));
	
	$typeDiv = new Div(array("id" => $this->pn("typediv")));
        $typeDiv->setVisibility($isCustomType);
	
	$t2 = new Table();
	$t2->add(new TrFormElement(_T("Custom record type"), new InputTpl($this->pn("customtype"),'/\w+/')),
		array("value"=>$customType));
		
	$t3 = new Table();
			
	$t3->add(new TrFormElement(_T("Algorithm"), $algorithmComboBox),
		array("value"=>$algorithmIndex));
		
	$algorithmDiv = new Div(array("id" => $this->pn("algorithmdiv")));
        $algorithmDiv->setVisibility($isCustomAlgorithm);
	
	$t4 = new Table();
	$t4->add(new TrFormElement(
		    _T("Custom algorithm"), 
		    new InputTpl($this->pn("customalgorithm"), '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/'), 
		    array("tooltip" => _T("Algorithm ranges from 0 to 255"))
		    ),
		 array("value"=>$customAlgorithm));
	
	$t5 = new Table();
	$t5->add(new TrFormElement(
		    _T("Labels"), 
		    new InputTpl($this->pn("labels"), '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/'),
		    array("tooltip" => _T("Define an unsigned count of how many labels there are in the original SIG record owner name not counting the null label for root and not counting any initial \"*\" for a wildcard.") . "<br>" .
   	        		       _T("Labels count ranges from 0 to 255"))
		    ),
		array("value" => $this->values["labels"], "required" => True));
		
	$t5->add(new TrFormElement(_T("Original TTL"), new BindRemainingTimeTpl($this->pn("ttl"))),
		array("value"=>BindRemainingTimeTpl::valueFromBindTimeString($this->values["ttl"])));
	$t5->add(new TrFormElement(_T("Signature inception time"), new ExtendedDateTpl($this->pn("inception"))),
		array("value"=>$this->bindTimeToDateTplTime($this->values["inception"])));
	$t5->add(new TrFormElement(_T("Signature expiration time"), new ExtendedDateTpl($this->pn("expiration"))),
		array("value"=>$this->bindTimeToDateTplTime($this->values["expiration"])));
	$t5->add(new TrFormElement(
		    _T("Key tag"), 
		    new InputTpl($this->pn("keytag"), '/^([0-5]?\d?\d?\d?\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5])$/'),
		    array("tooltip" => _T("Key tag is a decimal number that ranges from 0 to 65535"))
		    ),
		array("value" => $this->values["keytag"], "required" => True));
	$t5->add(new TrFormElement(_T("Signature"), $signatureTextarea),
		array("value" => $this->values["signature"]));
		
	
	return array($this->stackedUi($t1), $this->stackedUi($typeDiv,0), $this->stackedUi($t2,2),
		     $this->stackedUi($t3), $this->stackedUi($algorithmDiv,0), $this->stackedUi($t4,2),
		     $this->stackedUi($t5));
	
    }
Example #3
0
    function createUiContainers(){
                                                                                         
	$typesMap = $this->types();
	$types = array_values($typesMap);
	if (isset($typesMap[$this->values["type"]])){
	    $typeIndex = array_search($typesMap[$this->values["type"]], $types);
	    $customType = "";
	} else {
	    $typeIndex = count($types) - 1;
	    $customType = $this->values["type"];
	}
	$isCustomType = ($typeIndex == (count($types) - 1)) ? "checked" : ""; 
	
	$algorithmsMap = $this->algorithms();
	$algorithms = array_values($algorithmsMap);
	if (isset($algorithmsMap[$this->values["algorithm"]])){
	    $algorithmIndex = array_search($algorithmsMap[$this->values["algorithm"]], $algorithms);
	    $customAlgorithm = "";
	} else {
	    $algorithmIndex = count($algorithms) - 1;
	    $customAlgorithm = $this->values["algorithm"];
	}
	$isCustomAlgorithm = ($algorithmIndex == (count($algorithms) - 1)) ? "checked" : ""; 

	
        $typeComboBox = new ExtendedSelectItem($this->pn("type"));
 	$typeComboBox->setAdditionalParams("onkeyup=\"this.blur();this.focus();\" onchange=\"var state = (this.selectedIndex == this.length - 1) ? 'inline' : 'none'; changeObjectDisplay('" . $this->pn("typediv"). "',state);\"");
	$typeComboBox->setElements(array_values($types));
	$typeComboBox->setElementsVal(array_keys($types));
	
	$algorithmComboBox = new ExtendedSelectItem($this->pn("algorithm"));
 	$algorithmComboBox->setAdditionalParams("onkeyup=\"this.blur();this.focus();\" onchange=\"var state = (this.selectedIndex == this.length - 1) ? 'inline' : 'none'; changeObjectDisplay('" . $this->pn("algorithmdiv"). "',state);\"");
	$algorithmComboBox->setElements(array_values($algorithms));
	$algorithmComboBox->setElementsVal(array_keys($algorithms));
		
	$certificateTextarea = new TextareaTpl($this->pn("certificate"));
	$certificateTextarea->setCols(43);
	
	
	$t1 = new Table();
	$t1->add($this->_createNameElement(_T("Domain name")),
		array("value" => $this->hostname, "required" => True));
	$t1->add(new TrFormElement(_T("Type"), $typeComboBox),
		array("value"=>$typeIndex));
	
	$typeDiv = new Div(array("id" => $this->pn("typediv")));
        $typeDiv->setVisibility($isCustomType);
	
	$t2 = new Table();
	$t2->add(new TrFormElement(
		    _T("Custom type"), 
		    new InputTpl($this->pn("customtype"),'/^([0-5]?\d?\d?\d?\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5])$/'),
		    array("tooltip" => _T("Type ranges from 0 to 65535"))
		    ),
		array("value"=>$customType));
		
	$t3 = new Table();
			
	$t3->add(new TrFormElement(_T("Algorithm"), $algorithmComboBox),
		array("value"=>$algorithmIndex));
		
	$algorithmDiv = new Div(array("id" => $this->pn("algorithmdiv")));
        $algorithmDiv->setVisibility($isCustomAlgorithm);
	
	$t4 = new Table();
	$t4->add(new TrFormElement(
		    _T("Custom algorithm"), 
		    new InputTpl($this->pn("customalgorithm"), '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/'), 
		    array("tooltip" => _T("Algorithm ranges from 0 to 255"))
		    ),
		 array("value"=>$customAlgorithm));
	
	$t5 = new Table();
	
	 $t5->add(new TrFormElement(
	                 _T("Key tag"), 
	                 new InputTpl($this->pn("keytag"), '/^([0-5]?\d?\d?\d?\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5])$/'),
	                 array("tooltip" => _T("Key tag is a decimal number that ranges from 0 to 65535"))
	                ),
	        array("value" => $this->values["keytag"], "required" => True));
	                                                                                                 
	
	$t5->add(new TrFormElement(_T("Certificate"), $certificateTextarea),
		array("value" => $this->values["certificate"]));
		
	
	return array($this->stackedUi($t1), $this->stackedUi($typeDiv,0), $this->stackedUi($t2,2),
		     $this->stackedUi($t3), $this->stackedUi($algorithmDiv,0), $this->stackedUi($t4,2),
		     $this->stackedUi($t5));
	
    }
Example #4
0
File: key.php Project: neoclust/mmc
    function createUiContainers(){

	$protocolsMap = $this->protocols();
	$protocols = array_values($protocolsMap);
	if (isset($protocolsMap[$this->values["protocol"]])){
	    $protocolIndex = array_search($protocolsMap[$this->values["protocol"]], protocols);
	    $customProtocol = "";
	} else {
	    $protocolIndex = count($protocols) - 1;
	    $customProtocol = $this->values["protocol"];
	}
	$isCustomProtocol = ($protocolIndex == (count($protocols) - 1)) ? "checked" : ""; 

	
	$algorithmsMap = $this->algorithms();
	$algorithms = array_values($algorithmsMap);
	if (isset($algorithmsMap[$this->values["algorithm"]])){
	    $algorithmIndex = array_search($algorithmsMap[$this->values["algorithm"]], $algorithms);
	    $customAlgorithm = "";
	} else {
	    $algorithmIndex = count($algorithms) - 1;
	    $customAlgorithm = $this->values["algorithm"];
	}
	$isCustomAlgorithm = ($algorithmIndex == (count($algorithms) - 1)) ? "checked" : ""; 

	$fh = new FlagsHandler($this->values["flags"]);
	
	$usePolicyIndex = $fh->usePolicy();
	$usePolicies = $fh->usePolicies();
	$hasSignature = ($usePolicyIndex < (count($usePolicies) - 1)) ? "checked" : ""; 

	$nameTypeIndex = $fh->nameType();
	$nameTypes = $fh->nameTypes();
	
	$hasUpdate = $fh->zoneUpdate() ? "checked" : "";
	$hasStrongUpdate = $fh->strongUpdate() ? "checked" : "";	
	$hasUniqueNameUpdate = $fh->nameUpdate() ? "checked" : "";	
	
        $protocolComboBox = new ExtendedSelectItem($this->pn("protocol"));
 	$protocolComboBox->setAdditionalParams("onkeyup=\"this.blur();this.focus();\" onchange=\"var state = (this.selectedIndex == this.length - 1) ? 'inline' : 'none'; changeObjectDisplay('" . $this->pn("protocoldiv"). "',state);\"");
	$protocolComboBox->setElements(array_values($protocols));
	$protocolComboBox->setElementsVal(array_keys($protocols));
	
	$algorithmComboBox = new ExtendedSelectItem($this->pn("algorithm"));
 	$algorithmComboBox->setAdditionalParams("onkeyup=\"this.blur();this.focus();\" onchange=\"var state = (this.selectedIndex == this.length - 1) ? 'inline' : 'none'; changeObjectDisplay('" . $this->pn("algorithmdiv"). "',state);\"");
	$algorithmComboBox->setElements(array_values($algorithms));
	$algorithmComboBox->setElementsVal(array_keys($algorithms));
	
	$usePolicyComboBox = new ExtendedSelectItem($this->pn("usepolicy"));
 	$usePolicyComboBox->setAdditionalParams("onkeyup=\"this.blur();this.focus();\" onchange=\"var state = (this.selectedIndex < this.length - 1) ? 'inline' : 'none'; changeObjectDisplay('" . $this->pn("signaturediv"). "',state);\"");
	$usePolicyComboBox->setElements(array_values($usePolicies));
	$usePolicyComboBox->setElementsVal(array_keys($usePolicies));
	
	$nameTypeComboBox = new ExtendedSelectItem($this->pn("nametype"));
	$nameTypeComboBox->setElements(array_values($nameTypes));
	$nameTypeComboBox->setElementsVal(array_keys($nameTypes));
 	
	
		
	$signatureTextarea = new TextareaTpl($this->pn("signature"));
	$signatureTextarea->setCols(43);
	
	$t1 = new Table();
	$t1->add($this->_createNameElement(_T("Domain name")),
		array("value" => $this->hostname, "required" => True));
		
	$t1->add(new TrFormElement(_T("Protocol"), $protocolComboBox),
		array("value"=>$protocolIndex));
	
	$protocolDiv = new Div(array("id" => $this->pn("protocoldiv")));
        $protocolDiv->setVisibility($isCustomProtocol);
	
	$t2 = new Table();
	$t2->add(new TrFormElement(
		    _T("Custom protocol"), 
		    new InputTpl($this->pn("customprotocol"), '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/'),
		    array("tooltip" => _T("Protocol ranges from 0 to 255"))
		    ),
		array("value"=>$customProtocol));
		
	$t3 = new Table();
			
	$t3->add(new TrFormElement(_T("Algorithm"), $algorithmComboBox),
		array("value"=>$algorithmIndex));
		
	$algorithmDiv = new Div(array("id" => $this->pn("algorithmdiv")));
        $algorithmDiv->setVisibility($isCustomAlgorithm);
	
	$t4 = new Table();
	$t4->add(new TrFormElement(
		    _T("Custom algorithm"), 
		    new InputTpl($this->pn("customalgorithm"), '/^([01]?\d?\d|2[0-4]\d|25[0-5])$/'), 
		    array("tooltip" => _T("Algorithm ranges from 0 to 255"))
		    ),
		 array("value"=>$customAlgorithm));
	
	$t5 = new Table();
	
	$t5->add(new TrFormElement( _T("Use policy"), $usePolicyComboBox),
		array("value" => $usePolicyIndex));
	
	$t5->add(new TrFormElement( _T("Name type"), $nameTypeComboBox),
		array("value" => $nameTypeIndex));
	
	$t5->add(new TrFormElement(
		    _T("Update mode for this zone"), 
		    new CheckboxTpl($this->pn("zoneupdate")),
		    array("tooltip" => _T("If checked, this key is authorized to attach, detach, and move zones by creating and deleting NS, glue A, and zone record(s).  If unchecked, the key can not authorize any update that would effect such records"))
		                  ),
		array("value" => $hasUpdate));

	$t5->add(new TrFormElement( 
		    _T("Strong update"), 
		    new CheckboxTpl($this->pn("strongupdate")),
		    array("tooltip" => _T("If checked, this key is authorized to add and delete records even if there are other records with the same owner name and class that are authenticated by a SIG signed with a different dynamic update KEY. If unchecked, the key can only authorize updates where any existing records of the same owner and class are authenticated by a SIG using the same key."))
		    ),
		array("value" => $hasStrongUpdate));
		
	$t5->add(new TrFormElement( 
		    _T("Unique name update"), 
		    new CheckboxTpl($this->pn("uniquenameupdate")),
		    array("tooltip" => _T("If checked, this key is authorized to add and update records for only a single owner name."))  
		    ),
		array("value" => $hasUniqueNameUpdate));
	
	$signatureDiv = new Div(array("id" => $this->pn("signaturediv")));
        $signatureDiv->setVisibility($hasSignature);
	
	$t6 = new Table();
	$t6->add(new TrFormElement(_T("Signature"), $signatureTextarea),
		array("value" => $this->values["signature"]));
		
	
	return array($this->stackedUi($t1), $this->stackedUi($protocolDiv,0), $this->stackedUi($t2,2),
		     $this->stackedUi($t3), $this->stackedUi($algorithmDiv,0), $this->stackedUi($t4,2),
		     $this->stackedUi($t5), $this->stackedUi($signatureDiv,0), $this->stackedUi($t6,2));
	
    }
Example #5
0
        exit;
    } elseif (count($ret) > 1) {
        new NotifyWidgetFailure($ret[1]);
    } else {
        $str = sprintf(_T("<strong>%s</strong> script wasn't %s", "imaging"), $script_name, $action);
        new NotifyWidgetFailure($str);
    }
}

// Display the script edit form
$f = new ValidatingForm();
$textareadesc = new TextareaTpl("postinstall_desc");
$textareadesc->setRows(2);
$textareadesc->setCols(50);

$textarea = new TextareaTpl("postinstall_value");
$textarea->setRows(15);
$textarea->setCols(50);
$f->push(new Table());
$disabled = (!$script['is_local'] && $task == 'edit');
$f->add(
    new TrFormElement("Script name", new InputTpl("postinstall_name")),
    array("value" => $name, "required" => True, 'disabled' => ($disabled?'disabled':''))
);
$f->add(
    new TrFormElement("Script description", $textareadesc),
    array("value" => $desc, "required" => True, 'disabled' => ($disabled?'disabled':''))
);
$f->add(
    new TrFormElement(_T("Script value"), $textarea),
    array("value" => $script['value'], "required" => True, 'disabled' => ($disabled?'disabled':''))