function print_namespace($item, $name, $fullkey, $islast) {
global $config, $redistypes, $server, $redis;
// Is this also a key and not just a namespace?
if (isset($item['__phpredisadmin__'])) {
// Unset it so we won't loop over it when printing this namespace.
unset($item['__phpredisadmin__']);
$type = $redis->type($fullkey);
if (!isset($redistypes[$type])) {
return;
}
$type = $redistypes[$type];
$class = array();
$len = false;
if (isset($_GET['key']) && ($fullkey == $_GET['key'])) {
$class[] = 'current';
}
if ($islast) {
$class[] = 'last';
}
// Get the number of items in the key.
if (!isset($config['faster']) || !$config['faster']) {
switch ($type) {
case 'hash':
$len = $redis->hLen($fullkey);
break;
case 'list':
$len = $redis->lSize($fullkey);
break;
case 'set':
// This is currently the only way to do this, this can be slow since we need to retrieve all keys
$len = count($redis->sMembers($fullkey));
break;
case 'zset':
// This is currently the only way to do this, this can be slow since we need to retrieve all keys
$len = count($redis->zRange($fullkey, 0, -1));
break;
}
}
?>
<li<?php echo empty($class) ? '' : ' class="'.implode(' ', $class).'"'?>>
<a href="?view&s=<?php echo $server['id']?>&key=<?php echo urlencode($fullkey)?>"><?php echo format_html($name)?><?php if ($len !== false) { ?><span class="info">(<?php echo $len?>)</span><?php } ?></a>
</li>
<?php
}
// Does this namespace also contain subkeys?
if (count($item) > 0) {
?>
<li class="folder<?php echo empty($fullkey) ? '' : ' collapsed'?><?php echo $islast ? ' last' : ''?>"><div class="icon"><?php echo format_html($name)?> <span class="info">(<?php echo count($item)?>)</span></div>
<ul>
<?php
$l = count($item);
foreach ($item as $childname => $childitem) {
// $fullkey will be empty on the first call.
if (empty($fullkey)) {
$childfullkey = $childname;
} else {
$childfullkey = $fullkey.$config['seperator'].$childname;
}
print_namespace($childitem, $childname, $childfullkey, (--$l == 0));
}
?>
</ul>
</li>
<?php
}
}
function output_update_html($token, $status, $done, $cancelled, $failed, $err, $errs, $errs_admin = false, $ajax = false)
{
global $fups_url_cancel, $fups_url_notify_email_address, $fups_url_run;
if ($err) {
?>
<div class="fups_error"><?php
echo format_html($err);
?>
</div>
<?php
return;
}
?>
<h3>Status</h3>
<div id="fups_div_status">
<?php
echo htmlspecialchars($status);
?>
</div>
<?php
if ($done) {
$output_info = json_decode(file_get_contents(make_output_info_filename($token)), true);
if ($output_info == null) {
?>
<p>We are sorry, but an unexpected error occurred. The scraping process completed, and the output was created, however we were unable to decode the list of output files. Please feel free to <a href="<?php
echo FUPS_CONTACT_URL;
?>
">contact me</a> for help with accessing your output files, quoting token "<?php
echo $token;
?>
".</p>
<?php
} else {
?>
<p>Success! Your posts were retrieved and the output is ready. The following output files are available:</p>
<table style="border-collapse: collapse;">
<tr><th style="border: 1px solid black;">Description</th><th style="border: 1px solid black;">View/download file (opens in a new window)</th><th style="border: 1px solid black;">File size</th></tr>
<?php
foreach ($output_info as $opv) {
?>
<tr><td style="border: 1px solid black;"><?php
echo $opv['description'];
?>
</td><td style="border: 1px solid black;"><a target="_blank" href="<?php
echo $opv['url'];
?>
">View/download file</a></td><td style="border: 1px solid black;"><?php
echo number_format($opv['size']) . ' bytes';
?>
</td></tr>
<?php
}
?>
</table>
<p>If you're wondering what to do next, here are some possible steps:</p>
<ol>
<li>Click on the "View/download file" link beside the HTML file which is sorted according to your preference. This will open up a new window/tab for that file. Switch to this window/tab if necessary, and then save the page, e.g. in Firefox click the "File" menu option and under that click "Save Page As". Select the directory/folder and filename you wish to save this output as (remember this location for the next step).</li>
<li>Start up a word processor such as LibreOffice/OpenOffice or Microsoft Word. Open up in that word processor the HTML file that you saved in the previous step, e.g. click the "File" menu option and under that click "Open", then select the file you saved in the previous step. You are now free to edit the file as you like. You can now (if you so desire) save the file in a friendlier format than HTML, a format such as your editor's default format, e.g. in LibreOffice, click the "File" menu option and then click "Save As" or "Export", and choose the format you desire.</li>
</ol>
<?php
show_delete($token, true);
}
} else {
if ($cancelled) {
?>
<p>Cancelled by your request.</p>
<?php
show_delete($token, false);
} else {
if ($failed) {
?>
<p>The script appears to have exited due to an error; the error message is shown below. I have been notified of this error by email; if you would like me to get back to you if/when I have fixed the error, then please enter your email address into the following box and press the button to notify me of it.</p>
<div>
<form method="post" action="<?php
echo $fups_url_notify_email_address;
?>
">
<input type="hidden" name="token" value="<?php
echo $token;
?>
" />
<label for="email_address.id">Your contact email address:</label><br />
<input type="text" name="email_address" id="email_address.id" /><br />
<label for="message.id">Any message you'd like to include (leaving this blank is fine):</label><br />
<textarea rows="5" cols="80" name="message" id="message.id"></textarea><br />
<input type="submit" value="Notify the FUPS maintainer" />
</form>
</div>
<p>Alternatively, feel free to retry or to <a href="<?php
echo FUPS_CONTACT_URL;
?>
">contact me</a> manually about this error, quoting your run token of "<?php
echo $token;
?>
//.........这里部分代码省略.........
开发者ID:ezeql,项目名称:fups,代码行数:101,代码来源:common.php
示例10: format_post_bits
<?php
include "../include.php";
if ($posting) {
format_post_bits("isAdmin,temporary");
$_POST["description"] = format_html($_POST["description"]);
db_enter("bulletin_board_topics", "title description isAdmin temporary");
//db_query("UPDATE bulletin_board_topics SET threadDate = GETDATE() WHERE id = " . $_GET["id"]); don't do this
syndicateBulletinBoard();
url_change("topic.php?id=" . $_GET["id"]);
}
drawTop();
$t = db_grab("SELECT title, description, isAdmin, temporary, createdBy FROM bulletin_board_topics WHERE id = " . $_GET["id"]);
$form = new intranet_form();
if ($isAdmin) {
$form->addUser("createdBy", "Posted By", $t["createdBy"], false, true);
$form->addCheckbox("isAdmin", "Admin Post?", $t["isAdmin"], "(check if yes)", true);
}
$form->addCheckbox("temporary", "Lifespan", $t['temporary'], "Check Box to Delete Post After 30 Days");
$form->addRow("itext", "Subject", "title", $t["title"], "", true);
$form->addRow("textarea", "Message", "description", $t["description"], "", true);
$form->addRow("submit", "edit topic");
$form->draw("Edit Bulletin Board Topic");
drawBottom();
function format_post_html($fieldnames)
{
//takes a comma-separated list of POST keys and formats the html in them
global $_POST;
$fields = array_post_fields($fieldnames);
foreach ($fields as $field) {
$return = format_html($_POST[$field]);
$_POST[$field] = empty($return) ? "NULL" : "'" . $_POST[$field] . "'";
}
}
请发表评论