/** * アクションプラグイン処理 */ function plugin_log_guess_user_convert() { global $_log_guess_user_msg; global $log; // ユーザを推測する // $user = log::guess_user( $data['user'], $data['ntlm'], $data['sig'] ); $filename = log::set_filename('guess_user', ''); // ログファイル名 $src = array(); $master = array(); if (file_exists($filename)) { $src = @file($filename); } // ログの読み込み foreach ($src as $_src) { $data = log::table2array($_src); // 0:ua 1:host 2:user $master[$data[0]][$data[1]][$data[2]] = ''; } // 更新ログから署名情報の収集 // $guess[ USER-AGENT ][ ホスト名 ][ ユーザ名 ][任意欄] の配列を戻す $guess = log::summary_signature(); $i = 0; foreach ($guess as $ua => $val1) { foreach ($val1 as $host => $val2) { foreach ($val2 as $user => $val3) { if (isset($master[$ua][$host][$user])) { continue; } log_put($filename, '|' . $ua . '|' . $host . '|' . $user . '||'); $i++; } } } $msg = sprintf($_log_guess_user_msg['msg_put'], $i); return $msg; }
/** * アクションプラグイン処理 */ function plugin_logview_action() { global $vars, $_logview_msg; global $log, $sortable_tracker; static $count = 0; $kind = isset($vars['kind']) ? $vars['kind'] : 'update'; $title = sprintf($_logview_msg['msg_title'], $kind); // タイトルを設定 $page = isset($vars['page']) ? $vars['page'] : ''; // ゲスト表示ができない場合は、認証を要求する if ($log[$kind]['guest'] == '') { $obj = new auth(); $user = $obj->check_auth(); if (empty($user)) { if (exist_plugin('login')) { do_plugin_action('login'); } unset($obj); return array('msg' => $title, 'body' => $_logview_msg['msg_not_auth']); } } unset($obj); check_readable($page, false); // 保存データの項目名を取得 $name = log::get_log_field($kind); $view = log::get_view_field($kind); // 表示したい項目設定 if ($sortable_tracker && $count == 0) { global $head_tags; $head_tags[] = ' <script type="text/javascript" charset="utf-8" src="' . SKIN_URI . 'sortabletable.js"></script>'; } $count++; $body = <<<EOD <table id="logview{$count}" class="style_table" cellspacing="1" border="0"> <thead> <tr> EOD; $cols = 0; $is_role_adm = auth::check_role('role_adm'); // タイトルの処理 foreach ($view as $_view) { if ($_view === 'local_id' && $is_role_adm) { continue; } $body .= '<td class="style_td">' . $_logview_msg[$_view] . '</td>' . "\n"; $cols++; } $body .= <<<EOD </tr> </thead> <tbody> EOD; // データを取得 $fld = logview_get_data(log::set_filename($kind, $page), $name); if (empty($fld)) { return array('msg' => $title, 'body' => 'no data'); } // USER-AGENT クラス $obj_ua = new user_agent(USE_UA_OPTION); $path_flag = IMAGE_URI . 'icon/flags/'; $path_browser = IMAGE_URI . 'icon/browser/'; $path_os = IMAGE_URI . 'icon/os/'; $path_domain = IMAGE_URI . 'icon/option/domain/'; $guess = $log['guess_user']['use'] ? log::read_guess() : log::summary_signature(); $ctr = 0; // データの編集 foreach ($fld as $data) { if (!VIEW_ROBOTS && $obj_ua->is_robots($data['ua'])) { continue; } // ロボットは対象外 $body .= "<tr>\n"; foreach ($view as $field) { switch ($field) { case 'ts': // タイムスタンプ (UTIME) $body .= ' <td class="style_td">' . get_date('Y-m-d H:i:s', $data['ts']) . ' ' . get_passage($data['ts']) . "</td>\n"; break; case '@guess_diff': case '@diff': // 差分内容 $update = $field == '@diff' ? true : false; // FIXME: バックアップ/差分 なしの新規の場合 // バックアップデータの確定 $body .= ' <td class="style_td">'; $age = log::get_backup_age($page, $data['ts'], $update); switch ($age) { case -1: // データなし $body .= '<a class="ext" href="' . get_page_uri($page) . '" rel="nofollow">none</a>'; break; case 0: // diff $body .= '<a class="ext" href="'; $body .= log::diff_exist($page) ? get_cmd_uri('diff', $page) : get_page_uri($page); $body .= '" rel="nofollow">now</a>'; break; default: // あり $body .= '<a class="ext" href="' . get_cmd_uri('backup', $page, '', array('age' => $age, 'action' => 'visualdiff')) . '"' . ' rel="nofollow">' . $age . '</a>'; break; } $body .= "</td>\n"; break; case 'host': // ホスト名 (FQDN) $body .= ' <td class="style_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 .= '<img src="' . $path_flag . $flag_icon . '.png"' . ' alt="' . $flag_name . '" title="' . $flag_name . '" />'; } // ドメイン取得 $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 .= $data['host'] . "</td>\n"; break; case '@guess': // 推測 $body .= ' <td class="style_td">' . htmlspecialchars(logview_guess_user($data, $guess), ENT_QUOTES) . "</td>\n"; break; case 'ua': // ブラウザ情報 (USER-AGENT) $body .= ' <td class="style_td">'; $os = $obj_ua->get_icon_os($data['ua']); if (!empty($os)) { $body .= '<img src="' . $path_os . $os . '.png"' . ' alt="' . $os . '" title="' . $os . '" />'; } $browser = $obj_ua->get_icon_broeswes($data['ua']); if (!empty($browser)) { $body .= '<img src="' . $path_browser . $browser . '.png"' . ' alt="' . htmlspecialchars($data['ua'], ENT_QUOTES) . '" title="' . htmlspecialchars($data['ua'], ENT_QUOTES) . '" />'; } $body .= "</td>\n"; break; case 'local_id': if ($is_role_adm) { continue; } default: $body .= ' <td class="style_td">' . htmlspecialchars($data[$field], ENT_QUOTES) . "</td>\n"; } } $body .= "</tr>\n"; $ctr++; } unset($obj_ua); if ($ctr == 0) { return array('msg' => $title, 'body' => 'no data'); } $body .= <<<EOD </tbody> </table> EOD; switch ($kind) { case 'login': case 'check': $body .= logview_user_list($fld, $page, $kind); break; } if ($sortable_tracker) { $logviewso = join(',', array_fill(0, $cols, '"String"')); $body .= <<<EOD <script type="text/javascript"> <!-- <![CDATA[ var st = new SortableTable(document.getElementById('logview{$count}'),[{$logviewso}]); //]]>--> </script> EOD; } return array('msg' => $title, 'body' => $body); }