1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
<?php
$PTR_session = session_start() ;
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/server.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/service.php";
//require_once $_SERVER['DOCUMENT_ROOT'] . "/class/users.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/magic.php";
// ==========================================================================
// Construct Working and Testing Environnment
// ==========================================================================
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/newMember.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/newLog.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/class/newDB.php";
// ------------------------------------------------------------------------------------------------------------------------------- //
// ------------------------------------------------------------------------------------------------------------------------------- //
// ------------------------------------------------------------------------------------------------------------------------------- //
// --------------------------------- INSTANCIATION DU SKELET --------------------------------- //
// ------------------------------------------------------------------------------------------------------------------------------- //
// ------------------------------------------------------------------------------------------------------------------------------- //
// ------------------------------------------------------------------------------------------------------------------------------- //
class Container
{ private $properties = array(), $dbEnv = array() ;
private $PTR_session, $debug ;
public static $Kernel, $Environ ;
public $server = array() ;
/**
* Container constructor
*
*/
public function __construct($PTR_session,$debug)
{ $this->PTR_session = $PTR_session ;
$this->debug = $debug ;
print("Container Starting" . CRLF) ;
}
public function execute($box=NULL, $parent=NULL, $param=NULL ) // array( $who , $desc , $arg ))
{ try {
print("Container Executing" . CRLF) ;
$dbEnv = Environ::getInstance($utf8=true,$this->debug) ;
$this->dbEnv = $dbEnv->getEnviron() ;
$this->db = Db::$MYsql ;
// =====================================================================================================================
// A partir de ce point, cela fonctionne, mais les routines vont tjs chercher leurs paramètres dans DB plutôt qu'ENVIRON
// =====================================================================================================================
$this->idConn = $this->db->dbConnect($debug=true,$utf8=true,$id='default') ;
$this->db->dbSelect($this->dbEnv['base'], $this->idConn ) ;
$Sql = "select * from screen where screen = 'index'" ;
$this->query = $this->db->dbQuery($Sql, $this->idConn) ;
$this->num = $this->db->dbNumrows($this->query) ;
$this->row = $this->db->dbfetchRows($this->query) ;
foreach ($this->row as $key => $value)
{ print("Key[".$key."] => Value[".$value."]" . CRLF ) ; }
// =====================================================================================================================
// Instantiation de 2 classes pour raison de test du Dispatcher
// =====================================================================================================================
/**
* Instanciation de la classe Member
* ---------------------------------
*/
if ($this->debug)
{ print("==========> Instanciating Member" . CRLF );
}
$this->member = new Member($this->db, $this->debug) ;
$this->member->execute() ; // donne un user_error dans le log.php
/**
* Instanciation de la classe Logging
* ----------------------------------
*/
if ($this->debug)
{ print("==========> Instanciating Logging" . CRLF );
}
$this->logging = new Logging($this->db, $this->debug) ;
$this->logging->execute() ; // donne un user_error dans le log.php
// =====================================================================================================================
// Enregistrement de ces 2 classes auprès du Dispatcher et execution de celui-ci
// =====================================================================================================================
$this->dispatcher("addServer",$this->member ,"gu_email" ) ;
$this->dispatcher("addServer",$this->logging,"isrt_log" ) ;
$this->printServer("After 2 isrts") ;
$this->dispatcher("remServer",$this->member ,"gu_email" ) ;
$this->printServer("After one remove") ;
// =====================================================================================================================
} catch (Exception $e) {
die("SKELETON CONNECTION ERROR: " . $this->display_exception($e) . "<br/>");
}
}
/**
* Container Destructor
*
*/
public function __destruct()
{
print("Container Ending" . CRLF) ;
}
/**
* get Db Environnment & handler
*
*/
function getDBenv()
{ return(Environ::$dbEnv) ;}
function getDBhandler()
{ return(DB::$dbInst ) ; }
// =============================================================================================================================== //
// ================================== Fonction de construction de la classe SKELETON ================================ //
// =============================================================================================================================== //
function getInstance($PTR_session, $debug=true)
{ if (self::$Kernel == NULL)
if (self::$Kernel = new Container($PTR_session, $debug=true))
if (self::$Kernel->debug)
user_error("Constructor Container OK !" , E_USER_NOTICE) ;
return(self::$Kernel) ;
}
// =============================================================================================================================== //
// =========================================== D I S P A T C H E R functions =================================================== //
// =============================================================================================================================== //
// =====================================================================================================================
// A partir de ce point se trouve le coding du dispatcher, les fonctions sont + bas
// =====================================================================================================================
function dispatcher($box, $parent, $param )
{ switch($box):
case "addServer" : //"addServer", $this , array(NOT USED)
$this->addServer( $parent , $parent, $param /*server*/ ) ;
break ;
case "remServer" : //"remServer", $this , array(NOT USED)
$this->remServer( $parent , $parent, $param/*server*/ ) ;
break ;
/*
case "addService" : //"addService", $this , array( $desc , $arg )
$this->addService( $parent, $param ) ;
break ;
case "addUsers" : $this->addUsers ( $method, $item ) ;
break ;
case "addRequest" : $this->addRequest( $method, $item ) ;
break ;
*/
endswitch ;
}
/**
* Server: ifExistServer
*
*/
function ifServerExist($servName)
{ foreach ($this->server as $key => $val)
{ if (strcmp($val,$servName) == 0)
return(true) ;
}
print("Server[".$servName."] (not ?) found ! " .CRLF) ;
return(false) ;
}
/**
* add Server
* ------------
* param obj: "$server" instanciated and having an "notify" property to be get in touch
* =======================================================================================
*/
function addServer( $server , $parent, $name )
{ if (!$this->ifServerExist($name))
if ( in_array($server, $this->server ) )
$this->message("Duplicated Server") ;
else
{ print("Server[".$name."] ADDED in list" . CRLF) ;
$this->server[] = $name ; //$server ;
}
$this->printServer("Addserver") ;
}
/**
* Server: delete Server
*
*/
function remServer( $server , $parent, $name )
{ if ($this->ifServerExist($name))
if ( in_array($server, $this->server ) )
return(False) ;
else
{ print("Server REMOVE from list" . CRLF) ;
//??? unset( $this->server[ $server ] ) ;
return True ;
}
$this->printServer("RemoveServer") ;
}
function addService( $server , $parent, $name )
{ if (!$this->ifServerExist($name))
if ( in_array($server, $this->server ) )
$this->message("Duplicated Server") ;
else
{ print("Server[".$name."] ADDED in list" . CRLF) ;
$this->server[] = $name ; //$server ;
}
$this->printServer("Addserver") ;
}
/**
* Server: print Server list
*
*/
function printServer($title)
{ print("=== printServer[".$title."] ===" . CRLF) ;
foreach($this->server as $key => $val)
print("key[".$key."] => val[".$val."]" . CRLF ) ;
}
// =============================================================================================================================== //
function __get($property)
{// user_error("__get used[".$property."]" , E_USER_NOTICE) ;
return( (isset($this->properties[$property])) ? $this->properties[$property] : NULL ) ;
}
function __set($property, $value)
{ // user_error("__set used[".$property."][".$value."]" , E_USER_NOTICE) ;
return($this->properties[$property] = $value) ;
}
// =============================================================================================================================== //
//
// End of class: Container
// ======================
}
$skelt = Container::getInstance($PTR_session, $debug=true) ;
$skelt->execute() ;
?> |
Partager