phpPoA2
[ class tree: phpPoA2 ] [ index: phpPoA2 ] [ all elements ]

Source for file PAPIDBADB.php

Documentation is available at PAPIDBADB.php

  1. <?php
  2. /**
  3.  * @copyright Copyright 2005-2010 RedIRIS, http://www.rediris.es/
  4.  *
  5.  *  This file is part of phpPoA2.
  6.  *  
  7.  *  phpPoA2 is free software: you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation, either version 3 of the License, or
  10.  *  (at your option) any later version.
  11.  *  
  12.  *  phpPoA2 is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with phpPoA2. If not, see <http://www.gnu.org/licenses/>.
  19.  *
  20.  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
  21.  * @version 2.0
  22.  * @author Jaime Perez <jaime.perez@rediris.es>
  23.  * @filesource
  24.  */
  25.  
  26. /**
  27.  * PAPI binding to a Berkeley DB backend.
  28.  * @package phpPoA2
  29.  * @subpackage PAPIAuthenticationEngine
  30.  */
  31. class PAPIDBADB extends DBADB implements PAPIDB {
  32.  
  33.     protected $context;
  34.  
  35.     public function replaceContents($key$get$post$request$query$method$input$hli{
  36.         $this->context['timestamp'time();
  37.         $this->context['GET'$get;
  38.         $this->context['POST'$post;
  39.         $this->context['REQUEST'$request;
  40.         $this->context['QUERY_STRING'$query;
  41.         $this->context['REQUEST_METHOD'$method;
  42.         $this->context['PHP_INPUT'$input;
  43.         $this->context['HLI'$hli;
  44.  
  45.         $result @dba_replace($keyserialize($this->context)$this->db);
  46.         dba_sync($this->db);
  47.         return $result;
  48.     }
  49.  
  50.     public function fetch($key{
  51.         $raw @dba_fetch($key$this->db);
  52.  
  53.         if (!$rawreturn false;
  54.  
  55.         $this->context = unserialize($raw);
  56.  
  57.         return $this->context;
  58.     }
  59.  
  60.     public function purge($gap{
  61.         $time time();
  62.         $key @dba_firstkey($this->db);
  63.         $result 0;
  64.  
  65.         // iterate over database
  66.         while ($key != false{
  67.             $entry unserialize(@dba_fetch($key$this->db));
  68.             if ($entry['timestamp'$time $gap{
  69.                 if (@dba_delete($key$this->db))
  70.                     $result++;
  71.             }
  72.             $key @dba_nextkey($this->db);
  73.         }
  74.  
  75.         return $result;
  76.     }
  77.  
  78. }
  79.  
  80. ?>

Documentation generated on Fri, 11 Feb 2011 10:58:03 +0100 by phpDocumentor 1.4.3