Memory Match โ€“ Server Documentation

PHP admin panel + API: player tracking, ad management ar 100 level control. Ei page ta server e rekhe dile jekono somoy khule shob info dekha jabe. Ekhane kono secret save hoy na.

๐Ÿ”ง Tomar Domain ar API Key

Niche domain ar key dile pura document e shob code yourdomain.com ar YOUR_API_KEY er jaygay tomar value diye jabe. Key ta browser e-i toiri hoy, kothao pathano ba save kora hoy na.

Key ta copy kore alada jayga e rakho. Page reload dile mone thakbe na. Eta dite hobe duita jayga e: server-er config.php ar Flutter-er api_service.dart.

๐Ÿ“˜ Overview

Ei server tomake ei kaj gulo korte dey:

Lagbe: PHP 8.1+ (PDO MySQL), MySQL 5.7+ / MariaDB 10.3+, Apache hosting (cPanel e hoy), HTTPS (SSL).

๐Ÿ“ File list

File / FolderKaj
schema.sqlDatabase table + 100 level toiri kore (phpMyAdmin e import)
config.phpDB info ar API_KEY (tumi edit korbe)
install.phpProthom admin toiri korar page (por e delete koro)
login.php / logout.phpAdmin login / logout
dashboard.phpStatistics ar chart
users.phpPlayer list, search, ban, delete
levels.php100 level edit
ads.phpAd management
account.phpPassword change
api/register.phpApp theke player ping
api/config.phpApp ke ad + level setting dey
includes/, assets/Shared code, CSS/JS (includes/ browser theke block kora)
.htaccessconfig.php ar .sql file protect kore
docs.htmlEi page

๐Ÿš€ Setup (A to Z)

1
Database toiri koro. cPanel โ†’ MySQL Databases โ†’ notun database, notun user, user ke database e All Privileges dao. Database name, user ar password lekhe rakho.
2
schema.sql import koro. cPanel โ†’ phpMyAdmin โ†’ tomar database select โ†’ Import โ†’ schema.sql choose โ†’ Go. Shesh holey levels table e 100 row thakbe.
3
API Key banao (uporer generator ba API Key section).
4
config.php edit koro:
define('DB_HOST', 'localhost');
define('DB_NAME', 'tomar_database');
define('DB_USER', 'tomar_user');
define('DB_PASS', 'tomar_password');
define('API_KEY', 'YOUR_API_KEY');
5
Upload koro. cPanel File Manager โ†’ public_html e shob file upload (zip upload kore Extract korle sohoj). .htaccess file ta ao jeno thake (hidden file show on koro).
6
Admin toiri koro. https://yourdomain.com/install.php e giye username/password dao, ba SQL diye.
7
install.php delete koro (security er jonno must).
8
Login koro: https://yourdomain.com/login.php
9
Flutter app connect koro (niche dekho) ar API tester diye check koro.

๐Ÿ”‘ API Key kibhabe nebe

API key kono company deyna, tumi nijei banao. Eta ekta lomba random password, jeta diye shudhu tomar app server er sathe kotha bolte pare. Tin vabe banano jay:

  1. Uporer "Generate API Key" button: 48 character-er shokto key toiri hoy.
  2. Terminal/SSH e:
    php -r "echo bin2hex(random_bytes(24));"
    ba
    openssl rand -hex 24
  3. Nijer moto lomba (30+ character) random lekha.
Notun (sohoj) upay: Admin panel e login kore sidebar er ๐Ÿ”Œ API page e jao โ†’ Generate API key chapo. Key database e save hoy, URL auto toiri hoy, ar Flutter-er code ready-made dekhay. Tokhon config.php e key boshate hoy na. Panel e key thakle seta-i kaj kore, config.php er key shudhu fallback.

Config file diye (purono upay): duita jayga e hubohu ek key

1) Server: config.php

define('API_KEY', 'YOUR_API_KEY');

