本文整理汇总了PHP中_rawurlencode函数的典型用法代码示例。如果您正苦于以下问题:PHP _rawurlencode函数的具体用法?PHP _rawurlencode怎么用?PHP _rawurlencode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_rawurlencode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: macro_PageHits
function macro_PageHits($formatter = "", $value)
{
global $DBInfo;
if (!$DBInfo->use_counter) {
return "[[PageHits is not activated. set \$use_counter=1; in the config.php]]";
}
$pages = $DBInfo->getPageLists();
sort($pages);
$hits = array();
foreach ($pages as $page) {
$hits[$page] = $DBInfo->counter->pageCounter($page);
}
if (!empty($value) and ($value == 'reverse' or $value[0] == 'r')) {
asort($hits);
} else {
arsort($hits);
}
$out = '';
while (list($name, $hit) = each($hits)) {
if (!$hit) {
$hit = 0;
}
$name = $formatter->link_tag(_rawurlencode($name), "", htmlspecialchars($name));
$out .= "<li>{$name} . . . . [{$hit}]</li>\n";
}
return "<ol>\n" . $out . "</ol>\n";
}
示例2: do_sitemap
function do_sitemap($formatter, $options)
{
global $DBInfo;
# get page list
if ($formater->group) {
$group_pages = $DBInfo->getLikePages($formater->group);
foreach ($group_pages as $page) {
$all_pages[] = str_replace($formatter->group, '', $page);
}
} else {
$all_pages = $DBInfo->getPageLists();
}
usort($all_pages, 'strcasecmp');
$items = '';
// empty string
# process page list
$zone = '+00:00';
foreach ($all_pages as $page) {
$url = qualifiedUrl($formatter->link_url(_rawurlencode($page)));
$p = new WikiPage($page);
$t = $p->mtime();
$date = gmdate("Y-m-d\\TH:i:s", $t) . $zone;
// W3C datetime format
$item = "<url>\n";
$item .= " <loc>" . $url . "</loc>\n";
$item .= " <lastmod>" . $date . "</lastmod>\n";
$item .= "</url>\n";
$items .= $item;
}
# process output
$out = $items;
if ($options['oe'] and strtolower($options['oe']) != $DBInfo->charset) {
$charset = $options['oe'];
if (function_exists('iconv')) {
$new = iconv($DBInfo->charset, $charset, $items);
if (!$new) {
$charset = $DBInfo->charset;
}
if ($new) {
$out = $new;
}
}
} else {
$charset = $DBInfo->charset;
}
$head = <<<HEAD
<?xml version="1.0" encoding="{$charset}"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9"
url="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
HEAD;
$foot = <<<FOOT
</urlset>
FOOT;
# output
header("Content-Type: text/xml");
print $head . $out . $foot;
}
示例3: do_Clip
function do_Clip($formatter, $options)
{
global $DBInfo;
$enable_replace = 1;
$keyname = $DBInfo->_getPageKey($options['page']);
$_dir = str_replace("./", '', $DBInfo->upload_dir . '/' . $keyname);
// support hashed upload dir
if (!is_dir($_dir) and !empty($DBInfo->use_hashed_upload_dir)) {
$prefix = get_hashed_prefix($keyname);
$_dir = str_replace('./', '', $DBInfo->upload_dir . '/' . $prefix . $keyname);
}
$pagename = _urlencode($options['page']);
$name = $options['value'];
if (!$name) {
$title = _("Fatal error !");
$formatter->send_header("Status: 406 Not Acceptable", $options);
$formatter->send_title($title, "", $options);
print "<h2>" . _("No filename given") . "</h2>";
$formatter->send_footer("", $options);
return;
}
$pngname = _rawurlencode($name);
//$imgpath="$_dir/$pngname";
$imgpath = "{$pngname}";
$imgparam = '';
if (file_exists($_dir . '/' . $imgpath . '.png')) {
$url = qualifiedUrl($DBInfo->url_prefix . '/' . $_dir . '/' . $imgpath . '.png');
$imgparam = "<param name='image' value='{$url}' />";
}
$png_url = "{$imgpath}.png";
$formatter->send_header("", $options);
$formatter->send_title(_("Clipboard"), "", $options);
$prefix = $formatter->prefix;
$now = time();
$url_exit = $formatter->link_url($pagename, "?ts={$now}");
$url_save = $formatter->link_url($pagename, "?action=draw");
$url_help = $formatter->link_url("ClipMacro");
$pubpath = $DBInfo->url_prefix . "/applets/ClipPlugin";
print "<h2>" . _("Cut & Paste a Clipboard Image") . "</h2>\n";
print <<<APPLET
<applet code="clip"
archive="clip.jar" codebase="{$pubpath}"
width='200' height='200' align="center">
<param name="pngpath" value="{$png_url}" />
<param name="savepath" value="{$url_save}" />
<param name="viewpath" value="{$url_exit}" />
<param name="compress" value="5" />
{$imgparam}
<b>NOTE:</b> You need a Java enabled browser to edit the drawing example.
</applet><br />
APPLET;
$formatter->send_footer("", $options);
return;
}
示例4: macro_PageHits
function macro_PageHits($formatter, $value = '', $params = array())
{
global $DBInfo, $Config;
if (empty($Config['use_counter'])) {
return "[[PageHits is not activated. set \$use_counter=1; in the config.php]]";
}
$perpage = !empty($Config['counter_per_page']) ? intval($Config['counter_per_page']) : 200;
if (!empty($params['p'])) {
$p = intval($params['p']);
} else {
$p = 0;
}
if ($p < 0) {
$p = 0;
}
$hits = $DBInfo->counter->getPageHits($perpage, $p);
if (!empty($value) and ($value == 'reverse' or $value[0] == 'r')) {
asort($hits);
} else {
arsort($hits);
}
$out = '';
while (list($name, $hit) = each($hits)) {
if (!$hit) {
$hit = 0;
}
$name = $formatter->link_tag(_rawurlencode($name), "", _html_escape($name));
$out .= "<li>{$name} . . . . [{$hit}]</li>\n";
}
$start = $perpage * $p;
if ($start > 0) {
$start = ' start="' . $start . '"';
} else {
$start = '';
}
$out = "<ol{$start}>\n" . $out . "</ol>\n";
$prev = '';
$next = '';
if ($p > 0) {
$prev = $formatter->link_tag($formatter->page->urlname, '?action=pagehits&p=' . ($p - 1), _("« Prev"));
}
$p++;
if (count($hits) >= 0) {
$next = $formatter->link_tag($formatter->page->urlname, '?action=pagehits&p=' . $p, _("Next »"));
}
return $out . $prev . ' ' . $next;
}
示例5: macro_JME
function macro_JME($formatter, $value)
{
global $DBInfo;
$jar = 'JME.zip';
// XXX
$jar = 'JME.jar';
$draw_dir = str_replace('./', '', $DBInfo->upload_dir . '/JME');
if (!file_exists($draw_dir)) {
umask(00);
mkdir($draw_dir, 0777);
}
$name = $value;
$urlname = _rawurlencode($value);
$molname = $name . ".mol";
$now = time();
$url = $formatter->link_url($formatter->page->name, "?action=jme&value={$urlname}&now={$now}");
if (!file_exists($draw_dir . "/{$molname}")) {
if ($name) {
return "<a href='{$url}'>" . sprintf(_("Draw a new molecule '%s'"), $name) . "</a>";
} else {
return "<a href='{$url}'>" . _("Draw a new molecule") . "</a>";
}
}
$fp = fopen($draw_dir . '/' . $molname, 'r');
if ($fp) {
$mol = '';
while (!feof($fp)) {
$mol .= fgets($fp, 2048);
}
fclose($fp);
$mol = str_replace("\r\n", "|\n", $mol);
}
$pubpath = $DBInfo->url_prefix . "/applets/JMEPlugin";
$mol = _html_escape($mol);
return <<<APPLET
<applet code="JME.class" name="JME" codebase="{$pubpath}" archive="{$jar}">
<param name="options" value="depict" />
<param name="mol" value="{$mol}" />
You have to enable Java and JavaScript on your machine !
</applet>
APPLET;
}
示例6: macro_Referer
function macro_Referer($formatter, $value, &$options)
{
global $DBInfo;
if (empty($DBInfo->use_referer)) {
return "[[Referer macro: {$use_referer} is off.]]";
}
$referer_log_filename = $DBInfo->cache_dir . "/referer/referer.log";
if ($value !== true) {
// [[referer]] or ?action=referer
$needle = $formatter->page->urlname;
} else {
// [[referer()]]
unset($needle);
}
if ($needle and false) {
// so slow XXX
$handle = fopen($referer_log_filename, 'r');
if (!is_resource($handle)) {
return '';
}
$logs = array();
while (!feof($handle)) {
$line = fgets($handle);
list(, $pagename, ) = explode("\t", $line);
if ($pagename == $needle) {
$logs[] = $line;
}
if ($count > 100) {
break;
}
$count++;
}
fclose($handle);
$logs = array_reverse($logs);
} else {
$number_of_lines = 200;
// XXX
$logs = tail_file($referer_log_filename, $number_of_lines);
}
$log = array();
$counter = 10;
// XXX
$count = 0;
foreach ($logs as $line) {
list(, $pagename, ) = explode("\t", $line);
if (strcmp($pagename, $needle) == 0) {
$log[] = $line;
}
if ($count > $counter) {
break;
}
$count++;
}
$logs = $log;
$tz_offset = $formatter->tz_offset;
$length = sizeof($logs);
for ($c = 0; $c < $length; $c++) {
$fields = explode("\t", $logs[$c]);
$fields[0] = date("Y-m-d H:i:s", strtotime($fields[0]) + $tz_offset);
$fields[1] = $formatter->link_tag(_rawurlencode($fields[1]), "", urldecode($fields[1]));
$found = '';
if (ereg("[?&][pqQ](uery)?=([^&]+)&?", $fields[2], $regs)) {
$check = strpos($regs[2], '%');
# is it urlecnoded ?
if ($check !== false) {
$found = urldecode($regs[2]);
if (function_exists('iconv')) {
$test = false;
if (strcasecmp('utf-8', $DBInfo->charset) != 0) {
$test = iconv('utf-8', $DBInfo->charset, $found);
if ($test !== false) {
$found = $test;
}
}
if ($test === false and !empty($DBInfo->url_encodings)) {
$cs = explode(',', $DBInfo->url_encodings);
foreach ($cs as $c) {
$test = @iconv($c, $DBInfo->charset, $found);
if ($test !== false) {
$found = $test;
break;
}
}
}
}
} else {
$found = $regs[2];
}
}
$fields[2] = (!empty($found) ? "[ {$found} ] " : '') . "<a href='{$fields['2']}'>" . urldecode($fields[2]) . "</a>";
if (isset($needle)) {
unset($fields[1]);
}
$logs[$c] = "<td class='date' style='width:20%'>" . implode("</td><td>", $fields) . "<td>";
}
$ret = '';
if ($length > 0) {
$ret = "\n<table>";
$ret .= "<caption>" . _("Referer history") . "</caption>";
$ret .= "<tr>";
//.........这里部分代码省略.........
示例7: macro_PageList
function macro_PageList($formatter, $arg = "", $options = array())
{
global $DBInfo;
$offset = '';
if (!is_numeric($options['offset']) or $options['offset'] <= 0) {
unset($options['offet']);
} else {
$offset = $options['offset'];
}
preg_match("/([^,]*)(\\s*,\\s*)?(.*)?\$/", $arg, $match);
if ($match[1] == 'date') {
$options['date'] = 1;
$arg = '';
} else {
if ($match) {
$arg = $match[1];
$opts = array();
if ($match[3]) {
$opts = explode(",", $match[3]);
}
if (in_array('date', $opts)) {
$options['date'] = 1;
}
if (in_array('dir', $opts)) {
$options['dir'] = 1;
}
if (in_array('subdir', $opts)) {
$options['subdir'] = 1;
}
if (in_array('info', $opts)) {
$options['info'] = 1;
} else {
if ($arg and (in_array('metawiki', $opts) or in_array('m', $opts))) {
$options['metawiki'] = 1;
}
}
}
}
$upper = '';
if (!empty($options['subdir'])) {
if (($p = strrpos($formatter->page->name, '/')) !== false) {
$upper = substr($formatter->page->name, 0, $p);
}
$needle = _preg_search_escape($formatter->page->name);
$needle = '^' . $needle . '\\/';
} else {
if (!empty($options['rawre'])) {
$needle = $arg;
} else {
$needle = _preg_search_escape($arg);
}
}
$test = @preg_match("/{$needle}/", "", $match);
if ($test === false) {
# show error message
return "[[PageList(<font color='red'>Invalid \"{$arg}\"</font>)]]";
}
$ret = array();
$options['ret'] =& $ret;
$options['offset'] = $offset;
if (!empty($options['date'])) {
$tz_offset =& $formatter->tz_offset;
$all_pages = $DBInfo->getPageLists($options);
} else {
if (!empty($options['metawiki'])) {
$all_pages = $DBInfo->metadb->getLikePages($needle);
} else {
$all_pages = $DBInfo->getLikePages($needle);
}
}
$hits = array();
$out = '';
if (!empty($options['date']) and !is_numeric($k = key($all_pages)) and is_numeric($all_pages[$k])) {
if ($needle) {
while (list($pagename, $mtime) = @each($all_pages)) {
preg_match("/{$needle}/", $pagename, $matches);
if ($matches) {
$hits[$pagename] = $mtime;
}
}
} else {
$hits = $all_pages;
}
arsort($hits);
while (list($pagename, $mtime) = @each($hits)) {
$out .= '<li>' . $formatter->link_tag(_rawurlencode($pagename), "", _html_escape($pagename)) . ". . . . [" . gmdate("Y-m-d", $mtime + $tz_offset) . "]</li>\n";
}
$out = "<ol>\n" . $out . "</ol>\n";
} else {
foreach ($all_pages as $page) {
preg_match("/{$needle}/", $page, $matches);
if ($matches) {
$hits[] = $page;
}
}
sort($hits);
if (!empty($options['dir']) or !empty($options['subdir'])) {
$dirs = array();
$files = array();
if ($options['subdir']) {
//.........这里部分代码省略.........
示例8: macro_Rss
function macro_Rss($formatter, $value)
{
global $DBInfo;
$xml_parser = xml_parser_create();
$rss_parser = new WikiRSSParser();
xml_set_object($xml_parser, $rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$key = _rawurlencode($value);
$cache = new Cache_text("rss");
# reflash rss each 7200 second (60*60*2)
if (!$cache->exists($key) or time() > $cache->mtime($key) + 7200) {
$fp = @fopen("{$value}", "r");
if (!$fp) {
return "[[RSS(ERR: not a valid URL! {$value})]]";
}
while ($data = fread($fp, 4096)) {
$xml_data .= $data;
}
fclose($fp);
$cache->update($key, $xml_data);
} else {
$xml_data = $cache->fetch($key);
}
list($line, $dummy) = explode("\n", $xml_data, 2);
preg_match("/\\sencoding=?(\"|')([^'\"]+)/", $line, $match);
if ($match) {
$charset = strtoupper($match[2]);
} else {
$charset = 'UTF-8';
}
# override $charset for php5
if ((int) phpversion() >= 5) {
$charset = 'UTF-8';
}
ob_start();
$ret = xml_parse($xml_parser, $xml_data);
if (!$ret) {
return sprintf("[[RSS(XML error: %s at line %d)]]", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser));
}
$out = ob_get_contents();
ob_end_clean();
xml_parser_free($xml_parser);
# if (strtolower(str_replace("-","",$options['oe'])) == 'euckr')
if (function_exists('iconv') and strtoupper($DBInfo->charset) != $charset) {
$new = iconv($charset, $DBInfo->charset, $out);
if ($new !== false) {
return $new;
}
}
return $out;
}
示例9: do_atom
function do_atom($formatter, $options)
{
global $DBInfo;
global $_release;
define('ATOM_DEFAULT_DAYS', 7);
$days = $DBInfo->rc_days ? $DBInfo->rc_days : ATOM_DEFAULT_DAYS;
$options['quick'] = 1;
if ($options['c']) {
$options['items'] = $options['c'];
}
$lines = $DBInfo->editlog_raw_lines($days, $options);
$time_current = time();
# $secs_per_day= 60*60*24;
# $days_to_show= 30;
# $time_cutoff= $time_current - ($days_to_show * $secs_per_day);
$URL = qualifiedURL($formatter->prefix);
$img_url = qualifiedURL($DBInfo->logo_img);
$url = qualifiedUrl($formatter->link_url($DBInfo->frontpage));
$surl = qualifiedUrl($formatter->link_url($options['page'] . '?action=atom'));
$channel = <<<CHANNEL
<title>{$DBInfo->sitename}</title>
<link href="{$url}"></link>
<link rel="self" type="application/atom+xml" href="{$surl}" />
<subtitle>RecentChanges at {$DBInfo->sitename}</subtitle>
<generator version="{$_release}">MoniWiki Atom feeder</generator>
CHANNEL;
$items = "";
$ratchet_day = FALSE;
if (!$lines) {
$lines = array();
}
foreach ($lines as $line) {
$parts = explode("\t", $line);
$page_name = $DBInfo->keyToPagename($parts[0]);
$addr = $parts[1];
$ed_time = $parts[2];
$user = $parts[4];
$user_uri = '';
if ($DBInfo->hasPage($user)) {
$user_uri = $formatter->link_url(_rawurlencode($user), "", $user);
$user_uri = '<uri>' . $user_uri . '</uri>';
}
$log = _stripslashes($parts[5]);
$act = rtrim($parts[6]);
$url = qualifiedUrl($formatter->link_url(_rawurlencode($page_name)));
$diff_url = qualifiedUrl($formatter->link_url(_rawurlencode($page_name), '?action=diff'));
$extra = "<br /><a href='{$diff_url}'>" . _("show changes") . "</a>\n";
$content = '';
if (!$DBInfo->hasPage($page_name)) {
$status = 'deleted';
$content = "<content type='html'><a href='{$url}'>{$page_name}</a> is deleted</content>\n";
} else {
$status = 'updated';
if ($options['diffs']) {
$p = new WikiPage($page_name);
$f = new Formatter($p);
$options['raw'] = 1;
$options['nomsg'] = 1;
$html = $f->macro_repl('Diff', '', $options);
if (!$html) {
ob_start();
$f->send_page('', array('fixpath' => 1));
#$f->send_page('');
$html = ob_get_contents();
ob_end_clean();
$extra = '';
}
$content = " <content type='xhtml'><div xmlns='http://www.w3.org/1999/xhtml'>{$html}</content>\n";
} else {
if ($log) {
$html = str_replace('&', '&', $log);
$content = "<content type='text'>" . $html . "</content>\n";
} else {
$content = "<content type='text'>updated</content>\n";
}
}
}
$zone = '+00:00';
$date = gmdate("Y-m-d\\TH:i:s", $ed_time) . $zone;
if (!isset($updated)) {
$updated = $date;
}
#$datetag = gmdate("YmdHis",$ed_time);
$valid_page_name = str_replace('&', '&', $page_name);
$items .= "<entry>\n";
$items .= " <title>{$valid_page_name}</title>\n";
$items .= " <link href='{$url}'></link>\n";
$items .= ' ' . $content;
$items .= " <author><name>{$user}</name>{$user_uri}</author>\n";
$items .= " <updated>{$date}</updated>\n";
$items .= " <contributor><name>{$user}</name>{$user_uri}</contributor>\n";
$items .= "</entry>\n";
}
$updated = " <updated>{$updated}</updated>\n";
$new = "";
if ($options['oe'] and strtolower($options['oe']) != $DBInfo->charset) {
$charset = $options['oe'];
if (function_exists('iconv')) {
$out = $head . $channel . $items . $form;
//.........这里部分代码省略.........
示例10: macro_BBS
function macro_BBS($formatter, $value, $options = array())
{
global $DBInfo;
# set defaults
$ncount = 20;
# default
$bname = $formatter->page->name;
$nid = '';
# check options
$args = preg_split('/\\s*,\\s*/', $value);
foreach ($args as $arg) {
$arg = trim($arg);
if ($arg == '') {
continue;
}
if (($p = strpos($arg, '=')) !== false) {
$k = substr($arg, 0, $p);
$v = substr($arg, $p + 1);
if ($k == 'no') {
$nid = $v;
} else {
if ($k == 'mode') {
$options['mode'] = $v;
}
}
} else {
if ($arg == 'mode') {
} else {
if ($arg == (int) $arg . "") {
$ncount = $arg;
} else {
$bname = $arg;
}
}
}
}
$bpage = _rawurlencode($bname);
$nid = $nid ? $nid : $_GET['no'];
$nids = array();
if ($nid) {
$nids = preg_split('/\\s+/', $nid);
rsort($nids);
}
$options['p'] = $_GET['p'] > 0 ? $_GET['p'] : 1;
$options['c'] = $ncount != 20 ? $ncount : '';
$options['p'] = intval($options['p']);
# is it exists ?
if (!$DBInfo->hasPage($bname)) {
return _("This bbs does not exists yet. Please save this page first");
}
# load a config file
$conf0 = array();
if (file_exists('config/bbs.' . $bname . '.php')) {
$confname = 'bbs.' . $bname . '.php';
$conf0 = _load_php_vars('config/bbs.default.php');
} else {
$confname = 'bbs.default.php';
}
$conf = _load_php_vars('config/' . $confname);
$conf = array_merge($conf0, $conf);
$conf['data_dir'] = $DBInfo->data_dir;
$conf['dba_type'] = $DBInfo->dba_type;
if (!$DBInfo->use_bbs) {
return '[[BBS]]';
}
#if ($DBInfo->use_bbs == 1);
#if ($DBInfo->use_bbs == 2);
$MyBBS = new BBS_text($bname, $conf);
// XXX
if ($options['new'] and $MyBBS) {
return $MyBBS;
}
if (!$MyBBS) {
return '[[BBS]]';
}
$msg = '';
$btn = array();
# read messages
#
$formatter->baserule[] = "/^((-=)+-?\$)/";
$formatter->baserule[] = "/ comment #(\\d+)\\b/";
$formatter->baserule[] = "/\\[reply (\\d+)\\]/";
$formatter->baserepl[] = "<hr />\n";
$formatter->baserepl[] = " comment [#c\\1 #\\1]";
$formatter->baserepl[] = "<script type='text/javascript'><!--\n" . " addReplyLink(\\1); //--></script>";
$msg = '';
$narticle = sizeof($nids);
$js = '';
if ($nid and $narticle == 1 and $options['mode'] == 'simple') {
$nid = $nids[0];
if (!$nid or !$MyBBS->hasPage($nid)) {
return '[[BBS(error)]]';
}
include_once 'lib/metadata.php';
$body = $MyBBS->getPage($nid);
list($metas, $body) = _get_metadata($body);
$img = '';
if ($MyBBS->use_attach) {
$cache = new Cache_text('attachments');
$attachs = $cache->fetch($MyBBS->bbsname . ':' . $nid);
//.........这里部分代码省略.........
示例11: macro_UploadedFiles
//.........这里部分代码省略.........
txtarea.value += tagOpen + myText + tagClose + " ";
txtarea.focus();
}
}
/*]]>*/
</script>
EOS;
}
if (!empty($DBInfo->download_action)) {
$mydownload = $DBInfo->download_action;
} else {
$mydownload = 'download';
}
$checkbox = 'checkbox';
$needle = "//";
if (!empty($options['download']) || !empty($DBInfo->force_download)) {
$force_download = 1;
if (!empty($options['download'])) {
$mydownload = $options['download'];
}
}
if (!empty($options['needle'])) {
$needle = '@' . $options['needle'] . '@i';
}
if (!empty($options['checkbox'])) {
$checkbox = $options['checkbox'];
}
if (!in_array('UploadFile', $formatter->actions)) {
$formatter->actions[] = 'UploadFile';
}
if ($value and $value != 'UploadFile') {
$key = $DBInfo->pageToKeyname($value);
//if ($force_download or $key != $value)
$down_prefix = $formatter->link_url(_rawurlencode($value), "?action={$mydownload}&value=");
$dir = $DBInfo->upload_dir . "/{$key}";
} else {
$value = $formatter->page->urlname;
$key = $DBInfo->pageToKeyname($formatter->page->name);
//if ($force_download or $key != $formatter->page->name)
$down_prefix = $formatter->link_url($formatter->page->urlname, "?action={$mydownload}&value=");
$dir = $DBInfo->upload_dir . "/{$key}";
}
// support hashed upload_dir
if (!is_dir($dir) and !empty($DBInfo->use_hashed_upload_dir)) {
$dir = $DBInfo->upload_dir . '/' . get_hashed_prefix($key) . $key;
}
if (!empty($force_download) or $key != $value) {
$prefix = $down_prefix;
}
if (!empty($formatter->preview) and $formatter->page->name == $value) {
$opener = '';
} else {
$opener = $value . ':';
}
if ($value != 'UploadFile' and file_exists($dir)) {
$handle = opendir($dir);
} else {
$key = '';
$value = 'UploadFile';
if (!$force_download) {
$prefix .= $prefix ? '/' : '';
}
$dir = $DBInfo->upload_dir;
$handle = opendir($dir);
$opener = '/';
}
示例12: macro_RecentChanges
//.........这里部分代码省略.........
$via_proxy = false;
if (($p = strpos($addr, ',')) !== false) {
// user via Proxy
$via_proxy = true;
$real_ip = substr($addr, 0, $p);
$log_proxy = '<span class="via-proxy">' . $real_ip . '</span>';
$log = isset($log[0]) ? $log_proxy . ' ' . $log : $log_proxy;
$dum = explode(',', $addr);
$addr = array_pop($dum);
}
// if ($ed_time < $time_cutoff)
// break;
$group = '';
if ($formatter->group) {
if (!preg_match("/^({$formatter->group})(.*)\$/", $page_name, $match)) {
continue;
}
$title = $match[2];
} else {
if (!empty($formatter->use_group) and ($p = strpos($page_name, '~')) !== false) {
$title = substr($page_name, $p + 1);
$group = ' (' . substr($page_name, 0, $p) . ')';
} else {
$title = $page_name;
}
}
if (!empty($changed_time_fmt)) {
if (empty($timesago)) {
$date = gmdate($changed_time_fmt, $ed_time + $tz_offset);
} else {
$date = _timesago($ed_time, 'Y-m-d', $tz_offset);
}
}
$pageurl = _rawurlencode($page_name);
// get title
$title0 = get_title($title) . $group;
$title0 = _html_escape($title0);
if ($rctype == 'list') {
$attr = '';
} else {
$attr = " id='title-{$ii}'";
}
if (!empty($strimwidth) and strlen(get_title($title)) > $strimwidth and function_exists('mb_strimwidth')) {
$title0 = mb_strimwidth($title0, 0, $strimwidth, '...', $DBInfo->charset);
}
$attr .= ' title="' . $title0 . '"';
$title = $formatter->link_tag($pageurl, "", $title0, $target . $attr);
// simple list format
if ($rctype == 'list') {
if (empty($logs[$page_key])) {
$logs[$page_key] = array();
}
$logs[$page_key][$day] = 1;
if (!$DBInfo->hasPage($page_name)) {
$act = 'DELETE';
$title = '<strike>' . $title . '</strike>';
}
$list[$page_name] = array($title, $date, $ed_time, $act);
continue;
}
// print $ed_time."/".$bookmark."//";
$diff = '';
$updated = '';
if ($act == 'UPLOAD') {
$icon = $formatter->link_tag($pageurl, "?action=uploadedfiles", $formatter->icon['attach']);
} else {
示例13: macro_Rss
function macro_Rss($formatter, $value)
{
global $DBInfo;
$rsscache = new Cache_text('rsscache');
$key = _rawurlencode($value);
// rss TTL = 7200 sec (60*60*2)
if (!$formatter->refresh && $rsscache->exists($key) && time() < $rsscache->mtime($key) + 7200) {
return $rsscache->fetch($key);
}
if ($rsscache->exists($key . '.lock')) {
return '';
}
$args = explode(',', $value);
// first arg assumed to be a date fmt arg
$date_fmt = '';
$title_width = 0;
if (count($args) > 1) {
if (preg_match("/^[\\s\\/\\-:aABdDFgGhHiIjmMOrSTY\\[\\]]+\$/", $args[0])) {
$date_fmt = array_shift($args);
}
if (is_numeric($args[0])) {
$title_width = array_shift($args);
// too small or too big
if ($title_width < 10 || $title_width > 40) {
$title_width = 0;
}
}
$value = implode(',', $args);
}
$cache = new Cache_text("rssxml");
# reflash rss each 7200 second (60*60*2)
if (!$cache->exists($key) or time() > $cache->mtime($key) + 7200) {
$fp = @fopen("{$value}", "r");
if (!$fp) {
return "[[RSS(ERR: not a valid URL! {$value})]]";
}
while ($data = fread($fp, 4096)) {
$xml_data .= $data;
}
fclose($fp);
$cache->update($key, $xml_data);
} else {
$xml_data = $cache->fetch($key);
}
// detect charset
$charset = 'UTF-8';
list($line, $dummy) = explode("\n", $xml_data, 2);
preg_match("/\\sencoding=?(\"|')([^'\"]+)/", $line, $match);
if ($match) {
$charset = strtoupper($match[2]);
}
// override $charset for php5
if ((int) phpversion() >= 5) {
$charset = 'UTF-8';
}
$xml_parser = xml_parser_create();
$rss_parser = new WikiRSSParser($charset);
if (!empty($date_fmt)) {
$rss_parser->setDateFormat($date_fmt);
}
if (!empty($title_width)) {
$rss_parser->setTitleWidth($title_width);
}
xml_set_object($xml_parser, $rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
ob_start();
$ret = xml_parse($xml_parser, $xml_data);
if (!$ret) {
return sprintf("[[RSS(XML error: %s at line %d)]]", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser));
}
$out = ob_get_contents();
ob_end_clean();
xml_parser_free($xml_parser);
$out = '<ul class="rss">' . $out . '</ul>';
# if (strtolower(str_replace("-","",$options['oe'])) == 'euckr')
if (function_exists('iconv') and strtoupper($DBInfo->charset) != $charset) {
$new = iconv($charset, $DBInfo->charset, $out);
if ($new !== false) {
return $new;
}
}
$rsscache->remove($key . '.lock');
$rsscache->update($key, $out);
return $out;
}
示例14: macro_FastSearch
//.........这里部分代码省略.........
$searchkeys = $sc->fetch($word);
} else {
$searchkeys = $DB->_search($word);
$sc->update($word, $searchkeys);
}
$new_words = array_merge($new_words, $searchkeys);
$new_words = array_merge($idx, $DB->_search($word));
}
$words = array_merge($words, $new_words);
//
$word = array_shift($words);
$idx = $DB->_fetchValues($word);
foreach ($words as $word) {
$ids = $DB->_fetchValues($word);
// FIXME
foreach ($ids as $id) {
$idx[] = $id;
}
}
$init_hits = array_count_values($idx);
// initial hits
$idx = array_keys($init_hits);
//arsort($idx);
$all_count = $DBInfo->getCounter();
$pages = array();
$hits = array();
foreach ($idx as $id) {
$key = $DB->_fetch($id);
$pages[$id] = $key;
$hits['_' . $key] = $init_hits[$id];
// HACK. prefix '_' to numerical named pages
}
$DB->close();
if (!empty($_GET['q']) and isset($_GET['q'][0])) {
return $pages;
}
$context = !empty($opts['context']) ? $opts['context'] : 0;
$limit = isset($opts['limit'][0]) ? $opts['limit'] : $default_limit;
$contexts = array();
if ($arena == 'fullsearch' || $arena == 'pagelinks') {
$idx = 1;
foreach ($pages as $page_name) {
if (!empty($limit) and $idx > $limit) {
break;
}
$p = new WikiPage($page_name);
if (!$p->exists()) {
continue;
}
$body = $p->_get_raw_body();
$count = preg_match_all($pattern, $body, $matches);
// more precisely count matches
if ($context) {
# search matching contexts
$contexts[$page_name] = find_needle($body, $needle, '', $context);
}
$hits['_' . $page_name] = $count;
// XXX hack for numerical named pages
$idx++;
}
}
//uasort($hits, 'strcasecmp');
//$order = 0;
//uasort($hits, create_function('$a, $b', 'return ' . ($order ? '' : '-') . '(strcasecmp($a, $b));'));
$name = array_keys($hits);
array_multisort($hits, SORT_DESC, $name, SORT_ASC);
$opts['hits'] = $hits;
$opts['hit'] = count($hits);
$opts['all'] = $all_count;
if (!empty($opts['call'])) {
return $hits;
}
$out = "<!-- RESULT LIST START -->";
// for search plugin
$out .= "<ul>";
$idx = 1;
while (list($page_name, $count) = each($hits)) {
$page_name = substr($page_name, 1);
$out .= '<!-- RESULT ITEM START -->';
// for search plugin
$out .= '<li>' . $formatter->link_tag(_rawurlencode($page_name), "?action=highlight&value=" . _urlencode($needle), $page_name, "tabindex='{$idx}'");
if ($count > 1) {
$out .= ' . . . . ' . sprintf($count == 1 ? _("%d match") : _("%d matches"), $count);
if (!empty($contexts[$page_name])) {
$out .= $contexts[$page_name];
}
}
$out .= "</li>\n";
$out .= '<!-- RESULT ITEM END -->';
// for search plugin
$idx++;
if (!empty($limit) and $idx > $limit) {
break;
}
}
$out .= "</ul>\n";
$out .= "<!-- RESULT LIST END -->";
// for search plugin
return $out;
}
示例15: macro_LikePages
//.........这里部分代码省略.........
}
if ($end) {
foreach ($pages as $page) {
preg_match("/{$end}\$/", $page, $matches);
if ($matches) {
$ends[$page] = 1;
}
}
}
if (!empty($DBInfo->use_similar_text)) {
$len = strlen($value);
$ii = 0;
foreach ($pages as $page) {
$ii++;
$match = similar_text($value, $page) / min($len, strlen($page));
if ($match > 0.9 && empty($starts[$page]) && empty($ends[$page])) {
$likes[$page] = $match;
}
}
} else {
if ($start || $end) {
if ($start and $end) {
$similar_re = "{$start}|{$end}";
} else {
if ($start) {
$similar_re = $start;
} else {
$similar_re = $end;
}
}
if (!empty($words)) {
$similar_re .= '|' . implode('|', $words);
}
foreach ($pages as $page) {
preg_match("/({$similar_re})/i", $page, $matches);
if ($matches && empty($starts[$page]) && empty($ends[$page])) {
$likes[$page] = 1;
}
}
}
}
$idx = 1;
$hits = 0;
$out = "";
if ($likes) {
ksort($likes);
$out .= "<h3>" . _("These pages share a similar word...") . "</h3>";
$out .= "<ol>\n";
foreach ($likes as $pagename => $i) {
$pageurl = _rawurlencode($pagename);
$pagetext = htmlspecialchars(urldecode($pagename));
$out .= '<li>' . $formatter->link_tag($pageurl, "", $pagetext, "tabindex='{$idx}'") . "</li>\n";
$idx++;
}
$out .= "</ol>\n";
$hits = count($likes);
}
if ($starts || $ends) {
ksort($starts);
$out .= "<h3>" . _("These pages share an initial or final title word...") . "</h3>";
$out .= "<table border='0' width='100%'><tr><td width='50%' valign='top'>\n<ol>\n";
while (list($pagename, $i) = each($starts)) {
$pageurl = _rawurlencode($pagename);
$pagetext = htmlspecialchars(urldecode($pagename));
$out .= '<li>' . $formatter->link_tag($pageurl, "", $pagetext, "tabindex='{$idx}'") . "</li>\n";
$idx++;
}
$out .= "</ol></td>\n";
ksort($ends);
$out .= "<td width='50%' valign='top'><ol>\n";
while (list($pagename, $i) = each($ends)) {
$pageurl = _rawurlencode($pagename);
$pagetext = htmlspecialchars(urldecode($pagename));
$out .= '<li>' . $formatter->link_tag($pageurl, "", $pagetext, "tabindex='{$idx}'") . "</li>\n";
$idx++;
}
$out .= "</ol>\n</td></tr></table>\n";
$hits += count($starts) + count($ends);
}
if (empty($hits)) {
$out .= "<h3>" . _("No similar pages found") . "</h3>";
}
$opts['msg'] = sprintf(_("Like \"%s\""), $value);
while (empty($metawiki)) {
if (empty($DBInfo->metadb)) {
$DBInfo->initMetaDB();
}
if (empty($DBInfo->metadb) or empty($DBInfo->shared_metadb)) {
break;
}
$opts['extra'] = _("If you can't find this page, ");
if (empty($hits) and empty($metawiki) and !empty($DBInfo->metadb)) {
$opts['extra'] = _("You are strongly recommened to find it in MetaWikis. ");
}
$tag = $formatter->link_to("?action=LikePages&metawiki=1", _("Search all MetaWikis"));
$opts['extra'] .= "{$tag} (" . _("Slow Slow") . ")<br />";
break;
}
return $out;
}