Exemplo n.º 1
0
 /**
  * Loads and initiates the SQL driver that we need to use.
  *
  */
 public function __construct()
 {
     if (!$this->_oObject) {
         switch (Phpfox::getParam(array('db', 'driver'))) {
             case 'mysqli':
                 $sDriver = 'phpfox.database.driver.mysqli';
                 break;
             case 'postgres':
                 $sDriver = 'phpfox.database.driver.postgres';
                 break;
             case 'mssql':
                 $sDriver = 'phpfox.database.driver.mssql';
                 break;
             case 'oracle':
                 $sDriver = 'phpfox.database.driver.oracle';
                 break;
             case 'sqlite':
                 $sDriver = 'phpfox.database.driver.sqlite';
                 break;
             default:
                 $sDriver = 'phpfox.database.driver.mysql';
                 break;
         }
         $this->_oObject = Phpfox::getLib($sDriver);
         $this->_oObject->connect(Phpfox::getParam(array('db', 'host')), Phpfox::getParam(array('db', 'user')), Phpfox::getParam(array('db', 'pass')), Phpfox::getParam(array('db', 'name')));
     }
 }
Exemplo n.º 2
0
 /**
  * Invoke middleware
  * 
  * @param ServerRequestInterface $request  request
  * @param ResponseInterface      $response response
  * @param callable               $next     callable
  * 
  * @return object ResponseInterface
  */
 public function __invoke(Request $request, Response $response, callable $next = null)
 {
     $this->websocket = new Websocket($this->getContainer()->get('app'), $this->getContainer()->get('config'), $this->getContainer()->get('logger.params'));
     $this->websocket->connect();
     $err = null;
     return $next($request, $response, $err);
 }
Exemplo n.º 3
0
 /**
  * 初始化
  * 
  * @param array $option  配置数组
  */
 public function __construct($option)
 {
     empty($option['host']) or $this->host = $option['host'];
     empty($option['port']) or $this->port = intval($option['port']);
     is_null($option['flag']) or $this->flag = $option['flag'];
     is_null($option['expire']) or $this->expire = intval($option['expire']);
     $this->mem = new Memcache();
     $this->mem->connect($this->host, $this->port) and $this->isConnected = TRUE;
 }
Exemplo n.º 4
0
Arquivo: Redis.php Projeto: Rgss/imp
 /**
  * 初始化Redis
  * 
  * @param array $config
  */
 public function __construct($config = array())
 {
     if (empty($config['server'])) {
         $config['server'] = '127.0.0.1';
     }
     if (empty($config['port'])) {
         $config['port'] = '6379';
     }
     $this->redis = new Redis();
     $this->redis->connect($config['server'], $config['port']);
 }
Exemplo n.º 5
0
 /**
  * Connect to the queue.
  *
  * @return .
  */
 public function connect()
 {
     $config =& $this->_config;
     if (!$this->connection) {
         $this->connection = new AMQPConnection(array('host' => $config['host'], 'port' => $config['port'], 'vhost' => $config['vhost'], 'login' => $config['login'], 'password' => $config['password'], 'read_timeout' => $config['readTimeout'], 'write_timeout' => $config['writeTimeout'], 'connect_timeout' => $config['connectTimeout']));
         if ($this->connection->connect()) {
             $this->_isConnected = true;
         }
     }
     return $this->isConnected();
 }
Exemplo n.º 6
0
 protected function _connect()
 {
     $this->_iSession = new iSession();
     if (!isset($this->profile['port'])) {
         $this->profile['port'] = 8088;
     }
     $connectionArray = array('host' => $this->profile['host'], 'port' => $this->profile['port'], 'read_only' => 1, 'charset' => in_UTF8, 'database' => $this->profile['database'], 'user' => $this->profile['user'], 'password' => $this->profile['password'], 'page_size' => 20, 'max_answers_count' => 1000, 'default-language' => 'en');
     $cnx = @$this->_iSession->connect($connectionArray);
     if ($cnx) {
         return $this->_iSession;
     } else {
         throw new Exception($this->_iSession->status());
     }
 }
