summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/Bootstrap.php4
-rw-r--r--application/controllers/IndexController.php18
-rw-r--r--application/modules/fbgui/controllers/IndexController.php19
-rw-r--r--library/Pbs/Filter.php112
-rw-r--r--library/Pbs/Session.php7
-rw-r--r--send-post.html12
6 files changed, 99 insertions, 73 deletions
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index cfa09f5..8ac8651 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -3,7 +3,9 @@
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoloader()
- {
+ {
+ setlocale(LC_ALL, "de_DE.UTF-8");
+ date_default_timezone_set('Europe/Berlin');
$moduleLoader = new Zend_Application_Module_Autoloader
(
array
diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php
index 9a65853..2972e9e 100644
--- a/application/controllers/IndexController.php
+++ b/application/controllers/IndexController.php
@@ -4,23 +4,15 @@ class IndexController extends Zend_Controller_Action
{
public function init()
- {
- /* Initialize action controller here */
- if(stristr($_SERVER['HTTP_USER_AGENT'],'prebootGUI')){
- $redirector = $this->_helper->getHelper('Redirector');
- $redirector->gotoSimple('index',
- 'Index',
- 'fbgui',
- array('keys' => array_keys($_POST),
- 'post' => $_POST
- )
- );
-
- }
+ {
+ /* Initialize action controller here */
}
public function indexAction()
{
+ if(stristr($_SERVER['HTTP_USER_AGENT'],'prebootGUI')){
+ $this->_forward('index','Index','fbgui');
+ }
// action body
}
diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php
index 5a99feb..c55ea50 100644
--- a/application/modules/fbgui/controllers/IndexController.php
+++ b/application/modules/fbgui/controllers/IndexController.php
@@ -10,11 +10,15 @@ class Fbgui_IndexController extends Zend_Controller_Action
public function indexAction()
{
- if(isset($this->_request->getParam('post')) && $this->_request->getParam('keys')){
- $data = $this->_request->getParam('post');
- $keys = $this->_request->getParam('keys');
- $_POST = array_combine ( $keys , $data );
- }
+
+ $keys = $this->_request->getParam('keys');
+ $post = $this->_request->getParam('post');
+ if($post != '' && $keys != ''){
+ $keys = $keys;
+ $post = $post;
+ $_POST = array_combine ( $keys , $post );
+ print_a($keys, $data,$_POST);
+ }
if(isset($_POST['bootisoID'])){
// Create a session
$n = new Pbs_Session();
@@ -44,11 +48,12 @@ class Fbgui_IndexController extends Zend_Controller_Action
// Request Bootmenu
$pbsFilter = new Pbs_Filter();
$bootmenuID = $pbsFilter->evaluate();
+ print_a('bootmenuID is ',$bootmenuID);
if($bootmenuID != null){
- $this->_redirect('/dev/bootmenu/index/bootmenuid/'.$bootmenuID);
+ #$this->_redirect('/dev/bootmenu/index/bootmenuid/'.$bootmenuID);
}
else{
- $this->_redirect('/dev/auth/index/');
+ #$this->_redirect('/dev/auth/index/');
}
}
else{
diff --git a/library/Pbs/Filter.php b/library/Pbs/Filter.php
index 6bfed94..9e1f6db 100644
--- a/library/Pbs/Filter.php
+++ b/library/Pbs/Filter.php
@@ -13,8 +13,12 @@ class Pbs_Filter{
$membershipMapper = new Application_Model_MembershipMapper();
$this->membership = new Application_Model_Membership();
- $membershipMapper->find($_SESSION['membershipID'],$this->membership);
-
+ if(isset($_SESSION['membershipID'])){
+ $membershipMapper->find($_SESSION['membershipID'],$this->membership);
+ }
+ else{
+ $this->membership->setID(null);
+ }
// For Testing Filters
$testFilter = (isset($_POST['submit']))?true:false;
@@ -51,8 +55,9 @@ class Pbs_Filter{
$session = new Application_Model_Session();
$sessionmapper = new Application_Model_SessionMapper();
$sessionarray = $sessionmapper->findBy('alphasessionID',$_SESSION['alphasessionID']);
- $session->setOption($sessionarray);
- $session->setID($sessionarray['sessionID'];
+ print_a($sessionarray[0]);
+ $session->setOptions($sessionarray[0]);
+ $session->setID($sessionarray['sessionID']);
#########################################################
// IP Adress
$filtertypID = 1;
@@ -175,65 +180,70 @@ class Pbs_Filter{
#########################################################
// MembershipID
$filtertypID = 5;
-
- if(!$testFilter){
- // get membership from the session
- //TODO: GET MEMBERSHIP from SESSION
- $membershipID = $this->membership->getID();
- }
- try{
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$membershipID." ");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ if($this->membership->getID() != null){
+ if(!$testFilter){
+ // get membership from the session
+ //TODO: GET MEMBERSHIP from SESSION
+ $membershipID = $this->membership->getID();
}
- }
- catch(Exception $e){}
+ try{
+ $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
+ filtertypeID = ".$filtertypID." AND
+ filtervalue = ".$membershipID." ");
+ $result = $stmt->fetchAll();
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
+ }
+ catch(Exception $e){}
- if($showPartResults)
- print_a('membership',$result,$set[$filtertypID]);
+ if($showPartResults)
+ print_a('membership',$result,$set[$filtertypID]);
+ }
#########################################################
// GroupID
$filtertypID = 6;
-
- if(!$testFilter){
- // get membership from the session
- //TODO: GET GROUP from SESSION
- $groupID = $this->membership->getGroupID();
- }
- try{
- $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
- filtertypeID = ".$filtertypID." AND
- filtervalue = ".$groupID." ");
- $result = $stmt->fetchAll();
- foreach($result as $r){
- $set[$filtertypID][] = $r['filterID'];
+ if($this->membership->getID() != null){
+ if(!$testFilter){
+ // get membership from the session
+ //TODO: GET GROUP from SESSION
+ $groupID = $this->membership->getGroupID();
}
- }
- catch(Exception $e){}
+ try{
+ $stmt = $db->query("SELECT * FROM pbs_filterentries WHERE
+ filtertypeID = ".$filtertypID." AND
+ filtervalue = ".$groupID." ");
+ $result = $stmt->fetchAll();
+ foreach($result as $r){
+ $set[$filtertypID][] = $r['filterID'];
+ }
+ }
+ catch(Exception $e){}
- if($showPartResults)
- print_a('membership',$result,$set[$filtertypID]);
+ if($showPartResults)
+ print_a('membership',$result,$set[$filtertypID]);
+ }
#########################################################
// Time
$filtertypID = 7;
if(!$testFilter){
- $time = time("H:i");
+ $nowShort = date("h:i");
+ }
+ else{
+ $nowShort = date("h:i",$time);
}
-
- $nowShort = $time;
$nowShort = str_replace(":","",$nowShort);
try{
- $select = $db->select()
- ->from(array('pbs_filterentries')
- )
- ->where('filtertypeID = ?',$filtertypID)
- ->where('REPLACE(filtervalue,":","") <= ? AND ? <= REPLACE(filtervalue2,":","")',$nowShort);
- $stmt = $select->query();
+ $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.' ');
$result = $stmt->fetchAll();
foreach($result as $r){
$set[$filtertypID][] = $r['filterID'];
@@ -335,7 +345,11 @@ class Pbs_Filter{
}
print_a('Übereinstimmungen pro Filter',$a);
// Get the number of filtertypes every filter has
- $stmt = $db->query('SELECT filterID, COUNT(filtertypeID) as num FROM pbs_filterentries GROUP BY 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'];
@@ -386,7 +400,7 @@ class Pbs_Filter{
echo "class: ".get_class($e)."<br>\n";
echo "Error message 2: " . $e->getMessage() . "\n";
}
-
+ }
private function fillIP($ip)
{
$ar = explode(".",$ip);
diff --git a/library/Pbs/Session.php b/library/Pbs/Session.php
index eb7c927..ab29a04 100644
--- a/library/Pbs/Session.php
+++ b/library/Pbs/Session.php
@@ -16,11 +16,12 @@ class Pbs_Session{
$sessionmapper->find($id, $session);
return $session;
}
- public function createClient(Application_Model_Client $client){
+ public function createClient(Application_Model_Client $client){
$clientmapper = new Application_Model_ClientMapper();
$result = $clientmapper->findBy('macadress',$client->getMacadress());
- if(($result)>0){
- $client->setOptions($result);
+ if(count($result)>0){
+ $client->setOptions($result[0]);
+ $client->setID($result[0]['clientID']);
}
else{
$id = $clientmapper->save($client);
diff --git a/send-post.html b/send-post.html
new file mode 100644
index 0000000..d2ac08e
--- /dev/null
+++ b/send-post.html
@@ -0,0 +1,12 @@
+<html>
+
+<form action='http://localhost:81/' method='post'>
+BootisoID <input type='text' name='bootisoID' value='1'></br>
+mac <input type='text' name='mac' value='00:0c:29:01:63:88'></br>
+hardwarehash <input type='text' name='hardwarehash' value='51685132196851652186121869413216'></br>
+<input type='submit' value='test'>
+</form>
+
+
+</html>
+