Ejemplo n.º 1
0
 /**
  * It allows to run your simple web-apps in spawn-fcgi/php-fpm environment.
  * @return boolean - Success.
  */
 public static function compatRunEmul()
 {
     Daemon::$dir = realpath(__DIR__ . '/..');
     Daemon::$compatMode = TRUE;
     Daemon::initSettings();
     $argv = isset($_SERVER['CMD_ARGV']) ? $_SERVER['CMD_ARGV'] : '';
     $args = Daemon_Bootstrap::getArgs($argv);
     if (isset($args[$k = 'configfile'])) {
         Daemon::$config[$k] = $args[$k];
     }
     if (!Daemon::$config->loadCmdLineArgs($args)) {
         $error = TRUE;
     }
     if (isset(Daemon::$config->configfile->value) && !Daemon::loadConfig(Daemon::$config->configfile->value)) {
         $error = TRUE;
     }
     if (!isset(Daemon::$config->path->value)) {
         exit('\'path\' is not defined');
     }
     $appResolver = (require Daemon::$config->path->value);
     $appResolver->init();
     $req = new stdClass();
     $req->attrs = new stdClass();
     $req->attrs->request = $_REQUEST;
     $req->attrs->get = $_GET;
     $req->attrs->post = $_REQUEST;
     $req->attrs->cookie = $_REQUEST;
     $req->attrs->server = $_SERVER;
     $req->attrs->files = $_FILES;
     $req->attrs->session = isset($_SESSION) ? $_SESSION : NULL;
     $req->attrs->connId = 1;
     $req->attrs->trole = 'RESPONDER';
     $req->attrs->flags = 0;
     $req->attrs->id = 1;
     $req->attrs->params_done = TRUE;
     $req->attrs->stdin_done = TRUE;
     $req = $appResolver->getRequest($req);
     while (TRUE) {
         $ret = $req->call();
         if ($ret === 1) {
             return;
         }
     }
 }