Exemplo n.º 7
0
 /**
  * Initialize
  */
 public function __construct()
 {
     // ObjectManager aufrufen
     $this->objectManager = ObjectManager::getInstance();
     // Registry
     $this->registry = $this->objectManager->getObject('Registry');
     // Request
     $this->request = $this->objectManager->getObject('Request');
     // Debug Trace
     $this->debug = $this->objectManager->getObject('Debug');
     // Database access point
     $this->database = $this->objectManager->getObject('Database');
     $this->database->connect();
     return $this;
 }
Exemplo n.º 8
0
 /**
  * Handles connecting to the server and checking the
  * response is valid.
  *
  * @access private
  * @param  string $host Hostname of server
  * @param  string $port Port of server
  * @return mixed        True on success, PEAR_Error otherwise
  */
 function connect($host, $port)
 {
     if (NET_SIEVE_STATE_DISCONNECTED != $this->_state) {
         $msg = 'Not currently in DISCONNECTED state';
         $code = 1;
         return $this->_raiseError($msg, $code);
     }
     if (PEAR::isError($res = $this->_sock->connect($host, $port, null, 5))) {
         return $res;
     }
     $this->_state = NET_SIEVE_STATE_AUTHORISATION;
     if (PEAR::isError($res = $this->_doCmd())) {
         return $res;
     }
     /*
             if(PEAR::isError($res = $this->_cmdCapability() )) {
                 $msg='Failed to connect, server said: ' . $res->getMessage();
                 $code=2;
                 return $this->_raiseError($msg,$code);
             }
     */
     // Get logon greeting/capability and parse
     $this->_parseCapability($res);
     return true;
 }
		/**
		 * Connect to memcached server
		 * @return bool
		 * @access protected
		 */
		protected function Connect()
		{
			if (!is_object($this->MemCache))
				$this->MemCache = new Memcache;
				
			try
			{
				$this->IsConnected = @$this->MemCache->connect($this->Options["host"], $this->Options["port"]);
				return $this->IsConnected;
			}
			catch (Exception $e)
			{
				Core::RaiseWarning("Cannot connect to memcached server on 
				".$this->Options["host"] .":". $this->Options["port"]);
				
				return false;
			}
			
			// Would need it anyway
			if (!$retval)
				Core::RaiseWarning("Cannot connect to memcached server on 
				".$this->Options["host"] .":". $this->Options["port"]);
			
			return false;
		}
Exemplo n.º 10
0
Arquivo: smtp.php Projeto: roojs/pear
 /**
  * Connect to the SMTP server by instantiating a Net_SMTP object.
  *
  * @return mixed Returns a reference to the Net_SMTP object on success, or
  *               a PEAR_Error containing a descriptive error message on
  *               failure.
  *
  * @since  1.2.0
  * @access public
  */
 function &getSMTPObject()
 {
     if (is_object($this->_smtp) !== false) {
         return $this->_smtp;
     }
     include_once 'Net/SMTP.php';
     $this->_smtp =& new Net_SMTP($this->host, $this->port, $this->localhost, false, 0, $this->socket_options);
     /* If we still don't have an SMTP object at this point, fail. */
     if (is_object($this->_smtp) === false) {
         return $this->raiseError('Failed to create a Net_SMTP object', PEAR_MAIL_SMTP_ERROR_CREATE);
     }
     /* Configure the SMTP connection. */
     if ($this->debug) {
         $this->_smtp->setDebug(true, $this->debug_handler);
     }
     /* Attempt to connect to the configured SMTP server. */
     if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) {
         list($code, $error) = $this->_error('Failed to connect to ' . $this->host . ':' . $this->port, $res);
         $txt = implode("\n", $this->_smtp->_arguments);
         return $this->raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT, null, null, array('smtpcode' => $code, 'smtptext' => $txt));
     }
     /* Attempt to authenticate if authentication has been enabled. */
     if ($this->auth) {
         $method = is_string($this->auth) ? $this->auth : '';
         if (PEAR::isError($res = $this->_smtp->auth($this->username, $this->password, $method))) {
             list($code, $error) = $this->_error("{$method} authentication failure", $res);
             $txt = implode("\n", $this->_smtp->_arguments);
             $this->_smtp->rset();
             return $p = new PEAR();
             raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH, null, null, array('smtpcode' => $code, 'smtptext' => $txt));
         }
     }
     return $this->_smtp;
 }
