removal of unneeded files, fixes of some SQLite3 bugs, added README/doc
This commit is contained in:
parent
c28ce28aab
commit
755a608cd7
37
README
37
README
|
@ -1,4 +1,4 @@
|
||||||
Hackerspace Brussels
|
Hackerspace Brussels/Whitespace Ghent
|
||||||
presents
|
presents
|
||||||
_ _ _
|
_ _ _
|
||||||
_ __ _ __ ___ (_) ___ ___| |_ _ __ __ _ _ __ ___ ___| | __ _
|
_ __ _ __ ___ (_) ___ ___| |_ _ __ __ _ _ __ ___ ___| | __ _
|
||||||
|
@ -9,9 +9,38 @@
|
||||||
|
|
||||||
|
|
||||||
Imagine some very elaborate description on what this is, but I fail in finding
|
Imagine some very elaborate description on what this is, but I fail in finding
|
||||||
the right words right now. It is a very cool way to visualize people being
|
the right words right now. It is a very cool way to visualize any kind of data,
|
||||||
present in the same physical location. It scans the local network for mac
|
for example people being present in the same physical location.
|
||||||
|
Currently it comes with an example scanner that scans the local network for mac
|
||||||
addresses and displays them in a very nice 3d HTML 5 canvas thing. Enough with
|
addresses and displays them in a very nice 3d HTML 5 canvas thing. Enough with
|
||||||
the words, look at the installation in hsbxl.
|
the words, look at the installation in hsbxl and whitespace:
|
||||||
|
|
||||||
http://hackerspace.be/pam/
|
http://hackerspace.be/pam/
|
||||||
|
http://0x20.be/pam
|
||||||
|
|
||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
* Copy all the files in a directory that is hosted by a webserver, e.g. apache
|
||||||
|
* Your webserver must naturally support php
|
||||||
|
* The php-sqlite3 extension must be installed
|
||||||
|
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
* Edit the config.php to configure Pamela
|
||||||
|
* Make sure the configuration of where the database will be is a writable
|
||||||
|
directory, a database will be created there automatically using the name you
|
||||||
|
specified.
|
||||||
|
|
||||||
|
Scanner details
|
||||||
|
===============
|
||||||
|
|
||||||
|
You can upload data to the webinterface by posting a comma separted list to the
|
||||||
|
upload.php page. This is done using application/x-www-form-urlencoded format,
|
||||||
|
with the key beying "data" and the value being a comma separated list of items.
|
||||||
|
|
||||||
|
e.g. using wget:
|
||||||
|
|
||||||
|
wget http://host/pamela/upload.php -O - --post-data data=comma,separated,list,of,items
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
// Number of seconds a mac address file is valid. If it's older it will be removed.
|
|
||||||
define("MACFILE_TTL", "3600");
|
|
||||||
|
|
||||||
// Where the db is located for the sqlite db. The file does not have to exist.
|
|
||||||
// The directory does need to exist though, and the directory must be writable.
|
|
||||||
define("SQLITE_DB", "/home/sandbender/www/pamela/db/pamela.sql");
|
|
||||||
|
|
||||||
// sql create statement for mac table
|
|
||||||
define("CREATE_MAC_TABLE_SQL", "create table macs (mac text unique on conflict replace, committime integer);");
|
|
||||||
define("CREATE_KNOWN_MAC_TABLE_SQL", "create table knownmacs (userid integer, mac text, name text, primary key (mac, userid));");
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Copyright 2009 Pieter Iserbyt
|
Copyright 2010 Pieter Iserbyt
|
||||||
|
|
||||||
This file is part of Pamela.
|
This file is part of Pamela.
|
||||||
|
|
||||||
|
@ -24,24 +24,24 @@ header("Cache-Control: no-cache");
|
||||||
header("Pragma: no-cache");
|
header("Pragma: no-cache");
|
||||||
|
|
||||||
require_once("config.php");
|
require_once("config.php");
|
||||||
require_once("lib/macs.php");
|
require_once("lib/data.php");
|
||||||
|
|
||||||
// for debug purposes, increases the numbers of macs artificially
|
// for debug purposes, increases the numbers of data artificially
|
||||||
function multiply() {
|
function multiply() {
|
||||||
global $macs;
|
global $data;
|
||||||
$c = count($macs);
|
$c = count($data);
|
||||||
for ($j = 0; $j < $c; $j++) {
|
for ($j = 0; $j < $c; $j++) {
|
||||||
for ($i = 0; $i <10; $i++) {
|
for ($i = 0; $i <10; $i++) {
|
||||||
$macs[] = $macs[$j].$i;
|
$data[] = $data[$j].$i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$macs = macs_get();
|
$data = data_get();
|
||||||
if (count($macs) > 0) {
|
if (count($data) > 0) {
|
||||||
//multiply();
|
//multiply();
|
||||||
echo('["'.implode('", "', $macs).'"]');
|
echo('["'.implode('", "', $data).'"]');
|
||||||
} else {
|
} else {
|
||||||
echo('[]');
|
echo('[]');
|
||||||
}
|
}
|
||||||
macs_purge();
|
data_purge();
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,21 +0,0 @@
|
||||||
------------------------------------------------------------------------
|
|
||||||
The eurofurence typeface family by tobias b koehler (unci@tigerden.com)
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
|
|
||||||
This is a family of geometric rounded sans serif fonts consisting of
|
|
||||||
three weights (light, medium, bold) in upright and italic styles,
|
|
||||||
originally designed for EuroFurence, the first European furry convention
|
|
||||||
1995 in Kaiser-Wilhelm-Koog.
|
|
||||||
|
|
||||||
The character set includes Roman, Greek and Cyrillic characters.
|
|
||||||
File format is TrueType for PC (under Windows, Linux etc).
|
|
||||||
|
|
||||||
These fonts are freeware and can be distributed as long as they are
|
|
||||||
together with this text file. I would appreciate it though if you could
|
|
||||||
contact me at unci@tigerden.com if you put them on a server. Free
|
|
||||||
samples from commercial users are always very welcome. :)
|
|
||||||
|
|
||||||
For more information, please see the uncifonts WWW page at:
|
|
||||||
http://mercurio.iet.unipi.it/users/tobias/uncifonts.html
|
|
||||||
|
|
||||||
Have fun! tobias b koehler, 2000-04-02
|
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
19
index.php
19
index.php
|
@ -1,4 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
|
Copyright 2010 Pieter Iserbyt
|
||||||
|
|
||||||
|
This file is part of Pamela.
|
||||||
|
|
||||||
|
Pamela is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Pamela is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Pamela. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
require_once("config.php");
|
require_once("config.php");
|
||||||
?><html xmlns="http://www.w3.org/1999/xhtml">
|
?><html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
|
|
|
@ -98,7 +98,6 @@ function DownloadScriptButton(x, y) {
|
||||||
|
|
||||||
DownloadScriptButton.prototype.draw = function() {
|
DownloadScriptButton.prototype.draw = function() {
|
||||||
if (this.isHover) {
|
if (this.isHover) {
|
||||||
//context.fillStyle = 'rgb(192,192,192)';
|
|
||||||
context.fillStyle = config.buttonColor;
|
context.fillStyle = config.buttonColor;
|
||||||
context.font = "18pt sans-serif";
|
context.font = "18pt sans-serif";
|
||||||
context.fillText("Download pamela scanner script", this.x, this.y - 10);
|
context.fillText("Download pamela scanner script", this.x, this.y - 10);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2009 Pieter Iserbyt
|
Copyright 2010 Pieter Iserbyt
|
||||||
|
|
||||||
This file is part of Pamela.
|
This file is part of Pamela.
|
||||||
|
|
||||||
|
@ -33,12 +33,10 @@ function ColorGenerator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorGenerator.prototype.generate = function() {
|
ColorGenerator.prototype.generate = function() {
|
||||||
if (this.colorGeneratorValue > this.colors.length)
|
this.colorGeneratorValue += 1;
|
||||||
|
if (this.colorGeneratorValue >= this.colors.length)
|
||||||
this.colorGeneratorValue = 0;
|
this.colorGeneratorValue = 0;
|
||||||
|
var c = this.colors[this.colorGeneratorValue];
|
||||||
// weirdo fix for chrome bug where the colors get
|
|
||||||
// garbage collected. I think.
|
|
||||||
var c = this.colors[this.colorGeneratorValue++];
|
|
||||||
return [c[0], c[1], c[2]];
|
return [c[0], c[1], c[2]];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,10 +50,6 @@ function Node(name) {
|
||||||
this.setMode("newNode");
|
this.setMode("newNode");
|
||||||
|
|
||||||
var size = Math.min(width, height);
|
var size = Math.min(width, height);
|
||||||
//this.color = [
|
|
||||||
// Math.random() * 128,
|
|
||||||
// Math.random() * 128,
|
|
||||||
// Math.random() * 128];
|
|
||||||
this.color = colorGenerator.generate();
|
this.color = colorGenerator.generate();
|
||||||
this.position = new Vector(
|
this.position = new Vector(
|
||||||
(Math.random() * size) - (size / 2),
|
(Math.random() * size) - (size / 2),
|
||||||
|
@ -97,19 +91,12 @@ Node.prototype.normal = {
|
||||||
var scale = width * 3 / -this.projection.z;
|
var scale = width * 3 / -this.projection.z;
|
||||||
var alphaScale = 0.5 + this.alpha / 128;
|
var alphaScale = 0.5 + this.alpha / 128;
|
||||||
var invAlphaScale = 1 - alphaScale;
|
var invAlphaScale = 1 - alphaScale;
|
||||||
var col =
|
var col = [
|
||||||
/* [
|
|
||||||
Math.round(this.color[0]),
|
|
||||||
Math.round(this.color[1]),
|
|
||||||
Math.round(this.color[2]),
|
|
||||||
]; */
|
|
||||||
[
|
|
||||||
Math.round(128 * invAlphaScale + this.color[0] * alphaScale),
|
Math.round(128 * invAlphaScale + this.color[0] * alphaScale),
|
||||||
Math.round(128 * invAlphaScale + this.color[1] * alphaScale),
|
Math.round(128 * invAlphaScale + this.color[1] * alphaScale),
|
||||||
Math.round(128 * invAlphaScale + this.color[2] * alphaScale),
|
Math.round(128 * invAlphaScale + this.color[2] * alphaScale),
|
||||||
];
|
];
|
||||||
context.fillStyle = 'rgb(' + col[0] + ',' + col[1] + ',' + col[2] + ')';
|
context.fillStyle = 'rgb(' + col[0] + ',' + col[1] + ',' + col[2] + ')';
|
||||||
//context.globalAlpha = this.alpha / 255;
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.arc(this.projection.x, this.projection.y, scale, 0, Math.PI * 2, false);
|
context.arc(this.projection.x, this.projection.y, scale, 0, Math.PI * 2, false);
|
||||||
context.fill();
|
context.fill();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2009 Pieter Iserbyt
|
Copyright 2010 Pieter Iserbyt
|
||||||
|
|
||||||
This file is part of Pamela.
|
This file is part of Pamela.
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ Pamela.prototype.resize = function() {
|
||||||
|
|
||||||
Pamela.prototype.updateEntries = function() {
|
Pamela.prototype.updateEntries = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
$.getJSON("macs.php", function(data) {
|
$.getJSON("data.php", function(data) {
|
||||||
self.updateNodes(data);
|
self.updateNodes(data);
|
||||||
});
|
});
|
||||||
self.entriesTimer = setTimeout(function() { self.updateEntries(); }, 20000);
|
self.entriesTimer = setTimeout(function() { self.updateEntries(); }, 20000);
|
||||||
|
|
70
lib/data.php
Normal file
70
lib/data.php
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
Copyright 2010 Pieter Iserbyt
|
||||||
|
|
||||||
|
This file is part of Pamela.
|
||||||
|
|
||||||
|
Pamela is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Pamela is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Pamela. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
require_once("lib/db.php");
|
||||||
|
|
||||||
|
function data_check_table() {
|
||||||
|
static $table_exists = FALSE;
|
||||||
|
|
||||||
|
// already checked? skip...
|
||||||
|
if ($table_exists == TRUE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get db handle
|
||||||
|
$db = get_db();
|
||||||
|
|
||||||
|
// already in db? skip and remember...
|
||||||
|
$q = $db->query("select name from sqlite_master where type='table' and name='data'");
|
||||||
|
if ($q->fetchArray()) {
|
||||||
|
$table_exists = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the table and remember...
|
||||||
|
$table_exists = $db->exec("create table data (data text unique on conflict replace, committime integer)");
|
||||||
|
}
|
||||||
|
|
||||||
|
function data_get() {
|
||||||
|
$results = array();
|
||||||
|
data_check_table();
|
||||||
|
$db = get_db();
|
||||||
|
$q = $db->query("select data from data where committime > strftime('%s','now') - ".DATA_TTL);
|
||||||
|
if (!$q) return $results;
|
||||||
|
while($row = $q->fetchArray(SQLITE3_ASSOC)) {
|
||||||
|
$results[] = $row['data'];
|
||||||
|
}
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
function data_add($data) {
|
||||||
|
$db = get_db();
|
||||||
|
data_check_table();
|
||||||
|
$data = $db->escapeString($data);
|
||||||
|
#echo "insert or replace into data values (\"$data\", strftime('%s','now'))\n";
|
||||||
|
$result = $db->exec("insert or replace into data values (\"$data\", strftime('%s','now'))");
|
||||||
|
if (!$result)
|
||||||
|
echo "ERROR: ".$db->lastErrorMsg()."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function data_purge() {
|
||||||
|
$db = get_db();
|
||||||
|
data_check_table();
|
||||||
|
return $db->exec("delete from data where committime <= strftime('%s','now') - ".DATA_TTL);
|
||||||
|
}
|
18
lib/db.php
18
lib/db.php
|
@ -1,4 +1,22 @@
|
||||||
<?php
|
<?php
|
||||||
|
/*
|
||||||
|
Copyright 2010 Pieter Iserbyt
|
||||||
|
|
||||||
|
This file is part of Pamela.
|
||||||
|
|
||||||
|
Pamela is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Pamela is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Pamela. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
require_once("config.php");
|
require_once("config.php");
|
||||||
|
|
||||||
function get_db() {
|
function get_db() {
|
||||||
|
|
24
lib/macs.php
24
lib/macs.php
|
@ -1,24 +0,0 @@
|
||||||
<?php
|
|
||||||
require_once("lib/db.php");
|
|
||||||
|
|
||||||
function macs_get() {
|
|
||||||
$results = array();
|
|
||||||
$db = get_db();
|
|
||||||
$q = $db->query("select mac from macs where committime > strftime('%s','now') - ".MACFILE_TTL);
|
|
||||||
if (!$q) return $results;
|
|
||||||
while($row = $q->fetch_array(SQLITE_ASSOC)) {
|
|
||||||
$results[] = $row['mac'];
|
|
||||||
}
|
|
||||||
return $results;
|
|
||||||
}
|
|
||||||
|
|
||||||
function macs_add($mac) {
|
|
||||||
$db = get_db();
|
|
||||||
$mac = $db->escape_string($mac);
|
|
||||||
return $db->exec("insert or replace into macs values (\"$mac\", strftime('%s','now'))");
|
|
||||||
}
|
|
||||||
|
|
||||||
function macs_purge() {
|
|
||||||
$db = get_db();
|
|
||||||
return $db->exec("delete from macs where committime <= strftime('%s','now') - ".MACFILE_TTL);
|
|
||||||
}
|
|
23
pamela.css
23
pamela.css
|
@ -1,23 +0,0 @@
|
||||||
@font-face {
|
|
||||||
font-family: AnjaEliane;
|
|
||||||
src: url('http://localhost/sb/pamela/fonts/AnjaEliane.ttf');
|
|
||||||
}
|
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: Eurofurence;
|
|
||||||
src: url('http://localhost/sb/pamela/fonts/eurofurence/eurof35.ttf');
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: Eurofurence;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
font-family: AnjaEliane, sans-serif;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
font-family: Eurofurence;
|
|
||||||
font-size: 16pt;
|
|
||||||
}
|
|
|
@ -45,11 +45,10 @@ function usage {
|
||||||
-p Http-auth password. Defaults to [$PASSWORD].
|
-p Http-auth password. Defaults to [$PASSWORD].
|
||||||
-h Shows help
|
-h Shows help
|
||||||
|
|
||||||
Pamela is an arp-scanner, it uploads the mac addresses in your local lan on a
|
This pamela scanner is an arp-scanner that uploads mac addresses in your local
|
||||||
webserver where you get a visual representation of the mac addresses present.
|
lan on a webserver where you get a visual representation of those mac addresses
|
||||||
Multiple people on multiple lans can run pamela together against the same
|
present. Multiple people on multiple lans can run this or any other scanner
|
||||||
server, where all results are agregated. In short, pamela gives you an overview
|
together against the same web server, where all results will be agregated."
|
||||||
of how big the shared network is."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_if_root {
|
function check_if_root {
|
||||||
|
@ -109,22 +108,22 @@ function parse_params {
|
||||||
|
|
||||||
function scan_and_upload {
|
function scan_and_upload {
|
||||||
echo $(date)" scanning..."
|
echo $(date)" scanning..."
|
||||||
NETMASK="$(ip -4 addr show "$IF" | egrep -o "brd [0-9\.]+" | egrep -o "[0-9\.]+")"
|
DATA=""
|
||||||
MACS=""
|
NUM_DATA=0
|
||||||
NUM_MACS=0
|
|
||||||
for M in $(arp-scan -R -i 10 --interface "$IF" --localnet | awk '{ print $2 }' | grep :.*: | sort | uniq)
|
for M in $(arp-scan -R -i 10 --interface "$IF" --localnet | awk '{ print $2 }' | grep :.*: | sort | uniq)
|
||||||
do
|
do
|
||||||
[ -n "$MACS" ] && MACS="$MACS,$M" || MACS="$M";
|
[ -n "$DATA" ] && DATA="$DATA,$M" || DATA="$M";
|
||||||
let "NUM_MACS=NUM_MACS+1"
|
let "NUM_DATA=NUM_DATA+1"
|
||||||
done
|
done
|
||||||
POST="sn=$NETMASK&macs=$MACS"
|
POST="data=$DATA"
|
||||||
RESULT=$(wget "$OUT" -O - --quiet --post-data "$POST" --user "$USER" --password "$PASSWORD" || echo "wget error: $?")
|
echo wget "$OUT" -O - --quiet --post-data "$POST" --user "$USER" --password "$PASSWORD" || echo "wget error: $?"
|
||||||
|
RESULT=$(wget "$OUT" -O - --post-data "$POST" --user "$USER" --password "$PASSWORD")
|
||||||
if [ -n "$RESULT" ]
|
if [ -n "$RESULT" ]
|
||||||
then
|
then
|
||||||
echo Error uploading results:
|
echo Error uploading results:
|
||||||
echo "$RESULT"
|
echo "$RESULT"
|
||||||
fi
|
fi
|
||||||
echo $(date)" Uploaded $NUM_MACS mac addresses..."
|
echo $(date)" Uploaded $NUM_DATA mac addresses..."
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_params $@
|
parse_params $@
|
||||||
|
|
33
upload.php
33
upload.php
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
Copyright 2009 Pieter Iserbyt
|
Copyright 2010 Pieter Iserbyt
|
||||||
|
|
||||||
This file is part of Pamela.
|
This file is part of Pamela.
|
||||||
|
|
||||||
|
@ -20,42 +20,35 @@
|
||||||
|
|
||||||
header("Content-type: text/plain");
|
header("Content-type: text/plain");
|
||||||
require_once("lib/util.php");
|
require_once("lib/util.php");
|
||||||
require_once("lib/macs.php");
|
require_once("lib/data.php");
|
||||||
|
|
||||||
class Upload {
|
class Upload {
|
||||||
|
|
||||||
private $macs;
|
private $data;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
$this->macs = getPost("macs");
|
$this->data = getPost("data");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseAndValidate() {
|
private function validate() {
|
||||||
if ($this->macs == NULL) {
|
if ($this->data == NULL) {
|
||||||
echoln("Missing macs param");
|
echoln("Missing data param");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mcs = explode(',', $this->macs);
|
|
||||||
foreach($mcs as $mac) {
|
|
||||||
if (preg_match("/^(([\dABCDEF]){2}:){5}([\dABCDEF]){2}$/i", $mac) == 1)
|
|
||||||
continue;
|
|
||||||
echoln("mac $mac is not in the right format");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function writeMacs() {
|
private function writeData() {
|
||||||
$mcs = explode(',', $this->macs);
|
$datas = explode(',', $this->data);
|
||||||
foreach($mcs as $mac) {
|
foreach($datas as $data) {
|
||||||
macs_add($mac);
|
data_add($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
$this->parseAndValidate();
|
if ($this->validate())
|
||||||
$this->writeMacs();
|
$this->writeData();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user