/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: file.php,v 1.1 2004/08/01 01:54:35 henoheno Exp $
+// $Id: file.php,v 1.2 2004/08/01 13:00:01 henoheno Exp $
//
// ¥½¡¼¥¹¤ò¼èÆÀ
-function get_source($page=NULL)
+function get_source($page = NULL)
{
- if (!is_page($page))
- {
+ if (! is_page($page)) {
return array();
+ } else {
+ return str_replace("\r", '', file(get_filename($page)));
}
- return str_replace("\r",'',file(get_filename($page)));
}
// ¥Ú¡¼¥¸¤Î¹¹¿·»þ¹ï¤òÆÀ¤ë
function get_filetime($page)
{
- if (!is_page($page))
- {
+ if (! is_page($page)) {
return 0;
+ } else {
+ return filemtime(get_filename($page)) - LOCALZONE;
}
- return filemtime(get_filename($page)) - LOCALZONE;
}
// ¥Ú¡¼¥¸¤Î¥Õ¥¡¥¤¥ë̾¤òÆÀ¤ë
function get_filename($page)
{
- return DATA_DIR.encode($page).'.txt';
+ return DATA_DIR . encode($page) . '.txt';
}
// ¥Ú¡¼¥¸¤Î½ÐÎÏ
-function page_write($page,$postdata,$notimestamp=FALSE)
+function page_write($page, $postdata, $notimestamp = FALSE)
{
$postdata = make_str_rules($postdata);
// º¹Ê¬¥Õ¥¡¥¤¥ë¤ÎºîÀ®
- $oldpostdata = is_page($page) ? join('',get_source($page)) : '';
- $diffdata = do_diff($oldpostdata,$postdata);
- file_write(DIFF_DIR,$page,$diffdata);
+ $oldpostdata = is_page($page) ? join('', get_source($page)) : '';
+ $diffdata = do_diff($oldpostdata, $postdata);
+ file_write(DIFF_DIR, $page, $diffdata);
// ¥Ð¥Ã¥¯¥¢¥Ã¥×¤ÎºîÀ®
- make_backup($page,$postdata == '');
+ make_backup($page, $postdata == '');
// ¥Õ¥¡¥¤¥ë¤Î½ñ¤¹þ¤ß
- file_write(DATA_DIR,$page,$postdata,$notimestamp);
+ file_write(DATA_DIR, $page, $postdata, $notimestamp);
// TrackBack Ping ¤ÎÁ÷¿®
// ¡ÖÄɲá׹ԤòÃê½Ð
- $lines = join("\n",preg_replace('/^\+/','',preg_grep('/^\+/',explode("\n",$diffdata))));
- tb_send($page,$lines);
+ $lines = join("\n", preg_replace('/^\+/', '', preg_grep('/^\+/', explode("\n", $diffdata))));
+ tb_send($page, $lines);
// link¥Ç¡¼¥¿¥Ù¡¼¥¹¤ò¹¹¿·
links_update($page);
// ¥æ¡¼¥¶ÄêµÁ¥ë¡¼¥ë(¥½¡¼¥¹¤òÃÖ´¹¤¹¤ë)
function make_str_rules($str)
{
- global $str_rules,$fixed_heading_anchor;
+ global $str_rules, $fixed_heading_anchor;
- $arr = explode("\n",$str);
+ $arr = explode("\n", $str);
- $retvars = array();
+ $retvars = $matches = array();
foreach ($arr as $str)
{
if ($str != '' and $str{0} != ' ' and $str{0} != "\t")
{
foreach ($str_rules as $rule => $replace)
{
- $str = preg_replace("/$rule/",$replace,$str);
+ $str = preg_replace("/$rule/", $replace, $str);
}
}
// ¸«½Ð¤·¤Ë¸ÇÍID¤òÉÕÍ¿¤¹¤ë
if ($fixed_heading_anchor and
- preg_match('/^(\*{1,3}(.(?!\[#[A-Za-z][\w-]+\]))+)$/',$str,$matches))
+ preg_match('/^(\*{1,3}(.(?!\[#[A-Za-z][\w-]+\]))+)$/', $str, $matches))
{
// ¸ÇÍID¤òÀ¸À®¤¹¤ë
// ¥é¥ó¥À¥à¤Ê±Ñ»ú(1ʸ»ú)+md5¥Ï¥Ã¥·¥å¤Î¥é¥ó¥À¥à¤ÊÉôʬʸ»úÎó(7ʸ»ú)
- $anchor = chr(mt_rand(ord('a'),ord('z'))).
- substr(md5(uniqid(substr($matches[1],0,100),1)),mt_rand(0,24),7);
- $str = rtrim($matches[1])." [#$anchor]";
+ $anchor = chr(mt_rand(ord('a'), ord('z'))).
+ substr(md5(uniqid(substr($matches[1], 0, 100), 1)), mt_rand(0, 24), 7);
+ $str = rtrim($matches[1]) . " [#$anchor]";
}
$retvars[] = $str;
}
- return join("\n",$retvars);
+ return join("\n", $retvars);
}
// ¥Õ¥¡¥¤¥ë¤Ø¤Î½ÐÎÏ
-function file_write($dir,$page,$str,$notimestamp=FALSE)
+function file_write($dir, $page, $str, $notimestamp = FALSE)
{
global $update_exec;
global $_msg_invalidiwn;
global $notify, $notify_diff_only, $notify_to, $notify_subject, $notify_header;
global $smtp_server, $smtp_auth;
- if (!is_pagename($page))
- {
- die_message(
- str_replace('$1',htmlspecialchars($page),
- str_replace('$2','WikiName',$_msg_invalidiwn)
- )
+ if (! is_pagename($page))
+ die_message(str_replace('$1', htmlspecialchars($page),
+ str_replace('$2', 'WikiName', $_msg_invalidiwn))
);
- }
+
$page = strip_bracket($page);
$timestamp = FALSE;
- $file = $dir.encode($page).'.txt';
+ $file = $dir . encode($page) . '.txt';
- if ($dir == DATA_DIR and $str == '' and file_exists($file))
- {
+ if ($dir == DATA_DIR and $str == '' and file_exists($file)) {
unlink($file);
put_recentdeleted($page);
}
- if ($str != '')
- {
- $str = preg_replace("/\r/",'',$str);
- $str = rtrim($str)."\n";
- if ($notimestamp and file_exists($file))
- {
+ if ($str != '') {
+ $str = preg_replace("/\r/", '', $str);
+ $str = rtrim($str) . "\n";
+
+ if ($notimestamp and file_exists($file)) {
$timestamp = filemtime($file) - LOCALZONE;
}
- $fp = fopen($file,'w')
- or die_message('cannot write page file or diff file or other'.htmlspecialchars($page).'<br />maybe permission is not writable or filename is too long');
+ $fp = fopen($file, 'w') or
+ die_message('Cannot write page file or diff file or other ' .
+ htmlspecialchars($page) .
+ '<br />Maybe permission is not writable or filename is too long');
+
set_file_buffer($fp, 0);
- flock($fp,LOCK_EX);
+ flock($fp, LOCK_EX);
rewind($fp);
- fputs($fp,$str);
- flock($fp,LOCK_UN);
+ fputs($fp, $str);
+ flock($fp, LOCK_UN);
fclose($fp);
- if ($timestamp)
- {
- touch($file,$timestamp + LOCALZONE);
+ if ($timestamp) {
+ touch($file, $timestamp + LOCALZONE);
}
}
- // is_page¤Î¥¥ã¥Ã¥·¥å¤ò¥¯¥ê¥¢¤¹¤ë¡£
- is_page($page,TRUE);
+ // is_page¤Î¥¥ã¥Ã¥·¥å¤ò¥¯¥ê¥¢¤¹¤ë
+ is_page($page, TRUE);
- if (!$timestamp and $dir == DATA_DIR)
- {
+ if (! $timestamp and $dir == DATA_DIR) {
put_lastmodified();
}
- if ($update_exec and $dir == DATA_DIR)
- {
- system($update_exec.' > /dev/null &');
+ if ($update_exec and $dir == DATA_DIR) {
+ system($update_exec . ' > /dev/null &');
}
- if ($notify and $dir == DIFF_DIR)
- {
- if ($notify_diff_only)
- {
- // º¹Ê¬¤À¤±¤òÁ÷¿®¤¹¤ë
- $str = preg_replace('/^[^-+].*\n/m','',$str);
+ if ($notify and $dir == DIFF_DIR) {
+ if ($notify_diff_only) { // º¹Ê¬¤À¤±¤òÁ÷¿®¤¹¤ë
+ $str = preg_replace('/^[^-+].*\n/m', '', $str);
}
- if ($smtp_auth)
- {
+ if ($smtp_auth) {
pop_before_smtp();
}
- $subject = str_replace('$page',$page,$notify_subject);
- ini_set('SMTP',$smtp_server);
+ $subject = str_replace('$page', $page, $notify_subject);
+ ini_set('SMTP', $smtp_server);
mb_language(LANG);
- mb_send_mail($notify_to,$subject,$str,$notify_header);
+ mb_send_mail($notify_to, $subject, $str, $notify_header);
}
}
// ºï½üÍúÎò¥Ú¡¼¥¸¤Î¹¹¿·
function put_recentdeleted($page)
{
- global $whatsdeleted,$maxshow_deleted;
+ global $whatsdeleted, $maxshow_deleted;
- if ($maxshow_deleted == 0)
- {
- return;
- }
- // update RecentDeleted
- $lines = array();
- foreach (get_source($whatsdeleted) as $line)
- {
- if (preg_match('/^-(.+) - (\[\[.+\]\])$/',$line,$matches))
- {
+ if ($maxshow_deleted == 0) return;
+
+ // Update RecentDeleted
+ $lines = $matches = array();
+ foreach (get_source($whatsdeleted) as $line) {
+ if (preg_match('/^-(.+) - (\[\[.+\]\])$/', $line, $matches))
$lines[$matches[2]] = $line;
- }
}
+
$_page = "[[$page]]";
- if (array_key_exists($_page,$lines))
- {
- unset($lines[$_page]);
- }
- array_unshift($lines,'-'.format_date(UTIME)." - $_page\n");
- $lines = array_splice($lines,0,$maxshow_deleted);
- $fp = fopen(get_filename($whatsdeleted),'w')
- or die_message('cannot write page file '.htmlspecialchars($whatsdeleted).'<br />maybe permission is not writable or filename is too long');
+ if (isset($lines[$_page])) unset($lines[$_page]);
+
+ array_unshift($lines, '-' . format_date(UTIME) . " - $_page\n");
+ $lines = array_splice($lines, 0, $maxshow_deleted);
+
+ $fp = fopen(get_filename($whatsdeleted), 'w') or
+ die_message('Cannot write page file ' .
+ htmlspecialchars($whatsdeleted) .
+ '<br />Maybe permission is not writable or filename is too long');
+
set_file_buffer($fp, 0);
- flock($fp,LOCK_EX);
+ flock($fp, LOCK_EX);
rewind($fp);
- fputs($fp,join('',$lines));
- fputs($fp,"#norelated\n"); // :)
- flock($fp,LOCK_UN);
+ fputs($fp, join('', $lines));
+ fputs($fp, "#norelated\n"); // :)
+ flock($fp, LOCK_UN);
fclose($fp);
}
// ºÇ½ª¹¹¿·¥Ú¡¼¥¸¤Î¹¹¿·
function put_lastmodified()
{
- global $maxshow,$whatsnew,$non_list,$autolink;
+ global $maxshow, $whatsnew, $non_list, $autolink;
$pages = get_existpages();
$recent_pages = array();
- foreach($pages as $page)
- {
- if ($page != $whatsnew and !preg_match("/$non_list/",$page))
- {
+ foreach($pages as $page) {
+ if ($page != $whatsnew and ! preg_match("/$non_list/", $page))
$recent_pages[$page] = get_filetime($page);
- }
}
//»þ¹ï¹ß½ç¤Ç¥½¡¼¥È
- arsort($recent_pages,SORT_NUMERIC);
+ arsort($recent_pages, SORT_NUMERIC);
// create recent.dat (for recent.inc.php)
- $fp = fopen(CACHE_DIR.'recent.dat','w')
- or die_message('cannot write cache file '.CACHE_DIR.'recent.dat<br />maybe permission is not writable or filename is too long');
+ $fp = fopen(CACHE_DIR . 'recent.dat', 'w') or
+ die_message('Cannot write cache file ' .
+ CACHE_DIR . 'recent.dat' .
+ '<br />Maybe permission is not writable or filename is too long');
+
set_file_buffer($fp, 0);
- flock($fp,LOCK_EX);
+ flock($fp, LOCK_EX);
rewind($fp);
- foreach ($recent_pages as $page=>$time)
- {
- fputs($fp,"$time\t$page\n");
+ foreach ($recent_pages as $page=>$time) {
+ fputs($fp, "$time\t$page\n");
}
- flock($fp,LOCK_UN);
+ flock($fp, LOCK_UN);
fclose($fp);
// create RecentChanges
- $fp = fopen(get_filename($whatsnew),'w')
- or die_message('cannot write page file '.htmlspecialchars($whatsnew).'<br />maybe permission is not writable or filename is too long');
+ $fp = fopen(get_filename($whatsnew), 'w') or
+ die_message('Cannot write page file ' .
+ htmlspecialchars($whatsnew) .
+ '<br />Maybe permission is not writable or filename is too long');
+
set_file_buffer($fp, 0);
- flock($fp,LOCK_EX);
+ flock($fp, LOCK_EX);
rewind($fp);
- foreach (array_splice(array_keys($recent_pages),0,$maxshow) as $page)
- {
+ foreach (array_splice(array_keys($recent_pages), 0, $maxshow) as $page) {
$time = $recent_pages[$page];
$s_lastmod = htmlspecialchars(format_date($time));
$s_page = htmlspecialchars($page);
fputs($fp, "-$s_lastmod - [[$s_page]]\n");
}
- fputs($fp,"#norelated\n"); // :)
- flock($fp,LOCK_UN);
+ fputs($fp, "#norelated\n"); // :)
+ flock($fp, LOCK_UN);
fclose($fp);
// for autolink
- if ($autolink)
- {
- list($pattern,$pattern_a,$forceignorelist) = get_autolink_pattern($pages);
+ if ($autolink) {
+ list($pattern, $pattern_a, $forceignorelist) = get_autolink_pattern($pages);
- $fp = fopen(CACHE_DIR.'autolink.dat','w')
- or die_message('cannot write autolink file '.CACHE_DIR.'/autolink.dat<br />maybe permission is not writable');
+ $fp = fopen(CACHE_DIR . 'autolink.dat', 'w') or
+ die_message('Cannot write autolink file ' .
+ CACHE_DIR . '/autolink.dat' .
+ '<br />Maybe permission is not writable');
set_file_buffer($fp, 0);
- flock($fp,LOCK_EX);
+ flock($fp, LOCK_EX);
rewind($fp);
- fputs($fp,$pattern."\n");
- fputs($fp,$pattern_a."\n");
- fputs($fp,join("\t",$forceignorelist)."\n");
- flock($fp,LOCK_UN);
+ fputs($fp, $pattern . "\n");
+ fputs($fp, $pattern_a . "\n");
+ fputs($fp, join("\t", $forceignorelist) . "\n");
+ flock($fp, LOCK_UN);
fclose($fp);
}
}
// »ØÄꤵ¤ì¤¿¥Ú¡¼¥¸¤Î·Ð²á»þ¹ï
-function get_pg_passage($page,$sw=TRUE)
+function get_pg_passage($page, $sw = TRUE)
{
global $show_passage;
static $pg_passage = array();
- if (!$show_passage)
- {
- return '';
- }
+ if (! $show_passage) return '';
- if (!array_key_exists($page,$pg_passage))
- {
+ if (! array_key_exists($page, $pg_passage)) {
$pg_passage[$page] = (is_page($page) and $time = get_filetime($page)) ?
get_passage($time) : '';
}
}
// Last-Modified ¥Ø¥Ã¥À
-function header_lastmod($page=NULL)
+function header_lastmod($page = NULL)
{
global $lastmod;
- if ($lastmod and is_page($page))
- {
- header('Last-Modified: '.date('D, d M Y H:i:s',get_filetime($page)).' GMT');
+ if ($lastmod and is_page($page)) {
+ header('Last-Modified: ' .
+ date('D, d M Y H:i:s', get_filetime($page)) . ' GMT');
}
}
// Á´¥Ú¡¼¥¸Ì¾¤òÇÛÎó¤Ë
-function get_existpages($dir=DATA_DIR,$ext='.txt')
+function get_existpages($dir = DATA_DIR, $ext = '.txt')
{
$aryret = array();
$pattern = '^((?:[0-9A-F]{2})+)';
if ($ext != '')
- {
- $pattern .= preg_quote($ext,'/').'$';
- }
- $dp = @opendir($dir)
- or die_message($dir. ' is not found or not readable.');
- while ($file = readdir($dp))
- {
- if (preg_match("/$pattern/",$file,$matches))
- {
+ $pattern .= preg_quote($ext, '/') . '$';
+
+ $dp = @opendir($dir) or
+ die_message($dir . ' is not found or not readable.');
+ $matches = array();
+ while ($file = readdir($dp)) {
+ if (preg_match("/$pattern/", $file, $matches))
$aryret[$file] = decode($matches[1]);
- }
}
closedir($dp);
+
return $aryret;
}
+
// ¥Ú¡¼¥¸Ì¾¤ÎÆɤߤòÇÛÎó¤Ë
function get_readings()
{
foreach ($pages as $page) {
$readings[$page] = '';
}
+
$deletedPage = FALSE;
+ $matches = array();
foreach (get_source($pagereading_config_page) as $line) {
$line = chop($line);
if(preg_match('/^-\[\[([^]]+)\]\]\s+(.+)$/', $line, $matches)) {
}
}
}
+
+ // ChaSen/KAKASI ¸Æ¤Ó½Ð¤·¤¬Í¸ú¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç
if($pagereading_enable) {
- // ChaSen/KAKASI ¸Æ¤Ó½Ð¤·¤¬Í¸ú¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç
- $unknownPage = FALSE;
+
// Æɤߤ¬ÉÔÌÀ¤Î¥Ú¡¼¥¸¤¬¤¢¤ë¤«¥Á¥§¥Ã¥¯
+ $unknownPage = FALSE;
foreach ($readings as $page => $reading) {
- if($reading=='') {
+ if($reading == '') {
$unknownPage = TRUE;
break;
}
}
+
+ // Æɤߤ¬ÉÔÌÀ¤Î¥Ú¡¼¥¸¤¬¤¢¤ë¾ì¹ç¡¢ChaSen/KAKASI ¤ò¼Â¹Ô
if($unknownPage) {
- // Æɤߤ¬ÉÔÌÀ¤Î¥Ú¡¼¥¸¤¬¤¢¤ë¾ì¹ç¡¢ChaSen/KAKASI ¤ò¼Â¹Ô
switch(strtolower($pagereading_kanji2kana_converter)) {
case 'chasen':
$tmpfname = tempnam(CACHE_DIR, 'PageReading');
- $fp = fopen($tmpfname, "w")
- or die_message("cannot write temporary file '$tmpfname'.\n");
+ $fp = fopen($tmpfname, "w") or
+ die_message("Cannot write temporary file '$tmpfname'.\n");
foreach ($readings as $page => $reading) {
- if($reading=='') {
+ if($reading == '') {
fputs($fp, mb_convert_encoding("$page\n", $pagereading_kanji2kana_encoding, SOURCE_ENCODING));
}
}
fclose($fp);
- if(!file_exists($pagereading_chasen_path)) {
+
+ if(! file_exists($pagereading_chasen_path)) {
unlink($tmpfname);
- die_message("CHASEN not found: $pagereading_chasen_path");
+ die_message("ChaSen not found: $pagereading_chasen_path");
}
- $fp = popen("$pagereading_chasen_path -F %y $tmpfname", "r");
- if(!$fp) {
+
+ $chasen = "$pagereading_chasen_path -F %y $tmpfname";
+ $fp = popen($chasen, "r");
+ if(! $fp) {
unlink($tmpfname);
- die_message("ChaSen execution failed: $pagereading_chasen_path -F %y $tmpfname");
+ die_message("ChaSen execution failed: $chasen");
}
foreach ($readings as $page => $reading) {
- if($reading=='') {
+ if($reading == '') {
$line = fgets($fp);
$line = mb_convert_encoding($line, SOURCE_ENCODING, $pagereading_kanji2kana_encoding);
$line = chop($line);
}
}
pclose($fp);
- unlink($tmpfname) or die_message("temporary file can not be removed: $tmpfname");
+
+ unlink($tmpfname) or die_message("Temporary file can not be removed: $tmpfname");
break;
+
case 'kakasi':
case 'kakashi':
$tmpfname = tempnam(CACHE_DIR, 'PageReading');
- $fp = fopen($tmpfname, "w")
- or die_message("cannot write temporary file '$tmpfname'.\n");
+ $fp = fopen($tmpfname, "w") or
+ die_message("Cannot write temporary file '$tmpfname'.\n");
foreach ($readings as $page => $reading) {
- if($reading=='') {
+ if($reading == '') {
fputs($fp, mb_convert_encoding("$page\n", $pagereading_kanji2kana_encoding, SOURCE_ENCODING));
}
}
fclose($fp);
- if(!file_exists($pagereading_kakasi_path)) {
+
+ if(! file_exists($pagereading_kakasi_path)) {
unlink($tmpfname);
die_message("KAKASI not found: $pagereading_kakasi_path");
}
- $fp = popen("$pagereading_kakasi_path -kK -HK -JK <$tmpfname", "r");
+
+ $kakasi = "$pagereading_kakasi_path -kK -HK -JK < $tmpfname";
+ $fp = popen($kakasi, "r");
if(!$fp) {
unlink($tmpfname);
- die_message("KAKASI execution failed: $pagereading_kakasi_path -kK -HK -JK <$tmpfname");
+ die_message("KAKASI execution failed: $kakasi");
}
foreach ($readings as $page => $reading) {
- if($reading=='') {
+ if($reading == '') {
$line = fgets($fp);
$line = mb_convert_encoding($line, SOURCE_ENCODING, $pagereading_kanji2kana_encoding);
$line = chop($line);
}
}
pclose($fp);
- unlink($tmpfname) or die_message("temporary file can not be removed: $tmpfname");
+
+ unlink($tmpfname) or die_message("Temporary file can not be removed: $tmpfname");
break;
+
case 'none':
- $patterns = array();
- $replacements = array();
+ $patterns = $replacements = $matches = array();
foreach (get_source($pagereading_config_dict) as $line) {
$line = chop($line);
if(preg_match('|^ /([^/]+)/,\s*(.+)$|', $line, $matches)) {
- $patterns[] = $matches[1];
+ $patterns[] = $matches[1];
$replacements[] = $matches[2];
}
}
foreach ($readings as $page => $reading) {
- if($reading=='') {
+ if($reading == '') {
$readings[$page] = $page;
foreach ($patterns as $no => $pattern) {
$readings[$page] = mb_convert_kana(mb_ereg_replace($pattern, $replacements[$no], $readings[$page]), "aKCV");
}
}
break;
+
default:
- die_message("unknown kanji-kana converter: $pagereading_kanji2kana_converter.");
+ die_message("Unknown kanji-kana converter: $pagereading_kanji2kana_converter.");
break;
}
}
+
if($unknownPage or $deletedPage) {
- // Æɤߤǥ½¡¼¥È
- asort($readings);
+
+ asort($readings); // Æɤߤǥ½¡¼¥È
// ¥Ú¡¼¥¸¤ò½ñ¤¹þ¤ß
$body = '';
// ¤Ó½Ð¤·¤¬Ìµ¸ú¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤ä¡¢ChaSen/KAKASI ¸Æ¤Ó½Ð¤·¤Ë
// ¼ºÇÔ¤·¤¿»þ¤Î°Ù)
foreach ($pages as $page) {
- if($readings[$page]=='') {
+ if($readings[$page] == '') {
$readings[$page] = $page;
}
}
return $readings;
}
+
//¥Õ¥¡¥¤¥ë̾¤Î°ìÍ÷¤òÇÛÎó¤Ë(¥¨¥ó¥³¡¼¥ÉºÑ¤ß¡¢³ÈÄ¥»Ò¤ò»ØÄê)
-function get_existfiles($dir,$ext)
+function get_existfiles($dir, $ext)
{
$aryret = array();
- $pattern = '^(?:[0-9A-F]{2})+'.preg_quote($ext,'/').'$';
- $dp = @opendir($dir)
- or die_message($dir. ' is not found or not readable.');
+ $pattern = '^(?:[0-9A-F]{2})+' . preg_quote($ext, '/') . '$';
+ $dp = @opendir($dir) or
+ die_message($dir . ' is not found or not readable.');
while ($file = readdir($dp)) {
- if (preg_match("/$pattern/",$file)) {
- $aryret[] = $dir.$file;
- }
+ if (preg_match("/$pattern/", $file))
+ $aryret[] = $dir . $file;
}
closedir($dp);
return $aryret;
}
+
//¤¢¤ë¥Ú¡¼¥¸¤Î´ØÏ¢¥Ú¡¼¥¸¤òÆÀ¤ë
function links_get_related($page)
{
- global $vars,$related;
+ global $vars, $related;
static $links = array();
- if (array_key_exists($page,$links))
- {
- return $links[$page];
- }
+ if (isset($links[$page])) return $links[$page];
// ²Äǽ¤Ê¤émake_link()¤ÇÀ¸À®¤·¤¿´ØÏ¢¥Ú¡¼¥¸¤ò¼è¤ê¹þ¤à
$links[$page] = ($page == $vars['page']) ? $related : array();