/** * リダイレクトプラグイン * * @copyright Copyright © 2006,2008, Katsumi Saito <*****@*****.**> * @version $Id: redirect.inc.php,v 0.3 2008/01/06 05:35:00 upk Exp $ * @license http://opensource.org/licenses/gpl-license.php GNU Public License * */ function plugin_redirect_action() { global $vars; if (empty($vars['u'])) { return ''; } // 自サイトからのリダイレクトのみ飛ばす if (path_check($_SERVER['HTTP_REFERER'], get_script_absuri())) { // 以下の方法は、NG です。 // <a href="javascript:location.replace('URL');">Caption</a> //header('Location: ' . $vars['u'] ); //die(); $time = 0; echo <<<EOD <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> <head> <meta http-equiv="Refresh" content="{$time};URL={$vars['u']}" /> <title>Auto Redirect</title> </head> <body> <div><a href="{$vars['u']}">Please click here.</a></div> </body> </html> EOD; die; } return ''; }
function sbm_make($cmd, &$info) { global $vars, $_sbm_msg; $title = rawurlencode($vars['page']); $link = get_page_absuri($vars['page']); $rlink = rawurlencode($link); $rtlink = rawurlencode(get_script_absuri() . '?') . $title; // url switch ($cmd) { case 'twitter': if (exist_plugin_inline('bitly')) { $val = bitly_convert('shorten', $link); $rlink = !$val['rc'] ? 'N/A' : $val['msg']; $url = str_replace('$link', $rlink, $info['url']); } else { $url = $info['url']; } break; default: $url = $info['url']; } $width = empty($info['width']) ? '16' : $info['width']; $height = empty($info['height']) ? '16' : $info['height']; $msg_alt = isset($info['msg']) ? $info['msg'] : 'msg_alt'; $alt = sprintf($_sbm_msg[$msg_alt], $info['name']); // img switch ($cmd) { case 'yahoo_jp_entry': $img = str_replace('$rlink', $link, $info['img']); break; case 'livedoor_entry': $img = str_replace('$link', $link, $info['img']); $alt = ''; break; default: $img = $info['img']; } // Conversion processing $url = str_replace('$title', $title, $url); $url = str_replace('$link', $link, $url); $url = str_replace('$rlink', $rlink, $url); $url = str_replace('$rtlink', $rtlink, $url); $retval = <<<EOD <a href="{$url}"> <img src="{$img}" width="{$width}" height="{$height}" style="border: none;" alt="{$alt}" title="{$alt}" /> </a> EOD; switch ($cmd) { case 'hatena_entry': $retval .= '<img src="http://b.hatena.ne.jp/entry/image/' . $link . '" alt="counter"/>'; } return $retval; }
function plugin_redirect_action() { global $vars; if (empty($vars['u'])) { return ''; } // 自サイトからのリダイレクトのみ飛ばす if (path_check($_SERVER['HTTP_REFERER'], get_script_absuri())) { Utility::redirect($vars['u']); } return ''; }
function is_requestable($uri) { $arr1 = parse_url(get_script_absuri()); $arr2 = parse_url($uri); $arr1['port'] = isset($arr1['port']) ? $arr1['port'] : 80; $arr2['port'] = isset($arr2['port']) ? $arr2['port'] : 80; $arr1['path'] = isset($arr1['path']) ? dirname($arr1['path'] . 'dummy') : '/'; $arr2['path'] = isset($arr2['path']) ? dirname($arr2['path'] . 'dummy') : '/'; if ($arr1['scheme'] != $arr2['scheme'] || $arr1['host'] != $arr2['host'] || $arr1['port'] != $arr2['port'] || $arr1['path'] != $arr2['path']) { return TRUE; } return FALSE; }
function set_language() { global $language_considering_setting_level; global $language; global $public_holiday_guest_view; $language = get_language($language_considering_setting_level); // LANG - Internal content encoding ('en', 'ja', or ...) define('LANG', $language); // Set COOKIE['lang'] $parsed_url = parse_url(get_script_absuri()); $path = $parsed_url['path']; if (($pos = strrpos($path, '/')) !== FALSE) { $path = substr($path, 0, $pos + 1); } setcookie('lang', $language, 0, $path); $_COOKIE['lang'] = $language; // PUBLIC HOLIDAY // Installation person's calendar is adopted. if ($public_holiday_guest_view) { $_c = split('_', $language); } else { // 設置者のカレンダーを採用 $_c = split('_', DEFAULT_LANG); } define('COUNTRY', $_c[1]); unset($_c); // FIXME: // UI_LANG - Content Language for buttons, menus, etc define('UI_LANG', LANG); // 'en' for Internationalized wikisite // LANG_ENCODING - content encoding ('', 'UTF-8', or ...) define('LANG_ENCODING', 'UTF-8'); // I18N // LOCALE Name specified by GETTEXT(). define('DOMAIN', 'pukiwiki'); // LOCALE Name specified by SETLOCALE(). if (!defined('PO_LANG')) { define('PO_LANG', $language); // 'en_US', 'ja_JP' } // PHP mbstring process. set_mbstring($language); }
/** * tzCalculation_LocalTimeZone Plugin * * @copyright Copyright © 2006,2008, Katsumi Saito <*****@*****.**> * @version $Id: tz.inc.php,v 0.3 2008/08/30 21:38:00 upk Exp $ * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @link http://www.desisoftsystems.com/white-papers/timeZoneCalculation/ */ function plugin_tz_convert() { global $use_local_time; if ($use_local_time) { return ''; } if (isset($_COOKIE['timezone'])) { return ''; } $url = parse_url(get_script_absuri()); if (empty($url['host'])) { return ''; } return <<<EOD <script type="text/javascript"> <!-- tzCalculation_LocalTimeZone ('{$url['host']}',false); --> </script> EOD; }
function plugin_ajaxrss_output_xml() { global $page_title; $lang = LANG; $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING); $self = get_script_absuri(); $version = '0.91'; $items = ''; foreach (get_source('RSS') as $line) { if (preg_match('/\\[(' . '(?:(?:https?|ftp|news):\\/\\/|\\.\\.?\\/)' . '[!~*\'();\\/?:\\@&=+\\$,%#\\w.-]*)\\s([^\\]]+)\\]\\s?([^\\s]*)/', $line, $matches)) { $title = $matches[2]; $link = $self . '?cmd=ajaxrss&t=url&q=' . encode($matches[1]); $desc = $matches[3]; $items .= <<<EOD <item> <title>{$title}</title> <link>{$link}</link> <description>{$desc}</description> </item> EOD; } } $rssxml = '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' . ' "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n"; $rssxml .= <<<EOD <rss version="{$version}"> <channel> <title>{$page_title_utf8}</title> <link>{$self}</link> <description>AjaxRSS Sample</description> <language>{$lang}</language> {$items} </channel> </rss> EOD; return $rssxml; }
function typekey_logout_url($return = '') { if (empty($return)) { $return = get_script_absuri(); } // return TYPEKEY_URL_LOGOUT.'?_return='.$return; return TYPEKEY_URL_LOGOUT . '?to=' . $return; }
function get_script_uri($path = '') { global $absolute_uri, $script_directory_index; if ($absolute_uri) { return get_script_absuri(); } $uri = get_baseuri($path); if (!isset($script_directory_index)) { $uri .= init_script_filename(); } return $uri; }
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; }
function plugin_rss_action() { global $vars, $rss_max, $rss_description, $page_title, $whatsnew, $trackback; $version = isset($vars['ver']) ? $vars['ver'] : '2.0'; switch ($version) { case '1': $version = '1.0'; break; // Sugar // Sugar case '2': $version = '2.0'; break; // Sugar // Sugar case '0.91': /* FALLTHROUGH */ /* FALLTHROUGH */ case '1.0': /* FALLTHROUGH */ /* FALLTHROUGH */ case '2.0': default: break; } $lang = LANG; $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING); $self = get_script_absuri(); $rss_description_utf8 = mb_convert_encoding(htmlspecialchars($rss_description), 'UTF-8', SOURCE_ENCODING); // Creating <item> $items = $rdf_li = ''; $recent = CACHE_DIR . PKWK_MAXSHOW_CACHE; if (!file_exists($recent)) { die('PKWK_MAXSHOW_CACHE is not found'); } foreach (file_head($recent, $rss_max) as $line) { list($time, $page) = explode("\t", rtrim($line)); $items .= plugin_rss_generate_item($version, $time, $page); } // Feeding start pkwk_common_headers($time); // header('Content-type: application/xml'); header('Content-type: text/html'); print '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $url_whatsnew = get_page_absuri($whatsnew); switch ($version) { case '0.91': print '<!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': print <<<EOD <rss version="{$version}"> \t<channel> \t\t<title><![CDATA[{$page_title_utf8}]]></title> \t\t<link>{$url_whatsnew}</link> \t\t<description><![CDATA[{$rss_description_utf8}]]></description> \t\t<language>{$lang}</language> {$items} \t</channel> </rss> EOD; break; case '1.0': $xmlns_trackback = $trackback ? 'xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"' : ''; print <<<EOD <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" {$xmlns_trackback} xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:lang="{$lang}"> \t<channel rdf:about="{$url_whatsnew}"> \t\t<title><![CDATA[{$page_title_utf8}]]></title> \t\t<link>{$url_whatsnew}</link> \t\t<description><![CDATA[{$rss_description_utf8}]]></description> \t\t<items> \t\t\t<rdf:Seq> {$rdf_li} \t\t\t</rdf:Seq> \t\t</items> \t</channel> {$items} </rdf:RDF> EOD; break; } exit; }
function plugin_typekey_jump_url() { global $auth_api, $vars; $page = get_script_absuri() . rawurlencode('?plugin=typekey'); if (!empty($vars['page'])) { $page .= rawurlencode('&page=' . $vars['page']); } $obj = new AuthTypekey($auth_api['typekey']['site_token']); $obj->set_need_email($auth_api['typekey']['need_email']); return $obj->typekey_login_url($page); }
</div> <?php } ?> <div id="footer"> <table id="footertable" border="0" cellspacing="0" cellpadding="0"> <tr> <td id="footerltable"> <?php if (exist_plugin_inline('qrcode')) { ?> <?php $a_page = str_replace('%', '%25', $r_page); echo plugin_qrcode_inline(1, get_script_absuri() . '?' . $a_page); ?> <?php } ?> </td> <td id="footerctable"><div id="sigunature"> Founded by <a href="<?php echo $modifierlink; ?> "><?php echo $modifier; ?> </a>. <br /> Powered by PukiWiki Plus! <?php
function plugin_amazon_action() { global $vars, $script; global $amazon_body; global $_amazon_msg; $check = new amazon_check_asin(htmlspecialchars(rawurlencode(strip_bracket($vars['asin'])))); if (!$check->is_asin) { $retvars['msg'] = $_amazon_msg['msg_BookReviewEdit']; $retvars['refer'] = $vars['refer']; $s_page = $vars['refer']; $r_page = $s_page . '/' . $check->asin; $retvars['body'] = plugin_amazon_convert(); return $retvars; } $s_page = $vars['refer']; $r_page = $s_page . '/' . $check->asin; // $r_page_url = rawurlencode($r_page); if (!check_readable($r_page, false, false)) { header('Location: ' . get_page_location_uri($r_page)); } elseif (check_editable($r_page, false, false)) { $info = new amazon_getinfo($check->asin, 'heavy'); $title = $info->items['title']; if ($title == '' or preg_match('/^\\//', $s_page)) { header('Location: ' . get_script_absuri() . '?' . encode($s_page)); } $body = "#amazon({$check->asin},,image)\n*{$title}\n" . $amazon_body; amazon_review_save($r_page, $body); header('Location: ' . get_location_uri('edit', $r_page)); } else { return false; } die; }
function pkwk_spamnotify($action, $page, $target = array('title' => ''), $progress = array(), $method = array()) { global $notify, $notify_spam, $notify_subject; if (!$notify) { return; } if (!$notify_spam) { honeypot_write(); return; } $asap = isset($method['asap']); $summary['ACTION'] = 'Blocked by: ' . summarize_spam_progress($progress, TRUE); if (!$asap) { $summary['METRICS'] = summarize_spam_progress($progress); } $tmp = summarize_detail_badhost($progress); if ($tmp != '') { $summary['DETAIL_BADHOST'] = $tmp; } $tmp = summarize_detail_newtral($progress); if (!$asap && $tmp != '') { $summary['DETAIL_NEUTRAL_HOST'] = $tmp; } $summary['COMMENT'] = $action; $summary['PAGE'] = '[blocked] ' . (is_pagename($page) ? $page : ''); $summary['URI'] = get_script_absuri() . '?' . rawurlencode($page); $summary['USER_AGENT'] = TRUE; $summary['REMOTE_ADDR'] = TRUE; pkwk_mail_notify($notify_subject, var_export($target, TRUE), $summary, TRUE); }
function is_ignore($link) { static $my, $ignore_link; if (!isset($my)) { $my = get_script_absuri(); } if (!isset($ignore_link)) { $ignore_link = array($my . '?cmd=edit&page=', $my . '?cmd=attach', $my . '?plugin=attach'); } foreach ($ignore_link as $ignore) { if (strpos($link, $ignore) !== FALSE) { return TRUE; } } return FALSE; }
function tb_get_rdf($page) { $_script = get_script_absuri(); // Get absolute path $r_page = rawurlencode($page); $tb_id = tb_get_id($page); // $dcdate = substr_replace(get_date('Y-m-d\TH:i:sO', $time), ':', -2, 0); // dc:date="$dcdate" return <<<EOD <!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> <rdf:Description rdf:about="{$_script}?{$r_page}" dc:identifier="{$_script}?{$r_page}" dc:title="{$page}" trackback:ping="{$_script}?tb_id={$tb_id}" /> </rdf:RDF> --> EOD; }
function print_qr_code($page) { if (!exist_plugin_inline('qrcode')) { return ''; } $script = get_script_absuri(); $r_page = rawurlencode($page); $a_script = $script; $a_script = str_replace("\\", "\\\\", $a_script); $a_script = str_replace(':', '\\:', $a_script); $a_script = str_replace(';', '\\;', $a_script); $a_script = str_replace(',', '\\,', $a_script); $a_page = str_replace('%', '%25', $r_page); return plugin_qrcode_inline(1, $script . '?' . $a_page); }
function attach_doupload(&$file, $page, $pass = NULL, $temp = '', $copyright = FALSE, $notouch = FALSE) { global $_attach_messages; global $notify, $notify_subject, $notify_exclude, $spam; $type = get_mimeinfo($file['tmp_name']); $must_compress = attach_is_compress($type, PLUGIN_ATTACH_UNKNOWN_COMPRESS); if ($must_compress) { // if attach spam, filtering attach file. $vars['uploadname'] = $file['name']; $vars['uploadtext'] = attach_gettext($file['tmp_name']); if ($vars['uploadtext'] === '' || $vars['uploadtext'] === FALSE) { return FALSE; } //global $spam; if ($spam !== 0) { if (isset($spam['method']['attach'])) { $_method =& $spam['method']['attach']; } else { if (isset($spam['method']['_default'])) { $_method =& $spam['method']['_default']; } else { $_method = array(); } } $exitmode = isset($spam['exitmode']) ? $spam['exitmode'] : ''; pkwk_spamfilter('File Attach', $page, $vars, $_method, $exitmode); } } if ($must_compress && is_uploaded_file($file['tmp_name'])) { if (PLUGIN_ATTACH_COMPRESS_TYPE == 'TGZ' && exist_plugin('dump')) { $obj =& new AttachFile($page, $file['name'] . '.tgz'); if ($obj->exist) { return array('result' => FALSE, 'msg' => $_attach_messages['err_exists']); } $tar = new tarlib(); $tar->create(CACHE_DIR, 'tgz') or die_message(_("It failed in the generation of a temporary file.")); $tar->add_file($file['tmp_name'], $file['name']); $tar->close(); @rename($tar->filename, $obj->filename); chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE); @unlink($tar->filename); } else { if (PLUGIN_ATTACH_COMPRESS_TYPE == 'GZ' && extension_loaded('zlib')) { $obj =& new AttachFile($page, $file['name'] . '.gz'); if ($obj->exist) { return array('result' => FALSE, 'msg' => $_attach_messages['err_exists']); } $tp = fopen($file['tmp_name'], 'rb') or die_message(_("The uploaded file cannot be read.")); // アップロードされたファイルが読めません。 $zp = gzopen($obj->filename, 'wb') or die_message(_("The compression file cannot be written.")); // 圧縮ファイルが書けません。 while (!feof($tp)) { gzwrite($zp, fread($tp, 8192)); } gzclose($zp); fclose($tp); chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE); @unlink($file['tmp_name']); } else { if (PLUGIN_ATTACH_COMPRESS_TYPE == 'ZIP' && class_exists('ZipArchive')) { $obj =& new AttachFile($page, $file['name'] . '.zip'); if ($obj->exist) { return array('result' => FALSE, 'msg' => $_attach_messages['err_exists']); } $zip = new ZipArchive(); $zip->addFile($file['tmp_name'], $file['name']); // if ($zip->status !== ZIPARCHIVE::ER_OK) if ($zip->status !== 0) { die_message(_('The error occurred') . '(' . $zip->status . ').'); } $zip->close(); chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE); @unlink($file['tmp_name']); } } } } else { //miko $obj =& new AttachFile($page, $file['name']); if ($obj->exist) { return array('result' => FALSE, 'msg' => $_attach_messages['err_exists']); } if (move_uploaded_file($file['tmp_name'], $obj->filename)) { chmod($obj->filename, PLUGIN_ATTACH_FILE_MODE); } } if (is_page($page)) { touch(get_filename($page)); } $obj->getstatus(); $obj->status['pass'] = $pass !== TRUE && $pass !== NULL ? md5($pass) : ''; $obj->putstatus(); if ($notify) { $notify_exec = TRUE; foreach ($notify_exclude as $exclude) { $exclude = preg_quote($exclude); if (substr($exclude, -1) == '.') { $exclude = $exclude . '*'; } if (preg_match('/^' . $exclude . '/', $_SERVER['REMOTE_ADDR'])) { $notify_exec = FALSE; break; } } } else { $notify_exec = FALSE; } if ($notify_exec !== FALSE) { $footer['ACTION'] = 'File attached'; $footer['FILENAME'] =& $file['name']; $footer['FILESIZE'] =& $file['size']; $footer['PAGE'] =& $page; $footer['URI'] = get_script_absuri() . '?plugin=attach' . '&refer=' . rawurlencode($page) . '&file=' . rawurlencode($file['name']) . '&pcmd=info'; $footer['USER_AGENT'] = TRUE; $footer['REMOTE_ADDR'] = TRUE; pkwk_mail_notify($notify_subject, "\n", $footer); } return array('result' => TRUE, 'msg' => $_attach_messages['msg_uploaded']); }
function plugin_rss_action() { global $vars, $rss_max, $rss_description, $page_title, $whatsnew, $trackback; $version = isset($vars['ver']) ? $vars['ver'] : ''; switch ($version) { case '': $version = '0.91'; break; // Default // Default case '1': $version = '1.0'; break; // Sugar // Sugar case '2': $version = '2.0'; break; // Sugar // Sugar case '0.91': /* FALLTHROUGH */ /* FALLTHROUGH */ case '1.0': /* FALLTHROUGH */ /* FALLTHROUGH */ case '2.0': break; default: die('Invalid RSS version!!'); } $recent = CACHE_DIR . PKWK_MAXSHOW_CACHE; if (!file_exists($recent)) { die('PKWK_MAXSHOW_CACHE is not found'); } $lang = LANG; $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING); $self = get_script_absuri(); $rss_description_utf8 = mb_convert_encoding(htmlspecialchars($rss_description), 'UTF-8', SOURCE_ENCODING); // Creating <item> $items = $rdf_li = ''; foreach (file_head($recent, $rss_max) as $line) { list($time, $page) = explode("\t", rtrim($line)); $r_page = rawurlencode($page); $url = get_page_absuri($page); $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); $trackback_ping = ''; if ($trackback) { $tb_id = md5($r_page); $trackback_ping = ' <trackback:ping rdf:resource="' . "{$self}?tb_id={$tb_id}" . '"/>'; } $items .= <<<EOD <item rdf:about="{$url}"> <title>{$title}</title> <link>{$url}</link> <dc:date>{$date}</dc:date> <dc:identifier>{$url}</dc:identifier> {$trackback_ping} </item> EOD; break; } } // Feeding start pkwk_common_headers(); header('Content-type: application/xml'); print '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n"; $url_whatsnew = get_page_absuri($whatsnew); switch ($version) { case '0.91': print '<!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': print <<<EOD <rss version="{$version}"> <channel> <title><![CDATA[{$page_title_utf8}]]></title> <link>{$url_whatsnew}</link> <description><![CDATA[{$rss_description_utf8}]]></description> <language>{$lang}</language> {$items} </channel> </rss> EOD; break; case '1.0': $xmlns_trackback = $trackback ? ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"' : ''; print <<<EOD <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" {$xmlns_trackback} xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:lang="{$lang}"> <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; } exit; }
function plugin_openid_verify($consumer) { global $vars, $_openid_msg; $die_message = PLUS_PROTECT_MODE ? 'die_msg' : 'die_message'; $page = empty($vars['page']) ? '' : '' . $vars['page']; $openid = $vars['openid_url']; $return_to = get_location_uri('openid', '', 'action=finish_auth'); $trust_root = get_script_absuri(); // FIXME: 不正な文字列の場合は、logoff メッセージを設定できない $author = empty($vars['author']) ? 'openid' : $vars['author']; $auth_request = $consumer->begin($openid); if (!$auth_request) { $die_message($_openid_msg['err_authentication']); } $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email')); if ($sreg_request) { $auth_request->addExtension($sreg_request); } $shouldSendRedirect = $auth_request->shouldSendRedirect(); if ($shouldSendRedirect) { $redirect_url = $auth_request->redirectURL($trust_root, $return_to); if (Auth_OpenID::isFailure($redirect_url)) { $die_mesage(sprintf($_openid_msg['err_redirect'], $redirect_url->message)); } } else { $form_id = 'openid_message'; $form_html = $auth_request->htmlMarkup($trust_root, $return_to, false, array('id' => $form_id)); if (Auth_OpenID::isFailure($form_html)) { $die_mesage(sprintf($_openid_msg['err_redirect'], $form_html->message)); } } // v1 v2 // openid.server openid2.provider => $auth_request->endpoint->server_url ex. http://www.myopenid.com/server // openid.delegate openid2.local_id => $auth_request->endpoint->local_id ex. http://youraccount.myopenid.com/ $obj = new auth_openid_plus_verify(); $obj->response = array('server_url' => $auth_request->endpoint->server_url, 'local_id' => $auth_request->endpoint->local_id, 'page' => $page, 'author' => $author); $obj->auth_session_put(); if ($shouldSendRedirect) { header('Location: ' . $redirect_url); } else { //print $form_html; die($form_html); } }
function message_md5() { // return md5($this->auth_name.'_message_'.get_script_absuri().session_id()); return md5('plus_auth_msg_' . get_script_absuri() . session_id()); }
function plugin_mixirss_action() { global $vars, $get, $post, $rss_max, $rss_description, $page_title, $whatsnew, $trackback; global $modifier; global $exclude_plugin; $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!!'); } $recent = CACHE_DIR . 'recent.dat'; if (!file_exists($recent)) { die('recent.dat is not found'); } $time_recent = filemtime($recent); $rsscache = CACHE_DIR . 'rsscache' . $version . '.dat'; if (file_exists($rsscache)) { $time_rsscache = filemtime($rsscache); } else { $time_rsscache = 0; } // if caching rss file, return cache. if ($time_recent <= $time_rsscache) { pkwk_common_headers(); header('Content-type: application/xml'); print '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n"; print implode('', file($rsscache)); exit; } // 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 = ''; $source = file($recent); foreach (array_splice($source, 0, $rss_max) as $line) { list($time, $page) = explode("\t", rtrim($line)); $r_page = rawurlencode($page); $url = get_page_uri($page); $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); $trackback_ping = ''; if ($trackback) { $tb_id = md5($r_page); $trackback_ping = ' <trackback:ping rdf:resource="' . $self . '?tb_id=' . $tb_id . '"/>'; } 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(convert_html($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> {$trackback_ping} </item> EOD; } else { if (preg_match('/^(\\-{1,3})(.*)$/m', $line, $matches)) { $anchortitle = strip_htmltag(convert_html($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> {$trackback_ping} </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> {$trackback_ping} </item> EOD; } } // upk 2006-03-22 // } else if (check_readable($page,false,false) && !ereg(MIXIRSS_IGNORE_REGEX, $page)) { } else { if (check_readable($page, false, false) && !is_ignore_page($page)) { $get['page'] = $post['page'] = $vars['page'] = $page; //miko added $description = strip_htmltag(convert_html(get_source($page))); $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> {$trackback_ping} </item> EOD; } } break; } } // Feeding start pkwk_common_headers(); header('Content-type: application/xml'); print '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n"; $url_whatsnew = get_page_uri($whatsnew); $html = ''; 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': $xmlns_trackback = $trackback ? ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"' : ''; $html .= <<<EOD <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" {$xmlns_trackback} 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; } print $html; // Write Cache-file $fp = fopen($rsscache, 'w'); flock($fp, LOCK_EX); rewind($fp); fputs($fp, $html); flock($fp, LOCK_UN); fclose($fp); log_write('cmd', 'mixirss'); exit; }
function get_link_list($diffdata) { $links = array(); list($plus, $minus) = get_diff_lines($diffdata); // Get URLs from <a>(anchor) tag from convert_html() $plus = convert_html($plus); // WARNING: heavy and may cause side-effect preg_match_all('#href="(https?://[^"]+)"#', $plus, $links, PREG_PATTERN_ORDER); $links = array_unique($links[1]); // Reject from minus list if ($minus != '') { $links_m = array(); $minus = convert_html($minus); // WARNING: heavy and may cause side-effect preg_match_all('#href="(https?://[^"]+)"#', $minus, $links_m, PREG_PATTERN_ORDER); $links_m = array_unique($links_m[1]); $links = array_diff($links, $links_m); } unset($plus, $minus); // Reject own URL (Pattern _NOT_ started with '$script' and '?') $links = preg_grep('/^(?!' . preg_quote(get_script_absuri(), '/') . '\\?)./', $links); // No link, END if (!is_array($links) || empty($links)) { return; } return $links; }
function plugin_tb_mode_view_set($page) { global $vars; $tb_id = tb_get_id($page); $body = '<div><fieldset><legend>' . _('TrackBack URL') . '</legend>' . '<p>' . get_script_absuri() . '?tb_id=' . $tb_id . '</p>' . '</fieldset></div>' . "\n"; $_tb_header_Weblog = _('Blog:'); $_tb_header_Tracked = _('Date:'); $_tb_date = _('F j, Y, g:i A'); $data = tb_get(tb_get_filename($page)); // Sort: The first is the latest usort($data, create_function('$a,$b', 'return $b[0] - $a[0];')); foreach ($data as $x) { if (count($x) != 5) { continue; } // Ignore incorrect record list($time, $url, $title, $excerpt, $blog_name) = $x; if ($title == '') { $title = 'no title'; } $time = get_date($_tb_date, $time); $body .= '<div><fieldset>' . '<legend><a class="ext" href="' . $url . '" rel="nofollow">' . $title . '<img src="' . IMAGE_URI . 'plus/ext.png" alt="" title="" class="ext" onclick="return open_uri(\'' . $url . '\', \'_blank\');" /></a></legend>' . "\n" . '<p>' . $excerpt . "</p>\n" . '<div style="text-align:right">' . '<strong>' . $_tb_header_Tracked . '</strong>' . $time . ' ' . '<strong>' . $_tb_header_Weblog . '</strong>' . $blog_name . '</div>' . "\n" . '</fieldset></div>' . "\n"; } $body .= '<div style="text-align:right">' . '<a href="' . get_cmd_uri('tb', '', '', '__mode=view') . '">' . '<img src="' . IMAGE_URI . 'plus/trackback.png" alt="" title="" />' . 'Trackback List' . '</a>' . "</div>\n"; return $body; }
function get_baseuri($path = '') { global $script; // RFC2396,RFC3986 : relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ] // absoluteURI = scheme ":" ( hier_part | opaque_part ) $ret = ''; switch ($path) { case 'net': // net_path = "//" authority [ abs_path ] $parsed_url = parse_url(get_script_absuri()); $pref = '//'; if (isset($parsed_url['user'])) { $ret .= $pref . $parsed_url['user']; $pref = ''; $ret .= isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; $ret .= '@'; } if (isset($parsed_url['host'])) { $ret .= $pref . $parsed_url['host']; $pref = ''; } $ret .= isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; case 'abs': // abs_path = "/" path_segments if ($path === 'abs') { $parsed_url = parse_url(get_script_absuri()); } if (isset($parsed_url['path']) && ($pos = strrpos($parsed_url['path'], '/')) !== false) { $ret .= substr($parsed_url['path'], 0, $pos + 1); } else { $ret .= '/'; } break; case 'rel': // rel_path = rel_segment [ abs_path ] if (is_url($script, true)) { $ret = './'; } else { $parsed_url = parse_url($script); if (isset($parsed_url['path']) && ($pos = strrpos($parsed_url['path'], '/')) !== false) { $ret .= substr($parsed_url['path'], 0, $pos + 1); } } break; case 'full': default: $absoluteURI = get_script_absuri(); $ret = substr($absoluteURI, 0, strrpos($absoluteURI, '/') + 1); break; } return $ret; }
// absoluteURI // $script の値に、相対URIを指定した場合に効果があります。 // // 0: It depends on the value of $script. // 1: The value of absoluteURI is always returned. // ---- // 0: $script の値に準ずる // 1: 常に、絶対URIを戻す $absolute_uri = 1; // Specify PukiWiki Plus! absoluteURI (Only when you set $script to relativeURI) // $script に相対URIを指定した際に、必要であれば、絶対URIを指定して下さい。 //$script_abs = ''; // Site admin's name (CHANGE THIS) $modifier = 'anonymous'; // Site admin's Web page (CHANGE THIS) $modifierlink = get_script_absuri(); //$modifierlink = dirname($_SCRIPT_NAME); // Default page name $defaultpage = 'FrontPage'; // Top / Default page $whatsnew = 'RecentChanges'; // Modified page list $whatsdeleted = 'RecentDeleted'; // Removeed page list $interwiki = 'InterWikiName'; // Set InterWiki definition here $aliaspage = 'AutoAliasName'; // Set AutoAlias definition here $glossarypage = 'Glossary'; // Set Glossary definition here $menubar = 'MenuBar';