Exemple #1
0
 function execute()
 {
     if (Config::lpStoreRedis) {
         $key = get_class() . ':' . $this->typeID . ',' . $this->qty;
         $cache = json_decode($this->bpcCache->get($key), true);
         if (empty($cache) || empty($cache['manDetails']) || $cache['version'] != Db::$dbName) {
             $cache = array('version' => Db::$dbName, 'manDetails' => $this->performQuery());
             $this->bpcCache->set($key, json_encode($cache));
         }
     } else {
         $cache = array('version' => Db::$dbName, 'manDetails' => $this->performQuery());
     }
     # set price info for manufacturing materials
     foreach ($cache['manDetails'] as &$manItem) {
         try {
             $price = new Price(Emdr::get($manItem['typeID']));
             $manItem['price'] = $price->{Prefs::get('marketMat')}[0];
             $manItem['totPrice'] = $manItem['price'] * $manItem['totQty'];
         } catch (Exception $e) {
             array_push($this->noCache, $manItem['typeName']);
         }
     }
     return $cache['manDetails'];
 }
Exemple #2
0
// comment this out for local debug copy
require_once 'Savant3.php';
# taken from http://stackoverflow.com/a/12583387/788054
# TBS cannot use DEFINE(), so these are variables
define('ABS_PATH', str_replace('\\', '/', dirname(__FILE__)) . '/');
define('BASE_PATH', '/' . substr(dirname(__FILE__), strlen($_SERVER['DOCUMENT_ROOT'])) . '/');
# to be deprecated - currently strongly discouraged in official documentation -gg
#function __autoload($class) {
#   require_once('lib/' . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php');
#}
# new style using spl_autoload_register:
spl_autoload_register(function ($class) {
    require_once 'lib/' . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
});
Emdr::$regions = json_decode(file_get_contents(ABS_PATH . '/emdr/regions.json'), true);
Prefs::getInstance();
$tpl = new Savant3();
$tpl->addPath('template', 'templates/bootstrap');
$tpl->addPath('resource', 'lib');
$tpl->siteTime = new Timer();
$tpl->emdrDown = false;
# https://forums.eveonline.com/default.aspx?g=posts&m=2508255
$regions = json_decode(file_get_contents(dirname(__FILE__) . '/emdr/regions.json'), true);
Emdr::setRegion(Prefs::get('region'));
# If price of Tritanium is more than 12 hours old, then something has happened with EMDR consumer
# Set template variable to display warning to user when this happens
if (time() - (new Price(Emdr::get(34)))->generatedAt > 60 * 60 * 12) {
    $tpl->emdrDown = true;
}
$tpl->webkitFix = preg_match("#.+WebKit/(\\H+)+\\s.+?#s", $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 535 ? true : false;
Exemple #3
0
 private function bpcCalc()
 {
     if (!$this->bpc) {
         return;
     }
     # Something's gone wrong, don't do this if not a BPC
     # Do this in template
     // $name =  "1 x ".$offer['typeName']." Copy (".$offer['quantity']." run".($offer['quantity'] > 1 ? "s" : null).")";
     $this->manTypeID = Db::qColumn('
         SELECT `productTypeID`
         FROM `industryActivityProducts`
         WHERE `typeID` = :typeID
         AND `activityID` = 1', array(':typeID' => $this->offerDetails['typeID']));
     # set pricing info per the manufactured item
     try {
         $price = new Price(Emdr::get($this->manTypeID));
         $this->cached = true;
         $this->price = $price->{Prefs::get('marketOffer')}[0];
         $this->totVolume = $price->{Prefs::get('marketOffer')}[1];
         $this->timeDiff = (time() - $price->generatedAt) / 60 / 60;
         # time difference in hours
     } catch (Exception $e) {
         array_push($this->noCache, $this->offerDetails['typeName']);
     }
     # find cached result of BPC manufacturing materials
     $this->manDetails = (new Query_OfferMaterials($this->offerDetails['typeID'], $this->offerDetails['quantity']))->execute();
     # set market group to BPs (doesn't happen automatically since you can't find LP Store BPs on market)
     $this->offerDetails['marketRoot'] = '2';
 }