function pico_xpwiki($mydirname, $text, $content4assign) { @(include_once XOOPS_TRUST_PATH . "/modules/xpwiki/include.php"); if (!class_exists('XpWiki')) { die('xpWiki is not installed correctly'); } // 引数は、xpWikiをインストールしたディレクトリ名です。 $wiki = new XpWiki('xpwiki'); // create instance. option is xpWiki module's directory name. // 第二引数は、xpWikiのCSSを適用するためのDIVクラス名です。 return $wiki->transform($text, 'pico_body'); }
function b_sitemap_xpwiki($mydirname) { global $sitemap_configs; (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $ret = array(); include_once dirname(dirname(__FILE__)) . '/include.php'; $xpwiki =& XpWiki::getInitedSingleton($mydirname); $result = $xpwiki->func->get_existpages(FALSE, '', array('limit' => 5, 'order' => ' ORDER BY editedtime DESC', 'select' => array('title'), 'nolisting' => TRUE)); $ret = array(); // Recent Changes $show_cat = @$sitemap_configs['show_subcategoris'] ? 'child' : 'parent'; if ($show_cat === 'child') { $ret['id'] = 0; $ret['title'] = $xpwiki->root->_LANG['skin']['recent']; $ret['url'] = '?' . rawurlencode($xpwiki->root->whatsnew); } foreach ($result as $_res) { $pgid = $_res['pgid']; $page = $_res['name']; $title = $_res['title']; $title = $xpwiki->root->pagename_num2str ? preg_replace('/\\/(?:[0-9\\-]+|[B0-9][A-Z0-9]{9})$/', '/' . $xpwiki->func->get_heading($page), $page) : $page; $ret[$show_cat][] = array("id" => intval($pgid), "title" => $myts->makeTboxData4Show($title), "url" => $xpwiki->func->get_page_uri($page), 'image' => 2); } if ($show_cat === 'child') { $ret = array('parent' => array($ret)); } // Other menus $ret['parent'][] = array('id' => 0, 'title' => $xpwiki->root->_LANG['skin']['list'], 'url' => '?cmd=list'); $ret['parent'][] = array('id' => 0, 'title' => $xpwiki->root->_attach_messages['msg_list'], 'url' => '?plugin=attach&pcmd=list'); $ret['parent'][] = array('id' => 0, 'title' => $xpwiki->root->_LANG['skin']['help'], 'url' => '?Help'); return $ret; }
function xpwiki_global_search_base($mydirname, $keywords, $andor, $limit, $offset, $userid) { // 必要なファイルの読み込み $mytrustdirpath = dirname(__FILE__); include_once "{$mytrustdirpath}/include.php"; // XpWiki オブジェクト作成 $xpwiki = new XpWiki($mydirname); // xoopsSearch extension 読み込み $xpwiki->load_extensions("xoopsSearch"); // 初期化 $xpwiki->init('#RenderMode'); // データ取得 $ret = $xpwiki->extension->xoopsSearch->get($keywords, $andor, $limit, $offset, $userid); // オブジェクト破棄 $xpwiki = null; return $ret; }
function xpwiki_whatsnew_base($mydirname, $limit, $offset) { // 必要なファイルの読み込み $mytrustdirpath = dirname(dirname(__FILE__)); include_once "{$mytrustdirpath}/include.php"; // XpWiki オブジェクト作成 $xpwiki = new XpWiki($mydirname); // whatsnew extension 読み込み $xpwiki->load_extensions("whatsnew"); // 初期化 $xpwiki->init('#RenderMode'); // whatsnew データ取得 $ret = $xpwiki->extension->whatsnew->get($limit, $offset); // オブジェクト破棄 $xpwiki = null; return $ret; }
function validate_users2notify($link_id, $users2notify = array()) { if (!$users2notify || $users2notify === array(0)) { return $users2notify; } include_once dirname(dirname(__FILE__)) . "/include.php"; $xpwiki =& XpWiki::getInitedSingleton($this->mydirname); $xpwiki_users2notify = $xpwiki->func->get_users_can_read($link_id); return array_intersect($users2notify, $xpwiki_users2notify); }
function get_content($page, $get_body = true) { $html = null; $description = $this->func->get_description_cache($page, $this->root->description_max_length_rss); // 追加情報取得 $added = $this->func->get_page_changes($page); $added = $this->func->emoji2img($added); if ($get_body) { // 指定ページの本文取得 $a_page =& XpWiki::getSingleton($this->root->mydirname); $a_page->init($page); $GLOBALS['Xpwiki_' . $this->root->mydirname]['cache'] = null; $a_page->root->rtf['use_cache_always'] = TRUE; $a_page->execute(); $html = $a_page->body; if (!$description) { // html から description 作成してキャッシュ $description = $this->func->get_description_cache($page, $this->root->description_max_length_rss, $html); } // 付箋 if (empty($GLOBALS['Xpwiki_' . $this->root->mydirname]['cache']['fusen']['loaded'])) { if ($fusen = $this->func->get_plugin_instance('fusen')) { if ($fusen_data = $fusen->plugin_fusen_data($page)) { if ($fusen_tag = $fusen->plugin_fusen_gethtml($fusen_data, '')) { $html .= '<fieldset><legend> fusen.dat </legend>' . $fusen_tag . '</fieldset>'; } } } } $html = $this->func->emoji2img($html); $html = $this->func->add_MyHostUrl($html); if ($added) { $html = '<dl><dt>Changes</dt><dd>' . $added . '</dd></dl><hr />' . $html; } // ]]> をクォート $html = str_replace(']]>', ']]>', $html); // 無効なタグを削除 $html = preg_replace('#<(script|form|embed|object).+?/\\1>#is', '', $html); $html = preg_replace('#<(link|wbr).*?>#is', '', $html); // 相対指定リンクを削除 $html = preg_replace('#<a[^>]+href=(?!(?:"|\')?[_0-9a-zA-Z]+://)[^>]+>(.*?)</a>#is', '$1', $html); // タグ中の無効な属性を削除 $_reg = '/(<[^>]*)\\s+(?:id|class|name|on[^=]+)=("|\').*?\\2([^>]*>)/s'; while (preg_match($_reg, $html)) { $html = preg_replace($_reg, '$1$3', $html); } } $description = ($added ? $this->func->substr_entity($this->func->htmlspecialchars(trim(preg_replace('/\\s+/', ' ', strip_tags($added)))), 0, 250) . '¶' : '') . $description; $tags = array(); if (is_file($this->cont['CACHE_DIR'] . $this->func->encode($page) . '_page.tag')) { $tags = file($this->cont['CACHE_DIR'] . $this->func->encode($page) . '_page.tag'); } $pginfo = $this->func->get_pginfo($page); return array($description, $html, $pginfo, $tags); }
function xpwiki_saf_getRecentPages_base($options) { $mydirname = preg_replace('/[^0-9a-zA-Z_-]/', '', $options[0]); $base = empty($options[1]) ? '' : strval($options[1]); $count = empty($options[2]) ? 10 : max(1, intval($options[2])); // Load need files. include_once dirname(dirname(__FILE__)) . '/include.php'; // Make XpWiki object. $xpwiki = new XpWiki($mydirname); $xpwiki->init('#RenderMode'); $rss_plugin =& $xpwiki->func->get_plugin_instance('rss'); if (!empty($options[3])) { $xpwiki->root->userinfo['admin'] = FALSE; $xpwiki->root->userinfo['uid'] = 0; $xpwiki->root->userinfo['uname'] = ''; $xpwiki->root->userinfo['uname_s'] = ''; $xpwiki->root->userinfo['gids'] = array(); } $getbody = !empty($options[4]); $lines = $xpwiki->func->get_existpages(FALSE, $base ? $base . '/' : '', array('limit' => $count, 'order' => ' ORDER BY editedtime DESC', 'nolisting' => TRUE, 'withtime' => TRUE)); $ret = array(); if ($base) { $ret['base'] = array('name' => $base, 'link' => $xpwiki->func->get_page_uri($base, true), 'child_counts' => $xpwiki->func->get_child_counts($base)); } foreach ($lines as $line) { list($time, $page) = explode("\t", rtrim($line)); $title = $xpwiki->root->pagename_num2str ? preg_replace('/\\/(?:[0-9\\-]+|[B0-9][A-Z0-9]{9})$/', '/' . $xpwiki->func->get_heading($page), $page) : $page; if ($base) { $title = substr($title, strlen($base) + 1); } list($description, $html, $pginfo, $tags) = $rss_plugin->get_content($page, $getbody); $entry = array('id' => $xpwiki->func->get_pgid_by_name($page), 'pagename' => htmlspecialchars($page, ENT_COMPAT, $xpwiki->cont['SOURCE_ENCODING']), 'views' => $xpwiki->func->get_page_views($page), 'replies' => $xpwiki->func->count_page_comments($page), 'pubtime' => $time + date('Z'), 'link' => $xpwiki->func->get_page_uri($page, true), 'headline' => htmlspecialchars($title, ENT_COMPAT, $xpwiki->cont['SOURCE_ENCODING']), 'description' => $description, 'pginfo' => $pginfo); if (!is_null($html)) { $entry['content'] = $html; } $ret['entries'][] = $entry; } $xpwiki = null; // As for all the values, it is not escaped in HTML. return $ret; }
function xpwiki_notify_base($mydirname, $category, $item_id) { if ($category == 'global') { $item['name'] = ''; $item['url'] = ''; return $item; } include_once dirname(__FILE__) . '/include.php'; $xpwiki =& XpWiki::getInitedSingleton($mydirname); if (substr($category, 0, 4) === 'page') { // Assume we have a valid $item_id $item['name'] = $xpwiki->func->get_name_by_pgid($item_id); $item['url'] = $xpwiki->func->get_page_uri($item['name'], true); return $item; } }
function d3downloads_xpwiki( $text, $html, $smiley, $xcode, $image, $br ) { if ( ! class_exists( 'd3downloadsTextSanitizer' ) ) { require_once dirname( dirname( dirname(__FILE__) ) ).'/class/d3downloads.textsanitizer.php' ; } $myts =& d3downloadsTextSanitizer::getInstance() ; if ( ! class_exists( 'XpWiki' ) ) { @ include_once XOOPS_TRUST_PATH.'/modules/xpwiki/include.php' ; } if( ! class_exists( 'XpWiki' ) ) die( 'xpWiki is not installed correctly' ) ; // Get instance. option is xpWiki module's directory name. // 引数は、xpWikiをインストールしたディレクトリ名です。 $wiki =& XpWiki::getSingleton( 'xpwiki' ); // xpWiki の動作を決定する設定値を変更できます。 // $wiki->setIniConst( '[KEY]' , '[VALUE]' ); // $wiki->root->[KEY] = [VALUE]; // $wiki->setIniRoot( '[KEY]' , '[VALUE]' ); // $wiki->cont->[KEY] = [VALUE]; // ex, 改行を有効にする $wiki->setIniRoot( 'line_break' , 1 ); // ex. レンダリングキャッシュをする $wiki->setIniRoot( 'render_use_cache' , 1 ); // ex. レンダリングキャッシュの有効期限は新たにページが作成されるまで $wiki->setIniRoot( 'render_cache_min' , 0 ); // キャッシュ有効時間(分) // ex. 外部リンクの target 属性 '_blank' $wiki->setIniRoot( 'link_target' , '_blank' ); if ($html != 1) { // 第二引数は、xpWikiのCSSを適用するためのDIVクラス名 // 通常インストールしたディレクトリ名です。 // CSS を適用しない場合は空白 '' でOK。 $text = $wiki->transform( $text , 'xpwiki' ) ; } else { $text = $myts->codePreConv( $text, $xcode ) ; $text = $myts->makeClickable( $text ); if( $smiley != 0 ) $text = $myts->smiley( $text ) ; } if( $xcode != 0 ) $text = $myts->xoopsCodeDecode( $text, $image ) ; if( $html && $br != 0) $text = $myts->nl2Br( $text ) ; if( $html ) $text = $myts->codeConv( $text, $xcode, $image ) ; $text = $myts->postCodeDecode( $text , $image ) ; return $text; }
function validate_id($link_id) { static $check; if (isset($check[$this->mydirname][$link_id])) { return $check[$this->mydirname][$link_id]; } $ret = intval($link_id); if ($ret <= 0) { $ret = false; } else { include_once dirname(dirname(__FILE__)) . "/include.php"; $xpwiki =& XpWiki::getInitedSingleton($this->mydirname); $page = $xpwiki->func->get_name_by_pgid($ret); if (!$xpwiki->func->is_page($page) || !$xpwiki->func->check_readable($page, false, false)) { $ret = false; } } $check[$this->mydirname][$link_id] = $ret; return $ret; }
function plugin_include_convert() { static $included = array(); if (!isset($included[$this->xpwiki->pid])) { $included[$this->xpwiki->pid] = array(); } static $count = array(); if (!isset($count[$this->xpwiki->pid])) { $count[$this->xpwiki->pid] = 1; } if (func_num_args() == 0) { return $this->cont['PLUGIN_INCLUDE_USAGE'] . '<br />' . "\n"; } // $menubar will already be shown via menu plugin if (!isset($included[$this->xpwiki->pid][$this->root->menubar])) { $included[$this->xpwiki->pid][$this->root->menubar] = TRUE; } // Loop yourself $root = isset($this->root->vars['page']) ? $this->root->vars['page'] : ''; $included[$this->xpwiki->pid][$root] = TRUE; // Get arguments $args = func_get_args(); // strip_bracket() is not necessary but compatible $pageKey = $page = isset($args[0]) ? $this->func->get_fullname($this->func->strip_bracket(array_shift($args)), $root) : ''; $options = array('title' => FALSE, 'notitle' => FALSE, 'source' => FALSE, 'html' => FALSE); $this->fetch_options($options, $args); if ($options['source']) { $this->otherIncludeMode = 'source'; } else { if ($options['html']) { $this->otherIncludeMode = 'html'; } } $targetObj = NULL; $isThis = TRUE; if (intval(strpos($page, ':')) > 0) { list($other_dir, $_page) = explode(':', $page, 2); $targetObj =& XpWiki::getInitedSingleton($other_dir); if ($targetObj->isXpWiki) { $page = $_page; $isThis = FALSE; } else { $targetObj = NULL; } } if (is_null($targetObj)) { $targetObj =& $this; $other_dir = ''; } $with_title = $options['title'] ? TRUE : ($options['notitle'] ? FALSE : $this->cont['PLUGIN_INCLUDE_WITH_TITLE']); $s_page = $this->func->htmlspecialchars($page); $r_page = rawurlencode($page); // Include A page, that probably includes another pages if ($targetObj->func->check_readable($page, false, false)) { // $with_title = $this->cont['PLUGIN_INCLUDE_WITH_TITLE']; // if (isset($args[0])) { // switch(strtolower(array_shift($args))) { // case 'title' : $with_title = TRUE; break; // case 'notitle': $with_title = FALSE; break; // } // } $link = '<a href="' . $this->func->get_page_uri($page, TRUE) . '">' . $s_page . '</a>'; // Read link // I'm stuffed $pageKey4disp = $this->func->htmlspecialchars($pageKey); if ($this->root->render_mode === 'main' && isset($included[$this->xpwiki->pid][$pageKey])) { return '#include(' . $pageKey4disp . '): Included already: ' . $link . '<br />' . "\n"; } if (!$targetObj->func->is_page($page)) { return '#include(): No such page: ' . $s_page . '<br />' . "\n"; } if ($count[$this->xpwiki->pid] > $this->cont['PLUGIN_INCLUDE_MAX']) { return '#include(): Limit exceeded: ' . $link . '<br />' . "\n"; } else { ++$count[$this->xpwiki->pid]; } // for renderer mode $this->root->rtf['disable_render_cache'] = TRUE; // One page, only one time, at a time $included[$this->xpwiki->pid][$pageKey] = TRUE; if ($this->root->render_mode === 'render') { $_PKWK_READONLY = $this->cont['PKWK_READONLY']; $this->cont['PKWK_READONLY'] = $this->root->rtf['PKWK_READONLY']; } if ($this->otherIncludeMode === 'html') { $body = ''; if (!$isThis) { $this->swap_global_vars($this->xpwiki, $targetObj); $body .= '<div class="xpwiki_r_' . $other_dir . '">'; } else { $body .= '<div>'; } $body .= $targetObj->func->convert_html($targetObj->func->get_source($page), $page); $body .= '</div>'; if (!$isThis) { $this->swap_global_vars($this->xpwiki, $targetObj); } } else { $body = $this->func->convert_html($targetObj->func->get_source($page), $page); } if ($this->root->render_mode === 'render') { $this->cont['PKWK_READONLY'] = $_PKWK_READONLY; } } else { $body = str_replace('$1', $page, $this->root->_msg_include_restrict); } // Put a title-with-edit-link, before including document if ($with_title) { $link = '<a href="' . $targetObj->root->script . '?cmd=edit&page=' . $r_page . '">' . $s_page . '</a>'; if ($page === $targetObj->root->menubar) { $body = '<span align="center"><h5 class="side_label">' . $link . '</h5></span><small>' . $body . '</small>'; } else { $body = '<h1>' . $link . '</h1>' . "\n" . $body . "\n"; } } return $body; }
function toString($page = '', $flat = FALSE) { $pcmd = $this->mode == "imglist" ? "imglist" : "list"; $pcmd2 = $this->mode == "imglist" ? "list" : "imglist"; $otherkeys = array('cols', 'max', 'base', 'mode', 'winop', 'basedir', 'encode_hint', 'word'); if ($this->is_popup) { $otherkeys[] = 'popup'; if ($this->cont['UA_PROFILE'] === 'mobile') { $this->func->add_tag_head('<!--jqm_theme_d-->'); } } if (!isset($this->root->vars['basedir'])) { $this->root->vars['basedir'] = $this->root->mydirname; } $otherparm = ''; $otherprams = array(); $hiddens = array(); $hiddens['plugin'] = 'attach'; $hiddens['pcmd'] = $pcmd; $hiddens['refer'] = isset($this->root->vars['refer']) ? $this->func->htmlspecialchars($this->root->vars['refer']) : ''; foreach ($otherkeys as $key) { if (isset($this->root->vars[$key])) { $otherprams[] = rawurlencode($key) . '=' . rawurlencode($this->root->vars[$key]); $hiddens[$this->func->htmlspecialchars($key)] = $this->func->htmlspecialchars($this->root->vars[$key]); } } $select_js = $otherDir = $select = ''; if ($this->is_popup) { $dirs = $otherDirs = array(); if ($handle = opendir($this->cont['MODULE_PATH'])) { while (false !== ($dir = readdir($handle))) { if (is_dir($this->cont['MODULE_PATH'] . $dir) && $dir[0] !== '.' && $this->func->isXpWikiDirname($dir)) { $other = XpWiki::getInitedSingleton($dir); if ($other->isXpWiki) { if ($other->root->pages_for_attach) { list($dirs[$dir]['defaultpage']) = explode('#', $other->root->pages_for_attach); } else { $dirs[$dir]['defaultpage'] = $other->root->defaultpage; } $dirs[$dir]['title'] = $other->root->module['title']; } } } } if (count($dirs) > 1) { ksort($dirs); foreach ($dirs as $dir => $val) { $defaultpage = $val['defaultpage']; $selected = $dir === $this->root->mydirname ? ' selected="selected"' : ''; if ($this->root->vars['basedir'] === $dir) { $defaultpage = $this->root->vars['base']; } $otherDirs[] = '<option value="' . $dir . '#' . $this->func->htmlspecialchars($defaultpage) . '"' . $selected . '>' . $this->func->htmlspecialchars($val['title']) . '</option>'; } $otherDir = '<form><img src="' . $this->cont['LOADER_URL'] . '?src=folder_go.png" alt="Dir" /> <select name="otherdir" style="max-width:85%;" onchange="xpwiki_dir_selector_change(this.options[this.selectedIndex].value)">' . join('', $otherDirs) . '</select></form>'; } $where = array(); if (!empty($this->root->vars['word'])) { foreach (explode(' ', mb_convert_kana($this->root->vars['word']), 's') as $search) { $where[] = 'a.`name` LIKE \'%' . addslashes($search) . '%\''; } } $where = $where ? ' AND ' . join(' AND ', $where) : ''; $otherPages = array(); $shown = array($this->root->vars['base']); $attach =& $this->func->get_plugin_instance('attach'); if ($this->root->pages_for_attach) { $otherPages[] = '<optgroup label="' . $this->root->_attach_messages['msg_select_useful'] . '">'; foreach (explode('#', $this->root->pages_for_attach) as $_page) { if ($this->func->check_readable($_page, false, false)) { $selected = $_page === $page ? ' selected="selected"' : ''; $shown[] = $_page; $_pgid = $this->func->get_pgid_by_name($_page); if ($_pgid) { $query = 'SELECT count( * ) FROM `' . $this->xpwiki->db->prefix($this->root->mydirname . '_attach') . '` a WHERE a.pgid="' . $_pgid . '" AND a.age = 0 AND a.name != "fusen.dat"' . $where . ' LIMIT 1'; $count = ''; if ($result = $this->xpwiki->db->query($query)) { $row = $this->xpwiki->db->fetchRow($result); $count = ' (' . $row[0] . ')'; } } else { $count = ' (0)'; } $_attachable = ''; $_class = 'readable'; if ($attach->attachable($_page)) { $_class = 'attachable'; if ($this->cont['UA_PROFILE'] !== 'default') { $_attachable = '↑'; } } $otherPages[] = '<option class="' . $_class . '" value="' . rawurlencode($_page) . '"' . $selected . '>' . $_attachable . $this->func->htmlspecialchars($_page) . $count . '</option>'; } } $otherPages[] = '</optgroup>'; } $query = 'SELECT p.name, count( * ) AS count FROM `' . $this->xpwiki->db->prefix($this->root->mydirname . '_pginfo') . '` p INNER JOIN `' . $this->xpwiki->db->prefix($this->root->mydirname . '_attach') . '` a ON p.pgid = a.pgid WHERE a.age =0 AND a.name != "fusen.dat"' . $where . ' GROUP BY a.pgid ORDER BY count DESC, p.name ASC LIMIT 0 , 50'; if ($result = $this->xpwiki->db->query($query)) { $otherPages[] = '<optgroup label="' . $this->root->_attach_messages['msg_select_manyitems'] . '">'; while ($row = $this->xpwiki->db->fetchRow($result)) { if ($this->func->check_readable($row[0], false, false)) { if (in_array($row[0], $shown)) { continue; } $selected = $row[0] === $page ? ' selected="selected"' : ''; $_page = $this->func->htmlspecialchars($row[0]); $_attachable = ''; $_class = 'readable'; if ($attach->attachable($_page)) { $_class = 'attachable'; if ($this->cont['UA_PROFILE'] !== 'default') { $_attachable = '↑'; } } $otherPages[] = '<option class="' . $_class . '" value="' . rawurlencode($_page) . '"' . $selected . '>' . $_attachable . $this->func->htmlspecialchars($_page) . ' (' . $row[1] . ')</option>'; } } $otherPages[] = '</optgroup>'; } if ($otherPages) { $thisPage = '<option value="">--- ' . $this->root->_attach_messages['msg_page_select'] . ' ---</option>'; if ($this->root->vars['basedir'] === $this->root->mydirname) { $selected = $this->root->vars['base'] === $page ? ' selected="selected"' : ''; $thisPage .= '<option value="' . rawurlencode($this->root->vars['base']) . '"' . $selected . '>' . $this->func->htmlspecialchars($this->root->vars['base']) . $this->root->_attach_messages['msg_select_current'] . '</option>'; } if (!empty($this->root->vars['refer'])) { $thisPage .= '<option value="#">' . $this->root->_attach_messages['msg_show_all_pages'] . '</option>'; } $base = rawurlencode($this->root->vars['base']); $select = '<form><img src="' . $this->cont['LOADER_URL'] . '?src=page_attach.png" alt="Pages" /> <select name="othorpage" style="max-width:85%;" onchange="xpwiki_file_selector_change(this.options[this.selectedIndex].value, \'' . $base . '\')">' . $thisPage . join('', $otherPages) . '</select></form>'; } $select_js = <<<EOD <script type="text/javascript"><!-- function xpwiki_file_selector_change(page, base) { \tif (page || page == 0) { \t\tif (page == '#') page = ''; \t\tvar href = location.href; \t\tif (! href.match(/&refer=[^&]*/)) { \t\t\thref += '&refer='; \t\t} \t\tlocation.href = href.replace(/&refer=[^&]*/, '&refer=' + page).replace(/&base=[^&]*/, '&base=' + base).replace(/&(start|encode_hint)=[^&]+/, ''); \t} } function xpwiki_dir_selector_change(dir) { \tif (dir) { \t\tvar arr = dir.split('#'); \t\tlocation.href = location.href.replace(/\\/modules\\/[^\\/]+/, '/modules/' + arr[0]).replace(/&refer=[^&]*/, '&refer=').replace(/&start=[^&]+/, ''); \t} } //--> </script> EOD; } $sword = isset($this->root->vars['word']) ? $this->func->htmlspecialchars($this->root->vars['word']) : ''; $hidden = ''; unset($hiddens['word']); foreach ($hiddens as $key => $val) { $hidden .= sprintf('<input type="hidden" name="%s" value="%s" />', $key, $val); } if ($flat) { $search = ''; } else { if ($this->cont['UA_PROFILE'] === 'mobile') { $search = '<div><form method="get" action="' . $this->root->script . '"><input type="search" name="word" autocomplete="off" value="' . $sword . '" />' . $hidden . '</form></div>'; } else { $search = '<div><form method="get" action="' . $this->root->script . '"><img src="' . $this->cont['LOADER_URL'] . '?src=find.png" alt="Search" /> <input size="15" type="search" name="word" value="' . $sword . '" /><input data-inline="true" type="submit" value="' . $this->root->_btn_search . '" />' . $hidden . '</form></div>'; } } if ($page !== '') { if (!array_key_exists($page, $this->pages)) { return ''; } return '<div class="attach_list">' . $select_js . $otherDir . $select . $search . $this->pages[$page]->toString($flat, FALSE, $this->mode) . '</div>'; } if ($otherprams) { $otherparm = '&' . join('&', $otherprams); } $url = $this->root->script . "?plugin=attach&pcmd={$pcmd}{$otherparm}&order=" . $this->order . "&start="; $url2 = $this->root->script . "?plugin=attach&pcmd={$pcmd}{$otherparm}&start="; $url3 = $this->root->script . "?plugin=attach&pcmd={$pcmd2}{$otherparm}&order=" . $this->order . "&start=" . $this->start; $sort_time = $this->order == "name" ? " [ <a href=\"{$url2}0&order=time\">{$this->root->_attach_messages['msg_sort_time']}</a> |" : " [ <b>{$this->root->_attach_messages['msg_sort_time']}</b> |"; $sort_name = $this->order == "name" ? " <b>{$this->root->_attach_messages['msg_sort_name']}</b> ] " : " <a href=\"{$url2}0&order=name\">{$this->root->_attach_messages['msg_sort_name']}</a> ] "; if ($this->is_popup) { $mode_tag = ''; } else { $mode_tag = $this->mode == "imglist" ? "[ <a href=\"{$url3}\">{$this->root->_attach_messages['msg_list_view']}</a> ]" : "[ <a href=\"{$url3}\">{$this->root->_attach_messages['msg_image_view']}</a> ]"; } $_start = $this->start + 1; $_end = $this->start + $this->max; $_end = min($_end, $this->count); $now = $this->start / $this->max + 1; $total = ceil($this->count / $this->max); $navi = array(); for ($i = 1; $i <= $total; $i++) { if ($now == $i) { $navi[] = "<b>{$i}</b>"; } else { $navi[] = "<a href=\"" . $url . ($i - 1) * $this->max . "\"><span class=\"button\">{$i}</span></a>"; } } $navi = join(' ', $navi); $prev = max(0, $now - 1); $next = $now; $prev = $prev ? "<a href=\"" . $url . ($prev - 1) * $this->max . "\" title=\"Prev\"><span class=\"button\"> <img src=\"{$this->cont['LOADER_URL']}?src=prev.png\" width=\"6\" height=\"12\" alt=\"Prev\"> </span></a>" : ""; $next = $next < $total ? "<a href=\"" . $url . $next * $this->max . "\" title=\"Next\"><span class=\"button\"> <img src=\"{$this->cont['LOADER_URL']}?src=next.png\" width=\"6\" height=\"12\" alt=\"Next\"> </span></a>" : ""; $navi = "<div class=\"page_navi\">| {$navi} |<br />[{$prev} {$_start} - {$_end} / " . $this->count . " pages {$next}]<br />{$sort_time}{$sort_name}{$mode_tag}</div>"; $ret = ''; $pages = array_keys($this->pages); if ($pages) { foreach ($pages as $page) { $ret .= $this->pages[$page]->toString($flat, TRUE, $this->mode) . "\n"; } } else { $navi = ''; } return "\n<div class=\"attach_list\">{$select_js}{$otherDir}{$select}{$search}{$navi}" . ($navi ? "<hr />" : "") . "\n{$ret}\n" . ($navi ? "<hr />" : "") . "{$navi}</div>\n"; }
function BBCode_add_switch(&$html, $element) { if (!preg_match('/(?:^| )(?:plain|none|xcode)(?: |$)/', $element['class'])) { $this->check_XpWiki(); $script = method_exists('XpWiki', 'sGet_BBCode_switch_js') ? XpWiki::sGet_BBCode_switch_js($element['id'], XPWIKI_RENDERER_DIR) : ''; $html .= $script; } }
* Created on 2008/05/13 by nao-pon http://hypweb.net/ * $Id: jobstack.php,v 1.10 2011/10/31 16:04:47 nao-pon Exp $ */ error_reporting(0); ignore_user_abort(TRUE); $file = $mytrustdirpath . '/skin/image/gif/blank.gif'; header('Content-Type: image/gif'); header('Content-Length: ' . filesize($file)); header('Expires: Thu, 01 Dec 1994 16:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0'); header('Pragma: no-cache'); HypCommonFunc::readfile($file); flush(); include_once $mytrustdirpath . '/include.php'; $xpwiki = new XpWiki($mydirname); $xpwiki->init('#RenderMode'); $max_execution_time = intval(ini_get('max_execution_time')); // It is all as for the one executed soon. (ttl = 0) $sql = 'SELECT `key`, `data` FROM ' . $xpwiki->db->prefix($xpwiki->root->mydirname . '_cache') . ' WHERE `plugin`=\'jobstack\' AND `mtime` <= ' . $xpwiki->cont['UTC'] . ' AND `ttl`=0 ORDER BY `mtime` ASC LIMIT 1'; if ($res = $xpwiki->db->query($sql)) { $row = $xpwiki->db->fetchRow($res); while ($row) { if ($max_execution_time) { @ini_set('max_execution_time', (string) $max_execution_time); } xpwiki_jobstack_switch($xpwiki, $row); $res = $xpwiki->db->query($sql); $row = $xpwiki->db->fetchRow($res); } }
function b_xpwiki_block_show($options, $src, $nocache = false) { $mydirname = empty($options[0]) ? 'xpwiki' : $options[0]; // 必要なファイルの読み込み (固定値:変更の必要なし) include_once XOOPS_TRUST_PATH . "/modules/xpwiki/include.php"; // XpWiki オブジェクト取得 (引数: モジュールディレクトリ名) $xw =& XpWiki::getSingleton($mydirname); $width = empty($options[1]) ? '100%' : $options[1]; $this_template = empty($options[2]) ? 'db:' . $mydirname . '_block_a_page.html' : trim($options[2]); $div_class = empty($options[3]) ? 'xpwiki_b_' . $mydirname : $options[3]; $css = isset($options[4]) ? $options[4] : NULL; $head_tag_place = empty($options[5]) ? 'module' : trim($options[5]); $configs = array(); if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } // ページキャッシュを常に無効にする if ($nocache) { $configs['root']['pagecache_min'] = 0; } // Wikiソース $arg = array('source' => $src); // ブロック用として取得 (引数: Wikiソース, 表示幅) list($str, $head) = $xw->get_html_for_block($arg, $width, $div_class, $css, $configs, TRUE); // MenuBar の ページCSS を読み込み if (isset($options['menubar'])) { $head .= $xw->func->get_page_css_tag('MenuBar'); } // オブジェクトを破棄 //$xw = null; //unset($xw); if ($head_tag_place === 'body' || !b_xpwiki_insert_headtag($head, $head_tag_place)) { $str = $head . $str; } if (!$str) { return FALSE; } $block = array('mydirname' => $mydirname, 'mod_url' => XOOPS_URL . '/modules/' . $mydirname, 'pagename' => '', 'content' => $str); if (defined('ICMS_ROOT_PATH') && !class_exists('XoopsTpl')) { include_once ICMS_ROOT_PATH . '/class/template.php'; } $tpl = new XoopsTpl(); $tpl->assign('block', $block); $ret['content'] = $tpl->fetch($this_template); return $ret; }
} if ($face_remake) { list($face_tag, $face_tag_full, $_face_tag_ver, $fck_smileys) = xpwiki_make_facemarks($xpwiki, $skin_dirname, $face_cache, $face_tag_ver); } $ieDomLoadedDisabled = $xpwiki->root->ieDomLoadedDisabled ? 'true' : 'false'; $UseWikihelperAtAll = $xpwiki->root->render_UseWikihelperAtAll ? 'true' : 'false'; if (defined('XPWIKI_RENDERER_DIR')) { $RendererDir = XPWIKI_RENDERER_DIR; if (defined('XPWIKI_RENDERER_USE_WIKIHELPER')) { $UseWikihelperAtAll = XPWIKI_RENDERER_USE_WIKIHELPER ? 'true' : 'false'; } if ($xpwiki->root->mydirname === XPWIKI_RENDERER_DIR) { $RendererPage = $xpwiki->root->render_attach; $skinname = $xpwiki->cont['SKIN_NAME']; } else { $renderer = new XpWiki(XPWIKI_RENDERER_DIR); $renderer->init('#RenderMode'); $RendererPage = $renderer->root->render_attach; $skinname = $renderer->cont['SKIN_NAME']; } $skinname = 'XpWiki.SkinName[\'' . $RendererDir . '\'] = \'' . $skinname . '\';'; } else { $skinname = $RendererDir = $RendererPage = ''; } $fckeditor_path = ''; if ($xpwiki->root->fckeditor_path) { $fckeditor_path = $xpwiki->cont['ROOT_URL'] . trim($xpwiki->root->fckeditor_path, '/') . '/'; } $fckxpwiki_path = $xpwiki->cont['ROOT_URL'] . trim($xpwiki->root->fckxpwiki_path, '/') . '/'; $ie6JsPass = $xpwiki->root->ie6JsPass ? 'true' : 'false'; $imageDir = $xpwiki->cont['IMAGE_DIR'];
<?php include_once XOOPS_TRUST_PATH . "/modules/xpwiki/include.php"; $xw =& XpWiki::getInitedSingleton($mydirname); if (!$xw->func->get_pgid_by_name($xw->root->defaultpage)) { $xw->func->send_location('', '', $xw->cont['HOME_URL'] . '?cmd=dbsync'); } $check_dir = array($xw->cont['UPLOAD_DIR'], $xw->cont['UPLOAD_DIR'] . 's', $xw->cont['BACKUP_DIR'], $xw->cont['CACHE_DIR'], $xw->cont['CACHE_DIR'] . 'page', $xw->cont['CACHE_DIR'] . 'plugin', $xw->cont['DIFF_DIR'], $xw->cont['TRACKBACK_DIR'], $xw->cont['RENDER_CACHE_DIR'], $xw->cont['DATA_DIR']); $check_dir = array_unique($check_dir); sort($check_dir); $dir_res = array(); foreach ($check_dir as $dir) { $dir = rtrim($dir, '/'); if (is_writable($dir)) { $dir .= ' (<span style="color:green;font-weight:bold;">OK</span>)'; } else { $dir .= ' (<span style="color:red;font-weight:bold;">NG</span>)'; } $dir_res[] = $dir; } $dir_res = '<ul><li>' . join('</li><li>', $dir_res) . '</li></ul>'; // output xoops_cp_header(); include dirname(__FILE__) . '/mymenu.php'; echo <<<EOD <h3>Writable check results</h3> {$dir_res} EOD; xoops_cp_footer();
$this->week_start : sunday:0 monday:1 $this->user_TZ : user's timezone (+1.5 etc) $this->server_TZ : server's timezone (-2.5 etc) $tzoffset_s2u : the offset from server to user $now : the result of time() $plugin = array('dirname'=>'dirname','name'=>'name','dotgif'=>'*.gif','options'=>'options') $plugin_returns[ DATE ][] */ // set range (added 86400 second margin "begin" & "end") $range_start_s = mktime(0, 0, 0, $this->month, $this->date - 1, $this->year); $range_end_s = mktime(0, 0, 0, $this->month, $this->date + 2, $this->year); // options //$options = explode( '|' , $plugin['options'] ) ; require_once XOOPS_TRUST_PATH . '/modules/xpwiki/include.php'; $xpwiki =& XpWiki::getSingleton($plugin['dirname']); $xpwiki->init('#RenderMode'); // to GMT $range_start_s -= $xpwiki->cont['LOCALZONE']; $range_end_s -= $xpwiki->cont['LOCALZONE']; $where = $xpwiki->func->get_readable_where(); $where_base = "editedtime >= {$range_start_s} AND editedtime < {$range_end_s}"; if ($where) { $where = '(' . $where . ') AND ' . $where_base; } else { $where = $where_base; } // query (added 86400 second margin "begin" & "end") $result = $db->query('SELECT name, editedtime, title FROM ' . $db->prefix($plugin['dirname'] . '_pginfo') . ' WHERE ' . $where); while (list($page, $server_time, $title) = $db->fetchRow($result)) { $server_time += $xpwiki->cont['LOCALZONE'];
function get_ext_autolink($autolink) { // check valid pages. $valid = isset($autolink['target']) ? (string) $autolink['target'] : false; if ($valid && isset($this->root->vars['page'])) { $_check = false; foreach (explode('&', $valid) as $_valid) { if ($_valid && strpos($this->root->vars['page'], $_valid) === 0) { $_check = true; break; } } if (!$_check) { return ''; } } // initialize $inits = array('target' => '', 'priority' => 40, 'url' => '', 'urldat' => 0, 'case_i' => 0, 'base' => '', 'len' => 3, 'enc' => $this->cont['CONTENT_CHARSET'], 'cache' => 10, 'title' => 'Ext:[KEY]', 'pat' => '', 'a_target' => '', 'a_class' => '', 'option' => '', 'popup' => ''); $autolink = array_merge($inits, $autolink); if (preg_match('#^https?://#', $autolink['url'])) { $this->ext_autolink_own = false; } else { $this->ext_autolink_own = $autolink['url']; } // plain_db_write() から呼ばれている時自己Wiki以外はパス if (!empty($this->root->rtf['is_init']) && $this->ext_autolink_own !== '') { return ''; } $autolink['base'] = trim($autolink['base'], '/'); $this->ext_autolink_enc_conv = strtoupper($this->cont['CONTENT_CHARSET']) !== strtoupper($autolink['enc']); if ($autolink['urldat']) { $target = $autolink['url']; } else { $target = $this->ext_autolink_enc_conv ? mb_convert_encoding($autolink['base'], $autolink['enc'], $this->cont['CONTENT_CHARSET']) : $autolink['base']; $target = $autolink['url'] . '?plugin=api&pcmd=autolink&base=' . rawurlencode($target); } $cache = $this->cont['CACHE_DIR'] . sha1($target . $autolink['option']) . '.extautolink'; // 重複登録チェック if (isset($this->root->rtf['get_ext_autolink_done'][$target])) { return ''; } $this->root->rtf['get_ext_autolink_done'][$target] = true; $this->ci = $autolink['case_i']; $this->make_pagelink_options = array(); $cache_min = intval(max($autolink['cache'], 10)); // 自己xpWiki以外 & キャッシュあり & キャッシュが有効範囲 if ($this->ext_autolink_own !== '' && is_file($cache) && filemtime($cache) + $cache_min * 60 > $this->cont['UTC']) { $pat = file_get_contents($cache); if ($this->ext_autolink_own !== false) { $obj =& XpWiki::getInitedSingleton($this->ext_autolink_own); if (!$obj->isXpWiki) { return; } $this->ext_autolink_func =& $obj->func; $this->ci = $obj->root->page_case_insensitive; } } else { if ($this->ext_autolink_own !== false) { if ($this->ext_autolink_own) { $obj =& XpWiki::getInitedSingleton($this->ext_autolink_own); if (!$obj->isXpWiki) { return; } $this->ext_autolink_func =& $obj->func; $this->ci = $obj->root->page_case_insensitive; $plugin =& $obj->func->get_plugin_instance('api'); } else { $this->ci = $this->root->page_case_insensitive; $plugin =& $this->func->get_plugin_instance('api'); // Cache しない $cache = false; } $options = array(); if ($autolink['option']) { $_options = $this->func->csv_explode(',', $autolink['option']); foreach ($_options as $option) { list($key, $val) = array_pad(explode(':', $option, 2), 2, TRUE); $options[trim($key)] = trim($val); } } $pat = $plugin->autolink(true, $autolink['base'], $options); if ($autolink['popup']) { $this->make_pagelink_options['popup']['use'] = 1; } } else { $data = $this->func->http_request($target); if ($data['rc'] !== 200) { $pat = ''; } else { $pat = $this->ext_autolink_enc_conv ? mb_convert_encoding($data['data'], $this->cont['CONTENT_CHARSET'], $autolink['enc']) : $data['data']; $pat = trim($pat); @(list($pat1, $pat2) = preg_split('/[\\r\\n]+/', $pat)); // check regex pattern if ($pat1) { foreach (explode("\t", $pat1) as $_pat) { if (preg_match('/(' . $_pat . ')/S', '') === false) { $pat1 = ''; break; } } } if ($pat2) { foreach (explode("\t", $pat2) as $_pat) { if (preg_match('/(' . $_pat . ')/S', '') === false) { $pat2 = ''; break; } } } $pat = ''; if ($pat1) { $pat = $pat1; } if ($pat2) { $pat .= "\t" . $pat2; } } } if ($cache) { $fp = fopen($cache, 'w'); fwrite($fp, $pat); fclose($fp); } } $this->ext_autolink_url = $autolink['url']; $this->ext_autolink_base = $autolink['base'] ? $autolink['base'] . '/' : ''; $this->ext_autolink_len = intval($autolink['len']); $this->ext_autolink_enc = $autolink['enc']; $this->ext_autolink_pat = $autolink['pat']; $this->ext_autolink_title = $autolink['title']; $this->ext_autolink_a_target = $autolink['a_target'] ? $autolink['a_target'] : $this->root->link_target; $this->ext_autolink_a_class = $autolink['a_class'] ? $autolink['a_class'] : 'ext_autolink'; if ($this->ext_autolink_pat) { if (strpos($this->ext_autolink_pat, '[URL_ENCODE]') !== false) { $this->ext_autolink_replace['from'] = '[URL_ENCODE]'; $this->ext_autolink_replace['func'] = create_function('$key', 'return urlencode($key);'); } else { if (strpos($this->ext_autolink_pat, '[WIKI_ENCODE]') !== false) { $this->ext_autolink_replace['from'] = '[WIKI_ENCODE]'; $this->ext_autolink_replace['func'] = create_function('$key', 'return XpWikiFunc::encode($key);'); } else { if (strpos($this->ext_autolink_pat, '[EWORDS_ENCODE]') !== false) { $this->ext_autolink_replace['from'] = '[EWORDS_ENCODE]'; $this->ext_autolink_replace['func'] = create_function('$key', 'return str_replace(array(\'%\',\'.\'), array(\'\',\'2E\'), urlencode($key));'); } } } } return $pat; }
function plain_db_write($page, $action, $init = FALSE, $notimestamp = FALSE) { if (!($pgid = $this->get_pgid_by_name($page))) { return false; } // For AutoLink if (!$init && $action !== 'update') { $this->autolink_dat_update(); } $rel_pages = array(); $data = ''; // ¥Ú¡¼¥¸ÆɤߤΥǡ¼¥¿¥Ú¡¼¥¸¤Ï¥³¥ó¥Ð¡¼¥È½èÍý¤·¤Ê¤¤(²áÉé²ÙÂкö) if ($page !== $this->root->pagereading_config_page) { $spc = array(array('<', '>', '&', '"', ''', ' '), array('<', '>', '&', '"', "'", " ")); // Clear page cache $this->clear_page_cache($page); $pobj =& XpWiki::getSingleton($this->root->mydirname); $pobj->init($page); $GLOBALS['Xpwiki_' . $this->root->mydirname]['cache'] = null; $pobj->root->userinfo['admin'] = true; $pobj->root->userinfo['uname_s'] = ''; $pobj->root->read_auth = 0; $pobj->root->rtf['is_init'] = true; $pobj->root->pagecache_min = 0; $pobj->execute(); $data = $pobj->body; // remove javascript $data = preg_replace("#<script.+?/script>#i", "", $data); // ¥ê¥ó¥¯Àè¥Ú¡¼¥¸Ì¾ //$rel_pages = array_merge(array_keys($pobj->related), array_keys($pobj->notyets)); $rel_pages = array_keys($pobj->related); $rel_pages = array_unique($rel_pages); // ̤ºîÀ®¥Ú¡¼¥¸ if ($page !== $this->root->whatsdeleted && $page !== $this->cont['PLUGIN_RENAME_LOGPAGE']) { $yetlists = array(); $notyets = array_keys($pobj->notyets); if (is_file($this->cont['CACHE_DIR'] . "yetlist.dat")) { $yetlists = unserialize(file_get_contents($this->cont['CACHE_DIR'] . "yetlist.dat")); } // ¥Ú¡¼¥¸¿·µ¬ºîÀ®¤µ¤ì¤¿¤é¥ê¥¹¥È¤«¤é½ü³° if ($action === 'insert') { if (isset($yetlists[$page])) { unset($yetlists[$page]); } } // ¤È¤ê¤¢¤¨¤º»²¾È¸µ¥ê¥¹¥È¤«¤é½üµî foreach ($yetlists as $_notyet => $_pages) { $yetlists[$_notyet] = array_diff($_pages, array($page)); if (!$yetlists[$_notyet]) { unset($yetlists[$_notyet]); } } // ºï½ü»þ°Ê³°¤Ï»²¾È¸µ¥ê¥¹¥È¤ËÄɲà if ($action !== 'delete' && $notyets) { foreach ($notyets as $notyet) { $yetlists[$notyet][] = $page; $yetlists[$notyet] = array_unique($yetlists[$notyet]); } } if ($fp = fopen($this->cont['CACHE_DIR'] . "yetlist.dat", "wb")) { fputs($fp, serialize($yetlists)); fclose($fp); } } // ÉÕäµ if (empty($GLOBALS['Xpwiki_' . $this->root->mydirname]['cache']['fusen']['loaded'])) { if ($fusen = $this->get_plugin_instance('fusen')) { if ($fusen_data = $fusen->plugin_fusen_data($page)) { $fusen_tag = $fusen->plugin_fusen_gethtml($fusen_data, ''); $data .= $fusen_tag; } } } $data = preg_replace("/" . preg_quote("<a href=\"{$this->root->script}?cmd=edit&page=", "/") . "[^\"]+" . preg_quote("\">{$this->root->_symbol_noexists}</a>", "/") . "/", "", $data); $data = str_replace($spc[0], $spc[1], strip_tags($data)) . join(',', $rel_pages); // ±Ñ¿ô»ú¤ÏȾ³Ñ,¥«¥¿¥«¥Ê¤ÏÁ´³Ñ,¤Ò¤é¤¬¤Ê¤Ï¥«¥¿¥«¥Ê¤Ë if (function_exists("mb_convert_kana")) { $data = mb_convert_kana($data, 'aKVC'); } } $data = addslashes(preg_replace("/[\\s]+/", " ", $data)); // ¥Ú¡¼¥¸¹¹¿· if ($action === 'update') { $value = "plain='{$data}'"; $query = "UPDATE " . $this->xpwiki->db->prefix($this->root->mydirname . "_plain") . " SET {$value} WHERE pgid = {$pgid};"; if ($result = $this->xpwiki->db->queryF($query)) { //¥ê¥ó¥¯Àè¥Ú¡¼¥¸ $query = "DELETE FROM " . $this->xpwiki->db->prefix($this->root->mydirname . "_rel") . " WHERE pgid = " . $pgid . ";"; $this->xpwiki->db->queryF($query); foreach ($rel_pages as $rel_page) { $relid = $this->get_pgid_by_name($rel_page); if ($pgid == $relid || !$relid) { continue; } $query = "INSERT INTO " . $this->xpwiki->db->prefix($this->root->mydirname . "_rel") . " (pgid,relid) VALUES(" . $pgid . "," . $relid . ");"; $this->xpwiki->db->queryF($query); } if (!$init && $notimestamp === FALSE && $this->check_readable_page($page, FALSE, FALSE, 0)) { // Send update ping $this->send_update_ping(); } return true; } else { // Update ¤Ê¤Î¤Ë¥Ç¡¼¥¿¤¬¤Ê¤¤ÌÏÍÍ $action = 'insert'; } } // ¿·µ¬ºîÀ® if ($action === 'insert') { // Ç°¤Î¤¿¤áºï½ü $query = "DELETE FROM " . $this->xpwiki->db->prefix($this->root->mydirname . "_plain") . " WHERE `pgid`='{$pgid}' LIMIT 1"; $this->xpwiki->db->queryF($query); $query = "INSERT INTO " . $this->xpwiki->db->prefix($this->root->mydirname . "_plain") . " (pgid,plain) VALUES({$pgid},'{$data}');"; $this->xpwiki->db->queryF($query); //¥ê¥ó¥¯Àè¥Ú¡¼¥¸ // Ç°¤Î¤¿¤áºï½ü $query = "DELETE FROM " . $this->xpwiki->db->prefix($this->root->mydirname . "_rel") . " WHERE pgid = " . $pgid . ";"; $this->xpwiki->db->queryF($query); foreach ($rel_pages as $rel_page) { $relid = $this->get_pgid_by_name($rel_page); if ($pgid == $relid || !$relid) { continue; } $query = "INSERT INTO " . $this->xpwiki->db->prefix($this->root->mydirname . "_rel") . " (pgid,relid) VALUES(" . $pgid . "," . $relid . ");"; $this->xpwiki->db->queryF($query); } //¥ê¥ó¥¯¸µ¥Ú¡¼¥¸ // $page¤¬AutoLink¤ÎÂоݤȤʤêÆÀ¤ë¾ì¹ç if (!$init && $this->root->autolink and preg_match('/^' . $this->root->WikiName . '$/', $page) ? $this->root->nowikiname : strlen($page) >= $this->root->autolink) { // $page¤ò»²¾È¤·¤Æ¤¤¤½¤¦¤Ê¥Ú¡¼¥¸¤Ë°ìµ¤¤ËÄɲà $this->root->search_non_list = 1; $lookup_page = $page; // ¸¡º÷¥Ú¡¼¥¸Ì¾¤Î¶¦ÄÌ¥ê¥ó¥¯¥Ç¥£¥ì¥¯¥È¥ê¤ò¾Êά foreach ($this->root->ext_autolinks as $valid => $autolink) { if ($autolink['url'] === '') { if (strpos($lookup_page, $autolink['base']) === 0) { $lookup_page = substr($lookup_page, strlen($autolink['base']) + 1); if ($this->root->autolink > strlen($lookup_page)) { $lookup_page = $page; } break; } } } // Page Aliases $andor = 'AND'; if ($alias = join(' ', $this->get_page_alias($page, TRUE))) { $andor = 'OR'; $lookup_page .= ' ' . $alias; } // ¸¡º÷¼Â¹Ô $pages = !empty($this->root->rtf['is_init']) ? $this->do_source_search($lookup_page, $andor, TRUE) : $this->do_search($lookup_page, $andor, TRUE); foreach ($pages as $_page) { $refid = $this->get_pgid_by_name($_page); if ($pgid == $refid || !$refid) { continue; } $query = "INSERT INTO " . $this->xpwiki->db->prefix($this->root->mydirname . "_rel") . " (pgid,relid) VALUES(" . $refid . "," . $pgid . ");"; $result = $this->xpwiki->db->queryF($query); // Áê¼êÀè¥Ú¡¼¥¸¤â¹¹¿· $this->plain_db_write($_page, 'update', FALSE, TRUE); } } // Send update ping if ($notimestamp === FALSE && $this->check_readable_page($page, FALSE, FALSE, 0)) { $this->send_update_ping(); } } elseif ($action === 'delete') { $query = "DELETE FROM " . $this->xpwiki->db->prefix($this->root->mydirname . "_plain") . " WHERE pgid = {$pgid};"; $result = $this->xpwiki->db->queryF($query); //if (!$result) echo $query."<hr>"; //¥ê¥ó¥¯¥Ú¡¼¥¸ $query = "DELETE FROM " . $this->xpwiki->db->prefix($this->root->mydirname . "_rel") . " WHERE pgid = " . $pgid . " OR relid = " . $pgid . ";"; $result = $this->xpwiki->db->queryF($query); // Optimaize DB tables $tables = array(); foreach (array('attach', 'cache', 'count', 'pginfo', 'plain', 'rel', 'tb') as $table) { $tables[] = '`' . $this->xpwiki->db->prefix($this->root->mydirname . '_' . $table) . '`'; } $sql = 'OPTIMIZE TABLE ' . join(',', $tables); $this->xpwiki->db->queryF($sql); } else { return false; } return true; }
function &get_interwiki_url($name, &$param, &$alias) { static $interwikinames = array(); static $encode_aliases = array('sjis' => 'SJIS', 'euc' => 'EUC-JP', 'utf8' => 'UTF-8'); $false = FALSE; if (!isset($interwikinames[$this->root->mydirname])) { $interwiki_dat = $this->cont['CACHE_DIR'] . 'interwiki.dat'; if (is_file($interwiki_dat)) { $interwikinames[$this->root->mydirname] = unserialize(file_get_contents($interwiki_dat)); } else { $interwikinames[$this->root->mydirname] = $this->interwiki_dat_update($this->get_source($this->root->interwiki)); } } if (!isset($interwikinames[$this->root->mydirname][$name])) { // Inner other xpwiki if ($this->isXpWikiDirname($name)) { $interwikinames[$this->root->mydirname][$name] = array($name, 'inner'); } else { return $false; } } list($url, $opt) = $interwikinames[$this->root->mydirname][$name]; $replaces = array(); if (strpos($opt, '|') !== FALSE) { $options = explode('|', $opt); $opt = array_shift($options); foreach ($options as $option) { if (strpos($option, '>')) { list($from, $to) = explode('>', $option); $replaces[$from] = $to; } else { if ($alias === '' && substr($option, 0, 7) === 'prefix:') { $alias = substr($option, 7) . $param; } } } if ($replaces) { $param = strtr($param, $replaces); } } // Encoding switch ($opt) { case '': /* FALLTHROUGH */ /* FALLTHROUGH */ case 'std': // Simply URL-encode the string, whose base encoding is the internal-encoding $param = rawurlencode($param); break; case 'asis': /* FALLTHROUGH */ /* FALLTHROUGH */ case 'raw': // Truly as-is $param = $param; break; case 'yw': // YukiWiki if (!preg_match('/' . $this->root->WikiName . '/', $param)) { $param = '[[' . mb_convert_encoding($param, 'SJIS', $this->cont['SOURCE_ENCODING']) . ']]'; } break; case 'moin': // MoinMoin $param = str_replace('%', '_', rawurlencode($param)); break; // Æó½Å¤ËURL¥¨¥ó¥³¡¼¥É¤¹¤ë // Æó½Å¤ËURL¥¨¥ó¥³¡¼¥É¤¹¤ë case 'dbl': $param = rawurlencode(rawurlencode($param)); break; case 'dbl_utf8': $param = rawurlencode(rawurlencode(mb_convert_encoding($param, 'UTF-8', $this->cont['SOURCE_ENCODING']))); break; case 'dbl_sjis': $param = rawurlencode(rawurlencode(mb_convert_encoding($param, 'SJIS', $this->cont['SOURCE_ENCODING']))); break; case 'dbl_euc-jp': $param = rawurlencode(rawurlencode(mb_convert_encoding($param, 'EUC-JP', $this->cont['SOURCE_ENCODING']))); break; // HexEncode·Ï // HexEncode·Ï case 'hex_utf8': case 'wiki_utf8': $param = $this->encode(mb_convert_encoding($param, 'UTF-8', $this->cont['SOURCE_ENCODING'])); break; case 'hex_sjis': case 'wiki_sjis': $param = $this->encode(mb_convert_encoding($param, 'SJIS', $this->cont['SOURCE_ENCODING'])); break; case 'hex_euc-jp': case 'wiki_euc-jp': $param = $this->encode(mb_convert_encoding($param, 'EUC-JP', $this->cont['SOURCE_ENCODING'])); break; // Inner other xpwiki // Inner other xpwiki case 'inner': case 'xpwiki': if (strpos($url, '?') !== FALSE) { list($url, $prefix) = explode('?', $url, 2); $param = $prefix . $param; } $otherObj =& XpWiki::getInitedSingleton(basename($url)); if ($otherObj->isXpWiki) { if ($param !== '') { if (!$otherObj->func->is_pagename($param)) { return $false; } } return $otherObj; } return $false; break; // Rakuten affiliate // Rakuten affiliate case 'rakuten': $param = '?pc=http%3A%2F%2Fesearch.rakuten.co.jp%2Frms%2Fsd%2Fesearch%2Fvc%3Fsv%3D2%26sitem%3D' . urlencode(urlencode(mb_convert_encoding($param, 'EUC-JP', $this->cont['SOURCE_ENCODING']))) . '&m=http%3A%2F%2Fs.j.rakuten.co.jp%2Fr%2Fs%2Fwb%3Fws%3D1%26w%3D' . urlencode(urlencode(mb_convert_encoding($param, 'SJIS', $this->cont['SOURCE_ENCODING']))); break; // ewords // ewords case 'ewords': $param = str_replace(array('%', '.'), array('', '2E'), urlencode(mb_convert_encoding($param, 'UTF-8', $this->cont['SOURCE_ENCODING']))); break; default: // Alias conversion of $opt if (isset($encode_aliases[$opt])) { $opt =& $encode_aliases[$opt]; } // Encoding conversion into specified encode, and URLencode $param = rawurlencode(mb_convert_encoding($param, $opt, $this->cont['SOURCE_ENCODING'])); } // Replace or Add the parameter if (strpos($url, '$1') !== $false) { $url = str_replace('$1', $param, $url); } else { $url .= $param; } if (!preg_match('/' . $this->root->interwikinameRegex . '[!~*\'();\\/?:\\@&=+\\$,%#_0-9a-zA-Z.-]*/', $url) || strlen($url) > 512) { return $false; } return $url; }
function plugin_edit_write() { $_uname = empty($this->root->vars['uname']) || !empty($this->root->vars['anonymous']) ? $this->root->siteinfo['anonymous'] : $this->root->vars['uname']; if ($_uname) { if (!empty($this->root->vars['anonymous'])) { $this->root->cookie['name'] = $_uname; } else { // save name to cookie $this->func->save_name2cookie($_uname); } } $page = isset($this->root->vars['page']) ? $this->root->vars['page'] : ''; $add = isset($this->root->vars['add']) ? $this->root->vars['add'] : ''; $digest = isset($this->root->vars['digest']) ? $this->root->vars['digest'] : ''; $paraid = isset($this->root->vars['paraid']) ? $this->root->vars['paraid'] : ''; $original = ''; $this->root->vars['msg'] = preg_replace($this->cont['PLUGIN_EDIT_FREEZE_REGEX'], '', $this->root->vars['msg']); $this->root->vars['msg'] = $this->func->remove_pginfo($this->root->vars['msg']); $msg =& $this->root->vars['msg']; // Reference // Get original data from cache DB. if (!empty($this->root->vars['orgkey'])) { $original = (string) $this->func->cache_get_db($this->root->vars['orgkey'], 'edit', true); $original = $this->func->remove_pginfo($original); } // ParaEdit $hash = ''; if ($paraid) { if (!$original) { $original = $this->func->remove_pginfo($this->func->get_source($page, TRUE, TRUE)); } $source = preg_split('/([^\\n]*\\n)/', $original, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); if ($this->plugin_edit_parts($paraid, $source, $msg) !== FALSE) { $fullmsg = join('', $source); } else { // $this->root->vars['msg']だけがページに書き込まれてしまうのを防ぐ。 $fullmsg = rtrim($original) . "\n\n" . $msg; } $msg = $fullmsg; $hash = '#' . $paraid; } // 文末処理 $msg = rtrim($msg) . "\n"; // 改行・TAB・スペースのみだったら削除とみなす $msg = preg_replace('/^\\s+$/', '', $msg); // Page title if ($msg && !empty($this->root->post['pgtitle'])) { $msg = $this->root->title_setting_string . trim($this->root->post['pgtitle']) . "\n" . $msg; } $retvars = array(); // Collision Detection $oldpagesrc = $this->func->get_source($page, TRUE, TRUE); $oldpagemd5 = $this->func->get_digests($oldpagesrc); if ($digest != $oldpagemd5) { $this->root->vars['digest'] = $oldpagemd5; // Reset unset($this->root->vars['paraid']); // 更新が衝突したら全文編集に切り替え $oldpagesrc = $this->func->remove_pginfo($oldpagesrc); list($postdata_input, $auto) = $this->func->do_update_diff($oldpagesrc, $msg, $original); $retvars['msg'] = $this->root->_title_collided; $retvars['body'] = ($auto ? $this->root->_msg_collided_auto : $this->root->_msg_collided) . "\n"; $retvars['body'] .= $this->root->do_update_diff_table; $retvars['body'] .= $this->func->edit_form($page, $postdata_input, $oldpagemd5, FALSE); if (isset($this->root->vars['ajax'])) { $this->func->convert_finisher($retvars['body']); $body = <<<EOD <xpwiki> <content><![CDATA[{$retvars['body']}]]></content> <mode>preview</mode> </xpwiki> EOD; $this->func->send_xml($body); } return $retvars; } // Action? if ($add) { // Add if (isset($this->root->vars['add_top']) && $this->root->vars['add_top']) { $postdata = $msg . "\n\n" . $this->func->get_source($page, TRUE, TRUE); } else { $postdata = $this->func->get_source($page, TRUE, TRUE) . "\n\n" . $msg; } } else { // Edit or Remove $postdata =& $msg; // Reference } // NULL POSTING, OR removing existing page if (!$postdata) { $this->func->page_write($page, ''); if ($this->root->trackback) { $this->func->tb_delete($page); } if ($this->root->maxshow_deleted && $this->func->is_page($this->root->whatsdeleted)) { $url = $this->func->get_page_uri($this->root->whatsdeleted, true); } else { $url = $this->cont['HOME_URL']; } $title = str_replace('$1', $this->func->htmlspecialchars($page), $this->root->_title_deleted); if (isset($this->root->vars['ajax'])) { $url = $this->func->htmlspecialchars($url, ENT_QUOTES); $body = <<<EOD <xpwiki> <content><![CDATA[{$title}]]></content> <mode>delete</mode> <url>{$url}</url> </xpwiki> EOD; $this->func->send_xml($body); } $this->func->redirect_header($url, 1, $title); } // $notimeupdate: Checkbox 'Do not change timestamp' $notimestamp = isset($this->root->vars['notimestamp']) && $this->root->vars['notimestamp'] != ''; if ($this->root->notimeupdate > 1 && !$this->root->userinfo['admin']) { $notimestamp = false; } $this->func->page_write($page, $postdata, $this->root->notimeupdate != 0 && $notimestamp); if (isset($this->root->vars['ajax'])) { if (!empty($this->root->vars['nonconvert'])) { $body = ''; } else { $obj = new XpWiki($this->root->mydirname); $obj->init($page); $obj->root->userinfo['uname_s'] = $this->func->htmlspecialchars($this->root->cookie['name']); $obj->execute(); if (isset($obj->root->rtf['useJavascriptInHead'])) { $body = '<script src="" />'; } else { $body = $obj->body; // set target if (isset($this->root->vars['popup'])) { $body = preg_replace('/(<a[^>]+)(href=(?:"|\')[^#])/isS', '$1target="' . (intval($this->root->vars['popup']) === 1 ? '_parent' : $this->func->htmlspecialchars(substr($this->root->vars['popup'], 0, 30))) . '" $2', $body); } $body = str_replace(array('<![CDATA[', ']]>'), '', $body); } if (preg_match('/\\(\\([eisv]:[0-9a-f]{4}\\)\\)|\\[emj:\\d{1,4}(?::(?:im|ez|sb))?\\]/S', $body)) { if (!XC_CLASS_EXISTS('MobilePictogramConverter')) { HypCommonFunc::loadClass('MobilePictogramConverter'); } if (XC_CLASS_EXISTS('MobilePictogramConverter')) { $mpc =& MobilePictogramConverter::factory_common(); $mpc->setImagePath($this->cont['ROOT_URL'] . 'images/emoji'); $mpc->setString($body, FALSE); $body = $mpc->autoConvertModKtai(); } } } $body = <<<EOD <xpwiki> <content><![CDATA[{$body}]]></content> <mode>write</mode> </xpwiki> EOD; $this->func->send_xml($body); } $this->func->send_location($page, $hash); }
function get($keywords, $andor, $limit, $offset, $userid) { // for XOOPS Search module $showcontext = empty($_GET['showcontext']) ? 0 : 1; $where_readable = $this->func->get_readable_where('p.'); $where = "p.editedtime != 0"; if ($where_readable) { $where = "{$where} AND ({$where_readable})"; } $sql = "SELECT p.pgid,p.name,p.editedtime,p.title,p.uid FROM " . $this->xpwiki->db->prefix($this->root->mydirname . "_pginfo") . " p INNER JOIN " . $this->xpwiki->db->prefix($this->root->mydirname . "_plain") . " t ON t.pgid=p.pgid WHERE ({$where}) "; if ($userid != 0) { $sql .= "AND (p.uid=" . $userid . ") "; } if (is_array($keywords) && $keywords) { $keywords = array_map('stripslashes', $keywords); // 英数字は半角,カタカナは全角,ひらがなはカタカナに $sql .= "AND ("; $i = 0; foreach ($keywords as $keyword) { if ($i++ !== 0) { $sql .= " {$andor} "; } if ($this->cont['LANG'] === 'ja' && function_exists("mb_convert_kana")) { // 英数字は半角,カタカナは全角,ひらがなはカタカナに $word = addslashes(mb_convert_kana($keyword, 'aKCV')); } else { $word = addslashes($keyword); } $sql .= "(p.name_ci LIKE '%{$word}%' OR t.plain LIKE '%{$word}%')"; } $sql .= ") "; } $sql .= "ORDER BY p.editedtime DESC"; //exit($sql); $result = $this->xpwiki->db->query($sql, $limit, $offset); $ret = array(); if (!$keywords) { $keywords = array(); } $sword = rawurlencode(join(' ', $keywords)); $context = ''; $make_context_func = function_exists('xoops_make_context') ? 'xoops_make_context' : (function_exists('search_make_context') ? 'search_make_context' : ''); while ($myrow = $this->xpwiki->db->fetchArray($result)) { // get context for module "search" if ($make_context_func && $showcontext) { $pobj =& XpWiki::getSingleton($this->root->mydirname); $pobj->init($myrow['name']); $GLOBALS['Xpwiki_' . $this->root->mydirname]['cache'] = null; $pobj->root->rtf['use_cache_always'] = TRUE; $pobj->execute(); $text = $pobj->body; $text = preg_replace('/<!--description ignore-->.+?<!--\\/description ignore-->|<(script|style).+?<\\/\\1>/is', '', $text); // 付箋 if (empty($GLOBALS['Xpwiki_' . $this->root->mydirname]['cache']['fusen']['loaded'])) { if ($fusen = $this->func->get_plugin_instance('fusen')) { if ($fusen_data = $fusen->plugin_fusen_data($myrow['name'])) { if ($fusen_tag = $fusen->plugin_fusen_gethtml($fusen_data, '')) { $text .= '<fieldset><legend> fusen.dat </legend>' . $fusen_tag . '</fieldset>'; } } } } $full_context = strip_tags($text); if (function_exists('easiestml')) { $full_context = easiestml($full_context); } $context = $make_context_func($full_context, $keywords); } $title = $myrow['title'] ? ' [' . $myrow['title'] . ']' : ''; $link = $this->func->get_page_uri($myrow['name']); $ret[] = array('link' => $link . (strpos($link, '?') === false ? '?' : '&') . 'word=' . $sword, 'title' => htmlspecialchars($myrow['name'] . $title, ENT_QUOTES, _CHARSET), 'image' => 'skin/loader.php?src=xoops_search.png', 'time' => $myrow['editedtime'] + $this->cont['LOCALZONE'], 'uid' => $myrow['uid'], 'page' => $myrow['name'], 'context' => $context); } // for xoops search module $GLOBALS['md_search_flg_zenhan_support'] = true; return $ret; }
error_reporting(0); $source = isset($_POST['s']) ? $_POST['s'] : ''; $line_break = isset($_POST['lb']) ? strval($_POST['lb']) : ''; $page = isset($_POST['page']) ? $_POST['page'] : ''; if (get_magic_quotes_gpc()) { $source = stripslashes($source); $page = stripslashes($page); } define('DEBUG', !empty($_GET['debug'])); if ($source || $line_break === '') { if ($source) { $source = str_replace(array("\r\n", "\r"), "\n", $source); $source = rtrim($source) . "\n"; } include_once $mytrustdirpath . '/include.php'; $xpwiki = new XpWiki($mydirname); $xpwiki->root->fckediting = true; $xpwiki->init('#RenderMode'); if ($page) { $e_page = mb_convert_encoding($page, $xpwiki->cont['SOURCE_ENCORDING'], 'UTF-8'); $xpwiki->cont['PageForRef'] = $xpwiki->root->vars['page'] = $xpwiki->root->post['page'] = $xpwiki->root->get['page'] = $e_page; } // 定数設定 define('PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK', $xpwiki->cont['PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK']); define('MSIE', strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE); define('COLORS_REG', 'aqua|navy|black|olive|blue|purple|fuchsia|red|gray|silver|green|teal|lime|white|maroon|yellow|transparent'); // globals if ($line_break === '') { $line_break = $xpwiki->root->line_break; } $hr = $xpwiki->root->hr;
function xpwikifunc_delete_counter($mydirname) { $msg = array(); include_once XOOPS_TRUST_PATH . '/modules/xpwiki/include.php'; $xpwiki = XpWiki::getInitedSingleton($mydirname); if ($xpwiki->func->get_plugin_instance('counter')) { $dir = $xpwiki->cont['COUNTER_DIR']; if ($handle = opendir($dir)) { $suffix = $xpwiki->cont['PLUGIN_COUNTER_SUFFIX']; $del = false; while (false !== ($file = readdir($handle))) { if (substr($file, strlen($suffix) * -1) === $suffix) { $target = $dir . $file; $del = unlink($target) || $del; //$msg[] = $target; } } closedir($handle); if ($del) { $msg[] = 'All counter files (' . $dir . '*' . $suffix . ') were deleted successful.'; } } } return $msg; }
<?php // Forbid prefetch if (isset($_SERVER['HTTP_X_MOZ']) && $_SERVER['HTTP_X_MOZ'] === 'prefetch' || isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] === 'Fasterfox') { header('HTTP/1.1 403 Forbidden'); exit; } $mytrustdirname = basename(dirname(__FILE__)); $mytrustdirpath = dirname(__FILE__); include_once "{$mytrustdirpath}/include.php"; $xpwiki = new XpWiki($mydirname); // initialize $xpwiki->init(); // XCL >= 2.2 Use "Legacy_Utils::formatPagetitle" if (defined('LEGACY_MODULE_VERSION') && version_compare(LEGACY_MODULE_VERSION, '2.2', '>=')) { $xpwiki->root->html_head_title = trim(str_replace('$module_title', '', $xpwiki->root->html_head_title), ' -'); } // execute $xpwiki->execute(); // gethtml $xpwiki->catbody(); // Add error message if ($xpwiki->root->userinfo['admin']) { $hyp_common_methods = get_class_methods('HypCommonFunc'); if (is_null($hyp_common_methods) || !in_array('get_version', $hyp_common_methods) || HypCommonFunc::get_version() < 20100725) { $xpwiki->admin_messages[] = '[Warning] Please install or update <a href="http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/hypweb/XOOPS_TRUST/class/hyp_common.tar.gz?view=tar" title="Download">a newest HypCommonFunc</a> into "XOOPS_TRUST_PATH/class/".'; } if ($xpwiki->admin_messages) { $xpwiki->html = '<p style="color:red;font-weight:bold;">' . join('<br />', $xpwiki->admin_messages) . '</p><hr />' . $xpwiki->html; } }
function &renderWikistyle($text, $html = 0, $smiley = 1, $xcode = 1, $image = 1, $br = 1, $use_cache = 0) { static $pat = array(); static $rep = array(); $className = get_class($this); $br = $br ? 1 : 0; $use_cache = $use_cache ? 1 : 0; $smiley = $smiley ? 1 : 0; $image = $image ? 1 : 0; // xpWiki if (!class_exists('XpWiki')) { include XOOPS_TRUST_PATH . '/modules/xpwiki/include.php'; } $render = XpWiki::getSingleton(XPWIKI_RENDERER_DIR); // pukiwiki.ini.php setting $render->setIniRoot('line_break', $br); $render->setIniRoot('render_use_cache', $use_cache); $render->setIniRoot('use_extra_facemark', 1); $render->setIniRoot('usefacemark', $smiley); $render->setIniRoot('render_cache_min', 1440); // 1day $render->setIniRoot('link_target', '_blank'); $render->setIniRoot('nowikiname', 1); $render->setIniRoot('show_passage', 0); $render->setIniRoot('no_slashes_commentout', 1); if ($xcode) { if (!isset($pat[$className][$image])) { // BB Code code $pat[$className][$image][] = '/(?:\\r\\n|\\r|\\n)?\\[code](?:\\r\\n|\\r|\\n)?(.*)(?:\\r\\n|\\r|\\n)?\\[\\/code\\](?:\\r\\n|\\r|\\n)?/sUS'; $rep[$className][$image][] = "\n" . '#code(){{{' . "\n" . '$1' . "\n" . '}}}' . "\n"; // BB Code email $pat[$className][$image][] = '/\\[email](.+?)\\[\\/email]/iS'; $rep[$className][$image][] = '$1'; // BB Code url $pat[$className][$image][] = '/\\[url=([\'"]?)((?:ht|f)tp[s]?:\\/\\/[!~*\'();\\/?:\\@&=+\\$,%#\\w.-]+)\\1\\](.+)\\[\\/url\\]/esUS'; $rep[$className][$image][] = '\'[[\'.Hyp_TextFilter::renderWiki_ret2br(\'$3\').\':$2]]\''; $pat[$className][$image][] = '/\\[url=([\'"]?)([!~*\'();\\/?:\\@&=+\\$,%#\\w.-]+)\\1\\](.+)\\[\\/url\\]/esUS'; $rep[$className][$image][] = '\'[[\'.Hyp_TextFilter::renderWiki_ret2br(\'$3\').\':http://$2]]\''; $pat[$className][$image][] = '/\\[siteurl=([\'"]?)\\/?([!~*\'();?:\\@&=+\\$,%#\\w.-][!~*\'();\\/?:\\@&=+\\$,%#\\w.-]+)\\1\\](.+)\\[\\/siteurl\\]/esUS'; $rep[$className][$image][] = '\'[[\'.Hyp_TextFilter::renderWiki_ret2br(\'$3\').\':http:///$2]]\''; // BB Code quote $pat[$className][$image][] = '/(\\[quote[^\\]]*])(?:\\r\\n|\\r|\\n)(?![<>*|,#: \\t+-])/S'; $rep[$className][$image][] = "\n\n\$1"; $pat[$className][$image][] = '/(?:\\r\\n|\\r|\\n)*\\[\\/quote\\]/S'; $rep[$className][$image][] = '[/quote]' . "\n\n"; if ($image) { // BB Code image with align $pat[$className][$image][] = '/\\[img\\s+align=([\'"]?)(left|center|right)\\1(?:\\s+title=([\'"]?)([^\'"][^\\]\\s]*?)\\3)?(?:\\s+w(?:idth)?=([\'"]?)([\\d]+?)\\5)?(?:\\s+h(?:eight)?=([\'"]?)([\\d]+?)\\7)?]([!~*\'();\\/?:\\@&=+\\$,%#\\w.-]+)\\[\\/img\\]/US'; $rep[$className][$image][] = '&ref($9,$2,"t:$4",mw:$6,mw:$8);'; // BB Code image normal $pat[$className][$image][] = '/\\[img(?:\\s+title=([\'"]?)([^\'"][^\\]\\s]*?)\\1)?(?:\\s+w(?:idth)?=([\'"]?)([\\d]+?)\\3)?(?:\\s+h(?:eight)?=([\'"]?)([\\d]+?)\\5)?]([!~*\'();\\/?:\\@&=+\\$,%#\\w.-]+)\\[\\/img\\]/US'; $rep[$className][$image][] = '&ref($7,"t:$2",mw:$4,mw:$6);'; } else { // BB Code image with align $pat[$className][$image][] = '/\\[img\\s+align=([\'"]?)(left|center|right)\\1(?:\\s+title=([\'"]?)([^\'"][^\\]\\s]*?)\\3)?(?:\\s+w(?:idth)?=([\'"]?)([\\d]+?)\\5)?(?:\\s+h(?:eight)?=([\'"]?)([\\d]+?)\\7)?]([!~*\'();\\/?:\\@&=+\\$,%#\\w.-]+)\\[\\/img\\]/US'; $rep[$className][$image][] = '&ref($9,"t:$4",noimg);'; // BB Code image normal $pat[$className][$image][] = '/\\[img(?:\\s+title=([\'"]?)([^\'"][^\\]\\s]*?)\\1)?(?:\\s+w(?:idth)?=([\'"]?)([\\d]+?)\\3)?(?:\\s+h(?:eight)?=([\'"]?)([\\d]+?)\\5)?]([!~*\'();\\/?:\\@&=+\\$,%#\\w.-]+)\\[\\/img\\]/US'; $rep[$className][$image][] = '&ref($7,"t:$2",noimg);'; } // BB Code siteimage with align $pat[$className][$image][] = '/\\[siteimg\\s+align=([\'"]?)(left|center|right)\\1(?:\\s+title=([\'"]?)([^\'"][^\\]\\s]*?)\\3)?(?:\\s+w(?:idth)?=([\'"]?)([\\d]+?)\\5)?(?:\\s+h(?:eight)?=([\'"]?)([\\d]+?)\\7)?]\\/?([!~*\'();?\\@&=+\\$,%#\\w.-][!~*\'();\\/?\\@&=+\\$,%#\\w.-]+?)\\[\\/siteimg\\]/US'; $rep[$className][$image][] = '&ref(http:///$9,$2,"t:$4",mw:$6,mw:$8);'; // BB Code siteimage normal $pat[$className][$image][] = '/\\[siteimg(?:\\s+title=([\'"]?)([^\'"][^\\]\\s]*?)\\1)?(?:\\s+w(?:idth)?=([\'"]?)([\\d]+?)\\3)?(?:\\s+h(?:eight)?=([\'"]?)([\\d]+?)\\5)?]\\/?([!~*\'();?\\@&=+\\$,%#\\w.-][!~*\'();\\/?\\@&=+\\$,%#\\w.-]+?)\\[\\/siteimg\\]/US'; $rep[$className][$image][] = '&ref(http:///$7,"t:$2",mw:$4,mw:$6);'; // Some BB Code Tags, Contents allows xpWiki rendering. if ($_reg = join('|', $this->renderWiki_getEscTags())) { $pat[$className][$image][] = '/\\[\\/?(?:' . $_reg . ')(?:(?: |=)[^\\]]+)?\\]/eS'; $rep[$className][$image][] = '\'[ b 6 4 ]\' . base64_encode(\'$0\') . \'[ / b 6 4 ]\''; } // Other or Unknown BB Code Tags, All part escapes. if ($_reg = join('|', $this->renderWiki_getBypassTags())) { $pat[$className][$image][] = '/\\[(' . $_reg . ')(?:\\b[^\\]]+)?].+\\[\\/\\1\\]/esUS'; $rep[$className][$image][] = '\'[ b 6 4 ]\' . base64_encode(\'$0\') . \'[ / b 6 4 ]\''; } } $text = preg_replace($pat[$className][$image], $rep[$className][$image], $text); } if ($text = $render->transform($text, XPWIKI_RENDERER_DIR)) { if (isset($pat[$className])) { // BB Code decode $text = preg_replace('/\\[ b 6 4 ](.+?)\\[ \\/ b 6 4 ]/eS', 'Hyp_TextFilter::renderWiki_base64decode(\'$1\',\'' . $render->root->word_breaker . '\')', $text); } // XOOPS Quote style $text = str_replace(array('<blockquote>', '</blockquote>'), array('<div class="paragraph">' . _QUOTEC . '<div class="xoopsQuote"><blockquote>', '</blockquote></div></div>'), $text); } return $text; }
function make_body($cmd, $dir, $retry = false, $pages = array()) { $select = ''; if ($dir === $this->cont['DATA_DIR']) { $ext = '.txt'; $_dir = dirname($this->cont['DATA_HOME']); $items = array(); if ($dh = opendir($_dir)) { while (($item = readdir($dh)) !== false) { if (is_dir($_dir . '/' . $item)) { if ($this->root->mydirname !== $item && is_file($_dir . '/' . $item . '/private/ini/pukiwiki.ini.php')) { $obj =& XpWiki::getInitedSingleton($item); if ($obj->root->module['mid']) { $items[] = $item; } } } } closedir($dh); } if ($items) { $select = '<div><input type="checkbox" name="move" value="1" /> '; $select .= $this->msg['msg_move_flag']; $select .= '<select name="movedir">'; foreach ($items as $_dir) { $select .= '<option value="' . $_dir . '">' . $_dir . '</option>'; } $select .= '</select></div>'; } } elseif ($dir === $this->cont['BACKUP_DIR']) { $ext = function_exists('gzfile') ? ".gz" : ".txt"; } elseif ($dir === $this->cont['DIFF_DIR']) { $ext = '.txt'; } elseif ($dir === $this->cont['TRACKBACK_DIR']) { $ext = '.ref'; } elseif ($dir === $this->cont['COUNTER_DIR']) { $ext = '.count'; } $script = $this->func->get_script_uri(); $body = ''; $body .= "<form method='post' action=\"{$script}?cmd={$cmd}\"><div>\n"; if ($dir === $this->cont['DATA_DIR']) { $body .= "<input type=\"hidden\" name=\"dir\" value=\"DATA\"/>\n"; $body .= "<input type=\"hidden\" name=\"mode\" value=\"select\"/>\n"; $body .= "{$this->msg['msg_regexp_label']}<input type='text' name='regexp' value='{$this->root->vars['s_regxp']}' />\n"; $body .= "<input type=\"submit\" value=\"{$this->msg['btn_research']}\" /></div></form>\n"; } if ($retry === false) { $body .= "<form method='post' action=\"{$script}?cmd={$cmd}\"><div>\n"; if ($pages) { $body .= $this->page_list2($pages, 'read', FALSE, TRUE); } else { if ($dir === $this->cont['DATA_DIR']) { $body .= '<p>' . $this->msg['msg_is_freezed'] . '</p>'; $body .= $this->page_list2($this->func->get_existpages(true)); } else { $body .= '<p>' . $this->msg['msg_is_freezed'] . '</p>'; $body .= '<p>' . $this->msg['msg_is_deleted'] . '</p>'; $body .= $this->page_list2($this->func->get_existpages($dir, $ext, true)); } } if ($dir === $this->cont['DATA_DIR']) { $dir = 'DATA'; $body .= $cmd === 'deldel' ? "<input type=\"checkbox\" name=\"cascade\" value=\"1\" checked=\"checked\"/> <span>{$this->msg['msg_together_flag']}</span><br />\n" : ""; $body .= $select; } elseif ($dir === $this->cont['BACKUP_DIR']) { $dir = 'BACKUP'; } elseif ($dir === $this->cont['DIFF_DIR']) { $dir = 'DIFF'; } elseif ($dir === $this->cont['TRACKBACK_DIR']) { $dir = 'REFERER'; } elseif ($dir === $this->cont['COUNTER_DIR']) { $dir = 'COUNTER'; } $body .= "<input type=\"hidden\" name=\"mode\" value=\"confirm\"/>\n"; $body .= "<input type=\"hidden\" name=\"dir\" value=\"{$dir}\"/>\n"; $body .= "<input type=\"submit\" value=\"{$this->msg['btn_concern']}\" /></div></form>\n"; $body .= $this->msg['msg_check']; } return $body; }
function xpwiki_onupdate_base($module, $mydirname) { // transations on module update global $msgs; // TODO :-D // for Cube 2.1 if (defined('XOOPS_CUBE_LEGACY')) { $root =& XCube_Root::getSingleton(); $root->mDelegateManager->add('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($mydirname) . '.Success', 'xpwiki_message_append_onupdate'); $root->mDelegateManager->add('Legacy.Admin.Event.ModuleUpdate.' . ucfirst($mydirname) . '.Fail', 'xpwiki_message_append_onupdate'); $msgs = array(); } else { if (!is_array($msgs)) { $msgs = array(); } } $db =& Database::getInstance(); $mid = $module->getVar('mid'); // DB Check for db non support version $query = "SELECT * FROM " . $db->prefix($mydirname . "_pginfo"); if (!$db->query($query)) { // TABLES (loading mysql.sql) $sql_file_path = dirname(__FILE__) . '/sql/mysql.sql'; $prefix_mod = $db->prefix() . '_' . $mydirname; if (file_exists($sql_file_path)) { $ret[] = "SQL file found at <b>" . htmlspecialchars($sql_file_path, ENT_COMPAT, _CHARSET) . "</b>.<br /> Creating tables..."; if (is_file(XOOPS_ROOT_PATH . '/class/database/oldsqlutility.php')) { include_once XOOPS_ROOT_PATH . '/class/database/oldsqlutility.php'; $sqlutil = new OldSqlUtility(); } else { include_once XOOPS_ROOT_PATH . '/class/database/sqlutility.php'; $sqlutil = new SqlUtility(); } $sql_query = trim(file_get_contents($sql_file_path)); $sqlutil->splitMySqlFile($pieces, $sql_query); $created_tables = array(); foreach ($pieces as $piece) { $prefixed_query = $sqlutil->prefixQuery($piece, $prefix_mod); if (!$prefixed_query) { $ret[] = "Invalid SQL <b>" . htmlspecialchars($piece, ENT_COMPAT, _CHARSET) . "</b><br />"; return false; } if (!$db->query($prefixed_query[0])) { $ret[] = '<b>' . htmlspecialchars($db->error(), ENT_COMPAT, _CHARSET) . '</b><br />'; //var_dump( $db->error() ) ; return false; } else { if (!in_array($prefixed_query[4], $created_tables)) { $ret[] = 'Table <b>' . htmlspecialchars($prefix_mod . '_' . $prefixed_query[4], ENT_COMPAT, _CHARSET) . '</b> created.<br />'; $created_tables[] = $prefixed_query[4]; } else { $ret[] = 'Data inserted to table <b>' . htmlspecialchars($prefix_mod . '_' . $prefixed_query[4], ENT_COMPAT, _CHARSET) . '</b>.</br />'; } } } } } // TABLES (write here ALTER TABLE etc. if necessary) $query = "SELECT `reading` FROM " . $db->prefix($mydirname . "_pginfo"); if (!$db->query($query)) { $db->queryF('ALTER TABLE `' . $db->prefix($mydirname . "_pginfo") . '` ADD `reading` VARCHAR( 255 ) BINARY NOT NULL'); } $query = "SELECT `name_ci` FROM " . $db->prefix($mydirname . "_pginfo"); if (!$db->query($query)) { $db->query('ALTER TABLE `' . $db->prefix($mydirname . '_pginfo') . '` ADD `name_ci` VARCHAR( 255 ) NOT NULL'); $db->query('ALTER TABLE `' . $db->prefix($mydirname . '_pginfo') . '` ADD INDEX ( `name_ci` )'); $db->query('UPDATE `' . $db->prefix($mydirname . '_pginfo') . '` SET `name_ci` = `name`'); } $query = "SELECT `pgorder` FROM " . $db->prefix($mydirname . "_pginfo"); if (!$db->query($query)) { $db->query('ALTER TABLE `' . $db->prefix($mydirname . '_pginfo') . '` ADD `pgorder` FLOAT DEFAULT \'1\' NOT NULL'); } $query = "SELECT count(*) FROM " . $db->prefix($mydirname . "_cache"); if (!$db->query($query)) { $db->query('CREATE TABLE `' . $db->prefix($mydirname . '_cache') . '` ( `key` varchar(64) NOT NULL default \'\', `plugin` varchar(100) NOT NULL default \'\', `data` mediumblob NOT NULL, `mtime` int(11) NOT NULL default \'0\', `ttl` int(11) NOT NULL default \'0\', KEY `key` (`key`), KEY `plugin` (`plugin`) ) ENGINE=MyISAM'); } $query = "SELECT count(*) FROM " . $db->prefix($mydirname . "_alias"); if (!$db->query($query)) { $db->query('CREATE TABLE `' . $db->prefix($mydirname . '_alias') . '` ( `name` varchar(255) binary NOT NULL DEFAULT \'\', `pgid` int(11) NOT NULL DEFAULT \'0\', PRIMARY KEY (`name`), KEY `pgid` (`pgid`) ) ENGINE=MyISAM'); include_once XOOPS_TRUST_PATH . "/modules/xpwiki/include.php"; $xpwiki = XpWiki::getInitedSingleton($mydirname); $xpwiki->init(); if ($xpwiki->root->page_aliases) { $query = array(); foreach ($xpwiki->root->page_aliases as $alias => $page) { if ($pgid = $xpwiki->func->get_pgid_by_name($page)) { $query[] = '(' . $db->quoteString($alias) . ',' . $pgid . ')'; } } if ($query) { $query = 'INSERT INTO `' . $db->prefix($mydirname . "_alias") . '` (`name`,`pgid`) VALUES ' . join(',', $query); if ($db->query($query)) { $inifile = $xpwiki->cont['CACHE_DIR'] . 'pukiwiki.ini.php'; $ini = file_get_contents($inifile); file_put_contents($inifile . '.alias.bak', $ini); $ini = preg_replace('#//<page_aliases>.+//<page_aliases/>\\s+#s', '', $ini); file_put_contents($inifile, $ini); } } } unset($xpwiki); } // ADD Keys $table = $db->prefix($mydirname . '_attach'); if ($result = $db->query('SHOW INDEX FROM `' . $table . '`')) { $keys = array('name' => '', 'type' => '', 'mode' => '', 'age' => ''); while ($arr = $db->fetchArray($result)) { unset($keys[$arr['Key_name']]); } foreach ($keys as $_key => $_val) { $query = 'ALTER TABLE `' . $table . '` ADD INDEX(`' . $_key . '`' . $_val . ')'; $db->query($query); //$msgs[] = $query; } } $table = $db->prefix($mydirname . '_pginfo'); if ($result = $db->query('SHOW INDEX FROM `' . $table . '`')) { $keys = array('editedtime' => '', 'freeze' => '', 'egids' => '', 'vgids' => '', 'eaids' => '(255)', 'vaids' => '(255)', 'vids' => array('vaids' => '(200)', 'vgids' => '(133)')); while ($arr = $db->fetchArray($result)) { unset($keys[$arr['Key_name']]); } foreach ($keys as $_key => $_val) { if (is_array($_val)) { $_index = array(); foreach ($_val as $__key => $__val) { $_index[] = '`' . $__key . '`' . $__val; } $_index = join(', ', $_index); } else { $_index = '`' . $_key . '`' . $_val; } $query = 'ALTER TABLE `' . $table . '` ADD INDEX `' . $_key . '`(' . $_index . ')'; $db->query($query); //$msgs[] = $query; } } $table = $db->prefix($mydirname . '_rel'); if ($result = $db->query('SHOW INDEX FROM `' . $table . '`')) { $keys = array('PRIMARY' => ''); while ($arr = $db->fetchArray($result)) { unset($keys[$arr['Key_name']]); } if ($keys) { $dels = array(); $query = 'SELECT CONCAT(pgid, \'_\', relid) as id, (count(*)-1) as count FROM `' . $table . '` GROUP BY id HAVING count >= 1'; if ($result = $db->query($query)) { while ($arr = $db->fetchRow($result)) { $dels[$arr[0]] = $arr[1]; } } foreach ($dels as $key => $limit) { $arr = explode('_', $key); $query = 'DELETE FROM ' . $table . ' WHERE pgid=' . $arr[0] . ' AND relid=' . $arr[1] . ' LIMIT ' . $limit; $db->query($query); //$msgs[] = $query; } $query = 'ALTER TABLE `' . $table . '` ADD PRIMARY KEY(`pgid`,`relid`)'; $db->query($query); //$msgs[] = $query; } } $table = $db->prefix($mydirname . '_count'); if ($result = $db->query('SHOW INDEX FROM `' . $table . '`')) { $keys = array('today' => ''); while ($arr = $db->fetchArray($result)) { unset($keys[$arr['Key_name']]); } foreach ($keys as $_key => $_val) { $query = 'ALTER TABLE `' . $table . '` ADD INDEX(`' . $_key . '`' . $_val . ')'; $db->query($query); //$msgs[] = $query; } } // TEMPLATES (all templates have been already removed by modulesadmin) $tplfile_handler =& xoops_gethandler('tplfile'); $tpl_path = dirname(__FILE__) . '/templates'; if ($handler = @opendir($tpl_path . '/')) { while (($file = readdir($handler)) !== false) { if (substr($file, 0, 1) == '.') { continue; } $file_path = $tpl_path . '/' . $file; if (is_file($file_path) && substr($file, -5) == '.html') { $mtime = intval(@filemtime($file_path)); $tplfile =& $tplfile_handler->create(); $tplfile->setVar('tpl_source', file_get_contents($file_path), true); $tplfile->setVar('tpl_refid', $mid); $tplfile->setVar('tpl_tplset', 'default'); $tplfile->setVar('tpl_file', $mydirname . '_' . $file); $tplfile->setVar('tpl_desc', '', true); $tplfile->setVar('tpl_module', $mydirname); $tplfile->setVar('tpl_lastmodified', $mtime); $tplfile->setVar('tpl_lastimported', 0); $tplfile->setVar('tpl_type', 'module'); if (!$tplfile_handler->insert($tplfile)) { $msgs[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>' . htmlspecialchars($mydirname . '_' . $file, ENT_COMPAT, _CHARSET) . '</b> to the database.</span>'; } else { $tplid = $tplfile->getVar('tpl_id'); $msgs[] = 'Template <b>' . htmlspecialchars($mydirname . '_' . $file, ENT_COMPAT, _CHARSET) . '</b> added to the database. (ID: <b>' . $tplid . '</b>)'; // generate compiled file include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; include_once XOOPS_ROOT_PATH . '/class/template.php'; if (!xoops_template_touch($tplid)) { $msgs[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>' . htmlspecialchars($mydirname . '_' . $file, ENT_COMPAT, _CHARSET) . '</b>.</span>'; } else { $msgs[] = 'Template <b>' . htmlspecialchars($mydirname . '_' . $file, ENT_COMPAT, _CHARSET) . '</b> compiled.</span>'; } } } } closedir($handler); } include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; include_once XOOPS_ROOT_PATH . '/class/template.php'; xoops_template_clear_module_cache($mid); // xpWiki original functions include_once dirname(__FILE__) . '/include/check.func.php'; $_ret = xpwikifunc_permission_check($mydirname); if (!$_ret) { $msgs = array_merge($msgs, xpwikifunc_defdata_check($mydirname, 'update')); } else { $msgs = array_merge($msgs, $_ret); return false; } // Delete COUNTER_DIR/*.counter $msgs = array_merge($msgs, xpwikifunc_delete_counter($mydirname)); return true; }