Skip to content

Commit

Permalink
Cleanup install folder (slawkens#7)
Browse files Browse the repository at this point in the history
* Adding .env support  (slawkens#2)

* - adding composer

* - adding .env support

* Improve DotEnv and fix e-mail settings  (slawkens#3)

* - revert changes on config.php, add config.local.php

* - adding missing account e-mails settings

* - adding check before flush buffer (slawkens#4)

* - raw import myaac-gesior-shop-system-v5.0-beta.2

* Fresh install (slawkens#5)

* - adding hidden ids

* - hiding template

* - removing katherine template

* - moving game server files to a specific folder
  • Loading branch information
danilopucci committed Dec 31, 2023
1 parent c9e99a2 commit e8693bc
Show file tree
Hide file tree
Showing 311 changed files with 5,013 additions and 1,137 deletions.
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
WEBSITE_DATABASE_USER=my_user
WEBSITE_DATABASE_PASSWORD=my_password
WEBSITE_DATABASE_NAME=my_database_name
WEBSITE_DATABASE_HOST_IP=my_database_ip
WEBSITE_DATABASE_HOST_PORT=my_database_port
WEBSITE_URL=https://myurl.com
WEBSITE_EMAIL_SMTP=smtp.myhost.com
WEBSITE_EMAIL_SMTP_PORT=587
WEBSITE_EMAIL=noreply@myname.com
WEBSITE_EMAIL_PASSWORD=myemailpassword
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cypress/e2e/2-advanced-examples
releases
tmp

config.local.php
#config.local.php

# all custom templates
templates/*
Expand Down Expand Up @@ -72,3 +72,5 @@ landing

# others/rest
system/pages/downloads.php

.env
6 changes: 6 additions & 0 deletions .htaccess.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [L]
</IfModule>

# block files which needs to be hidden, specify .example extension of the file
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
Order allow,deny
Deny from all
</Files>
218 changes: 218 additions & 0 deletions admin/pages/gifts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
<?php
/**
* Gifts System
*
* @package MyAAC
* @author whiteblXK <admin@dbstory.eu>
* @copyright 2019 MyAAC
* @link https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Gifts';
require_once PLUGINS . 'gesior-shop-system/libs/shop-system.php';

$types = [
'item', 'addon', 'mount', 'pacc', 'container'
];

if(!empty($action)) {
$id = $_REQUEST['id'] ?? null;
$errors = array();

if($action == 'offer_form') {
$categories = GesiorShop::getCategories();

$values = [
'categories' => $categories,
'types' => $types,
];

$offer_id = $_REQUEST['id'] ?? null;
if ($offer_id !== null) {
$values['offer'] = GesiorShop::getOfferById($offer_id);
}

$twig->display('gesior-shop-system/templates/admin-offers-add.html.twig', $values);
} elseif($action == 'add' || $action == 'edit') {
if ($action == 'edit') {
$offer_id = $_REQUEST['offer_id'] ?? null;

if (!$offer_id) {
$errors[] = 'Offer id not set.';
}
}

$itemid1 = $count1 = $itemid2 = $count2 = 0;

$points = $_REQUEST['points'] ?? null;
$category_id = $_REQUEST['category'] ?? 1;
$offer_type = isset($_REQUEST['type']) ? strtolower($_REQUEST['type']) : null;
$offer_name = $_REQUEST['offer_name'] ?? null;
$offer_desc = $_REQUEST['description'] ?? '';
if(empty($points)) {
error('Please fill all fields. Points is empty.');
} else if(!$category_id || !is_numeric($category_id)) {
error('Please fill all fields. Category is empty or its not a number.');
} else if(empty($offer_type)) {
error('Please fill all fields. Type is empty.');
} else if(empty($offer_name)) {
error('Please fill all fields. Name is empty.');
} else {
switch($offer_type) {
case 'item':
$itemid1 = $_REQUEST['item_id'] ?? null;
$count1 = $_REQUEST['item_count'] ?? null;
if(!$itemid1 || !is_numeric($itemid1)) {
$errors[] = 'Please fill all fields. Item ID is empty or its not a number.';
}
else if(!$count1 || !is_numeric($count1)) {
$errors[] = 'Please fill all fields. Item Count is empty or its not a number.';
}

break;

case 'container':
$itemid1 = $_REQUEST['item_id'] ?? null;
$count1 = $_REQUEST['item_count'] ?? null;
$itemid2 = $_REQUEST['container_id'] ?? null;
$count2 = $_REQUEST['container_count'] ?? null;
if(!$itemid1 || !is_numeric($itemid1)) {
$errors[] = 'Please fill all fields. Item ID is empty or its not a number.';
}
else if(!$count1 || !is_numeric($count1)) {
$errors[] = 'Please fill all fields. Item Count is empty or its not a number.';
}
else if(!$itemid2 || !is_numeric($itemid2)) {
$errors[] = 'Please fill all fields. Container ID is empty or its not a number.';
}
else if(!$count2 || !is_numeric($count2)) {
$errors[] = 'Please fill all fields. Container Count is empty or its not a number.';
}

break;
case 'addon':
$itemid1 = $_REQUEST['look_female'] ?? null;
$count1 = $_REQUEST['addons_female'] ?? null;
$itemid2 = $_REQUEST['look_male'] ?? null;
$count2 = $_REQUEST['addons_male'] ?? null;

if(!$itemid1 || !is_numeric($itemid1)) {
$errors[] = 'Please fill all fields. Look Female is empty or its not a number.';
}
else if(!isset($count1) || !is_numeric($count1)) {
$errors[] = 'Please fill all fields. Addons Female is empty or its not a number.';
}
else if(!$itemid2 || !is_numeric($itemid2)) {
$errors[] = 'Please fill all fields. Look Male is empty or its not a number.';
}
else if(!isset($count2) || !is_numeric($count2)) {
$errors[] = 'Please fill all fields. Addons Male is empty or its not a number.';
}

break;

case 'mount':
$itemid1 = $_REQUEST['mount_id'] ?? null;

if(!$itemid1 || !is_numeric($itemid1)) {
$errors[] = 'Please fill all fields. Mount ID is empty or its not a number.';
}

break;

case 'pacc':
$count1 = $_REQUEST['days'] ?? null;

if(!$count1 || !is_numeric($count1)) {
$errors[] = 'Please fill all fields. Premium Days is empty or its not a number.';
}

break;

case 'other':
break;

default:
$errors[] = 'Unsupported offer type.';
}

if(empty($errors)) {
$data = [
'points' => $points,
'itemid1' => $itemid1, 'count1' => $count1,
'itemid2' => $itemid2, 'count2' => $count2,
'category_id' => $category_id,
'offer_type' => $offer_type,
'offer_name' => $offer_name, 'offer_description' => $offer_desc,
];

if ($action == 'edit') {
$db->update('z_shop_offer', $data, ['id' => $offer_id]);
success('Your offer has been edited!');
}
else {
$db->insert('z_shop_offer', $data);
success('Your offer has been saved!');
}
}
}
} else if($action == 'delete') {
GesiorShop::deleteOffer($id, $errors);
success("Deleted successful.");
} else if($action == 'toggle_hidden') {
GesiorShop::toggleOffer($id, $errors, $status);
success(($status == 1 ? 'Show' : 'Hide') . " successful.");
}
else if($action == 'moveup') {
GesiorShop::move($id, -1, $errors);
}
else if($action == 'movedown') {
GesiorShop::move($id, 1, $errors);
}
else if($action == 'edit_categories') {
$categoriesPost = $_REQUEST['categories'] ?? null;
if(empty($categoriesPost)) {
$errors[] = 'Please fill all fields. Categories are empty.';
}

$categoriesExploded = explode(',', $categoriesPost);

if (GesiorShop::saveCategories($categoriesExploded, $errors)) {
success('Saved categories.');
}

}
else if($action == 'reset_categories') {
$categoriesReset = ['Items', 'Addons', 'Mounts', 'Premium Account', 'Containers', 'Other'];
if (GesiorShop::saveCategories($categoriesReset, $errors)) {
success('Reset categories successful.');
}
}

if(!empty($errors))
error(implode(", ", $errors));
}

$categories = GesiorShop::getCategories();

$offers = array();
$offers_fetch = GesiorShop::getOffers(true);
if(!empty($offers_fetch)) {
foreach ($offers_fetch as $offer_id => $offer) {
$tmp_information = GesiorShop::createOfferInformation($offer, $offer['type']);
$offers[] = array_merge($offer, array('information' => $tmp_information));
}
}

if ($action !== 'offer_form') {
$twig->display('gesior-shop-system/templates/admin-categories.html.twig', [
'categories' => implode(',', array_values($categories)),
]);
}

$last = count($offers_fetch);
$twig->display('gesior-shop-system/templates/admin-offers.html.twig', [
'offers' => $offers,
'categories' => $categories,
'last' => $last,
]);
27 changes: 27 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"require": {
"php": "^8.0",
"ext-pdo": "*",
"ext-pdo_mysql": "*",
"ext-json": "*",
"ext-xml": "*",
"ext-dom": "*",
"phpmailer/phpmailer": "^6.1",
"composer/semver": "^3.2",
"twig/twig": "^2.0",
"erusev/parsedown": "^1.7",
"nikic/fast-route": "^1.3",
"matomo/device-detector": "^6.0",
"illuminate/database": "^10.18",
"peppeocchi/php-cron-scheduler": "4.*",
"vlucas/phpdotenv": "^5.5"
},
"require-dev": {
"filp/whoops": "^2.15"
},
"autoload": {
"psr-4": {
"MyAAC\\": "system/src"
}
}
}
61 changes: 61 additions & 0 deletions config.local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

require_once __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();

// place for your configuration directives; so you can later easily update myaac
$config['installed'] = true;
$config['env'] = 'prod'; // dev or prod
$config['server_path'] = '/var/www/html/gameserverfiles/';

$config['gifts_system'] = true;

$config['template'] = 'old-school'; // template used by website (kathrine, tibiacom)
$config['template_allow_change'] = false; // allow users to choose their own template while browsing website?
$config['highscores_ids_hidden'] = array(5, 6, 7, 8, 9);

$config['date_timezone'] = 'UTC';
$config['client'] = '772';
$config['anonymous_usage_statistics'] = true;
$config['session_prefix'] = 'myaac_n9f5f8in_';
$config['cache_prefix'] = 'myaac_cb8lia18_';

// database
$config['database_host'] = $_ENV['WEBSITE_DATABASE_HOST_IP'];
$config['database_port'] = $_ENV['WEBSITE_DATABASE_HOST_PORT']; // leave blank to default 3306
$config['database_user'] = $_ENV['WEBSITE_DATABASE_USER'];
$config['database_password'] = $_ENV['WEBSITE_DATABASE_PASSWORD'];
$config['database_name'] = $_ENV['WEBSITE_DATABASE_NAME'];
$config['database_encryption'] = 'sha1';



// mail
$config['mail_enabled'] = true; // is aac maker configured to send e-mails?
$config['mail_address'] = $_ENV['WEBSITE_EMAIL'];; // server e-mail address (from:)
$config['mail_admin'] = $_ENV['WEBSITE_EMAIL'];; // admin email address; where mails from contact form will be sent
$config['mail_signature'] = array( // signature that will be included at the end of every message sent using _mail function
'plain' => ""/*"--\nMy Server,\nhttp://www.myserver.com"*/,
'html' => ''/*'<br/>My Server,\n<a href="http://www.myserver.com">myserver.com</a>'*/
);

// account e-mail
$config['send_mail_when_change_password'] = true; // send e-mail with new password when change password to account
$config['send_mail_when_generate_reckey'] = true; // send e-mail with rec key (key is displayed on page anyway when generate)
$config['account_mail_verify'] = false;
$config['account_mail_unique'] = true; // email addresses cannot be duplicated? (one account = one email)

// smtp
$config['smtp_enabled'] = true; // send by smtp or mail function (set false if use mail function; set to true if you use GMail or Microsoft Outlook)
$config['smtp_auth'] = true; // need authorization?
$config['smtp_host'] = $_ENV['WEBSITE_EMAIL_SMTP']; // mail host. smtp.gmail.com for GMail / smtp-mail.outlook.com for Microsoft Outlook
$config['smtp_port'] = $_ENV['WEBSITE_EMAIL_SMTP_PORT']; // 25 (default) / 465 (ssl; GMail) / 587 (tls; Microsoft Outlook)
$config['smtp_user'] = $_ENV['WEBSITE_EMAIL']; // here your email username
$config['smtp_pass'] = $_ENV['WEBSITE_EMAIL_PASSWORD'];

$config['smtp_secure'] = 'ssl'; // What kind of encryption to use on the SMTP connection. Options: ''; 'ssl'](GMail) or 'tls'](Microsoft Outlook)

$config['smtp_debug'] = true; // set true to debug (you will see more info in error.log)
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,4 @@
'words' => array(),
),

);
);
28 changes: 28 additions & 0 deletions gameserverfiles/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
serverName = "Vetus"

-- system/status.php
statusPort = 7171
statusTimeout = 2000

-- login.php
gameProtocolPort = 7171
ip = "192.168.18.128"
worldType = 'pvp'
freePremium = false

-- system/pages/experiencestages.php
experienceStages = {
{ minlevel = 1, maxlevel = 8, multiplier = 7 },
{ minlevel = 9, maxlevel = 20, multiplier = 6 },
{ minlevel = 21, maxlevel = 50, multiplier = 5 },
{ minlevel = 51, maxlevel = 100, multiplier = 4 },
{ minlevel = 101, multiplier = 3 }
}
rateExperience = 1

-- system/pages/houses.php
houseRentPeriod = 1
houseCleanOld = false

-- system/pages/online.php
worldId = 1
6 changes: 6 additions & 0 deletions gameserverfiles/data/XML/groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<groups>
<group id="1" name="player" flags="0" maxdepotitems="0" maxvipentries="0" access="0" />
<group id="2" name="gamemaster" flags="412316860415" maxdeoptitems="0" maxvipentries="0" access="1" />
<group id="3" name="god" flags="547608305658" maxdepotitems="0" maxvipentries="0" access="1" />
</groups>
Loading

0 comments on commit e8693bc

Please sign in to comment.