本文整理汇总了PHP中page_write函数的典型用法代码示例。如果您正苦于以下问题:PHP page_write函数的具体用法?PHP page_write怎么用?PHP page_write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了page_write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
public function write()
{
$output = PKWK_YAMLCONFIG_HEAD . yaml_emit($this->getArrayCopy()) . PKWK_YAMLCONFIG_TAIL;
$source = get_source($this->page, TRUE, TRUE);
$source = $source != FALSE && preg_match(PKWK_YAMLCONFIG_PATTERN, $source) ? preg_replace(PKWK_YAMLCONFIG_PATTERN, $output, $source) : $output;
page_write($this->page, $source);
return $source;
}
示例2: plugin_vote_action
function plugin_vote_action()
{
global $vars, $script, $cols, $rows;
global $_title_collided, $_msg_collided, $_title_updated;
global $_vote_plugin_votes;
if (PKWK_READONLY) {
die_message('PKWK_READONLY prohibits editing');
}
$postdata_old = get_source($vars['refer']);
$vote_no = 0;
$title = $body = $postdata = $postdata_input = $vote_str = '';
$matches = array();
foreach ($postdata_old as $line) {
if (!preg_match('/^#vote(?:\\((.*)\\)(.*))?$/i', $line, $matches) || $vote_no++ != $vars['vote_no']) {
$postdata .= $line;
continue;
}
$args = explode(',', $matches[1]);
$lefts = isset($matches[2]) ? $matches[2] : '';
foreach ($args as $arg) {
$cnt = 0;
if (preg_match('/^(.+)\\[(\\d+)\\]$/', $arg, $matches)) {
$arg = $matches[1];
$cnt = $matches[2];
}
$e_arg = encode($arg);
if (!empty($vars['vote_' . $e_arg]) && $vars['vote_' . $e_arg] == $_vote_plugin_votes) {
++$cnt;
}
$votes[] = $arg . '[' . $cnt . ']';
}
$vote_str = '#vote(' . @join(',', $votes) . ')' . $lefts . "\n";
$postdata_input = $vote_str;
$postdata .= $vote_str;
}
if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
$title = $_title_collided;
$s_refer = htmlsc($vars['refer']);
$s_digest = htmlsc($vars['digest']);
$s_postdata_input = htmlsc($postdata_input);
$body = <<<EOD
{$_msg_collided}
<form action="{$script}?cmd=preview" method="post">
<div>
<input type="hidden" name="refer" value="{$s_refer}" />
<input type="hidden" name="digest" value="{$s_digest}" />
<textarea name="msg" rows="{$rows}" cols="{$cols}" id="textarea">{$s_postdata_input}</textarea><br />
</div>
</form>
EOD;
} else {
page_write($vars['refer'], $postdata);
$title = $_title_updated;
}
$vars['page'] = $vars['refer'];
return array('msg' => $title, 'body' => $body);
}
示例3: plugin_memo_action
function plugin_memo_action()
{
global $script, $vars, $cols, $rows;
global $_title_collided, $_msg_collided, $_title_updated;
if (PKWK_READONLY) {
die_message('PKWK_READONLY prohibits editing');
}
if (!isset($vars['msg']) || $vars['msg'] == '') {
return;
}
$memo_body = preg_replace('/' . "\r" . '/', '', $vars['msg']);
$memo_body = str_replace("\n", '\\n', $memo_body);
$memo_body = str_replace('"', '"', $memo_body);
// Escape double quotes
$memo_body = str_replace(',', ',', $memo_body);
// Escape commas
$postdata_old = get_source($vars['refer']);
$postdata = '';
$memo_no = 0;
foreach ($postdata_old as $line) {
if (preg_match("/^#memo\\(?.*\\)?\$/i", $line)) {
if ($memo_no == $vars['memo_no']) {
$postdata .= '#memo(' . $memo_body . ')' . "\n";
$line = '';
}
++$memo_no;
}
$postdata .= $line;
}
$postdata_input = $memo_body . "\n";
$body = '';
if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
$title = $_title_collided;
$body = $_msg_collided . "\n";
$s_refer = htmlspecialchars($vars['refer']);
$s_digest = htmlspecialchars($vars['digest']);
$s_postdata_input = htmlspecialchars($postdata_input);
$body .= <<<EOD
<form action="{$script}?cmd=preview" method="post">
<div>
<p>
<input type="hidden" name="refer" value="{$s_refer}" />
<input type="hidden" name="digest" value="{$s_digest}" />
<textarea name="msg" rows="{$rows}" cols="{$cols}" id="textarea">{$s_postdata_input}</textarea>
</p>
</div>
</form>
EOD;
} else {
page_write($vars['refer'], $postdata);
$title = $_title_updated;
}
$retvars['msg'] =& $title;
$retvars['body'] =& $body;
$vars['page'] = $vars['refer'];
return $retvars;
}
示例4: plugin_insert_action
function plugin_insert_action()
{
global $script, $vars, $cols, $rows;
global $_title_collided, $_msg_collided, $_title_updated;
if (PKWK_READONLY) {
die_message('PKWK_READONLY prohibits editing');
}
if (!isset($vars['msg']) || $vars['msg'] == '') {
return;
}
$vars['msg'] = preg_replace('/' . "\r" . '/', '', $vars['msg']);
$insert = $vars['msg'] != '' ? "\n" . $vars['msg'] . "\n" : '';
$postdata = '';
$postdata_old = get_source($vars['refer']);
$insert_no = 0;
foreach ($postdata_old as $line) {
if (!INSERT_INS) {
$postdata .= $line;
}
if (preg_match('/^#insert$/i', $line)) {
if ($insert_no == $vars['insert_no']) {
$postdata .= $insert;
}
$insert_no++;
}
if (INSERT_INS) {
$postdata .= $line;
}
}
$postdata_input = $insert . "\n";
$body = '';
if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
$title = $_title_collided;
$body = $_msg_collided . "\n";
$s_refer = htmlsc($vars['refer']);
$s_digest = htmlsc($vars['digest']);
$s_postdata_input = htmlsc($postdata_input);
$body .= <<<EOD
<form action="{$script}?cmd=preview" method="post">
<div>
<input type="hidden" name="refer" value="{$s_refer}" />
<input type="hidden" name="digest" value="{$s_digest}" />
<textarea name="msg" rows="{$rows}" cols="{$cols}" id="textarea">{$s_postdata_input}</textarea><br />
</div>
</form>
EOD;
} else {
page_write($vars['refer'], $postdata);
$title = $_title_updated;
}
$retvars['msg'] = $title;
$retvars['body'] = $body;
$vars['page'] = $vars['refer'];
return $retvars;
}
示例5: replace_do
function replace_do($search, $replace, $notimestamp)
{
global $cycle, $cantedit;
global $_replace_msg;
// パスワードが合ってたらいよいよ置換
$pages = auth::get_existpages();
$replaced_pages = array();
foreach ($pages as $page) {
if (REPLACE_IGNORE_FREEZE) {
$editable = !in_array($page, $cantedit);
} else {
$editable = (!is_freeze($page) and !in_array($page, $cantedit));
}
if ($editable) {
// パスワード一致
$postdata = '';
$postdata_old = get_source($page);
foreach ($postdata_old as $line) {
// キーワードの置換
$line = str_replace($search, $replace, $line);
$postdata .= $line;
}
if ($postdata != join('', $postdata_old)) {
$cycle = 0;
set_time_limit(30);
page_write($page, $postdata, $notimestamp);
$replaced_pages[] = htmlspecialchars($page);
}
}
}
$vars['cmd'] = 'read';
if (count($replaced_pages) == 0) {
return array('msg' => $_replace_msg['msg_H0_no_data'], 'body' => '<p>' . $_replace_msg['msg_no_replaced'] . '</p>');
}
return array('msg' => $_replace_msg['msg_H0_replaced'], 'body' => '<p>' . $_replace_msg['msg_replaced'] . "</p>\n<p>" . join("<br />\n", $replaced_pages) . '</p>');
}
示例6: plugin_delete_write
function plugin_delete_write()
{
global $vars, $trackback, $layout_pages;
global $notimeupdate, $do_update_diff_table;
$qm = get_qm();
$page = isset($vars['page']) ? $vars['page'] : '';
$digest = isset($vars['digest']) ? $vars['digest'] : '';
// Collision Detection
$oldpagesrc = join('', get_source($page));
$oldpagemd5 = md5($oldpagesrc);
if ($digest == $oldpagemd5) {
$retvars = array();
page_write($page, '');
$retvars['msg'] = $qm->m['fmt_title_deleted'];
$retvars['body'] = str_replace('$1', htmlspecialchars($page), $qm->m['fmt_title_deleted']);
if ($trackback) {
tb_delete($page);
}
} else {
$retvars['msg'] = '$1 を削除できません';
$retvars['body'] = $page . 'を削除できませんでした。';
}
return $retvars;
}
示例7: get_readings
//.........这里部分代码省略.........
if ($reading != '') {
continue;
}
fputs($fp, mb_convert_encoding($page . "\n", $pagereading_kanji2kana_encoding, SOURCE_ENCODING));
}
fclose($fp);
$chasen = "{$pagereading_chasen_path} -F %y {$tmpfname}";
$fp = popen($chasen, 'r');
if ($fp === false) {
unlink($tmpfname);
die_message('ChaSen execution failed: ' . $chasen);
}
foreach ($readings as $page => $reading) {
if ($reading != '') {
continue;
}
$line = fgets($fp);
$line = mb_convert_encoding($line, SOURCE_ENCODING, $pagereading_kanji2kana_encoding);
$line = chop($line);
$readings[$page] = $line;
}
pclose($fp);
unlink($tmpfname) or die_message('Temporary file can not be removed: ' . $tmpfname);
break;
case 'kakasi':
/*FALLTHROUGH*/
/*FALLTHROUGH*/
case 'kakashi':
if (!file_exists($pagereading_kakasi_path)) {
die_message('KAKASI not found: ' . $pagereading_kakasi_path);
}
$tmpfname = tempnam(realpath(CACHE_DIR), 'PageReading');
$fp = fopen($tmpfname, 'w') or die_message('Cannot write temporary file "' . $tmpfname . '".' . "\n");
foreach ($readings as $page => $reading) {
if ($reading != '') {
continue;
}
fputs($fp, mb_convert_encoding($page . "\n", $pagereading_kanji2kana_encoding, SOURCE_ENCODING));
}
fclose($fp);
$kakasi = "{$pagereading_kakasi_path} -kK -HK -JK < {$tmpfname}";
$fp = popen($kakasi, 'r');
if ($fp === false) {
unlink($tmpfname);
die_message('KAKASI execution failed: ' . $kakasi);
}
foreach ($readings as $page => $reading) {
if ($reading != '') {
continue;
}
$line = fgets($fp);
$line = mb_convert_encoding($line, SOURCE_ENCODING, $pagereading_kanji2kana_encoding);
$line = chop($line);
$readings[$page] = $line;
}
pclose($fp);
unlink($tmpfname) or die_message('Temporary file can not be removed: ' . $tmpfname);
break;
case 'none':
$patterns = $replacements = $matches = array();
foreach (get_source($pagereading_config_dict) as $line) {
$line = chop($line);
if (preg_match('|^ /([^/]+)/,\\s*(.+)$|', $line, $matches)) {
$patterns[] = $matches[1];
$replacements[] = $matches[2];
}
}
foreach ($readings as $page => $reading) {
if ($reading != '') {
continue;
}
$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 . '.');
break;
}
}
if ($unknownPage || $deletedPage) {
asort($readings);
// Sort by pronouncing(alphabetical/reading) order
$body = '';
foreach ($readings as $page => $reading) {
$body .= '-[[' . $page . ']] ' . $reading . "\n";
}
page_write($pagereading_config_page, $body);
}
}
// Pages that are not prounouncing-clear, return pagenames of themselves
foreach ($pages as $page) {
if ($readings[$page] == '') {
$readings[$page] = $page;
}
}
return $readings;
}
示例8: plugin_listbox_mkconfig
function plugin_listbox_mkconfig()
{
$conffile = ':config/' . PLUGIN_LISTBOX_CONFIGPAGE;
if (!is_page($conffile)) {
$qm = get_qm();
$maxyear = date("Y") + 5;
$contents = '#close
* listbox setting [#v69f5c78]
' . $qm->m['plg_listbox']['cfg_desc'] . '
' . $qm->m['plg_listbox']['cfg_ex1'] . '
' . $qm->m['plg_listbox']['cfg_ex2'] . '
' . $qm->m['plg_listbox']['cfg_ntc'] . '
* member [#j18e38d8]
| -- |
|Taro|
|Hanako|
|Ken|
|Michael|
* year [#cad00f59]
|1960|' . $maxyear . '|
* mon [#c1ae4bb0]
|1|12|
* Mon
|Jan.|
|Feb.|
|Mar.|
|Apr.|
|May |
|Jun.|
|Jul.|
|Aug.|
|Sep.|
|Oct.|
|Nov.|
|Dec.|
* Month
|January|
|February|
|March|
|April|
|May|
|June|
|July|
|August|
|September|
|October|
|November|
|December|
* day [#ub609568]
|1|31|
* hour [#l156dc58]
|1|24|
* min [#h6c0ab82]
|1|60|
* sec [#lfb1a875]
|1|60|
';
page_write($conffile, $contents);
}
}
示例9: plugin_tracker_action
function plugin_tracker_action()
{
global $post, $vars, $now;
if (PKWK_READONLY) {
die_message('PKWK_READONLY prohibits editing');
}
$config_name = array_key_exists('_config', $post) ? $post['_config'] : '';
$config = new Config('plugin/tracker/' . $config_name);
if (!$config->read()) {
return "<p>config file '" . htmlsc($config_name) . "' not found.</p>";
}
$config->config_name = $config_name;
$source = $config->page . '/page';
$refer = array_key_exists('_refer', $post) ? $post['_refer'] : $post['_base'];
if (!is_pagename($refer)) {
return array('msg' => 'cannot write', 'body' => 'page name (' . htmlsc($refer) . ') is not valid.');
}
if (!is_page($source)) {
return array('msg' => 'cannot write', 'body' => 'page template (' . htmlsc($source) . ') is not exist.');
}
// ページ名を決定
$base = $post['_base'];
$num = 0;
$name = array_key_exists('_name', $post) ? $post['_name'] : '';
if (array_key_exists('_page', $post)) {
$page = $real = $post['_page'];
} else {
$real = is_pagename($name) ? $name : ++$num;
$page = get_fullname('./' . $real, $base);
}
if (!is_pagename($page)) {
$page = $base;
}
while (is_page($page)) {
$real = ++$num;
$page = "{$base}/{$real}";
}
// ページデータを生成
$postdata = plugin_tracker_get_source($source);
// 規定のデータ
$_post = array_merge($post, $_FILES);
$_post['_date'] = $now;
$_post['_page'] = $page;
$_post['_name'] = $name;
$_post['_real'] = $real;
// $_post['_refer'] = $_post['refer'];
$fields = plugin_tracker_get_fields($page, $refer, $config);
// Creating an empty page, before attaching files
touch(get_filename($page));
foreach (array_keys($fields) as $key) {
$value = array_key_exists($key, $_post) ? $fields[$key]->format_value($_post[$key]) : '';
foreach (array_keys($postdata) as $num) {
if (trim($postdata[$num]) == '') {
continue;
}
$postdata[$num] = str_replace("[{$key}]", ($postdata[$num][0] == '|' or $postdata[$num][0] == ':') ? str_replace('|', '|', $value) : $value, $postdata[$num]);
}
}
// Writing page data, without touch
page_write($page, join('', $postdata));
$r_page = rawurlencode($page);
pkwk_headers_sent();
header('Location: ' . get_script_uri() . '?' . $r_page);
exit;
}
示例10: plugin_approve_action
function plugin_approve_action()
{
global $vars, $post;
if (auth::check_role('readonly')) {
die_message(_('PKWK_READONLY prohibits editing'));
}
if (auth::is_check_role(PKWK_CREATE_PAGE)) {
die_message(_('PKWK_CREATE_PAGE prohibits editing'));
}
// Petit SPAM Check (Client(Browser)-Server Ticket Check)
$spam = FALSE;
if (function_exists('pkwk_session_start') && pkwk_session_start() != 0) {
$s_tracker = md5(get_ticket() . 'Approve');
error_log("\$s_tracker: " . $s_tracker);
error_log("\$_SESSION['tracker']: " . $_SESSION['tracker']);
} else {
if (isset($post['encode_hint']) && $post['encode_hint'] != '') {
error_log("\$post['encode_hint']: " . $post['encode_hint']);
if (PKWK_ENCODING_HINT != $post['encode_hint']) {
$spam = TRUE;
}
} else {
error_log("PKWK_ENCODING_HINT: " . PKWK_ENCODING_HINT);
if (PKWK_ENCODING_HINT != '') {
$spam = TRUE;
}
}
error_log("is_spampost: " . is_spampost(array('body'), PLUGIN_TRACKER_REJECT_SPAMCOUNT));
if (is_spampost(array('body'), PLUGIN_TRACKER_REJECT_SPAMCOUNT)) {
$spam = TRUE;
}
}
error_log("isSpam: " . $spam);
if ($spam) {
honeypot_write();
return array('msg' => 'cannot write', 'body' => '<p>prohibits editing</p>');
}
$name = isset($post['name']) ? $post['name'] : '';
$page = isset($post['_page']) ? $post['_page'] : '';
if ($name == '') {
return '<p>approve(): empty name.</p>';
}
if ($page == '') {
return '<p>approve(): empty page.</p>';
}
$config_path = PLUGIN_APPROVE_CONFIG_ROOT . $name;
$config = new YamlConfig($config_path);
if (!$config->read()) {
return array('msg' => 'Approve', 'body' => '<p>approve(): failed to load config. "' . $config_path . '"</p>');
}
$pattern = $config[PLUGIN_APPROVE_KEY_PATTERN];
$replace = $config[PLUGIN_APPROVE_KEY_REPLACE];
$page_regex = $config[PLUGIN_APPROVE_KEY_PAGE_REGEX];
if ($page == '') {
return array('msg' => 'Approve', 'body' => '<p>approve(): empty page.</p>');
}
if ($pattern == '') {
return array('msg' => 'Approve', 'body' => '<p>approve(): empty pattern.</p>');
}
if ($page_regex == '') {
return array('msg' => 'Approve', 'body' => '<p>approve(): empty page_regex.</p>');
}
if (!preg_match($page_regex, $page)) {
return array('msg' => 'Approve', 'body' => '<p>approve(): page not match.</p>');
}
if (PKWK_READONLY > 0 || is_freeze($vars['page']) || !plugin_approve_is_edit_authed($page)) {
return array('msg' => 'Approve', 'body' => '<p>approve(): prohibit editing. "' . $page . '"</p>');
}
$source = get_source($page, TRUE, TRUE);
if ($source === FALSE) {
return array('msg' => 'Approve', 'body' => '<p>approve(): failed to load page. "' . $page . '"</p>');
}
if (strpos($source, $pattern) === FALSE) {
return array('msg' => 'Approve', 'body' => '<p>approve(): pattern not match.</p>');
}
$source = str_replace($pattern, $replace, $source);
//return array('msg'=>'Approve', 'body'=>$source);
page_write($page, $source);
pkwk_headers_sent();
header('Location: ' . get_page_location_uri($page));
exit;
}
示例11: plugin_replace_tak_action
function plugin_replace_tak_action()
{
global $script, $post;
$pass = isset($post['pass']) ? $post['pass'] : NULL;
$prefix = isset($post['prefix']) ? $post['prefix'] : NULL;
$search = isset($post['search']) ? $post['search'] : PLUGIN_REPLACE_TAK_SEARCH_DEFAULT;
$replace = isset($post['replace']) ? $post['replace'] : NULL;
$act = isset($post['act']) ? $post['act'] : NULL;
$preserveTimeStamp = array_key_exists('preserveTimeStamp', $post) ? $post['preserveTimeStamp'] : NULL;
$changedpages = array();
$body = '';
$replace_real = stripcslashes($replace);
$preserveTimeStamp = $preserveTimeStamp != '' ? TRUE : FALSE;
$islogin = pkwk_login($pass);
// パスワード一致
if ($search != PLUGIN_REPLACE_TAK_SEARCH_DEFAULT && $islogin) {
$pages = get_existpages();
if ($prefix != NULL) {
$tmppages = array();
foreach ($pages as $page) {
if (preg_match($prefix, $page)) {
$tmppages[] = $page;
}
}
$pages = $tmppages;
}
natsort($pages);
foreach ($pages as $page) {
$postdata = '';
$count = 0;
$postdata_old = join('', get_source($page));
// キーワードの置換
$postdata = preg_replace($search, $replace_real, $postdata_old, -1, $count);
if ($count > 0) {
$changedpages[] = htmlspecialchars($page);
if ($act == 'Replace') {
set_time_limit(30);
page_write($page, $postdata, $preserveTimeStamp);
}
}
}
if ($act == 'Replace') {
$body = '<p>Completed.</p>';
}
}
if ($pass !== NULL && !$islogin) {
$body .= "<p><strong>Password error.</strong></p>\n";
}
$replacebutton = $islogin && count($changedpages) > 0 && ($act == 'Preview' || $act == 'Replace') ? '<input type="submit" name="act" value="Replace" />' : '';
$statTimeStamp = $preserveTimeStamp ? 'checked' : '';
$body .= <<<EOD
<p>Please input the keyword and password to replace.</p>
<form action="{$script}" method="post">
<div>
<input type="hidden" name="plugin" value="replace_tak" />
<p>Page Prefix (option, 'Regular Expression (Perl-Compatible)' needed)<br />
<input type="text" name="prefix" size="60" value="{$prefix}" /> </p>
<p>Search word ('Regular Expression (Perl-Compatible)' needed)<br />
<input type="text" name="search" size="60" value="{$search}" /></p>
<p>Replace word<br />
<input type="text" name="replace" size="60" value="{$replace}" /> </p>
<p>Password<br />
<input type="password" name="pass" size="12" value="{$pass}" /> </p>
<p><input type="checkbox" name="preserveTimeStamp" {$statTimeStamp} /> preserve time stamp</p>
<p><input type="submit" name="act" value="Preview" /> {$replacebutton}</p>
</div>
</form>
EOD;
if ($search != PLUGIN_REPLACE_TAK_SEARCH_DEFAULT) {
$body .= "<p>Target: " . count($changedpages) . " page(s).</p>\n";
}
if (count($changedpages) > 0) {
$body .= "<ul>\n";
foreach ($changedpages as $page) {
$body .= '<li>' . make_link($page) . "\n";
}
$body .= "</ul>\n";
}
return array('msg' => 'Replace with regular expression', 'body' => $body);
}
示例12: plugin_urlbookmark_action
function plugin_urlbookmark_action()
{
global $script, $vars, $post, $now;
if (auth::check_role('readonly')) {
die_message('PKWK_READONLY prohibits editing');
}
$post['msg'] = preg_replace("/\n/", '', $post['msg']);
$url = $post['url'];
if ($url == '') {
return array('msg' => '', 'body' => '');
}
$head = '';
if (preg_match('/^(-{1,2})(.*)/', $post['msg'], $match)) {
$head = $match[1];
$post['msg'] = $match[2];
}
$title = $post['title'];
if ($title == '') {
// try to get the title from the site
$title = plugin_urlbookmark_get_title($url);
}
if ($title == '') {
$_name = str_replace('$name', $url, URLBOOKMARK_NAME_FORMAT);
} else {
$patterns = array("/:/", "/\\[/", "/\\]/");
$replace = array(" ", "(", ")");
$title = preg_replace($patterns, $replace, $title);
$_name = str_replace('$name', '[[' . $title . ":" . $url . ']]', URLBOOKMARK_NAME_FORMAT);
}
$_msg = str_replace('$msg', $post['msg'], URLBOOKMARK_MSG_FORMAT);
$_now = $post['nodate'] == '1' ? '' : str_replace('$now', $now, URLBOOKMARK_NOW_FORMAT);
$urlbookmark = str_replace("MSG", $_msg, URLBOOKMARK_FORMAT);
$urlbookmark = str_replace("NAME", $_name, $urlbookmark);
$urlbookmark = str_replace("NOW", $_now, $urlbookmark);
$urlbookmark = $head . $urlbookmark;
$postdata = '';
$postdata_old = get_source($post['refer']);
$urlbookmark_no = 0;
$urlbookmark_ins = $post['above'] == '1';
foreach ($postdata_old as $line) {
if (!$urlbookmark_ins) {
$postdata .= $line;
}
if (preg_match('/^#urlbookmark/', $line) and $urlbookmark_no++ == $post['urlbookmark_no']) {
$postdata = rtrim($postdata) . "\n-{$urlbookmark}\n";
if ($urlbookmark_ins) {
$postdata .= "\n";
}
}
if ($urlbookmark_ins) {
$postdata .= $line;
}
}
$title = _(" \$1 was updated");
$body = '';
if (md5(@join('', get_source($post['refer']))) != $post['digest']) {
$title = _("On updating \$1, a collision has occurred.");
$body = _("It seems that someone has already updated this page while you were editing it.<br />") . _("It is likely to be inserted in a different position though it bookmarked.<br />") . make_pagelink($post['refer']);
}
page_write($post['refer'], $postdata);
$retvars['msg'] = $title;
$retvars['body'] = $body;
$post['page'] = $vars['page'] = $post['refer'];
return $retvars;
}
示例13: plugin_commentx_write
function plugin_commentx_write()
{
global $script, $vars, $now;
global $_no_name;
// global $_msg_comment_collided, $_title_comment_collided, $_title_updated;
$_title_updated = _("\$1 was updated");
$_title_comment_collided = _("On updating \$1, a collision has occurred.");
$_msg_comment_collided = _("It seems that someone has already updated the page you were editing.<br />") . _("The comment was added, alhough it may be inserted in the wrong position.<br />");
if (!isset($vars['msg'])) {
return array('msg' => '', 'body' => '');
}
// Do nothing
if (preg_match(PLUGIN_COMMENTX_NGWORD, $vars['msg'])) {
return array('msg' => '', 'body' => '');
}
// Validate
if (is_spampost(array('msg'))) {
return plugin_commentx_honeypot();
}
$vars['msg'] = preg_replace('/\\s+$/', "", $vars['msg']);
// Cut last LF
if (PLUGIN_COMMENTX_LINE_BREAK) {
// Convert linebreaks into pukiwiki's linebreaks &br;
$vars['msg'] = str_replace("\n", "&br;\n", $vars['msg']);
} else {
// Replace empty lines into #br
$vars['msg'] = preg_replace('/^\\s*\\n/m', "#br\n", $vars['msg']);
}
$head = '';
$match = array();
if (preg_match('/^(-{1,2})-*\\s*(.*)/', $vars['msg'], $match)) {
$head =& $match[1];
$vars['msg'] =& $match[2];
}
if ($vars['msg'] == '') {
return array('msg' => '', 'body' => '');
}
// Do nothing
$comment = str_replace('$msg', $vars['msg'], PLUGIN_COMMENTX_FORMAT_MSG);
list($nick, $vars['name'], $disabled) = plugin_commentx_get_nick();
if (isset($vars['name']) || $vars['nodate'] != '1') {
$_name = !isset($vars['name']) || $vars['name'] == '' ? $_no_name : $vars['name'];
$_name = $_name == '' ? '' : str_replace('$name', $_name, PLUGIN_COMMENTX_FORMAT_NAME);
$_now = $vars['nodate'] == '1' ? '' : str_replace('$now', $now, PLUGIN_COMMENTX_FORMAT_NOW);
$comment = str_replace("MSG", $comment, PLUGIN_COMMENTX_FORMAT_STRING);
$comment = str_replace("NAME", $_name, $comment);
$comment = str_replace("NOW", $_now, $comment);
}
$comment = '-' . $head . ' ' . $comment;
$postdata = '';
$comment_no = 0;
$above = isset($vars['above']) && $vars['above'] == '1';
foreach (get_source($vars['refer']) as $line) {
if (!$above) {
$postdata .= $line;
}
if (preg_match('/^#commentx/i', $line) && $comment_no++ == $vars['comment_no']) {
if ($above) {
$postdata = rtrim($postdata) . "\n" . $comment . "\n" . "\n";
// Insert one blank line above #commment, to avoid indentation
} else {
$postdata = rtrim($postdata) . "\n" . $comment . "\n";
// Insert one blank line below #commment
}
}
if ($above) {
$postdata .= $line;
}
}
$title = $_title_updated;
$body = '';
if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
$title = $_title_comment_collided;
$body = $_msg_comment_collided . make_pagelink($vars['refer']);
}
page_write($vars['refer'], $postdata);
$retvars['msg'] = $title;
$retvars['body'] = $body;
if ($vars['refpage']) {
header("Location: {$script}?" . rawurlencode($vars['refpage']));
exit;
}
$vars['page'] = $vars['refer'];
return $retvars;
}
示例14: paint_insert_ref
function paint_insert_ref($filename)
{
global $script, $vars, $now, $do_backup;
global $_paint_messages, $_no_name;
$ret['msg'] = $_paint_messages['msg_title'];
$msg = mb_convert_encoding(rtrim($vars['msg']), SOURCE_ENCODING, 'auto');
$name = mb_convert_encoding($vars['yourname'], SOURCE_ENCODING, 'auto');
$msg = str_replace('$msg', $msg, PAINT_MSG_FORMAT);
$name = $name == '' ? $_no_name : $vars['yourname'];
$name = $name == '' ? '' : str_replace('$name', $name, PAINT_NAME_FORMAT);
$now = str_replace('$now', $now, PAINT_NOW_FORMAT);
$msg = trim($msg);
$msg = $msg == '' ? PAINT_FORMAT_NOMSG : str_replace("MSG", $msg, PAINT_FORMAT);
$msg = str_replace("NAME", $name, $msg);
$msg = str_replace("NOW", $now, $msg);
//ブロックに食われないように、#clearの直前に\nを2個書いておく
$msg = "#ref({$filename},wrap,around)\n" . trim($msg) . "\n\n" . "#clear\n";
$postdata_old = get_source($vars['refer']);
$postdata = '';
$paint_no = 0;
//'#paint'の出現回数
foreach ($postdata_old as $line) {
if (!PAINT_INSERT_INS) {
$postdata .= $line;
}
if (preg_match('/^#paint/i', $line)) {
if ($paint_no == $vars['paint_no']) {
$postdata .= $msg;
}
$paint_no++;
}
if (PAINT_INSERT_INS) {
$postdata .= $line;
}
}
// 更新の衝突を検出
if (md5(join('', $postdata_old)) != $vars['digest']) {
$ret['msg'] = $_paint_messages['msg_title_collided'];
$ret['body'] = $_paint_messages['msg_collided'];
}
page_write($vars['refer'], $postdata);
return $ret;
}
示例15: adm_auth_wkgrp_import
function adm_auth_wkgrp_import()
{
global $_adm_auth_wkgrp_msg;
$config_page_name = ':config/' . CONFIG_AUTH_WKGRP;
// 処理中に誰かがページを作成した場合にしか発生しないはず
if (is_page($config_page_name)) {
return $_adm_auth_wkgrp_msg['err_already'];
}
$data = "#check_role(2)\n" . adm_auth_wkgrp_file2page();
// このイメージをページに出力
page_write($config_page_name, $data);
// php ファイルのタイムスタンプとページを一致させる
adm_auth_wkgrp_touch_file2page();
return sprintf($_adm_auth_wkgrp_msg['msg_ok_import'], $config_page_name);
}