コード例 #1
0
ファイル: BattleEditor.php プロジェクト: kingboard/kingboard
 public function create(array $params)
 {
     $form = new \Kingboard\Lib\Forms\BattleCreateForm();
     if (!$form->validate($_POST)) {
         // @todo handle invalid
         return $this->error("form is not valid");
     }
     $user = \Kingboard\Lib\Auth\Auth::getUser();
     $key = $form->apiKey;
     $scope = "char";
     // for now we default to char. Account keys are never corp keys.
     if ($key['type'] == "Character") {
         $scope = "char";
     }
     if ($key['type'] == "Corporation") {
         $scope = "corp";
     }
     $pheal = new Pheal($key['apiuserid'], $key['apikey'], $scope);
     $contacts = $pheal->ContactList(array('characterID' => $form->character));
     // reset to neutral pheal
     $pheal = new Pheal();
     $characterInfo = $pheal->eveScope->CharacterInfo(array('characterID' => $form->character));
     $positives = array();
     foreach ($contacts->corporateContactList as $contact) {
         // accumulate postive standings
         if ($contact->standing > 0) {
             $positives[$contact->contactID] = $contact->contactName;
         }
     }
     // alliance standings override corp standings
     foreach ($contacts->allianceContactList as $contact) {
         if ($contact->standing > 0) {
             $positives[$contact->contactID] = $contact->contactName;
         } else {
             // negative standings, we only need those if corp has positive, but alliance negative
             if (isset($positives[$contact->contactID])) {
                 unset($positives[$contact->contactID]);
             }
         }
     }
     $battleSetting = new \Kingboard\Model\BattleSettings();
     $battleSetting->startdate = new \MongoDate(strtotime($_POST['startdate']));
     $battleSetting->user = $user->_id;
     $battleSetting->enddate = new \MongoDate(strtotime($_POST['enddate']));
     $battleSetting->system = $_POST['system'];
     $battleSetting->key = $key;
     // lets fix some info about the creator of this report
     $battleSetting->ownerCharacter = $form->character;
     $battleSetting->ownerCharacterName = $characterInfo->characterName;
     $battleSetting->ownerCorporation = (int) $characterInfo->corporationID;
     $battleSetting->ownerCorporationName = $characterInfo->corporation;
     $battleSetting->ownerAlliance = (int) $characterInfo->allianceID;
     $battleSetting->ownerAllianceName = $characterInfo->alliance;
     $battleSetting->positives = $positives;
     $battleSetting->runs = 0;
     $battleSetting->nextRun = new \MongoDate(time());
     $battleSetting->save();
     // we are done here, lets redirect to the battle!
     $this->redirect("/battle/" . $battleSetting->_id);
 }
コード例 #2
0
ファイル: eve.inc.php プロジェクト: jgrancell/blackbriar
 public function getCharacterID($characterName)
 {
     /** Leading in PhealNG with blank keys */
     $pheal = new Pheal('', '', 'eve');
     try {
         /** Verifying the CCP API server is functioning */
         if ($this->_ccpAPIStatus) {
             /** Pulling the CharacterAffiliation */
             $response = $pheal->CharacterID(array('names' => $characterName));
             /** Working through the pheal response*/
             if (is_object($response->characters)) {
                 /** Returning the character information */
                 return $response->characters[0];
             } else {
                 /** Returning null to indicate that the characterID doesn't exist */
                 return null;
             }
         } else {
             /** Returning false to indicate that the API server has issues */
             return false;
         }
     } catch (\Pheal\Exceptions\PhealException $e) {
         get_class($e);
         $_SESSION['alert'] = new Alert('warning', $e->getMessage());
     }
 }
コード例 #3
0
ファイル: EveApi.php プロジェクト: kingboard/kingboard
 /**
  * fetch all kills for $key
  * @static
  * @param array $key
  * @return array
  */
 public static function fetch($key)
 {
     $newkills = 0;
     $oldkills = 0;
     $errors = 0;
     $pheal = new Pheal($key['apiuserid'], $key['apikey']);
     $pheal->detectAccess();
     $characters = $pheal->accountScope->Characters()->characters;
     foreach ($characters as $character) {
         switch ($key['type']) {
             case "Corporation":
                 $pheal->scope = "corp";
                 break;
             case "Account":
                 // account keys are like character keys, just for the complete account
             // account keys are like character keys, just for the complete account
             case "Character":
                 $pheal->scope = "char";
                 break;
             default:
                 // not a key type we can use..
                 continue;
         }
         $kills = $pheal->Killlog(array('characterID' => $character->characterID))->kills;
         $kakp = new \Kingboard\Lib\Parser\EveAPI();
         $info = $kakp->parseKills($kills);
         $oldkills += $info['oldkills'];
         $newkills += $info['newkills'];
         $errors += $info['errors'];
     }
     return array("old" => $oldkills, "new" => $newkills, "total" => $oldkills + $newkills, "errors" => $errors);
 }