Exemplo n.º 11
0
 /**
  * Envoi via la classe smtp
  * 
  * @param string $address  Adresses des destinataires
  * @param string $message  Corps de l'email
  * @param string $headers  Entêtes de l'email
  * @param string $Rpath    Adresse d'envoi (définit le return-path)
  * 
  * @access private
  * @return boolean
  */
 function smtpmail($address, $message, $headers, $Rpath)
 {
     if (!is_resource($this->smtp->connect_id) || !$this->smtp->noop()) {
         if (!$this->smtp->connect()) {
             $this->error($this->smtp->msg_error);
             return false;
         }
     }
     if (!$this->smtp->mail_from($Rpath)) {
         $this->error($this->smtp->msg_error);
         return false;
     }
     foreach ($address as $email) {
         if (!$this->smtp->rcpt_to($email)) {
             $this->error($this->smtp->msg_error);
             return false;
         }
     }
     if (!$this->smtp->send($headers, $message)) {
         $this->error($this->smtp->msg_error);
         return false;
     }
     //
     // Apparamment, les commandes ne sont réellement effectuées qu'après la fermeture proprement
     // de la connexion au serveur SMTP. On quitte donc la connexion courante si l'option de connexion
     // persistante n'est pas activée.
     //
     if (!$this->persistent_connection) {
         $this->smtp->quit();
     }
     return true;
 }
Exemplo n.º 12
0
 /**
  * Connect to the SMTP server by instantiating a Net_SMTP object.
  *
  * @return mixed Returns a reference to the Net_SMTP object on success, or
  *               a PEAR_Error containing a descriptive error message on
  *               failure.
  *
  * @since  1.2.0
  * @access public
  */
 function &getSMTPObject()
 {
     if (is_object($this->_smtp) !== false) {
         return $this->_smtp;
     }
     include_once 'Net/SMTP.php';
     $this->_smtp = new Net_SMTP($this->host, $this->port, $this->localhost);
     /* If we still don't have an SMTP object at this point, fail. */
     if (is_object($this->_smtp) === false) {
         return PEAR::raiseError('Failed to create a Net_SMTP object', PEAR_MAIL_SMTP_ERROR_CREATE);
     }
     /* Configure the SMTP connection. */
     if ($this->debug) {
         $this->_smtp->setDebug(true);
     }
     /* Attempt to connect to the configured SMTP server. */
     if (PEAR::isError($res = $this->_smtp->connect($this->timeout))) {
         $error = $this->_error('Failed to connect to ' . $this->host . ':' . $this->port, $res);
         return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_CONNECT);
     }
     /* Attempt to authenticate if authentication has been enabled. */
     if ($this->auth) {
         $method = is_string($this->auth) ? $this->auth : '';
         if (PEAR::isError($res = $this->_smtp->auth($this->username, $this->password, $method))) {
             $error = $this->_error("{$method} authentication failure", $res);
             $this->_smtp->rset();
             return PEAR::raiseError($error, PEAR_MAIL_SMTP_ERROR_AUTH);
         }
     }
     return $this->_smtp;
 }
Exemplo n.º 13
0
 /**
  * Handles connecting to the server and checking the
  * response is valid.
  *
  * @access private
  * @param  string $host Hostname of server
  * @param  string $port Port of server
  * @param  array  $options List of options to pass to connect
  * @param  boolean $useTLS Use TLS if available
  * @return mixed        True on success, PEAR_Error otherwise
  */
 function connect($host, $port, $options = null, $useTLS = true)
 {
     if (NET_SIEVE_STATE_DISCONNECTED != $this->_state) {
         $msg = 'Not currently in DISCONNECTED state';
         $code = 1;
         return $this->_raiseError($msg, $code);
     }
     if (PEAR::isError($res = $this->_sock->connect($host, $port, false, 5, $options))) {
         return $res;
     }
     if ($this->_bypassAuth === false) {
         $this->_state = NET_SIEVE_STATE_AUTHORISATION;
         if (PEAR::isError($res = $this->_doCmd())) {
             return $res;
         }
     } else {
         $this->_state = NET_SIEVE_STATE_TRANSACTION;
     }
     // Explicitly ask for the capabilities in case the connection
     // is picked up from an existing connection.
     if (PEAR::isError($res = $this->_cmdCapability())) {
         $msg = 'Failed to connect, server said: ' . $res->getMessage();
         $code = 2;
         return $this->_raiseError($msg, $code);
     }
     if ($useTLS === true) {
         // check if we can enable TLS via STARTTLS
         if (isset($this->_capability['starttls']) && function_exists('stream_socket_enable_crypto') === true) {
             if (PEAR::isError($res = $this->_startTLS())) {
                 return $res;
             }
         }
     }
     return true;
 }
