Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation and Admin Panel Update Bootstrap 5 #590

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
About
====

XG Proyect (XGP) is a web browser game based on the famous OGame. Our goal is to offer a package that is as similar as possible to the original, but keeping their original design.

Official Website: https://www.xgproyect.org/
Live Server: https://www.xgproyect.net/
XG Proyect (XGP) is an OGame clone open-source web application framework designed for creating game clones, particularly those inspired by the popular game OGame, set in a vast and captivating space-themed universe. Our goal is to offer a package that is as similar as possible to the original, but keeping their original design.

## Requirements

Expand All @@ -28,16 +25,20 @@ MySQLi 5.7 or greater
### Manually
This is the simplest and easiest way if you're not a technical person. Download and install XG Proyect will be easy! ;)

- Go to the releases section and get the latest stable release, and simply download it. It is the file `.zip` then you can do whatever you want with that package, use it on your local stack, hosting or even docker!
1. Go to [releases](https://github.com/XGProyect/XG-Proyect-v3.x.x/releases)
2. Look for the last version and then **assets** and finally look for the `.zip` file.
3. Unzip the file.
4. Browse the folder and search for the upload directory, there are hidden files in it, be sure that those are copied over also, specially the `.htaccess` file.
5. Using docker, XAMPP or any local stack that you want set the copies files to your root.

### Composer
Choose this option if you want to contribute to the project.

Composer which will get you everything, including docker and would install the test dependencies like PHPUnit.
Composer is a package manager and also a quick way to setup your project.

1. Run
```
composer create-project xgproyect/xgproyect
```
2. Once composer has finishing installing all the dependencies you can use docker, see below.

## How to run XG Proyect?
### Docker
Expand All @@ -62,6 +63,15 @@ Simple change the **PHP version** to any other **version** that you'd like to te
### Other ways
- Other options are also possible like XAMPP, or using it on your own hosting.

### DB Connect defaults
```
host=db
user=root
password=root
db=xgp
prefix=xgp_
```

## MailHog
XGP uses MailHog and PHPMailer as tools for better mailing support. MailHog allows you to intercept emails **locally** and receive them under a convenient panel.

Expand Down Expand Up @@ -93,4 +103,4 @@ The following are tools or frameworks that we use to do our coding experience be
</p>

## License
The XG Proyect is open-sourced software licensed under the GPL-3.0 License.
The XG Proyect is open-sourced software licensed under the GPL-3.0 License.
35 changes: 7 additions & 28 deletions app/Http/Controllers/Game/ResearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,43 +217,22 @@ private function doCommand()
}
}

