Commit 17ea8459 authored by 's avatar

Files moved to another repository


git-svn-id: file:///home/svn/mapi/trunk@1438 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent d191f4fd
# This is a configuration file for packetloss GUI.
# packetloss home
packetloss_home = "/path/to/packetloss"
# packetloss restart command
#packetloss_restart = /usr/bin/ssh -f packetloss@localhost "/path/to/packetloss/bin/packetloss.sh restart '%filter%' >/dev/null 2>&1"
#packetloss_reset = /usr/bin/ssh -f packetloss@localhost "/path/to/packetloss/bin/packetloss.sh reset >/dev/null 2>&1"
packetloss_restart = "/path/to/packetloss.sh restart '%filter%' >/dev/null 2>&1"
packetloss_reset = "/path/to/packetloss.sh reset >/dev/null 2>&1"
# rrd server
#rrdsrv = "localhost:13900"
# rrdtool binary
rrdtool = "rrdtool"
# rrdtool log file (if commented out and php gb present, errors will be printed into image)
#rrdtool_error_log = "log/packetloss_rrdtool_error.log"
# rrds
packetloss_rrd = "packetloss.rrd"
packetcount_rrd = "packetloss_packets.rrd"
flows_rrd = "packetloss_flows.rrd"
matchedflows_rrd = "packetloss_matchedflows.rrd"
# packetloss files
packetloss_status = "packetloss_status.csv"
packetloss_starts = "packetloss_starts.csv"
packetloss_startlog = "packetloss_start.log"
# enable or disable status
enable_packetloss_status
# packetloss GUI home
packetloss_gui_home = "/path/to/packetlossGUI"
# packetloss GUI log
packetloss_gui_log = "log/packetloss.log"
<?php
# File name: flows.php
# Date: 2008/02/09 17:18
# Author: Ales Friedl <ales.friedl@email.cz>
# Includes {{{
$DIR="../";
require_once "${DIR}lib/expire.php";
require_once "${DIR}lib/graph/flows.php";
# }}}
$allowed_args = ",host0rrddsid,host1rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,withstarts,";
foreach(array_keys($_GET) as $key) {
if(strpos($allowed_args,",$key,") !== false) {
$$key = $_GET[$key];
}
}
$graph = new Flows_Graph(array($host0rrddsid, $host1rrddsid), $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info, $withstarts);
//$graph->dry_run();
$graph->flush();
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
?>
<?php
# File name: matchedflows.php
# Date: 2008/06/06 21:06
# Author: Ales Friedl <ales.friedl@email.cz>
# Includes {{{
$DIR="../";
require_once "${DIR}lib/expire.php";
require_once "${DIR}lib/graph/matchedflows.php";
# }}}
$allowed_args = ",host0rrddsid,host1rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,withstarts,";
foreach(array_keys($_GET) as $key) {
if(strpos($allowed_args,",$key,") !== false) {
$$key = $_GET[$key];
}
}
$graph = new Matchedflows_Graph(array($host0rrddsid, $host1rrddsid), $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info, $withstarts);
//$graph->dry_run();
$graph->flush();
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
?>
<?php
# Includes {{{
$DIR="../";
require_once "${DIR}lib/expire.php";
require_once "${DIR}lib/graph/packetcount.php";
# }}}
$allowed_args = ",host0rrddsid,host1rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,withstarts,";
foreach(array_keys($_GET) as $key) {
if(strpos($allowed_args,",$key,") !== false) {
$$key = $_GET[$key];
}
}
$graph = new Packetcount_Graph(array($host0rrddsid, $host1rrddsid), $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info, $withstarts);
//$graph->dry_run();
$graph->flush();
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
?>
<?php
# Includes {{{
$DIR="../";
require_once "${DIR}lib/expire.php";
require_once "${DIR}lib/graph/packetloss.php";
# }}}
$allowed_args = ",host0rrddsid,host1rrddsid,start,end,step,avg,max,min,width,height,upperLimit,lowerLimit,onlyGraph,title,info,withstarts,";
foreach(array_keys($_GET) as $key) {
if(strpos($allowed_args,",$key,") !== false) {
$$key = $_GET[$key];
}
}
$graph = new Packetloss_Graph(array($host0rrddsid, $host1rrddsid), $start, $end, $step, $avg, $max, $min, $width, $height, $title, $info, $withstarts);
//$graph->dry_run();
$graph->flush();
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
?>
/*
* File name: ajax.js
* Date: 2007/09/20 08:07
* Author: Ales Friedl <ales.friedl@email.cz>
*
*/
// Request {{{
Request = new Function();
Request.prototype.request = function(url, params, rhandler) {
this.url = url;
// when GET, append parameters to URL
if (Ajax.options.method == "get" && params) {
var paramstr = "";
for (var param in params) {
paramstr += (paramstr == "" ? "" : "&") + param + "=" + params[param];
}
this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + paramstr;
}
try {
this.connection = Ajax.getConnection();
Ajax.openConnection(this.connection, this.url);
this.connection.onreadystatechange = this.onStateChange_closure(rhandler);
this.body = Ajax.getBody();
this.connection.send(this.body);
}
catch (e) {
//alert(e);
window.status = e;
}
}
Request.prototype.onStateChange_closure = function(rhandler) {
var request = this;
var rhandler = rhandler;
return function() {
if(Ajax.states[request.connection.readyState] == "Complete") {
if (!request.connection.status || (request.connection.status >= 200 && request.connection.status < 300)) {
rhandler(request);
}
else //alert("Ajax Request Error: " + request.connection.status);
window.status="Ajax Request Error: " + request.connection.status;
}
}
}
// }}}
// Object Literal Ajax {{{
Ajax = {
author: "Aleš Friedl",
version: "2.0",
exists: false,
autorun: true,
init: function() {
if(Ajax.exists) return false;
Ajax.exists = true;
if(Ajax.autorun) Ajax.start();
},
start: function() {
},
getConnection: function() {
try {
return new XMLHttpRequest()
} catch(e) {}
try {
return new ActiveXObject("Msxml2.XMLHTTP")
} catch(e) {}
try {
return new ActiveXObject("Microsoft.XMLHTTP")
} catch(e) {}
return false;
},
openConnection: function(connection, url) {
connection.open(Ajax.options.method.toUpperCase(), url, Ajax.options.asynchronous);
Ajax.setRequestsHeaders(connection);
},
setRequestsHeaders: function(connection) {
for (var header in Ajax.requestsHeaders) {
connection.setRequestHeader(header, Ajax.requestHeaders[header]);
}
},
getBody: function() {
return (Ajax.method == "post" ? Ajax.params : null);
},
states: ["Uninitialized", "Loading", "Loaded", "Interactive", "Complete"],
options: {
method: "get",
asynchronous: true
},
headers: {
contentType: "application/x-www-form-urlencoded",
encoding: "UTF-8"
},
requestHeaders: {
"X-Requested-With": "XMLHttpRequest",
"Accept": "text/javascript, text/html, application/xml, text/xml, */*",
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
}
}
// }}}
window_onDOMContentLoaded_add(Ajax.init);
// vim:foldmethod=marker:foldmarker=\ {{{,\ }}}:foldclose=:foldcolumn=0
/*
* Filename: altitle.js
* Date:
* Author: Aleš Friedl <ales.friedl@email.cz>
*
*/
// Object Literal altitle {{{
var altitle = {
author: "Aleš Friedl",
version: "2.1a",
autorun: true,
exists: false,
init: function() {
if(altitle.exists) return false;
altitle.exists = true;
if(altitle.autorun) altitle.start();
},
start: function() {
var isImg = 0;
var isAcronym = 1;
var isAnchor = 2;
var altitlec = 0;
if(document.getElementsByTagName) {
var miragearr = new Array(
document.getElementsByTagName("img"),
document.getElementsByTagName("acronym"),
document.getElementsByTagName("a")
);
var hasAltitleClassRegExp = new RegExp("(^|\\s)altitleclass_[^\\s$]+(\\s|$)");
for(j = 0; j < miragearr.length; j++) {
for(i = 0; i < miragearr[j].length; i++) {
// exact match! vs. miragearr[i].className.search(/(^a| a)ltitl(e$|e )/) != -1);
// automirage
if(!miragearr[j][i].className.match(new RegExp("(^|\\s)noaltitle(\\s|$)"))) {
var title = miragearr[j][i].getAttribute("title");
if(title != null && title!="") {
var hasAltitleClass = miragearr[j][i].className.match(hasAltitleClassRegExp);
var altitleClass = "";
if(hasAltitleClass) {
var altitleClassRegExp = new RegExp("(^|\\s)altitleclass_[^\\s$]+(\\s|$)");
var altitleClass = altitleClassRegExp.exec(miragearr[j][i].className)[0].substring("altitleclass_".length + 1);
}
var additionaltitle = "";
var firstChild = miragearr[j][i].firstChild;
if(firstChild) {
if(firstChild.nodeName.toLowerCase() == "img") {
//firstChild.setAttribute("alt",""); // XXX mirage needs alt
additionaltitle = "";
}
}
var onmouseoverstr = "if(typeof(altitle) != 'undefined') altitle.show("+(altitlec)+",'"+escape(title+additionaltitle)+"','"+(altitleClass != "" ? altitleClass : (j == isImg ? "altitle-img" : (j == isAcronym ? "altitle-acronym" : "altitle-a")))+"'); return false;";
var onmouseoutstr = "if(typeof(altitle) != 'undefined') altitle.hide("+(altitlec)+"); return true;";
altitlec++;
//miragearr[j][i].setAttribute("onmouseover", onmouseoverstr); // W3C
//miragearr[j][i].setAttribute("onmouseover", new Function(onmouseoverstr)); // M$
miragearr[j][i].onmouseover = new Function(onmouseoverstr);
//miragearr[j][i].setAttribute("onmouseout", onmouseoutstr); // W3C
//miragearr[j][i].setAttribute("onmouseout", new Function(onmouseoutstr)); // M$
miragearr[j][i].onmouseout = new Function(onmouseoutstr);
miragearr[j][i].setAttribute("title", ""); // kill title, bye bye browser
}
}
}
}
}
},
id: null,
show: function(id, title, altitleclass) {
if(id != null || altitle.id != null) { // explicit call or onmousemove implicit call
if(id != null && altitle.id != null){ // previous id not destroyed or duplicit call
if(altitle.id != id) {
altitle.hide(altitle.id); // hide previous
altitle.id = id;
}
else return false; // duplicit -> mutex
}
if(altitle.id == null) altitle.id = id; // first time
if(document.getElementsByTagName) {
var altitleid = document.getElementById("altitle"+altitle.id);
if(!altitleid) { // explicit call, else onmousemove implicit call
altitleid = document.createHTMLElement("div", {"class":altitleclass, "id":"altitle"+(id), "smarttext":unescape(title)});
document.getElementsByTagName("body")[0].appendChild(altitleid);
}
}
if(altitleid) {
var MX = mouse?mouse.MX:0;
var MY = mouse?mouse.MY:0;
var seeX = mouse?mouse.seeX:800;
var seeY = mouse?mouse.seeY:600;
if(MX == 0 && MY == 0) {
MX = (seeX - 100) / 2;
MY = (seeY - 50) / 2;
}
altitleid.style.position = "absolute";
altitleid.style.left = (((MX+100) < seeX) ? MX + 15 : MX - 50) + "px";
altitleid.style.top = (((MY+50) < seeY) ? (((MX+100) < seeX) ? MY + 15 : MY + 20) : MY - 20) + "px";
}
}
else return false; // void onmousemove implicit call
},
hide: function(id) {
if(document.getElementsByTagName) {
var altitleid = document.getElementById("altitle"+id);
if(altitleid) {
document.getElementsByTagName("body")[0].removeChild(altitleid);
}
}
altitle.id = null;
}
}
// }}}
window_onDOMContentLoaded_add(altitle.init);
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
/*
* Filename: dom.js
* Author: Aleš Friedl <ales.friedl@email.cz>
*
*/
/*
* author: "Aleš Friedl"
* version: "0.2"
*/
document.createHTMLElement = function(name, attrarr) {
// if (document.createElementNS) {
// var elem = document.createElementNS("http://www.w3.org/1999/xhtml", name);
// var useNS = elem.setAttributeNS; // Opera
// }
// else {
var elem = document.createElement(name);
var useNS = false;
// }
if (typeof attrarr != "undefined") {
for (var i in attrarr) {
switch (i) {
case "text": elem.appendChild(document.createTextNode(attrarr[i])); break;
case "smarttext": { // visualise line-breaks and html eventually
if(attrarr[i].search("\n") != -1) elem.innerHTML = attrarr[i].replace(/\n/g, "<br />");
else elem.appendChild(document.createTextNode(attrarr[i]));
break;
}
case "html": elem.innerHTML = attrarr[i]; break;
case "class": elem.className = attrarr[i]; break;
case "style":
if(useNS) {
elem.setAttributeNS("http://www.w3.org/1999/xhtml", i, attrarr[i]);
}
else {
elem.setAttribute(i, attrarr[i]);
}
//elem.style.setAttribute(i,attrarr[i]); // Redmond
elem.style.cssText = attrarr[i]; // Redmond
break;
case "id":
default:
if(useNS) {
elem.setAttributeNS("http://www.w3.org/1999/xhtml", i, "");
}
else {
elem.setAttribute(i, "");
}
elem[i] = attrarr[i]; // Opera
}
}
}
return elem;
}
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
/*
* File name: logger.js
* Date: 2007/11/10 18:34
* Author: Ales Friedl <ales.friedl@email.cz>
*
* JavaScript, version
*
*/
// Object Literal logger {{{
var logger = {
author: "Aleš Friedl",
version: "0.1",
debug: false,
logging: true,
autorun: true,
exists: false,
init: function() {
if(logger.exists) return false;
logger.exists = true;
if(logger.autorun) logger.start();
},
logarea: null,
start: function() {
logger.logarea = document.forms["debugform"].debugarea;
logger.running = true;
if(logger.logging) { logger.smartlog("logger.js: Started..."); }
},
stop: function() {
if(logger.logging) logger.smartlog("logger.js: Stopped...");
logger.running = false;
},
clear: function() {
logger.logarea.value = "";
},
smartlog: function(str) {
if(logger.running) {
var delim = " ";
d = new Date();
datestr = (d.getHours() < 10 ? "0" + d.getHours() : d.getHours()) +
":" +
(d.getMinutes() < 10 ? "0" + d.getMinutes() : d.getMinutes()) +
":" +
(d.getSeconds() < 10 ? "0" + d.getSeconds() : d.getSeconds()) +
" " +
d.getDate() +
" " +
monthNumberToLongName[d.getMonth()] +
" " +
d.getFullYear();
logger.logarea.value += datestr + delim + str + "\n";
}
}
}
// }}}
window_onDOMContentLoaded_add(logger.init);
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
/*
* Filename: misc.js
* Author: Aleš Friedl <ales.friedl@email.cz>
*
*/
function window_onload_add(f) {
if (!window.addEventListener && !window.attachEvent) return false;
if (window.addEventListener) window.addEventListener("load", f, false); // W3C
else window.attachEvent("onload", f); // Redmond
return true;
}
function window_onDOMContentLoaded_add(f) {
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", f, false);
}
window_onload_add(f); // Redmond
}
// MSIE only?
function window_onresize_add(f) {
if (!window.addEventListener && !window.attachEvent) return false;
if (window.addEventListener) window.addEventListener("resize", f, false); // W3C
else window.attachEvent("onresize", f); // Redmond
return true;
}
monthNumberToLongName = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
/*
* Filename: mouse.js
* Date: 2007/01/25 18:43
* Author: Aleš Friedl <ales.friedl@email.cz>
*
*/
// Object Literal mouse {{{
var mouse = {
author: "Aleš Friedl",
version: "0.2",
exists: false,
autorun: true,
MX: 0,
MY: 0,
seeX: 800,
seeY: 600,
init: function() {
if(mouse.exists) return false;
mouse.exists = true;
if(mouse.autorun) mouse.start();
},
start: function() {
document.onmousemove = mouse.mousemove;
//if(document.captureEvents) document.captureEvents(Event.MOUSEMOVE);
},
stop: function() {
document.onmousemove = null
//if(document.releaseEvents) document.releaseEvents(Event.MOUSEMOVE);
},
mousemove: function(e) {
if(mouse.exists) {
if(e) {
mouse.MX = e.pageX
mouse.MY = e.pageY
}
else {
mouse.MX = window.event.clientX + (document.documentElement?document.documentElement.scrollLeft:document.body.scrollLeft)
mouse.MY = window.event.clientY + (document.documentElement?document.documentElement.scrollTop:document.body.scrollTop)
}
if(window.innerWidth) {
mouse.seeX = window.innerWidth + window.pageXOffset - 22;
mouse.seeY = window.innerHeight + window.pageYOffset;
}
else {
mouse.seeX = document.body.offsetWidth + (document.documentElement?document.documentElement.scrollLeft:document.body.scrollLeft - 22);
mouse.seeY = document.body.offsetHeight + (document.documentElement?document.documentElement.scrollTop:document.body.scrollTop);
}
if(typeof(altitle) != "undefined") altitle.show();
//window.status = "seeX: "+mouse.seeX+" seeY: "+mouse.seeY+" MX: "+mouse.MX+" MY: "+mouse.MY+"";
}
}
}
// }}}
window_onDOMContentLoaded_add(mouse.init);
// vim: set foldmethod=marker foldmarker=\ {{{,\ }}} foldclose= foldcolumn=0 :
This diff is collapsed.
<?php
# File name: config.php
# Author: Ales Friedl <ales.friedl@email.cz>
/**
*
* Very simple config reader
*
* @version $Id$
*/
class Config {
var $debug = false;
function Config($filename) {
if($this->debug) echo "Config reading config file: $filename\n";
$rarr = file($filename);
for($i = 0; $i < count($rarr); $i++) {
$line = trim($rarr[$i]);
if($line != "" && $line[0] != "" && $line[0] != "#") {
$property = trim(trim(strtok($line,"=")), "\"");
$value = trim(strtok(""));
if($value != ltrim($value, "\"")) $value = trim($value, "\"");
$this->$property = $value;
if($this->debug) echo "Config: $property = $value\n";
}
}
}
function abspath($rootdir, $path, $search="", $replace="") {
if($search && $replace) $path = str_replace($search, $replace, $path);
if($path != "" && $path[0] == "/") $abspath = $path;
else $abspath = $rootdir."/".$path;
return $abspath;
}