Exemplo n.º 14
0
 /**
  * 获取Redis实例
  * @param string $host
  * @param string $port
  * @param string $auth
  * @param string $sign
  */
 public static function getInstance($host = 'localhost', $port = '6379', $auth = '', $sign = 'default')
 {
     if (!self::$instance) {
         self::$instance = new Redis();
         self::$instance->connect($host, $port);
         if ($auth) {
             self::$instance->auth($auth);
         }
         self::$instanceList[$sign] = self::$instance;
     } else {
         if (isset(self::$instanceList[$sign])) {
             self::$instance = self::$instanceList[$sign];
         }
     }
     return self::$instance;
 }
Exemplo n.º 15
0
 /**
  * 构造函数
  *
  * @access public
  *
  * @param array $params 数据库连接参数,如主机名,数据库用户名,密码等
  *
  * @return boolean
  */
 public function __construct($options = null)
 {
     if (!extension_loaded('redis')) {
         Controller::halt('The redis extension to be loaded!');
     }
     //当参数为空时,程序则自动加载配置文件中数据库连接参数
     if (!$options || !is_array($options)) {
         $options = Configure::get('redis');
         if (!$options) {
             $options = array();
         }
     }
     $options += $this->_defaultServer;
     //连接数据库
     $this->_dbLink = new Redis();
     $this->_dbLink->connect($options['host'], $options['port']);
     return true;
 }
Exemplo n.º 16
0
 /**
  * 连接数据库
  *
  * @param	array	$config
  * @return	mixed
  */
 private function _connect($db)
 {
     try {
         $connection = $this->_driver->connect($db['host'], $db['port'], $db['username'], $db['password'], $db['default'], $db['charset']);
     } catch (Exception $e) {
         throw new Exception('亲,我鸭梨山大,请稍后再试');
     }
     return $connection;
 }
Exemplo n.º 17
0
 /**
  * Sets up the database manager that will be used and name of the search
  * engine database
  *
  * @param string $db_name the name of the database for the search engine
  * @param bool $connect whether to connect to the database by default
  *     after making the datasource class
  */
 function __construct($db_name = DB_NAME, $connect = true)
 {
     $db_class = ucfirst(DBMS) . "Manager";
     $this->db = new $db_class();
     if ($connect) {
         $this->db->connect();
     }
     $this->db_name = $db_name;
 }
Exemplo n.º 18
0
 /**
  * Connects to a server in connection pool
  *
  * @param string $host host ip address or name
  * @param integer $port Server port
  * @return boolean True if memcache server was connected
  * @access public
  */
 function connect($host, $port = 11211)
 {
     if ($this->memcache->getServerStatus($host, $port) === 0) {
         if ($this->memcache->connect($host, $port)) {
             return true;
         }
         return false;
     }
     return true;
 }
Exemplo n.º 19
0
 /**
  * 连接Redis数据库
  *
  * @access private
  * @return void
  */
 private function _connect()
 {
     if (empty($this->_redis)) {
         if (!class_exists('Redis')) {
             trigger_error('PHP Extend error: Redis extend class dos not exists');
         }
         $this->_redis = new Redis();
         $this->_redis->connect($this->_config['host'], $this->_config['port']);
     }
 }
