Beispiel #1
0
 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;
 }
Beispiel #2
0
 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_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;
 }
Beispiel #4
0
 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'];
 if ($xpwiki->root->use_root_image_manager && is_file($xpwiki->cont['ROOT_PATH'] . 'imagemanager.php')) {
Beispiel #5
0
    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);
    }
Beispiel #6
0
 * $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);
    }
}
// Additionally, the one executed sequentially
Beispiel #7
0
function xpwikifunc_defdata_check($mydirname, $mode = 'install')
{
    $msg = array();
    $config_handler =& xoops_gethandler('config');
    $xoopsConfig =& $config_handler->getConfigsByCat(XOOPS_CONF);
    $language = $xoopsConfig['language'];
    $utf8from = '';
    switch (strtolower($language)) {
        case 'japanese':
        case 'japaneseutf':
        case 'ja_utf8':
        case 'japanese_utf8':
            $lang = 'ja';
            if ('utf-8' === strtolower(_CHARSET)) {
                $utf8from = 'EUC-JP';
            }
            break;
        case 'english':
            $lang = 'en';
            break;
        default:
            $lang = 'en';
    }
    $dirs = array('cache' => 'private/cache', 'wiki' => 'private/wiki');
    $from_base = dirname(dirname(__FILE__)) . '/ID/' . $lang . '/';
    $timestamp = array();
    foreach (file($from_base . 'wiki/.timestamp') as $line) {
        list($file, $time) = explode("\t", $line);
        $timestamp[$file] = intval(trim($time));
    }
    foreach ($dirs as $from => $to) {
        $dir = $from;
        $from = $from_base . $from;
        $to = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/' . $to;
        if ($handle = opendir($from)) {
            while (false !== ($file = readdir($handle))) {
                if ($file !== '.' && $file !== '..' && !is_dir($from . '/' . $file)) {
                    if ($mode === 'install' || $dir !== 'wiki' || substr($file, -4) !== '.txt') {
                        if (!is_file($to . '/' . $file)) {
                            copy($from . '/' . $file, $to . '/' . $file);
                            if ($utf8from) {
                                xpwikifunc_conv_utf($to . '/' . $file, $utf8from);
                            }
                            if ($dir === 'wiki' && isset($timestamp[$file])) {
                                touch($to . '/' . $file, $timestamp[$file]);
                            }
                            $msg[] = "Copied a file '{$file}'.<br />";
                        }
                    } else {
                        // wiki pages
                        $_file_exist = is_file($to . '/' . $file);
                        if (!$_file_exist || isset($timestamp[$file]) && filemtime($to . '/' . $file) < $timestamp[$file]) {
                            if (!isset($xpwiki)) {
                                include_once dirname(dirname(__FILE__)) . '/include.php';
                                $xpwiki = new XpWiki($mydirname);
                                $xpwiki->init('#RenderMode');
                            }
                            $page = $xpwiki->func->decode(str_replace('.txt', '', $file));
                            if (!$_file_exist && $xpwiki->func->get_pgid_by_name($page)) {
                                // The user has intentionally deleted it.
                                continue;
                            }
                            // Reformat source
                            $src = file_get_contents($from . '/' . $file);
                            $src = $xpwiki->func->remove_pginfo($src);
                            $src_freeze = false;
                            if (!$_file_exist) {
                                $src_freeze = preg_match('/^#freeze\\s*$/m', $src);
                            }
                            // Remove '#freeze'
                            $src = preg_replace('/^#freeze\\s*$/m', '', $src);
                            $src = ltrim($src);
                            // UTF-8?
                            if ($utf8from) {
                                $src = mb_convert_encoding($src, 'UTF-8', $utf8from);
                            }
                            // Was it frozen?
                            $is_freeze = $xpwiki->func->is_freeze($page);
                            $xpwiki->root->rtf['no_checkauth_on_write'] = $is_freeze || $src_freeze ? 'dofreeze' : true;
                            $xpwiki->func->page_write($page, $src);
                            // touch page
                            $xpwiki->func->touch_page($page, $timestamp[$file]);
                            $msg[] = "Updated a page '" . $xpwiki->func->htmlspecialchars($page) . "'.<br />";
                        }
                    }
                }
            }
            closedir($handle);
        }
    }
    if (isset($xpwiki)) {
        $xpwiki = null;
    }
    // Remove facemarks.js
    @unlink(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/private/cache/' . md5(XOOPS_URL . '/modules/' . $mydirname) . '_facemarks.js');
    return $msg;
}
Beispiel #8
0
<?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;
    }
}