Skip to content

Commit

Permalink
Use composer for dependency management
Browse files Browse the repository at this point in the history
  • Loading branch information
splittingred committed Mar 4, 2020
1 parent 8fe32a3 commit 684ddb6
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ variants/*/cache/
variants/KnownWorld_901/
ghostRatingData.*
gr.php
adminInfo.php
adminInfo.php
vendor/
8 changes: 8 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ Edit config.sample.php to work with your setup, being very careful to read the w
about security issues. The salts/secrets, errorlog/orderlog directories, can all
leave your server wide open if you don't set them right. Rename to config.php when ready.

=> Composer

Install Composer via https://getcomposer.org/. Then run:

composer install

This will install all external dependencies that webDiplomacy uses.

=> Log-on
Once you've set config.php up you can use the random gameMasterSecret you entered
to authenticate as the admin. First create a user via the registration page, then
Expand Down
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "kestasjk/web-diplomacy",
"description": "webDiplomacy",
"keywords": ["diplomacy"],
"type": "project",
"repositories": [],
"require": {
"php": "^7.0"
},
"require-dev": {},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
19 changes: 19 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions contrib/PHPMailer_v5.1/PHPMailerAutoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,5 @@ function PHPMailerAutoload($classname)
}
}

if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
PHPMailerAutoload($classname);
}
}
//SPL autoloading was introduced in PHP 5.1.2
spl_autoload_register('PHPMailerAutoload', true, true);
1 change: 1 addition & 0 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function setExpires($expires) {
if( !defined('IN_CODE') )
define('IN_CODE', 1); // A flag to tell scripts they aren't being executed by themselves

require_once 'vendor/autoload.php';
require_once('config.php');

require_once('global/definitions.php');
Expand Down
19 changes: 9 additions & 10 deletions variants/variant.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,15 @@ public function link() {
* [Name]Variant -> variants/[Name]/variant.php
* [Name]Variant_[Class] -> variants/[Name]/classes/[Class].php
*/
function __autoload($classname) {
spl_autoload_register(function ($classname) {
$pos = strpos($classname, 'Variant');
if (empty($pos)) return;

if( !( $pos=strpos($classname,'Variant') ) || $pos==0 ) return;
$variantName = substr($classname, 0, $pos);

$variantName=substr($classname, 0, $pos);
$variantFile = $classname == $variantName . 'Variant' ?
l_r('variants/' . $variantName . '/variant.php') :
l_r('variants/' . $variantName . '/classes/' . substr($classname, ($pos + 8)) . '.php');

if( $classname==$variantName.'Variant' )
require_once(l_r('variants/'.$variantName.'/variant.php'));
else
require_once(l_r('variants/'.$variantName.'/classes/'.substr($classname, ($pos+8)).'.php'));
}

?>
require_once $variantFile;
});

0 comments on commit 684ddb6

Please sign in to comment.