Exemplo n.º 20
0
 /**
  * 构造方法,根据不同的引擎传入配置信息数组
  * @param array $config
  * @return null
  */
 private function __construct($config = array())
 {
     self::$ip = self::get_client_ip();
     self::$watchType = isset($config['type']) ? $config['type'] : 'number';
     if (class_exists('Redis') && isset($config['mode']) && $config['mode'] == 'redis') {
         self::$kv = new RedisCache();
         $redis_config = array('host' => isset($config['host']) ? $config['host'] : '127.0.0.1', 'port' => isset($config['port']) ? $config['port'] : 6379, 'auth' => isset($config['auth']) ? $config['auth'] : '');
         self::$kv->connect($redis_config);
         // 如果设置了记录间隔时间则判断$key是否需要清除
         if (isset($config['interval'])) {
             // redis的kv类型直接使用ttl获取过期时间,expire设置过期时间
             if (self::$watchType == 'number') {
                 // 查看是否已经设置了过期时间
                 $ttl = self::$kv->ttl(self::$ip);
                 self::$kv->expire(self::$ip, $config['interval']);
             } else {
                 // redis的list类型需要获取尾部最后一次请求的时间与当前时间做比对以判断是否过期
                 $first = self::$kv->lget(self::$ip, -1);
                 if ($first && $first + $config['interval'] < time()) {
                     self::$kv->delete(self::$ip);
                 }
             }
         }
     } else {
         // 文件缓存配置
         $file_config = array('file_dir' => isset($config['file_dir']) ? $config['file_dir'] : sys_get_temp_dir() . '/' . self::$watchType, 'prefix' => isset($config['prefix']) ? $config['prefix'] : '', 'suffix' => isset($config['suffix']) ? $config['suffix'] : '');
         // 建立缓存目录
         if (!is_dir($file_config['file_dir'])) {
             mkdir($file_config['file_dir'], 0777, true);
         }
         self::$kv = new FileCache($file_config);
         // 如果设置了记录间隔时间则判断$key是否需要清除
         if (isset($config['interval'])) {
             $filepath = self::$kv->_path(self::$ip);
             // 清除缓存,通过文件的修改时间判断,如果过期则删除重新计数
             clearstatcache();
             if (file_exists($filepath) && filemtime($filepath) + $config['interval'] < time()) {
                 @unlink($filepath);
             }
         }
     }
 }
Exemplo n.º 21
0
 /**
  * Build cache data.
  *
  */
 function cache()
 {
     global $db, $mybb;
     switch ($mybb->config['cache_store']) {
         // Disk cache
         case "files":
             require_once MYBB_ROOT . "/inc/cachehandlers/disk.php";
             $this->handler = new diskCacheHandler($this->silent);
             break;
             // Memcache cache
         // Memcache cache
         case "memcache":
             require_once MYBB_ROOT . "/inc/cachehandlers/memcache.php";
             $this->handler = new memcacheCacheHandler($this->silent);
             break;
             // eAccelerator cache
         // eAccelerator cache
         case "eaccelerator":
             require_once MYBB_ROOT . "/inc/cachehandlers/eaccelerator.php";
             $this->handler = new eacceleratorCacheHandler($this->silent);
             break;
             // Xcache cache
         // Xcache cache
         case "xcache":
             require_once MYBB_ROOT . "/inc/cachehandlers/xcache.php";
             $this->handler = new xcacheCacheHandler($this->silent);
             break;
     }
     if (is_object($this->handler)) {
         if (method_exists($this->handler, "connect")) {
             if (!$this->handler->connect()) {
                 $this->handler = null;
             }
         }
     } else {
         // Database cache
         $query = $db->simple_select("datacache", "title,cache");
         while ($data = $db->fetch_array($query)) {
             $this->cache[$data['title']] = unserialize($data['cache']);
         }
     }
 }
Exemplo n.º 22
0
 /**
  * Initialize
  */
 public function __construct()
 {
     // ObjectManager aufrufen
     $this->objectManager = ObjectManager::getInstance();
     // Registry
     $this->registry = $this->objectManager->getObject('Registry');
     // Request
     $this->request = $this->objectManager->getObject('Request');
     // Debug Trace
     $this->debug = $this->objectManager->getObject('Debug');
     /*
      *  Autoconnect ?
      */
     if ($this->registry->databaseAutoconnect == true) {
         // Database objct
         $this->database = $this->objectManager->getObject('Database');
         $this->database->connect();
     }
     // back instance of object
     return $this;
 }
