Commit Graph

101 Commits

Author SHA1 Message Date
Guangcong Luo
86a55ee61e Fix minor bug in dispatcher 2019-01-05 04:04:10 -05:00
Guangcong Luo
5b21cce99a Improve action.php
POSTing JSON data is now supported, since apparently Axios does that by
default: #1160

In addition, error messages should be more informative, for anyone else
trying to write a third-party client.
2018-11-14 21:49:40 -05:00
Guangcong Luo
a133ee8c5e Fix some bugs caught by LGTM 2018-09-05 16:48:27 -05:00
Guangcong Luo
8562b2f090 Fix misc bugs 2018-08-26 16:18:06 -04:00
Guangcong Luo
6e7b3b6d5c Update Google Auth Library dependency 2018-05-19 19:30:51 -04:00
The Immortal
db0b7b3684
Update decay for Random Battle and OU 2018-03-22 00:33:38 +08:00
Guangcong Luo
f07fad8aaa Improve login session ID system 2017-11-23 01:31:37 -05:00
Guangcong Luo
2dc0f28e78 Use Node library for Google token validation
After lots of tries, the PHP code just couldn't be made to work...
2017-11-17 20:21:24 -05:00
Guangcong Luo
9e35550fc8 Try to fix Google login
Honestly, I have no clue at this point, but setting the PHP timezone to
UTC seems to fix most of the login bugs I've been seeing.
2017-10-29 21:16:05 -04:00
Guangcong Luo
a0570290a8 Fix timezone for Google login validation 2017-10-21 13:10:44 -04:00
Guangcong Luo
6f841a70a3 Fix crash in Google login verification 2017-10-10 23:05:42 -04:00
Guangcong Luo
ab657d2511 Include server ID in replay data
This is to help the replay server determine how much to trust the info
uploaded.
2017-10-10 23:04:51 -04:00
Guangcong Luo
644d5ccf91 Support Google login (two-factor auth) (#999)
This doesn't support setting accounts up for Google login: that still
has to be manually done via the database by setting the email field to
`username@gmail.com@`, where the second `@` denotes that it's using
Gmail login.

If the email field does end in `@`, `getassertion` will note this by
sending `;;@gmail`, to convey that the server is expecting a Google
login token rather than a password.

Upon receiving `;;@gmail`, the client will replace the password box will
with a Google login button, and then send the resulting Google login
token to the server in the `password` field. The server will validate
the "password" using the Google server libraries, and otherwise handle
the login as normal.

Note that Google login requires various features that a paranoid person
might disable; most notably 3rd-party cookies.

Fixes Zarel/Pokemon-Showdown#3394
2017-09-13 16:20:38 -04:00
Guangcong Luo
fceb63c0ee Ladder: Support "both players lose"
Send -1 as the score to mean "both players lose"
2017-07-28 23:09:10 -04:00
Guangcong Luo
0b153268e9 Clarify disabled account message 2017-07-20 20:59:33 -04:00
Sacha Reinert
a6e7db9b89 Use Wikimedia's css sanitizer for custom css parsing (#919) 2017-06-13 23:26:15 -05:00
Guangcong Luo
c0efe4e0a3 Update sim server URL 2017-05-15 05:55:08 -04:00
Guangcong Luo
c5bc304522 Fix style in session library 2017-03-25 14:15:30 -04:00
Guangcong Luo
a7b45d7430 Fix security vulnerability in register 2017-03-13 02:29:09 -04:00
Guangcong Luo
c91cb4d57e Consistently transform new challenge token 2017-01-22 03:17:47 -05:00
Guangcong Luo
f229736b4d Finish converting session lib to prepared statements 2016-12-11 05:34:52 -05:00
Guangcong Luo
0ae5999701 Fix UTF-8 support in database 2016-11-04 05:39:27 -04:00
Guangcong Luo
638c117db0 Refactor database to use prepared statements
Prepared statements are much better than manually constructing queries,
but PHP's MySQLi prepared statement syntax sucks.

So does PDO's, but we're abstracting it out so we can make it not suck,
and give it the syntax it should always have had. Which is what this
does.

Yay, finally.
2016-10-20 21:12:06 -04:00
Guangcong Luo
fc547732a6 Refactor ntbb-database to PDO
A hack is required to keep Database::escape's API the same, but
otherwise this API lends itself to having the internals swapped out
surprisingly well.
2016-10-20 20:34:52 -04:00
Guangcong Luo
9ea444aeea Fix bugs/crashes in ntbb-session 2016-10-20 20:34:07 -04:00
Guangcong Luo
82e7a917ab Move session library inside repository
For too long, ntbb-session and ntbb-database have been maintained
outside of this repo, but no longer! All these files are now part of the
repository, making it significantly more self-contained.

If I had to say why it took this long, I think it was mostly inertia. It
was easier leaving them where they were than having to audit them for
private keys in the wrong places, etc.

I'm starting to think of PS more as sim first, website secondary than
the other way around, now. Especially now that we don't have a forum,
the website itself isn't really important... Maybe one day I'll get rid
of the landing page and make the sim itself the first thing you see when
you hit pokemonshowdown.com... but today is not that day!

The repo is still not "batteries-included" since I am not going to teach
anyone how to set up PHP and MySQL or even get the config files working.
But for anyone who wanted their own client, well, it gets a lot easier
to do now.
2016-10-20 13:16:06 -04:00
Guangcong Luo
898debcd09 Update ntbb_ladder.sql 2016-03-18 11:43:04 -04:00
Guangcong Luo
ecafe4b779 Save name capitalization changes
Name capitalization and spacing used to reset to their previous value
on login. Changes are now stored long-term.
2016-03-08 05:08:26 -05:00
Guangcong Luo
abc4902d34 Make less popular ladders decay slower 2016-02-28 01:57:25 -05:00
Guangcong Luo
5ca5448ed2 Fix Elo rating decay 2016-02-16 20:00:13 -05:00
Guangcong Luo
7d2ec99067 Don't check IPs for token-auth
Allows login server requests from non-matching IPs to go through when
the request is using token auth.

Affects certain request-proxying Node hosts such as c9.
2016-01-25 03:32:25 -05:00
Guangcong Luo
15e6d69fac Slightly more helpful error message in action.php 2016-01-16 04:14:13 -05:00
Guangcong Luo
09fa73f719 Remove serverid from NTBBLadder constructor
NTBBLadder no longer supports alternate servers, making it unnecessary.
2015-12-31 00:34:54 -05:00
Guangcong Luo
dd4e9ae51c Support ladder resets
A lot of this stuff involves the website itself, but this part is
the part contained in the client.
2015-12-31 00:33:47 -05:00
Guangcong Luo
fe38cc3ead More consistent CORS support 2015-11-26 03:53:56 -05:00
Guangcong Luo
bc8daf62e4 Ladder refactor 2015-11-25 17:36:28 -05:00
Guangcong Luo
3f8ffa684f Support new challstr protocol
See Zarel/Pokemon-Showdown@d5c622b493

New system is backwards-compatible with old one. This also slightly
refactors some other stuff, for an overall simpler system.
2015-06-28 00:50:17 -04:00
Guangcong Luo
4c35e2041a Change rating period advance time
Instead of advancing rating periods at midnight GMT, they're now
advanced at 9:00 GMT, which corresponds to 1am-4am in the US.
2014-09-25 16:43:10 -05:00
Guangcong Luo
f525c08b49 Fix support for autodetecting server for ladders 2014-04-11 02:51:44 -05:00
Guangcong Luo
4f3f526c61 Fix crash in IP reporter 2014-04-02 22:58:13 -05:00
Guangcong Luo
6f14a44b55 Report IPs from unregistered servers
Right now, unregistered servers often get unclear error messages
about why laddering and replay saving doesn't work. This commit
attempts to clarify those error messages.

In addition, servers that make requests from different IPs from
their registered IP didn't have an easy way to fix. Reporting
IPs should make it clearer which IP they need to register.
2014-04-02 00:39:16 -05:00
Guangcong Luo
da74983e9c Ladder: Tweak decay
Decay how happens half as fast on days where players have played at
least one game.
2014-03-01 16:19:42 -06:00
Guangcong Luo
e04eb7d113 Rating decay and other ladder tweaks
We now have a rating decay of -1/day at 1400, -2/day at 1450, -3/day
at 1500, etc. This roughly translates to a fall from the top of OU to
the bottom over a month of full inactivity, which is somewhat harsh
considering it's done regardless of inactivity. I might tweak this to
be less harsh later.

There's no rating decay below 1400. People can stay there as long as
they want.

The only other tweak is that K is now 40 at >1300 instead of >1400.
Very very slight tweak so that ratings in the 1300-1500 range are
very very slightly more precise.
2014-02-27 19:32:18 -06:00
Guangcong Luo
585e82c26d Ladder: Dynamic K-factor
We are now attempting to enforce a center at 1100 (tentative, may move
to 1200 later) by increasing points gained for winning and decreasing
points lost for losing below that. This will make a user with equal
wins/losses higher than a user who consistently loses.

The other change is to scale K down at higher ratings. >1400 now uses
K=40, and >1600 uses K=32. This is a really conservative scale, and
we might make it less conservative later.

STAY TUNED!
COMING UP NEXT: rating decay
2014-02-12 13:00:09 -06:00
Guangcong Luo
eb102e5474 Add COIL/ARMS to ladders 2014-01-23 12:18:22 -06:00
Guangcong Luo
3aa5c6825e Replace Glicko-2 with Glicko-1 2014-01-16 00:23:37 -06:00
Guangcong Luo
726709c2fb Fix Glicko updating with provisional rating 2014-01-15 12:37:08 -06:00
Guangcong Luo
096047ffd5 Glicko2 rating period now 1 day 2014-01-15 12:37:08 -06:00
Guangcong Luo
2be6563318 Elo ladder 2014-01-15 12:37:08 -06:00
Guangcong Luo
ae12fbbd09 Fix error in ladder rating calculation 2013-11-30 00:54:42 -06:00