Location: PHPKode > projects > Network Configuration Store > NCS-3.0.2/wwwroot/Settings/Options.php
<?php

require_once('./CS_Includes.inc.php');

try {
	if (isset($_GET['submit']))
	{
		CS::Check($_POST['tftp_svc_name'], CSA_ISSET|CSA_THROW, 'Options: submit action with no tftp_svc_name');
		CS::Check($_POST['filter_enable'], CSA_ISSET|CSA_THROW, 'Options: submit action with no filter_enable');

		if (!CS::Check($_POST['max_threads'], CSA_THREADCNT))
			throw new CSThreadCountInvalidException();
		if (!CS::Check($_POST['tftp_path'], CSA_PATH))
			throw new CSPathInvalidException();
		if (!CS::Check($_POST['tftp_ipaddress'], CSA_IP4))
			throw new CSIPAddressException();

		$CS->getDb()->UpdateRecord('UPDATE `options` SET `url` = ?, `max_threads` = ?, `tftp_svc_name` = ?, `tftp_path` = ?, `tftp_ipaddress` = ?, '.
						'`filter_enable` = ?, `alert_smtp_server` = ?, `alert_source` = ?',
					array($_POST['url'], $_POST['max_threads'], $_POST['tftp_svc_name'], $_POST['tftp_path'], $_POST['tftp_ipaddress'],
						$_POST['filter_enable'], $_POST['alert_smtp_server'], $_POST['alert_source']));
		
		header('Location: Options.php?updated');
		exit();
	}
	else
	{
		$optionForm = new CSForm('Options.php?submit');
		$optionForm->AddButton(new CSFormControl(CSF_SUBMIT, array('value' => 'Submit')));
		$optionForm->AddButton(new CSFormControl(CSF_RESET, array('value' => 'Reset')));

		// options.url
		//
		$optionForm->AddControl('<strong>URL</strong><br />Specifies the URL of your NCS interface.',
				new CSFormControl(CSF_TEXTBOX, array('name' => 'url',
								'value' => $CS->GetOption('url'), 'size' => '40')));

		// options.max_threads
		//
		$optionForm->AddControl('<strong>Maximum Threads</strong><br />Specify how many simultanious threads should be used when polling.',
				new CSFormControl(CSF_TEXTBOX, array('name' => 'max_threads',
								'value' => $CS->GetOption('max_threads'), 'size' => '5')));

		// options.tftp_svc_name
		//
		$optionForm->AddControl('<strong>TFTP Service Name</strong><br />Specify the name of your Windows TFTP Service if NCS is to control it.',
				new CSFormControl(CSF_TEXTBOX, array('name' => 'tftp_svc_name',
								'value' => $CS->GetOption('tftp_svc_name'), 'size' => '40')));

		// options.tftp_path
		//
		$optionForm->AddControl('<strong>TFTP Path</strong><br />The root path of the TFTP server.',
				new CSFormControl(CSF_TEXTBOX, array('name' => 'tftp_path',
								'value' => $CS->GetOption('tftp_path'), 'size' => '40')));

		// options.tftp_ipaddress
		//
		$optionForm->AddControl('<strong>TFTP IP Address</strong><br />What IP address to transfer configuration files to.',
				new CSFormControl(CSF_TEXTBOX, array('name' => 'tftp_ipaddress',
								'value' => $CS->GetOption('tftp_ipaddress'), 'size' => '25')));

		// options.filter_enable
		//
		$s = $optionForm->AddControl('<strong>Enable Filters</strong><br />Filters potentially sensitive information out of configurations.',
				new CSFormControl(CSF_RADIO, array('name' => 'filter_enable', 'value' => 1,
								'id' => 'filter_enable_on', 'checked' => ($CS->GetOption('filter_enable') == TRUE))));
		$s->AddChild(new CSFormControl(CSF_LABEL, array('for' => 'filter_enable_on', 'text' => 'Enabled')));
		$s->AddChild(new CSFormControl(CSF_RADIO, array('name' => 'filter_enable', 'value' => 0,
								'id' => 'filter_enable_off', 'checked' => ($CS->GetOption('filter_enable') == FALSE))));
		$s->AddChild(new CSFormControl(CSF_LABEL, array('for' => 'filter_enable_off', 'text' => 'Disabled')));

		// options.alert_smtp_server
		//
		$optionForm->AddControl('<strong>SMTP Server</strong><br />Specify an SMTP Server for alert e-mails.',
				new CSFormControl(CSF_TEXTBOX, array('name' => 'alert_smtp_server',
								'value' => $CS->GetOption('alert_smtp_server'), 'size' => '40')));

		// options.alert_source
		//
		$optionForm->AddControl('<strong>Alert Source</strong><br />Specifies the sender address of alert e-mails.',
				new CSFormControl(CSF_TEXTBOX, array('name' => 'alert_source',
								'value' => $CS->GetOption('alert_source'), 'size' => '40')));
	}
}
catch (Exception $e) {
	CS::Abort($e);
}

CS::PrintHtmlHeader('General Options - Settings');

?>

<body id="Main">

	<h1>General Options</h1>
	<p>These parameters are general options for <?php echo CS_TITLE; ?>.</p>

	<?php if (isset($_GET['updated'])): ?>
		<p class="InfoMsg">Options successfully updated.</p>
	<?php endif; ?>

	<?php $optionForm->InsertHtml(); ?>

</body>
</html>
Return current item: Network Configuration Store