示例#1
0
 /**
  * 設定を読み込む
  */
 private static function init()
 {
     static $rules;
     if (!isset($rules)) {
         $rules = Utility::loadConfig('rules.ini.php');
     }
     return $rules;
 }
示例#2
0
 /**
  * コンストラクタ
  * @param string $page
  */
 public function __construct($page = null)
 {
     if (empty($this->kind)) {
         throw new Exception('LogFile::__construct(): class "' . get_called_class() . '" does not defined $kind value.');
     }
     $this->config = Utility::loadConfig('config-log.ini.php');
     if (!$this->isWiki) {
         if (empty($page)) {
             throw new Exception('LogFile::__construct(): Page name is missing!');
         }
         // ページ名
         $this->page = $page;
         parent::__construct(self::$dir . $this->kind . '/' . Utility::encode($page) . '.txt');
     } else {
         // Wikiに保存する場合
         parent::__construct(DATA_DIR . Utility::encode($this->config[$this->kind]['file']) . '.txt');
     }
 }
示例#3
0
/**
 * アクションプラグイン処理
 */
function plugin_logview_action()
{
    global $vars, $_logview_msg, $_logview_logname;
    global $sortable_tracker, $_LANG, $vars;
    static $count = 0;
    $kind = isset($vars['kind']) ? $vars['kind'] : null;
    $title = $kind !== null ? sprintf($_logview_msg['msg_title'], $kind) : $_LANG['skin']['log'];
    // タイトルを設定
    $page = isset($vars['page']) ? $vars['page'] : null;
    $ajax = isset($vars['ajax']) ? $vars['ajax'] : null;
    $is_role_adm = Auth::check_role('role_adm');
    // 設定を読む
    $log = Utility::loadConfig('config-log.ini.php');
    // ゲスト表示ができない場合は、認証を要求する
    if ($kind !== null && empty($log[$kind]['guest'])) {
        $obj = new Auth();
        $user = $obj->check_auth();
        if (empty($user)) {
            PluginRenderer::executePluginAction('login');
            unset($obj);
            return array('msg' => $title, 'body' => '<p class="alert-warning">' . $_logview_msg['msg_not_auth'] . '</p>');
        }
    }
    unset($obj);
    if (empty($page)) {
        return array('msg' => 'Page name is missing', 'body' => '<p class="alert-warning">Page name is missing.</p>');
    }
    $wiki = Factory::Wiki($page);
    if (!$wiki->isReadable()) {
        return array('msg' => 'not readable', 'body' => '<p class="alert-warning">You have no permission to read this log.</p>');
    }
    if ($kind === null) {
        if (!IS_MOBILE) {
            $body = '<div class="tabs" role="application">' . "\n";
            $body .= '<ul role="tablist">';
            $cnt = 0;
            foreach ($log as $key => $val) {
                $link_text = isset($_logview_logname[$key]) ? $_logview_logname[$key] : $key;
                if ($val['use'] === 1) {
                    $body .= '<li role="tab"><a href="' . $wiki->uri('logview', array('kind' => $key)) . '">' . $link_text . '</a></li>';
                }
                /*
                				else
                				{
                					$body .= '<li><a href="'.get_cmd_uri('logview',$page,null,array('kind'=>$key)).'" data-ajax="raw" data-disabled="true">'.$link_text.'</a></li>';
                				}
                */
            }
            $body .= '</ul></div>' . "\n";
            if ($kind === null) {
                return array('msg' => $title, 'body' => $body);
            }
            $body .= '<div class="no-js" role="tabpanel">';
            $nodata = $body . '<p>' . $_logview_msg['msg_nodata'] . '</p></div></div>';
        } else {
            $body = '<div data-role="controlgroup" data-type="horizontal">' . "\n";
            $cnt = 0;
            foreach ($log as $key => $val) {
                $link_text = isset($_LANG['skin']['log_' . $key]) ? $_LANG['skin']['log_' . $key] : $key;
                if ($val['use'] === 1) {
                    $body .= '<a href="' . $wiki->uri('logview', array('kind' => $key)) . '" data-role="button">' . $link_text . '</a>';
                }
                /*
                				else
                				{
                					$body .= '<a href="'.get_cmd_uri('logview',$page,null,array('kind'=>$key)).'" data-ajax="raw" data-disabled="true">'.$link_text.'</a>';
                				}
                */
            }
            $body .= '</div>' . "\n" . '<div class="ui-body ui-body-c"></div>';
            if ($kind === null) {
                return array('msg' => $title, 'body' => $body);
            }
        }
    } else {
        $body = '';
    }
    // 保存データの項目名を取得
    $logfile = LogFactory::factory($kind, $page);
    $view = $logfile->get_view_field();
    // 表示したい項目設定
    $count++;
    $body[] = '<div class="table_wrapper">';
    $body[] = '<table class="table table-bordered table_logview" data-pagenate="true">';
    $body[] = '<thead>';
    $body[] = '<tr>';
    $cols = 0;
    // タイトルの処理
    foreach ($view as $_view) {
        if ($_view === 'local_id' && $is_role_adm) {
            continue;
        }
        $body[] = '<th>' . $_logview_msg[$_view] . '</th>';
        $cols++;
    }
    $body[] = '</tr>';
    $body[] = '</thead>';
    $body[] = '<tbody>';
    $nodata = '<p class="alert alert-warning">' . $_logview_msg['msg_nodata'] . '</p>';
    // USER-AGENT クラス
    $obj_ua = new UserAgent(USE_UA_OPTION);
    $guess = $log['guess_user']['use'] ? LogFactory::factory('guess_user')->get() : LogFactory::factory('update', $page)->getSigunature();
    $ctr = 0;
    // データの編集
    $lines = $logfile->get();
    if (!$lines) {
        return array('msg' => $title, 'body' => $nodata);
    }
    foreach ($lines as $data) {
        if (!VIEW_ROBOTS && $obj_ua->is_robots($data['ua'])) {
            continue;
        }
        // ロボットは対象外
        $body[] = '<tr>';
        foreach ($view as $field) {
            switch ($field) {
                case 'ts':
                    // タイムスタンプ (UTIME)
                    $body[] = '<td>' . get_date('Y-m-d H:i:s', $data['ts']) . ' ' . get_passage($data['ts']) . '</td>';
                    break;
                case '@guess_diff':
                case '@diff':
                    // 差分内容
                    $update = $field == '@diff' ? true : false;
                    // FIXME: バックアップ/差分 なしの新規の場合
                    // バックアップデータの確定
                    $body[] = '<td class="style_td">';
                    $age = $logfile->get_backup_age($data['ts'], $update);
                    switch ($age) {
                        case -1:
                            // データなし
                            $body[] = '<a href="' . $wiki->uri() . '" rel="nofollow">none</a>';
                            break;
                        case 0:
                            // diff
                            $body[] = '<a href="' . ($logfile->diff_exist() ? $wiki->uri('diff') : $wiki->uri()) . '" rel="nofollow">now</a>';
                            break;
                        default:
                            // あり
                            $body[] = '<a class="ext" href="' . $wiki->uri('backup', null, array('age' => $age, 'action' => 'visualdiff')) . '" rel="nofollow">' . $age . '</a>';
                            break;
                    }
                    $body[] = '</td>';
                    break;
                case 'host':
                    // ホスト名 (FQDN)
                    $body[] = ' <td>';
                    if ($data['ip'] != $data['host']) {
                        // 国名取得
                        list($flag_icon, $flag_name) = $obj_ua->get_icon_flag($data['host']);
                        if (!empty($flag_icon) && $flag_icon != 'jp') {
                            $body[] = '<span class="flag flag-' . $flag_icon . '" title="' . $flag_name . '" ></span>';
                        }
                        // ドメイン取得
                        $domain = $obj_ua->get_icon_domain($data['host']);
                        if (!empty($domain)) {
                            //						$body .= '<img src="'.$path_domain.$domain.'.png"'.
                            //								' alt="'.$data['host'].'" title="'.$data['host'].'" />';
                            $body[] = '<span class="flag flag-' . $domain . '" title="' . $data['host'] . '" ></span>';
                        }
                    }
                    if ($data['ip'] !== '::1') {
                        $body[] = '<a href="http://robtex.com/ip/' . $data['ip'] . '.html" rel="external nofollow">' . $data['host'] . '</a></td>';
                    } else {
                        $body[] = $data['host'] . '</td>';
                    }
                    break;
                case '@guess':
                    // 推測
                    $body[] = '<td>' . Utility::htmlsc(logview_guess_user($data, $guess), ENT_QUOTES) . '</td>';
                    break;
                case 'ua':
                    // ブラウザ情報 (USER-AGENT)
                    $body[] = ' <td>';
                    $os = $obj_ua->get_icon_os($data['ua']);
                    if (!empty($os)) {
                        $body[] = '<span class="os os-' . $os . '" title="' . $os . '"></span>';
                    }
                    $browser = $obj_ua->get_icon_broeswes($data['ua']);
                    if (!empty($browser)) {
                        $body[] = '<span class="browser browser-' . $browser . '" title="' . Utility::htmlsc($data['ua'], ENT_QUOTES) . '"></span>';
                    }
                    $body[] = '</td>';
                    break;
                case 'local_id':
                    if ($is_role_adm) {
                        continue;
                    }
                default:
                    $body[] = '<td>' . Utility::htmlsc($data[$field], ENT_QUOTES) . '</td>';
            }
        }
        $body[] = '</tr>';
        $ctr++;
    }
    unset($obj_ua);
    if ($ctr == 0) {
        return array('msg' => $title, 'body' => $nodata);
    }
    $body[] = '</tbody>';
    $body[] = '</table>';
    $body[] = '</div>';
    switch ($kind) {
        case 'login':
        case 'check':
            $body .= logview_user_list($fld, $page, $kind);
            break;
    }
    if ($ajax !== 'raw') {
        $body[] = '</div>';
        $body[] = '</div>';
    } else {
        echo join("\n", $body);
        exit;
    }
    return array('msg' => $title, 'body' => join("\n", $body));
}
示例#4
0
$usedatetime = 1;
/////////////////////////////////////////////////
// Template setting
$auto_template_func = 1;
$auto_template_rules = array('((.+)\\/([^\\/]+))' => '\\2/template');
/////////////////////////////////////////////////
// Allow to use 'Do not change timestamp' checkbox
// (0:Disable, 1:For everyone,  2:Only for the administrator)
$notimeupdate = 2;
/////////////////////////////////////////////////
// Ignore list
// Regex of ignore pages
$non_list = '^\\:';
// Search ignored pages
$search_non_list = 1;
/////////////////////////////////////////////////
// Automatically add fixed heading anchor
$fixed_heading_anchor = 1;
/////////////////////////////////////////////////
// 見出しごとの編集を可能にする
//
// 見出し行の固有のアンカ自動挿入されているとき
// のみ有効です
// 0:無効
// 1:edit, 2:guiedit, 3:edit+guiedit プラグインを利用
$fixed_heading_edited = 1;
// 同一サーバーとしてみなすホストのURI
$open_uri_in_new_window_servername = array($_SERVER['HTTP_HOST']);
// Server settings
Utility::loadConfig('server.ini.php');
示例#5
0
$realm = 'PukiWiki Adv. Auth';
/////////////////////////////////////////////////
// Admin name and password for this Wikisite
$adminname = 'admin';
// CHANGE THIS
$adminpass = '******';
// MD5('pass')
/////////////////////////////////////////////////
// User definition
//
// ROLE
//
// Data is managed by the plugin.
$auth_users = Utility::loadConfig('auth_users.ini.php');
$auth_wkgrp_user = Utility::loadConfig('auth_wkgrp.ini.php');
$auth_api = Utility::loadConfig('auth_api.ini.php');
/////////////////////////////////////////////////
// Authentication method
$auth_method_type = Auth::AUTH_METHOD_PAGENAME;
// By Page name
//$auth_method_type = Auth::AUTH_METHOD_CONTENTS; // By Page contents
// Accept specified IP without basic_auth
$read_auth_pages_accept_ip = array('#Private\\/#' => '127.0.');
/////////////////////////////////////////////////
// Read auth (0:Disable, 1:Enable)
// 他のページから参照する場合や、プラグインで使用するページ(:config)を指定しないでください。
// その場合、参照されたタイミングで閲覧制限がかかります。
$read_auth = 0;
$read_auth_pages = array('/:log/' => $adminname, '#FooBar#' => 'hoge', '#(Foo|Bar)#' => 'foo,bar,hoge');
/////////////////////////////////////////////////
// Edit auth (0:Disable, 1:Enable)