/includes/class.pos.php
PHP | 2519 lines | 1633 code | 462 blank | 424 comment | 218 complexity | 0baf8c46ce2ff040f2348a7ab41b43e1 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-3.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- * Pos-Tracker2
- *
- * Starbase Tracking Page, multiple Tower view
- *
- * PHP version 5
- *
- * LICENSE: This file is part of POS-Tracker2.
- * POS-Tracker2 is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3 of the License.
- *
- * POS-Tracker2 is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with POS-Tracker2. If not, see <http://www.gnu.org/licenses/>.
- *
- * @author Stephen Gulickk <stephenmg12@gmail.com>
- * @author DeTox MinRohim <eve@onewayweb.com>
- * @author Andy Snowden <forumadmin@eve-razor.com>
- * @copyright 2007-2008 (C) Stephen Gulick, DeTox MinRohim, and Andy Snowden
- * @copyright 2008-2009 (C) Stephen Gulick and DeTox MinRohim
- * @license http://www.gnu.org/licenses/gpl-3.0.html GPL 3.0
- * @access public
- * @package POS-Tracker2
- * @version SVN: $Id: class.pos.php 309 2010-03-08 02:55:24Z stephenmg12@gmail.com $
- * @link https://sourceforge.net/projects/pos-tracker2/
- * @link http://www.eve-online.com/
- */
-
- define('INT_SECOND', 1);
- define('INT_MINUTE', 60);
- define('INT_HOUR', 3600);
- define('INT_6HOUR', 21600);
- define('INT_DAY', 86400);
- define('INT_WEEK', 604800);
-
- include 'includes/pos_val.php';
- require_once('includes/TEAC.php');
-
- class POSMGMT extends TEAC
- {
-
- /**
- * POSMGMT::get_formatted_timediff()
- *
- * @param mixed $then
- * @param bool $now
- * @return return $str
- */
- function get_formatted_timediff($then, $now = false)
- {
- $now = (!$now) ? time() : $now;
- $timediff = ($now - $then);
- $weeks = (int) intval($timediff / INT_WEEK);
- $timediff = (int) intval($timediff - (INT_WEEK * $weeks));
- $days = (int) intval($timediff / INT_DAY);
- $timediff = (int) intval($timediff - (INT_DAY * $days));
- $hours = (int) intval($timediff / INT_HOUR);
- $timediff = (int) intval($timediff - (INT_HOUR * $hours));
- $mins = (int) intval($timediff / INT_MINUTE);
- $timediff = (int) intval($timediff - (INT_MINUTE * $mins));
- $sec = (int) intval($timediff / INT_SECOND);
- $timediff = (int) intval($timediff - ($sec * INT_SECOND));
-
- $str = '';
- if ( $weeks ) {
- $str .= intval($weeks);
- $str .= ($weeks > 1) ? ' weeks' : ' week';
- }
- if ( $days ) {
- $str .= ($str) ? ', ' : '';
- $str .= intval($days);
- $str .= ($days > 1) ? ' days' : ' day';
- }
- if ( $hours ) {
- $str .= ($str) ? ', ' : '';
- $str .= intval($hours);
- $str .= ($hours > 1) ? ' hours' : ' hour';
- }
- if ( $mins ) {
- $str .= ($str) ? ', ' : '';
- $str .= intval($mins);
- $str .= ($mins > 1) ? ' minutes' : ' minute';
- }
- if ( $sec ) {
- $str .= ($str) ? ', ' : '';
- $str .= intval($sec);
- $str .= ($sec > 1) ? ' seconds' : ' second';
- }
- if ( !$weeks && !$days && !$hours && !$mins && !$sec ) {
- $str .= '0 seconds ago';
- } else {
- $str .= ' ago';
- }
-
- return $str;
- }
-
- /**
- * POSMGMT::GetLastSystemUpdate()
- *
- * @return $row['updateTime']
- */
- function GetLastSystemUpdate()
- {
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."system_status
- WHERE SolarSystemID = '30023410'";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row['updateTime'];
-
- }
-
- /**
- * POSMGMT::GetLastAllianceUpdate()
- *
- * @return $row['updateTime']
- */
- function GetLastAllianceUpdate()
- {
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."alliance_info
- WHERE AllianceID = '0'";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row['updateTime'];
-
- }
-
- /**
- * POSMGMT::GetAllianceByName()
- *
- * @param mixed $allname
- * @return
- */
- function GetAllianceByName($allname)
- {
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."alliance_info
- WHERE name = '".Eve::VarPrepForStore($allname)."'";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row;
-
- }
-
- /**
- * POSMGMT::GetLastAPITimer()
- *
- * @return
- */
- function GetLastAPITimer()
- {
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."eveapi
- ORDER BY apitimer DESC LIMIT 1";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row['apitimer'];
- }
-
- function GetLastHangerAPITimer()
- {
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."update_log
- WHERE type = '5'
- ORDER BY datetime DESC LIMIT 1";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row['datetime'];
- }
- /**
- * POSMGMT::GetLastPosUpdate()
- *
- * @param mixed $pos_id
- * @return
- */
- function GetLastPosUpdate($pos_id)
- {
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."update_log
- WHERE type_id = '" . $pos_id . "'
- AND type = '1'
- ORDER BY id DESC LIMIT 1";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row;
-
- }
-
- /**
- * POSMGMT::GetAllUsers()
- *
- * @return
- */
- function GetAllUsers()
- {
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."user
- ORDER BY name";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- if ($result->EOF) {
- return false;
- }
-
- for(; !$result->EOF; $result->MoveNext()) {
- $users[] = $result->GetRowAssoc(2);
- }
-
- $result->Close();
-
- return $users;
-
- }
-
- /**
- * POSMGMT::GetAllUsersArray()
- *
- * @return
- */
- function GetAllUsersArray()
- {
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT name, eve_id
- FROM ".TBL_PREFIX."user
- ORDER BY name";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- if ($result->EOF) {
- return false;
- }
-
- for(; !$result->EOF; $result->MoveNext()) {
- $users[] = $result->GetRowAssoc(2);
- }
-
- foreach($users as $user) {
- $user_array[$user['eve_id']]=$user['name'];
- }
-
- $result->Close();
-
- return $user_array;
-
- }
- /**
- * POSMGMT::GetAllUsersWithAccess()
- *
- * @param mixed $access
- * @return
- */
- function GetAllUsersWithAccess($access)
- {
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."user
- WHERE access = '".Eve::VarPrepForStore($access)."'";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- if ($result->EOF) {
- return false;
- }
-
- for(; !$result->EOF; $result->MoveNext()) {
- $users[] = $result->GetRowAssoc(2);
- }
-
- $result->Close();
-
- return $users;
-
- }
-
- /**
- * POSMGMT::GetUserInfofromID()
- *
- * @param mixed $characterID
- * @return
- */
- function GetUserInfofromID($characterID)
- {
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."user
- WHERE eve_id = '".Eve::VarPrepForStore($characterID)."'";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row;
-
- }
-
- /**
- * POSMGMT::LogUser()
- *
- * @param mixed $args
- * @return
- */
- function LogUser($args)
- {
-
- if (!isset($args['name']) or empty($args['name'])) {
- return false;
- }
- if (!isset($args['pass']) or empty($args['pass'])) {
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."user
- WHERE name = '" . Eve::VarPrepForStore($args['name']) . "'";
- //AND pass = (PASSWORD('" . Eve::VarPrepForStore($args['pass']) . "'))";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- if ($result->EOF) {
- return false;
- }
-
- $userinfo = $result->GetRowAssoc(2);
- //echo '<pre>';print_r($userinfo);echo '</pre>';exit;
- $result->Close();
-
- $compare = false;
- $password = $args['pass'];
- $hash = $userinfo['pass'];
-
- $compare = $this->comparePassword($password, $hash); //New Password Hashing method
-
- if ($compare)
- {
- Eve::SessionSetVar('name', $userinfo['name']);
- Eve::SessionSetVar('eve_id', $userinfo['eve_id']);
- Eve::SessionSetVar('access', $userinfo['access']);
- Eve::SessionSetVar('corp', $userinfo['corp']);
- Eve::SessionSetVar('id', $userinfo['id']);
- Eve::SessionSetVar('email', $userinfo['email']);
- Eve::SessionSetVar('away', $userinfo['away']);
- Eve::SessionSetVar('highly_trusted', $userinfo['highly_trusted']);
- Eve::SessionSetVar('delsid', $userinfo['delsid']);
- Eve::SessionSetVar('allianceID', $userinfo['alliance_id']);
- Eve::SessionSetVar('userlogged', true);
- if ($args['cookie'])
- {
- $cookie = hash('md5', $hash.time().mt_rand());
- Eve::SessionSetVar('cookie', $cookie);
- $result = $dbconn->Execute("UPDATE ".TBL_PREFIX."user SET cookie = '".$cookie."' WHERE name = '".Eve::VarPrepForStore($args['name'])."'");
- setcookie('postrackerLoginN', $userinfo['name'], time() + 31104000, NULL, $_SERVER['SERVER_NAME'], false, true);
- setcookie('postrackerLoginP', $cookie, time() + 31104000, NULL, $_SERVER['SERVER_NAME'], false, true);
- }
- return $userinfo;
- }
- else
- {
- return false;
- }
- }
-
- function CookieLogUser($args)
- {
- if (empty($args['name']))
- return false;
- if (empty($args['pass']))
- return false;
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."user
- WHERE name = '" . Eve::VarPrepForStore($args['name']) . "'";
- //AND pass = (PASSWORD('" . Eve::VarPrepForStore($args['pass']) . "'))";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0)
- {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- if ($result->EOF)
- return false;
-
- $userinfo = $result->GetRowAssoc(2);
- //echo '<pre>';print_r($userinfo);echo '</pre>';exit;
- $result->Close();
-
- $password = $args['pass'];
-
- if ($password = $userinfo['cookie'])
- {
- Eve::SessionSetVar('name', $userinfo['name']);
- Eve::SessionSetVar('eve_id', $userinfo['eve_id']);
- Eve::SessionSetVar('access', $userinfo['access']);
- Eve::SessionSetVar('corp', $userinfo['corp']);
- Eve::SessionSetVar('id', $userinfo['id']);
- Eve::SessionSetVar('email', $userinfo['email']);
- Eve::SessionSetVar('away', $userinfo['away']);
- Eve::SessionSetVar('highly_trusted', $userinfo['highly_trusted']);
- Eve::SessionSetVar('delsid', $userinfo['delsid']);
- Eve::SessionSetVar('allianceID', $userinfo['alliance_id']);
- Eve::SessionSetVar('userlogged', true);
- return $userinfo;
- }
- else
- {
- return false;
- }
- }
-
- /**
- * POSMGMT::getPasswordSalt()
- *
- * @return
- */
- function getPasswordSalt()
- {
- return substr( str_pad( dechex( mt_rand() ), 8, '0', STR_PAD_LEFT ), -8 );
- }
-
- // calculate the hash from a salt and a password
- /**
- * POSMGMT::getPasswordHash()
- *
- * @param mixed $salt
- * @param mixed $password
- * @return
- */
- function getPasswordHash($salt, $password )
- {
- //hash requires php version 5.1.2 to work. It also must be enabled, check with your hosting provider on how to enable/install extentions
- return (hash('md5', $salt.$password ) );
- //return (md5($salt.$password)); //If you have dificulty with hash, you can uncomment this line and comment the line above
- }
-
- // compare a password to a hash
- /**
- * POSMGMT::comparePassword()
- *
- * @param mixed $password
- * @param mixed $dbhash
- * @return
- */
- function comparePassword($password, $dbhash)
- {
- $password = Eve::VarCleanFromInput('pass');//$_POST['pass'];
- $salt = substr($dbhash, 0, 8);
- $hash = $this->getPasswordHash($salt, $password);
- $shash = $salt.$hash;
- if($shash == $dbhash) {
- return true;
- } else {
- return false;
- }
-
- }
-
- /**
- * POSMGMT::newpasswordhash()
- *
- * @param mixed $password
- * @return
- */
- function newpasswordhash($password)
- {
- $salt = $this->getPasswordSalt();
- $hash = $this->getPasswordHash($salt, $password);
- $dbhash = $salt.$hash;
- return $dbhash;
- }
-
- /**
- * POSMGMT::GetUserInfo()
- *
- * @return
- */
- function GetUserInfo()
- {
-
- $userlogged = Eve::SessionGetVar('userlogged');
-
- if (!$userlogged) {
- return false;
- } else {
- $userinfo = array('name' => Eve::SessionGetVar('name'),
- 'access' => Eve::SessionGetVar('access'),
- 'corp' => Eve::SessionGetVar('corp'),
- 'id' => Eve::SessionGetVar('id'),
- 'eve_id' => Eve::SessionGetVar('eve_id'),
- 'email' => Eve::SessionGetVar('email'),
- 'away' => Eve::SessionGetVar('away'),
- 'highly_trusted' => Eve::SessionGetVar('highly_trusted'),
- 'delsid' => Eve::SessionGetVar('delsid'),
- 'allianceID' => Eve::SessionGetVar('allianceID'));
-
- }
- return $userinfo;
- }
-
- function VerifySessionInfo()
- {
- $userlogged = Eve::SessionGetVar('userlogged');
-
- if (!$userlogged)
- return false;
-
- $session = array('name' => Eve::SessionGetVar('name'),
- 'access' => Eve::SessionGetVar('access'),
- 'corp' => Eve::SessionGetVar('corp'),
- 'id' => Eve::SessionGetVar('id'),
- 'eve_id' => Eve::SessionGetVar('eve_id'),
- 'email' => Eve::SessionGetVar('email'),
- 'away' => Eve::SessionGetVar('away'),
- 'highly_trusted' => Eve::SessionGetVar('highly_trusted'),
- 'delsid' => Eve::SessionGetVar('delsid'),
- 'allianceID' => Eve::SessionGetVar('allianceID'));
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."user
- WHERE name = '" . Eve::VarPrepForStore($session['name']) . "'";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- $error = TRUE;
- }
-
- if ($result->EOF) {
- $error = TRUE;
- }
-
- $userinfo = $result->GetRowAssoc(2);
- //echo '<pre>';print_r($userinfo);echo '</pre>';exit;
- $result->Close();
-
- if($error)
- {
- Eve::SessionDelVar('name');
- Eve::SessionDelVar('access');
- Eve::SessionDelVar('corp');
- Eve::SessionDelVar('id');
- Eve::SessionDelVar('eve_id');
- Eve::SessionDelVar('email');
- Eve::SessionDelVar('away');
- Eve::SessionDelVar('highly_trusted');
- Eve::SessionDelVar('delsid');
- Eve::SessionDelVar('allianceID');
- Eve::SessionDelVar('userlogged');
- }
- else
- {
- Eve::SessionSetVar('name', $userinfo['name']);
- Eve::SessionSetVar('eve_id', $userinfo['eve_id']);
- Eve::SessionSetVar('access', $userinfo['access']);
- Eve::SessionSetVar('corp', $userinfo['corp']);
- Eve::SessionSetVar('id', $userinfo['id']);
- Eve::SessionSetVar('email', $userinfo['email']);
- Eve::SessionSetVar('away', $userinfo['away']);
- Eve::SessionSetVar('highly_trusted', $userinfo['highly_trusted']);
- Eve::SessionSetVar('delsid', $userinfo['delsid']);
- Eve::SessionSetVar('allianceID', $userinfo['alliance_id']);
- Eve::SessionSetVar('userlogged', true);
- }
- }
-
- /**
- * POSMGMT::LogOutUser()
- *
- * @return
- */
- function LogOutUser()
- {
-
- $userlogged = Eve::SessionGetVar('userlogged');
-
- if (!$userlogged) {
- return true;
- } else {
- Eve::SessionDelVar('name');
- Eve::SessionDelVar('access');
- Eve::SessionDelVar('corp');
- Eve::SessionDelVar('id');
- Eve::SessionDelVar('eve_id');
- Eve::SessionDelVar('email');
- Eve::SessionDelVar('away');
- Eve::SessionDelVar('highly_trusted');
- Eve::SessionDelVar('delsid');
- Eve::SessionDelVar('allianceID');
- Eve::SessionDelVar('userlogged');
- }
- return true;
-
- }
-
- /**
- * POSMGMT::UpdateUserAway()
- *
- * @param mixed $args
- * @return
- */
- function UpdateUserAway($args)
- {
- if (!isset($args['id'])) {
- Eve::SessionSetVar('errormsg', 'No ID!');
- return false;
- }
- if (!isset($args['newaway'])) {
- Eve::SessionSetVar('errormsg', 'No Away Status!');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "UPDATE ".TBL_PREFIX."user
- SET away = '".Eve::VarPrepForStore($args['newaway'])."'
- WHERE id = '".Eve::VarPrepForStore($args['id'])."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- Eve::SessionSetVar('away', $newaway);
-
- return true;
- }
-
-
- /**
- * POSMGMT::UpdateUserMail()
- *
- * @param mixed $args
- * @return
- */
- function UpdateUserMail($args)
- {
- if (!isset($args['id'])) {
- Eve::SessionSetVar('errormsg', 'No ID!');
- return false;
- }
- if (!isset($args['newmail'])) {
- Eve::SessionSetVar('errormsg', 'No Mail!');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "UPDATE ".TBL_PREFIX."user
- SET email = '".Eve::VarPrepForStore($args['newmail'])."'
- WHERE id = '".Eve::VarPrepForStore($args['id'])."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- Eve::SessionSetVar('email', $newmail);
-
- return true;
- }
-
- /**
- * POSMGMT::UpdateUserPass()
- *
- * @param mixed $args
- * @return
- */
- function UpdateUserPass($args)
- {
- if (!isset($args['id'])) {
- Eve::SessionSetVar('errormsg', 'No ID!');
- return false;
- }
- if (!isset($args['newpass'])) {
- Eve::SessionSetVar('errormsg', 'No Mail!');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "UPDATE ".TBL_PREFIX."user
- SET pass = '".Eve::VarPrepForStore($this->newpasswordhash($args['newpass']))."'
- WHERE id = '".Eve::VarPrepForStore($args['id'])."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- Eve::SessionSetVar('email', $newmail);
-
- return true;
- }
-
- /**
- * POSMGMT::UpdateUserInfo()
- *
- * @param mixed $args
- * @return
- */
- function UpdateUserInfo($args)
- {
- if (!isset($args['id'])) {
- Eve::SessionSetVar('errormsg', 'No ID!');
- return false;
- }
-
- $alliance = $this->GetAllianceByName($args['useralliance']);
-
- $dbconn =& DBGetConn(true);
-
- $sql = "UPDATE ".TBL_PREFIX."user
- SET corp = '".Eve::VarPrepForStore($args['usercorp'])."',
- alliance_id = '".Eve::VarPrepForStore($alliance['allianceID'])."',
- datetime = '".Eve::VarPrepForStore(time())."'
- WHERE id = '".Eve::VarPrepForStore($args['id'])."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- Eve::SessionSetVar('corp', $args['usercorp']);
- Eve::SessionSetVar('allianceID', $alliance['allianceID']);
-
- return true;
- }
-
- /**
- * POSMGMT::UpdateUserAccess()
- *
- * @param mixed $args
- * @return
- */
- function UpdateUserAccess($args)
- {
-
- if (!isset($args['id'])) {
- Eve::SessionSetVar('errormsg', 'No ID!');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "UPDATE ".TBL_PREFIX."user
- SET access = '".Eve::VarPrepForStore($args['access'])."',
- highly_trusted = '".Eve::VarPrepForStore($args['highly_trusted'])."'
- WHERE id = '".Eve::VarPrepForStore($args['id'])."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- return true;
- }
-
- /**
- * POSMGMT::DeleteUser()
- *
- * @param mixed $id
- * @return
- */
- function DeleteUser($id)
- {
-
- if (!$id) {
- Eve::SessionSetVar('errormsg', 'No ID!');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "DELETE FROM ".TBL_PREFIX."user
- WHERE id = '".Eve::VarPrepForStore($id)."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- return true;
- }
-
- /**
- * POSMGMT::DeletePOS()
- *
- * @param mixed $pos_id
- * @return
- */
- function DeletePOS($pos_id)
- {
-
- if (!$pos_id) {
- Eve::SessionSetVar('errormsg', 'No ID!');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "DELETE FROM ".TBL_PREFIX."tower_info
- WHERE pos_id = '".Eve::VarPrepForStore($pos_id)."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $sql = "DELETE FROM ".TBL_PREFIX."pos_hanger
- WHERE pos_id = '".Eve::VarPrepForStore($pos_id)."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $sql = "DELETE FROM ".TBL_PREFIX."pos_structures
- WHERE pos_id = '".Eve::VarPrepForStore($pos_id)."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $sql = "DELETE FROM ".TBL_PREFIX."reactor_info
- WHERE pos_id = '".Eve::VarPrepForStore($pos_id)."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $sql = "DELETE FROM ".TBL_PREFIX."silo_info
- WHERE pos_id = '".Eve::VarPrepForStore($pos_id)."'";
-
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $time = time();
- $sql = "INSERT INTO ".TBL_PREFIX."update_log (
- eve_id,
- type_id,
- type,
- action,
- datetime)
- VALUES ('0',
- '" . Eve::VarPrepForStore($pos_id) . "',
- '1',
- 'Delete POS',
- '" . Eve::VarPrepForStore($time) . "')";
- $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- return true;
- }
-
- /**
- * POSMGMT::GetAllPos2()
- *
- * @param mixed $args
- * @return
- */
- function GetAllPos2($args)
- {
-
- $userinfo = $this->GetUserInfo();
-
- if (!$userinfo) {
- Eve::SessionSetVar('errormsg', 'User Not Logged!');
- return false;
- }
-
- //$limit = false;
- if (isset($args['limit']) && is_numeric($args['limit'])) {
- $limit = $args['limit'];
- $startnum = ((isset($args['startnum'])) ? $args['startnum'] : 0);
- $page = ((isset($args['page'])) ? $args['page'] : 1);
- $startnum = ($page * $limit) - $limit;
- }
-
- //Sorting Code
- $orderby='';
- if(isset($args['scolumn'])) {
- switch($args['scolumn']) {
- case 1:
- default:
- $orderby="ORDER BY MoonName";
- $orderstatus=true;
- break;
- case 2:
- $orderby="ORDER BY MoonName";
- break;
- case 3:
- $orderby="ORDER BY region";
- break;
- case 4:
- $orderby="ORDER BY towerName";
- break;
- case 5:
- $orderby="ORDER BY typeID"; //Need to come up with a way to be alphabetically
- break;
- case 6:
- $orderby="ORDER BY u1.name";
- break;
- case 7:
- $orderby="ORDER BY backup";
- break;
- case 8:
- $orderby="ORDER BY outpost_id";
- break;
- case 9:
- $orderby="ORDER BY pos_size, typeID";
- break;
- case 10:
- $orderby="ORDER BY pos_race, pos_size";
- break;
- case 11:
- $orderby="ORDER BY corp";
- break;
- }
- } else {
- $orderby="ORDER BY MoonName";
- $orderstatus=true;
- }
-
- switch($userinfo['access']) {
- case 0:
- default:
- // This should never happen anyways, so we're going to make sure it won't.
- $where = "WHERE 0=1";
- break;
- case 1:
- // Access Level 1 = Show Towers User is Fuel Tech
- $where = "WHERE ".TBL_PREFIX."tower_info.owner_id = ".$userinfo['eve_id']."
- OR ".TBL_PREFIX."tower_info.secondary_owner_id = ".$userinfo['eve_id'];
- break;
- case 2:
- // Access Level 2 = Show Towers User is Fuel Tech or Same Corp but no Fuel Tech yet.
- $where = "WHERE ".TBL_PREFIX."tower_info.owner_id = ".$userinfo['eve_id']."
- OR ".TBL_PREFIX."tower_info.secondary_owner_id = ".$userinfo['eve_id']."
- OR ( ".TBL_PREFIX."tower_info.owner_id = 0
- AND ".TBL_PREFIX."tower_info.corp = '".$userinfo['corp']."' )";
- break;
- case 3:
- case 4:
- case 5:
- // Access Level 3 or Higher Show everything.
- $where = "WHERE 1=1";
- break;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT ".TBL_PREFIX."tower_info.*,
- u1.name,
- u1.corp as ucorp,
- u2.name AS 'backup',
- ".TBL_PREFIX."evemoons.moonName AS 'MoonName',
- mr.regionName AS 'region',
- ms.solarSystemName AS 'system'
- FROM ".TBL_PREFIX."tower_info
- LEFT JOIN ".TBL_PREFIX."user u1 ON ".TBL_PREFIX."tower_info.owner_id = u1.eve_id
- LEFT JOIN ".TBL_PREFIX."user u2 ON ".TBL_PREFIX."tower_info.secondary_owner_id = u2.eve_id
- LEFT JOIN ".TBL_PREFIX."evemoons ON ".TBL_PREFIX."tower_info.moonID = ".TBL_PREFIX."evemoons.moonID
- LEFT JOIN ".TBL_PREFIX."mapregions mr ON ".TBL_PREFIX."evemoons.regionID = mr.regionID
- LEFT JOIN ".TBL_PREFIX."mapsolarsystems ms ON ".TBL_PREFIX."tower_info.systemID = ms.solarSystemID
- ".$where."
- ".$orderby;
-
-
- //$result = $dbconn->SelectLimit($sql, $limit, $startnum);
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- for (; !$result->EOF; $result->MoveNext()) {
- $rows[] = $result->GetRowAssoc(2);
- }
-
- $result->Close();
- foreach($rows as $key => $row) {
-
- $row2 = $this->GetLastPosUpdate($row['pos_id']);
-
-
- $row['result_uptimecalc'] = $this->uptimecalc($row['pos_id']);
- $row['result_online'] = $this->online($row['result_uptimecalc']);
- $row['last_update'] = gmdate("Y-m-d H:i:s", $row2['datetime']);
- $row['online'] = $this->daycalc($row['result_online']);
- //$row['region'] = $this->getRegionNameFromMoonID($row['MoonName']);
- //$row['system'] = $this->getSystemName($row['systemID']);
-
- $sortAarr[] = $row['result_online'];
-
- $rows[$key] = $row;
-
- }
- if(isset($orderstatus)) {
- array_multisort($sortAarr, SORT_ASC, $rows);
- }
- if($limit) {
- $rows=array_slice($rows, $startnum, $limit);
- }
-
- return $rows;
-
- }
-
- /**
- * POSMGMT::GetAllPos2Count()
- *
- * @return
- */
- function GetAllPos2Count()
- {
- $userinfo = $this->GetUserInfo();
-
- if (!$userinfo) {
- Eve::SessionSetVar('errormsg', 'User Not Logged!');
- return false;
- }
-
- switch($userinfo['access']) {
- case 0:
- default:
- // This should never happen anyways, so we're going to make sure it won't.
- $where = "WHERE 0=1";
- break;
- case 1:
- // Access Level 1 = Show Towers User is Fuel Tech
- $where = "WHERE ".TBL_PREFIX."tower_info.owner_id = ".$userinfo['eve_id']."
- OR ".TBL_PREFIX."tower_info.secondary_owner_id = ".$userinfo['eve_id'];
- break;
- case 2:
- // Access Level 2 = Show Towers User is Fuel Tech or Same Corp but no Fuel Tech yet.
- $where = "WHERE ".TBL_PREFIX."tower_info.owner_id = ".$userinfo['eve_id']."
- OR ".TBL_PREFIX."tower_info.secondary_owner_id = ".$userinfo['eve_id']."
- OR ( ".TBL_PREFIX."tower_info.owner_id = 0
- AND ".TBL_PREFIX."tower_info.corp = '".$userinfo['corp']."' )";
- break;
- case 3:
- case 4:
- case 5:
- // Access Level 3 or Higher Show everything.
- $where = "WHERE 1=1";
- break;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT ".TBL_PREFIX."tower_info.*,
- (SELECT ".TBL_PREFIX."user.name
- FROM ".TBL_PREFIX."user
- WHERE ".TBL_PREFIX."tower_info.secondary_owner_id = ".TBL_PREFIX."user.eve_id ) AS 'backup',
- (SELECT ".TBL_PREFIX."evemoons.moonName
- FROM ".TBL_PREFIX."evemoons
- WHERE ".TBL_PREFIX."tower_info.moonID = ".TBL_PREFIX."evemoons.moonID) AS 'MoonName'
- FROM ".TBL_PREFIX."tower_info
- ".$where."
- ORDER BY MoonName";
-
- $result = $dbconn->Execute($sql);
-
- $resultcount = $result->_numOfRows;
-
- $result->Close();
-
- return $resultcount;
- }
-
- /**
- * POSMGMT::GetAllPoses()
- *
- * @return
- */
- function GetAllPoses()
- {
-
- $userinfo = GetUserInfo();
-
- if (!$userinfo) {
- Eve::SessionSetVar('errormsg', 'User Not Logged!');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $where_statement = "WHERE user.corp = '" . $userinfo['corp'] . "' AND pos_info.secret_pos = 0" ;
-
- if (($userinfo['access'] >= "1") && ($userinfo['highly_trusted'] == 1)) {
- $where_statement2 = "WHERE user.corp = '" . $userinfo['corp'] . "'";
- }
- if (($userinfo['access'] >= "3") && ($userinfo['highly_trusted'] == 1)) {
- $where_statement2 = "";
- }
- if (($userinfo['access'] >= "3") && ($userinfo['highly_trusted'] != 1)) {
- $where_statement2 = "WHERE ".TBL_PREFIX."tower_info.secret_pos = 0";
- }
-
- //Update pos timers
- $sql = "SELECT ".TBL_PREFIX."tower_info.*,
- ".TBL_PREFIX."user.name,
- ".TBL_PREFIX."user.corp,
- (SELECT ".TBL_PREFIX."user.name
- FROM ".TBL_PREFIX."user
- WHERE ".TBL_PREFIX."tower_info.secondary_owner_id = ".TBL_PREFIX."user.eve_id ) AS 'backup',
- (SELECT ".TBL_PREFIX."evemoons.moonName
- FROM ".TBL_PREFIX."evemoons
- WHERE ".TBL_PREFIX."tower_info.moonID = ".TBL_PREFIX."evemoons.moonID) AS 'MoonName'
- FROM ".TBL_PREFIX."tower_info
- LEFT JOIN ".TBL_PREFIX."user ON ".TBL_PREFIX."tower_info.owner_id = ".TBL_PREFIX."user.eve_id " . $where_statement . "
- ORDER BY MoonName";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- for (; !$result->EOF; $result->MoveNext()) {
- $row = $result->GetRowAssoc(2);
-
- $result_uptimecalc = $this->uptimecalc($row['pos_id']);
- $result_online = $this->online($result_uptimecalc, $row['pos_id']);
- $id = $row['pos_id'];
-
- $this->UpdatePosStatus($id, $result_online);
- }
-
- $result->Close();
-
- $sql = "SELECT pos_info.*,
- user.name,
- user.corp ,
- (SELECT user.name
- FROM user
- WHERE pos_info.secondary_owner_id = user.eve_id) AS 'backup'
- FROM pos_info
- LEFT JOIN user ON pos_info.owner_id=user.eve_id " . $where_statement2 . "
- ORDER BY pos_info.status, pos_info.system ASC";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $rows = array();
- for (; !$result->EOF; $result->MoveNext()) {
- $rows[] = $result->GetRowAssoc(2);
- }
-
- $result->Close();
-
- return $rows;
-
-
- }
-
- /**
- * POSMGMT::posoptimaluptime()
- *
- * @param mixed $tower
- * @return
- */
- function posoptimaluptime($tower)
- {
- //Setup
- $required_isotope = $tower['required_isotope'];
- $required_oxygen = $tower['required_oxygen'];
- $required_mechanical_parts = $tower['required_mechanical_parts'];
- $required_coolant = $tower['required_coolant'];
- $required_robotics = $tower['required_robotics'];
- $required_uranium = $tower['required_uranium'];
- $required_ozone = $tower['required_ozone'];
- $required_heavy_water = $tower['required_heavy_water'];
- $required_strontium = $tower['required_strontium'];
- $required_charters = $charters_needed?1:0;
- $race_isotope = $result['race_isotope'];
- $total_pg = $tower['total_pg'];
- $total_cpu = $tower['total_cpu'];
- $current_pg = $tower['current_pg'];
- $current_cpu = $tower['current_cpu'];
- //$tower['uptimecalc'] = $posmgmt->uptimecalc($pos_id);
- $strontium_capacity = $tower['strontium_capacity'];
- $pos_capacity = $tower['fuel_hangar'];
- $tower['pos_capacity'] = $pos_capacity;
-
-
-
- //Calculate Optimal cycles
- $volume_per_cycle = 0;
- $volume_per_cycle += ($required_uranium * $GLOBALS["pos_Ura"]);
- $volume_per_cycle += ($required_oxygen * $GLOBALS["pos_Oxy"]);
- $volume_per_cycle += ($required_mechanical_parts * $GLOBALS["pos_Mec"]);
- $volume_per_cycle += ($required_coolant * $GLOBALS["pos_Coo"]);
- $volume_per_cycle += ($required_robotics * $GLOBALS["pos_Rob"]);
- $volume_per_cycle += ($required_isotope * $GLOBALS["pos_Iso"]);
- $volume_per_cycle += ceil(($current_pg / $total_pg) * $required_ozone) * $GLOBALS["pos_Ozo"];
- $volume_per_cycle += ceil(($current_cpu / $total_cpu) * $required_heavy_water) * $GLOBALS["pos_Hea"];
- $volume_per_cycle += ($required_charters * $GLOBALS["pos_Cha"]);
- $optimum_cycles = floor(($pos_capacity)/$volume_per_cycle);
- /*
- echo $pos_capacity;
- echo "<br>";
- echo $volume_per_cycle;
- exit;*/
-
- //var_dump($tower);
-
- //calculate optimal (done!, do not touch)
- $optimal['optimum_cycles']=$optimum_cycles;
- $optimal['optimal_strontium_cycles'] = $optimal_strontium_cycles = floor($strontium_capacity/($required_strontium*3));
- $optimal['optimum_uranium'] = $required_uranium * $optimum_cycles;
- $optimal['optimum_oxygen'] = $required_oxygen * $optimum_cycles;
- $optimal['optimum_mechanical_parts'] = $required_mechanical_parts * $optimum_cycles;
- $optimal['optimum_coolant'] = $required_coolant * $optimum_cycles;
- $optimal['optimum_robotics'] = $required_robotics * $optimum_cycles;
- $optimal['optimum_isotope'] = $required_isotope * $optimum_cycles;
- $optimal['optimum_ozone'] = ceil(($current_pg / $total_pg) * $required_ozone) * $optimum_cycles;
- $optimal['optimum_heavy_water'] = ceil(($current_cpu / $total_cpu) * $required_heavy_water) * $optimum_cycles;
- $optimal['optimum_charters'] = $required_charters * $optimum_cycles;
- $optimal['optimum_strontium'] = $required_strontium * $optimal_strontium_cycles;
- return $optimal;
- }
-
- /**
- * POSMGMT::getOptimalDifference()
- * @param array $optimal
- * @param array $tower
- * @return array $diff
- */
- function getOptimalDifference($optimal, $tower)
- {
- //Diff clear
- $diff=array();
- //Calculate the difference between whats in the tower and optimal
- $diff['uranium']=$optimal['optimum_uranium']-$tower['uranium'];
- $diff['isotopes']=$optimal['optimum_isotope']-$tower['isotope'];
- $diff['oxygen']=$optimal['optimum_oxygen']-$tower['oxygen'];
- $diff['mechanical_parts']=$optimal['optimum_mechanical_parts']-$tower['mechanical_parts'];
- $diff['coolant']=$optimal['optimum_coolant']-$tower['coolant'];
- $diff['robotics']=$optimal['optimum_robotics']-$tower['robotics'];
- $diff['charters']=$optimal['optimum_charters']-$tower['charters'];
- $diff['ozone']=$optimal['optimum_ozone']-$tower['ozone'];
- $diff['heavy_water']=$optimal['optimum_heavy_water']-$tower['heavy_water'];
- $diff['strontium']=$optimal['optimum_strontium']-$tower['strontium'];
-
- //calculate optimal difference in m3
- $diff['uranium_m3']=$diff['uranium']*$GLOBALS["pos_Ura"];
- $diff['isotopes_m3']=$diff['isotopes']*$GLOBALS["pos_Iso"];
- $diff['oxygen_m3']=$diff['oxygen']*$GLOBALS["pos_Oxy"];
- $diff['mechanical_parts_m3']=$diff['mechanical_parts']*$GLOBALS["pos_Mec"];
- $diff['coolant_m3']=$diff['coolant']*$GLOBALS["pos_Coo"];
- $diff['robotics_m3']=$diff['robotics']*$GLOBALS["pos_Rob"];
- $diff['charters_m3']=$diff['charters']*$GLOBALS["pos_Cha"];
- $diff['ozone_m3']=$diff['ozone']*$GLOBALS["pos_Ozo"];
- $diff['heavy_water_m3']=$diff['heavy_water']*$GLOBALS["pos_Hea"];
- $diff['strontium_m3']=$diff['strontium']*$GLOBALS["pos_Str"];
-
- if ($diff['uranium_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['uranium_m3'];
- }
- if ($diff['isotopes_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['isotopes_m3'];
- }
- if ($diff['oxygen_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['oxygen_m3'];
- }
- if ($diff['mechanical_parts_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['mechanical_parts_m3'];
- }
- if ($diff['coolant_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['coolant_m3'];
- }
- if ($diff['robotics_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['robotics_m3'];
- }
- if ($diff['charters_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['charters_m3'];
- }
- if ($diff['ozone_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['ozone_m3'];
- }
- if ($diff['heavy_water_m3']>= 1)
- {
- $diff['totalDiff']=$diff['totalDiff']+$diff['heavy_water_m3'];
- }
-
- return $diff;
- }
-
- /**
- * POSMGMT::getConstellationNameFromMoonID()
- *
- * @param mixed $moon
- * @return
- */
- function getConstellationNameFromMoonID($moon)
- {
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT ".TBL_PREFIX."mapconstellations.constellationName,
- moonName
- FROM ".TBL_PREFIX."mapconstellations,
- ".TBL_PREFIX."mapsolarsystems,
- ".TBL_PREFIX."evemoons
- WHERE ".TBL_PREFIX."evemoons.moonName = '".Eve::VarPrepForStore($moon)."'
- AND ".TBL_PREFIX."evemoons.systemID = ".TBL_PREFIX."mapsolarsystems.SolarSystemID
- AND ".TBL_PREFIX."mapsolarsystems.constellationID = ".TBL_PREFIX."mapconstellations.constellationID";
-
- $result = $dbconn->Execute($sql);
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', 'Could not select from getConstellationNameFromMoonID ' . $dbconn->ErrorMsg() . $sql);
- return false;
- }
- $row = $result->GetRowAssoc(2);
- $result->Close();
- //echo '<pre>';print_r($rows);echo '</pre>';exit;
- return $row['constellationName'];
- }
-
-
- /**
- * POSMGMT::getRegionNameFromMoonID()
- *
- * @param mixed $moon
- * @return
- */
- function getRegionNameFromMoonID($moon)
- {
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT ".TBL_PREFIX."mapregions.regionName,
- moonName
- FROM ".TBL_PREFIX."mapregions,
- ".TBL_PREFIX."evemoons
- WHERE ".TBL_PREFIX."evemoons.moonName = '".Eve::VarPrepForStore($moon)."'
- AND ".TBL_PREFIX."evemoons.regionID = ".TBL_PREFIX."mapregions.regionID";
-
- $result = $dbconn->Execute($sql);
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', 'Could not select from getRegionNameFromMoonID ' . $dbconn->ErrorMsg() . $sql);
- return false;
- }
- $row = $result->GetRowAssoc(2);
- $result->Close();
- //echo '<pre>';print_r($rows);echo '</pre>';exit;
- return $row['regionName'];
- }
-
- /**
- * POSMGMT::getMoonNameFromMoonID()
- *
- * @param mixed $moonID
- * @return
- */
- function getMoonNameFromMoonID($moonID)
- {
- $dbconn =& DBGetConn(true);
- $sql = "SELECT `moonName` FROM `".TBL_PREFIX."evemoons` WHERE `moonID`=".Eve::VarPrepForStore($moonID)." LIMIT 0, 30 ";
-
- $result = $dbconn->Execute($sql);
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', 'Could not select from getMoonNameFromMoonID ' . $dbconn->ErrorMsg() . $sql);
- return false;
- }
- $row = $result->GetRowAssoc(2);
- $result->Close();
- //echo '<pre>';print_r($rows);echo '</pre>';exit;
- return $row['moonName'];
- }
-
- /**
- * POSMGMT::GetAllTowers()
- *
- * @param mixed $args
- * @return
- */
- function GetAllTowers($args)
- {
-
- $dbconn =& DBGetConn(true);
-
- $where = "";
- $where2 = "";
- if (isset($args['ownerID'])) {
- $where2 = " AND (".TBL_PREFIX."tower_info.owner_id = '".$args['ownerID']."' OR ".TBL_PREFIX."tower_info.secondary_owner_id = '".$args['ownerID']."') ";
- }
-
- if (isset($args['corp'])) {
- $where2 .= " AND corp = '".$args['corp']."' ";
- }
-
- if (isset($args['pos_ids']))
- {
- $where = "WHERE ".TBL_PREFIX."tower_info.pos_id IN ('".implode('\',\'', $args['pos_ids'])."') ";
- $sql = "SELECT * FROM `".TBL_PREFIX."tower_info` ".$where . $where2;
- }
- elseif (isset($args['systemID']))
- {
- $where = "WHERE ".TBL_PREFIX."tower_info.systemID = '".$args['systemID']."' ";
- $sql = "SELECT * FROM `".TBL_PREFIX."tower_info` ".$where . $where2;
- }
- elseif (isset($args['constellationID']))
- {
- $sql = "SELECT pos_id,
- typeID,
- evetowerID,
- outpost_id,
- corp,
- allianceid,
- pos_size,
- pos_race,
- isotope,
- oxygen,
- mechanical_parts,
- coolant,
- robotics,
- uranium,
- ozone,
- heavy_water,
- charters,
- strontium,
- towerName,
- systemID,
- charters_needed,
- status,
- owner_id,
- secondary_owner_id,
- pos_status,
- pos_comment,
- secret_pos,
- moonID,
- ".TBL_PREFIX."mapconstellations.constellationID as constellationID,
- ".TBL_PREFIX."mapconstellations.constellationName as constellationName
- FROM ".TBL_PREFIX."tower_info,
- ".TBL_PREFIX."mapsolarsystems,
- ".TBL_PREFIX."mapconstellations
- WHERE ".TBL_PREFIX."tower_info.systemID = ".TBL_PREFIX."mapsolarsystems.solarSystemID
- AND ".TBL_PREFIX."mapsolarsystems.constellationID = ".TBL_PREFIX."mapconstellations.constellationID
- AND ".TBL_PREFIX."mapsolarsystems.constellationID = '".$args['constellationID']."'" . $where2;
- }
- elseif (isset($args['regionID']))
- {
- $sql = "SELECT pos_id,
- typeID,
- evetowerID,
- outpost_id,
- corp,
- allianceid,
- pos_size,
- pos_race,
- isotope,
- oxygen,
- mechanical_parts,
- coolant,
- robotics,
- uranium,
- ozone,
- heavy_water,
- charters,
- strontium,
- towerName,
- systemID,
- charters_needed,
- status,
- owner_id,
- secondary_owner_id,
- pos_status,
- pos_comment,
- secret_pos,
- moonID,
- ".TBL_PREFIX."mapregions.regionID as regionID,
- ".TBL_PREFIX."mapregions.regionName as regionName
- FROM ".TBL_PREFIX."tower_info,
- ".TBL_PREFIX."mapsolarsystems,
- ".TBL_PREFIX."mapregions
- WHERE ".TBL_PREFIX."tower_info.systemID = ".TBL_PREFIX."mapsolarsystems.solarSystemID
- AND ".TBL_PREFIX."mapsolarsystems.regionID = ".TBL_PREFIX."mapregions.regionID
- AND ".TBL_PREFIX."mapsolarsystems.regionID = '".$args['regionID']."'" . $where2;
- }
- elseif (isset($args['ownerID']) || isset($args['corp']))
- {
- $sql = "SELECT * FROM `".TBL_PREFIX."tower_info` WHERE 1=1" . $where2;
- }
- else
- {
- $sql = "SELECT * FROM `".TBL_PREFIX."tower_info`";
- }
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', $dbconn->ErrorMsg() . $sql);
- return false;
- }
-
- $rows = array();
- for (; !$result->EOF; $result->MoveNext()) {
- $rows[] = $result->GetRowAssoc(2);
- }
-
- $result->Close();
-
- return $rows;
- }
-
- /**
- * POSMGMT::GetTowerTypeID()
- *
- * @param mixed $args
- * @return
- */
- function GetTowerTypeID($args)
- {
-
- if (!isset($args['pos_race']) || !isset($args['pos_size'])) {
- Eve::SessionSetVar('errormsg', 'Missing Information');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."tower_static
- WHERE pos_race = '".Eve::VarPrepForStore($args['pos_race'])."'
- AND pos_size = '".Eve::VarPrepForStore($args['pos_size'])."'";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', 'Failed to get Static Tower Info: '.$dbconn->ErrorMsg());
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row;
- }
-
- /**
- * POSMGMT::GetTowerType()
- *
- * @param mixed $typeID
- * @return
- */
- function GetTowerType($typeID)
- {
-
- if (!isset($typeID) && is_numeric($typeID)) {
- Eve::SessionSetVar('errormsg', 'Missing Information');
- return false;
- }
-
- $dbconn =& DBGetConn(true);
-
- $sql = "SELECT *
- FROM ".TBL_PREFIX."tower_static
- WHERE typeID = '".Eve::VarPrepForStore($typeID)."';";
-
- $result = $dbconn->Execute($sql);
-
- if ($dbconn->ErrorNo() != 0) {
- Eve::SessionSetVar('errormsg', 'Failed to get Static Tower Info: '.$dbconn->ErrorMsg());
- return false;
- }
-
- $row = $result->GetRowAssoc(2);
-
- $result->Close();
-
- return $row;
- }
-
- /**
- * POSMGMT::AddNewPOS()
- *
- * @param mixed $args
- * @return
- */
- function AddNewPOS($args = array())
- {
-
- if (!$args) {
- return false;
- }
-
- $pos_size = Eve::VarPrepForStore($args['pos_size']);
- $corp = Eve::VarPrepForStore($args['corp']);
- $allianceid = Eve::VarPrepForStore($args['allianceid']);
- $typeID = Eve::VarPrepForStore($args['typeID']);
- $pos_race = Eve::VarPrepForStore($args['pos_race']);
- $pos_size = Eve::VarPrepForStore($args['pos_size']);
- $system = Eve::VarPrepForStore($args['system']);
- //$sovereignity = Eve::VarPrepForStore($args['sovereignity']);
- $uranium = Eve::VarPrepForStore($args['uranium']);
- $oxygen = Eve::VarPrepForStore($args['oxygen']);
- $mechanical_parts = Eve::VarPrepForStore($args['mechanical_parts']);
- $coolant = Eve::VarPrepForStore($args['coolant']);
- $robotics = Eve::VarPrepForStore($args['robotics']);
- $isotope = Eve::VarPrepForStore($args['isotope']);
- $ozone = Eve::VarPrepForStore($args['ozone']);
- $heavy_water = Eve::VarPrepForStore($args['heavy_water']);
- $strontium = Eve::VarPrepForStore($args['strontium']);
- $struct_amount = Eve::VarPrepForStore($args['struct_amount']);
- $owner_id = Eve::VarPrepForStore($args['owner_id']);
- $pos_status = Eve::VarPrepForStore($args['pos_status']);
- $systemID = Eve::VarPrepForStore($args['systemID']);
- $moonID = Eve::VarPrepForStore($args['moonID']);
- $towerName = Eve::VarPrepForStore($args['towerName']);
-
- $security=$this->getSystemSecurity($systemID);
- if($security>=0.35)
- {
- $charters_needed=1;
- }
- else
- {
- $charters_needed=0;
- }
- $dbconn =& DBGetConn(true);
-
- //$nextId = $dbconn->GenId(TBL_PREFIX.'tower_info');
-
- $sql = "INSERT INTO ".TBL_PREFIX."tower_info (typeID,
- evetowerID,
- corp,
- allianceid,
- pos_size,
- pos_race,
- isotope,
- oxygen,
- mechanical_parts,
- coolant,
- robotics,
- uranium,
- ozone,
- heavy_water,
- charters,
- strontium,
- towerName,
- systemID,
- charters_needed,
- status,
- owner_id,
- secondary_owner_id,
- pos_status,
- pos_comment,
- secret_pos,
- moonID,
- onlineSince)
- VALUES ('" . $typeID . "',
- '0',
- '" . $corp . "',
- '" . $allianceid . "',
- '" . $pos_size . "',
- '" . $pos_race . "',
- '" . $isotope . "',
- …
Large files files are truncated, but you can click here to view the full file