Exemplo n.º 23
0
	/**
	 * init
	 * initialize the module
	 * sets up our sockets and loads the configuration settings
	 *
	 * @access public
	 * @return void
	 */
	public function init() {
		// Set up the constants
		require_once('modules/source_rcon/defines.php');

		$this->readConfig();

		// Set up TCP sending socket
		$this->m_oSendSock = new connection($this->m_aConfig['server']['ip'], $this->m_aConfig['server']['port'], 5);

		$this->m_oSendSock->setSocketClass($this->socketClass);
		$this->m_oSendSock->setIrcClass($this->ircClass);
		$this->m_oSendSock->setTimerClass($this->timerClass);

		$this->m_oSendSock->setCallbackClass($this);

		$this->m_oSendSock->init();

		if ($this->m_oSendSock->getError()) {
			$this->destroy('Error creating TCP socket: ' . $this->m_oSendSock->getErrorMsg());
			return;
		}

		$this->m_oSendSock->connect();

		$this->m_iSendSock = $this->m_oSendSock->getSockInt();

		// setup UDP socket for recieviing server logs
		if (!$this->m_oRecvSock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)) {
			$this->destroy('Error creating UDP socket [1]');
			return;
		}
		if (!socket_bind($this->m_oRecvSock, '0.0.0.0', $this->m_aConfig['local']['port'])) {
			$this->destroy('Error creating UDP socket [2]');
			return;
		}

		if (!socket_set_nonblock($this->m_oRecvSock)) {
			$this->destroy('Error creating UDP socket [3]');
			return;
		}

		// set up udp reading process
		$this->timerClass->addTimer('parseReadLog', $this, 'parseReadLog', '', 0.1, true);

		// add the status timer, call it every 5 minutes
		$this->timerClass->addTimer('statusQuery', $this, 'statusQuery', '', 300, false);

		// add our UDP handlers
		$this->registerHandlers();

		// initiate logging to file
		$this->openLogfile();
	}
Exemplo n.º 24
0
 protected function connect($exception = true)
 {
     $host = $this->config['host'];
     $port = $this->config['port'];
     $this->memcache->addServer($host, $port);
     if ($exception) {
         $stats = $this->memcache->getExtendedStats();
         if (!isset($stats["{$host}:{$port}"]) || !$stats["{$host}:{$port}"]) {
             throw new MemcachedException('Can not connect to Memcached server');
         }
     }
     return $this->memcache->connect($host, $port);
 }
Exemplo n.º 25
0
 /**
  * Connect to the SMTP server by instantiating a Net_SMTP2 object.
  *
  * @return mixed Returns a reference to the Net_SMTP2 object on success
  *
  * @since  1.2.0
  */
 public function getSMTPObject()
 {
     if (is_object($this->_smtp) !== false) {
         return $this->_smtp;
     }
     include_once 'Net/SMTP2.php';
     $this->_smtp = new Net_SMTP2($this->host, $this->port, $this->localhost, $this->pipelining, 0, $this->socket_options);
     /* Configure the SMTP connection. */
     if ($this->debug) {
         $this->_smtp->setDebug(true);
     }
     /* Attempt to connect to the configured SMTP server. */
     $res = $this->_smtp->connect($this->timeout);
     /* Attempt to authenticate if authentication has been enabled. */
     if ($this->auth) {
         $method = is_string($this->auth) ? $this->auth : '';
         $this->_smtp->auth($this->username, $this->password, $method);
     }
     return $this->_smtp;
 }
