/** * 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(); }
/** * Method to unlock the database table for writing. * * @return boolean True on success. * * @since 11.1 */ protected function _unlock() { // Unlock the table. $this->_db->setQuery('UNLOCK TABLES'); $this->_db->query(); // Check for a database error. if ($this->_db->getErrorNum()) { $this->setError($this->_db->getErrorMsg()); return false; } $this->_locked = false; return true; }
/** * Method to unlock the database table for writing. * * @return boolean True on success. * @since 1.6 */ private function _unlock() { // Unlock the table. $this->_dbo->setQuery('UNLOCK TABLES'); $this->_dbo->execute(); // Check for a database error. if ($this->_dbo->getErrorNum()) { $errorMsg = $this->_dbo->getErrorMsg(); JError::raiseWarning('', $errorMsg); return false; } $this->_locked = false; return true; }
/** * Save the current balance * * @param string $type Record type (inserting or updating) * @return boolean True on success */ public function _saveBalance($type) { if ($type == 'creation') { $query = "INSERT INTO `#__users_points` (uid, balance, earnings, credit) VALUES('" . $this->uid . "','" . $this->balance . "','" . $this->earnings . "','" . $this->credit . "')"; } else { $query = "UPDATE `#__users_points` SET balance='" . $this->balance . "', earnings='" . $this->earnings . "', credit='" . $this->credit . "' WHERE uid=" . $this->uid; } $this->_db->setQuery($query); if ($this->_db->query()) { return true; } else { $this->setError($this->_db->getErrorMsg()); return false; } return true; }
/** * Method to get the page title of any menu item that is linked to the * content item, if it exists and is set. * * @param string $url The url of the item. * * @return mixed The title on success, null if not found. * * @since 2.5 * @throws Exception on database error. */ protected function getItemMenuTitle($url) { JLog::add('FinderIndexerAdapter::getItemMenuTitle', JLog::INFO); $return = null; // Set variables $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); // Build a query to get the menu params. $sql = $this->db->getQuery(true); $sql->select($this->db->quoteName('params')); $sql->from($this->db->quoteName('#__menu')); $sql->where($this->db->quoteName('link') . ' = ' . $this->db->quote($url)); $sql->where($this->db->quoteName('published') . ' = 1'); $sql->where($this->db->quoteName('access') . ' IN (' . $groups . ')'); // Get the menu params from the database. $this->db->setQuery($sql); $params = $this->db->loadResult(); // Check for a database error. if ($this->db->getErrorNum()) { // Throw database error exception. throw new Exception($this->db->getErrorMsg(), 500); } // Check the results. if (empty($params)) { return $return; } // Instantiate the params. $params = json_decode($params); // Get the page title if it is set. if ($params->page_title) { $return = $params->page_title; } return $return; }