2) Flutter app: lib/api_service.dart

static const baseUrl = 'https://yourdomain.com/api';
static const apiKey  = 'YOUR_API_KEY';
Key bodlate chaile: notun key banao โ†’ config.php ar api_service.dart duita-i bodlao โ†’ app notun kore build/publish koro. Ager app ba key leak hole purono key diye ar kaj hobe na.
Key kokhono GitHub, screenshot ba public jaygay dio na. Je-i app ta decompile kore key pete pare, tai server-e rate limit ar validation rakha hoyeche.

๐Ÿ‘ค Admin account toiri

Way 1: install.php (sohoj)

https://yourdomain.com/install.php โ†’ username + password (min 10 character) โ†’ Create. Tarpor file ta delete koro. Admin age theke thakle eta 403 dey.

Way 2: SQL diye

Prothome nijer password-er hash banao (server e ba PHP ache emon jekono jaygay):

php -r "echo password_hash('NijerPassword#2026', PASSWORD_DEFAULT);"

Tarpor phpMyAdmin โ†’ SQL tab e:

INSERT INTO admins (username, password_hash)
VALUES ('admin', 'PASTE_HASH_HERE');

Password bhule gele

UPDATE admins SET password_hash = 'PASTE_NEW_HASH' WHERE username = 'admin';
DELETE FROM login_attempts;   -- lockout shoriye dey

๐Ÿ–ฅ๏ธ Admin panel guide

PageKi korte pare
๐Ÿ“Š DashboardTotal player, ajker active, notun player, 7 din er active, banned, 7 diner chart, top device model, recently active list.
๐Ÿ‘ฅ PlayersName/device/model diye search. Ban: player flag hoy. Delete: record muche jay (app abar khulle notun player hishebe ashbe).
๐ŸŽฎ Levels1-100 level edit, nicher Levels section dekho.
๐Ÿ’ฐ AdsShob ad setting, nicher Ads section dekho.
๐Ÿ”‘ AccountAdmin password change.

Login 30 minute kichu na korle auto logout hoy. 5 bar vul password dile 15 minute er jonno lock hoy.

๐Ÿ’ฐ Ad management

AdMob unit ID kothay pabe

  1. admob.google.com e account khulo โ†’ Apps โ†’ Add app (tomar app ta add koro).
  2. App er bhitore Ad units โ†’ Banner, Interstitial, Rewarded, tin ta alada alada toiri koro.
  3. Prottek ad unit er ID dekhte ei rokom: ca-app-pub-1234567890123456/1234567890.

Panel e boshano (Ads page)

SettingMane
Ads enabledMaster switch. Off korle app e kono ad dekhabe na.
Test modeOn thakle Google-er demo ad dekhay (development e on rakho). Real ad dekhate off koro.
Banner / Interstitial / RewardedAlada alada on-off. Banner = game screen er niche, Interstitial = level jitle, Rewarded = time sesh holey extra time.
Interstitial every N1 = proti level jetar por, 3 = proti 3 ta level jetar por.
Extra seconds / Coin priceTime sesh holey koto second pabe ar coin diye nile koto coin lagbe.
Android / iOS unitsProttek platform er alada 3 ta unit ID. Khali rakhle test ad dekhabe.
Real ad dekhanor niyom: unit ID boshao โ†’ Test mode off koro โ†’ Save. Notun setting app porer bar open korle kaj korbe.
AdMob App ID (ca-app-pub-xxx~yyy) Android AndroidManifest.xml / iOS Info.plist e thake. Eta panel theke bodlano jay na, app build er somoy boshate hoy.

๐ŸŽฎ Levels (1-100)

Levels page e prottek level-er 3 ta jinis edit kora jay, tarpor Save all levels chapo:

Default: Level 1 = 4 card, Level 2 = 12, Level 3-9 = 16, Level 10-29 = 20, Level 30+ = 24 card. Vul value dile ager value-i thake.

