Build Travian- and OGame-style strategy worlds with a compact, feature-rich engine. phpSGE delivers time-based resource production, construction queues, research trees, unit training, alliances, diplomacy, maps, and rankings in a modular package.
Admins get a web installer, an automatic database updater with versioned migrations, robust multi-language support, and a plugin system—including social integrations—to tailor each server to their community.
Name: phpSGE (PHP Strategy Game Engine)
Version: 0.6.0.355
Genre: Strategy Game Engine (NOT RPG - city-building/resource management)
Type: Opensource game engine/toolkit
Developers: Aldrigo Raffaele and Kushnir Nikita (11VKSS iT-Group)
Additional Contributors: Raffa50, AgManiX de Mal
Website: rpvg.altervista.org/phpsge/ (official game list registration)
License: Opensource (specific license not documented)
Date: Version 0.6.0.355 (active development, 2010s era based on version system)
UNIQUE DISTINCTION: First strategy game engine in this collection (vs character-based RPGs). Represents the Travian/OGame genre of browser-based empire-building games with resource management, military units, alliances, and territorial conquest.
18 core tables (phpsge-base060.sql, 272 lines):
`php
// Auto-redirect to installer if not configured
if (!file_exists("config.php")) {
header("Location: ./install/index.php");
}
// AUTOMATIC DATABASE UPDATER!
$old_ver = sge_ver();
if((int)$newver > (int)$old_ver) {
include("adm/updater/proc.php");
updateDB($old_ver);
}
// OOP Login System
if ($_POST['nik']) {
$log = new sge_login();
$log->username = $_POST['nik'];
$log->password = $_POST['pass'];
$log->login();
}
// Game Registration to Official List
include "adm/Snoopy.class.php";
$snoopy = new Snoopy;
$submit_url = "http://rpvg.altervista.org/phpsge/do.php";
$snoopy->submit($submit_url, $submit_vars);
`
`php
class sge_main {
var $username;
var $id_city;
var $id;
// Resource production system (post-035)
public function resources() {
// Time-based resource accumulation
// Magazine capacity limits (if MAG_E enabled)
// Per-building production rates
}
// Building queue system
function que_build($bid, $id_city, $field=NULL) {
// Cost calculation with level multipliers
// Resource verification
// Population requirements (if POP_E enabled)
// Points awarded
}
// Research queue
function que_research($idres) {
// Technology unlock system
}
// Military unit training
function qunt($id_unt, $uqnt) {
// Unit cost calculation
// Barracks level time reduction
// Training queue
}
// Combat resolution
function bataglia($city_id) {
// Attack/defense calculations
// Unit casualties
// Resource plunder
}
}
`
Version Variables (func.php):
`php
$confcver = "053"; // Config version
$newver = "060"; // Latest DB version
$scriptver = "059"; // Script version
`
Auto-Updater (adm/updater/proc.php):
adm/updater/046.sql through 059.sql026-035/ subdirectoryLanguage directories:
Per-language modules:
`
admcp.lng, ally.lng, barraks.lng, battle.lng, buildings.lng,
chat.lng, highscore.lng, index.lng, install.lng, map.lng,
map2.lng, market.lng, menu.lng, pm.lng, profile.lng,
research.lng, settings.lng, var.lng
`
Most comprehensive i18n in entire collection (previous max: 4 languages in Phaos).
`php
function updateDB($old_ver) {
// Reads version-specific SQL file
if((int)$old_ver < 36) {
$str = file_get_contents("./adm/updater/026-035/".$old_ver.".sql");
} else {
$str = file_get_contents("./adm/updater/".$old_ver.".sql");
}
// Replace prefix and execute batch
$str = preg_replace("'%PREFIX%'", TB_PREFIX, $str);
mysql_exec_batch($str);
}
`
Version tracking: 35+ versions documented (026 → 060), seamless migration path for game admins.
facebook.sql: Dedicated tables for Facebook Connect authentication and social features. Represents mid-2000s push for social gaming integration.
Plugin system:
`sql
INSERT INTO %PREFIX%plugins VALUES
('fbplug', 'facebook', 0, NULL),
('fblog', 'fb/fb-log', 0, NULL);
`
Snoopy HTTP Client (1,170 lines): Submits game instance data to rpvg.altervista.org/phpsge/do.php to appear on official phpSGE game list. Creates community ecosystem of phpSGE-powered games.
`php
// plugins/installed.php
$plugs = mysql_query("SELECT * FROM ".TB_PREFIX."plugins WHERE active =1");
while($riga = mysql_fetch_array($plugs)) {
define($riga['name'], $riga['active']);
include("plugins/".$riga['file'].".php");
}
`
Available plugins:
3 map implementations:
City coordinates: Galaxy/System/Position for spatial strategy gameplay.
3 base resources (expandable):
`sql
INSERT INTO %PREFIX%resdata VALUES
(1, 'Gold', 5, 500, NULL), -- 5 per hour production
(2, 'Mana', 1, 500, NULL), -- 1 per hour production
(3, 'Power', 2, 510, NULL); -- 2 per hour production
`
Time-based accumulation:
`php
$diffd = ($mtimet - $ktimer) / 3600; // Hours since last update
$res1_ora = $riga['prod_rate'] * $abbl_r1['lev']; // Production per hour
$up_res1_tot = $qres1 + ($res1_ora * $diffd);
`
Magazine capacity system (optional):
`php
if(MAG_E == "1") {
$r_max = $mag_lv * 100 + MG_max_cap;
if ($up_res1_tot > $r_max) { $up_res1_tot = $r_max; }
}
`
Sample buildings:
`sql
INSERT INTO %PREFIX%t_builds VALUES
(1, 'barraks', 'barraks', 'barraks.gif', 'barracks', 0, 0, 0.25, 70, 0, 0, 30, 0.25, 3, 1, 0, 0, 15, 0),
(2, 'Gold Mine', 'res1', 'mine.gif', 'gold mine', 0, 0, 0.25, 50, 0, 0, 15, 0.25, 0, 0, 0, 0, 10, 0),
(3, 'Mana node', 'res2', 'node.gif', 'mana pool', 0, 0, 0.25, 50, 0, 0, 15, 0.25, 2, 1, 0, 0, 10, 0),
(4, 'Research Lab', 'reslab', '31.gif', NULL, 0, 0, 0.25, 60, 30, 0, 55, 0.25, 3, 2, 0, 0, 15, 0);
`
Features:
cost = base_cost + (base_cost level res_mpl)time = base_time + (base_time level time_mpl)Unit definitions:
`sql
INSERT INTO %PREFIX%t_unt VALUES
(1, 'milita', 1, 'milita.gif', 5, 5, 5, 10, 1, 25, 3, 0, 20, 'a simple soldier', NULL, 0, 0, 0, 0),
(2, 'Drago', 1, 'rdragus.gif', 55, 55, 30, 10, 1, 900, 600, 0, 300, 'the powerful dragon!', NULL, 0, 0, 0, 0);
`
Stats:
Unit states (action field):
`php
// Attack initiation
if($_POST['act'] == "atk") {
$aftunt = $su['uqnt'] - $_POST['qnt']; // Deduct attackers
$timeend = mtimetn() + 30; // Travel time
mysql_query("UPDATE units SET
from = '$sge->id_city',
to = '".(int)$_POST['dp']."',
where = NULL,
time = '$timeend',
action = '1'
WHERE id =".$su['id']);
}
`
Combat resolution (func.php bataglia()):
Tables:
Pact types:
Access control:
`sql
INSERT INTO %PREFIX%t_research VALUES
(1, 'magic servant', NULL, 0, 'null.gif', 50, 100, 0, 15, 0, 0, 0, 0, 0);
`
Research queue (rque table): Technology unlocks with time/resource costs, prerequisites, and level progression.
Resource trading:
`sql
CREATE TABLE %PREFIX%market (
owner int(10) unsigned NOT NULL,
resoff smallint(1) unsigned NOT NULL, -- Resource offered
resoqnt int(15) unsigned NOT NULL, -- Quantity offered
resreq smallint(1) unsigned NOT NULL, -- Resource requested
resrqnt int(15) unsigned NOT NULL -- Quantity requested
)
`
Player-to-player resource exchange (known bug: "cannot accept offer").
Login (log-reg.php):
`php
$this->password = strip_tags($this->password);
$q = "SELECT * FROM ".TB_PREFIX."users
WHERE username = '".mysql_real_escape_string($this->username)."'
AND password = '".md5($this->password)."' LIMIT 1";
`
Registration:
`php
$pass = md5($_POST['rpass']);
$reg = "INSERT INTO ".TB_PREFIX."users
(username, password, ...)
VALUES ('".mysql_real_escape_string($nik)."', '$pass', ...)";
`
Security measures:
Consistent escaping in func.php:
`php
function snmsg($from, $to, $mtit, $msg, $mtp=1, $aiid=NULL) {
$mtit = mysql_real_escape_string($mtit);
$msg = mysql_real_escape_string($msg);
mysql_query("INSERT INTO ".TB_PREFIX."umsg
(from, to, mtit, text, read, mtype, aiid)
VALUES ('$from', '$to', '$mtit', '$msg', '0', '$mtp', '$aiid')");
}
`
Integer casting for IDs:
`php
$qcb = mysql_query("SELECT * FROM ".TB_PREFIX."t_builds WHERE id ='".(int)$bid."' LIMIT 1");
`
Good: Widespread use of mysql_real_escape_string and (int) casting
⚠️ Concern: Some direct POST variable usage without validation (e.g., battle.php)
`php
session_start();
if ($_SESSION['log'] == "y") { header("Location: main.php"); }
`
SECURITY RATING: 5/10
Strengths:
Weaknesses:
Comparison: Similar security level to other 2006-2010 era games. Better than plaintext passwords, worse than games with triple-escaping or modern hashing.
Modular features (config.php defines):
Minimal implementation:
include("templates/".TEMPLATE."/body.php")Three-tier versioning:
`php
$confcver = "053"; // Config file version
$newver = "060"; // Target DB version
$scriptver = "059"; // Current script version
`
Database version storage:
`sql
CREATE TABLE %PREFIX%conf (
sge_ver varchar(5) NOT NULL default '047',
UNIQUE KEY sge_ver (sge_ver)
);
`
35+ documented updates (026 → 060) = ~35 version releases tracked meticulously.
6 JavaScript files (190 KB):
Modern for 2010 era: AJAX was cutting-edge for browser games at the time.
68 image files (370 KB total):
Active bug list:
Recent fixes (completed):
TODO list:
Transparency: Honest documentation of current state shows active development mindset.
Registration system (index.php):
`php
$snoopy = new Snoopy;
$submit_url = "http://rpvg.altervista.org/phpsge/do.php";
$snoopy->submit($submit_url, $submit_vars);
`
Purpose: Creates centralized directory of phpSGE-powered games. Promotes engine adoption by showcasing live instances.
Developer website: rpvg.altervista.org/phpsge/ (Altervista free hosting platform, popular in Italy).
4 language packs (72 total files) demonstrate:
install/ directory:
Admin tools:
First strategy game engine in collection. Previous 53 games were character-based RPGs (progression, equipment, quests). phpSGE represents the Travian/OGame/Ikariam genre:
Browser strategy game boom (2006-2010):
Codebase size:
Despite small size, includes:
Efficiency through simplicity: Minimal feature set executed well rather than feature bloat.
35+ versions (026 → 060):
Development arc:
Mid-2000s standards:
Modernization needs:
Core features implemented:
Known broken features:
Playability: 70% - Core gameplay loop functional but several features broken.
Ideal for:
Not suitable for:
vs Travian/OGame clones in collection:
vs RPG engines:
Breakdown:
Tier Classification: MID-TIER ENGINE
Verdict: phpSGE is a capable strategy game engine with exceptional internationalization (72-language RECORD!) and an innovative auto-updater system. The small codebase (5,883 lines) makes it highly customizable, and the modular design (MAG_E, POP_E toggles) allows admins to tailor gameplay. The official game registration network creates a community ecosystem unique in this collection.
However, multiple known bugs, weak MD5 passwords, deprecated mysql_* functions, and missing XSS protection prevent production deployment without significant security hardening. The template system is basic, and several features (market, account deletion, holiday mode) are documented as broken.
Best use case: Learning resource or customization base for PHP developers creating strategy games. With security fixes and bug resolution, could be a solid mid-tier engine. The version tracking system (59 SQL files!) is exemplary and should be studied by other engine developers.
Historical significance: Represents the browser strategy game boom (2006-2010 era) when Travian/OGame inspired countless clones. phpSGE offered an opensource alternative, and the 72-language support demonstrates serious ambition for international deployment. The game registration network shows forward-thinking community building.
For 2010-era standards: 7/10 (modern for its time)
For 2025 deployment: 4/10 (needs modernization)
---
Analysis Date: December 11, 2025
Archive Location: d:\_HOUSE\SOCIALMUD\WWW\_MUD Games\unzipped\php_sge\phpSGE\
Game #54 of 79 in systematic browser game analysis project
Running many of the scripts in this archive on a live server presents a serious security risk. These projects were created before modern hardening practices and may contain vulnerabilities that can compromise your system.
We strongly recommend using this code for reference and analysis only, or in isolated local environments. By downloading these files, you accept full responsibility for their use.