Пример #1
0
 function configure()
 {
     $this->pid = getmypid();
     $this->mode = isset($_REQUEST['jaxl']) ? "cgi" : "cli";
     if (!JAXLUtil::isWin() && JAXLUtil::pcntlEnabled() && $config['sigh'] != FALSE) {
         pcntl_signal(SIGTERM, array($this, "shutdown"));
         pcntl_signal(SIGINT, array($this, "shutdown"));
         JAXLog::log("Registering shutdown for SIGH Terms ...", 0, $this);
     }
     if (JAXLUtil::sslEnabled()) {
         JAXLog::log("Openssl enabled ...", 0, $this);
     }
     if ($this->mode == "cli") {
         if (!function_exists('fsockopen')) {
             die("Jaxl requires fsockopen method ...");
         }
         file_put_contents(JAXL_PID_PATH, $this->pid);
     }
     if ($this->mode == "cgi") {
         if (!function_exists('curl_init')) {
             die("Jaxl requires curl_init method ...");
         }
     }
     // include service discovery XEP, recommended for every IM client
     jaxl_require('JAXL0030', $this, array('category' => 'client', 'type' => 'bot', 'name' => JAXL_NAME, 'lang' => 'en'));
 }
Пример #2
0
 /**
  * Configures Jaxl instance to run across various platforms (*nix/windows)
  *
  * Configure method tunes connecting Jaxl instance for
  * OS compatibility, SSL support and dependencies over PHP methods
  */
 protected function configure()
 {
     // register shutdown function
     if (!JAXLUtil::isWin() && JAXLUtil::pcntlEnabled() && $this->sigh) {
         pcntl_signal(SIGTERM, array($this, "shutdown"));
         pcntl_signal(SIGINT, array($this, "shutdown"));
         $this->log("[[JAXL]] Registering shutdown callbacks", 5);
     } else {
         $this->log("[[JAXL]] No callbacks for shutdown", 5);
     }
     // check Jaxl dependency on PHP extension in cli mode
     if ($this->mode == "cli") {
         if ($this->openSSL = JAXLUtil::sslEnabled()) {
             $this->log("[[JAXL]] OpenSSL extension is loaded.", 5);
         } else {
             $this->log("[[JAXL]] OpenSSL extension not loaded.", 5);
         }
         if (!function_exists('fsockopen')) {
             throw new JAXLException("[[JAXL]] Requires fsockopen method");
         }
         if (@is_writable($this->pidPath)) {
             file_put_contents($this->pidPath, $this->pid);
         }
     }
     // check Jaxl dependency on PHP extension in cgi mode
     if ($this->mode == "cgi") {
         if (!function_exists('curl_init')) {
             throw new JAXLException("[[JAXL]] Requires CURL PHP extension");
         }
         if (!function_exists('json_encode')) {
             throw new JAXLException("[[JAXL]] Requires JSON PHP extension.");
         }
     }
 }