Exemplo n.º 1
0
 /**
  * Establish connection to server based on config.
  *
  * @param Flux_Config $dbConfig
  * @return PDO
  * @access private
  */
 private function connect(Flux_Config $dbConfig)
 {
     $dsn = 'mysql:';
     // Differentiate between a socket-type connection or an ip:port
     // connection.
     if ($sock = $dbConfig->getSocket()) {
         $dsn .= "unix_socket={$sock}";
     } else {
         $dsn .= 'host=' . $dbConfig->getHostname();
         if ($port = $dbConfig->getPort()) {
             $dsn .= ";port={$port}";
         }
     }
     // May or may not have a database name specified.
     if ($dbName = $dbConfig->getDatabase()) {
         $dsn .= ";dbname={$dbName}";
     }
     $persistent = array(PDO::ATTR_PERSISTENT => (bool) $dbConfig->getPersistent());
     return new PDO($dsn, $dbConfig->getUsername(), $dbConfig->getPassword(), $persistent);
 }
Exemplo n.º 2
0
 /**
  * Initialize char/map pair Flux_Athena pair.
  *
  * @param Flux_Connection $connection
  * @param Flux_Config $charMapConfig
  * @param Flux_LoginServer $loginServer
  * @param Flux_CharServer $charServer
  * @param Flux_MapServer $mapServer
  * @access public
  */
 public function __construct(Flux_Config $charMapConfig, Flux_LoginServer $loginServer, Flux_CharServer $charServer, Flux_MapServer $mapServer)
 {
     $this->loginServer = $loginServer;
     $this->charServer = $charServer;
     $this->mapServer = $mapServer;
     $this->loginDatabase = $loginServer->config->getDatabase();
     $this->serverName = $charMapConfig->getServerName();
     $this->maxBaseLevel = (int) $charMapConfig->getMaxBaseLevel();
     $this->expRates = $charMapConfig->getExpRates()->toArray();
     $this->dropRates = $charMapConfig->getDropRates()->toArray();
     $this->isRenewal = (bool) $charMapConfig->getRenewal();
     $this->maxCharSlots = (int) $charMapConfig->getMaxCharSlots();
     $this->dateTimezone = $charMapConfig->getDateTimezone();
     $this->charMapDatabase = $charMapConfig->getDatabase();
     $resetDenyMaps = $charMapConfig->getResetDenyMaps();
     if (!$resetDenyMaps) {
         $this->resetDenyMaps = array('sec_pri');
     } elseif (!is_array($resetDenyMaps)) {
         $this->resetDenyMaps = array($resetDenyMaps);
     } else {
         $this->resetDenyMaps = $resetDenyMaps->toArray();
     }
     // Get WoE times specific in servers config.
     $woeDayTimes = $charMapConfig->getWoeDayTimes();
     if ($woeDayTimes instanceof Flux_Config) {
         $woeDayTimes = $woeDayTimes->toArray();
         foreach ($woeDayTimes as $dayTime) {
             if (!is_array($dayTime) || count($dayTime) < 4) {
                 continue;
             }
             list($sDay, $sTime, $eDay, $eTime) = array_slice($dayTime, 0, 4);
             $sTime = trim($sTime);
             $eTime = trim($eTime);
             if ($sDay < 0 || $sDay > 6 || $eDay < 0 || $eDay > 6 || !preg_match('/^\\d{2}:\\d{2}$/', $sTime) || !preg_match('/^\\d{2}:\\d{2}$/', $eTime)) {
                 continue;
             }
             $this->woeDayTimes[] = array('startingDay' => $sDay, 'startingTime' => $sTime, 'endingDay' => $eDay, 'endingTime' => $eTime);
         }
     }
     // Config used for disallowing access to certain modules during WoE.
     $woeDisallow = $charMapConfig->getWoeDisallow();
     $_tempArray = array();
     $this->woeDisallow = new Flux_Config($_tempArray);
     if ($woeDisallow instanceof Flux_Config) {
         $woeDisallow = $woeDisallow->toArray();
         foreach ($woeDisallow as $disallow) {
             if (array_key_exists('module', $disallow)) {
                 $module = $disallow['module'];
                 if (array_key_exists('action', $disallow)) {
                     $action = $disallow['action'];
                     $this->woeDisallow->set("{$module}.{$action}", true);
                 } else {
                     $this->woeDisallow->set($module, true);
                 }
             }
         }
     }
 }