/**
  * testConnection
  *
  * @return void
  */
 public function testConnection()
 {
     $this->Couchdb = new CouchdbSource($this->config);
     $this->Couchdb =& ConnectionManager::getDataSource($this->Post->useDbConfig);
     $reconnect = $this->Couchdb->reconnect($this->config);
     $this->assertTrue($reconnect);
     $disconnect = $this->Couchdb->disconnect();
     $this->assertTrue($disconnect);
 }
Example #2
0
 /**
  * Disconnect from the dict server
  *
  * @see     Net_Socket::disconnect()
  * @return  mixed  Net_Socket::disconnect()'s return value
  * @author  Ian Eure <*****@*****.**>
  */
 function disconnect()
 {
     if (isset($this->_socket)) {
         return $this->_socket->disconnect();
     }
     return new PEAR_Error('not connected');
 }
Example #3
0
 /**
  * properly disconnect from resources
  *
  * @access  public
  */
 function disconnect()
 {
     if ($this->disconnect) {
         $this->dbc->disconnect();
         $this->dbc = null;
     }
 }
Example #4
0
 /**
  * PEAR-Deconstructor
  * Call deconstructor of parent,
  * close database connection if open
  */
 function _Cache_DB()
 {
     $this->_Cache();
     if (is_object($this->db)) {
         $this->db->disconnect();
     }
 }
Example #5
0
 /**
  * Sends the QUIT command
  *
  * @return bool Success/Failure
  */
 function _cmdQuit()
 {
     $data = $this->_sendCmd('QUIT');
     $this->_state = NET_POP3_STATE_DISCONNECTED;
     $this->_socket->disconnect();
     return (bool) $data;
 }
Example #6
0
	/**
	 * destroy
	 * destroy the module
	 *
	 * @access public
	 * @param string $p_sErrorMsg
	 * @return void
	 */
	public function destroy($p_sErrorMsg = '') {
		if (!empty($p_sErrorMsg)) {
			$this->ircClass->privMsg($this->m_aConfig['setup']['channel'], $p_sErrorMsg);
		}

		$this->closeLogfile();

		if (!empty($this->m_aConfig['local']['ip']) && $this->m_bAuthenticated == true) {
			$this->rawPacketSend('logaddress_del '.$this->m_aConfig['local']['ip'].':'.$this->m_aConfig['local']['port']);
		}

		if ($this->timerExists('processResponse')) {
			$this->timerClass->removeTimer('processResponse');
		}
		if ($this->timerExists('doSendQueue')) {
			$this->timerClass->removeTimer('doSendQueue');
		}
		if ($this->timerExists('doReconnect')) {
			$this->timerClass->removeTimer('doReconnect');
		}
		$this->timerClass->removeTimer('parseReadLog');
		$this->timerClass->removeTimer('statusQuery');

		@socket_close($this->m_oRecvSock);
		if (!is_null($this->m_oSendSock)) {
			$this->m_oSendSock->disconnect();
		}

		$this->resetClassVars();
	}
Example #7
0
 /**
  * Closes the connection to the database if it is still open and we were
  * the ones that opened it.  It is the caller's responsible to close an
  * existing connection that was passed to us via $conf['db'].
  *
  * @return boolean   True on success, false on failure.
  * @access public     
  */
 function close()
 {
     if ($this->_opened && !$this->_existingConnection) {
         $this->_opened = false;
         return $this->_db->disconnect();
     }
     return $this->_opened === false;
 }
Example #8
0
 /**
  * Disconnects from the SQL server and cleans up the connection.
  */
 protected function _disconnect()
 {
     if ($this->_connected) {
         $this->_connected = false;
         $this->_db->disconnect();
         $this->_write_db->disconnect();
     }
 }
 /**
  * Test connection.
  *
  * @return void
  */
 public function testConnection()
 {
     $this->CouchDB = new CouchDBSource($this->_config);
     $this->CouchDB = ConnectionManager::getDataSource($this->Post->useDbConfig);
     $reconnect = $this->CouchDB->reconnect($this->_config);
     $this->assertSame($reconnect, true, __d('test_cases', 'Not reconnected'));
     $disconnect = $this->CouchDB->disconnect();
     $this->assertSame($disconnect, true, __d('test_cases', 'Not disconnect'));
 }
Example #10
0
 /**
  * Disconnect and destroy the current SMTP connection.
  *
  * @return boolean True if the SMTP connection no longer exists.
  *
  * @since  1.1.9
  * @access public
  */
 function disconnect()
 {
     /* If we have an SMTP object, disconnect and destroy it. */
     if (is_object($this->_smtp) && $this->_smtp->disconnect()) {
         $this->_smtp = null;
     }
     /* We are disconnected if we no longer have an SMTP object. */
     return $this->_smtp === null;
 }
