IMSpector log düzenleme
Pfsense içinde yer alan imspector logları biraz karışıktır, aşağıdaki kodu veya buradan indireceğiniz php dosyasını
/usr/local/www/services_imspector_logs.php dosyasını bul,içini temizle ve aşağıdaki kodu yapıştır.böylelikle hangi msnin hangi ipden geldiğini loglayabilirsin
/usr/local/www/services_imspector_logs.php dosyasını bul,içini temizle ve aşağıdaki kodu yapıştır.böylelikle hangi msnin hangi ipden geldiğini loglayabilirsin
<?php
require("guiconfig.inc");
/* variables */
$log_dir = '/var/imspector';
$imspector_config = $config['installedpackages']['imspector']['config'][0];
$border_color = '#c0c0c0';
$default_bgcolor = '#eeeeee';
$list_protocol_color = '#000000';
$list_local_color = '#ffffff';
$list_remote_color = '#666666';
$list_convo_color = '#888888';
$list_protocol_bgcolor = '#cccccc';
$list_local_bgcolor = '#850000';
$list_remote_bgcolor = '#eeeeee';
$list_end_bgcolor = '#bbbbbb';
$convo_title_color = 'black';
$convo_local_color = 'blue';
$convo_remote_color = 'red';
$convo_title_bgcolor = '#cccccc';
$convo_local_bgcolor = '#dddddd';
$convo_remote_bgcolor = '#eeeeee';
/* functions */
function convert_dir_list ($topdir) {
if (!is_dir($topdir)) return;
if ($dh = opendir($topdir)) {
while (($file = readdir($dh)) !== false) {
if(!preg_match('/^\./', $file) == 0) continue;
if (is_dir("$topdir/$file")) {
$list .= convert_dir_list("$topdir/$file");
} else {
$list .= "$topdir/$file\n";
}
}
closedir($dh);
}
return $list;
}
/* ajax response */
if ($_POST['mode'] == "render") {
/* user list */
print(str_replace(array($log_dir,'/'),array('','|'),convert_dir_list($log_dir)));
print("--END--\n");
/* log files */
if ($_POST['section'] != "none") {
$section = explode('|',$_POST['section']);
$protocol = $section[0];
$localuser = $section[1];
$remoteuser = $section[2];
$conversation = $section[3];
/* conversation title */
print(implode(', ', $section)."\n");
print("--END--\n");
/* conversation content */
$filename = $log_dir.'/'.implode('/', $section);
if($fd = fopen($filename, 'r')) {
$satir_oku = fgets($fd);
$ipsinibulduk = explode(':',$satir_oku);
print("<table width='100%' border='0' cellpadding='2' cellspacing='1'><tr><td style='color:#fff;' colspan='4' align='center' width='100%' bgcolor='#850000'>kullanilan [<span style='font-weight:bold;'>$localuser</span>] adresine ait local ip: [<span style='font-weight:bold;'>$ipsinibulduk[0]</span>]</td></tr>\n");
while (!feof($fd)) {
$line = fgets($fd);
if(feof($fd)) continue;
$new_format = '([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),(.*)';
$old_format = '([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),(.*)';
preg_match("/${new_format}|${old_format}/", $line, $matches);
$address = $matches[1];
$addresbul = explode(':',$address);
$addressnew =$addresbul[0] ;
$timestamp = $matches[2];
$direction = $matches[3];
$type = $matches[4];
$filtered = $matches[5];
if(count($matches) == 8) {
$category = $matches[6];
$data = $matches[7];
} else {
$category = "";
$data = $matches[6];
}
if($direction == '0') {
$bgcolor = $convo_remote_bgcolor;
$user = "<span style='color: $convo_remote_color;'>$remoteuser</span>";
}
if($direction == '1') {
$bgcolor = $convo_local_bgcolor;
$user = "<span style='color: $convo_local_color;'>$localuser</span>";
}
$time = strftime("%H:%M", $timestamp);
print("<tr bgcolor='$bgcolor'>
<td style='width: 5%; vertical-align: top;border-bottom:1px solid #ccc;'>[$time]</td>\n
<td style='border-bottom:1px solid #ccc; width: 13%; vertical-align: top;'>$user</td>\n
<td style='border-bottom:1px solid #ccc; width: 1%; vertical-align: top;'>$category</td>\n
<td style='border-bottom:1px solid #ccc; width: 82%; vertical-align: top;'>$data</td></tr>\n");
}
print("</table>\n");
fclose($fd);
}
}
exit;
}
/* defaults to this page but if no settings are present, redirect to setup page */
if(!$imspector_config["enable"] || !$imspector_config["iface_array"] || !$imspector_config["proto_array"])
Header("Location: /pkg_edit.php?xml=imspector.xml&id=0");
$pgtitle = "Services: IMSpector Log Viewer";
include("head.inc");
/* put your custom HTML head content here */
/* using some of the $pfSenseHead function calls */
//$pfSenseHead->addMeta("<meta http-equiv=\"refresh\" content=\"120;url={$_SERVER['SCRIPT_NAME']}\" />");
//echo $pfSenseHead->getHTML();
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<div id="mainlevel">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php
$tab_array = array();
$tab_array[] = array(gettext("IMSpector Log Viewer "), true, "/services_imspector_logs.php");
$tab_array[] = array(gettext("IMSpector Settings "), false, "/pkg_edit.php?xml=imspector.xml&id=0");
display_top_tabs($tab_array);
?>
</table>
<?php
$zz = <<<EOD
<script type="text/javascript">
var section = 'none';
var moveit = 1;
var the_timeout;
function xmlhttpPost()
{
var xmlHttpReq = false;
var self = this;
if (window.XMLHttpRequest)
self.xmlHttpReq = new XMLHttpRequest();
else if (window.ActiveXObject)
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
self.xmlHttpReq.open('POST', 'services_imspector_logs.php', true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq && self.xmlHttpReq.readyState == 4)
updatepage(self.xmlHttpReq.responseText);
}
document.getElementById('im_status').style.display = "inline";
self.xmlHttpReq.send("mode=render§ion=" + section);
}
function updatepage(str)
{
/* update the list of conversations ( if we need to ) */
var parts = str.split("--END--\\n");
var lines = parts[0].split("\\n");
for (var line = 0 ; line < lines.length ; line ++) {
var a = lines[line].split("|");
if (!a[1] || !a[2] || !a[3]) continue;
/* create titling information if needed */
if (!document.getElementById(a[1])) {
document.getElementById('im_convos').innerHTML +=
"<div id='" + a[1] + "_t' style='width: 100%; background-color: $list_protocol_bgcolor; color: $list_protocol_color;'>" + a[1] + "</div>" +
"<div id='" + a[1] + "' style='width: 100%; background-color: $list_local_bgcolor;'></div>";
}
if (!document.getElementById(a[1] + "_" + a[2])) {
var imageref = "";
if (a[0]) imageref = "<img src='" + a[0] + "' alt='" + a[1] + "'/>";
document.getElementById(a[1]).innerHTML +=
"<div id='" + a[1] + "_" + a[2] + "_t' style='width: 100%; color: $list_local_color; padding-left: 5px;'>" + imageref + a[2] + "</div>" +
"<div id='" + a[1] + "_" + a[2] + "' style='width: 100%; background-color: $list_remote_bgcolor; border-bottom: solid 1px $list_end_bgcolor;'></div>";
}
if (!document.getElementById(a[1] + "_" + a[2] + "_" + a[3])) {
document.getElementById(a[1] + "_" + a[2]).innerHTML +=
"<div id='" + a[1] + "_" + a[2] + "_" + a[3] + "_t' style='width: 100%; color: $list_remote_color; padding-left: 10px;'>" + a[3] + "</div>" +
"<div id='" + a[1] + "_" + a[2] + "_" + a[3] + "' style='width: 100%;'></div>";
}
if (!document.getElementById(a[1] + "_" + a[2] + "_" + a[3] + "_" + a[4])) {
document.getElementById(a[1] + "_" + a[2] + "_" + a[3]).innerHTML +=
"<div id='" + a[1] + "_" + a[2] + "_" + a[3] + "_" + a[4] +
"' style='width: 100%; color: $list_convo_color; cursor: pointer; padding-left: 15px;' onClick=" +
'"' + "setsection('" + a[1] + "|" + a[2] + "|" + a[3] + "|" + a[4] + "');" + '"' + "' + >»" + a[4] + "</div>";
}
}
/* determine the title of this conversation */
var details = parts[1].split(",");
var title = "<table border='1' width='100%'><tr><td style='color:#666;' align='center' bgcolor='#eee' valign='top'>"+ details[3]+ " tarihli " + "[<span style='font-weight:bold;'>" + details[1]+ "</span> ]"+ " ile " + "[ <span style='font-weight:bold;'>" + details[2] + " </span> ] " + details[0] + " görüsme kaydi</td></tr></table>";
if (!details[1]) title = " ";
if (!parts[2]) parts[2] = " ";
document.getElementById('im_status').style.display = "none";
var bottom = parseInt(document.getElementById('im_content').scrollTop);
var bottom2 = parseInt(document.getElementById('im_content').style.height);
var absheight = parseInt( bottom + bottom2 );
if (absheight == document.getElementById('im_content').scrollHeight) {
moveit = 1;
} else {
moveit = 0;
}
document.getElementById('im_content').innerHTML = parts[2];
if (moveit == 1) {
document.getElementById('im_content').scrollTop = 0;
document.getElementById('im_content').scrollTop = document.getElementById('im_content').scrollHeight;
}
document.getElementById('im_content_title').innerHTML = title;
the_timeout = setTimeout( "xmlhttpPost();", 5000 );
}
function setsection(value)
{
section = value;
clearTimeout(the_timeout);
xmlhttpPost();
document.getElementById('im_content').scrollTop = 0;
document.getElementById('im_content').scrollTop = document.getElementById('im_content').scrollHeight;
}
</script>
EOD;
print($zz);
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<div style='width: 100%; text-align: right;'><span id='im_status' style='display: none;'>Yenileniyor...</span> </div>
<table width="100%">
<tr>
<td width="15%" bgcolor="<?=$default_bgcolor?>" style="overflow: auto; border: solid 1px <?=$border_color?>;">
<div id="im_convos" style="height: 400px; overflow: auto; overflow-x: hidden;"></div>
</td>
<td width="75%" bgcolor="<?=$default_bgcolor?>" style="border: solid 1px <?=$border_color?>;">
<div id="im_content_title" style="height: 20px; overflow: auto; vertical-align: top;
color: <?=$convo_title_color?>; background-color: <?=$convo_title_bgcolor?>;"></div>
<div id="im_content" style="height: 380px; overflow: auto; vertical-align: bottom; overflow-x: hidden;"></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script type="text/javascript">xmlhttpPost();</script>
</div>
<?php include("fend.inc"); ?>
</body>
</html>
IMSpector log düzenleme
Reviewed by Admin
on
20:56
Rating:
dünya alem bir yana sen bir yana doğan abi
YanıtlaSil