Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemKo7v committed Feb 24, 2017
2 parents 62a03d3 + a4d6761 commit ded009f
Show file tree
Hide file tree
Showing 49 changed files with 4,894 additions and 1,729 deletions.
23 changes: 11 additions & 12 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
DirectoryIndex page568524.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/(.*) api/index.php [L,QSA]
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^last$ page627123.html
RewriteRule ^top$ page627210.html
RewriteRule ^about$ page627364.html
RewriteRule ^privacy$ page627373.html

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^tx/(.*) index.html [L,QSA]

RewriteRule ^widgets$ widgets.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^address/(.*) index.html [L,QSA]
RewriteRule ^tx/(.*) index.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^search/(.*) index.html [L,QSA]
RewriteRule ^address/(.*) index.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.htm [L,QSA]

RewriteRule ^$ index.htm [L,QSA]
RewriteRule ^search/(.*) index.php [L,QSA]
1 change: 0 additions & 1 deletion 404.html

This file was deleted.

24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
# Ethplorer

Ethereum tokens and transactions viewer.
Ethereum tokens viewer.

View tokens developed with Ethereum's [ERC20 (before known as EIP20)](https://github.com/ethereum/EIPs/issues/20) standard.
Easy to view tokens and custom data. Users first.

Explore sender, receiver and amount of transaction in token units.
Support tokens developed with Ethereum's [ERC20 (before known as EIP20)](https://github.com/ethereum/EIPs/issues/20) standard.

Provides API, Widgets for websites.