๐Ÿ”Œ API reference

Base URL: https://yourdomain.com/api. Shob request e header: Authorization: Bearer YOUR_API_KEY. Response shob shomoy JSON: {"status":"ok",...} ba {"status":"error","message":"..."}.

POST /register.php โ€“ player ping

curl -X POST https://yourdomain.com/api/register.php \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"device_id":"a1b2c3d4e5f6a7b8","name":"Player-123","model":"Pixel 7","app_version":"1.0.0"}'
FieldRule
device_id8-64 char: A-Z a-z 0-9 _ -
name1-30 character
modelmax 60 character
app_version1-20 character (0-9 A-Z a-z . + _ -)

Success: {"status":"ok","banned":false}. Ekoi device_id abar ping dile notun player hoy na, last_seen ar open_count update hoy.

GET /config.php โ€“ ad + level setting

curl https://yourdomain.com/api/config.php \
  -H "Authorization: Bearer YOUR_API_KEY"

Response e ads (enabled, test_mode, banner, interstitial, rewarded, interstitial_every, extra_seconds, extra_coin_cost, units.android/ios) ar levels list (l level, c cards, t time, r reward) thake.

Error code

CodeMane
400JSON vul
401API key nai ba vul
405Vul method (POST/GET)
413Data 4KB er beshi
422Field vul (message e bole kon ta)
429Onek beshi request (default 120/minute/IP)
500Server error ba API_KEY config kora nai

๐Ÿงช API tester

Uporer domain ar key diye server thik moto chalche kina check koro. Register test e "Docs-Test" namer ekta player toiri hobe, Players page theke delete kore dio.

Result ekhane ashbeโ€ฆ

๐Ÿ“ฑ Flutter app connect

1
lib/api_service.dart e domain ar key boshao:
static const baseUrl = 'https://yourdomain.com/api';
static const apiKey  = 'YOUR_API_KEY';
2
App chalao (Android emulator/phone): flutter run. App khulle chup kore ping jay ar config nay.
3
Panel er Players page e tomar device dekhte pabe. Na dekhle Troubleshooting dekho.
4
Ad ar level panel theke bodlale app restart dile notun value niye nibe. Offline thakleo ager cache kora value diye game chole.

๐Ÿ›ก๏ธ Security checklist

Already ache: SQL injection protection, CSRF token, secure session cookie, login lockout, API rate limit, input validation, security header.

๐Ÿฉบ Troubleshooting

SomosshaSomadhan
API 401 UnauthorizedKey duita jayga e hubohu mile nai, ba header e Bearer nai. Apache e .htaccess upload hoyeche kina dekho. Nginx hole fastcgi_param HTTP_AUTHORIZATION $http_authorization; dao.
500 "Server not configured"config.php e API_KEY ager default value-i ache, notun key boshao.
500 "Server error"Database name/user/password vul, ba schema.sql import hoy ni. cPanel Errors / error_log dekho.
429 Too many requestsEk minute opekkha koro. Proyojone config.php e API_RATE_LIMIT_PER_MIN barao.
Login e "Too many failed attempts"15 minute opekkha koro, ba SQL: DELETE FROM login_attempts;
"Invalid request (CSRF)"Page reload kore abar try koro, browser cookie on rakho.
install.php 403Admin age theke ache. Login koro, ba SQL diye password reset koro.
Blank / 500 pagePHP version 8.1 er kom, ba pdo_mysql extension off. cPanel โ†’ Select PHP Version.
App e ad ashche naAds enabled/ type on kina dekho. Real ad e unit ID format sothik, Test mode off, AdMob App ID manifest e ache kina, ar app restart koro. Notun ad unit e kichu ghonta lagte pare.
Panel e notun setting app e naiApp ekbar bondho kore abar kholo, ar internet on rakho.
API tester e "Failed to fetch"Domain thik kina, HTTPS ache kina, ar server chalu kina dekho.