Skip to content
NB-CorePublic

About

Legend of the Green Dragon +nb Fork

Resources

Code of conduct

Contributing

Security policy

Stars

28 stars

Watchers

5 watching

Forks

Latest commit

 

History

4,486 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Legend of the Green Dragon Fork

PHP Version License CI This is a fork of the original Legend of the Green Dragon game by Eric "MightyE" Stevens (http://www.mightye.org) and JT "Kendaer" Traub (http://www.dragoncat.net)

The original readme and license texts follow below, also the installation + upgrade routines which haven't changed much.

Note: CHANGELOG.md is the current changelog for modern releases (2.x+). The docs/LegacyChangelog.txt file is archival and does not cover every historical change; around 300 commits were made without entries, so refer to git history for a complete list.

This fork updates the Dragonprime 1.1.1 release with modern tooling while remaining compatible with existing modules. It aims to provide a smoother experience on current PHP versions. The source lives on GitHub where you can follow development and open issues.

Features of this fork include:

  • additional hooks
  • a stat system with strength, dexterity, and other attributes
  • numerous other changes documented in docs/LegacyChangelog.txt
  • compatibility with PHP 8.3
  • PHPMailer replacing the sendmail system
  • mail notifications that auto-refresh via Ajax (resources under async/)
  • incremental chat updates via commentary_refresh to load new messages without reloading the page
  • Ajax requests are rate limited to roughly one per second; faster requests receive an HTTP 429 response. When enabling Ajax features, copy config/async.settings.php.dist to config/async.settings.php and adjust $ajax_rate_limit_seconds as needed.
  • Composer integration for third-party modules
    • after modifying Composer settings, run composer dump-autoload to recognize new namespaces
    • after running composer install or composer dump-autoload, include autoload.php to load all dependencies
    • autoload.php automatically loads vendor/autoload.php and registers the project namespace
  • mysqli is now the default database layer
  • Twig is now the default template system located in templates_twig/ (classic .htm files continue to work)

It should run on any modern PHP environment. Open an issue on GitHub with questions.

Join the Community

Chat with other adventurers and get quick support on our Discord server!

Discord

Demo

Game screenshot There is no official demo server. You can explore the original at LotGD.net or the current version at Shinobi Legends. You can create an account to explore, but you will only have standard user rights.

Contributing

See AGENTS.md for full contributor guidelines. Highlights:

  • Follow the PSR-12 coding standard.
  • Run composer test and composer static before committing.
  • Check PHP syntax with php -l on changed PHP files.

Table of Contents

Read Me First

Thank you for downloading the modified version of Legend Of the Green Dragon. See docs/LegacyChangelog.txt for a list of changes up until version 1.3.2. 👉 See CHANGELOG.md for a detailed history after that up until now.

If you need modules, go there and fetch the ones you like. There may be more out there, in the original dragonprime resources or other people's work. Modern DragonPrime resources, templates, and community support now live at DragonPrime Reborn, the successor to the legacy DragonPrime site, which also hosts a snapshot archive of legacy modules that typically require refactoring for PHP 8+ compatibility.

To follow the actively maintained spiritual successor of the main core this fork extends, visit StephenKise's Legend of the Green Dragon, which carries forward ongoing development and releases.

If you need more legacy templates / skins for the game, go there.

System Requirements

To run Legend of the Green Dragon on a typical web host you will need:

  • Web server: Apache 2 (or another server capable of running PHP)
  • PHP: version 8.3 or newer (the Docker image ships 8.4; CI tests both), with the extensions mysqli, pdo_mysql and mbstring. The installer checks these first and names any that are missing; on shared hosting they are usually switched on in the panel's PHP settings. gd, zip and OPcache are recommended (the superuser diagnostics page lists them).
  • Database: MySQL 8.0 or later (8.4 LTS is what the Docker stack ships and what CI exercises). MariaDB 10.6 or later is a compatible alternative. Older servers may still work, but they are neither tested nor supported by their own vendors any more.
  • The database user must have the LOCK TABLES privilege.
  • The web server must be able to deny access to files that are not entry points. The shipped .htaccess does this on Apache when AllowOverride permits it; on Nginx or a locked-down Apache, port the rules from the comment block at the end of .htaccess.

Getting Started

Installing on shared hosting with FTP and a control panel? Follow the step-by-step webspace guide instead; it needs no command line.

  1. Clone the repository. The production dependencies are committed under vendor/, so the game runs without Composer.
  2. For development or a test server, run composer tools:install. It installs PHPUnit, PHPStan and PHP_CodeSniffer into tools/vendor/, which is never committed or deployed. In a container that runs as root, Composer refuses every command in the root project because of its merge plugin: use composer install --working-dir=tools instead, which is the same install, and set COMPOSER_ALLOW_SUPERUSER=1 for composer test and composer static.
  3. Open installer.php in your browser and follow the prompts. When asked for a cache directory, enter a writable directory outside the web root, for example /home/you/lotgd-cache next to the folder that holds the game (see Data cache location).
  4. (Optional) Use Docker—see docs/Docker.md.

Maintenance

Regular upkeep tasks:

  • Run composer update to update dependencies and commit vendor/ with it. vendor/ holds production packages only; composer static (and CI) fails if it no longer matches composer.lock or a development package ends up in it.
  • Update the development tools with composer update --working-dir=tools and commit tools/composer.lock.
  • Run composer test to execute the unit tests and composer static to run PHPStan or other static analyzers; ensure both pass before committing. Both need composer tools:install once.
  • Optionally schedule cron.php via cron for automated jobs; without it, the daily maintenance runs when the first player of the day arrives.
  • Configure SMTP settings in the in-game settings editor (configuration.php, Superuser navigation); they are stored as game settings, not in a file.
  • If you change DB_PREFIX, clear the cache directory to avoid reusing metadata from the previous prefix.

What’s new in 2.0

  • Full PSR-4 / Composer refactor
  • Doctrine ORM + migrations
  • Twig template engine
  • Async/Ajax UX improvements (one async endpoint, async/process.php)
  • PHP 8.3 baseline

Performance defaults:

  • zlib output compression enabled when available.
  • Data cache and Twig cache use the datacachepath directory; the game warns admins if the path is missing or not writable.

👉 See UPGRADING.md if you’re moving from 1.3.x

Further Reading

For details on key components:

Twig Templates

Twig templates reside in the templates_twig/ directory. Each template should have its own folder containing a config.json, page.twig, and popup.twig. The distribution includes the aurora template and uses it as the default skin. You can switch to another template by changing the defaultskin setting or by setting a template cookie. If a matching folder is found, pages are rendered with Twig; classic .htm templates continue to work as before. Twig views receive variables for common placeholders like nav, stats, and paypal, allowing flexible layouts. When a page controller needs vendor assets (CSS/JS) without polluting Twig templates, register them in PHP before rendering and let the layout print the resulting head/script output. For example, in a controller such as modules.php:

use Lotgd\Output;
use Lotgd\Page\Header;
use Lotgd\Page\Footer;

Header::pageHeader('Module Manager');
Output::requireVendorAsset('datatables', 'css');
Output::requireVendorAsset('datatables', 'js');
// ... page logic ...
Footer::pageFooter();

Twig layouts already emit headscript and script ({{ headscript|raw }} / {{ script|raw }}), so registered assets appear automatically. Compiled Twig templates are cached under the directory defined by the datacachepath setting. The engine attempts to create a twig subdirectory and only enables caching when it is writable. If the path cannot be created or written to, templates are rendered without caching.

dbconnect.php is created by the installer and stores database and cache settings in plain PHP. It is the only core file not overwritten during updates and remains the primary place for these settings. Site-specific overrides can be placed in the config/ directory (e.g., config/configuration.php) to keep them separate from the core. After installation you can edit dbconnect.php to point the cache at a writable directory:

<?php

return [
    // ... database settings written by the installer ...
    'DB_USEDATACACHE' => 1,
    'DB_DATACACHEPATH' => '/home/you/lotgd-cache', // without trailing slash
    // ... further entries unchanged ...
];

Change only these two entries and leave the rest of the file as the installer wrote it.

A valid datacachepath enables Twig caching—without it pages must be recompiled and the game runs noticeably slower.

Data cache location

The data cache stores whole settings tables as plain files, including the SMTP password and other credentials entered in the game settings. Put it outside the web root, the directory your web address points to, so the web server has no URL for it:

/home/you/
├── public_html/        <- web root: the game lives here
└── lotgd-cache/        <- data cache: next to it, not inside

Most hosting panels let you create a folder next to public_html (or htdocs, www). The directory only needs to be writable by the user PHP runs as—on shared hosting that is usually your own account, so the default permissions work. Do not make it writable by everyone (chmod 777).

If your hosting gives you no directory outside the web root, a cache inside it is still protected on Apache by the shipped .htaccess, which denies the data/ directory and every datacache-* file. That depends on the server reading .htaccess: check it by opening https://your.game/data/cache/datacache-gamesettings in a browser after the game has run for a moment—the answer must be 403 Forbidden. Admins with configuration rights see a security warning in the game while the cache is inside the web root.

Install on Shared Webspace

No command line or Composer is needed: the repository includes the vendor/ directory. On the project page, use Code → Download ZIP, upload the contents to your web space and open installer.php in your browser. docs/InstallWebspace.md walks through every step, including the checks to run afterwards.

Release Workflow

Releases are prepared manually by maintainers. The Release GitHub Actions workflow is intentionally configured as manual-only (workflow_dispatch) so it does not auto-run on tags.

To publish a release:

  1. Update the version in common.php and run composer shipped-files in the same commit (CI checks that the list names the new version). Add the release to CHANGELOG.md, then merge to master.
  2. Create the tag (for example v2.0.8) and the release on GitHub. Pushing a v* tag also publishes the Docker image as :X.Y.Z, :X.Y and :latest (.github/workflows/image.yml). Publishing the release starts the Release notes workflow, which puts the CHANGELOG.md sections since the previous release at the top of its text and folds GitHub's generated list of pull requests away underneath (scripts/release-notes.php). To refresh the text after correcting the changelog, run Actions → Release notes with the tag.
  3. For downloadable archives, open Actions → Release → Run workflow and enter the tag.

The Release workflow checks out that tag, refuses to continue when common.php in it declares another version, and builds archives that contain the application and its vendor/ dependencies while omitting development files such as the tests/ directory.

GitHub Actions Storage Policy

  • CI uses a Composer cache key scoped to OS + PHP version + composer.lock to avoid uncontrolled cache growth.
  • Release artifacts use a 14-day retention period to reduce billable GitHub Actions storage.
  • Set repository-level artifact/log retention in GitHub settings for additional control of monthly storage usage.

Cron Job Setup

cron.php handles automated tasks such as daily resets. Run it from the command line with php cron.php and schedule it in your system's crontab. The script automatically determines its installation directory, so no manual configuration or $GAME_DIR value is required.

⚠️ cron.php must not be reachable over HTTP. Depending on the register_argc_argv setting, a plain web request can pass the execution bitmask through the query string and start a newday or database-cleanup run. The rule is now shipped by default — the project's root .htaccess and the Docker virtual host both deny it — so nothing needs to be added by hand on Apache.

Verify it after deployment; a request must answer 403:

curl -s -o /dev/null -w '%{http_code}\n' https://your.game/cron.php

On other servers apply the equivalent protection (for example, an Nginx location = /cron.php { return 403; } block); the commented Nginx translation at the end of .htaccess lists all of the project's access rules. Moving the script outside the document root also works.

Constant Bit value Routine Notes
CRON_NEWDAY 1 Daily reset Calls Newday::runOnce() to process turns, buffs, and cache maintenance.
CRON_DBCLEANUP 2 Database maintenance Runs Newday::dbCleanup() to optimize all tables. Accepts an optional second CLI argument to force an optimization even if the daily timer has not elapsed.
CRON_COMMENTCLEANUP 4 Content cleanup Purges old commentary, news, referers, mail, fail logs, and archives via Newday::commentCleanup().
CRON_CHARCLEANUP 8 Character expiration Invokes Newday::charCleanup() and ExpireChars::expire() to remove inactive characters.

Invoke php cron.php with no arguments for the full maintenance run (1|2|4|8 = 15). Supply a bitmask to limit the routines—for example, php cron.php 5 (1|4) runs the newday reset and content cleanup while skipping database/character cleanup. Leave off the second argument unless you need to force database optimization.

Enable the newdaycron flag in the admin settings (or set newdaycron to 1 in the settings table) to process new days exclusively through the cron job instead of when the first player logs in. Each maintenance step records its work in the Game Log (Superuser ➜ Game Log or gamelog.php), letting administrators confirm that the cron run completed successfully.

SMTP Mail Setup

LOTGD uses PHPMailer for all outgoing mail. Open Game Settings in the Superuser Grotto (configuration.php) and fill in the options under SMTP Mail Settings. They are stored as game settings, not in a file:

"gamemailhost"       => "SMTP Hostname",
"gamemailsmtpauth"   => "SMTP Auth, bool",
"gamemailusername"   => "SMTP Username",
"gamemailpassword"   => "SMTP Password",
"gamemailsmtpsecure" => "SMTP Secure mechanism, enum: [starttls, STARTTLS, tls, TLS]",
"gamemailsmtpport"   => "SMTP port to use,int",

SMTP is used only when SMTP Password is set; without it, mail goes through the server's local sendmail. SMTP Secure mechanism and SMTP port take effect only with SMTP Auth enabled, so a typical mailbox needs all of host, user name, password, auth on, tls and port 587. Test SMTP settings in the Game Settings menu sends a test mail to the admin address.

Enable notify_on_warn or notify_on_error and set notify_address in the Error Notification section to receive site warnings or errors via email. These notifications rely on the data cache, so ensure $DB_USEDATACACHE is set to 1 and $DB_DATACACHEPATH points to a writable directory in dbconnect.php.

Beta Setup

pavilion.php is an optional script used when beta features are enabled per player. Players flagged for beta access see a link to the pavilion in the village and can use it to try experimental features. The repository provides a minimal template for this file which simply displays a message and a commentary section. Customize it to implement your own beta content.

After Upgrading

After upgrading from versions prior to 1.1.1 DP Edition you should:

  • Check your races and remove any charstats hooks that only output the race under Vital Info.
  • Users with data cache enabled must edit dbconnect.php and add:
$DB_USEDATACACHE = 1;
$DB_DATACACHEPATH = "/your/caching/dir"; // without trailing slash
  • Translators should replace hard coded names in dialogues with %s using the Translation Wizard.
  • Verify that the server supported languages are configured correctly.
  • Index definitions that exceed MySQL's key length limits are now automatically truncated by the installer. String columns in composite indexes are reduced to safe prefixes (for example (191) for utf8mb4) when necessary.

Legend of the Green Dragon

by Eric "MightyE" Stevens (http://www.mightye.org) and JT "Kendaer" Traub (http://www.dragoncat.net)

Modification AND Support Community Page: http://dragonprime.net

Primary game servers: http://lotgd.net http://logd.dragoncat.net

For a new installation, see INSTALLATION below. For upgrading a new installation, see UPGRADING below. If you have problems, please visit Dragonprime at the address above.

UPGRADING

Legacy installation and upgrade instructions have moved to docs/LegacyREADME.md.

When upgrading from a legacy release, run the legacy upgrade script before migrations. This applies all legacy SQL for newer versions prior to running Doctrine migrations.

  1. Step 1 (pre-migration versions only):

    php bin/legacy-upgrade --from-version="1.1.1 Dragonprime Edition"
  2. Step 2:

    php bin/doctrine migrations:migrate

    The command reads src/Lotgd/Config/migrations.php and src/Lotgd/Config/migrations-db.php by default. If your configuration lives elsewhere, pass --configuration and --db-configuration with the appropriate paths.

Omitting --from-version bypasses legacy SQL entirely.

Docker

Docker provides an immutable production image and a source-mounted development workflow. Begin by cloning the repository and creating the local environment file:

git clone https://github.com/NB-Core/lotgd.git
cd lotgd
cp .env.example .env

.env.example ships with empty password fields on purpose; Compose refuses to start until both are set to independently generated values:

chmod 600 .env
sed -i "s|^MYSQL_PASSWORD=$|MYSQL_PASSWORD=$(openssl rand -base64 32)|" .env
sed -i "s|^MYSQL_ROOT_PASSWORD=$|MYSQL_ROOT_PASSWORD=$(openssl rand -base64 32)|" .env

Build and start the default production configuration:

docker compose up -d --build

Or skip the build: every push to master publishes the image for AMD64 and ARM64 to ghcr.io/nb-core/lotgd. Select it with LOTGD_WEB_IMAGE=ghcr.io/nb-core/lotgd:master in .env, then run docker compose pull web && docker compose up -d --no-build. See Prebuilt image for the available tags and for adding your own modules.

For development, layer the override onto the same base configuration:

docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build

The development override mounts the checkout while keeping vendor/ and the application cache in Docker volumes. A separate state volume preserves the installer-generated dbconnect.php and installer-completion state across image replacements. Production serves only HTTP on the chosen LOTGD_HTTP_PORT; deploy it behind a TLS-terminating reverse proxy for HTTPS. TLS is intentionally not bundled because each deployment must supply and renew certificates for its own domain, for example through Let's Encrypt. Install without a browser once the stack runs: docker compose exec -T --user www-data web php bin/install --admin=YourName creates the game and your administrator and prints the password once (see Installing from the command line). The browser installer is denied by default and can be enabled deliberately instead, as described in the guide.

See the Docker guide for cache behavior, verification, and troubleshooting — in particular backups, the update procedure, the reverse-proxy setup, and the state of the pinned base images.

About

Legend of the Green Dragon +nb Fork

Resources

Code of conduct

Contributing

Security policy

Stars

28 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages