<?php
// PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: func.php,v 1.73 2006/05/15 16:41:39 teanan Exp $
+// $Id: func.php,v 1.104 2011/01/25 15:01:01 henoheno Exp $
// Copyright (C)
// 2002-2006 PukiWiki Developers Team
// 2001-2002 Originally written by yu-ji
return FALSE;
} else {
$fp = fopen(get_filename($page), 'rb') or
- die('is_freeze(): fopen() failed: ' . htmlspecialchars($page));
+ die('is_freeze(): fopen() failed: ' . htmlsc($page));
flock($fp, LOCK_SH) or die('is_freeze(): flock() failed');
rewind($fp);
$buffer = fgets($fp, 9);
flock($fp, LOCK_UN) or die('is_freeze(): flock() failed');
- fclose($fp) or die('is_freeze(): fclose() failed: ' . htmlspecialchars($page));
+ fclose($fp) or die('is_freeze(): fclose() failed: ' . htmlsc($page));
$is_freeze[$page] = ($buffer != FALSE && rtrim($buffer, "\r\n") == '#freeze');
return $is_freeze[$page];
$char = mb_substr($word_nm, $pos, 1, SOURCE_ENCODING);
// Just normalized one? (ASCII char or Zenkaku-Katakana?)
- $or = array(preg_quote($do_escape ? htmlspecialchars($char) : $char, $quote));
+ $or = array(preg_quote($do_escape ? htmlsc($char) : $char, $quote));
if (strlen($char) == 1) {
// An ASCII (single-byte) character
foreach (array(strtoupper($char), strtolower($char)) as $_char) {
if ($non_format) return array_keys($pages);
$r_word = rawurlencode($word);
- $s_word = htmlspecialchars($word);
+ $s_word = htmlsc($word);
if (empty($pages))
return str_replace('$1', $s_word, $_msg_notfoundresult);
- ksort($pages);
+ ksort($pages, SORT_STRING);
$retval = '<ul>' . "\n";
foreach (array_keys($pages) as $page) {
$r_page = rawurlencode($page);
- $s_page = htmlspecialchars($page);
+ $s_page = htmlsc($page);
$passage = $show_passage ? ' ' . get_passage(get_filetime($page)) : '';
$retval .= ' <li><a href="' . $script . '?cmd=read&page=' .
$r_page . '&word=' . $r_word . '">' . $s_page .
}
// Encode page-name
-function encode($key)
+function encode($str)
{
- return ($key == '') ? '' : strtoupper(bin2hex($key));
+ $str = strval($str);
+ return ($str == '') ? '' : strtoupper(bin2hex($str));
// Equal to strtoupper(join('', unpack('H*0', $key)));
// But PHP 4.3.10 says 'Warning: unpack(): Type H: outside of string in ...'
}
// Decode page name
-function decode($key)
+function decode($str)
{
- return hex2bin($key);
+ return pkwk_hex2bin($str);
}
// Inversion of bin2hex()
-function hex2bin($hex_string)
+function pkwk_hex2bin($hex_string)
{
// preg_match : Avoid warning : pack(): Type H: illegal hex digit ...
// (string) : Always treat as string (not int etc). See BugTrack2/31
foreach($pages as $file=>$page) {
$r_page = rawurlencode($page);
- $s_page = htmlspecialchars($page, ENT_QUOTES);
+ $s_page = htmlsc($page, ENT_QUOTES);
$passage = get_pg_passage($page);
$str = ' <li><a href="' . $href . $r_page . '">' .
$s_page . '</a>' . $passage;
if ($withfilename) {
- $s_file = htmlspecialchars($file);
+ $s_file = htmlsc($file);
$str .= "\n" . ' <ul><li>' . $s_file . '</li></ul>' .
"\n" . ' ';
}
}
} else {
$head = (preg_match('/^([A-Za-z])/', $page, $matches)) ? $matches[1] :
- (preg_match('/^([ -~])/', $page, $matches) ? $symbol : $other);
+ (preg_match('/^([ -~])/', $page) ? $symbol : $other);
}
$list[$head][$page] = $str;
global $rule_page;
if (! is_page($rule_page)) {
- return '<p>Sorry, page \'' . htmlspecialchars($rule_page) .
+ return '<p>Sorry, page \'' . htmlsc($rule_page) .
'\' unavailable.</p>';
} else {
return convert_html(get_source($rule_page));
if (isset($script_directory_index)) {
if (! file_exists($script_directory_index))
die_message('Directory index file not found: ' .
- htmlspecialchars($script_directory_index));
+ htmlsc($script_directory_index));
$matches = array();
if (preg_match('#^(.+/)' . preg_quote($script_directory_index, '#') . '$#',
$script, $matches)) $script = $matches[1];
return join($glue, $arr);
}
+// Sugar with default settings
+function htmlsc($string = '', $flags = ENT_COMPAT, $charset = CONTENT_CHARSET)
+{
+ return htmlspecialchars($string, $flags, $charset); // htmlsc()
+}
+
+
//// Compat ////
// is_a -- Returns TRUE if the object is of this class or has this class as one of its parents