.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
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 = '#000000';
$list_remote_color = '#000000';
$list_convo_color = '#000000';
$list_protocol_bgcolor = '#cccccc';
$list_local_bgcolor = '#dddddd';
$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')) {
print("
var section = 'none';
var moveit = 1;
var the_timeout;
function xmlhttpPost(){
var url = "/services_imspector_logs.php"
new Ajax.Request(url, {
method: 'post',
parameters: {
mode: 'render',
section: section
},
onSuccess: function(transport){
var response = transport.responseText || "";
updatepage(response);
$('im_status').style.display = "none";
},
onLoading: function(){
$('im_status').style.display = "inline";
}
});
}
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 (!$(a[1])) {
$('im_convos').innerHTML +=
"
" + a[1] + "
" +
"
";
}
if (!$(a[1] + "_" + a[2])) {
var imageref = "";
if (a[0]) imageref = "
![" + a[1] + "](" + a[0] + ")
";
$(a[1]).innerHTML +=
"
" + imageref + a[2] + "
" +
"
";
}
if (!$(a[1] + "_" + a[2] + "_" + a[3])) {
$(a[1] + "_" + a[2]).innerHTML +=
"
" + a[3] + "
" +
"
";
}
if (!$(a[1] + "_" + a[2] + "_" + a[3] + "_" + a[4])) {
$(a[1] + "_" + a[2] + "_" + a[3]).innerHTML +=
"
»" + a[4] + "
";
}
}
/* determine the title of this conversation */
var details = parts[1].split(",");
var title = details[0] + " conversation between
" + details[1] +
" and
" + details[2] + "";
if (!details[1]) title = " ";
if (!parts[2]) parts[2] = " ";
var bottom = parseInt($('im_content').scrollTop);
var bottom2 = parseInt($('im_content').style.height);
var absheight = parseInt( bottom + bottom2 );
if (absheight == $('im_content').scrollHeight) {
moveit = 1;
} else {
moveit = 0;
}
$('im_content').update(parts[2]);
if (moveit == 1) {
$('im_content').scrollTop = 0;
$('im_content').scrollTop = $('im_content').scrollHeight;
}
$('im_content_title').update(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;
}
EOD;
print($zz);
?>