/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: file.php,v 1.39 2004/02/29 08:01:45 arino Exp $
+// $Id: file.php,v 1.40 2004/03/18 10:02:13 arino Exp $
//
// ¥½¡¼¥¹¤ò¼èÆÀ
$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);
+ rewind($fp);
fputs($fp,$str);
flock($fp,LOCK_UN);
fclose($fp);
$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);
+ rewind($fp);
fputs($fp,join('',$lines));
fputs($fp,"#norelated\n"); // :)
flock($fp,LOCK_UN);
// 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');
+ set_file_buffer($fp, 0);
flock($fp,LOCK_EX);
+ rewind($fp);
foreach ($recent_pages as $page=>$time)
{
fputs($fp,"$time\t$page\n");
// 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');
+ set_file_buffer($fp, 0);
flock($fp,LOCK_EX);
+ rewind($fp);
foreach (array_splice(array_keys($recent_pages),0,$maxshow) as $page)
{
$time = $recent_pages[$page];
$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);
+ rewind($fp);
fputs($fp,$pattern."\n");
fputs($fp,$pattern_a."\n");
fputs($fp,join("\t",$forceignorelist)."\n");
/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: attach.inc.php,v 1.38 2003/12/06 05:12:38 arino Exp $
+// $Id: attach.inc.php,v 1.39 2004/03/18 10:02:13 arino Exp $
//
/*
$this->status['count'] = join(',',$this->status['count']);
$fp = fopen($this->logname,'wb')
or die_message('cannot write '.$this->logname);
+ set_file_buffer($fp, 0);
flock($fp,LOCK_EX);
+ rewind($fp);
foreach ($this->status as $key=>$value)
{
fwrite($fp,$value."\n");
* CopyRight 2002 Y.MASUI GPL2
* http://masui.net/pukiwiki/ masui@masui.net
*
- * $Id: counter.inc.php,v 1.12 2003/12/02 09:21:36 arino Exp $
+ * $Id: counter.inc.php,v 1.13 2004/03/18 10:02:13 arino Exp $
*/
// counter file
$counters[$page] = $default;
// ¥«¥¦¥ó¥¿¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤¹¤ë¾ì¹ç¤ÏÆɤ߹þ¤à
- $fp = NULL;
$file = COUNTER_DIR.encode($page).COUNTER_EXT;
- if (file_exists($file))
+ $fp = fopen($file, file_exists($file) ? 'r+' : 'w+')
+ or die_message('counter.inc.php:cannot open '.$file);
+ set_file_buffer($fp, 0);
+ flock($fp,LOCK_EX);
+ rewind($fp);
+
+ foreach ($default as $key=>$val)
{
- $fp = fopen($file, 'r+')
- or die_message('counter.inc.php:cannot read '.$file);
- flock($fp,LOCK_EX);
- foreach ($default as $key=>$val)
- {
- $counters[$page][$key] = rtrim(fgets($fp,256));
- }
+ $counters[$page][$key] = rtrim(fgets($fp,256));
+ if (feof($fp)) { break; }
}
// ¥Õ¥¡¥¤¥ë¹¹¿·¤¬É¬Íפ«?
$modify = FALSE;
}
//¥Ú¡¼¥¸Æɤ߽Ф·»þ¤Î¤ß¥Õ¥¡¥¤¥ë¤ò¹¹¿·
-// for PukiWiki/1.3.x
-// $is_read = !(arg_check('add') || arg_check('edit') || arg_check('preview') ||
-// $vars['preview'] != '' || $vars['write'] != '');
-// for PukiWiki/1.4
- $is_read = ($vars['cmd'] == 'read');
-
- if ($modify and $is_read)
+ if ($modify and $vars['cmd'] == 'read')
{
- // ¥Õ¥¡¥¤¥ë¤¬³«¤¤¤Æ¤¤¤ë
- if ($fp)
- {
- // ¥Õ¥¡¥¤¥ë¤ò´Ý¤á¤ë
- ftruncate($fp,0);
- rewind($fp);
- }
- else
- {
- // ¥Õ¥¡¥¤¥ë¤ò³«¤¯
- $fp = fopen($file, 'w')
- or die_message('counter.inc.php:cannot write '.$file);
- flock($fp,LOCK_EX);
- }
+ // ¥Õ¥¡¥¤¥ë¤ò´Ý¤á¤ë
+ rewind($fp);
+ ftruncate($fp,0);
// ½ñ¤½Ð¤¹
foreach (array_keys($default) as $key)
{
fputs($fp,$counters[$page][$key]."\n");
}
}
- // ¥Õ¥¡¥¤¥ë¤¬³«¤¤¤Æ¤¤¤ë
- if ($fp)
- {
- // ¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë
- flock($fp,LOCK_UN);
- fclose($fp);
- }
+ // ¥Õ¥¡¥¤¥ë¤òÊĤ¸¤ë
+ flock($fp,LOCK_UN);
+ fclose($fp);
return $counters[$page];
}
/////////////////////////////////////////////////
// PukiWiki - Yet another WikiWikiWeb clone.
//
-// $Id: online.inc.php,v 1.7 2003/11/05 10:40:48 arino Exp $
+// $Id: online.inc.php,v 1.8 2004/03/18 10:02:13 arino Exp $
//
// user list file
{
$usr_arr = file(USR_LST);
$fp = fopen(USR_LST, 'w');
+ set_file_buffer($fp, 0);
flock($fp,LOCK_EX);
+ rewind($fp);
$now = UTIME;
for ($i = 0; $i < count($usr_arr); $i++)
{