コード例 #4
0
ファイル: apikey.inc.php プロジェクト: jgrancell/blackbriar
 /**
  * Class constructor. Called on every page load.
  * @param $keyID integer
  * @param $vCode string
  * @param $user object/integer
  * @param $db PDO object
  */
 public function __construct($keyID, $vCode, $user, $db)
 {
     /** Saving the database into the db param */
     $this->_db = $db;
     /** Determining if we're live or a cronjob -- */
     if (is_object($user)) {
         /** We're dealing with a live user */
         $this->_userID = $user->getUserID();
     } else {
         $this->_userID = $user;
     }
     /** Saving the API key keyID and vCode */
     $this->_keyID = $keyID;
     $this->_vCode = $vCode;
     /** Creating a new Phealng object */
     $pheal = new Pheal($keyID, $vCode, 'account');
     /** Starting a Phealng lookup */
     try {
         $response = $pheal->APIKeyInfo();
         /** Checking to see if we received a valid response */
         if (!isset($response->code) && $response->key->accessMask & MINIMUM_API_MASK) {
             $this->_keyStatus = 1;
             $this->_accessMask = $response->key->accessMask;
             $this->_keyExpiration = $response->key->expires;
             $this->_keyType = $response->key->type;
             if ($response->key->expires == null) {
                 $this->_keyExpiration = 'No Expiration';
             } else {
                 $this->_keyExpiration = $response->key->expires;
             }
             $response2 = $pheal->AccountStatus();
             if ($response2->paidUntil == null) {
                 $this->_accountStatus = "Account Unsubscribed";
             } else {
                 $this->_accountStatus = $response2->paidUntil;
             }
             $i = 1;
             foreach ($response->key->characters as $character) {
                 if ($character->allianceID == "0") {
                     $allianceID = 0;
                     $allianceName = "No Alliance";
                 } else {
                     $allianceID = $character->allianceID;
                     $allianceName = $character->allianceName;
                 }
                 $this->_characters[$i] = array('characterName' => $character->characterName, 'characterID' => $character->characterID, 'corporationName' => $character->corporationName, 'corporationID' => $character->corporationID, 'allianceName' => $allianceName, 'allianceID' => $allianceID);
                 $i++;
             }
         } else {
             $this->_keyStatus = 0;
             $this->keyError = $this->parseKeyError($response->code, 'code');
         }
     } catch (\Pheal\Exceptions\PhealException $e) {
         $this->keyError = $this->parseKeyError($e, 'exception');
         $this->_keyStatus = 0;
         $_SESSION['alert'] = new Alert('danger', 'API Key Error', $e->getMessage());
     }
 }
コード例 #5
0
ファイル: User.php プロジェクト: kingboard/kingboard
 public function myKingboard(array $parameters)
 {
     $user = \Kingboard\Lib\Auth\Auth::getUser();
     $context = array();
     if (isset($_POST['XSRF']) && \Kingboard\Lib\Form::getXSRFToken() == $_POST['XSRF']) {
         try {
             $pheal = new Pheal($_POST['apiuserid'], $_POST['apikey']);
             $pheal->detectAccess();
             $keyinfo = $pheal->accountScope->ApiKeyInfo();
             $keytype = $keyinfo->key->type;
             $accessmask = $keyinfo->key->accessMask;
             if (!($accessmask & 272)) {
                 throw new \Exception("Key invalid, or wrong permissions!");
             }
             if (!isset($user['keys'])) {
                 $keys = array();
             } else {
                 $keys = $user['keys'];
             }
             $keys[$_POST['apiuserid']] = array('apiuserid' => $_POST['apiuserid'], 'apikey' => $_POST['apikey'], 'type' => $keytype, 'active' => true);
             $user['keys'] = $keys;
             $user->save();
             // ensure user is refreshed in session
             \Kingboard\Lib\Auth\Auth::getUser();
         } catch (\Exception $e) {
             $context = $_POST;
             $context['error'] = $e->getMessage();
             //$context['error'] = "the key could not be validated as a valid apikey";
         }
     } elseif (isset($_POST['XSRF'])) {
         return $this->error('XSRF detected');
     }
     if (isset($user['keys'])) {
         $activeKeys = $user['keys'];
     } else {
         $activeKeys = array();
     }
     foreach ($activeKeys as $id => $key) {
         try {
             $pheal = new Pheal($key['apiuserid'], $key['apikey']);
             $chars = $pheal->accountScope->Characters()->characters->toArray();
             $charlist = array();
             foreach ($chars as $char) {
                 $charlist[] = $char['name'];
             }
             $activeKeys[$id]["chars"] = join(', ', $charlist);
         } catch (\Exception $e) {
             //print_r($e);
         }
     }
     $context = array_merge($context, array('active_keys' => $activeKeys));
     $this->render('user/index.html', $context);
 }
コード例 #6
0
 public function __construct($keyID, $vcode, $user, $db)
 {
     $this->db = $db;
     if (is_object($user)) {
         $this->uid = $user->getUID();
     } else {
         $this->uid = $user;
     }
     $this->keyID = $keyID;
     $this->vcode = $vcode;
     $pheal = new Pheal($keyID, $vcode, 'account');
     try {
         $response = $pheal->APIKeyInfo();
         if (!isset($response->code) and $response->key->accessMask & MINIMUM_API) {
             $this->keyStatus = 1;
             $this->accessMask = $response->key->accessMask;
             $this->expires = $response->key->expires;
             $this->keyType = $response->key->type;
             if ($response->key->expires == NULL) {
                 $this->expires = 'No Expiration';
             } else {
                 $this->expires = $response->key->expires;
             }
             $response2 = $pheal->AccountStatus();
             if ($response2->paidUntil == NULL) {
                 $this->accountStatus = "Account Unsubscribed";
             } else {
                 $this->accountStatus = $response2->paidUntil;
             }
             $i = 1;
             foreach ($response->key->characters as $character) {
                 if ($character->allianceID == "0") {
                     $allianceID = 0;
                     $allianceName = "No Alliance";
                 } else {
                     $allianceID = $character->allianceID;
                     $allianceName = $character->allianceName;
                 }
                 $this->characters[$i] = array('characterName' => $character->characterName, 'characterID' => $character->characterID, 'corporationName' => $character->corporationName, 'corporationID' => $character->corporationID, 'allianceName' => $allianceName, 'allianceID' => $allianceID);
                 $i++;
             }
         } else {
             $this->keyStatus = 0;
             $this->keyError = $this->parseKeyError($response->code, 'code');
         }
     } catch (\Pheal\Exceptions\PhealException $e) {
         $this->keyError = $this->parseKeyError($e, 'exception');
         $this->keyStatus = 0;
         setAlert('danger', 'API Key Error', $e->getMessage());
     }
 }
