Source for file OCSP_OBJ.phpclass

Documentation is available at OCSP_OBJ.phpclass

  1. <?php
  2. /**
  3.   * OCSP common class provides some basic methods
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    common
  7.   *
  8.   * @author     Peter Krebs (pk)<pitlinz@users.sourceforge.net>
  9.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-07-10-11
  12.   * @version $Id: OCSP_OBJ.phpclass,v 1.18 2008/12/12 17:35:14 pitlinz Exp $
  13.   ***/
  14.  
  15. if (!defined('_OCSP_PCF_COMMON_FUNCTIONS_LOADED_'))
  16. {
  17.     require_once __OCSP_PHPINCPATH__ "common" _OCSP_DIRSEP_ "pcf.phpinc";
  18. }
  19.  
  20. pcf_require_class('OCSP_CONF',dirname(__FILE__"/OCSP_CONF.phpclass");
  21.  
  22. /**
  23.   * OCSP common class
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    common
  27.   *
  28.   * @author     Peter Krebs (pk)<pitlinz@users.sourceforge.net>
  29.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   * @since pk-07-10-11
  32.   * @abstract
  33.   *
  34.   ***/
  35. abstract class OCSP_OBJ {
  36.  
  37.     /*** class constants  --------------------------------------------- */
  38.  
  39.     /**
  40.       * @constant string CLASS_SRC_FILE
  41.       * 
  42.       * @abstract
  43.       */
  44.     const CLASS_SRC_FILE = __FILE__;
  45.  
  46.     /*** class variables  --------------------------------------------- */
  47.  
  48.     /**
  49.       * @staticvar array $staticClassVars vars which must not be copied
  50.       */
  51.     protected static $staticClassVars=array();
  52.     
  53.  
  54.     
  55.     /*** compositions ------------------------------------------------  */
  56.  
  57.     /**
  58.       * @var OCSP_DB $myDBObj 
  59.       * @since pk-07-05-31
  60.       ***/
  61.     protected $myDBObj=NULL;
  62.  
  63.     /*** aggregation -------------------------------------------------- */
  64.  
  65.     /*** attributes --------------------------------------------------- */
  66.  
  67.     /*** OCSP environment --------------------------------------------- */
  68.         
  69.     /**
  70.      * @var OCSP_USER $global_currentUser 
  71.      */
  72.     protected static $global_currentUser NULL;
  73.  
  74.     /**
  75.      * returns the current user object
  76.      *
  77.      * @param boolean $$instantiate (do instantiate a new object if no one was found)
  78.      *  
  79.      * @return OCSP_USER 
  80.      * 
  81.      * @version pk-08-06-06
  82.      */
  83.     public static function currentUser($instantiate=True)
  84.     {
  85.         if (!self::$global_currentUser)
  86.         {            
  87.             // old style
  88.             global $OCSP_OBJ;
  89.             if (pcf_is_instance_of($OCSP_OBJ['USER'],'OCSP_USER'))
  90.             {
  91.                 self::$global_currentUser $OCSP_OBJ['USER'];
  92.                 $GLOBALS['OCSP_OBJ']['USER'&$OCSP_OBJ['USER'];
  93.             else if (pcf_is_instance_of($GLOBALS['OCSP_OBJ']['USER'],'OCSP_USER')) {
  94.                 self::$global_currentUser $GLOBALS['OCSP_OBJ']['USER'];
  95.                 $OCSP_OBJ['USER'&$GLOBALS['OCSP_OBJ']['USER'];
  96.             else if (!$instantiate{
  97.                 return self::$global_currentUser;
  98.             else if (class_exists('OCSP_SESSION'&& OCSP_SESSION::hasInstance()) {
  99.                 if (self::$global_currentUser OCSP_SESSION::getInstance(true)->getUser())
  100.                 {
  101.                     $OCSP_OBJ['USER'self::$global_currentUser;
  102.                     $GLOBALS['OCSP_OBJ']['USER'&$OCSP_OBJ['USER'];                         
  103.                 }
  104.             else {
  105.                 return NULL;
  106.             }
  107.         
  108.                             
  109.         }
  110.         return self::$global_currentUser;
  111.     }
  112.     
  113.     /**
  114.      * holdung the efault open connection for reads
  115.      *
  116.      * @staticvar OCSP_DB $global_defaultDBObj_read 
  117.      */
  118.     protected static $global_defaultDBObj_read  NULL;
  119.     
  120.     /**
  121.      * returns the default database object for read operations
  122.      *
  123.      * @return OCSP_DB 
  124.      */
  125.     public static function &defaultReadDBObj()
  126.     {
  127.         if (!self::$global_defaultDBObj_read)
  128.         {
  129.             return self::defaultDBObj('r');
  130.         else {
  131.             return self::$global_defaultDBObj_read;
  132.         }
  133.     }    
  134.  
  135.     /**
  136.      * holdung the default open connection for writes
  137.      *
  138.      * @staticvar OCSP_DB $global_defaultDBObj_write 
  139.      */    
  140.     protected static $global_defaultDBObj_write NULL;
  141.     
  142.     /**
  143.      * returns the default database object for write operations
  144.      *
  145.      * @return OCSP_DB 
  146.      */
  147.     public static function &defaultWriteDBObj()
  148.     {
  149.         if (!self::$global_defaultDBObj_write)
  150.         {
  151.             return self::defaultDBObj('w');
  152.         else {
  153.             return self::$global_defaultDBObj_write;
  154.         }
  155.     }      
  156.     
  157.     /**
  158.      * returns the default database object
  159.      * 
  160.      * possible modes are:
  161.      * - r (read)
  162.      * - w (write)
  163.      * - rw (read & write)
  164.      *
  165.      * @param string $mode 
  166.      * @param boolean $getFromUser 
  167.      * @param boolean $debug 
  168.      * 
  169.      * @return OCSP_DB 
  170.      * 
  171.      * @version pk-08-06-05
  172.      */
  173.     public static function &defaultDBObj($mode='rw',$getFromUser=True,$debug=False)
  174.     {
  175.         switch($mode)
  176.         {
  177.             case "w":
  178.             case "rw":
  179.                 if (!self::$global_defaultDBObj_write)
  180.                 {
  181.                     global $OCSP_OBJ;
  182.                     if (pcf_is_instance_of($OCSP_OBJ['USRDB'],'OCSP_DB'))
  183.                     {
  184.                         self::$global_defaultDBObj_write $OCSP_OBJ['USRDB'];
  185.                     else if ($getFromUser{
  186.                         self::$global_defaultDBObj_write self::currentUser()->getMyDBObj(False,"",False,$debug);
  187.                     }
  188.                 }
  189.                 return self::$global_defaultDBObj_write;
  190.             case "r":
  191.                 if (!self::$global_defaultDBObj_read)
  192.                 {
  193.                     global $OCSP_OBJ;
  194.                     if (pcf_is_instance_of($OCSP_OBJ['USRDB'],'OCSP_DB'))
  195.                     {
  196.                         self::$global_defaultDBObj_read $OCSP_OBJ['USRDB'];                        
  197.                     else if ($getFromUser{
  198.                         self::$global_defaultDBObj_read self::currentUser()->getMyDBObj(False,"",False,$debug);
  199.                     }
  200.                 }
  201.                 return self::$global_defaultDBObj_read;
  202.             default:
  203.                 throw new Exception('Database mode ' $mode " not implemented");
  204.         }
  205.     }
  206.  
  207.     /**
  208.      * returns a configuration option of $OCSP_CONF
  209.      *
  210.      * @param string $optName 
  211.      * 
  212.      * @return mixed 
  213.      */
  214.     public static function getConf($optName)
  215.     {
  216.         return OCSP_CONF::getInstance('OCSP')->getValue($optName,False,False,False);        
  217.     }
  218.     
  219.     /**
  220.      * sets a configuration value
  221.      *
  222.      * @param string $optName 
  223.      * @param mixed $optValue 
  224.      * 
  225.      * @since pk-08-03-18
  226.      */
  227.     public static function setConf($optName,$optValue)
  228.     {
  229.         global $OCSP_CONF;
  230.         $OCSP_CONF[$optName$optValue;
  231.         OCSP_CONF::getInstance('OCSP')->setValue($optName,$optValue);        
  232.     }
  233.  
  234.     /**
  235.      * checks if a string is utf8 encoded
  236.      *
  237.      * @param string $aString 
  238.      * @return boolean 
  239.      * 
  240.      * @since pk-08-11-12
  241.      */
  242.     public static function isUTF8($aString,$debug=False)
  243.     {        
  244.         if ($debugechoDebugMethod(__FILE__,"__STATIC__","OCSP_OBJ::isUTF8()",htmlspecialchars($aString));
  245.  
  246.         $c=0$b=0$i=0;
  247.         $bits=0;
  248.         $len=strlen($aString);
  249.         while ($i<$len)
  250.         {
  251.             $c=ord($aString[$i]);
  252.             if($c 128){
  253.                 if(($c >= 254)) return false;
  254.                 elseif($c >= 252$bits=6;
  255.                 elseif($c >= 248$bits=5;
  256.                 elseif($c >= 240$bits=4;
  257.                 elseif($c >= 224$bits=3;
  258.                 elseif($c >= 192$bits=2;
  259.                 else return false;
  260.                 if(($i+$bits$len)
  261.                 {
  262.                     return false;
  263.                 }
  264.                 while($bits 1)
  265.                 {
  266.                     $i++;
  267.                     $b=ord($str[$i]);
  268.                     if($b 128 || $b 191return false;
  269.                     $bits--;
  270.                 }
  271.             }
  272.             $i++;
  273.         }
  274.         return true;
  275.     }
  276.     
  277.     /**
  278.      * returns if $aString is a multibyte string
  279.      *
  280.      * @param string $aString 
  281.      * 
  282.      * @return boolean 
  283.      * 
  284.      * @since pk-08-11-12
  285.      */
  286.     public static function isMultiByteStr($aString)
  287.     {
  288.         $len=strlen($aString);
  289.         $i=0;
  290.         while ($i<$len)
  291.         {
  292.             $c=ord($aString[$i]);
  293.             if ($c 128)
  294.             {
  295.                 if($c >= 252return True//$bits=6;
  296.                 if($c >= 248return True//$bits=5;
  297.                 if($c >= 240return True//$bits=4;
  298.                 if($c >= 224return True//$bits=3;
  299.                 if($c >= 192return True//$bits=2;                
  300.             }
  301.             $i++;
  302.         }
  303.         return False;
  304.     }
  305.     
  306.     /**
  307.       *
  308.       * METHODS _____________________________________________
  309.       *
  310.       */
  311.  
  312.     /**
  313.      * returns the value of a class constant set with const aConstName=....
  314.      *
  315.      * @param string $aConstName 
  316.      * 
  317.      * @return mixed 
  318.      * 
  319.      * @since pk-08-01-19
  320.      */
  321.     public function get_myClassConstant($aConstName)
  322.     {
  323.         return constant(get_class($this).'::'.$aConstName);
  324.     }
  325.     
  326.     /**
  327.       * returns the class source file (if set)
  328.       *
  329.       * @return string 
  330.       *
  331.       */
  332.     public function get_mySourceFile()
  333.     {
  334.         return $this->get_myClassConstant('CLASS_SRC_FILE');
  335.     }
  336.  
  337.     /**
  338.       * object casting
  339.       */
  340.  
  341.     /**
  342.       * returns the object vars as array
  343.       *
  344.       * @param boolean $asRef (return an array of references to the vars array[$var]=&$this->var)
  345.       * @param boolean $strict (only return declared vars)
  346.       * @param boolean $debug 
  347.       *
  348.       * @return array 
  349.       *
  350.       * @access public
  351.       */
  352.     public function get_myObject_vars($asRef=FALSE,$strict=TRUE,$debug=FALSE)
  353.     {
  354.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_OBJ::get_myObject_vars()");
  355.  
  356.         $arr_ret=array();
  357.         if ($strict)
  358.         {
  359.             foreach(array_keys(get_class_vars(__CLASS__)) as $str_var)
  360.             {
  361.                 if ($asRef)
  362.                 {
  363.                     $arr_ret[$str_var]=&$this->{$str_var};
  364.                 else {
  365.                     $arr_ret[$str_var]=$this->{$str_var};
  366.                 }
  367.             }
  368.         else {
  369.             foreach(array_keys(get_object_vars($this)) as $str_var)
  370.             {
  371.                 if ($asRef)
  372.                 {
  373.                     $arr_ret[$str_var]=&$this->{$str_var};
  374.                 else {
  375.                     $arr_ret[$str_var]=$this->{$str_var};
  376.                 }
  377.             }
  378.         }
  379.         if ($debugechoDebugLine(__FILE__,__LINE__,"Class vars set:<pre>".print_r(array_keys($arr_ret),TRUE)."</pre>");
  380.         return $arr_ret;
  381.     }
  382.  
  383.     /**
  384.       * sets the object vars from an array
  385.       *
  386.       * @param array $objData 
  387.       * @param boolean $strict (set only declared vars)
  388.       * @param boolean $debug 
  389.       *
  390.       * @access protected
  391.       */
  392.     protected function set_myObject_vars($objData,$strict=FALSE,$debug=FALSE)
  393.     {
  394.         if ($debugechoDebugMethod(__FILE__,__CLASS__,"OCSP_OBJ::set_myObject_vars()","<pre>".print_r(array_keys($objData),TRUE)."</pre>");
  395.         
  396.         if ($strict)
  397.         {
  398.             foreach(array_keys(get_class_vars(__CLASS__)) as $str_var)
  399.             {
  400.                 if (!in_array($str_var,self::$staticClassVars))
  401.                 {
  402.                     if (isset($objData[$str_var])) $this->{$str_var}=$objData[$str_var];
  403.                 }
  404.             }
  405.         else {
  406.             //echo "<pre>".str_replace("\0","#",print_r((array) $this,TRUE))."</pre>";
  407.             foreach(array_keys($objDataas $str_var)
  408.             {
  409.                 if (!in_array($str_var,self::$staticClassVars))
  410.                 {
  411.                     $this->{$str_var}=$objData[$str_var];
  412.                 }
  413.             }
  414.         }
  415.     }
  416.  
  417.     /**
  418.       * sets the object vars from another object to $this
  419.       *
  420.       * @param object $srcobj 
  421.       * @param boolean $asRef (return an array of references to the vars array[$var]=&$this->var)
  422.       * @param boolean $strict (only return declared vars)
  423.       * @param boolean $debug 
  424.       *
  425.       * @return boolean 
  426.       */
  427.     public function set_myVarsFrom($srcobj,$asRef=FALSE,$strict=FALSE,$debug=FALSE)
  428.     {
  429.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_OBJ::set_myVarsFrom(".get_class($srcobj).")");
  430.  
  431.         if (!is_object($srcobj)) {
  432.             if ($debugocsp_logError(__FILE__,__LINE__,"\$srcobj is not an object",E_WARNING);
  433.             return FALSE;
  434.         }
  435.         if (method_exists($srcobj,"get_myObject_vars"))
  436.         {
  437.             $arr_vals=$srcobj->get_myObject_vars($asRef,$strict,$debug);
  438.             $this->set_myObject_vars($arr_vals,$strict,$debug);
  439.             return TRUE;
  440.         else {
  441.             if ($debugocsp_logError(__FILE__,__LINE__,"method ".get_class($srcobj)."::get_myObject_vars() does not exist ",E_WARNING);
  442.             return FALSE;
  443.         }
  444.     }
  445.  
  446.     /**
  447.       * casts an object to an other type
  448.       * the newClass source must already been loaded
  449.       *
  450.       * @static
  451.       *
  452.       * @param object &$obj 
  453.       * @param string $newClassName 
  454.       * @param boolean $debug 
  455.       *
  456.       * @return object 
  457.       */
  458.     static public function castObj(&$obj,$newClassName,$debug=FALSE)
  459.     {
  460.         if ($debugechoDebugMethod(__FILE__,'static::'.get_class($obj),"OCSP_OBJ::castObj($newClassName)");
  461.  
  462.         if (!is_subclass_of($obj,"OCSP_OBJ"))
  463.         {
  464.             if ($debugocsp_logError(__FILE__,__LINE__,get_class($obj)." is not a sub class of OCSP_OBJ",E_ERROR);
  465.             return FALSE;
  466.         }
  467.  
  468.         if (get_class($obj)!=$newClassName// else this does not make sense
  469.         {
  470.             if (!class_exists($newClassName))
  471.             {
  472.                 if ($debugocsp_logError(__FILE__,__LINE__,"class$newClassName does not exist",E_ERROR);
  473.                 return FALSE;
  474.             }
  475.  
  476.             $obj_new=new $newClassName();
  477.             if (!is_subclass_of($obj_new,"OCSP_OBJ"))
  478.             {
  479.                 if ($debugocsp_logError(__FILE__,__LINE__,"new class ".get_class($obj_new)." is not a sub class of OCSP_OBJ",E_ERROR);
  480.                 return FALSE;
  481.             }
  482.  
  483.             // check if the objects are castable
  484.             if (is_subclass_of($obj_newget_class($obj)) || is_subclass_of($obj,get_class($obj_new)))
  485.             {
  486.                 $obj_new->set_myVarsFrom($obj,FALSE,FALSE,$debug);
  487.                 $obj=$obj_new;
  488.                 return TRUE;
  489.             else {
  490.                 if ($debugocsp_logError(__FILE__,__LINE__,"new class ($newClassNameis not a subclass nor a parent of ".get_class($obj),E_ERROR);
  491.                 return FALSE;
  492.             }
  493.  
  494.         else {
  495.             return TRUE;
  496.         }
  497.  
  498.     }
  499.  
  500.     /**
  501.      * clones the object
  502.      * 
  503.      * returns a new object with the same attribut values
  504.      *
  505.      * @param boolean $debug 
  506.      * 
  507.      * @return object 
  508.      * 
  509.      * @since pk-08-02-16
  510.      */
  511.     public function cloneMe($debug)
  512.     {
  513.         $str_cmd "\$obj_new = new " get_class($this"();";
  514.         eval ($str_cmd);
  515.         
  516.         if (is_object($obj_new))
  517.         {
  518.             $obj_new->set_myVarsFrom($this,FALSE,FALSE,$debug);
  519.         }
  520.         
  521.         return $obj_new;        
  522.     }
  523.     
  524.     /**
  525.       *
  526.       * database methods -------------------------------------------------------------------------------
  527.       *
  528.       */
  529.  
  530.     /**
  531.       * sets the database object  (link)
  532.       * @param OCSP_DB $dbObj 
  533.       * @since pk-07-05-31
  534.       * @access public
  535.       ***/
  536.     function setDBObj(&$dbObj)
  537.     {
  538.         $this->myDBObj=$dbObj;
  539.     }
  540.  
  541.     /**
  542.      * allowed modes are:
  543.      * - r for read
  544.      * - w for write
  545.      * - rw for read/write
  546.      * 
  547.      * @param string $mode 
  548.      * @return OCSP_DB 
  549.      * 
  550.      * @todo select the right db connection
  551.      */
  552.     function &getDBObj($mode="r")
  553.     {            
  554.         if (pcf_is_instance_of($this->myDBObj,'OCSP_DB'))
  555.         {
  556.             return $this->myDBObj;
  557.         else {
  558.             if (strstr($mode,"w"))
  559.             {
  560.                 return self::defaultWriteDBObj();
  561.             else {
  562.                 return self::defaultReadDBObj();
  563.             }
  564.         }
  565.     }
  566.  
  567.  
  568.     /**
  569.       * returns if the dbObj is connected
  570.       *
  571.       * @param boolean $autoConnect try to connect
  572.       * @param boolean $debug 
  573.       *
  574.       * @return boolean 
  575.       *
  576.       * @since pk-07-05-31
  577.       */
  578.     function isConnected($autoConnect=False,$debug=False)
  579.     {
  580.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_TABLEOBJ::isConnected()");
  581.         if (pcf_is_instance_of($this->myDBObj,'OCSP_DB'))
  582.         {
  583.             if ($debugechoDebugLine(__FILE__,__LINE__,"myDBObj set".($autoConnect "AUTO" ""));
  584.             if ($this->myDBObj->isConnected())
  585.             {
  586.                 return TRUE;
  587.             else if ($autoConnect{
  588.                 if ($debugechoDebugLine(__FILE__,__LINE__,"Connecting to the database");
  589.                 $this->myDBObj->connect("",TRUE);
  590.                 return $this->myDBObj->isConnected();
  591.             else {
  592.                 return FALSE;
  593.             }
  594.         else {
  595.             if ($autoConnect)
  596.             {
  597.                 return $this->dbConnect("",FALSE,$debug);
  598.             else {
  599.                 return FALSE;
  600.             }
  601.         }
  602.     }
  603.  
  604.     /**
  605.       * connects to the default database
  606.       *
  607.       * @param string $confFile 
  608.       * @param boolean $reconnect (init a new DB object even we already have one)
  609.       * @param boolean $debug# 
  610.       *
  611.       * @global $OCSP_CONF 
  612.       *
  613.       * @return boolean 
  614.       * @access public
  615.       * @requires dirname(__FILE__)."/OCSP_DB.phpclass";
  616.       *
  617.       * @since pk-07-06-15
  618.       *
  619.       * @todo check if the current connection
  620.       * @todo reconnect
  621.       */
  622.     function dbConnect($confFile="",$reconnect=FALSE,$debug=FALSE)
  623.     {
  624.         global $OCSP_CONF;
  625.  
  626.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_TABLEOBJ::dbConnect()");
  627.         if (!$reconnect{
  628.  
  629.             if (pcf_is_instance_of($this->myDBObj,'OCSP_DB'&& $this->myDBObj->isConnected())
  630.             {
  631.                 if ($debugechoDebugLine(__FILE__,__LINE__,"we already have an established connection");
  632.                 return TRUE;
  633.             }
  634.  
  635.             if (pcf_is_instance_of($GLOBALS['OCSP_OBJ']['USER'],"OCSP_USER"))
  636.             {
  637.                 $b_asPublic=$GLOBALS['OCSP_OBJ']['USER']->isPublic();
  638.             else {
  639.                 if ($debugechoDebugLine(__FILE__,__LINE__,"using logged in user");
  640.                 $b_asPublic=TRUE;
  641.             }
  642.  
  643.             if (pcf_is_instance_of($this->myDBObj,'OCSP_DB')) {
  644.                 if ($debugechoDebugLine(__FILE__,__LINE__,"using \$this->myDBObj");
  645.                 if (!$this->myDBObj->isConnected()) $this->myDBObj->connect($confFile,$b_asPublic,FALSE,$debug);
  646.                 return $this->myDBObj->isConnected();
  647.             }
  648.  
  649.             if (pcf_is_instance_of($GLOBALS['OCSP_OBJ']['USRDB'],'OCSP_DB')) {
  650.                 if ($debugechoDebugLine(__FILE__,__LINE__,"using global database connection");
  651.                 if (!$GLOBALS['OCSP_OBJ']['USRDB']->isConnected()) $GLOBALS['OCSP_OBJ']['USRDB']->connet($confFile,$b_asPublic,FALSE,$debug);
  652.                 $this->myDBObj=&$GLOBALS['OCSP_OBJ']['USRDB'];
  653.                 return $GLOBALS['OCSP_OBJ']['USRDB']->isConnected();
  654.             }
  655.  
  656.             if (empty($confFile)) {
  657.                 if ((pcf_is_instance_of($GLOBALS['OCSP_OBJ']['USER'],'OCSP_USER')) && ($confFile=$GLOBALS['OCSP_OBJ']['USER']->getDBConfFile(FALSE,$debug)))
  658.                 {
  659.                     if ($debugechoDebugLine(__FILE__,__LINE__,"using the users db configuration");
  660.                 else {
  661.                     require_once __OCSP_PHPINCPATH__."db"._OCSP_DIRSEP_."OCSP_DB.phpclass";
  662.                     if (!$confFile=OCSP_DB::getMyConfFile($debug))
  663.                     {
  664.                         ocsp_logError(__FILE__,__LINE__,'NO DATABASE CONFIGURATION FOR TABLE:'.$this->myTable." in Class:".get_class($this));
  665.                         return FALSE;
  666.                     }
  667.                     if ($debugechoDebugLine(__FILE__,__LINE__,"using global configuration file");
  668.                 }
  669.             }
  670.  
  671.             if (!file_exists($confFile)) $confFile=$OCSP_CONF['PROJECTPATH'].$confFile;
  672.             require_once $confFile;
  673.  
  674.             if (!isset($DBCONF['CLASS']|| empty($DBCONF['CLASS']))
  675.             {
  676.                 $DBCONF['CLASS']    "OCSP_DB_mySQL";
  677.                 $DBCONF['INCLUDE']  __OCSP_PHPINCPATH__."db/OCSP_DB_mySQL.phpclass";
  678.             }
  679.             if (!class_exists($DBCONF['CLASS']))
  680.             {
  681.                 if (!empty($DBCONF['INCLUDE']))
  682.                 {
  683.                     require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  684.                     $str_inc=pcf_tmpl_parse($DBCONF['INCLUDE']);
  685.                     if ($debugechoDebugLine(__FILE__,__LINE__,"loading DB-ClassFile ".$tsr_inc);
  686.                     require_once $str_inc;
  687.                 else {
  688.                     require_once __OCSP_PHPINCPATH__."db/".$DBCONF['CLASS'].".phpclass";
  689.                 }
  690.             }
  691.  
  692.             $str_cmd="\$this->myDBObj=new ".$DBCONF['CLASS']."();";
  693.             if ($debugechoDebugLine(__FILE__,__LINE__,"generating db object ".$str_cmd);
  694.  
  695.             eval ($str_cmd);
  696.             $this->myDBObj->connect($confFile,$b_asPublic,FALSE,$debug);
  697.  
  698.             if (($confFile == OCSP_CONF::getInstance()->getValue('DBCONFFILE')) && !pcf_is_instance_of($GLOBALS['OCSP_OBJ']['USRDB'],'OCSP_DB'))
  699.             {
  700.                 // setting global database connection
  701.                 if ($debugechoDebugLine(__FILE__,__LINE__,"setting global database object");
  702.                 $GLOBALS['OCSP_OBJ']['USRDB']=&$this->myDBObj;
  703.             }
  704.  
  705.             return $this->myDBObj->isConnected();
  706.         else {
  707.             if ($debugechoDebugLine(__FILE__,__LINE__,"DBMS_TABLEOBJ::dbConnect(reconnect) NOT IMPLEMENTED".$tsr_cmd);
  708.         }
  709.     }
  710.  
  711.  
  712.  
  713. }
  714. ?>

Documentation generated on Thu, 08 Jan 2009 17:47:06 +0100 by phpDocumentor 1.4.0a2