本文整理汇总了PHP中parse_options_string函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_options_string函数的具体用法?PHP parse_options_string怎么用?PHP parse_options_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_options_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ws_delete
function ws_delete($window_name, $form = '')
{
global $base, $include, $conf, $self, $onadb;
// Check permissions
if (!(auth('host_del') or auth('subnet_del'))) {
$response = new xajaxResponse();
$response->addScript("alert('Permission denied!');");
return $response->getXML();
}
// If an array in a string was provided, build the array and store it in $form
$form = parse_options_string($form);
// Instantiate the xajaxResponse object
$response = new xajaxResponse();
$js = '';
// Run the module
list($status, $output) = run_module('tag_del', array('tag' => $form['id'], 'commit' => 'Y'));
// If the module returned an error code display a popup warning
if ($status) {
$js .= "alert('Delete failed. " . preg_replace('/[\\s\']+/', ' ', $self['error']) . "');";
} else {
// If there's (refresh) js, send it to the browser
if ($form['js']) {
$js .= $form['js'];
}
}
// Return an XML response
$response->addScript($js);
return $response->getXML();
}
示例2: ws_menu
function ws_menu($window_name, $form = '')
{
global $conf, $images;
$html = $js = '';
// If an array in a string was provided, build the array and store it in $form
$form = parse_options_string($form);
printmsg("DEBUG => Displaying tooltip: {$form['tooltip']}", 4);
$menuname = 'get_html_' . $form['menu_name'];
list($html, $js) = $menuname($form);
// Okay here's what we do:
// 1. Hide the tool-tip
// 2. Update it's content
// 3. Reposition it
// 4. Unhide it
$response = new xajaxResponse();
if ($html) {
$response->addScript("el('{$form['id']}').style.visibility = 'hidden';");
$response->addAssign($form['id'], "innerHTML", $html);
$response->addScript("wwTT_position('{$form['id']}'); el('{$form['id']}').style.visibility = 'visible';");
}
if ($js) {
$response->addScript($js);
}
return $response->getXML();
}
示例3: ws_ipcalcgui_submit
function ws_ipcalcgui_submit($window_name, $form = '')
{
global $conf, $self, $onadb, $tip_style;
global $font_family, $color, $style, $images;
$html = $js = '';
// If an array in a string was provided, build the array and store it in $form
$form = parse_options_string($form);
$text = '';
$ipinfo = ipcalc_info($form['ip'], $form['mask']);
// MP: I removed the following as they are tooooo large
//bin128: {$ipinfo['ip_bin128']}
//bin128: {$ipinfo['mask_bin128']}
// NOTE: yes it is annoying but I had to do the <br> thing due to windows
// not being able to handle the new lines via a standard <pre> statement.
// I went with this as it keeps things consistant between platforms. The pre is now a span
$text .= <<<EOL
<br />
<br />
Input: IP={$ipinfo['in_ip']} MASK={$ipinfo['in_mask']}<br />
<br />
IP={$ipinfo['in_ip']}<br />
Dotted: {$ipinfo['ip_dotted']}<br />
Numeric: {$ipinfo['ip_numeric']}<br />
binary: {$ipinfo['ip_binary']}<br />
ipv6: {$ipinfo['ip_ipv6']}<br />
ipv6gz: {$ipinfo['ip_ipv6gz']}<br />
flip: {$ipinfo['ip_flip']}<br />
<br />
MASK={$ipinfo['mask_dotted']}<br />
Dotted: {$ipinfo['mask_dotted']}<br />
Numeric: {$ipinfo['mask_numeric']}<br />
Cidr: /{$ipinfo['mask_cidr']}<br />
binary: {$ipinfo['mask_binary']}<br />
bin invert: {$ipinfo['mask_bin_invert']}<br />
ipv6: {$ipinfo['mask_ipv6']}<br />
ipv6gz: {$ipinfo['mask_ipv6gz']}<br />
flip: {$ipinfo['mask_flip']}<br />
IP invert: {$ipinfo['mask_dotted_invert']}<br />
<br />
The subnet your IP falls in is: {$ipinfo['truenet']}/{$ipinfo['mask_cidr']} ({$ipinfo['mask_dotted']})<br />
<br />
Total addresses using this mask: {$ipinfo['ip_total']}<br />
Usable addresses using this mask: {$ipinfo['ip_usable']}<br />
Last address using this mask: {$ipinfo['ip_last']}<br />
<br />
EOL;
$response = new xajaxResponse();
$response->addAssign('ipcalc_data', "innerHTML", $text);
return $response->getXML();
}
示例4: ws_process_alerts_submit
function ws_process_alerts_submit($window_name, $form = '')
{
global $conf, $self, $onadb, $tip_style;
global $font_family, $color, $style, $images;
$html = $js = '';
// If an array in a string was provided, build the array and store it in $form
$form = parse_options_string($form);
printmsg("DEBUG => Processing Alerts:", 5);
// FIXME: this code is called from html_desktop.inc.php.. however it is failing to process for some reason
// The intent of this code is to be called to display a "message waiting" type icon in the top menu bar.
// Check for messages that begin with SYS_ in the table_name_ref column
list($status, $rows, $msg) = db_get_record($onadb, 'messages', "table_name_ref LIKE 'SYS_%'");
if ($rows) {
$js .= "if (el('sys_alert')) {el('sys_alert').style.visibility = 'visible';}";
} else {
$js .= "if (el('sys_alert')) {el('sys_alert').style.visibility = 'hidden';}";
}
$response = new xajaxResponse();
if ($js) {
$response->addScript($js);
}
return $response->getXML();
}
示例5: ws_change_tab
function ws_change_tab($window_name, $form, $display_list = 1, $return_text = 0)
{
global $conf, $self;
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
$form_id = $form['form_id'];
$tab = $form['tab'];
// Instantiate the xajaxResponse object
$response = new xajaxResponse();
$js = '';
// Save the new tab in the session
$old_tab = $_SESSION['ona'][$form_id]['tab'];
$_SESSION['ona'][$form_id]['tab'] = $tab;
// remove any messages
$js .= "el('search_results_msg').innerHTML = '';";
// Make the old tab look inactive
$js .= "_el = el('{$form_id}_{$old_tab}_tab'); if (_el) _el.className = 'table-tab-inactive'; el('{$old_tab}_search').style.display = 'none';";
// Make the new tab look active
$js .= "el('{$form_id}_{$tab}_tab').className = 'table-tab-active'; el('{$tab}_search').style.display = 'block';";
// Set the "filter" to the correct value
$js .= "el('{$form_id}_filter').value = '{$_SESSION['ona'][$form_id][$tab]['filter']}';";
// Set the "page" and "tab" to the correct value
$js .= "el('{$form_id}_page').value = '{$_SESSION['ona'][$form_id][$tab]['page']}';";
$js .= "el('{$form_id}_tab').value = '{$tab}';";
// Put the cursor in the first field
$js .= "_el = el('{$tab}_field1'); if (_el) el('{$tab}_field1').focus();";
// Hide/show the filter overlay
$js .= "el('{$form_id}_filter_overlay').style.display = (el('{$form_id}_filter').value == '') ? 'inline' : 'none';";
// Tell the browser to ask for a new list of data
if ($display_list) {
$js .= "xajax_window_submit('list_{$tab}', xajax.getFormValues('{$form_id}'), 'display_list');";
}
// If they asked us to return text, we return the javascript text..
if ($return_text) {
return $js;
}
// Send an XML response to the window
$response->addAssign($_SESSION['ona'][$form_id]['content_id'], 'innerHTML', $conf['loading_icon']);
$response->addScript($js);
return $response->getXML();
}
示例6: ws_window_progressbar
function ws_window_progressbar($window_name, $form = '')
{
global $images;
// If an array in a string was provided, build the array and store it in $form
$form = parse_options_string($form);
$window_name = $form['name'];
$output = "<center>Working on the results, please wait<br><img src={$images}/loading.gif></center>";
$window['title'] = 'Processing...';
$window['js'] = "el('{$window_name}_extras').innerHTML='<br>';";
$build_commit_html = 0;
$commit_function = '';
include window_find_include('module_results');
return window_open("{$window_name}_results", $window);
}
示例7: ws_display
function ws_display($window_name, $form = '')
{
global $conf, $self, $ona;
global $images, $color, $style;
$html = '';
$js = '';
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
// Build $ip from $form['ip_block_start']
$form['ip_block_start'] = ip_complete($form['ip_block_start'], '0');
// Since we currently only display /24 (C) class networks, the
//GD Need to call ip_mangle() so we can use is_ipv4()
// last quad needs to be a .0.
$ip = ip_mangle($form['ip_block_start'], 'numeric');
if (is_ipv4($ip)) {
$end = '\\.\\d+$';
$replace_end_by = '.0';
$version = 4;
} else {
$end = ':[0-9A-F]{0,4}$';
// $replace_end_by = ':0000';
$replace_end_by = ':';
$version = 6;
}
$ip = $form['ip_block_start'] = preg_replace("/{$end}/", $replace_end_by, $form['ip_block_start']);
// Find out if $ip is valid
$ip = ip_mangle($ip, 'numeric');
if ($ip == -1) {
$js .= "alert('The IP address specified is invalid!');";
}
// Update History Title
$history = array_pop($_SESSION['ona']['work_space']['history']);
$js .= "xajax_window_submit('work_space', ' ', 'rewrite_history');";
if ($history['title'] == $window_name) {
$history['title'] = 'Map: ' . ip_mangle($ip, 'dotted');
array_push($_SESSION['ona']['work_space']['history'], $history);
}
// Create some javascript to refresh the current page
$refresh = htmlentities(str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']), ENT_QUOTES, $conf['php_charset']);
$refresh = "xajax_window_submit('work_space', '{$refresh}');";
// Define the window's inner html
$html .= <<<EOL
<div id="{$window_name}_content" style="padding: 2px 4px;">
<form id="block_search_form" onsubmit="el('zoom_block_button').onclick(); return false;">
<div id="{$window_name}_tools">
<b>IP Address</b>
<input type="hidden" id="{$window_name}_zoom" name="zoom" value="8">
<input id="{$window_name}_ip_block_start" name="{$window_name}_ip_block_start" value="{$form['ip_block_start']}" class="edit" type="text" size="15" />
<a id="zoom_block_button" title="Zoom block"
class="act"
onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'{$window_name}\\', \\'ip_block_start=>' + el('{$window_name}_ip_block_start').value + ',zoom=>' + el('{$window_name}_zoom').value + '\\', \\'display\\');');"
><img src="{$images}/silk/bullet_go.png" border="0"></a>
<br><br>
</div>
</form>
<div id="{$window_name}_portal">
<span id="{$window_name}_substrate"></span>
</div>
</div>
EOL;
// Position/size the portal ourselves
$js .= <<<EOL
var _el = el('{$window_name}_portal');
/* Now calculate where we will sit */
var my_height = el('work_space_content').offsetHeight - el('{$window_name}_tools').offsetHeight - 40;
var my_width = el('{$window_name}_tools').offsetWidth - 10;
/* Finally reposition/resize the window */
_el.style.position = 'relative';
_el.style.height = my_height + 'px';
EOL;
// Get javascript to setup the map portal
$js .= get_portal_js($window_name, $ip, $version);
//*** Send a fake mouseup event to draw the initial map view ***
$js .= "el('{$window_name}_portal').myonmouseup('fake event');";
// Insert the new html into the window
// Instantiate the xajaxResponse object
$response = new xajaxResponse();
// GDO need to use Big Int JS
$response->addIncludeScript('include/js/bignumber.js');
$response->addAssign("work_space_content", "innerHTML", $html);
if ($js) {
$response->addScript($js);
}
return $response->getXML();
}
示例8: ws_delete
function ws_delete($window_name, $form = '')
{
global $include, $conf, $self, $onadb;
// Check permissions
if (!auth('host_del')) {
$response = new xajaxResponse();
$response->addScript("alert('Permission denied!');");
return $response->getXML();
}
// If an array in a string was provided, build the array and store it in $form
$form = parse_options_string($form);
// Instantiate the xajaxResponse object
$response = new xajaxResponse();
$js = '';
// Run the module
list($status, $output) = run_module('host_del', array('host' => $form['host_id'], 'commit' => $form['commit']));
// If commit was N, display the confirmation dialog box
if (!$form['commit']) {
$build_commit_html = 1;
$commit_function = 'delete';
include window_find_include('module_results');
return window_open("{$window_name}_results", $window);
}
// If the module returned an error code display a popup warning
if ($status) {
$js .= "alert('Delete failed. " . preg_replace('/[\\s\']+/', ' ', $output) . "');";
} else {
if ($form['js']) {
$js .= $form['js'];
}
}
// usually js will refresh the window we got called from
// Return an XML response
$response->addScript($js);
return $response->getXML();
}
示例9: ws_display
function ws_display($window_name, $form = '')
{
global $conf, $self, $onadb;
global $images, $color, $style, $msgtype;
$html = '';
$js = '';
$debug_val = 3;
// used in the auth() calls to supress logging
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
// Load the host record
if ($form['interface_id']) {
list($status, $rows, $record) = ona_get_interface_record(array('id' => $form['interface_id']));
}
$record['ip_addr'] = ip_mangle($record['ip_addr'], 'dotted');
if ($status or !$rows) {
array_pop($_SESSION['ona']['work_space']['history']);
$html .= "<br><center><font color=\"red\"><b>Interface doesn't exist!</b></font></center>";
$response = new xajaxResponse();
$response->addAssign("work_space_content", "innerHTML", $html);
return $response->getXML();
}
// Update History Title (and tell the browser to re-draw the history div)
$history = array_pop($_SESSION['ona']['work_space']['history']);
$js .= "xajax_window_submit('work_space', ' ', 'rewrite_history');";
if ($history['title'] == $window_name) {
$history['title'] = $record['ip_addr'];
array_push($_SESSION['ona']['work_space']['history'], $history);
}
// Create some javascript to refresh the current page
$refresh = htmlentities(str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']), ENT_QUOTES, $conf['php_charset']);
$refresh = "xajax_window_submit('work_space', '{$refresh}');";
// Associated Host info
list($status, $rows, $host) = ona_get_host_record(array('id' => $record['host_id']), '');
// Subnet description
list($status, $rows, $subnet) = ona_get_subnet_record(array('id' => $interface['subnet_id']));
$record['subnet_name'] = $subnet['name'];
$record['ip_subnet_mask'] = ip_mangle($subnet['ip_mask'], 'dotted');
$record['ip_subnet_mask_cidr'] = ip_mangle($subnet['ip_mask'], 'cidr');
$style['content_box'] = <<<EOL
margin: 10px 20px;
padding: 2px 4px;
background-color: #FFFFFF;
vertical-align: top;
EOL;
$style['label_box'] = <<<EOL
font-weight: bold;
padding: 2px 4px;
border: solid 1px {$color['border']};
background-color: {$color['window_content_bg']};
EOL;
// Escape data for display in html
foreach (array_keys($record) as $key) {
$record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
}
$html .= <<<EOL
<!-- FORMATTING TABLE -->
<div style="{$style['content_box']}">
<table cellspacing="0" border="0" cellpadding="0"><tr>
<!-- START OF FIRST COLUMN OF SMALL BOXES -->
<td nowrap="true" valign="top" style="padding-right: 15px;">
<!-- HOST INFORMATION -->
<table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
<tr><td colspan="99" nowrap="true" style="{$style['label_box']}">
<!-- LABEL -->
<form id="form_interface_{$record['id']}"
><input type="hidden" name="interface_id" value="{$record['id']}"
><input type="hidden" name="js" value="{$refresh}"
></form>
EOL;
if (auth('host_modify', $debug_val)) {
$html .= <<<EOL
<a title="Edit interface. ID: {$record['id']}"
class="act"
onClick="xajax_window_submit('edit_interface', xajax.getFormValues('form_interface_{$record['id']}'), 'editor');"
><img src="{$images}/silk/page_edit.png" border="0"></a>
EOL;
}
if (auth('host_del', $debug_val)) {
$html .= <<<EOL
<a title="Delete interface. ID: {$record['id']}"
class="act"
onClick="var doit=confirm('Are you sure you want to delete this interface?');
if (doit == true)
xajax_window_submit('edit_interface', xajax.getFormValues('form_interface_{$record['id']}'), 'delete');"
><img src="{$images}/silk/delete.png" border="0"></a>
EOL;
}
$html .= <<<EOL
{$record['ip_addr']}
</td></tr>
<tr>
<td align="right" nowrap="true"><b>MAC Address</b> </td>
<td class="padding" align="left">{$record['mac_addr']} </td>
</tr>
//.........这里部分代码省略.........
示例10: ws_display_list
function ws_display_list($window_name, $form)
{
global $conf, $self, $onadb;
global $font_family, $color, $style, $images;
// Check permissions
if (!auth('advanced')) {
$response = new xajaxResponse();
$response->addScript("alert('Permission denied!');");
return $response->getXML();
}
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
// Find out what page we're on
$page = 1;
if ($form['page'] and is_numeric($form['page'])) {
$page = $form['page'];
}
$html = <<<EOL
<!-- Results Table -->
<table cellspacing="0" border="0" cellpadding="0" width="100%" class="list-box">
<!-- Table Header -->
<tr>
<td class="list-header" align="center" style="{$style['borderR']};">Role</td>
<td class="list-header" align="center"> </td>
</tr>
EOL;
$where = 'id > 0';
if (is_array($form) and $form['filter']) {
$where = 'name LIKE ' . $onadb->qstr('%' . $form['filter'] . '%');
}
// Offset for SQL query
$offset = $conf['search_results_per_page'] * ($page - 1);
if ($offset == 0) {
$offset = -1;
}
// Get list of elements
list($status, $rows, $records) = db_get_records($onadb, 'roles', $where, 'name', $conf['search_results_per_page'], $offset);
// If we got less than serach_results_per_page, add the current offset to it
// so that if we're on the last page $rows still has the right number in it.
if ($rows > 0 and $rows < $conf['search_results_per_page']) {
$rows += $conf['search_results_per_page'] * ($page - 1);
} else {
if ($rows >= $conf['search_results_per_page']) {
list($status, $rows, $tmp) = db_get_records($onadb, 'roles', $where, '', 0);
}
}
$count = $rows;
// Loop through and display the users
foreach ($records as $record) {
// Escape data for display in html
foreach (array_keys($record) as $key) {
$record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
}
$html .= <<<EOL
<tr onMouseOver="this.className='row-highlight'" onMouseOut="this.className='row-normal'">
<td class="list-row">
<a title="Edit role. id: {$record['id']}"
class="act"
onClick="xajax_window_submit('app_device_role_edit', '{$record['id']}', 'editor');"
>{$record['name']}</a>
</td>
<td align="right" class="list-row" nowrap="true">
<a title="Edit role. id: {$record['id']}"
class="act"
onClick="xajax_window_submit('app_device_role_edit', '{$record['id']}', 'editor');"
><img src="{$images}/silk/page_edit.png" border="0"></a>
<a title="Delete role. id: {$record['id']}"
class="act"
onClick="var doit=confirm('Are you sure you want to delete this role?');
if (doit == true)
xajax_window_submit('{$window_name}', '{$record['id']}', 'delete');"
><img src="{$images}/silk/delete.png" border="0"></a>
</td>
</tr>
EOL;
}
$html .= <<<EOL
</table>
<!-- Add a new record -->
<div class="act-box" style="padding: 2px 4px; border-top: 1px solid {$color['border']}; border-bottom: 1px solid {$color['border']};">
<!-- ADD role LINK -->
<a title="New role"
class="act"
onClick="xajax_window_submit('app_device_role_edit', ' ', 'editor');"
><img src="{$images}/silk/page_add.png" border="0"></a>
<a title="New role"
class="act"
onClick="xajax_window_submit('app_device_role_edit', ' ', 'editor');"
>Add role</a>
</div>
EOL;
//.........这里部分代码省略.........
示例11: ws_delete
function ws_delete($window_name, $form = '')
{
global $include, $conf, $self, $mysql, $onadb;
// Check permissions
if (!auth('advanced')) {
$response = new xajaxResponse();
$response->addScript("alert('Permission denied!');");
return $response->getXML();
}
// If an array in a string was provided, build the array and store it in $form
$form = parse_options_string($form);
// Instantiate the xajaxResponse object
$response = new xajaxResponse();
$js = '';
// Run the module
list($status, $output) = run_module('domain_del', array('domain' => $form['id'], 'commit' => 'Y'));
// If the module returned an error code display a popup warning
if ($status) {
$js .= "alert('Delete failed. " . preg_replace('/[\\s\']+/', ' ', $self['error']) . "');";
} else {
if ($form['js']) {
$js .= $form['js'];
}
}
// usually js will refresh the window we got called from
// Return an XML response
$response->addScript($js);
return $response->getXML();
}
示例12: ws_display
function ws_display($window_name, $form = '')
{
global $conf, $self, $onadb, $base;
global $images, $color, $style, $msgtype;
$html = '';
$js = '';
$debug_val = 3;
// used in the auth() calls to supress logging
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
// Load the host record
if ($form['device_id']) {
list($status, $rows, $record) = ona_get_device_record(array('id' => $form['device_id']));
} else {
if ($form['device']) {
// FIXME.. no find_device yet
list($status, $rows, $record) = ona_find_device($form['device']);
}
}
if ($status or !$rows) {
array_pop($_SESSION['ona']['work_space']['history']);
$html .= "<br><center><font color=\"red\"><b>Device doesn't exist!</b></font></center>";
$response = new xajaxResponse();
$response->addAssign("work_space_content", "innerHTML", $html);
return $response->getXML();
}
// Update History Title (and tell the browser to re-draw the history div)
$history = array_pop($_SESSION['ona']['work_space']['history']);
$js .= "xajax_window_submit('work_space', ' ', 'rewrite_history');";
if ($history['title'] == $window_name) {
$history['title'] = $record['name'];
array_push($_SESSION['ona']['work_space']['history'], $history);
}
// Create some javascript to refresh the current page
$refresh = htmlentities(str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']), ENT_QUOTES, $conf['php_charset']);
$refresh = "xajax_window_submit('work_space', '{$refresh}');";
// Interface (and find out how many there are)
list($status, $interfaces, $interface) = ona_get_interface_record(array('host_id' => $record['id']), '');
$record['ip_address'] = ip_mangle($interface['ip_addr'], 'dotted');
$interface_style = '';
if ($interfaces > 1) {
$interface_style = 'font-weight: bold;';
}
// Subnet description
list($status, $rows, $subnet) = ona_get_subnet_record(array('ID' => $interface['subnet_id']));
$record['subnet'] = $subnet['name'];
$record['ip_subnet_mask'] = ip_mangle($subnet['ip_mask'], 'dotted');
$record['ip_subnet_mask_cidr'] = ip_mangle($subnet['ip_mask'], 'cidr');
// Device Description
list($status, $rows, $device_type) = ona_get_device_type_record(array('id' => $record['device_type_id']));
list($status, $rows, $role) = ona_get_role_record(array('id' => $device_type['role_id']));
list($status, $rows, $model) = ona_get_model_record(array('id' => $device_type['model_id']));
list($status, $rows, $manufacturer) = ona_get_manufacturer_record(array('id' => $model['manufacturer_id']));
$record['devicefull'] = "{$manufacturer['name']}, {$model['name']} ({$role['name']})";
$record['device'] = str_replace('Unknown', '?', $record['devicefull']);
// Get location_number from the location_id
list($status, $rows, $location) = ona_get_location_record(array('id' => $record['location_id']));
// extra stuff to pass to ws_plugins
$extravars['refresh'] = $refresh;
$extravars['window_name'] = $window_name;
$style['content_box'] = <<<EOL
margin: 10px 20px;
padding: 2px 4px;
background-color: #FFFFFF;
vertical-align: top;
EOL;
$style['label_box'] = <<<EOL
font-weight: bold;
padding: 2px 4px;
border: solid 1px {$color['border']};
background-color: {$color['window_content_bg']};
EOL;
// Escape data for display in html
foreach (array_keys($record) as $key) {
$record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
}
// force 300px width to Notes field if the length is longer than 50 characters and put Notes at the top of the td
$notes_width = "";
$notes_valign = "";
if (strlen($record['notes']) > 50) {
$notes_width = ' style="width: 300px" ';
$notes_valign = ' valign="top" ';
}
$html .= <<<EOL
<!-- FORMATTING TABLE -->
<div style="{$style['content_box']}">
<table cellspacing="0" border="0" cellpadding="0"><tr>
<!-- START OF FIRST COLUMN OF SMALL BOXES -->
<td nowrap="true" valign="top" style="padding-right: 15px;">
<form id="form_device_{$record['id']}"
><input type="hidden" name="device_id" value="{$record['id']}"
><input type="hidden" name="js" value="{$refresh}"
></form>
EOL;
$wspl = workspace_plugin_loader('host_detail', $record, $extravars);
$html .= $wspl[0];
//.........这里部分代码省略.........
示例13: ws_display_list
function ws_display_list($window_name, $form = '')
{
global $conf, $self, $onadb;
global $images, $color, $style;
$html = '';
$js = '';
$debug_val = 3;
// used in the auth() calls to supress logging
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
// Find the "tab" we're on
$tab = $_SESSION['ona'][$form['form_id']]['tab'];
// Build js to refresh this list
$refresh = "xajax_window_submit('{$window_name}', xajax.getFormValues('{$form['form_id']}'), 'display_list');";
// If it's not a new query, load the previous query from the session
// into $form and save the current page and filter in the session.
// Also find/set the "page" we're viewing
$page = 1;
if ($form['page'] and is_numeric($form['page'])) {
$form = array_merge($form, (array) $_SESSION['ona'][$form['form_id']][$tab]['q']);
$_SESSION['ona'][$form['form_id']][$tab]['page'] = $page = $form['page'];
$_SESSION['ona'][$form['form_id']][$tab]['filter'] = $form['filter'];
}
// Calculate the SQL query offset (based on the page being displayed)
$offset = $conf['search_results_per_page'] * ($page - 1);
if ($offset == 0) {
$offset = -1;
}
// Search results go in here
$results = array();
$count = 0;
//
// FIND RESULT SET
//
// Start building the "where" clause for the sql query to find the subnets to display
$where = "";
$and = "";
// SERVER ID
if ($form['server_id']) {
$where .= $and . 'id IN (SELECT subnet_id
FROM dhcp_server_subnets
WHERE host_id = ' . $onadb->qstr($form['server_id']) . '
UNION
SELECT subnet_id
FROM dhcp_pools
WHERE dhcp_failover_group_id IN (SELECT id
FROM dhcp_failover_groups
WHERE primary_server_id = ' . $onadb->qstr($form['server_id']) . '
OR secondary_server_id = ' . $onadb->qstr($form['server_id']) . '))';
$and = " AND ";
}
// Do the SQL Query
$filter = '';
if ($form['filter']) {
// Subnet descriptions are always upper case
$form['filter'] = strtoupper($form['filter']);
$filter = $and . ' name LIKE ' . $onadb->qstr('%' . $form['filter'] . '%');
}
list($status, $rows, $results) = db_get_records($onadb, 'subnets', $where . $filter, 'ip_addr', $conf['search_results_per_page'], $offset);
// If we got less than serach_results_per_page, add the current offset to it
// so that if we're on the last page $rows still has the right number in it.
if ($rows > 0 and $rows < $conf['search_results_per_page']) {
$rows += $conf['search_results_per_page'] * ($page - 1);
} else {
if ($rows >= $conf['search_results_per_page']) {
list($status, $rows, $records) = db_get_records($onadb, 'subnets', $where . $filter, "", 0);
}
}
$count = $rows;
//
// *** BUILD HTML LIST ***
//
$html .= <<<EOL
<!-- Subnet Results -->
<table id="{$form['form_id']}_dhcp_server_list" class="list-box" cellspacing="0" border="0" cellpadding="0">
<!-- Table Header -->
<tr>
<td class="list-header" align="center" style="{$style['borderR']};">Name</td>
<td class="list-header" align="center" style="{$style['borderR']};">Subnet</td>
<td class="list-header" align="center" style="{$style['borderR']};">Usage</td>
<td class="list-header" align="center" style="{$style['borderR']};">Type</td>
<td class="list-header" align="center"> </td>
</tr>
EOL;
// Loop and display each record
foreach ($results as $record) {
// Get additional info about eash subnet record //
// Convert IP and Netmask to a presentable format
$record['ip_addr'] = ip_mangle($record['ip_addr'], 'dotted');
$record['ip_mask'] = ip_mangle($record['ip_mask'], 'dotted');
$record['ip_mask_cidr'] = ip_mangle($record['ip_mask'], 'cidr');
list($status, $rows, $type) = ona_get_subnet_type_record(array('id' => $record['subnet_type_id']));
$record['type'] = $type['display_name'];
// Calculate the percentage of the subnet that's used (total size - allocated hosts - dhcp pool size)
$usage_html = get_subnet_usage_html($record['id']);
// Escape data for display in html
foreach (array_keys($record) as $key) {
$record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
}
//.........这里部分代码省略.........
示例14: ws_display_list
function ws_display_list($window_name, $form = '')
{
global $conf, $self, $onadb;
global $images, $color, $style;
$html = '';
$js = '';
$debug_val = 3;
// used in the auth() calls to supress logging
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
// Find the "tab" we're on
$tab = $_SESSION['ona'][$form['form_id']]['tab'];
// Build js to refresh this list
$refresh = "xajax_window_submit('{$window_name}', xajax.getFormValues('{$form['form_id']}'), 'display_list');";
// If it's not a new query, load the previous query from the session
// into $form and save the current page and filter in the session.
// Also find/set the "page" we're viewing
$page = 1;
if ($form['page'] and is_numeric($form['page'])) {
$form = array_merge($form, (array) $_SESSION['ona'][$form['form_id']][$tab]['q']);
$_SESSION['ona'][$form['form_id']][$tab]['page'] = $page = $form['page'];
$_SESSION['ona'][$form['form_id']][$tab]['filter'] = $form['filter'];
}
// Calculate the SQL query offset (based on the page being displayed)
$offset = $conf['search_results_per_page'] * ($page - 1);
if ($offset == 0) {
$offset = -1;
}
// Search results go in here
$results = array();
$count = 0;
// Start building the "where" clause for the sql query to find the blocks to display
$where = "";
$and = "";
// DISPLAY ALL DOMAINS
if ($form['server_id']) {
$where .= $and . 'id IN (SELECT domain_id FROM dns_server_domains WHERE host_id = ' . $onadb->qstr($form['server_id']) . ')';
$and = " AND ";
}
// Do the SQL Query
$filter = '';
if ($form['filter']) {
$filter = $and . 'name LIKE ' . $oracle->qstr('%' . $form['filter'] . '%');
}
list($status, $rows, $results) = db_get_records($onadb, 'domains', $where . $filter, "name ASC", $conf['search_results_per_page'], $offset);
// If we got less than search_results_per_page, add the current offset to it
// so that if we're on the last page $rows still has the right number in it.
if ($rows > 0 and $rows < $conf['search_results_per_page']) {
$rows += $conf['search_results_per_page'] * ($page - 1);
} else {
if ($rows >= $conf['search_results_per_page']) {
list($status, $rows, $records) = db_get_records($onadb, 'domains', $where . $filter, "", 0);
}
}
$count = $rows;
$html .= <<<EOL
<!-- Domain List -->
<table id="{$form['form_id']}_domain_list" class="list-box" cellspacing="0" border="0" cellpadding="0">
<!-- Table Header -->
<tr>
<td class="list-header" align="center" style="{$style['borderR']};">Domain Name</td>
<td class="list-header" align="center" style="{$style['borderR']};">Parent Domain</td>
<td class="list-header" align="center" style="{$style['borderR']};">Role</td>
<td class="list-header" align="center"> </td>
</tr>
EOL;
// Loop and display each record
foreach ($results as $record) {
// Grab some info from the associated domain server record
list($status, $rows, $domain_server) = ona_get_dns_server_domain_record(array('domain_id' => $record['id'], 'host_id' => $form['server_id']));
list($status, $rows, $parent_zone) = ona_get_domain_record(array('id' => $record['parent_id']));
$record['role'] = strtoupper($domain_server['role']);
$record['parent_dns_zone_id'] = $parent_zone['id'];
$record['parent_dns_zone'] = $parent_zone['fqdn'];
if ($parent_zone['fqdn']) {
$parent_zone['fqdn'] = '.' . $parent_zone['fqdn'];
}
// Escape data for display in html
foreach (array_keys((array) $record) as $key) {
$record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
}
$html .= <<<EOL
<tr onMouseOver="this.className='row-highlight'" onMouseOut="this.className='row-normal'">
<td class="list-row" align="left">
<a title="View domain. ID: {$record['id']}"
class="domain"
onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_domain\\', \\'domain_id=>{$record['id']}\\', \\'display\\')');"
>{$record['name']}{$parent_zone['fqdn']}</a>
</td>
<td class="list-row" align="left">
<a title="View domain. ID: {$record['parent_dns_zone_id']}"
class="domain"
onClick="xajax_window_submit('work_space', 'xajax_window_submit(\\'display_zone\\', \\'zone_id=>{$record['parent_dns_zone_id']}\\', \\'display\\')');"
>{$record['parent_dns_zone']}</a>
</td>
<td class="list-row" align="left">
//.........这里部分代码省略.........
示例15: ws_display
function ws_display($window_name, $form = '')
{
global $conf, $self, $onadb;
global $images, $color, $style;
$html = '';
$js = '';
$debug_val = 3;
// used in the auth() calls to supress logging
// If the user supplied an array in a string, build the array and store it in $form
$form = parse_options_string($form);
// Load the host record
list($status, $rows, $record) = ona_get_block_record(array('id' => $form['block_id']));
if ($status or !$rows) {
array_pop($_SESSION['ona']['work_space']['history']);
$html .= "<br><center><font color=\"red\"><b>Block doesn't exist!</b></font></center>";
$response = new xajaxResponse();
$response->addAssign("work_space_content", "innerHTML", $html);
return $response->getXML();
}
// Update History Title
$history = array_pop($_SESSION['ona']['work_space']['history']);
$js .= "xajax_window_submit('work_space', ' ', 'rewrite_history');";
if ($history['title'] == $window_name) {
$history['title'] = $record['name'];
array_push($_SESSION['ona']['work_space']['history'], $history);
}
// Create some javascript to refresh the current page
$refresh = htmlentities(str_replace(array("'", '"'), array("\\'", '\\"'), $history['url']), ENT_QUOTES, $conf['php_charset']);
$refresh = "xajax_window_submit('work_space', '{$refresh}');";
$record['ip_addr_start'] = ip_mangle($record['ip_addr_start'], 'dotted');
$record['ip_addr_end'] = ip_mangle($record['ip_addr_end'], 'dotted');
$style['content_box'] = <<<EOL
margin: 10px 20px;
padding: 2px 4px;
background-color: #FFFFFF;
vertical-align: top;
EOL;
$style['label_box'] = <<<EOL
font-weight: bold;
padding: 2px 4px;
border: solid 1px {$color['border']};
background-color: {$color['window_content_bg']};
EOL;
// Escape data for display in html
foreach (array_keys($record) as $key) {
$record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf['php_charset']);
}
$html .= <<<EOL
<!-- FORMATTING TABLE -->
<div style="{$style['content_box']}">
<table cellspacing="0" border="0" cellpadding="0"><tr>
<!-- START OF FIRST COLUMN OF SMALL BOXES -->
<td nowrap="true" valign="top" style="padding-right: 15px;">
EOL;
// BLOCK INFORMATION
$html .= <<<EOL
<table width=100% cellspacing="0" border="0" cellpadding="0" style="margin-bottom: 8px;">
<tr><td colspan="99" nowrap="true" style="{$style['label_box']}">
<!-- LABEL -->
<form id="form_block_{$record['id']}"
><input type="hidden" name="block_id" value="{$record['id']}"
><input type="hidden" name="js" value="{$refresh}"
></form>
EOL;
if (auth('advanced', $debug_val)) {
$html .= <<<EOL
<a title="Edit block"
class="act"
onClick="xajax_window_submit('edit_block', xajax.getFormValues('form_block_{$record['id']}'), 'editor');"
><img src="{$images}/silk/page_edit.png" border="0"></a>
<a title="Delete block"
class="act"
onClick="var doit=confirm('Are you sure you want to delete this block?');
if (doit == true)
xajax_window_submit('edit_block', xajax.getFormValues('form_block_{$record['id']}'), 'delete');"
><img src="{$images}/silk/delete.png" border="0"></a>
EOL;
}
$html .= <<<EOL
{$record['name']}
<a href="?work_space={$window_name}&block_id={$record['id']}"><img title="Direct link to {$record['name']}" src="{$images}/silk/application_link.png" border="0"></a>
</td>
</tr>
<tr>
<td align="right" nowrap="true"><b>Name</b> </td>
<td class="padding" align="left">{$record['name']} </td>
</tr>
<tr>
<td align="right" nowrap="true"><b>IP start</b> </td>
<td class="padding" align="left">
{$record['ip_addr_start']}
</td>
</tr>
//.........这里部分代码省略.........