/**
* method isLaboratoryInQueue
* param
* return true if all clear, false if is anything in the queue
*/
private function isLaboratoryInQueue()
private function isLaboratoryInQueue(): bool
{
$return = true;
$current_building = '';
$element_id = 0;

if ($this->planet['planet_b_building_id'] != 0) {
$current_queue = $this->planet['planet_b_building_id'];
$queue = explode(';', $current_queue);

if (strpos($current_queue, ';')) {
$queue = explode(';', $current_queue);

for ($i = 0; $i < MAX_BUILDING_QUEUE_SIZE; $i++) {
if (isset($queue[$i])) {
$element_data = explode(',', $queue[$i]);
$element_id = $element_data[0];

if ($element_id == 31) {
break;
}
for ($i = 0; $i < MAX_BUILDING_QUEUE_SIZE; $i++) {
if (isset($queue[$i])) {
if (explode(',', $queue[$i])[0] == 31) {
return false;
}
}
} else {
$current_building = $current_queue;
}

if ($current_building == 31 or $element_id == 31) {
$return = false;
}
}

return $return;
return true;
}

/**
Expand Down
21 changes: 10 additions & 11 deletions app/Http/Controllers/Game/TechtreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private function buildBlock(string $object_id): array

foreach ($objects as $object) {
$list_of_objects[] = [
'dpath' => DPATH,
'tt_info' => $object,
'tt_name' => $this->langs->language[$this->_resource[$object]],
'tt_detail' => '',
Expand All @@ -105,30 +106,28 @@ private function buildBlock(string $object_id): array
*
* @return array
*/
private function getRequirements(int $object): array
private function getRequirements(int $object, int $current_level = 0): array
{
$list_of_requirements = [];

if (!isset($this->_requirements[$object])) {
return $list_of_requirements;
}

foreach ($this->_requirements[$object] as $requirement => $level) {
foreach ($this->_requirements[$object] as $requirement => $required_level) {
$color = 'Red';
$current_resource_level = $this->planet[$this->_resource[$requirement]] ?? $this->user[$this->_resource[$requirement]] ?? 0;
$current_resource_level = max($current_resource_level, $current_level);

if ((isset($this->user[$this->_resource[$requirement]])
&& $this->user[$this->_resource[$requirement]] >= $level)
or (isset($this->planet[$this->_resource[$requirement]])
&& $this->planet[$this->_resource[$requirement]] >= $level)) {
if ($current_resource_level >= $required_level) {
$color = 'Green';
$display_level = $required_level;
} else {
$display_level = $current_resource_level . '/' . $required_level;
}

$list_of_requirements[] = FormatLib::{'color' . $color}(
FormatLib::formatLevel(
$this->langs->language[$this->_resource[$requirement]],
$this->langs->line('level'),
$level
)
FormatLib::formatLevel($this->langs->language[$this->_resource[$requirement]], $this->langs->line('level'), $display_level)
);
}

Expand Down
34 changes: 21 additions & 13 deletions app/Http/Controllers/Install/InstallationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private function buildPage(): void

// ACTION FOR THE CURRENT PAGE
$parse['alert'] = '';
$alerts = '';

switch ((isset($_POST['page']) ? $_POST['page'] : '')) {
case 'step1':
Expand Down Expand Up @@ -289,7 +290,7 @@ private function buildPage(): void
*/
private function serverRequirementes()
{
return !(version_compare(PHP_VERSION, '7.3.0', '<'));
return !(version_compare(PHP_VERSION, '7.4.0', '<'));
}

/**
Expand Down Expand Up @@ -341,20 +342,27 @@ private function isInstalled()
*
* @return boolean
*/
private function tablesExists()
private function tablesExists(): bool
{
$result = $this->installationModel->getListOfTables(DB_NAME);
$arr = [];

foreach ($result as $row) {
foreach ($row as $table) {
if (strpos($table, DB_PREFIX) !== false) {
$arr[] = $table;
// Check if $result is an array or an object before proceeding
if (is_array($result) || is_object($result)) {
foreach ($result as $row) {
foreach ($row as $table) {
if (strpos($table, DB_PREFIX) !== false) {
$arr[] = $table;
}
}
}
return (count($arr) > 0);
} else {
// Handle the case where $result is not of expected type
// For example, log the error or handle it in another appropriate way
// You can return false or throw an exception here, depending on your use case
return false;
}

return (count($arr) > 0);
}

/**
Expand Down Expand Up @@ -394,7 +402,7 @@ private function tryDatabase()
*/
private function writeConfigFile()
{
$config_file = @fopen(XGP_ROOT . CONFIGS_PATH . 'config.php', 'w');
$config_file = fopen(XGP_ROOT . CONFIGS_PATH . 'config.php', 'w');

if (!$config_file) {
return false;
Expand All @@ -417,8 +425,8 @@ private function writeConfigFile()
}

// check if something was created and delete it
if (file_exists($config_file)) {
unlink($config_file);
if (file_exists(XGP_ROOT . CONFIGS_PATH . 'config.php')) {
unlink(XGP_ROOT . CONFIGS_PATH . 'config.php');
}

return false;
Expand Down Expand Up @@ -559,12 +567,12 @@ private function saveMessage($message, $result = 'ok')
break;

case 'error':
$parse['color'] = 'alert-error';
$parse['color'] = 'alert-danger';
$parse['status'] = $this->langs->line('ins_error_title');
break;

case 'warning':
$parse['color'] = 'alert-block';
$parse['color'] = 'alert-warning';
$parse['status'] = $this->langs->line('ins_warning_title');
break;
}
Expand Down
Loading