summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon2011-03-19 13:35:22 +0100
committerSimon2011-03-19 13:35:22 +0100
commit509df04555d1289aa6df9023c07448e5d4d6b95a (patch)
tree642b722dfeaa8edf5616f7ea4763173f151bca32
parentFilter korrigiert (diff)
downloadpbs2-509df04555d1289aa6df9023c07448e5d4d6b95a.tar.gz
pbs2-509df04555d1289aa6df9023c07448e5d4d6b95a.tar.xz
pbs2-509df04555d1289aa6df9023c07448e5d4d6b95a.zip
Filter funktioniert nun, FBGui IndexController angepasst
-rw-r--r--application/modules/fbgui/controllers/IndexController.php9
-rw-r--r--library/Pbs/Filter.php65
2 files changed, 39 insertions, 35 deletions
diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php
index c55ea50..f5f8cdf 100644
--- a/application/modules/fbgui/controllers/IndexController.php
+++ b/application/modules/fbgui/controllers/IndexController.php
@@ -43,16 +43,21 @@ class Fbgui_IndexController extends Zend_Controller_Action
$session = $n->createSession($session);
$_SESSION['alphasessionID'] = $session->getAlphasessionID();
echo "<h1>Welcome</h1>";
- print_a('Session is now set','Your alphasessionID is '.$session->getAlphasessionID());
+ print_a('Session is now set',
+ 'Your sessionID is '.$session->getID(),
+ 'Your alphasessionID is '.$session->getAlphasessionID(),
+ 'Your client is '.$session->getClientID());
// Request Bootmenu
$pbsFilter = new Pbs_Filter();
$bootmenuID = $pbsFilter->evaluate();
print_a('bootmenuID is ',$bootmenuID);
- if($bootmenuID != null){
+ if($bootmenuID != null){
+ print_a('goto bootmenu');
#$this->_redirect('/dev/bootmenu/index/bootmenuid/'.$bootmenuID);
}
else{
+ print_a('no filter is valid, goto login');
#$this->_redirect('/dev/auth/index/');
}
}
diff --git a/library/Pbs/Filter.php b/library/Pbs/Filter.php
index 9e1f6db..91e97e9 100644
--- a/library/Pbs/Filter.php
+++ b/library/Pbs/Filter.php
@@ -9,7 +9,7 @@ class Pbs_Filter{
{
$this->db = Zend_Db_Table::getDefaultAdapter();
$db = $this->db;
- $showPartResults = false;
+ $debuglevel = 0;
$membershipMapper = new Application_Model_MembershipMapper();
$this->membership = new Application_Model_Membership();
@@ -55,7 +55,6 @@ class Pbs_Filter{
$session = new Application_Model_Session();
$sessionmapper = new Application_Model_SessionMapper();
$sessionarray = $sessionmapper->findBy('alphasessionID',$_SESSION['alphasessionID']);
- print_a($sessionarray[0]);
$session->setOptions($sessionarray[0]);
$session->setID($sessionarray['sessionID']);
#########################################################
@@ -80,7 +79,7 @@ class Pbs_Filter{
$set[$filtertypID][] = $r['filterID'];
}
- if($showPartResults)
+ if($debuglevel >= 3 )
print_a('ipAdress',$result,$set[$filtertypID]);
#########################################################
@@ -105,7 +104,7 @@ class Pbs_Filter{
}
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('macAdress',$result,$set[$filtertypID]);
#########################################################
@@ -134,7 +133,7 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('poolID',$result,$set[$filtertypID]);
#########################################################
// ClientID
@@ -155,7 +154,7 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('clientID',$result,$set[$filtertypID]);
#########################################################
// BootIsoID
@@ -175,7 +174,7 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('bootisoID',$result,$set[$filtertypID]);
#########################################################
// MembershipID
@@ -197,7 +196,7 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('membership',$result,$set[$filtertypID]);
}
#########################################################
@@ -220,7 +219,7 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('membership',$result,$set[$filtertypID]);
}
#########################################################
@@ -239,11 +238,7 @@ class Pbs_Filter{
$stmt = $db->query('SELECT * FROM pbs_filterentries WHERE
filtertypeID = '.$filtertypID.' AND
REPLACE(filtervalue,":","") <= '.$nowShort.' AND
- REPLACE(filtervalue2,":","") >= '.$nowShort.' ');
- print_a('SELECT * FROM pbs_filterentries WHERE
- filtertypeID = '.$filtertypID.' AND
- REPLACE(filtervalue,":","") <= '.$nowShort.' AND
- REPLACE(filtervalue2,":","") >= '.$nowShort.' ');
+ REPLACE(filtervalue2,":","") >= '.$nowShort.' ');
$result = $stmt->fetchAll();
foreach($result as $r){
$set[$filtertypID][] = $r['filterID'];
@@ -251,7 +246,7 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('time',$result,$set[$filtertypID]);
#########################################################
// Hardwarehash
@@ -278,7 +273,7 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('hardwarehash',$result,$set[$filtertypID]);
#########################################################
// weekday
@@ -302,7 +297,7 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('weekday',$result,$set[$filtertypID]);
#########################################################
// weekday
@@ -326,11 +321,12 @@ class Pbs_Filter{
}
catch(Exception $e){}
- if($showPartResults)
+ if($debuglevel >= 3)
print_a('weekday',$result,$set[$filtertypID]);
########################################
// ErgebnisSet auswerten
- print_a('the result sets of the filtertypes',$set);
+ if($debuglevel >= 2)
+ print_a('the result sets of the filtertypes',$set);
// Merging of the resultsets of the filter
$kk = array();
@@ -342,19 +338,22 @@ class Pbs_Filter{
$a = array();
foreach($set as $k=> $s){
$a[$s] += 1;
- }
- print_a('Übereinstimmungen pro Filter',$a);
+ }
+ if($debuglevel >= 2)
+ print_a('Übereinstimmungen pro Filter',$a);
// Get the number of filtertypes every filter has
- $stmt = $db->query("SELECT filterID,SUM(num) as num FROM (
-SELECT *, '1' as num
-FROM pbs_filterentries
-GROUP BY filterID, filtertypeID
-) d GROUP BY d.filterID");
+ $stmt = $db->query(
+ "SELECT filterID,SUM(num) as num FROM (
+ SELECT *, '1' as num
+ FROM pbs_filterentries
+ GROUP BY filterID, filtertypeID
+ ) d GROUP BY d.filterID");
$resultset = $stmt->fetchAll();
foreach($resultset as $d){
$database[$d['filterID']] = $d['num'];
- }
- print_a('Anzahl Filterentries in Datenbank',$database);
+ }
+ if($debuglevel >= 2)
+ print_a('Anzahl Filterentries in Datenbank',$database);
// remove all filters from resultset, which to few filtertypes satisfied
$result = array();
@@ -365,9 +364,10 @@ GROUP BY filterID, filtertypeID
else{
$result[] = $i;
}
- }
-
- print_a('True Filters',$result);
+ }
+ if($debuglevel >= 1)
+ print_a('Valid Filters',$result);
+
// now selecting the filter with the highest priority
$query = 'SELECT filterID, bootmenuID, priority
FROM pbs_filter WHERE ';
@@ -387,8 +387,7 @@ GROUP BY filterID, filtertypeID
if($bootmenuID != 'null'){
$bm = new Application_Model_BootMenu();
$bmmapper = new Application_Model_BootMenuMapper();
- $bmmapper->find($bootmenuID,$bm);
- echo "<h1><a href='/bootmenu/index/bootmenuid/".$bootmenuID."'>Goto BootmenuID: ".$bootmenuID."</a></h1>";
+ $bmmapper->find($bootmenuID,$bm);
return $bootmenuID;
}
else{