diff options
| -rw-r--r-- | application/models/SessionMapper.php | 5 | ||||
| -rw-r--r-- | application/modules/fbgui/controllers/IndexController.php | 9 | ||||
| -rw-r--r-- | application/modules/user/controllers/IndexController.php | 5 | ||||
| -rw-r--r-- | library/Pbs/PbsSession.php | 19 |
4 files changed, 30 insertions, 8 deletions
diff --git a/application/models/SessionMapper.php b/application/models/SessionMapper.php index 83f0687..0810566 100644 --- a/application/models/SessionMapper.php +++ b/application/models/SessionMapper.php @@ -45,8 +45,7 @@ class Application_Model_SessionMapper } public function save(Application_Model_Session $session) - { - + { $data = array( 'sessionID'=> $session->getID() , 'alphasessionID'=> $session->getAlphasessionID(), 'clientID'=> $session->getClientID() , @@ -59,7 +58,7 @@ class Application_Model_SessionMapper 'ip6'=> $session->getIp6() ); if (null === ($id = $session->getID()) ) { unset($data['sessionID']); - $this->getDbTable()->insert($data); + return $this->getDbTable()->insert($data); } else { $this->getDbTable()->update($data, array('sessionID = ?' => $id)); } diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php index c1621dc..d141733 100644 --- a/application/modules/fbgui/controllers/IndexController.php +++ b/application/modules/fbgui/controllers/IndexController.php @@ -11,6 +11,15 @@ class Fbgui_IndexController extends Zend_Controller_Action public function indexAction() { // action body + + // Call this Procedure after Login to create a session and save the alphasessionID to session + $n = new Pbs_PbsSession(); + $session = new Application_Model_Session(); + $session->setBootisoID(1); + $session->setTime(time()); + $session->setIp($_SERVER['REMOTE_ADDR']); + $session = $n->createsession($session); + $_SESSION['alphasessionID'] = $session->getAlphasessionID(); } diff --git a/application/modules/user/controllers/IndexController.php b/application/modules/user/controllers/IndexController.php index 1d41157..d39ff21 100644 --- a/application/modules/user/controllers/IndexController.php +++ b/application/modules/user/controllers/IndexController.php @@ -10,10 +10,7 @@ class User_IndexController extends Zend_Controller_Action public function indexAction() { - $n = new Pbs_PbsSession(); - $session = new Application_Model_Session(); - $session->setID('1'); - $n->createsession($session); + } diff --git a/library/Pbs/PbsSession.php b/library/Pbs/PbsSession.php index 1e7bf46..1ed7cb1 100644 --- a/library/Pbs/PbsSession.php +++ b/library/Pbs/PbsSession.php @@ -7,7 +7,24 @@ class Pbs_PbsSession{ print_a("das ist ein Test"); } public function createsession(Application_Model_Session $session){ - print_a($session); + $sessionmapper = new Application_Model_SessionMapper(); + + $uniqid = $this->getUniqueCode(10); + $sm = new Application_Model_SessionMapper(); + while(count($sm->findBy('alphasessionID',$uniqid))>0){ + $uniqid = $this->getUniqueCode(16); + } + + $session->setAlphasessionID($uniqid); + $id = $sessionmapper->save($session); + $sessionmapper->find($id, $session); + return $session; + } + private function getUniqueCode($length = "") + { + $code = md5(uniqid(rand(), true)); + if ($length != "") return substr($code, 0, $length); + else return $code; } } |
