function print_rspec($obj, $pretty, $filterToAM) { $args = array_keys($obj); // How many AMs reported actual results $amc = 0; foreach ($args as $arg) { if (is_array($obj[$arg]) and array_key_exists('value', $obj[$arg]) and array_key_exists('code', $obj[$arg]) and is_array($obj[$arg]['code']) and array_key_exists('geni_code', $obj[$arg]['code']) and $obj[$arg]['code']['geni_code'] == 0) { $amc = $amc + 1; } } foreach ($args as $arg) { $arg_url = $arg; $am_id = am_id($arg_url); $arg_name = am_name($arg_url); $arg_urn = am_urn($arg_url); if (is_array($obj[$arg]) and array_key_exists('value', $obj[$arg])) { $xml = $obj[$arg]['value']; } else { $xml = ""; } $code = -1; if (is_array($obj[$arg]) and array_key_exists('code', $obj[$arg]) and is_array($obj[$arg]['code']) and array_key_exists('geni_code', $obj[$arg]['code'])) { $code = $obj[$arg]['code']['geni_code']; } if (is_array($obj[$arg]) and array_key_exists('output', $obj[$arg])) { $output = $obj[$arg]['output']; } else { if (!is_array($obj[$arg]) or !array_key_exists('code', $obj[$arg])) { $output = (string) $obj[$arg]; } else { $output = ""; } } /* If pretty, keep output clean by only printing RSpec for aggregates which have a slice (ie code!=12 or code !==2). Also don't print if no code was returned (ie code!=-1) because something catastrophic happened. -- unless there are no aggregates with resources, in which case we print the error. */ // error_log("Aggregate listresources code is " . $code); if (!(($code == -1 or $code == 12 or $code == 2) and $pretty)) { if ($pretty) { print "<div class='aggregate' id='aggT_" . $am_id . "'>Aggregate <b>" . $arg_name . "'s</b> Resources:</div>"; } else { print "<div class='aggregate' id='aggT_" . $am_id . "'>Aggregate <b>" . $arg_name . "'s</b> Raw Resources:</div>"; } print "<div class='resources' id='agg_" . $am_id . "'>"; if ($code == 0) { if ($pretty) { /* Parsed into a table */ print_rspec_pretty($xml, False, $filterToAM, $arg_urn, $am_id); } else { // /* As plain XML but with newlines after each block */ // $xml = str_replace(">", ">\n", $xml); print_xml($xml); } } else { if ($output == "") { $output = "[None. Return code: " . $code . "]"; } echo "<p>Returned: <i>{$output}</i></p>"; } print "</div>\n"; } } }
function print_xml($feed) { echo "\n"; foreach ($feed as $key => $val) { echo "<{$key}>"; if (is_array($val)) { print_xml($val); } else { echo str_replace('"', '"', str_replace('<', '<', str_replace('>', '>', str_replace('&', '&', $val)))); } echo "</{$key}>\n"; } }
function print_xml($xml) { foreach ($xml->children() as $person) { echo "person: " . $person['name'] . "\n"; foreach ($person->children() as $child) { echo " child: " . $child['name'] . "\n"; } } } function print_xml2($xml) { $persons = 2; for ($i = 0; $i < $persons; $i++) { echo "person: " . $xml->person[$i]['name'] . "\n"; $children = 2; for ($j = 0; $j < $children; $j++) { echo " child: " . $xml->person[$i]->child[$j]['name'] . "\n"; } } } echo "---11---\n"; print_xml(simplexml_load_string($xml)); echo "---12---\n"; print_xml(simplexml_load_string($xml1)); echo "---21---\n"; print_xml2(simplexml_load_string($xml)); echo "---22---\n"; print_xml2(simplexml_load_string($xml1)); ?> ===DONE===
function print_xmle($xml) { print_xml($xml); print "\n==<i>exit() called from print_rre</i>==\n"; print_rr(get_backtrace_callers(0), 'print_xmle called from '); exit; }
foreach ($player['weapons'] as $w) { $ary['weapons'][$w['uniqueid']] = $w; } foreach ($player['maps'] as $m) { $ary['maps'][$m['uniqueid']] = $m; } print_xml($ary); } elseif ($x == 'w') { // weapons // re-arrange the weapons list so the uniqueid of each weapon is a key. // weapon uniqueid's should never have any weird characters so this should be safe. $ary = array(); foreach ($player['weapons'] as $w) { $ary[$w['uniqueid']] = $w; } print_xml($ary); } $rolepager = ""; if ($ps->use_roles) { $rolepager = pagination(array('baseurl' => ps_url_wrapper(array('id' => $id, 'rlimit' => $rlimit, 'rsort' => $rsort, 'rorder' => $rorder)), 'total' => $player['totalroles'], 'start' => $rstart, 'startvar' => 'rstart', 'perpage' => $rlimit, 'urltail' => 'roles', 'separator' => ' ', 'next' => $cms->trans("Next"), 'prev' => $cms->trans("Previous"), 'pergroup' => 5)); } $victimpager = pagination(array('baseurl' => ps_url_wrapper(array('id' => $id, 'vlimit' => $vlimit, 'vsort' => $vsort, 'vorder' => $vorder)), 'total' => $player['totalvictims'], 'start' => $vstart, 'startvar' => 'vstart', 'perpage' => $vlimit, 'urltail' => 'victims', 'separator' => ' ', 'next' => $cms->trans("Next"), 'prev' => $cms->trans("Previous"), 'pergroup' => 5)); $mappager = pagination(array('baseurl' => ps_url_wrapper(array('id' => $id, 'mlimit' => $mlimit, 'msort' => $msort, 'morder' => $morder)), 'total' => $player['totalmaps'], 'start' => $mstart, 'startvar' => 'mstart', 'perpage' => $mlimit, 'urltail' => 'maps', 'separator' => ' ', 'next' => $cms->trans("Next"), 'prev' => $cms->trans("Previous"))); $sessionpager = pagination(array('baseurl' => ps_url_wrapper(array('id' => $id, 'slimit' => $slimit, 'ssort' => $ssort, 'sorder' => $sorder)), 'total' => $player['totalsessions'], 'start' => $sstart, 'startvar' => 'sstart', 'perpage' => $slimit, 'urltail' => 'sessions', 'separator' => ' ', 'next' => $cms->trans("Next"), 'prev' => $cms->trans("Previous"))); // build a dynamic table that plugins can use to add custom columns of data $wtable = $cms->new_table($player['weapons']); $wtable->if_no_data($cms->trans("No Weapons Found")); $wtable->attr('class', 'ps-table ps-weapon-table'); $wtable->sort_baseurl(array('id' => $id, '_anchor' => 'weapons')); $wtable->start_and_sort($wstart, $wsort, $worder, 'w'); $wtable->columns(array('uniqueid' => array('label' => $cms->trans("Weapon"), 'callback' => 'ps_table_weapon_link'), 'kills' => array('label' => $cms->trans("Kills"), 'modifier' => 'commify'), 'deaths' => array('label' => $cms->trans("Deaths"), 'modifier' => 'commify'), 'headshotkills' => array('label' => $cms->trans("HS"), 'modifier' => 'commify', 'tooltip' => $cms->trans("Headshot Kills")), 'headshotkillspct' => array('label' => $cms->trans("HS%"), 'modifier' => '%s%%', 'tooltip' => $cms->trans("Headshot Kills Percentage")), 'accuracy' => array('label' => $cms->trans("Acc"), 'modifier' => '%s%%', 'tooltip' => $cms->trans("Accuracy")), 'shotsperkill' => array('label' => $cms->trans("S:K"), 'tooltip' => $cms->trans("Shots Per Kill")), 'damage' => array('label' => $cms->trans("Dmg"), 'callback' => 'dmg', 'tooltip' => $cms->trans("Damage"))));
if ($templates_export == 'print') { $templates_filename = 'observium_templates_alert_'; if ($vars['entity_type']) { $templates_filename .= $vars['entity_type']; } else { $templates_filename .= 'all'; } $form = array('type' => 'rows', 'space' => '10px', 'url' => generate_url($vars)); // Filename $form['row'][0]['filename'] = array('type' => 'text', 'name' => 'Filename', 'value' => $templates_filename . '.xml', 'grid_xs' => 8, 'width' => '100%', 'placeholder' => TRUE); // Save as human formatted XML $form['row'][0]['formatted'] = array('type' => 'select', 'grid_xs' => 4, 'value' => class_exists('DOMDocument') ? 'yes' : 'no', 'values' => array('yes' => 'Formatted', 'no' => 'Unformatted')); // search button $form['row'][0]['saveas'] = array('type' => 'submit', 'name' => 'Save as..', 'icon' => 'icon-save', 'right' => TRUE, 'value' => 'yes'); print_form($form); print_xml($templates_xml); //r(xml_to_array($templates_xml)); } else { $templates_filename = $templates_export; download_as_file($templates_xml, $templates_filename, $vars); } unset($for_export, $templates_xml, $templates_export, $templates_filename, $form); } //foreach (dbFetchRows("SELECT * FROM `alert_table` LEFT JOIN `alert_table-state` ON `alert_table`.`alert_table_id` = `alert_table-state`.`alert_table_id`") as $entry) foreach (dbFetchRows("SELECT * FROM `alert_table`" . $where) as $entry) { $alert_table[$entry['alert_test_id']][$entry['alert_table_id']] = $entry; } echo generate_box_open(); echo '<table class="table table-condensed table-striped table-hover"> <thead> <tr>