function write_xml($subtags, $label = NULL) { if (NULL !== $subtags) { if (NULL !== $label) { $attributes = ''; if (is_array($subtags) && isset($subtags['_attr']) && is_array($subtags['_attr'])) { foreach ($subtags['_attr'] as $attribute => $value) { $attributes .= " {$attribute}=\"" . xml_escape($value) . '"'; } } echo '<' . $label . $attributes . '>'; } if (is_array($subtags)) { foreach ($subtags as $tag => $content) { if (substr($tag, 0, 1) == '_') { continue; } if (is_numeric($tag)) { if (is_array($content) && isset($content['_tag'])) { $tag = $content['_tag']; } else { $tag = NULL; } } write_xml($content, $tag); } } else { echo xml_escape($subtags); } if (NULL !== $label) { echo '</' . $label . '>'; } } }
function get_userreg_30_days() { global $db; $xml = "userreg_30_days.xml"; if (!check_xml($xml)) { $datelist = array(); for ($i = 30; $i >= 1; $i--) { $day = date("m/d", strtotime("-{$i} day")); $datelist[$day] = 0; } $result = $db->query("SELECT * FROM " . table('members_log') . " WHERE log_type=1000 and log_addtime>" . strtotime("-30 day")); while ($row = $db->fetch_array($result)) { $date = date("m/d", $row['log_addtime']); $datelist[$date]++; } write_xml($xml, $datelist); } }
} if ($id == 0) { echo 'FAIL||You cannot delete the master user once created. If you no longer want multi-user mode enabled, you can turn it off normally.'; exit; } unset($users->user[$idx]); if (write_xml('users', $users)) { echo "PASS||{$id}"; } break; case 'LOGOUT': session_unset(); session_destroy(); echo 'FAIL||LOGIN'; break; default: if ((string) $opts['MU']->value == 'on' && check_login($_SESSION, $users)) { $user = get_user($_SESSION['uid'], $users); $user->notes = stripslashes($_REQUEST['data']); if (write_xml('users', $users)) { echo 'PASS'; } exit; } $str = "var phpDumpNotes = " . stripslashes($_REQUEST['data']) . ";"; if (!@file_put_contents('../js/notes.js', $str)) { echo "FAIL||No write access to notes file."; } else { echo "PASS"; } }
?> ?xml version="1.0" encoding="UTF-8"?><?php ?> <irc><?php if (isset($Errors) && is_array($Errors)) { foreach ($Errors as $error) { write_xml($error, 'error'); } } if (isset($Messages) && is_array($Messages)) { foreach ($Messages as $message) { echo '<msg type="' . xml_escape($message['type']) . '"'; if (isset($message['highlight'])) { echo ' highlight="1"'; } echo '>'; if (isset($message['received'])) { echo '<time>' . date('H:i', $message['received']) . '</time>'; } foreach ($simple_fields as $field) { if (isset($message[$field])) { write_xml($message[$field], $field); } } ?> </msg><?php } } ?> </irc>
function write_worksheet($in, $file, $options = array()) { $ext = pathinfo($file, PATHINFO_EXTENSION); if (isset($options["write"])) { if ($ext != "" && $options["write"] != $ext) { fputs(STDERR, "Warning: Ignored the extension to adopt {$options["write"]}.\n"); } $ext = $options["write"]; } switch (strtolower($ext)) { case "raw": $out = fopen($file, "w"); while (($line = fgets($in)) !== false) { fputs($out, $line); } fclose($out); break; case "csv": $options["delimiter"] = ","; write_csv($in, $file, $options); break; case "tsv": $options["delimiter"] = "\t"; write_csv($in, $file, $options); break; case "xlsx": write_excel($in, $file, $options); break; case "json": write_json($in, $file, $options); break; case "yml": case "yaml": write_yaml($in, $file, $options); break; case "xml": write_xml($in, $file, $options); break; case "htm": case "html": // a write only converter write_html($in, $file, $options); break; case "tex": // a write only converter write_tex($in, $file, $options); break; case "sql": // a write only converter write_sql($in, $file, $options); break; default: fputs(STDERR, "Error[{$ext}]: No writer is available.\n"); break; } return; }
/** * Write XML as per Associative Array * * @param object $xml XMLWriter Object * @param array $data Associative Data Array */ function write_xml(\XMLWriter $xml, $data) { foreach ($data as $key => $value) { if (is_array($value)) { $xml->startElement($key); write_xml($xml, $value); $xml->endElement(); continue; } $xml->writeElement($key, $value); } }
extract_zip($args['zip'], $src . DIRECTORY_SEPARATOR, false); // Move into position // (both src and dest. target dirs must NOT contain trailing slash) recursive_copy($src . '/connectors', $target . basename($data['connectors_path'])); recursive_copy($src . '/core', rtrim($data['core_path'], DIRECTORY_SEPARATOR)); // <-- special since it doesn't have to be in docroot recursive_copy($src . '/manager', $target . basename($data['mgr_path'])); recursive_copy($src . '/setup', $target . 'setup'); recursive_copy($src . '/index.php', $target . 'index.php'); recursive_copy($src . '/config.core.php', $target . 'config.core.php'); recursive_copy($src . '/ht.access', $target . 'ht.access'); // cleanup // Write the data to the XML file so MODX can read it write_xml($xml, $xml_path); if (!$args['config'] && $args['installmode'] != 'upgrade') { write_xml($xml, 'config.xml'); // backup for later } // TODO: Test Database Connection? // if upgrade, do some magic if ($args['installmode'] == 'upgrade') { prepare_modx_upgrade($data); } else { // Check that core/cache exists and is writeable, etc. etc. prepare_modx_new($data); } //------------------------------------------------------------------------------ // ! Run Setup //------------------------------------------------------------------------------ // Via command line, we'd do this: // php setup/index.php --installmode=new --config=/path/to/config.xml
echo "\n"; ?> <errors><?php echo "\n"; foreach ($errors as $error) { echo '<error'; if (isset($error['class'])) { echo ' class="' . xml_escape($error['class']) . '"'; } if (isset($error['code'])) { echo ' code="' . xml_escape($error['code']) . '"'; } if (isset($error['retry'])) { echo ' retry="' . ($error['retry'] ? '1' : '0') . '"'; } echo '>'; if (isset($error['text'])) { echo '<text>' . xml_escape($error['text']) . '</text>'; } if (isset($error['html'])) { echo '<html>' . xml_escape($error['html']) . '</html>'; } echo '</error>' . "\n"; } ?> </errors><?php echo "\n"; write_xml($xmlContent, $xmlContent['_tag']); ?> </theyorker>
$value->modified = 0; print_r($value); sleep(1); } try { if (@$value->regextern->pvt_modified == false) { $value->regextern->pvt_modified = 0; } } catch (Exception $e) { $value->regextern->pvt_modified = 0; print_r($value); sleep(1); } do_log("Extension:" . $value->regextern->extension . " (" . $value->regextern->pvt_modified . " >= " . $value->regextern->pvt_changed . " && " . $value->active . " == true && " . $value->state . " == 'in_service')", 'd', __FILE__, __FUNCTION__, __LINE__); if ($value->regextern->pvt_modified >= $value->regextern->pvt_changed && $value->active == true && ($value->state == 'in_service' || $value->state == 'reseved')) { write_xml($value); $reload = true; } elseif ($value->modified >= $value->changed && $value->active == false) { remove_xml($value); exec('fs_cli -x "sofia profile sipinterface_1 killgw ' . substr($value->id, 1) . '"', $ret); gateway_removed($value->id); $reload = true; } } if ($reload) { exec('fs_cli -x "sofia profile sipinterface_1 rescan reloadxml"', $gat); $reload = false; do_log("Reload Gateways:" . var_dump($gat), 'v', __FILE__, __FUNCTION__, __LINE__); } if ($checkit == false) { do_log("min check wait: {$ncheck} > " . $dbconfig['phone_numbers']->default->extern_numbermanager_min_check, 'v', 'info', __FILE__, __FUNCTION__, __LINE__);
<?php /** * @file views/general/xml.php * @brief Generic XML view. * @author James Hogan (jh559) * * @param $RootTag The root tag information. * @param $HeaderContentType null/string */ if (!isset($HeaderContentType) || null == $HeaderContentType) { $HeaderContentType = 'text/xml'; } header("content-type: {$HeaderContentType}"); $this->load->helper('xml'); ?> <<?php ?> ?xml version="1.0" encoding="UTF-8"?><?php write_xml($RootTag, $RootTag['_tag']);