[Online version at Ethplorer.io](https://ethplorer.io)

![alt tag](https://github.com/EverexIO/Ethplorer/blob/develop/images/ethplorer-home2.png)


# Widgets for third-party websites
![alt tag](https://github.com/EverexIO/Ethplorer/blob/develop/images/augur-widget.png)

[Samples and instructions for widget usage] (http://ethplorer.io/widgets)


# API

Documentation available at [WIKI pages ](https://github.com/EverexIO/Ethplorer/wiki/ethplorer-api).


# Installation

Clone repository into separate webserver's directory.
Expand All @@ -21,6 +36,7 @@ git clone https://github.com/everexio/ethplorer.git ethplorer

Make sure your web server supports .htaccess and mod_rewrite.


# Configure

Copy cfg/config.ethplorer.sample.js to cfg/config.ethplorer.js and specify service addresses.
Copy service/config.sample.php to service/config.php and specify service addresses.
124 changes: 0 additions & 124 deletions about.html

This file was deleted.

59 changes: 51 additions & 8 deletions api/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ethplorerController {
protected $db;
protected $command;
protected $params = array();
protected $apiCommands = array('getTxInfo', 'getTokenHistory', 'getAddressInfo', 'getTokenInfo', 'getAddressHistory');
protected $apiCommands = array('getTxInfo', 'getTokenHistory', 'getAddressInfo', 'getTokenInfo', 'getAddressHistory', 'getTopTokens', 'getTokenHistoryGrouped');
protected $defaults;

public function __construct($es){
Expand Down Expand Up @@ -80,16 +80,17 @@ public function sendError($code, $message){
* @return void
*/
public function run(){
$result = FALSE;
$command = $this->getCommand();
if($command && in_array($command, $this->apiCommands) && method_exists($this, $command)){
$key = $this->getRequest('apiKey', FALSE);
if(!$key || !$this->db->checkAPIkey($key)){
$this->sendError(1, 'Invalid API key');
}
$this->defaults = $this->db->getAPIKeyDefaults($key, $this->getCommand());
$result = call_user_func(array($this, $this->getCommand()));
$this->sendResult($result);
$this->defaults = $this->db->getAPIKeyDefaults($key, $command);
$result = call_user_func(array($this, $command));
}
return $result;
}

/**
Expand All @@ -98,7 +99,8 @@ public function run(){
* @return array
*/
public function getTokenInfo(){
$address = $this->getParam(0, FALSE);
$address = $this->getParam(0, '');
$address = strtolower($address);
if((FALSE === $address)){
$this->sendError(103, 'Missing address');
}
Expand All @@ -123,7 +125,8 @@ public function getTokenInfo(){
* @return array
*/
public function getAddressInfo(){
$address = $this->getParam(0, FALSE);
$address = $this->getParam(0, '');
$address = strtolower($address);
$onlyToken = $this->getRequest('token', FALSE);
if((FALSE === $address)){
$this->sendError(103, 'Missing address');
Expand Down Expand Up @@ -189,7 +192,8 @@ public function getAddressInfo(){
* @return array
*/
public function getTxInfo(){
$txHash = $this->getParam(0, FALSE);
$txHash = $this->getParam(0, '');
$txHash = strtolower($txHash);
if((FALSE === $txHash)){
$this->sendError(101, 'Missing transaction hash');
}
Expand Down Expand Up @@ -261,6 +265,40 @@ public function getAddressHistory(){
return $this->_getHistory(TRUE);
}

/**
* /getTopTokens method implementation.
*
* @undocumented
* @return array
*/
public function getTopTokens(){
$maxLimit = is_array($this->defaults) && isset($this->defaults['maxLimit']) ? $this->defaults['maxLimit'] : 50;
$maxPeriod = is_array($this->defaults) && isset($this->defaults['maxPeriod']) ? $this->defaults['maxPeriod'] : 90;
$limit = min(abs((int)$this->getRequest('limit', 10)), $maxLimit);
$period = min(abs((int)$this->getRequest('period', 10)), $maxPeriod);
$result = array('tokens' => $this->db->getTopTokens($limit, $period));
$this->sendResult($result);
}

/**
* /getTokenHistoryGrouped method implementation.
*
* @undocumented
* @return array
*/
public function getTokenHistoryGrouped(){
$period = min(abs((int)$this->getRequest('period', 30)), 90);
$address = $this->getParam(0, FALSE);
if($address){
$address = strtolower($address);
if(!$this->db->isValidAddress($address)){
$this->sendError(104, 'Invalid token address format');
}
}
$result = array('countTxs' => $this->db->getTokenHistoryGrouped($period, $address));
$this->sendResult($result);
}

/**
*
* Common method to get token and address operation history.
Expand All @@ -281,10 +319,15 @@ protected function _getHistory($addressHistoryMode = FALSE){
}
$maxLimit = is_array($this->defaults) && isset($this->defaults['limit']) ? $this->defaults['limit'] : 10;
$options = array(
'address' => $address,
'type' => $this->getRequest('type', FALSE),
'limit' => min(abs((int)$this->getRequest('limit', 10)), $maxLimit),
);
if(FALSE !== $address){
$options['address'] = $address;
}
if(FALSE !== $this->getRequest('timestamp', FALSE)){
$options['timestamp'] = (int)$this->getRequest('timestamp');
}
if($addressHistoryMode){
$token = $this->getRequest('token', FALSE);
if(FALSE !== $token){
Expand Down
20 changes: 5 additions & 15 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,10 @@
}

$ctr = new ethplorerController($es);
$ctr->run();
$result = $ctr->run();

$result = array();
$command = $ctr->getCommand();

switch($command){
case 'last':
$options = array(
'limit' => isset($_GET["limit"]) ? (int)$_GET["limit"] : 10,
'timestamp' => isset($_GET["timestamp"]) ? (int)$_GET["timestamp"] : 0,
);
$result = $es->getLastTransfers($options);
break;
default:
$ctr->sendError(17, 'Invalid request, check API manual there: https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API');
if(!$result){
$ctr->sendError(17, 'Invalid request, check API manual there: https://github.com/EverexIO/Ethplorer/wiki/Ethplorer-API');
}
$ctr->sendResult($result);

$ctr->sendResult($result);
Loading

0 comments on commit ded009f

Please sign in to comment.