Esempio n. 1
0
 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(']]>', ']]&gt;', $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) . '&#182;' : '') . $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);
 }
Esempio n. 2
0
	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 fetchSummary($pgid)
 {
     $db =& Database::getInstance();
     $myts =& MyTextsanitizer::getInstance();
     $module_handler =& xoops_gethandler('module');
     $module =& $module_handler->getByDirname($this->mydirname);
     $pgid = intval($pgid);
     $mydirname = $this->mydirname;
     if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) {
         die('Invalid mydirname');
     }
     // query
     $data = $db->fetchArray($db->query("SELECT `name`, `title`, `editedtime` FROM " . $db->prefix($mydirname . "_pginfo") . " WHERE `pgid`={$pgid} LIMIT 1"));
     // get body
     $uri = $body = '';
     if ($data['name'] !== '') {
         if (strpos(@$_SERVER['REQUEST_URI'], '/modules/' . $mydirname) === FALSE) {
             include_once dirname(dirname(__FILE__)) . "/include.php";
             $page =& XpWiki::getSingleton($mydirname);
             if ($data['editedtime']) {
                 $page->init($data['name']);
                 $page->execute();
                 $body = $page->body;
             } else {
                 $body = _MD_D3FORUM_ERR_READPOST . " \n" . '"' . $data['name'] . '" is deleted.';
             }
             $uri = $page->func->get_page_uri($data['name'], true);
         }
     } else {
         $body = _MD_D3FORUM_ERR_READPOST;
     }
     // make subject
     $subject = $data['name'];
     if ($subject !== $data['title']) {
         $subject .= ' [ ' . $data['title'] . ' ]';
     }
     return array('dirname' => $mydirname, 'module_name' => $module->getVar('name'), 'subject' => $myts->makeTboxData4Show($subject), 'uri' => $uri, 'summary' => xoops_substr(strip_tags($body), 0, 255));
 }
Esempio n. 4
0
	$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'];
Esempio n. 5
0
 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('&lt;', '&gt;', '&amp;', '&quot;', '&#039;', '&nbsp;'), 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&amp;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;
 }
Esempio n. 6
0
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;
}
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
 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 ? '?' : '&amp;') . '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;
 }