コード例 #1
0
ファイル: dbPoll.php プロジェクト: Juli55/mvc-framework
 /**
  * @return View 
  */
 public function poll()
 {
     $em = new EntityManager();
     $em->getEntity('usability:user');
     $sec = 5;
     do {
         sleep(1);
         $dbData = $em->find('first_name', 'test');
         $sec--;
         if ($dbData) {
             break;
         }
     } while ($sec);
     return $this->JsonResponse(array('name' => $dbData->getFirst_name()));
 }
コード例 #2
0
ファイル: Security.php プロジェクト: Juli55/mvc-framework
 /**
  *
  * The loginMethod check if logged or login when the datas are right
  * 
  * @return boolean
  */
 public function login()
 {
     $request = new Request();
     $em = new EntityManager();
     $securityConfig = Config::securityConfig();
     $identificator = $securityConfig['identificator'];
     $passwordKey = $securityConfig['passwordKey'];
     $entityShortcut = $securityConfig['entityShortcut'];
     //get the dbConnection
     $em->getConnection();
     $entity = $em->getEntity($entityShortcut);
     //if the authentificationSession is empty then check then loginRequest
     if (empty($request->session['userid'])) {
         //check if the authentificationPostParameters aren't empty then check if the datas are valid then return
         if (!empty($request->post[$identificator]) && !empty($request->post[$passwordKey])) {
             //set the identificatorValue and the passwordValue
             $identificatorValue = $request->post[$identificator];
             $passwordValue = $request->post[$passwordKey];
             //salt and hash the password
             $salt1 = "74930slei93kdie9i3kdie93kdie9kdie93kdie93kdie93kdie9kei309ioögeut3fhsoöiutusü0emiß+m0gü8wvtpomuv,ß+,xiü.uim vüiri3mß";
             $salt2 = "dsajkflsafis543908530ljfksld4sdf34453ß0klsdjflkdslkjflksjflkdsjflkjdslkfjdslkfjlkdsjflkdsjfldsjlfdslkflsdjflkdsjlfdslkjfldskjflkjdslfjdslklsl";
             $password = hash('sha512', $salt1 . $passwordValue . $salt2);
             //get identificatorValue
             $em->find($identificator, $identificatorValue);
             $identificatorValue = call_user_func(array($entity, 'get' . ucfirst($identificator)));
             //if identificatorValue isn't empty and if the password is right return true else set an error number
             if (!empty($identificatorValue) && $entity->getPassword() === $password) {
                 $this->userObject = $entity;
                 $request->setSession('userid', $entity->getID());
                 return true;
             } else {
                 //the identificatior is empty or password
                 $this->errorNumber = 1;
             }
         } else {
             //one of the postParameters is/are empty
             $this->errorNumber = 2;
         }
     } else {
         //set the userObject
         $this->userObject = $entity;
         $em->find('id', $request->session['userid']);
         return true;
     }
     return false;
 }
コード例 #3
0
ファイル: dbController.php プロジェクト: Juli55/mvc-framework
 public function view($entryMsg)
 {
     //init EntityManager
     $em = new EntityManager();
     $entity = $em->getEntity("usability:test");
     //set an databaseTable entry
     $entity->setTest1($entryMsg);
     $em->persist($entity);
     $em->flush();
     //select an entry
     $entryObject = $em->find('id', 1);
     //select all entries by an proberty
     $entryObjects = $em->findAll('test1', 'entry');
     return $this->render("usability:db.html", array('entryMsg' => $entryMsg, 'entryObject' => $entryObject, 'entryObjects' => $entryObjects));
 }