コード例 #7
0
ファイル: register.inc.php プロジェクト: addrever/ecat
include "vendor/autoload.php";
use Pheal\Pheal;
use Pheal\Core\Config;
Config::getInstance()->cache = new \Pheal\Cache\FileStorage('E:\\xampp\\tmp');
Config::getInstance()->access = new \Pheal\Access\StaticCheck();
if (isset($_POST['keyid'], $_POST['vcode'], $_POST['phase'])) {
    $keyid = $_POST['keyid'];
    $vcode = $_POST['vcode'];
    if (isset($_POST['corporationID'])) {
        $corporationID = $_POST['corporationID'];
    }
    $phase = $_POST['phase'];
    //echo $phase;
    switch ($phase) {
        case 1:
            $pheal = new Pheal($keyid, $vcode, "account");
            try {
                $result = $pheal->Characters();
            } catch (\Pheal\Exceptions\PhealException $e) {
                echo sprintf("an exception was caught! Type: %s Message: %s", get_class($e), $e->getMessage());
            }
            echo "<div>";
            echo "<form method=post action=" . htmlspecialchars($_SERVER['PHP_SELF']) . ">";
            foreach ($result->characters as $character) {
                echo "<img src=https://image.eveonline.com/Character/" . $character->characterID . "_32.jpg>";
                echo $character->name;
                echo $character->corporationName;
                echo "<img src=https://image.eveonline.com/Corporation/" . $character->corporationID . "_32.png>";
                echo "<input type=radio value=" . $character->characterID . "> <br>";
            }
            echo "<input type=hidden value=" . $keyid . " name=keyid>";
コード例 #8
0
 public function updateCharacterSkills()
 {
     $db = $this->_db;
     $pheal = new Pheal($this->_keyID, $this->_vCode, 'char');
     try {
         $response = $pheal->CharacterSheet(array('characterID' => $this->_characterID));
         $stmt = $db->prepare('INSERT INTO user_characters_skills (userid,character_id,key_keyid,skill_id,' . 'skill_level) VALUES (?,?,?,?,?) ON DUPLICATE KEY UPDATE userid=VALUES(userid)' . ',key_keyid=VALUES(key_keyid),skill_level=VALUES(skill_level)');
         foreach ($response->skills as $skill) {
             $stmt->execute(array($this->_userID, $this->_characterID, $this->_keyID, $skill->typeID, $skill->level));
         }
         return true;
     } catch (\Pheal\Exceptions\PhealException $phealException) {
         // Putting the pheal exception through our test function to determine if it's a key failure, or an API server failure.
         $this->handleAPIKeyException($phealException);
         return false;
     }
 }
コード例 #9
0
<?php

require '../includes/config.php';
use Pheal\Pheal;
use Pheal\Core\Config;
Config::getInstance()->cache = new \Pheal\Cache\MemcacheStorage();
Config::getInstance()->access = new \Pheal\Access\StaticCheck();
$stmt = $db->prepare('DELETE FROM alliance_contracts WHERE 1=1');
$stmt->execute(array());
$stmt = $db->prepare('DELETE FROM alliance_contract_items WHERE 1=1');
$stmt->execute(array());
$corpKeyID = 4813754;
$corpVCode = 'TQb0AdlLKCwZcUoGkHbb6TTmZTAleIuxZtNdlHOqograHNNyLNerJewlonedsnqv';
$pheal = new Pheal($corpKeyID, $corpVCode, 'corp');
$contracts = $pheal->Contracts(array('corporationID' => '98098579'));
$stmt = $db->prepare('INSERT INTO alliance_contracts (contractID,issuerID,issuerName,corporationID,volume,title,price,status,doctrine,ship,end_date) VALUEs (?,?,?,?,?,?,?,?,?,?,?)' . 'ON DUPLICATE KEY UPDATE status=VALUES(status),doctrine=VALUES(doctrine),ship=VALUES(ship),end_date=VALUES(end_date)');
$stmt_items = $db->prepare('INSERT INTO alliance_contract_items (contractID,itemID,quantity) VALUES (?,?,?) ON DUPLICATE KEY UPDATE quantity = quantity + ?');
foreach ($contracts->contractList as $contract) {
    if ($contract['assigneeID'] == '150097440' and $contract['status'] == 'Outstanding' and $contract['startStationID'] == '61000829' and $contract['type'] == 'ItemExchange') {
        $parsed_string = get_string_between($contract['title'], '[', ']');
        if ($parsed_string != '' and $parsed_string != NULL) {
            $parsed_array = explode("-", $parsed_string);
            $doctrine = trim($parsed_array[0]);
            $ship = trim($parsed_array[1]);
        } else {
            $doctrine = 'Unknown';
            $ship = 'Unknown';
        }
        $stmt->execute(array($contract['contractID'], $contract['issuerID'], Character::lookupCharacterName($contract['issuerID'], $user), $contract['issuerCorpID'], $contract['volume'], $contract['title'], $contract['price'], $contract['status'], $doctrine, $ship, strtotime($contract['dateExpired'])));
        $contractItems = $pheal->ContractItems(array('contractID' => $contract['contractID']));
        foreach ($contractItems->itemList as $item) {
コード例 #10
0
ファイル: select.php プロジェクト: marcfeather/EveTradeMaster
function fetchTransactions($apikey, $vcode, $refID, $idcharacter, $con)
{
    $pheal4 = new Pheal($apikey, $vcode, "char", $refID);
    $wallet_response = $pheal4->WalletTransactions(array("characterID" => $idcharacter));
    if ($refID != 0) {
        $wallet_response = $pheal4->WalletTransactions(array("fromID" => $refID));
    }
    $i = -1;
    //get the Eve transaction ID for the latest transaction (this might need some tweaking when they decide to recycle ids)
    $getLatestTransaction = utils::mysqli_result(mysqli_query($con, "SELECT MAX(transkey) AS val FROM transaction WHERE character_eve_idcharacter = '{$idcharacter}'"), 0, 0);
    //var_dump($getLatestTransaction);
    if (!isset($getLatestTransaction)) {
        $latestTransaction = 0;
    } else {
        $latestTransaction = $getLatestTransaction;
    }
    // var_dump($latestTransaction);
    $arrayfinal = array();
    $array_refs = array();
    $null = (string) "NULL";
    foreach ($wallet_response->transactions as $row2) {
        $transkey = $row2->transactionID;
        $typeid = $row2->typeID;
        $dateTime = $row2->transactionDateTime;
        $quantity = $row2->quantity;
        $price_unit = $row2->price;
        $transactionType = $row2->transactionType;
        $station = $row2->stationName;
        $price_total = $price_unit * $quantity;
        $station_id = $row2->stationID;
        $clientName = $row2->clientName;
        array_push($array_refs, $transkey);
        if ($transkey > $latestTransaction) {
            $i++;
            $item[$i] = array("{$null}", "'" . $dateTime . "'", "'" . $quantity . "'", "'" . $price_unit . "'", "'" . $price_total . "'", "'" . $transactionType . "'", "'" . $idcharacter . "'", "'" . $station_id . "'", "'" . $typeid . "'", "'" . $transkey . "'", "'" . str_replace("'", ".", $clientName) . "'");
        }
    }
    for ($j = 0; $j <= $i; $j++) {
        $arrayfinal[$j] = $item[$j];
    }
    $values_transactions = array();
    foreach ($arrayfinal as $rowValues) {
        foreach ($rowValues as $key => $rowValue) {
            $rowValues[$key] = $rowValues[$key];
        }
        //this array contains all transactions in this format: (x,y,z),(a,b,c),...
        $values_transactions[] = "(" . implode(', ', $rowValues) . ")";
    }
    if (!empty($values_transactions)) {
        //var_dump($values);
        $query_insert = "INSERT IGNORE INTO `trader`.`transaction` (`idbuy`, `time`, `quantity`, `price_unit`, `price_total`, `transaction_type`, `character_eve_idcharacter`, `station_eve_idstation`, `item_eve_iditem`, `transkey`, `client`) " . "VALUES " . implode(', ', $values_transactions);
        $insert_transactions = mysqli_query($con, $query_insert) or die(mysqli_error($con));
        return $newTransactions = mysqli_affected_rows($con);
        if (count($array_refs) == 2560) {
            $refID = end($array_refs);
            fetchTransactions($apikey, $vcode, $refID, $idcharacter, $con);
        }
    } else {
        return $newTransactions = 0;
        $insert_transactions = False;
    }
}
コード例 #11
0
 public static function lookupCharacterName($characterID, $user)
 {
     global $db;
     $pheal = new Pheal($user->getDefaultKeyID(), $user->getDefaultVCode(), 'eve');
     $characterName = $pheal->CharacterName(array('ids' => $characterID));
     return $characterName->characters[0]->name;
 }
コード例 #12
0
 }
 $values = array();
 foreach ($arrayfinal as $rowValues) {
     foreach ($rowValues as $key => $rowValue) {
         $rowValues[$key] = $rowValues[$key];
     }
     $values[] = "(" . implode(', ', $rowValues) . ")";
 }
 if (!empty($values)) {
     //var_dump($values);
     $query_insert = "INSERT IGNORE INTO `trader`.`transaction` (`idbuy`, `time`, `quantity`, `price_unit`, `price_total`, `transaction_type`, `character_eve_idcharacter`, `station_eve_idstation`, `item_eve_iditem`, `transkey`, `client`) " . "VALUES " . implode(', ', $values);
     $insert_transactions = mysqli_query($con, $query_insert) or die(mysqli_error($con));
 }
 $newTransactions = mysqli_affected_rows($con);
 ///Update contracts
 $pheal_contracts = new Pheal($apikey, $vcode, "char");
 //set scope
 $response = $pheal_contracts->Contracts(array("characterID" => $idcharacter));
 //add parameters
 $i = -1;
 foreach ($response->contractList as $row) {
     $contractID = $row->contractID;
     $issuerID = $row->issuerID;
     $acceptorID = $row->acceptorID;
     if ($acceptorID == "") {
         $acceptorID = "NULL";
     }
     $startStationID = $row->startStationID;
     if ($startStationID == "") {
         $startStationID = "NULL";
     }
コード例 #13
0
function standingsCheck($interactionName, $type)
{
    global $db;
    $interactionName = trim($interactionName);
    $standingsArray = ["Legion of xXDEATHXx" => "-10", "Shadow of xXDEATHXx" => "-5", "SHOVEL.OF.DEATH" => "-5", "Pandemic Legion" => "-10", "Northern Coalition." => "-5", "Black Legion" => "-5", "Mordus Angels" => "-10", "Goonswarm Federation" => "10", "RAZOR Alliance" => "5", "SpaceMonkey's Alliance" => "5", "Tactical Narcotics Team" => "5", "The Bastion" => "5", "Fidelas Constans" => "5", "Executive Outcomes" => "5", "A Band Apart." => "5", "The Terrifying League Of Dog Fort" => "10", "Get Off My Lawn" => "10", "Garys Most Noble Army of Third Place Mediocrity" => "5", "Ashkrall" => "10", "Mapache Doom" => "10", "Matt18001" => "10"];
    // Checking to see if the character name is in our standings
    if (isset($standingsArray[$interactionName])) {
        $value = $standingsArray[$interactionName];
    } else {
        // Creating the Pheal object for the Owner lookup
        $phealLookup = new Pheal(1, 1, 'eve');
        // Lookup OwnerID page
        $ownerInfo = $phealLookup->OwnerID(array('names' => $interactionName));
        // Geting the typeId and the object class
        $interactionClass = $ownerInfo->owners[0]->ownerGroupID;
        $interactionID = $ownerInfo->owners[0]->ownerID;
        //Guide to Interaction Classes:
        // 1 - character, 2 - corporation, 19 - faction, 32 - alliance
        if ($interactionClass != '32' and $interactionClass != '19' and $interactionID != '0') {
            if ($interactionClass == '1') {
                $lookupResponse = $phealLookup->CharacterAffiliation(array('ids' => $interactionID));
                $corporationID = $lookupResponse->characters[0]->corporationID;
            } else {
                $corporationID = $interactionID;
            }
            // Now we are on a corporation, so we're looking up their corporation ID
            $phealLookupCorp = new Pheal(1, 1, 'corp');
            $corporationInfo = $phealLookupCorp->CorporationSheet(array('corporationID' => $corporationID));
            $corporationName = $corporationInfo->corporationName;
            $allianceName = $corporationInfo->allianceName;
        } else {
            $value = 0;
        }
        // Checking to see if either the corporation or alliance name is in our standings
        if (isset($corporationName) and isset($standingsArray[$corporationName])) {
            $value = $standingsArray[$corporationName];
        } elseif (isset($allianceName) and isset($standingsArray[$allianceName])) {
            $value = $standingsArray[$allianceName];
        } else {
            $value = 0;
        }
    }
    switch ($value) {
        case "10":
            $color = 'primary';
            $secondary = 'white-space: normal';
            break;
        case "5":
            $color = 'info';
            $secondary = 'white-space: normal';
            break;
        case "-5":
            $color = 'warning';
            $secondary = 'white-space: normal';
            break;
        case "-10":
            $color = 'danger';
            $secondary = 'white-space: normal';
            break;
        default:
            $color = 'default';
            $secondary = 'background-color: transparent; background-image: none; color: #f5f5f5';
            break;
    }
    if ($type == 'button') {
        $return = 'btn-' . $color . '" style="' . $secondary;
    } else {
        $return = '<span class="label label-' . $color . '">';
    }
    return $return;
}
コード例 #14
0
ファイル: compliance.php プロジェクト: ArgusDrise/eveadmin
                    $char = new Character($character['characterID'], $key->getKeyID(), $key->getVCode(), $key->getAccessMask(), $db, $user);
                    if ($char->getExistance() or $char->getExistance() == FALSE) {
                        $char->updateCharacterInfo();
                    }
                }
                $refresh = $key->refreshAPIKey();
                setAlert('success', 'API Key Refreshed', 'The API key has been successfully refreshed.');
            }
        } elseif (!($key->getAccessMask() & MINIMUM_API) and $key->getKeyStatus() == 1) {
            setAlert('danger', 'The API Key Does Not Meet Minimum Requirements', 'The required minimum Access Mask for API keys is ' . MINIMUM_API . '. Please create a new key using the Create Key link.');
        }
    }
    // We're doing API compliance
    $compliance_type = "API";
    // Getting a full API-pulled member list
    $pheal = new Pheal($settings->getCorpUserID(), $settings->getCorpVCode(), 'corp');
    $response = $pheal->MemberTracking(array("extended" => 1));
    $memberList = array();
    foreach ($response->members as $member) {
        $memberList[$member->name]['name'] = $member->name;
        $memberList[$member->name]['id'] = $member->characterID;
    }
    ksort($memberList, SORT_NATURAL | SORT_FLAG_CASE);
    // Working through the member list
    $stmt = $db->prepare('SELECT * FROM characters WHERE charid = ?');
    $stmt_api = $db->prepare('SELECT * FROM user_apikeys WHERE userid = ?');
} elseif ($request['action'] == 'doctrine') {
    $compliance_type = 'Doctrine';
    // Getting all of the doctrines for the group
    $stmt = $db->prepare('SELECT * FROM doctrines WHERE gid = ? ORDER BY doctrine_name ASC');
    $stmt->execute(array($user->getGroup()));
コード例 #15
0
function register_val($con)
{
    //require_once('includes/bootstrapper.php');
    //require_once('includes/connect.php');
    //second send validation
    if (!empty($_POST['Send_2'])) {
        $username_final = mysqli_real_escape_string($con, $_POST['username']);
        $password_final = mysqli_real_escape_string($con, $_POST['password']);
        $apikey_final = mysqli_real_escape_string($con, $_POST['api']);
        $vcode_final = mysqli_real_escape_string($con, $_POST['vcode']);
        $email_final = mysqli_real_escape_string($con, $_POST['email']);
        $reports_final = mysqli_real_escape_string($con, $_POST['reports']);
        $dt = new DateTime();
        $tz = new DateTimeZone('Europe/Lisbon');
        $dt->setTimezone($tz);
        $datetime = $dt->format('Y-m-d H:i:s');
        $chars = array();
        if (isset($_POST['char1'])) {
            $char1 = $_POST['char1'];
            array_push($chars, $char1);
        } else {
            $char1 = "";
        }
        if (isset($_POST['char2'])) {
            $char2 = $_POST['char2'];
            array_push($chars, $char2);
        } else {
            $char2 = "";
        }
        if (isset($_POST['char3'])) {
            $char3 = $_POST['char3'];
            array_push($chars, $char3);
        } else {
            $char3 = "";
        }
        //$chars = array($char1,$char2,$char3);
        //FINAL SERVER VALIDATION #2 (just in case someone sneaks in HTML5)
        if (strlen($username_final) < 5 || $username_final == "") {
            echo "Username is too short (5 characters minimum)";
            failed_validation_2();
        } else {
            if ($password_final == "") {
                echo "Input a proper password";
                failed_validation_2();
            } else {
                if (!filter_var($email_final, FILTER_VALIDATE_EMAIL)) {
                    echo "Wrong email format.";
                    failed_validation_2();
                } else {
                    if (!in_array($reports_final, array('none', 'daily', 'weekly', 'monthly'))) {
                        echo "Invalid report type selection";
                        failed_validation_2();
                    } else {
                        //check if characters belong to API KEY by intersecting both arrays
                        $pheal2 = new Pheal($apikey_final, $vcode_final);
                        $chars_api = array();
                        $chars_name = array();
                        $empty = array();
                        $result2 = $pheal2->accountScope->APIKeyInfo();
                        foreach ($result2->key->characters as $character) {
                            array_push($chars_api, $character->characterID);
                            array_push($chars_name, $character->characterName);
                        }
                        if (array_intersect(array_diff($chars, $chars_api), $chars_api) != $empty) {
                            echo "Character does not belong to account";
                            failed_validation_2();
                        } else {
                            $cost = 10;
                            //Before creating the account, let's securely hash the password:
                            $salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
                            // Prefix information about the hash so PHP knows how to verify it later.
                            // "$2a$" Means we're using the Blowfish algorithm. The following two digits are the cost parameter.
                            $salt = sprintf("\$2a\$%02d\$", $cost) . $salt;
                            // Hash the password with the salt
                            $password_final = crypt($password_final, $salt);
                            //Everything is validated, prepare SQL transaction
                            mysqli_query($con, "START TRANSACTION");
                            $query_insert_user = $con->prepare("INSERT INTO `trader`.`user` (" . "`iduser`, " . "`username`, " . "`registration_date`, " . "`password`, " . "`reports`, " . "`email`, `salt`, `login_count`) " . "VALUES (" . "NULL, " . "?, " . "?, " . "?, " . "?, " . "?, ?, ?);");
                            $zero = 0;
                            $query_insert_user->bind_param("ssssssi", $username_final, $datetime, $password_final, $reports_final, $email_final, $salt, $zero);
                            //ss stands for 2 strings
                            $query_insert_user->execute();
                            $last_id_user = mysqli_insert_id($con);
                            //Insert ignore because api key may already exist
                            $query_insert_apikey = mysqli_query($con, "insert ignore into `trader`.`api` (`apikey`, `vcode`) " . "VALUES " . "('{$apikey_final}', " . "'{$vcode_final}');") or die(mysqli_error($con));
                            //  print_r($chars);
                            $pheal3 = new Pheal($apikey_final, $vcode_final, "char");
                            foreach ($chars as $row) {
                                //echo $row;
                                $response_final = $pheal3->CharacterSheet(array("characterID" => $row));
                                $name_char = mysqli_real_escape_string($con, $response_final->name);
                                $checkExistingCharacter = mysqli_query($con, "SELECT name FROM v_user_characters WHERE character_eve_idcharacter IN" . "(" . implode(",", $chars) . ")") or die(mysqli_error($con));
                                if (mysqli_num_rows($checkExistingCharacter) > 0) {
                                    $duplicates = array();
                                    while ($existing_characters = mysqli_fetch_array($checkExistingCharacter)) {
                                        array_push($duplicates, $existing_characters['name']);
                                    }
                                    echo implode(" and ", $duplicates) . " already belong to another account.";
                                    echo "<meta http-equiv='refresh' content='3;URL=register.php'>";
                                    return;
                                } else {
                                    $query_insert_character = mysqli_query($con, "replace INTO `trader`.`characters` " . "(`eve_idcharacter`, " . "`name`, " . "`balance`, " . "`api_apikey`," . "`networth`," . "`escrow`," . "`total_sell`," . "`broker_relations`," . "`accounting`) " . "VALUES " . "({$row}, " . "'{$name_char}', " . "'0', " . "'{$apikey_final}'," . "'0'," . "'0'," . "'0'," . "'0'," . "'0');") or die(mysqli_error($con));
                                }
                            }
                            //create aggregation between characters and account
                            foreach ($chars as $row2) {
                                $query_insert_aggr = mysqli_query($con, "INSERT INTO `trader`.`aggr` " . "(`idaggr`, " . "`user_iduser`, " . "`character_eve_idcharacter`) " . "VALUES " . "(NULL, " . "'{$last_id_user}', " . "'{$row2}');") or die(mysqli_error($con));
                            }
                            //check if everything is right before commit
                            if ($query_insert_user && $query_insert_apikey && $query_insert_character && $query_insert_aggr) {
                                mysqli_query($con, "COMMIT");
                                echo "Account created sucessfully" . "<br>" . "You may now login.";
                                echo "<br><br>";
                                $dt = new DateTime();
                                $tz = new DateTimeZone('Europe/Lisbon');
                                $dt->setTimezone($tz);
                                $datetime = $dt->format('Y-m-d H:i:s');
                                mysqli_query($con, "INSERT INTO `trader`.`log` (`idlog`, `user_iduser`, `type`, `datetime`) VALUES (NULL, '{$last_id_user}', 'register', '{$datetime}')") or die(mysqli_error($con));
                                redirect_login();
                            } else {
                                mysqli_query($con, "ROLLBACK");
                                echo "There was a problem creating your account. Try again.";
                                echo "<br>";
                                redirect_error();
                            }
                        }
                    }
                }
            }
        }
    } else {
        //first send validation
        if (!empty($_POST['Send'])) {
            $username = mysqli_real_escape_string($con, $_POST['username']);
            //password encryption
            $password1 = $_POST['password'];
            $password2 = $_POST['password2'];
            $cost = 10;
            // Create a random salt
            //$password1 = mysqli_real_escape_string($con,md5($_POST['password']));
            //$password2 = mysqli_real_escape_string($con,md5( $_POST['password2']));
            if ($password1 == $password2) {
                $pw_encr = $password1;
            }
            unset($_POST['password']);
            $apikey = mysqli_real_escape_string($con, $_POST['api']);
            $vcode = mysqli_real_escape_string($con, $_POST['vcode']);
            $reports = mysqli_real_escape_string($con, $_POST['reports']);
            $email = mysqli_real_escape_string($con, $_POST['email']);
            /*$pheal = new Pheal('4458709', 'vR9VUNKD3hSHD9KJRbTOUnPDiRC1Rb87ETUEbKsaxa4c9gXCtiNDNCPwKvdrt0tu');
              $result = $pheal->accountScope->APIKeyInfo();
                  foreach($result->key as $res) {echo $res->accessMask, $res->type;}
              */
            //Using CURL to fetch API Access Mask
            $curl_url = "https://api.eveonline.com/account/APIKeyInfo.xml.aspx?keyID=" . $apikey . "&vCode=" . $vcode;
            // create curl resource
            $ch = curl_init($curl_url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_HEADER, 0);
            // $response contains the XML response string from the API call
            $response = curl_exec($ch);
            // If curl_exec() fails/throws an error, the function will return false
            if ($response === false) {
                // Could add some 404 headers here
                echo 'Curl error: ' . curl_error($ch);
            } else {
                $apiInfo = new SimpleXMLElement($response);
                try {
                    checkXML($apiInfo->result->key);
                    $accessMask = (int) $apiInfo->result->key->attributes()->accessMask;
                } catch (Exception $e) {
                    echo 'Error: ' . $e->getMessage();
                    echo "<meta http-equiv='refresh' content='3;URL=register.php'>";
                    return;
                }
            }
            // close curl resource to free up system resources
            curl_close($ch);
            //***********SERVER VALIDATION #1***************
            //check if email is already taken
            $check_email = mysqli_query($con, "SELECT email FROM user WHERE email = '{$email}'") or die(mysqli_error($con));
            if (mysqli_num_rows($check_email) != 0) {
                echo "Email is already taken";
                redirect_error();
            } else {
                //check if access mask is correct
                if ($accessMask != '82317323' && $accessMask != '1073741823') {
                    echo "Your access mask is " . $accessMask . " which has different permissions than requested. Please <a href = 'https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=82317323' target='_blank'>create one here</a> with the correct permissions and <a href= 'register.php'>try again </a>.";
                } else {
                    //check if passwords match
                    if ($password1 != $password2) {
                        echo "Your passwords must match.";
                        redirect_error();
                    } else {
                        //check if username is already taken
                        $check_username = mysqli_query($con, "SELECT username FROM user WHERE username = '******'") or die(mysqli_error($con));
                        if (mysqli_num_rows($check_username) != 0) {
                            echo "Username is already taken";
                            redirect_error();
                        } else {
                            //check if API KEY is valid
                            echo "<b>Choose which characters to import:</b><br>";
                            //get character List from API KEY using Pheal
                            $pheal = new Pheal($apikey, $vcode);
                            $result = $pheal->accountScope->APIKeyInfo();
                            $count = 0;
                            echo "<table border ='1'>";
                            echo "<form action = {$_SERVER['PHP_SELF']} method = 'POST' >";
                            foreach ($result->key->characters as $character) {
                                $count = $count + 1;
                                echo "<tr><td>" . $character->characterName . "</td><td>" . "<img src='https://image.eveonline.com/Character/" . $character->characterID . "_64.jpg'" . "</td><td>" . "<input type = 'checkbox' name = 'char{$count}' value = '{$character->characterID}'>" . "</td></tr>";
                                //there is a KEY HEADER BEFORE THE CHARACTERS ROWSET
                            }
                            echo "</table><br>";
                            //rest of the parameters
                            echo "<input type ='hidden' name='username' value='{$username}'>";
                            echo "<input type ='hidden' name='password' value='{$pw_encr}'>";
                            echo "<input type ='hidden' name='api' value='{$apikey}'>";
                            echo "<input type ='hidden' name='vcode' value='{$vcode}'>";
                            echo "<input type ='hidden' name='reports' value='{$reports}'>";
                            echo "<input type ='hidden' name='email' value='{$email}'>";
                            echo "<input type ='Submit' name='Send_2' value ='Send' class='btn btn-lg btn-success btn-block'  />";
                            echo "</form>";
                        }
                    }
                }
            }
        } else {
            register_form();
        }
    }
}
コード例 #16
0
function api_val_form($character_get, $con)
{
    $activeUser = $_SESSION['user'];
    if (!empty($_POST['Send_2'])) {
        $apikey_final = mysqli_real_escape_string($con, $_POST['api']);
        $vcode_final = mysqli_real_escape_string($con, $_POST['vcode']);
        $chars = array();
        if (isset($_POST['char1'])) {
            $char1 = $_POST['char1'];
            array_push($chars, $char1);
        } else {
            $char1 = "";
        }
        if (isset($_POST['char2'])) {
            $char2 = $_POST['char2'];
            array_push($chars, $char2);
        } else {
            $char2 = "";
        }
        if (isset($_POST['char3'])) {
            $char3 = $_POST['char3'];
            array_push($chars, $char3);
        } else {
            $char3 = "";
        }
        //$chars = array($char1,$char2,$char3);
        //FINAL SERVER VALIDATION #2 (just in case someone sneaks in HTML5)
        //check if characters belong to API KEY by intersecting both arrays
        $pheal2 = new Pheal($apikey_final, $vcode_final);
        $chars_api = array();
        $chars_name = array();
        $empty = array();
        $result2 = $pheal2->accountScope->APIKeyInfo();
        foreach ($result2->key->characters as $character) {
            array_push($chars_api, $character->characterID);
            array_push($chars_name, $character->characterName);
        }
        if (array_intersect(array_diff($chars, $chars_api), $chars_api) != $empty) {
            echo "Character does not belong to Eve account";
            failed_validation_2();
        } else {
            $query_insert_apikey = mysqli_query($con, "insert ignore INTO `trader`.`api` (`apikey`, `vcode`) " . "VALUES " . "('{$apikey_final}', " . "'{$vcode_final}');") or die(mysqli_error($con));
            //  print_r($chars);
            $pheal3 = new Pheal($apikey_final, $vcode_final, "char");
            foreach ($chars as $row) {
                $row;
                $response_final = $pheal3->CharacterSheet(array("characterID" => $row));
                $name_char = mysqli_real_escape_string($con, $response_final->name);
                $activeUserID = utils::mysqli_result(mysqli_query($con, "SELECT iduser FROM user WHERE username = '******'"), 0, 0);
                $check_existing_character_user = mysqli_query($con, "SELECT * FROM aggr WHERE character_eve_idcharacter = '{$row}'") or die(mysqli_error($con));
                if (mysqli_num_rows($check_existing_character_user) != 1) {
                    $query_insert_character = mysqli_query($con, "replace INTO `trader`.`characters` " . "(`eve_idcharacter`, " . "`name`, " . "`balance`, " . "`api_apikey`," . "`networth`," . "`escrow`," . "`total_sell`," . "`broker_relations`," . "`accounting`) " . "VALUES " . "({$row}, " . "'{$name_char}', " . "'0', " . "'{$apikey_final}'," . "'0'," . "'0'," . "'0'," . "'0'," . "'0');") or die(mysqli_error($con));
                } else {
                    //check if one of the provided characters already exists in the DB. We don't allow for this.
                    $checkExistingCharacter = mysqli_query($con, "SELECT name FROM v_user_characters WHERE character_eve_idcharacter IN (" . implode(",", $chars) . ") AND username != '{$activeUser}'") or die(mysqli_error($con));
                    if (mysqli_num_rows($checkExistingCharacter) > 0) {
                        $duplicates = array();
                        while ($existing_characters = mysqli_fetch_array($checkExistingCharacter)) {
                            array_push($duplicates, $existing_characters['name']);
                        }
                        echo implode(" and ", $duplicates) . " already belong to another account.";
                        echo "<meta http-equiv='refresh' content='3;URL=api_add.php?character={$character_get}'>";
                        return;
                    } else {
                        echo "Character(s) already belongs to this account";
                        echo "<meta http-equiv='refresh' content='3;URL=api_add.php?character={$row}'>";
                        return;
                    }
                }
            }
            // echo $activeUser;
            //create aggregation between characters and account
            foreach ($chars as $row2) {
                //check if the character number has been exceeded
                echo $character_count = utils::mysqli_result(mysqli_query($con, "SELECT COUNT(character_eve_idcharacter) " . "FROM aggr " . "WHERE user_iduser = "******"(SELECT iduser FROM user WHERE username = '******') "), 0, 0);
                if ($character_count >= 10) {
                    echo "You have exceeded your character limit (currently 10)";
                    echo "<meta http-equiv='refresh' content='3;URL=api_add.php?character={$character_get}'>";
                    return;
                }
                $query_insert_aggr = mysqli_query($con, "INSERT IGNORE INTO `trader`.`aggr` " . "(`idaggr`, " . "`user_iduser`, " . "`character_eve_idcharacter`) " . "VALUES " . "(NULL, " . "'{$activeUserID}', " . "'{$row2}');") or die(mysqli_error($con));
            }
            //check if everything is right before commit
            if ($query_insert_apikey && $query_insert_character && $query_insert_aggr) {
                mysqli_query($con, "COMMIT");
                echo "API added successfully." . "<br>" . "You will now logoff so we can update your new character data. <br>";
                session_destroy();
                echo "<meta http-equiv='refresh' content='5;URL=login.php'>";
            } else {
                mysqli_query($con, "ROLLBACK");
                echo "error";
            }
        }
    }
    if (!empty($_POST['Send'])) {
        $apikey = mysqli_real_escape_string($con, $_POST['api']);
        $vcode = mysqli_real_escape_string($con, $_POST['vcode']);
        //Using CURL to fetch API Access Mask
        $curl_url = "https://api.eveonline.com/account/APIKeyInfo.xml.aspx?keyID=" . $apikey . "&vCode=" . $vcode;
        // create curl resource
        $ch = curl_init($curl_url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        // $response contains the XML response string from the API call
        $response = curl_exec($ch);
        // If curl_exec() fails/throws an error, the function will return false
        if ($response === false) {
            // Could add some 404 headers here
            echo 'Curl error: ' . curl_error($ch);
        } else {
            $apiInfo = new SimpleXMLElement($response);
            try {
                checkXML($apiInfo->result->key);
                $accessMask = (int) $apiInfo->result->key->attributes()->accessMask;
            } catch (Exception $e) {
                echo 'Error: ' . $e->getMessage();
                echo "<meta http-equiv='refresh' content='3;URL=api_add.php?character={$character_get}'>";
                return;
            }
        }
        //var_dump($apiInfo->result->key);
        // close curl resource to free up system resources
        curl_close($ch);
        if ($accessMask != '82317323' && $accessMask != '1073741823') {
            echo "Your access mask is " . $accessMask . " which has different permissions than requested. Please <a href = 'https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=82317315' target='_blank'>create one here</a> with the correct permissions and <a href= 'api_add?character?={$character_get}.php'>try again </a>.";
        } else {
            echo "<b>Choose which characters to import:</b><br>";
            //get character List from API KEY using Pheal
            $pheal = new Pheal($apikey, $vcode);
            $result = $pheal->accountScope->APIKeyInfo();
            $count = 0;
            echo "<table class='table table-striped table-bordered table-hover' id='dataTables-api'>";
            echo "<form action = 'api_add.php?character={$character_get}' method = 'POST' >";
            foreach ($result->key->characters as $character) {
                $count = $count + 1;
                echo "<tr><td>" . "<img src='https://image.eveonline.com/Character/" . $character->characterID . "_64.jpg'" . "</td><td>" . $character->characterName . "</td><td>" . "<input type = 'checkbox' name = 'char{$count}' value = '{$character->characterID}'>" . "</td></tr>";
                //there is a KEY HEADER BEFORE THE CHARACTERS ROWSET
            }
            echo "</table><br>";
            //rest of the parameters
            echo "<input type ='hidden' name='api' value='{$apikey}'>";
            echo "<input type ='hidden' name='vcode' value='{$vcode}'>";
            echo "<input type ='Submit' name='Send_2' value ='Send' class='btn btn-lg btn-success btn-block'  />";
            echo "</form>";
        }
    } else {
        api_add_form($character_get);
    }
}
コード例 #17
0
<?php

require 'includes/config.php';
use Pheal\Pheal;
use Pheal\Core\Config;
Config::getInstance()->cache = new \Pheal\Cache\MemcacheStorage();
Config::getInstance()->access = new \Pheal\Access\StaticCheck();
$pheal = new Pheal('', '', 'eve');
$allianceLookup = $pheal->AllianceList(array());
$stmt = $db->prepare('INSERT INTO eve_alliance_list (alliance_name,alliance_id,alliance_short_name) VALUES (?,?,?) ON DUPLICATE KEY UPDATE alliance_name=VALUES(alliance_name)');
foreach ($allianceLookup->alliances as $alliance) {
    $stmt->execute(array($alliance->name, $alliance->allianceID, $alliance->shortName));
}
echo "Alliance List Updated.";