Example #11
0
 /**
  * Closes the connection to the database if it is still open and we were
  * the ones that opened it.  It is the caller's responsible to close an
  * existing connection that was passed to us via $conf['db'].
  *
  * @return boolean   True on success, false on failure.
  * @access public
  */
 function close()
 {
     if ($this->_opened && !$this->_existingConnection) {
         $this->_opened = false;
         $this->_db->freePrepared($this->_statement);
         return $this->_db->disconnect();
     }
     return $this->_opened === false;
 }
Example #12
0
 /**
  * Destructor.
  */
 public function __destruct()
 {
     if ($this->dbh_ro) {
         $this->dbh_ro->disconnect();
     }
     if ($this->dbh_rw) {
         $this->dbh_rw->disconnect();
     }
     parent::__destruct();
 }
Example #13
0
 /**
  * Closes the connection to an SSH server
  *
  * @access private
  */
 function _close()
 {
     switch ($this->mode) {
         case self::MODE_SSH2:
             $this->ssh->_close_channel(SSH2::CHANNEL_EXEC, true);
             break;
         case self::MODE_SSH1:
             $this->ssh->disconnect();
     }
 }
Example #14
0
 /**
  * properly disconnect from resources
  *
  * @return bool true on success and false on failure
  *
  * @access public
  */
 function disconnect()
 {
     if ($this->dsn) {
         $result = $this->dbc->disconnect();
         if (PEAR::isError($result)) {
             $this->stack->push(LIVEUSER_ERROR, 'exception', array('reason' => $result->getMessage() . '-' . $result->getUserInfo()));
             return false;
         }
         $this->dbc = false;
     }
     return true;
 }
Example #15
0
 /**
  * Installs table(s)/data schema into database
  *
  * @access  public
  * @param   string  $new_schema     New schema file path/name
  * @param   array   $variables      Schema variables
  * @param   string  $old_schema     Old schema file path/name
  * @param   string  $init_data      Schema is include initialization data
  * @param   string  $create         If the database should be created
  * @return  mixed   True on success and Jaws_Error on failure
  */
 function installSchema($new_schema, $variables = array(), $old_schema = false, $init_data = false, $create = true)
 {
     MDB2::loadFile('Schema');
     $dsn = $this->_dsn;
     unset($dsn['database']);
     // If the database should be created
     $variables['create'] = (int) $create;
     // The database name
     $variables['database'] = $this->_dsn['database'];
     // Prefix of all the tables added
     $variables['table_prefix'] = $this->getPrefix();
     // set default charset
     if (!isset($variables['charset'])) {
         $variables['charset'] = $this->getUnicodeCharset();
     }
     $options = array('debug' => false, 'log_line_break' => '<br />', 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL ^ MDB2_PORTABILITY_FIX_CASE ^ MDB2_PORTABILITY_RTRIM, 'quote_identifier' => true, 'force_defaults' => false);
     switch ($this->_dsn['phptype']) {
         case 'ibase':
             $options['portability'] = $options['portability'] | MDB2_PORTABILITY_FIX_CASE;
             $options['database_path'] = empty($this->_db_path) ? JAWS_DATA : $this->_db_path;
             break;
         case 'oci8':
             $options['emulate_database'] = false;
             $options['portability'] = $options['portability'] | MDB2_PORTABILITY_FIX_CASE;
             break;
         case 'sqlite':
             $options['database_path'] = empty($this->_db_path) ? JAWS_DATA : $this->_db_path;
             break;
         case 'mssql':
             $options['multibyte_text_field_type'] = $this->Is_FreeTDS_MSSQL_Driver();
             break;
     }
     if ($this->_is_dba) {
         $options['DBA_username'] = $this->_dsn['username'];
         $options['DBA_password'] = $this->_dsn['password'];
     }
     if (!isset($this->schema)) {
         $this->schema =& MDB2_Schema::factory($this->dbc, $options);
         if (MDB2::isError($this->schema)) {
             return $this->schema;
         }
     }
     $method = $init_data === true ? 'writeInitialization' : 'updateDatabase';
     $result = $this->schema->{$method}($new_schema, $old_schema, $variables);
     if (MDB2::isError($result)) {
         $this->schema->disconnect();
         unset($this->schema);
         $GLOBALS['log']->Log(JAWS_ERROR_ERROR, $result->getUserInfo(), 2);
         return new Jaws_Error($result->getMessage(), $result->getCode(), JAWS_ERROR_ERROR, 1);
     }
     return $result;
 }
