Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Just pass your serial and restore code on the command line :

I'm using this on a little project of mine, an [Online Authenticator for Battle.Net](http://authenticator.me). It is actually in Beta, but I'm planning on launching it soon.

<a href='https://github.com/ymback'>ymback</a> has created a <a href='https://github.com/ymback/Battle.net-Authenticator-Online'>repo</a>, using this as a library on his [Battle.Net Authenticator Online](https://myauth.us). A Chinese-based website.

# Todo

* Sanitize inputs
Expand Down
14 changes: 11 additions & 3 deletions classes/Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Authenticator {
/**
* @var string format for the Battle.Net servers, %s must be replaced by the region
*/
static private $server = 'mobile-service.blizzard.com';
static private $server = array('eu.battle.net','us.battle.net', 'www.battlenet.com.cn');

/**
* @var string URI used for initialization
Expand Down Expand Up @@ -177,7 +177,7 @@ public function waitingtime() {
* @return int elapsed time in milliseconds
*/
public function elapsedtime() {
return ($this->servertime() % $this->waitingtime());
return fmod(floatval($this->servertime()),$this->waitingtime());
}

/**
Expand Down Expand Up @@ -292,7 +292,15 @@ private function set_secret($secret) {
* @return string The server address
*/
private function server() {
return sprintf(self::$server, strtolower($this->region()));
switch($this->region()){
case self::$accepted_region[0]:
return self::$server[0];
case self::$accepted_region[1]:
return self::$server[1];
case self::$accepted_region[2]:
return self::$server[2];
}
throw new DataAuthenticatorException('Invalid region provided : '.$this->region().'.');
}

// </editor-fold>
Expand Down