Exemplo n.º 26
0
 /**
  * Starts all default migration checks.
  *
  * If you want to add additional migration checks
  * you will have to call all check functions above manually.
  * Please don't forget to check whether they return 'true'.
  *
  * @param   array   $dirs         Array of directories to search for
  * @param   array   $tables       Array of database tables to search for
  * @param   string  $xml          Path to the XML-File of the required extension
  * @param   string  $min_version  minimal required version, false if no check shall be performed
  * @param   string  $min_version  maximum possible version, false if no check shall be performed
  * @return  void
  * @since   1.5.0
  */
 public function check($dirs = array(), $tables = array(), $xml = false, $min_version = false, $max_version = false)
 {
     // Check for correct connection to second database if necessary
     if ($this->otherDatabase) {
         try {
             $this->_db2->connect();
         } catch (Exception $e) {
             $this->_mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&controller=migration', $e->getMessage(), 'error');
         }
     }
     $layout = new JLayoutFile('joomgallery.migration.checkstart', JPATH_COMPONENT . '/layouts');
     echo $layout->render(null);
     $ready = array();
     $ready[] = $this->checkGeneral($xml, $min_version, $max_version);
     if ($ready[0] !== true && $ready[0] !== false) {
         $this->_mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&controller=migration', $ready[0], 'notice');
     }
     $ready[] = $this->checkDirectories($dirs);
     $ready[] = $this->checkTables($tables);
     $this->endCheck(!in_array(false, $ready));
 }
Exemplo n.º 27
0
 /**
  * Connects to the given host on the given port.
  * Also looks for the timestamp in the greeting
  * needed for APOP authentication
  *
  * @param  string $host Hostname/IP address to connect to
  * @param  string $port Port to use to connect to on host
  * @return bool  Success/Failure
  */
 function connect($host = 'localhost', $port = 110)
 {
     $this->_host = $host;
     $this->_port = $port;
     $result = $this->_socket->connect($host, $port, false, $this->_timeout);
     if ($result === true) {
         $data = $this->_recvLn();
         if ($this->_checkResponse($data)) {
             // if the response begins with '+OK' ...
             //            if (@substr(strtoupper($data), 0, 3) == '+OK') {
             // Check for string matching apop timestamp
             if (preg_match('/<.+@.+>/U', $data, $matches)) {
                 $this->_timestamp = $matches[0];
             }
             $this->_maildrop = array();
             $this->_state = NET_POP3_STATE_AUTHORISATION;
             return true;
         }
     }
     $this->_socket->disconnect();
     return false;
 }
Exemplo n.º 28
0
 /**
  * Make TCP connection
  *
  * @return  mixed  Net_Socket::connect()'s return value
  * @see     Net_Socket::connect()
  */
 function connect()
 {
     $this->log('Connecting to ' . $this->host . ':' . $this->port);
     $res = $this->_socket->connect($this->host, $this->port);
     if (!PEAR::isError($res)) {
         $this->state = Net_SMPP_Client::STATE_OPEN;
         return true;
     }
     $this->_errThunk($res);
     return false;
 }
Exemplo n.º 29
0
 /**
  * 
  * Post-construction tasks to complete object construction.
  * 
  * @return void
  * 
  */
 protected function _postConstruct()
 {
     parent::_postConstruct();
     $this->memcache = new Memcache();
     // pool or single-server connection?
     if (empty($this->_config['pool'])) {
         // make sure we can connect
         $result = @$this->memcache->connect($this->_config['host'], $this->_config['port'], $this->_config['timeout']);
         if (!$result) {
             throw $this->_exception('ERR_CONNECTION_FAILED', array('host' => $this->_config['host'], 'port' => $this->_config['port'], 'timeout' => $this->_config['timeout']));
         }
     } else {
         // set up a pool
         $this->_createPool();
     }
 }
Exemplo n.º 30
0
/**
 * This is in function because we want the /install.php to parse in PHP4
 *
 * @param object $database
 * @param string $dbhsot
 * @param string $dbuser
 * @param string $dbpass
 * @param string $dbname
 * @param string $prefix
 * @param mixed $dboptions
 * @return string
 */
function install_db_validate($database, $dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions)
{
    try {
        try {
            $database->connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
        } catch (moodle_exception $e) {
            // let's try to create new database
            if ($database->create_database($dbhost, $dbuser, $dbpass, $dbname, $dboptions)) {
                $database->connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
            } else {
                throw $e;
            }
        }
        return '';
    } catch (dml_exception $ex) {
        return get_string($ex->errorcode, $ex->module, $ex->a) . '<br />' . $ex->debuginfo;
    }
}