Example #16
0
 /**
  * Closes the connection to the database if it is still open and we were
  * the ones that opened it.  It is the caller's responsible to close an
  * existing connection that was passed to us via $conf['db'].
  *
  * @return boolean   True on success, false on failure.
  * @access public
  */
 function close()
 {
     /* If we have a statement object, free it. */
     if (is_object($this->_statement)) {
         $this->_statement->free();
         $this->_statement = null;
     }
     /* If we opened the database connection, disconnect it. */
     if ($this->_opened && !$this->_existingConnection) {
         $this->_opened = false;
         return $this->_db->disconnect();
     }
     return $this->_opened === false;
 }
Example #17
0
 /**
  * Sends the LOGOUT command and terminates the connection
  *
  * @access private
  * @param boolean $sendLogoutCMD True to send LOGOUT command before disconnecting
  * @return mixed True on success, PEAR_Error otherwise
  */
 function _cmdLogout($sendLogoutCMD = true)
 {
     if (NET_SIEVE_STATE_DISCONNECTED === $this->_state) {
         $msg = 'Not currently connected';
         $code = 1;
         return $this->_raiseError($msg, $code);
         //return PEAR::raiseError('Not currently connected');
     }
     if ($sendLogoutCMD) {
         if (PEAR::isError($res = $this->_doCmd('LOGOUT'))) {
             return $res;
         }
     }
     $this->_sock->disconnect();
     $this->_state = NET_SIEVE_STATE_DISCONNECTED;
     return true;
 }
Example #18
0
 /**
  * Implements Mail::send() function using SMTP direct delivery
  *
  * @access public
  * @param mixed $recipients in RFC822 style or array
  * @param array $headers The array of headers to send with the mail.
  * @param string $body The full text of the message body,
  * @return mixed Returns true on success, or a PEAR_Error
  */
 function send($recipients, $headers, $body)
 {
     if (!is_array($headers)) {
         return PEAR::raiseError('$headers must be an array');
     }
     $result = $this->_sanitizeHeaders($headers);
     if (is_a($result, 'PEAR_Error')) {
         return $result;
     }
     // Prepare headers
     $headerElements = $this->prepareHeaders($headers);
     if (is_a($headerElements, 'PEAR_Error')) {
         return $headerElements;
     }
     list($from, $textHeaders) = $headerElements;
     // use 'Return-Path' if possible
     if (!empty($headers['Return-Path'])) {
         $from = $headers['Return-Path'];
     }
     if (!isset($from)) {
         return $this->_raiseError('no_from');
     }
     // Prepare recipients
     $recipients = $this->parseRecipients($recipients);
     if (is_a($recipients, 'PEAR_Error')) {
         return $recipients;
     }
     foreach ($recipients as $rcpt) {
         list($user, $host) = explode('@', $rcpt);
         $mx = $this->_getMx($host);
         if (is_a($mx, 'PEAR_Error')) {
             return $mx;
         }
         if (empty($mx)) {
             $info = array('rcpt' => $rcpt);
             return $this->_raiseError('no_mx', $info);
         }
         $connected = false;
         foreach ($mx as $mserver => $mpriority) {
             $this->_smtp = new Net_SMTP($mserver, $this->port, $this->mailname);
             // 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);
             if (is_a($res, 'PEAR_Error')) {
                 $this->_smtp = null;
                 continue;
             }
             // connection established
             if ($res) {
                 $connected = true;
                 break;
             }
         }
         if (!$connected) {
             $info = array('host' => implode(', ', array_keys($mx)), 'port' => $this->port, 'rcpt' => $rcpt);
             return $this->_raiseError('not_connected', $info);
         }
         // Verify recipient
         if ($this->vrfy) {
             $res = $this->_smtp->vrfy($rcpt);
             if (is_a($res, 'PEAR_Error')) {
                 $info = array('rcpt' => $rcpt);
                 return $this->_raiseError('failed_vrfy_rcpt', $info);
             }
         }
         // mail from:
         $args['verp'] = $this->verp;
         $res = $this->_smtp->mailFrom($from, $args);
         if (is_a($res, 'PEAR_Error')) {
             $info = array('from' => $from);
             return $this->_raiseError('failed_set_from', $info);
         }
         // rcpt to:
         $res = $this->_smtp->rcptTo($rcpt);
         if (is_a($res, 'PEAR_Error')) {
             $info = array('rcpt' => $rcpt);
             return $this->_raiseError('failed_set_rcpt', $info);
         }
         // Don't send anything in test mode
         if ($this->test) {
             $result = $this->_smtp->rset();
             $res = $this->_smtp->rset();
             if (is_a($res, 'PEAR_Error')) {
                 return $this->_raiseError('failed_rset');
             }
             $this->_smtp->disconnect();
             $this->_smtp = null;
             return true;
         }
         // Send data
         $res = $this->_smtp->data("{$textHeaders}\r\n{$body}");
         if (is_a($res, 'PEAR_Error')) {
             $info = array('rcpt' => $rcpt);
             return $this->_raiseError('failed_send_data', $info);
         }
         $this->_smtp->disconnect();
         $this->_smtp = null;
     }
     return true;
 }
