コード例 #1
0
ファイル: jaxl.0199.php プロジェクト: ngsru/JAXL
 public static function pinged($payload, $jaxl)
 {
     if ($payload['type'] == 'error' && $payload['errorCode'] == 501 && $payload['errorCondition'] == 'feature-not-implemented') {
         $jaxl->log("[[JAXL0199]] Server doesn't support ping feature, disabling cron tab for periodic ping...");
         JAXLCron::delete(array('JAXL0199', 'ping'), $jaxl->pingInterval);
         return $payload;
     }
     $jaxl->log("[[JAXL0199]] Rcvd ping response from the server...");
 }
コード例 #2
0
ファイル: jaxl.class.php プロジェクト: pavl00/Kalkun
 /**
  * Jaxl core constructor
  *
  * Jaxl instance configures itself using the constants inside your application jaxl.ini.
  * However, passed array of configuration options overrides the value inside jaxl.ini.
  * If no configuration are found or passed for a particular value,
  * Jaxl falls back to default config options.
  * 
  * @param $config Array of configuration options
  * @todo Use DNS SRV lookup to set $jaxl->host from provided domain info
  */
 function __construct($config = array())
 {
     global $jaxl_instance_cnt;
     parent::__construct($config);
     $this->uid = ++$jaxl_instance_cnt;
     $this->ip = gethostbyname(php_uname('n'));
     $this->config = $config;
     $this->pid = getmypid();
     /* Mandatory params to be supplied either by jaxl.ini constants or constructor $config array */
     $this->user = $this->getConfigByPriority(@$config['user'], "JAXL_USER_NAME", $this->user);
     $this->pass = $this->getConfigByPriority(@$config['pass'], "JAXL_USER_PASS", $this->pass);
     $this->domain = $this->getConfigByPriority(@$config['domain'], "JAXL_HOST_DOMAIN", $this->domain);
     $this->bareJid = $this->user . "@" . $this->domain;
     /* Optional params if not configured using jaxl.ini or $config take default values */
     $this->host = $this->getConfigByPriority(@$config['host'], "JAXL_HOST_NAME", $this->domain);
     $this->port = $this->getConfigByPriority(@$config['port'], "JAXL_HOST_PORT", $this->port);
     $this->resource = $this->getConfigByPriority(@$config['resource'], "JAXL_USER_RESC", "jaxl." . $this->uid . "." . $this->clocked);
     $this->status = $this->getConfigByPriority(@$config['status'], "JAXL_USER_STATUS", $this->status);
     $this->logLevel = $this->getConfigByPriority(@$config['logLevel'], "JAXL_LOG_LEVEL", $this->logLevel);
     $this->logRotate = $this->getConfigByPriority(@$config['logRotate'], "JAXL_LOG_ROTATE", $this->logRotate);
     $this->logPath = $this->getConfigByPriority(@$config['logPath'], "JAXL_LOG_PATH", $this->logPath);
     if (!file_exists($this->logPath) && !touch($this->logPath)) {
         throw new JAXLException("Log file " . $this->logPath . " doesn't exists");
     }
     $this->pidPath = $this->getConfigByPriority(@$config['pidPath'], "JAXL_PID_PATH", $this->pidPath);
     $this->mode = $this->getConfigByPriority(@$config['mode'], "JAXL_MODE", PHP_SAPI == "cli" ? PHP_SAPI : "cgi");
     if ($this->mode == "cli" && !file_exists($this->pidPath) && !touch($this->pidPath)) {
         throw new JAXLException("Pid file " . $this->pidPath . " doesn't exists");
     }
     /* Resolve temporary folder path */
     if (function_exists('sys_get_temp_dir')) {
         $this->tmpPath = sys_get_temp_dir();
     }
     $this->tmpPath = $this->getConfigByPriority(@$config['tmpPath'], "JAXL_TMP_PATH", $this->tmpPath);
     if ($this->tmpPath && !file_exists($this->tmpPath)) {
         throw new JAXLException("Tmp directory " . $this->tmpPath . " doesn't exists");
     }
     /* Handle pre-choosen auth type mechanism */
     $this->authType = $this->getConfigByPriority(@$config['authType'], "JAXL_AUTH_TYPE", $this->authType);
     if ($this->authType) {
         $this->addPlugin('jaxl_get_auth_mech', array($this, 'doAuth'));
     }
     /* Presence handling */
     $this->trackPresence = isset($config['trackPresence']) ? $config['trackPresence'] : true;
     $this->autoSubscribe = isset($config['autoSubscribe']) ? $config['autoSubscribe'] : false;
     $this->addPlugin('jaxl_get_presence', array($this, '_handlePresence'), 0);
     /* Optional params which can be configured only via constructor $config */
     $this->sigh = isset($config['sigh']) ? $config['sigh'] : true;
     $this->dumpStat = isset($config['dumpStat']) ? $config['dumpStat'] : 300;
     /* Configure instance for platforms */
     $this->configure($config);
     /* Initialize xml to array class (will deprecate in future) */
     $this->xml = new XML();
     /* Initialize JAXLCron and register core jobs */
     JAXLCron::init($this);
     if ($this->dumpStat) {
         JAXLCron::add(array($this, 'dumpStat'), $this->dumpStat);
     }
     if ($this->logRotate) {
         JAXLCron::add(array('JAXLog', 'logRotate'), $this->logRotate);
     }
     /* include recommended XEP's for every XMPP entity */
     $this->requires(array('JAXL0030', 'JAXL0128'));
     /* initialize multi-core instance holder */
     if ($jaxl_instance_cnt == 1) {
         $this->instances = array('xmpp' => array());
     }
     $this->instances['xmpp'][] = $this;
 }
