Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from steemnova/master
Browse files Browse the repository at this point in the history
This is a test
  • Loading branch information
antonmosich authored Mar 19, 2018
2 parents b6a6ebb + 984d89e commit b12da2c
Show file tree
Hide file tree
Showing 407 changed files with 2,771 additions and 785 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ SteemNova expansion goes as follows:

- Clone the repo: `git clone https://github.com/steemnova/steemnova`
- Install components: `apt-get install apache2 php7.0 php7.0-gd php7.0-fpm php7.0-mysql libapache2-mod mysql-server`
- Install [php-ds extension](https://github.com/php-ds/extension)
- `apt-get install php-pear php7.0-dev`
- pecl install ds
- create file `30-ds.ini` with content `extension=ds.so` and put in `/etc/php/7.0/apache2/conf.d/` [source](https://github.com/php-ds/extension/issues/2#issuecomment-181855047)
- Setup mysql: `create user USER identified by PASSWORD; create database DB; grant all privileges on DB.* to USER;`
- Set write privileges to dirs: `cache/`, `includes/`
- Run wizard: `127.0.0.1/install/install.php`
Expand Down
10 changes: 5 additions & 5 deletions includes/classes/Database.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* 2Moons
* 2Moons
* by Jan-Otto Kröpke 2009-2016
*
* For the full copyright and license information, please view the LICENSE
Expand Down Expand Up @@ -88,7 +88,7 @@ public function rowCount()
{
return $this->rowCount;
}

protected function _query($qry, array $params, $type)
{
if (in_array($type, array("insert", "select", "update", "delete", "replace")) === false)
Expand All @@ -98,7 +98,7 @@ protected function _query($qry, array $params, $type)

$this->lastInsertId = false;
$this->rowCount = false;

$qry = str_replace($this->dbTableNames['keys'], $this->dbTableNames['names'], $qry);

/** @var $stmt PDOStatement */
Expand Down Expand Up @@ -203,7 +203,7 @@ public function selectSingle($qry, array $params = array(), $field = false)
$res = $stmt->fetch(PDO::FETCH_ASSOC);
return ($field === false || is_null($res)) ? $res : $res[$field];
}

/**
* Lists column values of a table
* with desired key from the
Expand All @@ -217,7 +217,7 @@ public function selectSingle($qry, array $params = array(), $field = false)
public function lists($table, $column, $key = null)
{
$selects = implode(', ', is_null($key) ? array($column) : array($column, $key));

$qry = "SELECT {$selects} FROM %%{$table}%%;";
$stmt = $this->_query($qry, array(), 'select');

Expand Down
49 changes: 30 additions & 19 deletions includes/classes/Language.class.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* 2Moons
* 2Moons
* by Jan-Otto Kröpke 2009-2016
*
* For the full copyright and license information, please view the LICENSE
Expand All @@ -19,7 +19,7 @@ class Language implements ArrayAccess {
private $container = array();
private $language = array();
static private $allLanguages = array();

static function getAllowedLangs($OnlyKey = true)
{
if(empty(self::$allLanguages))
Expand All @@ -28,7 +28,7 @@ static function getAllowedLangs($OnlyKey = true)
$cache->add('language', 'LanguageBuildCache');
self::$allLanguages = $cache->getData('language');
}

if($OnlyKey)
{
return array_keys(self::$allLanguages);
Expand All @@ -38,7 +38,7 @@ static function getAllowedLangs($OnlyKey = true)
return self::$allLanguages;
}
}

public function getUserAgentLanguage()
{
if (isset($_REQUEST['lang']) && in_array($_REQUEST['lang'], self::getAllowedLangs()))
Expand All @@ -47,13 +47,13 @@ public function getUserAgentLanguage()
$this->setLanguage($_REQUEST['lang']);
return true;
}

if ((MODE === 'LOGIN' || MODE === 'INSTALL') && isset($_COOKIE['lang']) && in_array($_COOKIE['lang'], self::getAllowedLangs()))
{
$this->setLanguage($_COOKIE['lang']);
return true;
}

if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
return false;
Expand All @@ -80,18 +80,18 @@ public function getUserAgentLanguage()
break;
}
}

HTTP::sendCookie('lang', $language, 2147483647);
$this->setLanguage($language);

return $language;
}

public function __construct($language = NULL)
{
$this->setLanguage($language);
}

public function setLanguage($language)
{
if(!is_null($language) && in_array($language, self::getAllowedLangs()))
Expand All @@ -107,16 +107,16 @@ public function setLanguage($language)
$this->language = DEFAULT_LANG;
}
}

public function addData($data) {
$this->container = array_replace_recursive($this->container, $data);
}

public function getLanguage()
{
return $this->language;
}

public function getTemplate($templateName)
{
if(file_exists('language/'.$this->getLanguage().'/templates/'.$templateName.'.txt'))
Expand All @@ -128,13 +128,24 @@ public function getTemplate($templateName)
return '### Template "'.$templateName.'" on language "'.$this->getLanguage().'" not found! ###';
}
}

public function includeData($files)
{
// Fixed BOM problems.
ob_start();
$LNG = array();

//FALLBACK
$path = 'language/en/';
foreach($files as $file) {
$filePath = $path.$file.'.php';
if(file_exists($filePath))
{
require $filePath;
}
}

//LANGUAGE
$path = 'language/'.$this->getLanguage().'/';

foreach($files as $file) {
Expand All @@ -151,26 +162,26 @@ public function includeData($files)

$this->addData($LNG);
}

/** ArrayAccess Functions **/

public function offsetSet($offset, $value) {
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}

public function offsetExists($offset) {
return isset($this->container[$offset]);
}

public function offsetUnset($offset) {
unset($this->container[$offset]);
}

public function offsetGet($offset) {
return isset($this->container[$offset]) ? $this->container[$offset] : $offset;
}
}
}
8 changes: 4 additions & 4 deletions includes/classes/Session.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ public function delete()

public function isValidSession()
{
if($this->compareIpAddress($this->data['userIpAddress'], self::getClientIp(), COMPARE_IP_BLOCKS) === false)
{
return false;
}
// if($this->compareIpAddress($this->data['userIpAddress'], self::getClientIp(), COMPARE_IP_BLOCKS) === false)
// {
// return false;
// }

if($this->data['lastActivity'] < TIMESTAMP - SESSION_LIFETIME)
{
Expand Down
4 changes: 3 additions & 1 deletion includes/classes/class.BuildFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ public static function getBuildingTime($USER, $PLANET, $Element, $elementPrice =
$time = $elementCost / ($config->game_speed * (1 + $PLANET[$resource[21]])) * pow(0.5, $PLANET[$resource[15]]) * (1 + $USER['factor']['ShipTime']);
} elseif (in_array($Element, $reslist['defense'])) {
$time = $elementCost / ($config->game_speed * (1 + $PLANET[$resource[21]])) * pow(0.5, $PLANET[$resource[15]]) * (1 + $USER['factor']['DefensiveTime']);
} elseif (in_array($Element, $reslist['missile'])) {
$time = $elementCost / ($config->game_speed * (1 + $PLANET[$resource[21]])) * pow(0.5, $PLANET[$resource[15]]) * (1 + $USER['factor']['DefensiveTime']);
} elseif (in_array($Element, $reslist['tech'])) {
if(is_numeric($PLANET[$resource[31].'_inter']))
{
Expand Down Expand Up @@ -268,4 +270,4 @@ public static function getAvalibleBonus($Element)

return $elementBonus;
}
}
}
Loading

0 comments on commit b12da2c

Please sign in to comment.