Example #19
0
 /**
  * stop
  *
  * @access public
  * @return mixed True on success, PEAR_Error on failure
  */
 public static function stop()
 {
     self::$controller->stop();
     self::$site->stop();
     if (DB::isConnection(self::$db)) {
         self::$db->disconnect();
     }
     if (self::$log instanceof Log) {
         self::$log->close();
     }
     return true;
 }
Example #20
0
 /**
  * Closes the connection to an SSH server
  *
  * @access private
  */
 function _close()
 {
     switch ($this->mode) {
         case NET_SCP_SSH2:
             $this->ssh->_close_channel(NET_SSH2_CHANNEL_EXEC, true);
             break;
         case NET_SCP_SSH1:
             $this->ssh->disconnect();
     }
 }
Example #21
0
 /**
  * Reconnects the socket.
  *
  * It will attempt to close before reconnecting.
  *
  * @return  void
  */
 public function reconnect()
 {
     $this->_connection->disconnect();
     $this->_connection = null;
     $this->_connect();
 }
Example #22
0
 /**
  * Send mails fom queue.
  *
  * Mail_Queue::sendMailsInQueue()
  *
  * @param integer $limit     Optional - max limit mails send.
  *                           This is the max number of emails send by
  *                           this function.
  * @param integer $offset    Optional - you could load mails from $offset (by id)
  * @param integer $try       Optional - hoh many times mailqueu should try send
  *                           each mail. If mail was sent succesful it will be delete
  *                           from Mail_Queue.
  * @return mixed  True on success else MAILQUEUE_ERROR object.
  **/
 function sendMailsInQueue($limit = MAILQUEUE_ALL, $offset = MAILQUEUE_START, $try = MAILQUEUE_TRY)
 {
     $this->container->setOption($limit, $offset, $try);
     while ($mail = $this->get()) {
         $this->container->countSend($mail);
         $result = $this->sendMail($mail);
         if (!PEAR::isError($result)) {
             $this->container->setAsSent($mail);
             if ($mail->isDeleteAfterSend()) {
                 $this->deleteMail($mail->getId());
             }
         } else {
             //remove the problematic mail from the buffer, but don't delete
             //it from the db: it might be a temporary issue.
             $this->container->skip();
             PEAR::raiseError('Error in sending mail: ' . $result->getMessage(), MAILQUEUE_ERROR_CANNOT_SEND_MAIL, PEAR_ERROR_TRIGGER, E_USER_NOTICE);
         }
     }
     if ($this->mail_options['persist'] && is_object($this->send_mail)) {
         $this->send_mail->disconnect();
     }
     return true;
 }
Example #23
0
 /**
  * properly disconnect from resources
  *
  * @access  public
  */
 function disconnect()
 {
     $this->_storage->disconnect();
 }
Example #24
0
 /**
  * properly disconnect resources in the active container
  *
  * @access  public
  * @return  void
  */
 function disconnect()
 {
     if ($this->_error) {
         return $this->_error;
     }
     if (is_object($this->_auth) && $this->_auth->loggedIn) {
         $this->_auth->disconnect();
         $this->_auth = null;
         if (is_object($this->_perm)) {
             $this->_perm->disconnect();
             $this->_perm = null;
         }
         return true;
     }
     $this->_error = LiveUser::raiseError(LIVEUSER_ERROR, null, null, "No connection to disconnect in LiveUser::disconnect()");
     return $this->_error;
 }
Example #25
0
File: Queue.php Project: roojs/pear
 /**
  * Send mails fom queue.
  *
  * Mail_Queue::sendMailsInQueue()
  *
  * @param integer $limit     Optional - max limit mails send.
  *                           This is the max number of emails send by
  *                           this function.
  * @param integer $offset    Optional - you could load mails from $offset (by id)
  * @param integer $try       Optional - hoh many times mailqueu should try send
  *                           each mail. If mail was sent succesful it will be
  *                           deleted from Mail_Queue.
  * @param mixed   $callback  Optional, a callback (string or array) to save the
  *                           SMTP ID and the SMTP greeting.
  *
  * @return mixed  True on success else MAILQUEUE_ERROR object.
  */
 function sendMailsInQueue($limit = MAILQUEUE_ALL, $offset = MAILQUEUE_START, $try = MAILQUEUE_TRY, $callback = null)
 {
     if (!is_int($limit) || !is_int($offset) || !is_int($try)) {
         return Mail_Queue::raiseError("sendMailsInQueue(): limit, offset and try must be integer.", MAILQUEUE_ERROR_UNEXPECTED);
     }
     if ($callback !== null) {
         if (!is_array($callback) && !is_string($callback)) {
             return Mail_Queue::raiseError("sendMailsInQueue(): callback must be a string or an array.", MAILQUEUE_ERROR_UNEXPECTED);
         }
     }
     $this->container->setOption($limit, $offset, $try);
     while (($mail = $this->get()) && !PEAR::isError($mail)) {
         $this->container->countSend($mail);
         $result = $this->sendMail($mail, true);
         if (PEAR::isError($result)) {
             //remove the problematic mail from the buffer, but don't delete
             //it from the db: it might be a temporary issue.
             $this->container->skip();
             PEAR::raiseError('Error in sending mail: ' . $result->getMessage(), MAILQUEUE_ERROR_CANNOT_SEND_MAIL, PEAR_ERROR_TRIGGER, E_USER_NOTICE);
             continue;
         }
         //take care of callback first, as it may need to retrieve extra data
         //from the mail_queue table.
         if ($callback !== null) {
             $queued_as = null;
             $greeting = null;
             if (isset($this->queued_as)) {
                 $queued_as = $this->queued_as;
             }
             if (isset($this->greeting)) {
                 $greeting = $this->greeting;
             }
             call_user_func($callback, array('id' => $mail->getId(), 'queued_as' => $queued_as, 'greeting' => $greeting));
         }
         // delete email from queue?
         if ($mail->isDeleteAfterSend()) {
             $status = $this->deleteMail($mail->getId());
         }
         unset($mail);
         if (isset($this->mail_options['delay']) && $this->mail_options['delay'] > 0) {
             sleep($this->mail_options['delay']);
         }
     }
     // most likely from breaking the loop
     if (isset($mail) && PEAR::isError($mail)) {
         return $mail;
     }
     if (!empty($this->mail_options['persist']) && is_object($this->send_mail)) {
         $this->send_mail->disconnect();
     }
     return true;
 }
Example #26
0
 /**
  * Properly disconnect resources in the active container.
  *
  * @return  bool true on success or false on failure
  *
  * @access public
  */
 function disconnect()
 {
     if (is_a($this->_auth, 'LiveUser_Auth_Common')) {
         $result = $this->_auth->disconnect();
         if ($result === false) {
             return false;
         }
         $this->_auth = null;
     }
     if (is_a($this->_perm, 'LiveUser_Perm_Simple')) {
         $result = $this->_perm->disconnect();
         if ($result === false) {
             return false;
         }
         $this->_perm = null;
     }
     return true;
 }
Example #27
0
 /**
  * stores the received answer into the result array
  *
  * @param object $irc
  * @param object $ircdata
  * @return void
  */
 function handler(&$irc, &$ircdata)
 {
     $irc->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: listenfor handler called', __FILE__, __LINE__);
     $this->result[] = $ircdata;
     $irc->disconnect();
 }
Example #28
0
 /**
  * properly disconnect resources in the active container
  *
  * @access  public
  * @return  void
  */
 function disconnect()
 {
     if ($this->_error) {
         return false;
     }
     if (is_object($this->_auth) && $this->_auth->loggedIn) {
         $this->_auth->disconnect();
         $this->_auth = null;
         if (is_object($this->_perm)) {
             $this->_perm->disconnect();
             $this->_perm = null;
         }
     }
 }
 /**
  * Disconnect TCP connection
  *
  * @return  mixed  Net_Socket::disconnect()'s return value
  * @see     Net_Socket::disconnect()
  */
 function disconnect()
 {
     $this->log('Disconnecting');
     $res = $this->_socket->disconnect();
     if (!PEAR::isError($res)) {
         $this->state = Net_SMPP_Client::STATE_CLOSED;
         return true;
     }
     $this->_errThunk($res);
     return false;
 }
Example #30
0
 public function DbDisconnect()
 {
     $this->DBHandle->disconnect();
 }