コード例 #3
0
ファイル: jaxl.class.php プロジェクト: ZZB/JAXL
 /**
  * Jaxl core constructor
  *
  * Jaxl instance configures itself using the constants inside your application jaxl.ini.
  * However, passed array of configuration options overrides the value inside jaxl.ini.
  * If no configuration are found or passed for a particular value,
  * Jaxl falls back to default config options.
  * 
  * @param $config Array of configuration options
  * @todo Use DNS SRV lookup to set $jaxl->host from provided domain info
  */
 function __construct($config = array())
 {
     $this->mode = PHP_SAPI == "cli" ? PHP_SAPI : "cgi";
     $this->pid = getmypid();
     $this->config = $config;
     $this->ip = gethostbyname(php_uname('n'));
     /* Mandatory params to be supplied either by jaxl.ini constants or constructor $config array */
     $this->user = $this->getConfigByPriority($config['user'], "JAXL_USER_NAME", $this->user);
     $this->pass = $this->getConfigByPriority($config['pass'], "JAXL_USER_PASS", $this->pass);
     $this->domain = $this->getConfigByPriority($config['domain'], "JAXL_HOST_DOMAIN", $this->domain);
     $this->bareJid = $this->user . "@" . $this->domain;
     /* Optional params if not configured using jaxl.ini or $config take default values */
     $this->host = $this->getConfigByPriority($config['host'], "JAXL_HOST_NAME", $this->domain);
     $this->port = $this->getConfigByPriority($config['port'], "JAXL_HOST_PORT", $this->port);
     $this->resource = $this->getConfigByPriority($config['resource'], "JAXL_USER_RESC", "jaxl." . time());
     $this->logLevel = $this->getConfigByPriority($config['logLevel'], "JAXL_LOG_LEVEL", $this->logLevel);
     $this->logRotate = $this->getConfigByPriority($config['logRotate'], "JAXL_LOG_ROTATE", $this->logRotate);
     $this->logPath = $this->getConfigByPriority($config['logPath'], "JAXL_LOG_PATH", $this->logPath);
     $this->pidPath = $this->getConfigByPriority($config['pidPath'], "JAXL_PID_PATH", $this->pidPath);
     $this->tmpPath = $this->getConfigByPriority($config['tmpPath'], "JAXL_TMP_PATH", sys_get_temp_dir());
     /* Handle pre-choosen auth type mechanism */
     $this->authType = $this->getConfigByPriority($config['authType'], "JAXL_AUTH_TYPE", $this->authType);
     if ($this->authType) {
         JAXLPlugin::add('jaxl_get_auth_mech', array($this, 'doAuth'));
     }
     /* Optional params which can be configured only via constructor $config */
     $this->sigh = isset($config['sigh']) ? $config['sigh'] : true;
     $this->dumpStat = isset($config['dumpStat']) ? $config['dumpStat'] : 300;
     /* Configure instance for platforms and call parent construct */
     $this->configure($config);
     parent::__construct($config);
     $this->xml = new XML();
     /* Initialize JAXLCron and register instance cron jobs */
     JAXLCron::init();
     if ($this->dumpStat) {
         JAXLCron::add(array($this, 'dumpStat'), $this->dumpStat);
     }
     if ($this->logRotate) {
         JAXLCron::add(array('JAXLog', 'logRotate'), $this->logRotate);
     }
     // include service discovery XEP-0030 and it's extensions, recommended for every XMPP entity
     $this->requires(array('JAXL0030', 'JAXL0128'));
 }