function plugin_feed_action() { global $vars, $site_name, $site_logo, $modifier, $modifierlink, $_feed_msg, $cache; $type = isset($vars['type']) ? $vars['type'] : 'rss'; $refer = isset($vars['refer']) ? $vars['refer'] : null; Recent::getFeed($refer, $type); exit; }
function plugin_recent_convert() { global $vars, $date_format, $link_compact, $page_title; // , $_recent_plugin_frame; static $exec_count = 1; global $cache; if (empty($vars['page'])) { return null; } $recent_lines = PLUGIN_RECENT_DEFAULT_LINES; $args = func_get_args(); if (!empty($args)) { if (isset($args[1]) || !is_numeric($args[0])) { return PLUGIN_RECENT_USAGE . '<br />'; } $recent_lines =& $args[0]; } if ($exec_count++ > PLUGIN_RECENT_EXEC_LIMIT) { return '<div class="alert alert-warning">#recent(): You called me too much.</div>' . "\n"; } $date = ''; $items = array(); $lines = Recent::get(); if ($lines !== null) { $count = count($lines) < $recent_lines ? count($lines) : $recent_lines; $i = 0; foreach ($lines as $page => $time) { $wiki = Factory::Wiki($page); if (!$wiki->isReadable()) { continue; } //if (! $wiki->isHidden()) continue; if ($i > $count) { break; } $s_page = Utility::htmlsc($page); $_date = get_date($date_format, $time); if (!IS_MOBILE) { if ($page === $vars['page']) { // No need to link to the page you just read, or notify where you just read $items[$_date][] = ' <li>' . $s_page . '</li>'; } else { $passage = !$link_compact ? ' ' . $wiki->passage(false, true) : ''; $items[$_date][] = ' <li><a href="' . $wiki->uri() . '" title="' . $s_page . $passage . '">' . $s_page . '</a></li>'; } } else { if ($date !== $_date) { // New day $date = $_date; $items[] = '<li data-role="list-divider">' . $date . '</li>'; } if ($page === $vars['page']) { // No need to link to the page you just read, or notify where you just read $items[] = ' <li data-theme="e">' . $s_page . '</li>'; } else { $passage = !$link_compact ? ' ' . '<span class="ui-li-count">' . $wiki->passage(false, false) . '</span>' : ''; $items[] = ' <li><a href="' . $wiki->uri() . '" data-transition="slide">' . $s_page . $passage . '</a></li>'; } } $i++; } unset($lines, $i); } $_recent_title = sprintf(T_('recent(%d)'), $count); if (!IS_MOBILE) { // End of the day $ret[] = '<div class="plugin-recent">'; $ret[] = '<h5>' . $_recent_title . '</h5>'; $ret[] = '<div class="hslice" id="webslice">'; $ret[] = '<span class="entry-title" style="display:none;">' . $page_title . '</span>'; $ret[] = '<div class="entry-content">'; $ret[] = '<ul class="list-unstyled">'; foreach ($items as $date => $entries) { $ret[] = '<li><strong>' . $date . '</strong><ul>'; foreach ($entries as $entry) { $ret[] = $entry; } $ret[] = '</ul></li>'; } $ret[] = '</ul>'; $ret[] = '</div>'; $ret[] = '</div>'; $ret[] = '</div>'; return join("\n", $ret); } else { return '<ul data-role="listview" data-dividertheme="b">' . "\n" . '<li data-theme="a">' . $_recent_title . '</li>' . "\n" . join("\n", $items) . '</ul>' . "\n"; } }
function put_lastmodified() { //trigger_error('put_lastmodified() is deprecated. use FileUtility::get_recent(true).', E_USER_DEPRECATED ); Recent::get(true); }
/** * ページを書き込む * @param string $str 書き込むデーター * @param boolean $notimestamp タイムスタンプを更新するかのフラグ * @return void */ public function set($str, $keeptimestamp = false) { global $use_spam_check, $_string, $vars, $_title, $whatsnew, $whatsdeleted; // roleのチェック if (Auth::check_role('readonly')) { return; } // Do nothing if (Auth::is_check_role(PKWK_CREATE_PAGE)) { Utility::dieMessage(sprintf($_strings['error_prohibit'], 'PKWK_READONLY'), 403); } // 簡易スパムチェック(不正なエンコードだった場合ここでエラー) if (isset($vars['encode_hint']) && $vars['encode_hint'] !== PKWK_ENCODING_HINT) { Utility::dump(); Utility::dieMessage($_string['illegal_chars'], 403); } // ポカミス対策:配列だった場合文字列に変換 if (is_array($str)) { $str = join("\n", $str); } // 入力データーを整形(※string型です) $postdata = Rules::make_str_rules($str); // 過去のデーターを取得 $oldpostdata = self::has() ? self::get(TRUE) : ''; // 差分を生成(ここでの差分データーはAkismetでも使う) $diff = new Diff($oldpostdata, $postdata); $diffobj = new LineDiff(); $diffdata = $diffobj->str_compare($oldpostdata, $postdata); // ログイン済みもしくは、自動更新されるページである $has_not_permission = Auth::check_role('role_contents_admin'); // 未ログインの場合、S25Rおよび、DNSBLチェック if ($has_not_permission) { $ip_filter = new IpFilter(); //if ($ip_filter->isS25R()) Utility::dieMessage('S25R host is denied.'); // 簡易スパムチェック if (Utility::isSpamPost()) { Utility::dump(); Utility::dieMessage('Writing was limited. (Blocking SPAM)'); } if (isset($use_spam_check['page_remote_addr']) && $use_spam_check['page_remote_addr'] !== 0) { // DNSBLチェック $listed = $ip_filter->checkHost(); if ($listed !== false) { Utility::dump('dnsbl'); Utility::dieMessage(sprintf($_strings['prohibit_dnsbl'], $listed), $_title['prohibit'], 400); } } if (isset($use_spam_check['page_contents']) && $use_spam_check['page_contents'] !== 0) { // URLBLチェック $reason = self::checkUriBl($diff); if ($reason !== false) { Utility::dump($reason); Utility::dieMessage($_strings['prohibit_uribl'], $_title['prohibit'], 400); } } // 匿名プロクシ if ($use_spam_check['page_write_proxy'] && ProxyChecker::is_proxy()) { Utility::dump('proxy'); Utility::dieMessage($_strings['prohibit_proxy'], $_title['prohibit'], 400); } // Akismet global $akismet_api_key; if (isset($use_spam_check['akismet']) && $use_spam_check['akismet'] !== 0 && !empty($akismet_api_key)) { $akismet = new Akismet($akismet_api_key, Router::get_script_absuri()); if ($akismet->verifyKey($akismet_api_key)) { // 送信するデーターをセット $akismet_post = array('user_ip' => REMOTE_ADDR, 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'comment_type' => 'comment', 'comment_author' => isset($vars['name']) ? $vars['name'] : 'Anonymous', 'comment_content' => $postdata); // if ($use_spam_check['akismet'] === 1){ // // 差分のみをAkismetに渡す // foreach ($diff->getSes() as $key=>$line){ // if ($key !== $diff::SES_ADD) continue; // $added_data[] = $line; // } // $akismet_post['comment_content'] = join("\n",$added_data); // unset($added_data); // } if ($akismet->isSpam($akismet_post)) { Utility::dump('akismet'); Utility::dieMessage($_strings['prohibit_akismet'], $_title['prohibit'], 400); } } else { Utility::dieMessage('Akismet API key does not valied.', 500); } } // captcha check if (isset($use_spam_check['captcha']) && $use_spam_check['captcha'] !== 0) { Captcha::check(false); } } // 現時点のページのハッシュを読む $old_digest = $this->wiki->has() ? $this->wiki->digest() : 0; // オリジナルが送られてきている場合、Wikiへの書き込みを中止し、競合画面を出す。 // 現時点のページのハッシュと、送信されたページのハッシュを比較して異なる場合、 // 自分が更新している間に第三者が更新した(=競合が起きた)と判断する。 $collided = isset($vars['digest']) && $old_digest !== 0 && $vars['digest'] !== $old_digest; if ($collided && isset($vars['original'])) { return array('msg' => $_string['title_collided'], 'body' => $_string['msg_collided'] . Utility::showCollision($oldpostdata, $postdata, $vars['original']) . Utility::editForm($this->page, $postdata, false)); } // add client info to diff // $diffdata[] = '// IP:"'. REMOTE_ADDR . '" TIME:"' . UTIME . '" REFERER:"' . $referer . '" USER_AGENT:"' . $user_agent. "\n"; FileFactory::Diff($this->page)->set($diffdata); unset($oldpostdata, $diff, $diffdata); // Logging postdata (Plus!) if (self::POST_LOGGING === TRUE) { Utility::dump(self::POST_LOG_FILENAME); } // 入力が空の場合、削除とする if (empty($str)) { // Wikiページを削除 $ret = $this->wiki->set(''); Recent::set($this->page, true); } else { // Wikiを保存 $ret = $this->wiki->set($postdata, $keeptimestamp); // 最終更新を更新 Recent::set($this->page); } if ($this->page !== $whatsnew || $this->page !== $whatsdeleted || !$this->isHidden()) { // バックアップを更新 Factory::Backup($this->page)->set(); // 更新ログをつける LogFactory::factory('update', $this->page)->set(); if (!$keeptimestamp && !empty($str)) { // weblogUpdates.pingを送信 $ping = new Ping($this->page); $ping->send(); } } // 簡易競合チェック if ($collided) { return array('msg' => $_string['title_collided'], 'body' => $_string['msg_collided_auto']); } }
/** * Returns a list of recent changes since given timestamp. * timestamp(UTC)以降に更新されたページのリストを得る。 * @param string $timestamp 時刻 * @return array */ public function getRecentChanges($timestamp = 0) { $ret = array(); $recents = Recent::get(); if ($timestamp === 0) { return array_keys($recents); } foreach ($recents as $page => $time) { if ($time < $timestamp) { continue; } $ret[] = $page; } return $ret; }
function plugin_mixirss_action() { global $vars, $get, $post, $rss_max, $rss_description, $page_title, $whatsnew; global $modifier; global $exclude_plugin; global $memcache; $version = isset($vars['ver']) ? $vars['ver'] : ''; switch ($version) { case '': $version = '1.0'; break; // mixi Default // mixi Default case '1': $version = '1.0'; break; case '2': $version = '2.0'; break; case '0.91': /* FALLTHROUGH */ /* FALLTHROUGH */ case '1.0': /* FALLTHROUGH */ /* FALLTHROUGH */ case '2.0': break; default: die('Invalid RSS version!!'); } // Official Main routine ... $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING); $rss_description_utf8 = mb_convert_encoding(htmlspecialchars($rss_description), 'UTF-8', SOURCE_ENCODING); // Disable plugin $exclude_plugin[] = 'include'; $self = get_script_absuri(); change_uri('', 1); // Force absoluteURI. // Creating <item> $items = $rdf_li = ''; foreach (Recent::get() as $page => $time) { $wiki = Factory::Wiki($page); $r_page = rawurlencode($page); $url = $wiki->uri(); $title = mb_convert_encoding($page, 'UTF-8', SOURCE_ENCODING); switch ($version) { case '0.91': /* FALLTHROUGH */ /* FALLTHROUGH */ case '2.0': $date = get_date('D, d M Y H:i:s T', $time); $date = $version == '0.91' ? ' <description>' . $date . '</description>' : ' <pubDate>' . $date . '</pubDate>'; $items .= <<<EOD <item> <title>{$title}</title> <link>{$url}</link> {$date} </item> EOD; break; case '1.0': // Add <item> into <items> // $rdf_li .= ' <rdf:li rdf:resource="' . $url . '" />' . "\n"; $date = substr_replace(get_date('Y-m-d\\TH:i:sO', $time), ':', -2, 0); if (plugin_mixirss_isValidDate(substr($page, -10)) && check_readable($page, false, false)) { // for Calendar/MiniCalendar $get['page'] = $post['page'] = $vars['page'] = $page; $source = get_source($page); $rdf_hx = ''; $rdf_lx = ''; $itemhx = ''; $itemlx = ''; while (!empty($source)) { $line = array_shift($source); if (preg_match('/^(\\*{1,3})(.*)\\[#([A-Za-z][\\w-]+)\\](.*)$/m', $line, $matches)) { $anchortitle = strip_htmltag(RendererFactory::factory($matches[2])); $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle); $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>'; $sharp = '#'; $rdf_hx .= ' <rdf:li rdf:resource="' . $url . $sharp . $matches[3] . '" />' . "\n"; $itemhx .= <<<EOD <item rdf:about="{$url}{$sharp}{$matches[3]}"> <title>{$anchortitle}</title> <link>{$url}{$sharp}{$matches[3]}</link> <dc:date>{$date}</dc:date> <dc:identifier>{$url}{$sharp}{$matches[3]}</dc:identifier> </item> EOD; } else { if (preg_match('/^(\\-{1,3})(.*)$/m', $line, $matches)) { $anchortitle = strip_htmltag(RendererFactory::factory($matches[2])); $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle); $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>'; $sharp = '#'; $rdf_lx .= ' <rdf:li rdf:resource="' . $url . '" />' . "\n"; $itemlx .= <<<EOD <item rdf:about="{$url}"> <title>{$anchortitle}</title> <link>{$url}</link> <dc:date>{$date}</dc:date> <dc:identifier>{$url}</dc:identifier> </item> EOD; } } } if ($itemhx != '') { $rdf_li .= $rdf_hx; $items .= $itemhx; } else { if ($itemlx != '') { $rdf_li .= $rdf_lx; $items .= $itemlx; } else { // default $rdf_li .= ' <rdf:li rdf:resource="' . $url . '" />' . "\n"; $items .= <<<EOD <item rdf:about="{$url}"> <title>{$title}</title> <link>{$url}</link> {$description} <dc:date>{$date}</dc:date> <dc:identifier>{$url}</dc:identifier> </item> EOD; } } // upk 2006-03-22 // } else if (check_readable($page,false,false) && !ereg(MIXIRSS_IGNORE_REGEX, $page)) { } else { if ($wiki->isReadable()) { $get['page'] = $post['page'] = $vars['page'] = $page; //miko added $description = strip_htmltag($wiki->render()); $description = mb_strimwidth(preg_replace("/[\r\n]/", ' ', $description), 0, MIXIRSS_DESCRIPTION_LENGTH, '...'); $description = ' <description><![CDATA[' . mb_convert_encoding($description, 'UTF-8', SOURCE_ENCODING) . ']]></description>'; //miko added $rdf_li .= ' <rdf:li rdf:resource="' . $url . '" />' . "\n"; global $newtitle, $newbase; if (isset($newbase) && $newbase != '') { $anchortitle = $newtitle . ' (' . $title . ')'; $newtitle = $newbase = ''; } else { $anchortitle = $title; } $items .= <<<EOD <item rdf:about="{$url}"> <title>{$anchortitle}</title> <link>{$url}</link> {$description} <dc:date>{$date}</dc:date> <dc:identifier>{$url}</dc:identifier> </item> EOD; } } break; } } // Feeding start $html = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $w_whatsnew = Factory::Wiki($whatsnew); $url_whatsnew = $w_whatsnew->uri(); switch ($version) { case '0.91': $html .= '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' . ' "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n"; /* FALLTHROUGH */ /* FALLTHROUGH */ case '2.0': $html .= <<<EOD <rss version="{$version}"> <channel> <title><![CDATA[{$page_title_utf8}]]></title> <link>{$url_whatsnew}</link> <description><![CDATA[{$rss_description_utf8}]]></description> <language>ja</language> {$items} </channel> </rss> EOD; break; case '1.0': $html .= <<<EOD <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:lang="ja"> <channel rdf:about="{$url_whatsnew}"> <title><![CDATA[{$page_title_utf8}]]></title> <link>{$url_whatsnew}</link> <description><![CDATA[{$rss_description_utf8}]]></description> <items> <rdf:Seq> {$rdf_li} </rdf:Seq> </items> </channel> {$items} </rdf:RDF> EOD; break; } $header = Header::getHeaders('application/xml', $w_whatsnew->time()); Header::writeResponse($header, 200, $html); exit; }