/**
  * 
  * @return string html
  */
 public function render()
 {
     if ($this->_enviroment->getDatabase() == "simulacion") {
         return $this->_ci->load->view("pages/layout/simulacion", array());
     } else {
         return "";
     }
 }
 /**
  * 
  * @return string
  */
 public function __toString()
 {
     if ($this->_enviroment->esSimulacion()) {
         return "[SIMULACIÓN] ";
     } else {
         return "";
     }
 }
 public function getDb()
 {
     if ($this->_bo_simulacion) {
         $this->_enviroment = new Enviroment();
         return $this->load->database($this->_enviroment->getDatabase(), true);
     } else {
         return $this->load->database(ENVIRONMENT, true);
     }
 }
Example #4
0
 /**
  * Get the current host of the request
  *
  * @return string
  * @throws UnexpectedValueException if the hostname is invalid
  */
 public function host()
 {
     if (!($host = Environment::get('HTTP_HOST'))) {
         if (!($host = $this->name())) {
             $host = Enviroment::get('SERVER_ADDR');
         }
     }
     // trim and remove port number from host
     $host = strtolower(preg_replace('/:\\d+$/', '', trim($host)));
     // check that it does not contain forbidden characters
     if ($host && preg_replace('/(?:^\\[)?[a-zA-Z0-9-:\\]_]+\\.?/', '', $host) !== '') {
         throw new UnexpectedValueException(sprintf('Invalid Host "%s"', $host));
     }
     // TODO
     // check the hostname against a trusted list of host patterns to avoid host header injection attacks
     if (count(self::$trustedHostPatterns) > 0) {
         foreach (self::$trustedHostPatterns as $pattern) {
             if (preg_match($pattern, $host)) {
                 return $host;
             }
         }
         throw new UnexpectedValueException(sprintf('Untrusted Host "%s"', $host));
     }
     return $host;
 }
Example #5
0
$autoLoader->setIncludePath(__DIR__ . '/entity/base');
// PARAM
define('VERSION', "1.0");
// ABSOLUTE DIR
define('CONFIG_ROUTE', __DIR__ . '/conf/route.xml');
define('CONFIG_DATABASE', __DIR__ . '/conf/database.xml');
define('BUILDER_ENTITY_PATH', __DIR__ . '/entity');
define('BUILDER_MODEL_PATH', __DIR__ . '/model');
define('BUILDER_CONTROLLER_PATH', __DIR__ . '/controller');
define('TEMPLATE_DIR', __DIR__ . '/view/');
// DIR
define('LOG_DIR', __DIR__ . '/log');
/**************************************************
 * Load Config
 **************************************************/
$env = new Enviroment();
$conf = new stdClass();
//apc_clear_cache(CONFIG_ROUTE);
//if( apc_exists(CONFIG_ROUTE) ) {
//	$conf->routes = apc_fetch(CONFIG_ROUTE);
//} else {
$tmpRoutes = simplexml_load_file(CONFIG_ROUTE);
$conf->routes = array();
foreach ($tmpRoutes as $route) {
    $routeObject = json_decode(json_encode($route));
    // Controller名をキーに連想配列に格納
    $conf->routes[$routeObject->path] = $routeObject;
}
// キャッシュに√設定を保存
//	apc_store(CONFIG_ROUTE, $conf->routes);
//}