diff --git a/package-lock.json b/package-lock.json index 5f0c355..3563d4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "next-connect": "0.13.0", "next-seo": "5.15.0", "nextjs-progressbar": "0.0.16", + "pg": "^8.12.0", "pino": "8.8.0", "pino-pretty": "^10.3.1", "prop-types": "15.8.1", @@ -4981,6 +4982,87 @@ "node": ">=8" } }, + "node_modules/pg": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.12.0.tgz", + "integrity": "sha512-A+LHUSnwnxrnL/tZ+OLfqR1SxLN3c/pgDztZ47Rpbsd4jUytsTtwQo/TLPRzPJMp/1pbhYVhH9cuSZLAajNfjQ==", + "dependencies": { + "pg-connection-string": "^2.6.4", + "pg-pool": "^3.6.2", + "pg-protocol": "^1.6.1", + "pg-types": "^2.1.0", + "pgpass": "1.x" + }, + "engines": { + "node": ">= 8.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.1.1" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz", + "integrity": "sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.6.4.tgz", + "integrity": "sha512-v+Z7W/0EO707aNMaAEfiGnGL9sxxumwLl2fJvCQtMn9Fxsg+lPpPkdcyBSv/KFgpGdYkMfn+EI1Or2EHjpgLCA==" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.6.2.tgz", + "integrity": "sha512-Htjbg8BlwXqSBQ9V8Vjtc+vzf/6fVUuak/3/XXKA9oxZprwW3IMDQTGHP+KDmVL7rtd+R1QjbnCFPuTHm3G4hg==", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.1.tgz", + "integrity": "sha512-jPIlvgoD63hrEuihvIg+tJhoGjUsLPn6poJY9N5CnlPd91c2T18T/9zBtLxZSb1EhYxBRoZJtzScCaWlYLtktg==" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "dependencies": { + "split2": "^4.1.0" + } + }, "node_modules/picocolors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", @@ -5123,6 +5205,41 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz", + "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -6757,6 +6874,14 @@ "node": ">=4.0" } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", diff --git a/package.json b/package.json index 50d0cc5..de37c44 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "dev:db-validate": "dotenv -e .env.development.local prisma validate", "prod:migrate": "dotenv -e .env.production.local prisma migrate deploy", "prod:build": "next build", - "prod:start": "next start", + "prod:start": "next start --port 42069", "global:check-dependencies": "npm-check --skip-unused" }, "devDependencies": { @@ -57,6 +57,7 @@ "next-connect": "0.13.0", "next-seo": "5.15.0", "nextjs-progressbar": "0.0.16", + "pg": "^8.12.0", "pino": "8.8.0", "pino-pretty": "^10.3.1", "prop-types": "15.8.1", diff --git a/public/img/coin/mariogalaxy.png b/public/img/coin/mariogalaxy.png new file mode 100644 index 0000000..14068fb Binary files /dev/null and b/public/img/coin/mariogalaxy.png differ diff --git a/public/img/flag/flag_ct.png b/public/img/flag/flag_ct.png new file mode 100644 index 0000000..d0271d2 Binary files /dev/null and b/public/img/flag/flag_ct.png differ diff --git a/src/lib/constants/forms/coins.js b/src/lib/constants/forms/coins.js index 314e87b..fdd5ede 100644 --- a/src/lib/constants/forms/coins.js +++ b/src/lib/constants/forms/coins.js @@ -62,6 +62,10 @@ export const COINS = Object.freeze([ { value: 'rhythmheaven', label: 'Rhythm Heaven (DS) Tutorial Coin' + }, + { + value: 'mariogalaxy', + label: 'Mario Galaxy Star Bit' } ]) diff --git a/src/lib/constants/forms/flags.js b/src/lib/constants/forms/flags.js index 4f4af1a..00ae96e 100644 --- a/src/lib/constants/forms/flags.js +++ b/src/lib/constants/forms/flags.js @@ -1114,6 +1114,10 @@ export const FLAGS = Object.freeze([ { value: 'wiiu', label: 'Wii U' + }, + { + value: 'flag_ct', + label: 'CT' } ]) diff --git a/src/lib/riitag/neo/std/Covers.ts b/src/lib/riitag/neo/std/Covers.ts index 5cd21cf..e3d1e6a 100644 --- a/src/lib/riitag/neo/std/Covers.ts +++ b/src/lib/riitag/neo/std/Covers.ts @@ -11,6 +11,16 @@ import { user } from '@prisma/client' const xml2js = require('xml2js') +const pg = require('pg') +const { Client } = pg +const client = new Client({ + host: 'localhost', + user: 'postgres', + password: 'postgres', + database: 'riitag', + port: 2345 +}) + export default class Covers extends ModuleBase { x: number y: number diff --git a/src/pages/api/account/language.js b/src/pages/api/account/language.js index d7afae8..a4eea3d 100644 --- a/src/pages/api/account/language.js +++ b/src/pages/api/account/language.js @@ -1,6 +1,5 @@ import HTTP_CODE from '@/lib/constants/httpStatusCodes' import { ncWithSession } from '@/lib/routing' -import { userIsMod } from '@/lib/utils/databaseUtils' import prisma from '@/lib/db' import logger from '@/lib/logger' import { isBlank } from '@/lib/utils/utils' @@ -25,12 +24,6 @@ async function exportData (request, response) { .json({ error: 'Unauthorized' }) } - if (!(await userIsMod(loggedInUser))) { - return response - .status(HTTP_CODE.UNAUTHORIZED) - .json({ error: 'Unauthorized' }) - } - try { await prisma.user.update({ data: { diff --git a/src/pages/user/[username]/index.jsx b/src/pages/user/[username]/index.jsx index 6c1d748..2526796 100644 --- a/src/pages/user/[username]/index.jsx +++ b/src/pages/user/[username]/index.jsx @@ -20,6 +20,38 @@ export const getServerSideProps = withSession(async ({ req, query }) => { // Get the logged in user. This can be null. const session = req.session?.username + const pg = require('pg') + const { Client } = pg + const client = new Client({ + host: 'localhost', + user: 'postgres', + password: 'postgres', + database: 'riitag', + port: 2345 + }) + + const fix = async (username) => { + await client.connect() + const userId = await client.query('SELECT * FROM public.user WHERE username=$1', [username.toString()]) + const res = await client.query('SELECT * FROM playlog WHERE user_id=$1', [userId.rows[0].id]) + console.log(res.rows) // Hello world! + + for (const row of res.rows) { + console.log(row) + + const res = await client.query('SELECT * FROM game WHERE game_pk=$1', [row.game_pk]) + if (res.rows.length === 0) { + console.log('No game found for game_pk', row.game_pk) + await client.query('DELETE FROM playlog WHERE game_pk=$1', [row.game_pk]) + } + console.log(res.rows) + } + + await client.end() + } + + await fix(username) + // get user and ban reason const user = await prisma.user.findUnique({ where: {