Compare commits

...

88 Commits

Author SHA1 Message Date
slawkens
c914a73352 * update to 0.6.0 2017-10-16 17:18:37 +02:00
slawkens
5041ed1564 * added client 11.00 to install options 2017-10-16 16:54:59 +02:00
slawkens
4daaa67710 * new account.login view for tibiacom template
* added new indicator icons for create account, create character and change character name
* attempt to fix incorrect views counter behavior (its resetting to 0 in some cases)
* moved check_* functions to class Validator
* from now all validators ajax requests will fire onblur instead of onkeyup
* ajax requests returns now json instead of xml
* added 404 response when file is not found
* fixed gallery
2017-10-16 16:49:35 +02:00
slawkens
dd572b00d0 * renamed screenshots to gallery and movies to videos 2017-10-16 09:25:26 +02:00
slawkens1
3fef1a6eec * fix for php versions under 5.5 where empty() function supported only variables 2017-10-15 22:12:23 +02:00
slawkens1
6d81a29bb6 * check if monster file exist before loading it 2017-10-15 21:53:44 +02:00
slawkens1
3f1c638a14 * removed never used lib - dwoo 2017-10-15 21:32:21 +02:00
slawkens1
7caca74d57 * fixed editing page in admin panel 2017-10-15 20:47:04 +02:00
slawkens
d95aea319e * fixed forum new post on mac os and some specific mysql versions
* fixed Account::getGuildAccess function
2017-10-13 15:30:29 +02:00
slawkens
9aed09d250 Added missing change email and change info buttons to account.management template 2017-10-13 09:11:15 +02:00
slawkens1
3ebcd788fb * also fixed frags table 2017-10-12 20:19:47 +02:00
slawkens1
816751f464 * fixed character deaths table 2017-10-12 20:18:04 +02:00
slawkens
f84ae88aa4 * added faq management - add/edit/move/hide/delete from website
* moved install pages to twig
* load monsters and spells on installation of the AAC
2017-10-12 17:40:02 +02:00
slawkens1
315e0400ff * fixed config loaded when some inline comments are present 2017-10-11 23:19:11 +02:00
slawkens1
22cf7f5d4f * more fixes to plugin dot 2017-10-11 22:26:16 +02:00
slawkens1
6ec829e47f * fixed if plugin zip file name contains dot (.) 2017-10-11 22:22:12 +02:00
slawkens1
a119d75589 * added if HTTP_IF_MODIFIED_SINCE 2017-10-11 21:58:28 +02:00
slawkens1
92028a2492 * enabled cache http headers for signatures
* disabled fullpage plugin in tinymce
2017-10-11 21:25:49 +02:00
slawkens
42ef8487c8 * updated changelog 2017-10-11 17:05:30 +02:00
slawkens
e92e5d1040 * update to 0.5.1 2017-10-11 17:01:14 +02:00
slawkens
a1950cf27e * fixed forum add/edit board 2017-10-11 16:59:31 +02:00
slawkens
27fb0ffb06 * update templates cache when installing/uninstalling plugin 2017-10-11 15:50:47 +02:00
slawkens
6c3439acf9 * check if plugin exist before uninstalling
* fixed some bug when you uninstall and then try to install again on the same page
* moved some characters.frags code to twig template
2017-10-11 15:24:54 +02:00
slawkens
005356ebb3 * new configurable: highscores_length, how much highscores to display
* fixed characters twig template loading
* fixed highscores links
2017-10-11 14:43:11 +02:00
slawkens
f0adabf567 * moved character deaths and frags table generation to twig
* fixed some warning in OTS_Base_DB
2017-10-11 13:49:57 +02:00
slawkens
739782109e * update to 0.5.0 2017-10-10 15:50:46 +02:00
slawkens
87ba018ab8 * some fix 2017-10-10 15:42:52 +02:00
slawkens
041702615f * fixed so you can also use slash in custom pages 2017-10-10 15:39:00 +02:00
slawkens
0a82f306f6 * moved admin pages to twig
* edited account.management.html.twig to fit modern templates, tibiacom have its own template
* sample characters are now assigned to admin account and have group_id 4 to not be shown on highscores
* fixed database pages loading
* added require.database plugin option, which will prove if DATABASE_VERSION is enough
2017-10-10 15:32:59 +02:00
slawkens1
856e72150c * fixed adding/editing commands
* fixed undefined index in install plugin
2017-10-09 20:34:06 +02:00
slawkens1
e2857f8ca5 * suggested by @gpedro 2017-10-09 20:01:29 +02:00
slawkens
04d9ec9c94 * updated tinymce to the latest (4.7.0) version
* added option to uninstall plugin
* added option to require specified myaac or php version for plugins
* added links loaded from database to admin panel - for future plugins
* added few characters hooks
* fixed some kathrine template js bug when shop is disabled
2017-10-09 16:47:34 +02:00
slawkens1
e984a467ef * print some info to error.log when can't find config.lua 2017-10-08 22:04:33 +02:00
slawkens1
8342a7b8a8 * fixed links like serverInfo (capitalized) 2017-10-08 20:53:45 +02:00
Sławek
269af1930c * updated readme 2017-10-08 19:07:21 +02:00
slawkens1
b7bb950abc * fixed typo 2017-10-08 18:59:43 +02:00
slawkens1
4a19458c15 * moved functions declaration a bit upper, so it can use str_replace_first 2017-10-08 18:24:35 +02:00
slawkens1
b6db420465 * fixed redirects when BASE_DIR is empty 2017-10-08 18:12:06 +02:00
slawkens
7b234ad41f * moved .htaccess rules to plain php (index.php)
Its a salut to nginx and other web server nutzer (not apache), as they can now simply redirect all requests with simple rule to index.php, and php will take care of all redirects. .htaccess just now redirects everything to index.php with simple 3 lines.
* change accountmanagement links to use friendly_urls
* fixed creating new forum thread
* some fixes in account changecomment action
* show info when account name/number or password is empty on login
* fixed showing account login errors
* added new twig function getLink that convert link taking into account config.friendly_urls
* internalLayoutLink -> getLink
2017-10-06 17:11:06 +02:00
slawkens
35b0795b51 * update to 0.4.3 2017-10-05 17:19:49 +02:00
slawkens
04a7796665 * moved some guild pages and account to twig
* fixed account create javascript warnings when fields are empty
2017-10-05 17:07:49 +02:00
slawkens1
755deae717 * enable auto_reload option for twig 2017-10-05 00:48:34 +02:00
slawkens1
6d66dc9043 * fixed country detection (was a little typo) 2017-10-05 00:38:48 +02:00
slawkens1
bbd9cd2101 * fixed showing of character deaths and frags 2017-10-04 20:52:36 +02:00
slawkens
b6ccde075d * moved some more pages to twig
* moved online, movies, google_analytics code, faq, experience_table, downloads to twig
* added new global variabl to twig (status)
* removed some unused page (custom.php)
* automatically append trailing slash at config.item_images_url
* moved downloads from clients.halfaway.net to tibia-clients.com
* show some more info on monster loot (currently only on TFS 0.3 and those that use item.id in monster files instead of item name)
* some more unimportant fixes
2017-10-04 17:49:54 +02:00
slawkens1
e94b9006e6 * set deletion = 0 on sample characters, so it won't be deleted by tfs 1.0 on startup 2017-09-30 14:06:52 +02:00
slawkens1
e9c8159bf3 * new, better config.lua parser from latest gesior
you can also now include files in your config.lua file by using
dofile('config.local.lua') and it will be loaded by aac
2017-09-30 00:32:26 +02:00
slawkens1
919f69ef46 * first check if page to load exist in database, then in pages/ dir 2017-09-29 22:33:25 +02:00
slawkens1
4ac2fe27d5 * fixed rook sample
* rook sample will now have level 1, 150 health, 0 mana, and 400 cap.
2017-09-29 18:30:53 +02:00
slawkens1
be2daeb4ab * fixed https://otland.net/threads/myaac-v0-0-1.251454/page-13#post-2466303
and https://otland.net/threads/myaac-v0-0-1.251454/page-13#post-2466313
2017-09-26 03:02:51 +02:00
slawkens1
7b96ce9b8c * added CREDITS file 2017-09-14 20:13:23 +02:00
slawkens
801188f957 * fixed country selection in create account
* deleted some useless code
2017-09-14 16:37:01 +02:00
slawkens
c546a46847 * moved rules to twig
* added bugtracker to kathrine template
2017-09-14 15:03:09 +02:00
slawkens
6527d21794 * updated version number
* updated to 0.4.2
2017-09-14 08:37:53 +02:00
slawkens
7fad722927 * update to 0.4.1 2017-09-13 16:39:09 +02:00
slawkens
ab249eb95f * fixed log in to admin panel
* fixed File is not .zip plugin upload error
2017-09-13 16:35:06 +02:00
slawkens
bdbd215aad * renamed some variable that caused problems with some templates 2017-09-13 15:53:56 +02:00
slawkens
68212a36bb *this 2017-09-13 15:35:08 +02:00
slawkens
ac3691dc08 * update to 0.4.0
* fixed some bugs in bugtracker
* updated database to version 9
2017-09-13 15:30:18 +02:00
slawkens
3a6aab67d5 * moved account.create and news.archive to twig
* added new configurable date_timezone
2017-09-13 14:32:50 +02:00
slawkens
2c5b3f4da3 * added some more mime types to zip file detection 2017-09-13 10:53:04 +02:00
slawkens
73eca63c4f * automatically detect json file in .zip instead of basing on filename 2017-09-13 09:03:48 +02:00
slawkens
c504588993 * added option to add/edit/delete/hide/move forum boards
* now whole account management page is moved to Twig
* renamed table forum_sections to forum_boards
* fixed some rare error when user is logged in for longer than 15 minutes and tries to login again
2017-09-12 15:55:23 +02:00
slawkens
5b14c6d4d4 * fixed global config variable in twig templates
* rest from account.create_character moved to twig
* fixed some grammar errors
* fixed some separators in kathrine template
2017-09-11 17:41:27 +02:00
slawkens
4685c7b868 * renamed twig templates to .twig, so IDE's can correctly render it
* moved news.add to twig template
* now twig templates will be loaded directly from template dir f.e. templates/kathrine/news.html.twig
2017-09-11 11:11:43 +02:00
slawkens
0e185c8bcf *more templates moved to Twig
*some not important small changes
2017-09-08 07:36:33 +02:00
Sławek
e230949edd Merge pull request #9 from AngelOfDeaths/patch-1
*Added to template bugtracker
2017-09-04 20:30:54 +02:00
Angel Of Death
a897b5e98c *Rework old code 2017-09-04 20:19:22 +02:00
Sławek
186d3dbd38 Merge pull request #8 from AngelOfDeaths/patch-4
*Added Bug Report page
2017-09-04 09:19:50 +02:00
Sławek
127c04070b Merge pull request #7 from AngelOfDeaths/patch-3
*Added Support Label and Report Bug
2017-09-04 09:19:10 +02:00
AngelOfDeaths
6ff65050f5 *correct to shop history transactions 2017-09-03 21:08:20 +02:00
AngelOfDeaths
d605ef4b28 *Added shopoffer 2017-09-03 18:46:34 +02:00
AngelOfDeaths
9466b7ce75 *Added to template bugtracker 2017-09-03 18:29:39 +02:00
AngelOfDeaths
7f6eff666e *Added Bug Report page 2017-09-03 17:42:45 +02:00
AngelOfDeaths
e878b4df48 *Added Support Label and Report Bug 2017-09-03 17:27:39 +02:00
Sławek
2c3c1529a7 Merge pull request #5 from AngelOfDeaths/patch-1
* Fix
2017-09-03 15:42:20 +02:00
Sławek
ecce524c7b Merge pull request #6 from AngelOfDeaths/patch-2
* Fixed Wrong name of table
2017-09-03 15:42:03 +02:00
AngelOfDeaths
5af617b869 * Fixed Wrong name of table 2017-09-03 14:48:51 +02:00
AngelOfDeaths
3f886c9f7c * Fix
missing . on bugtracker.php line 288
2017-09-03 14:40:05 +02:00
slawkens
d50fb7a291 * moved characters.php html code to Twig template
* moved news.php to Twig news.html template
* fixed some duplicated code in signature generators
* always check if name parameter is set when generating signatures
2017-09-01 17:00:29 +02:00
slawkens
37502c5562 * moved more templates to Twig
* now you can replace template in your main template, example is templates/kathrine/templates/success.html
* removed output_errors, replace with template
* some grammar fixes
* moved some forum code to Twig templates
* added movies link to tibiacom template
2017-08-31 17:01:17 +02:00
slawkens
7620ec896b Merge branch 'master' of https://github.com/slawkens/myaac 2017-08-29 17:38:37 +02:00
slawkens
8a87186833 * more templates moved to Twig 2017-08-29 17:38:32 +02:00
slawkens1
b0f8013762 * and this 2017-08-28 23:59:04 +02:00
slawkens1
3a6a1c448a * log errors instead showing them to users with system directories
* now it will print a notice, and aditionally log full path into
system/logs/error.log
* also, when it fails to load config.lua it will output error also to
error.log
* fix when $_SERVER['HTTP_ACCEPT_ENCODING'] is not set.
2017-08-28 23:58:53 +02:00
slawkens1
2cd9f80b34 * fixed Twig loading on case-sensitive systems 2017-08-28 22:52:27 +02:00
slawkens1
d88de8e072 * fixed Twig loading on case-sensitive systems 2017-08-28 22:43:03 +02:00
slawkens1
6e6ce55a7b * some better info when fetching latest version 2017-08-28 21:06:57 +02:00
1055 changed files with 9903 additions and 56907 deletions

View File

@@ -1,33 +1,7 @@
Options -Indexes -MultiViews Options -Indexes -MultiViews
RewriteEngine On RewriteEngine On
#RewriteBase /
# Page parser
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-_+']+)\.png/?$ tools/signature/index.php?name=$1 [L] RewriteRule ^.*$ index.php [L]
RewriteRule ^characters/([A-Za-z0-9-_+']+)$ index.php?subtopic=characters&name=$1
RewriteRule ^guilds/([A-Za-z0-9-_+']+)$ index.php?subtopic=guilds&action=show&guild=$1
RewriteRule ^forum/board/([0-9]+)$ index.php?subtopic=forum&action=show_board&id=$1
RewriteRule ^forum/board/([0-9]+)/([0-9]+)$ index.php?subtopic=forum&action=show_board&id=$1&page=$2
RewriteRule ^forum/thread/([0-9]+)$ index.php?subtopic=forum&action=show_thread&id=$1
RewriteRule ^forum/thread/([0-9]+)/([0-9]+)$ index.php?subtopic=forum&action=show_thread&id=$1&page=$2
RewriteRule ^forum/board/([0-9]+)/([0-9]+)$ index.php?subtopic=forum&action=show_thread&id=$1&page=$2
RewriteRule ^account/manage$ index.php?subtopic=accountmanagement
RewriteRule ^account/create$ index.php?subtopic=createaccount
RewriteRule ^account/lost$ index.php?subtopic=lostaccount
RewriteRule ^account/logout$ index.php?subtopic=accountmanagement&action=logout
RewriteRule ^news/archive/([0-9]+)$ index.php?subtopic=newsarchive&id=$1
RewriteRule ^news/archive$ index.php?subtopic=newsarchive
RewriteRule ^highscores/([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)?$ index.php?subtopic=highscores&list=$1&vocation=$2
RewriteRule ^highscores/([A-Za-z0-9-_']+)$ index.php?subtopic=highscores&list=$1
RewriteRule ^polls/([0-9]+)$ index.php?subtopic=polls&id=$1
RewriteRule ^admin/$ admin/index.php
RewriteRule ^install/$ install/index.php
# temp solution >.>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9-_]+)/?$ index.php?p=$1 [L]
RewriteRule ^([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)?$ index.php?p=$1&action=$2 [L]

View File

@@ -1,3 +1,93 @@
[0.6.0 - 16.10.2017]
- added faq management - add/edit/move/hide/delete from website
- new account.login view for tibiacom template
- monsters and spells are now being loaded at the installation of the AAC
- fix for php versions under 5.5 where empty() function supported only variables
- added missing change email and change info buttons to account.management default template
- added new indicator icons for create account, create character and change character name
- fixed config loader when some inline comments are present
- fixed editing page in admin panel that contains some html code
- fixed forum new post on mac os and some specific mysql versions
- attempt to fix incorrect views counter behavior (its resetting to 0 in some cases)
- enabled cache http headers for signatures
- check if monster file exist before loading it
- fixed if plugin zip file name contains dot (.)
- renamed screenshots to gallery and movies to videos
- moved install pages to twig
- fixed Account::getGuildAccess function
- removed never used library from sources - dwoo
- moved check_* functions to class Validator
- from now all validators ajax requests will fire onblur instead of onkeyup
- ajax requests returns now json instead of xml
- added 404 response when file is not found
[0.5.1 - 11.10.2017]
- fixed forum add/edit board
- new configurable: highscores_length, how much highscores to display
- fixed highscores links (ALL, previous and next page)
- update templates cache when installing/uninstalling plugin
- moved character deaths and frags table generation to twig
- fixed some bug when you uninstall plugin and then try to install again on the same page
- check if plugin exist before uninstalling
- fixed some warning in OTS_Base_DB
[0.5.0 - 10.10.2017]
- moved .htaccess rules to plain php (index.php)
- updated tinymce to the latest (4.7.0) version, you can now embed code, for example youtube videos
- added option to uninstall plugin
- added option to require specified myaac, php or database version for plugins, without that plugin won't be installed
- change accountmanagement links to use friendly_urls
- fixed creating new forum thread
- sample characters are now assigned to admin account and have group_id 4 to not be shown on highscores
- added links loaded from database to admin panel - for future plugins
- print some info to error.log when can't find config.lua
- some fixes in account changecomment action
- show info when account name/number or password is empty on login
- fixed showing account login errors
- added few characters hooks
- fixed some kathrine template js bug when shop is disabled
- you can now use slash '/' in custom pages loaded from database
- added new twig function getLink that convert link taking into account config.friendly_urls
- internalLayoutLink -> getLink
[0.4.3 - 05.10.2017]
- better config loader taken from latest gesior, you can now include files in your config by doing dofile('config.local.lua')
- fixed country detection in create account
- fixed showing of character deaths and frags
- fixed https://otland.net/threads/myaac-v0-0-1.251454/page-13#post-2466303
- fixed https://otland.net/threads/myaac-v0-0-1.251454/page-13#post-2466313
- fixed rook sample, which will now have level 1, 150 health, 0 mana, and 400 cap.
- fixed samples being deleted by tfs 1.0+ cause of 'deletion' field set to 1
- pages loaded from database have higher priority than normal .php pages, so they will be loaded first if they exist
- moved many pages to twig templates
- change download client links from clients.halfaway.net to tibia-clients.com
- added bugtracker to kathrine template
- added CREDITS file
[0.4.2 - 14.09.2017]
- updated version number
[0.4.1 - 13.09.2017]
- fixed log in to admin panel
- fixed File is not .zip plugin upload error
[0.4.0 - 13.09.2017
- added option to add/edit/delete/hide/move forum boards
- moved some of HTML-in-PHP code to Twig templates
- added bug_report configurable which can enable/disable bug tracker
- log errors instead of showing them to users with system directories
- fix when $_SERVER['HTTP_ACCEPT_ENCODING'] is not set
- when it fails to load config.lua it will output error also to error.log
- automatically detect json file in .zip instead of basing on filename (admin panel - plugins)
- hopefully fixed the error with "The file you are trying to upload is not a .zip file. Please try again."
- fixed wrong name of table in bugtracker
- fixed some bugs in bugtracker
- added report bug link in templates
- fixed some rare error when user is logged in for longer than 15 minutes and tries to login again
- fixed some grammar errors
- some small improvements
- fixed some separators in kathrine template
[0.3.0 - 28.08.2017] [0.3.0 - 28.08.2017]
- added administration panel for screenshots management with auto thumbnail generator and image auto-resizing - added administration panel for screenshots management with auto thumbnail generator and image auto-resizing
- added Twig template engine and moved some html-in-php code to it - added Twig template engine and moved some html-in-php code to it

2
CREDITS Normal file
View File

@@ -0,0 +1,2 @@
* Gesior.pl (2007 - 2008)
* Slawkens (2009 - 2017)

View File

@@ -1,7 +1,7 @@
# myaac # myaac
MyAAC is a free and open-source Automatic Account Creator (AAC) written in PHP. It is a fork of the [Gesior](https://github.com/gesior/Gesior2012) project. It supports only MySQL databases. MyAAC is a free and open-source Automatic Account Creator (AAC) and Content Management System (CMS) written in PHP. It is a fork of the [Gesior](https://github.com/gesior/Gesior2012) project. It supports only MySQL databases.
Official website: http://my-aac.org Official website: https://my-aac.org
### REQUIREMENTS ### REQUIREMENTS
@@ -27,7 +27,7 @@ Official website: http://my-aac.org
chmod 660 config.local.php chmod 660 config.local.php
chmod 660 images/guilds chmod 660 images/guilds
chmod 660 images/houses chmod 660 images/houses
chmod 660 images/screenshots chmod 660 images/gallery
Visit http://your_domain/install (http://localhost/install) and follow instructions in the browser. Visit http://your_domain/install (http://localhost/install) and follow instructions in the browser.

View File

@@ -9,6 +9,8 @@ if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['i
die('Setup detected that <b>install/</b> directory exists. Please visit <a href="' . BASE_URL . 'install">this</a> url to start MyAAC Installation.<br/>Delete <b>install/</b> directory if you already installed MyAAC.<br/>Remember to REFRESH this page when you\'re done!'); die('Setup detected that <b>install/</b> directory exists. Please visit <a href="' . BASE_URL . 'install">this</a> url to start MyAAC Installation.<br/>Delete <b>install/</b> directory if you already installed MyAAC.<br/>Remember to REFRESH this page when you\'re done!');
} }
define('ADMIN_PANEL', true);
$content = ''; $content = '';
// validate page // validate page
@@ -25,6 +27,9 @@ require(SYSTEM . 'status.php');
require(SYSTEM . 'login.php'); require(SYSTEM . 'login.php');
require(ADMIN . 'includes/functions.php'); require(ADMIN . 'includes/functions.php');
$twig->addGlobal('config', $config);
$twig->addGlobal('status', $status);
// if we're not logged in - show login box // if we're not logged in - show login box
if(!$logged || !admin()) { if(!$logged || !admin()) {
$page = 'login'; $page = 'login';

View File

@@ -26,7 +26,7 @@
<a href="<?php echo BASE_URL; ?>" target="_blank">Preview</a> <span class="separator">|</span> <a href="?action=logout">Log out<img src="<?php echo BASE_URL; ?>images/icons/logout.png" alt="" title="Log out" /></a> <a href="<?php echo BASE_URL; ?>" target="_blank">Preview</a> <span class="separator">|</span> <a href="?action=logout">Log out<img src="<?php echo BASE_URL; ?>images/icons/logout.png" alt="" title="Log out" /></a>
</div> </div>
<?php endif; ?> <?php endif; ?>
<h1><?php echo $config['lua']['serverName'] . ' - ' . $title; ?> - Admin Panel</h1> <h1><?php echo $config['lua']['serverName'] . (isset($title) ? ' - ' . $title : ''); ?> - Admin Panel</h1>
</div> </div>
<div id="wrapper"> <div id="wrapper">
<?php <?php
@@ -78,6 +78,19 @@
} }
echo '</li>'; echo '</li>';
} }
$query = $db->query('SELECT `name`, `page`, `flags` FROM `' . TABLE_PREFIX . 'admin_menu` ORDER BY `ordering`');
$menu_db = $query->fetchAll();
foreach($menu_db as $item) {
if($item['flags'] == 0 || hasFlag($item['flags'])) {
echo '<li><h3>
<a href="?p=' . $item['page'] . '">';
if($page == $item['page']) echo '<u>';
echo $item['name'];
if($page == $item['page']) echo '</u>';
echo '</a></h3></li>';
}
}
?> ?>
</ul> </ul>
</div> </div>

View File

@@ -21,14 +21,14 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
session_start(); session_start();
define('MYAAC', true); define('MYAAC', true);
define('MYAAC_VERSION', '0.3.0'); define('MYAAC_VERSION', '0.6.0');
define('DATABASE_VERSION', 7); define('DATABASE_VERSION', 11);
define('TABLE_PREFIX', 'myaac_'); define('TABLE_PREFIX', 'myaac_');
define('START_TIME', microtime(true)); define('START_TIME', microtime(true));
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX')); define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX'));
@@ -43,8 +43,9 @@ define('FLAG_CONTENT_FORUM', 32);
define('FLAG_CONTENT_COMMANDS', 64); define('FLAG_CONTENT_COMMANDS', 64);
define('FLAG_CONTENT_SPELLS', 128); define('FLAG_CONTENT_SPELLS', 128);
define('FLAG_CONTENT_MONSTERS', 256); define('FLAG_CONTENT_MONSTERS', 256);
define('FLAG_CONTENT_SCREENSHOTS', 512); define('FLAG_CONTENT_GALLERY', 512);
define('FLAG_CONTENT_MOVIES', 1024); define('FLAG_CONTENT_VIDEOS', 1024);
define('FLAG_CONTENT_FAQ', 2048);
// news // news
define('NEWS', 1); define('NEWS', 1);

View File

@@ -13,7 +13,7 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
@@ -35,6 +35,7 @@ $config = array(
// gesior backward support (templates & pages) // gesior backward support (templates & pages)
// allows using gesior templates and pages with myaac // allows using gesior templates and pages with myaac
// might bring some performance when disabled
'backward_support' => true, 'backward_support' => true,
// head options (html) // head options (html)
@@ -45,7 +46,7 @@ $config = array(
// footer // footer
'footer' => ''/*'<br/>Your Server &copy; 2016. All rights reserved.'*/, 'footer' => ''/*'<br/>Your Server &copy; 2016. All rights reserved.'*/,
'debug_level' => 0, // 0 - disabled, 1 - show load time, 2 - show db query counter, 3 - both, 4 - memory usage, 5 - load time & load time, 6 - queries & memory usage, 7 - all 'debug_level' => 0, // 0 - disabled, 1 - show load time, 2 - show db query counter, 3 - both, 4 - memory usage, 5 - load time & memory usage, 6 - queries & memory usage, 7 - all
'language' => 'en', // default language (currently only 'en' available) 'language' => 'en', // default language (currently only 'en' available)
'language_allow_change' => false, 'language_allow_change' => false,
@@ -65,7 +66,7 @@ $config = array(
'database_password' => '', 'database_password' => '',
'database_name' => '', 'database_name' => '',
// multiworld system // multiworld system (only TFS 0.3)
'multiworld' => false, // use multiworld system? 'multiworld' => false, // use multiworld system?
'worlds' => array( // list of worlds 'worlds' => array( // list of worlds
//'1' => 'Your World Name', //'1' => 'Your World Name',
@@ -157,7 +158,8 @@ $config = array(
'signature_enabled' => true, 'signature_enabled' => true,
'signature_type' => 'tibian', // signature engine to use: tibian, mango, gesior 'signature_type' => 'tibian', // signature engine to use: tibian, mango, gesior
'signature_cache_time' => 5, // how long to store cached file (in minutes) 'signature_cache_time' => 5, // how long to store cached file (in minutes), default 5 minutes
'signature_browser_cache' => 60, // how long to cache by browser (in minutes), default 1 hour
// online page // online page
'online_record' => true, // display players record? 'online_record' => true, // display players record?
@@ -184,6 +186,7 @@ $config = array(
'highscores_outfit' => true, // show player outfit? 'highscores_outfit' => true, // show player outfit?
'highscores_country_box' => false, // doesnt work yet! (not implemented) 'highscores_country_box' => false, // doesnt work yet! (not implemented)
'highscores_groups_hidden' => 4, // this group id and higher won't be shown on the highscores 'highscores_groups_hidden' => 4, // this group id and higher won't be shown on the highscores
'highscores_length' => 100, // how many records per page on highscores
// characters page // characters page
'characters' => array( // what things to display on character view page (true/false in each option) 'characters' => array( // what things to display on character view page (true/false in each option)
@@ -201,14 +204,17 @@ $config = array(
), ),
// news page // news page
'news_limit' => 5, // limit of news on latest news page 'news_limit' => 5, // limit of news on the latest news page
'news_ticker_limit' => 5, // limit of news in tickers (mini news) (0 to disable) 'news_ticker_limit' => 5, // limit of news in tickers (mini news) (0 to disable)
'news_date_format' => 'j.n.Y', // check php manual date() function for more info about this 'news_date_format' => 'j.n.Y', // check php manual date() function for more info about this
'news_author' => true, 'news_author' => true, // show author of the news
// gifts/shop system // gifts/shop system
'gifts_system' => false, 'gifts_system' => false,
// support/system
'bug_report' => true,
// forum // forum
'forum' => 'site', // link to the server forum, set to "site" if you want to use build in forum system, otherwise leave empty if you aren't going to use any forum 'forum' => 'site', // link to the server forum, set to "site" if you want to use build in forum system, otherwise leave empty if you aren't going to use any forum
'forum_level_required' => 0, // level required to post, 0 to disable 'forum_level_required' => 0, // level required to post, 0 to disable
@@ -228,6 +234,7 @@ $config = array(
'google_analytics_id' => '', // e.g.: UA-XXXXXXX-X 'google_analytics_id' => '', // e.g.: UA-XXXXXXX-X
'experiencetable_columns' => 5, // how many columns to display in experience table page. * experiencetable_rows, 5 = 500 (will show up to 500 level) 'experiencetable_columns' => 5, // how many columns to display in experience table page. * experiencetable_rows, 5 = 500 (will show up to 500 level)
'experiencetable_rows' => 100, // till how many levels in one column 'experiencetable_rows' => 100, // till how many levels in one column
'date_timezone' => 'Europe/Berlin', // more info at http://php.net/manual/en/timezones.php
'monsters' => array(), 'monsters' => array(),
'npc' => array() 'npc' => array()

View File

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
images/global/general/blank.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
images/global/general/box-top.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
images/global/general/chain.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 B

BIN
images/global/general/favicon.ico Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
images/global/general/hide.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

BIN
images/global/general/minus.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

BIN
images/global/general/nok.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

BIN
images/global/general/ok.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

BIN
images/global/general/plus.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 B

BIN
images/global/general/show.gif Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

BIN
images/items/empty.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

123
index.php
View File

@@ -21,7 +21,7 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
@@ -30,6 +30,11 @@
// ini_set('display_startup_errors', 1); // ini_set('display_startup_errors', 1);
// error_reporting(E_ALL); // error_reporting(E_ALL);
if(preg_match("/^(.*)\.(gif|png|jpg|jpeg|tiff|bmp|css|js|less|map|html|php|zip|rar|gz)$/i", $_SERVER['REQUEST_URI'])) {
header("HTTP/1.0 404 Not Found");
exit;
}
require_once('common.php'); require_once('common.php');
require_once(BASE . 'config.local.php'); require_once(BASE . 'config.local.php');
@@ -39,22 +44,123 @@ if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['i
die('Setup detected that <b>install/</b> directory exists. Please visit <a href="' . BASE_URL . 'install">this</a> url to start MyAAC Installation.<br/>Delete <b>install/</b> directory if you already installed MyAAC.<br/>Remember to REFRESH this page when you\'re done!'); die('Setup detected that <b>install/</b> directory exists. Please visit <a href="' . BASE_URL . 'install">this</a> url to start MyAAC Installation.<br/>Delete <b>install/</b> directory if you already installed MyAAC.<br/>Remember to REFRESH this page when you\'re done!');
} }
require_once(SYSTEM . 'functions.php');
$uri = $_SERVER['REQUEST_URI'];
$tmp = BASE_DIR;
if(!empty($tmp))
$uri = str_replace(BASE_DIR . '/', '', $uri);
else
$uri = str_replace_first('/', '', $uri);
$uri = strtolower(str_replace(array('index.php/', '?'), '', $uri));
$found = false;
if(empty($uri) || isset($_REQUEST['template'])) {
$_REQUEST['p'] = 'news';
$found = true;
}
else if(!preg_match('/[^A-z0-9_\-]/', $uri) && file_exists(SYSTEM . 'pages/' . $uri . '.php')) {
$_REQUEST['p'] = $uri;
$found = true;
}
else {
$rules = array(
'/^account\/manage\/?$/' => array('subtopic' => 'accountmanagement'),
'/^account\/create\/?$/' => array('subtopic' => 'createaccount'),
'/^account\/lost\/?$/' => array('subtopic' => 'lostaccount'),
'/^account\/logout\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'logout'),
'/^account\/password\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changepassword'),
'/^account\/register\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'registeraccount'),
'/^account\/register\/new\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'registernew'),
'/^account\/email\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changeemail'),
'/^account\/info\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changeinfo'),
'/^account\/character\/create\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'createcharacter'),
'/^account\/character\/name\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changename'),
'/^account\/character\/sex\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changesex'),
'/^account\/character\/delete\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'deletecharacter'),
'/^account\/character\/comment\/[A-Za-z]+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changecomment', 'name' => '$3'),
'/^account\/character\/comment\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changecomment'),
'/^characters\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'characters', 'name' => '$1'),
'/^commands\/add\/?$/' => array('subtopic' => 'commands', 'action' => 'add'),
'/^commands\/edit\/?$/' => array('subtopic' => 'commands', 'action' => 'edit'),
'/^faq\/add\/?$/' => array('subtopic' => 'faq', 'action' => 'add'),
'/^faq\/edit\/?$/' => array('subtopic' => 'faq', 'action' => 'edit'),
'/^forum\/add_board\/?$/' => array('subtopic' => 'forum', 'action' => 'add_board'),#
'/^forum\/edit_board\/?$/' => array('subtopic' => 'forum', 'action' => 'edit_board'),
'/^forum\/board\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_board', 'id' => '$2'),
'/^forum\/board\/[0-9]+\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_board', 'id' => '$2', 'page' => '$3'),
'/^forum\/thread\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_thread', 'id' => '$2'),
'/^forum\/thread\/[0-9]+\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_thread', 'id' => '$2', 'page' => '$3'),
'/^gallery\/add\/?$/' => array('subtopic' => 'gallery', 'action' => 'add'),
'/^gallery\/edit\/?$/' => array('subtopic' => 'gallery', 'action' => 'edit'),
'/^gallery\/[0-9]+\/?$/' => array('subtopic' => 'gallery', 'image' => '$1'),
'/^gifts\/history\/?$/' => array('subtopic' => 'gifts', 'action' => 'show_history'),
'/^guilds\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'guilds', 'action' => 'show', 'guild' => '$1'),
'/^highscores\/[A-Za-z0-9-_]+\/[A-Za-z0-9-_]+\/[0-9]+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1', 'vocation' => '$2', 'page' => '$3'),
'/^highscores\/[A-Za-z0-9-_]+\/[0-9]+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1', 'page' => '$2'),
'/^highscores\/[A-Za-z0-9-_]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1', 'vocation' => '$2'),
'/^highscores\/[A-Za-z0-9-_\']+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1'),
'/^news\/add\/?$/' => array('subtopic' => 'news', 'action' => 'add'),
'/^news\/edit\/?$/' => array('subtopic' => 'news', 'action' => 'edit'),
'/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'),
'/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'),
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1')
);
if (preg_match("/^[A-Za-z0-9-_%\'+]+\.png$/i", $uri)) {
$tmp = explode('.', $uri);
$_REQUEST['name'] = urldecode($tmp[0]);
chdir(TOOLS . 'signature');
include('index.php');
exit();
}
foreach($rules as $rule => $redirect) {
if (preg_match($rule, $uri)) {
$tmp = explode('/', $uri);
foreach($redirect as $key => $value) {
if(strpos($value, '$') !== false) {
$value = str_replace('$' . $value[1], $tmp[$value[1]], $value);
}
$_REQUEST[$key] = $value;
$_GET[$key] = $value;
}
$found = true;
break;
}
}
if(!$found)
$_REQUEST['p'] = $uri;
}
// define page visited, so it can be used within events system // define page visited, so it can be used within events system
$page = isset($_REQUEST['subtopic']) ? $_REQUEST['subtopic'] : (isset($_GET['p']) ? $_GET['p'] : ''); $page = isset($_REQUEST['subtopic']) ? $_REQUEST['subtopic'] : (isset($_REQUEST['p']) ? $_REQUEST['p'] : '');
if(empty($page) || preg_match('/[^A-z0-9_\-]/', $page)) if(empty($page) || preg_match('/[^A-z0-9\/_\-]/', $page)) {
if(!$found)
$page = '404';
else
$page = 'news'; $page = 'news';
}
$page = strtolower($page); $page = strtolower($page);
define('PAGE', $page); define('PAGE', $page);
$template_place_holders = array(); $template_place_holders = array();
require_once(SYSTEM . 'functions.php');
require_once(SYSTEM . 'init.php'); require_once(SYSTEM . 'init.php');
require_once(SYSTEM . 'login.php'); require_once(SYSTEM . 'login.php');
require_once(SYSTEM . 'status.php'); require_once(SYSTEM . 'status.php');
require_once(SYSTEM . 'template.php'); require_once(SYSTEM . 'template.php');
$twig->addGlobal('config', $config);
$twig->addGlobal('status', $status);
// database migrations // database migrations
$tmp = ''; $tmp = '';
if(fetchDatabaseConfig('database_version', $tmp)) { // we got version if(fetchDatabaseConfig('database_version', $tmp)) { // we got version
@@ -153,7 +259,7 @@ if($config['backward_support']) {
$config['site']['screenshot_page'] = true; $config['site']['screenshot_page'] = true;
if($config['forum'] != '') if($config['forum'] != '')
$config['forum_link'] = (strtolower($config['forum']) == 'site' ? internalLayoutLink('forum') : $config['forum']); $config['forum_link'] = (strtolower($config['forum']) == 'site' ? getLink('forum') : $config['forum']);
foreach($status as $key => $value) foreach($status as $key => $value)
$config['status']['serverStatus_' . $key] = $value; $config['status']['serverStatus_' . $key] = $value;
@@ -168,9 +274,7 @@ if($load_it)
require(SYSTEM . 'compat_pages.php'); require(SYSTEM . 'compat_pages.php');
$ignore = false; $ignore = false;
$file = SYSTEM . 'pages/' . $page . '.php';
if(!@file_exists($file))
{
$logged_access = 0; $logged_access = 0;
if($logged && $account_logged && $account_logged->isLoaded()) { if($logged && $account_logged && $account_logged->isLoaded()) {
$logged_access = $account_logged->getAccess(); $logged_access = $account_logged->getAccess();
@@ -220,6 +324,9 @@ if($load_it)
$content .= $query['body']; // plain html $content .= $query['body']; // plain html
} }
else else
{
$file = SYSTEM . 'pages/' . $page . '.php';
if(!@file_exists($file) && !$found)
{ {
$page = '404'; $page = '404';
$file = SYSTEM . 'pages/404.php'; $file = SYSTEM . 'pages/404.php';

View File

@@ -62,9 +62,9 @@ function next_buttons($previous = true, $next = true)
$ret .= '<input class="button" type="submit" onclick="document.getElementById(\'step\').value=\'' . $steps[$i + 1] . '\';" value="' . $locale['next'] . '" />'; $ret .= '<input class="button" type="submit" onclick="document.getElementById(\'step\').value=\'' . $steps[$i + 1] . '\';" value="' . $locale['next'] . '" />';
*/ */
if($previous) if($previous)
$ret .= '<input type="button" class="button" onclick="document.getElementById(\'step\').value=\'' . $steps[$i - 1] . '\'; this.form.submit();" value="' . $locale['previous'] . '" />'; $ret .= '<input type="button" class="button" onclick="document.getElementById(\'step\').value=\'' . $steps[$i - 1] . '\'; this.form.submit();" value="&laquo; ' . $locale['previous'] . '" />';
if($next) if($next)
$ret .= '<input type="button" class="button" onclick="document.getElementById(\'step\').value=\'' . $steps[$i + 1] . '\'; this.form.submit();" value="' . $locale['next'] . '" />'; $ret .= '<input type="button" class="button" onclick="document.getElementById(\'step\').value=\'' . $steps[$i + 1] . '\'; this.form.submit(); " value="' . $locale['next'] . ' &raquo;" />';
$ret .= '</div>'; $ret .= '</div>';
return $ret; return $ret;

View File

@@ -8,18 +8,29 @@ CREATE TABLE `myaac_account_actions`
KEY (`account_id`) KEY (`account_id`)
) ENGINE = MyISAM; ) ENGINE = MyISAM;
CREATE TABLE `myaac_admin_menu`
(
`id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL DEFAULT '',
`page` VARCHAR(255) NOT NULL DEFAULT '',
`ordering` INT(11) NOT NULL DEFAULT 0,
`flags` INT(11) NOT NULL DEFAULT 0,
`enabled` INT(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`id`)
) ENGINE = MyISAM;
CREATE TABLE `myaac_bugtracker` CREATE TABLE `myaac_bugtracker`
( (
`account` VARCHAR(255) NOT NULL, `account` VARCHAR(255) NOT NULL,
`type` INT(11) NOT NULL, `type` INT(11) NOT NULL DEFAULT 0,
`status` INT(11) NOT NULL, `status` INT(11) NOT NULL DEFAULT 0,
`text` text NOT NULL, `text` text NOT NULL,
`id` INT(11) NOT NULL, `id` INT(11) NOT NULL DEFAULT 0,
`subject` VARCHAR(255) NOT NULL, `subject` VARCHAR(255) NOT NULL DEFAULT '',
`reply` INT(11) NOT NULL, `reply` INT(11) NOT NULL DEFAULT 0,
`who` INT(11) NOT NULL, `who` INT(11) NOT NULL DEFAULT 0,
`uid` INT(11) NOT NULL AUTO_INCREMENT, `uid` INT(11) NOT NULL AUTO_INCREMENT,
`tag` INT(11) NOT NULL, `tag` INT(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`uid`) PRIMARY KEY (`uid`)
) ENGINE = MyISAM; ) ENGINE = MyISAM;
@@ -67,7 +78,7 @@ CREATE TABLE `myaac_faq`
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = MyISAM; ) ENGINE = MyISAM;
CREATE TABLE `myaac_forum_sections` CREATE TABLE `myaac_forum_boards`
( (
`id` INT(11) NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(32) NOT NULL, `name` VARCHAR(32) NOT NULL,
@@ -77,11 +88,11 @@ CREATE TABLE `myaac_forum_sections`
`hidden` TINYINT(1) NOT NULL DEFAULT 0, `hidden` TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = MyISAM; ) ENGINE = MyISAM;
INSERT INTO `myaac_forum_sections` (`id`, `name`, `description`, `closed`) VALUES (NULL, 'News', 'News commenting', 1); INSERT INTO `myaac_forum_boards` (`id`, `name`, `description`, `ordering`, `closed`) VALUES (NULL, 'News', 'News commenting', 0, 1);
INSERT INTO `myaac_forum_sections` (`id`, `name`, `description`) VALUES (NULL, 'Trade', 'Trade offers.'); INSERT INTO `myaac_forum_boards` (`id`, `name`, `description`, `ordering`) VALUES (NULL, 'Trade', 'Trade offers.', 1);
INSERT INTO `myaac_forum_sections` (`id`, `name`, `description`) VALUES (NULL, 'Quests', 'Quest making.'); INSERT INTO `myaac_forum_boards` (`id`, `name`, `description`, `ordering`) VALUES (NULL, 'Quests', 'Quest making.', 2);
INSERT INTO `myaac_forum_sections` (`id`, `name`, `description`) VALUES (NULL, 'Pictures', 'Your pictures.'); INSERT INTO `myaac_forum_boards` (`id`, `name`, `description`, `ordering`) VALUES (NULL, 'Pictures', 'Your pictures.', 3);
INSERT INTO `myaac_forum_sections` (`id`, `name`, `description`) VALUES (NULL, 'Bug Report', 'Report bugs there.'); INSERT INTO `myaac_forum_boards` (`id`, `name`, `description`, `ordering`) VALUES (NULL, 'Bug Report', 'Report bugs there.', 4);
CREATE TABLE `myaac_forum` CREATE TABLE `myaac_forum`
( (
@@ -112,6 +123,7 @@ CREATE TABLE `myaac_hooks`
`name` VARCHAR(30) NOT NULL DEFAULT '', `name` VARCHAR(30) NOT NULL DEFAULT '',
`type` INT(2) NOT NULL DEFAULT 0, `type` INT(2) NOT NULL DEFAULT 0,
`file` VARCHAR(100) NOT NULL, `file` VARCHAR(100) NOT NULL,
`ordering` INT(11) NOT NULL DEFAULT 0,
`enabled` INT(1) NOT NULL DEFAULT 1, `enabled` INT(1) NOT NULL DEFAULT 1,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = MyISAM; ) ENGINE = MyISAM;
@@ -135,7 +147,7 @@ CREATE TABLE `myaac_monsters` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = MyISAM; ) ENGINE = MyISAM;
CREATE TABLE `myaac_movies` CREATE TABLE `myaac_videos`
( (
`id` INT(11) NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`title` VARCHAR(100) NOT NULL DEFAULT '', `title` VARCHAR(100) NOT NULL DEFAULT '',
@@ -202,7 +214,7 @@ CREATE TABLE `myaac_pages`
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = MyISAM; ) ENGINE = MyISAM;
CREATE TABLE `myaac_screenshots` CREATE TABLE `myaac_gallery`
( (
`id` INT(11) NOT NULL AUTO_INCREMENT, `id` INT(11) NOT NULL AUTO_INCREMENT,
`comment` VARCHAR(255) NOT NULL DEFAULT '', `comment` VARCHAR(255) NOT NULL DEFAULT '',
@@ -214,7 +226,7 @@ CREATE TABLE `myaac_screenshots`
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE = MyISAM; ) ENGINE = MyISAM;
INSERT INTO `myaac_screenshots` (`id`, `ordering`, `comment`, `image`, `thumb`, `author`) VALUES (NULL, 1, 'Demon', 'images/screenshots/demon.jpg', 'images/screenshots/demon_thumb.gif', 'MyAAC'); INSERT INTO `myaac_gallery` (`id`, `ordering`, `comment`, `image`, `thumb`, `author`) VALUES (NULL, 1, 'Demon', 'images/gallery/demon.jpg', 'images/gallery/demon_thumb.gif', 'MyAAC');
CREATE TABLE `myaac_spells` CREATE TABLE `myaac_spells`
( (

View File

@@ -10,6 +10,16 @@ require(BASE . 'install/includes/functions.php');
require(BASE . 'install/includes/locale.php'); require(BASE . 'install/includes/locale.php');
require(BASE . 'config.local.php'); require(BASE . 'config.local.php');
// twig
require_once LIBS . 'Twig/Autoloader.php';
Twig_Autoloader::register();
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
$twig = new Twig_Environment($twig_loader, array(
'cache' => CACHE . 'twig/',
'auto_reload' => true
));
if(isset($_POST['vars'])) if(isset($_POST['vars']))
{ {
foreach($_POST['vars'] as $key => $value) foreach($_POST['vars'] as $key => $value)

View File

@@ -1,32 +1,14 @@
<?php <?php
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
?>
<form action="<?php echo BASE_URL; ?>install/" method="post" autocomplete="off">
<input type="hidden" name="step" id="step" value="finish" />
<table>
<?php
require(BASE . 'install/includes/config.php'); require(BASE . 'install/includes/config.php');
if(!$error) { if(!$error) {
require(BASE . 'install/includes/database.php'); require(BASE . 'install/includes/database.php');
foreach(array(USE_ACCOUNT_NAME ? 'account' : 'account_id', 'password') as $value) echo $twig->render('install.admin.html.twig', array(
echo ' 'locale' => $locale,
<tr> 'session' => $_SESSION,
<td> 'buttons' => next_buttons(true, $error ? false : true)
<label for="vars_' . $value . '"> ));
<span>' . $locale['step_admin_' . $value] . '</span>
</label>
<br>
<input type="text" name="vars[' . $value . ']" id="vars_' . $value . '"' . (isset($_SESSION['var_' . $value]) ? ' value="' . $_SESSION['var_' . $value] . '"' : '') . '/>
</td>
<td>
<em>' . $locale['step_admin_' . $value . '_desc'] . '</em>
</td>
</tr>';
} }
?> ?>
</table>
<?php echo next_buttons(true, $error ? false : true);
?>
</form>

View File

@@ -1,7 +1,7 @@
<?php <?php
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
$clients = array( $clients_list = array(
710, 710,
740, 740,
750, 750,
@@ -63,53 +63,22 @@ $clients = array(
1096, 1096,
1097, 1097,
1098, 1098,
1100,
); );
?> $clients = array();
<form action="<?php echo BASE_URL; ?>install/" method="post" autocomplete="off"> foreach($clients_list as $client) {
<input type="hidden" name="step" id="step" value="database" />
<table>
<?php
foreach(array('server_path', 'mail_admin', 'mail_address') as $value)
echo '
<tr>
<td>
<label for="vars_' . $value . '">
<span>' . $locale['step_config_' . $value] . '</span>
</label>
<br>
<input type="text" name="vars[' . $value . ']" id="vars_' . $value . '"' . (isset($_SESSION['var_' . $value]) ? ' value="' . $_SESSION['var_' . $value] . '"' : '') . '/>
</td>
<td>
<em>' . $locale['step_config_' . $value . '_desc'] . '</em>
</td>
</tr>';
echo '
<tr>
<td>
<label for="vars_client">
<span>' . $locale['step_config_client'] . '</span>
</label>
<br>
<select name="vars[client]" id="vars_client">';
//$i = 0;
foreach($clients as $client) {
$client_version = (string)($client / 100); $client_version = (string)($client / 100);
if(strpos($client_version, '.') == false) if(strpos($client_version, '.') == false)
$client_version .= '.0'; $client_version .= '.0';
echo '<option value="' . $client . '">' . $client_version . '</option>';
}
echo ' $clients[$client] = $client_version;
</td> }
<td>
<em>' . $locale['step_config_client_desc'] . '</em> echo $twig->render('install.config.html.twig', array(
</td> 'clients' => $clients,
</tr>'; 'locale' => $locale,
?> 'session' => $_SESSION,
</table> 'buttons' => next_buttons()
<?php ));
echo next_buttons(true, true);
?> ?>
</form>

View File

@@ -1,5 +1,6 @@
<?php <?php
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
//ini_set('display_errors', false); //ini_set('display_errors', false);
ini_set('max_execution_time', 300); ini_set('max_execution_time', 300);
$error = false; $error = false;
@@ -221,18 +222,18 @@ if(!$error) {
$content .= '$config[\'mail_enabled\'] = true;'; $content .= '$config[\'mail_enabled\'] = true;';
$content .= PHP_EOL; $content .= PHP_EOL;
if(!check_mail($_SESSION['var_mail_admin'])) { if(!Validator::email($_SESSION['var_mail_admin'])) {
error($locale['step_config_mail_admin_error']); error($locale['step_config_mail_admin_error']);
$error = true; $error = true;
} }
if(!check_mail($_SESSION['var_mail_address'])) { if(!Validator::email($_SESSION['var_mail_address'])) {
error($locale['step_config_mail_address_error']); error($locale['step_config_mail_address_error']);
$error = true; $error = true;
} }
$content .= '$config[\'client_download\'] = \'http://clients.halfaway.net/windows.php?tibia=\'. $config[\'client\'];'; $content .= '$config[\'client_download\'] = \'http://tibia-clients.com/clients/download/\'. $config[\'client\'] . \'/exe/windows\';';
$content .= PHP_EOL; $content .= PHP_EOL;
$content .= '$config[\'client_download_linux\'] = \'http://clients.halfaway.net/linux.php?tibia=\'. $config[\'client\'];'; $content .= '$config[\'client_download_linux\'] = \'http://tibia-clients.com/clients/download/\'. $config[\'client\'] . \'/tar/linux\';';
$content .= PHP_EOL; $content .= PHP_EOL;
$content .= '// place for your configuration directives, so you can later easily update myaac'; $content .= '// place for your configuration directives, so you can later easily update myaac';
$content .= PHP_EOL; $content .= PHP_EOL;

View File

@@ -6,14 +6,11 @@ if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['save
} }
else { else {
require(SYSTEM . 'init.php'); require(SYSTEM . 'init.php');
//require(BASE . 'install/includes/config.php');
if(!$error) { if(!$error) {
//require(BASE . 'install/includes/database.php');
if(USE_ACCOUNT_NAME) if(USE_ACCOUNT_NAME)
$account = isset($_SESSION['var_account']) ? $_SESSION['var_account'] : NULL; $account = isset($_SESSION['var_account']) ? $_SESSION['var_account'] : null;
else else
$account_id = isset($_SESSION['var_account_id']) ? $_SESSION['var_account_id'] : NULL; $account_id = isset($_SESSION['var_account_id']) ? $_SESSION['var_account_id'] : null;
$password = $_SESSION['var_password']; $password = $_SESSION['var_password'];
@@ -23,7 +20,7 @@ else {
$salt = generateRandomString(10, false, true, true); $salt = generateRandomString(10, false, true, true);
$password = $salt . $password; $password = $salt . $password;
} }
/*
$account_db = new OTS_Account(); $account_db = new OTS_Account();
$account_db->load(1); $account_db->load(1);
if($account_db->isLoaded()) { if($account_db->isLoaded()) {
@@ -38,12 +35,12 @@ else {
if(USE_ACCOUNT_NAME) if(USE_ACCOUNT_NAME)
$new_account->create('dummy_account', 1); $new_account->create('dummy_account', 1);
else else
$new_account->create(NULL, 1); $new_account->create(null, 1);
$new_account->setPassword('for sample characters. ' . generateRandomString(10)); $new_account->setPassword('for sample characters. ' . generateRandomString(10));
$new_account->save(); $new_account->save();
} }
*/
$account_db = new OTS_Account(); $account_db = new OTS_Account();
if(isset($account)) if(isset($account))
$account_db->find($account); $account_db->find($account);
@@ -146,31 +143,31 @@ INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `pl
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Rook Sample')); $query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Rook Sample'));
if($query->rowCount() == 0) { if($query->rowCount() == 0) {
if(!query($insert_into_players . "(null, 'Rook Sample', 1, 1, 8, 0, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179613, 2453925456, 1, 1255179614, 0, 1, UNIX_TIMESTAMP(), 1, '');")) if(!query($insert_into_players . "(null, 'Rook Sample', 4, " . $_SESSION['account'] . ", 1, 0, 150, 150, 4200, 118, 114, 38, 57, 130, 0, 0, 0, 0, 100, 11, 2200, 1298, 7, '', 400, 1, 1255179613, 2453925456, 1, 1255179614, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
$success = false; $success = false;
} }
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Sorcerer Sample')); $query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Sorcerer Sample'));
if($query->rowCount() == 0) { if($query->rowCount() == 0) {
if(!query($insert_into_players . "(null, 'Sorcerer Sample', 1, 1, 8, 1, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179571, 2453925456, 1, 1255179612, 0, 1, UNIX_TIMESTAMP(), 1, '');")) if(!query($insert_into_players . "(null, 'Sorcerer Sample', 4, " . $_SESSION['account'] . ", 8, 1, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179571, 2453925456, 1, 1255179612, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
$success = false; $success = false;
} }
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Druid Sample')); $query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Druid Sample'));
if($query->rowCount() == 0) { if($query->rowCount() == 0) {
if(!query($insert_into_players . "(null, 'Druid Sample', 1, 1, 8, 2, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179655, 2453925456, 1, 1255179658, 0, 1, UNIX_TIMESTAMP(), 1, '');")) if(!query($insert_into_players . "(null, 'Druid Sample', 4, " . $_SESSION['account'] . ", 8, 2, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179655, 2453925456, 1, 1255179658, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
$success = false; $success = false;
} }
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Paladin Sample')); $query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Paladin Sample'));
if($query->rowCount() == 0) { if($query->rowCount() == 0) {
if(!query($insert_into_players . "(null, 'Paladin Sample', 1, 1, 8, 3, 185, 185, 4200, 118, 114, 38, 57, 129, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179854, 2453925456, 1, 1255179858, 0, 1, UNIX_TIMESTAMP(), 1, '');")) if(!query($insert_into_players . "(null, 'Paladin Sample', 4, " . $_SESSION['account'] . ", 8, 3, 185, 185, 4200, 118, 114, 38, 57, 129, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179854, 2453925456, 1, 1255179858, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
$success = false; $success = false;
} }
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Knight Sample')); $query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Knight Sample'));
if($query->rowCount() == 0) { if($query->rowCount() == 0) {
if(!query($insert_into_players . "(null, 'Knight Sample', 1, 1, 8, 4, 185, 185, 4200, 118, 114, 38, 57, 131, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179620, 2453925456, 1, 1255179654, 0, 1, UNIX_TIMESTAMP(), 1, '');")) if(!query($insert_into_players . "(null, 'Knight Sample', 4, " . $_SESSION['account'] . ", 8, 4, 185, 185, 4200, 118, 114, 38, 57, 131, 0, 35, 35, 0, 100, 11, 2200, 1298, 7, '', 470, 1, 1255179620, 2453925456, 1, 1255179654, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
$success = false; $success = false;
} }
@@ -178,6 +175,14 @@ INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `pl
success($locale['step_database_imported_players']); success($locale['step_database_imported_players']);
} }
require LIBS . 'creatures.php';
if(Creatures::loadFromXML())
success($locale['step_database_loaded_creatures']);
require LIBS . 'spells.php';
if(Spells::loadFromXML())
success($locale['step_database_loaded_spells']);
$locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(ADMIN_URL, $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']); $locale['step_finish_desc'] = str_replace('$ADMIN_PANEL$', generateLink(ADMIN_URL, $locale['step_finish_admin_panel'], true), $locale['step_finish_desc']);
$locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(BASE_URL, $locale['step_finish_homepage'], true), $locale['step_finish_desc']); $locale['step_finish_desc'] = str_replace('$HOMEPAGE$', generateLink(BASE_URL, $locale['step_finish_homepage'], true), $locale['step_finish_desc']);
$locale['step_finish_desc'] = str_replace('$LINK$', generateLink('http://my-aac.org', 'http://my-aac.org', true), $locale['step_finish_desc']); $locale['step_finish_desc'] = str_replace('$LINK$', generateLink('http://my-aac.org', 'http://my-aac.org', true), $locale['step_finish_desc']);

View File

@@ -1,10 +1,8 @@
<?php <?php
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
?>
<form action="<?php echo BASE_URL; ?>install/" method="post">
<input type="hidden" name="step" id="step" value="requirements" />
<textarea rows="10" cols="80" readonly="1"><?php echo file_get_contents(BASE . 'LICENSE'); ?></textarea>
<?php echo next_buttons(); echo $twig->render('install.license.html.twig', array(
?> 'license' => file_get_contents(BASE . 'LICENSE'),
</form> 'buttons' => next_buttons()
));
?>

View File

@@ -23,7 +23,7 @@ $failed = false;
// start validating // start validating
version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50200), PHP_VERSION); version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50200), PHP_VERSION);
foreach(array('config.local.php', 'images/guilds', 'images/houses', 'images/screenshots') as $value) foreach(array('config.local.php', 'images/guilds', 'images/houses', 'images/gallery') as $value)
{ {
$perms = (int) substr(decoct(fileperms(BASE . $value)), 2); $perms = (int) substr(decoct(fileperms(BASE . $value)), 2);
version_check($locale['step_requirements_write_perms'] . ': ' . $value, $perms >= 660); version_check($locale['step_requirements_write_perms'] . ': ' . $value, $perms >= 660);

View File

@@ -5,12 +5,8 @@ if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['save
} }
else { else {
unset($_SESSION['saved']); unset($_SESSION['saved']);
?>
<form action="<?php echo BASE_URL; ?>install/" method="post"> $locales = array();
<input type="hidden" name="step" id="step" value="license" />
<div class="input"><p><?php echo $locale['step_welcome_desc']; ?></p>
<select name="lang">
<?php
foreach(get_locales() as $tmp_locale) foreach(get_locales() as $tmp_locale)
{ {
$lang_file_main = LOCALE . $tmp_locale . '/main.php'; $lang_file_main = LOCALE . $tmp_locale . '/main.php';
@@ -19,15 +15,13 @@ else {
&& @file_exists($lang_file_install)) && @file_exists($lang_file_install))
{ {
require($lang_file_main); require($lang_file_main);
echo '<option value="' . $tmp_locale . '">' . $locale['name'] . '</option>'; $locales[] = array('id' => $tmp_locale, 'name' => $locale['name']);
} }
} }
?> echo $twig->render('install.welcome.html.twig', array(
</select> 'locales' => $locales,
</div> 'locale' => $locale,
'buttons' => next_buttons(false, true)
<?php echo next_buttons(false, true); ?> ));
</form>
<?php
} }
?> ?>

View File

@@ -4,7 +4,16 @@
"version": "1.0", "version": "1.0",
"author": "nobody", "author": "nobody",
"contact": "nobody@example.org", "contact": "nobody@example.org",
"require": {
"myaac": "0.4.3",
"php": "5.2.0"
},
"install": "plugins/example/install.php", "install": "plugins/example/install.php",
"uninstall": [
"plugins/example.json",
"plugins/example/install.php",
"plugins/example/before.php"
],
"hooks": { "hooks": {
"Example Hook": { "Example Hook": {
"type": "BEFORE_PAGE", "type": "BEFORE_PAGE",

View File

@@ -5,7 +5,7 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');

View File

@@ -5,7 +5,7 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
@@ -15,19 +15,20 @@ $views_counter = 1; // default value, must be here!
if($cache->enabled()) if($cache->enabled())
{ {
$value = 0; $value = 0;
if(!$cache->fetch('views_counter', $value)) if(!$cache->fetch('views_counter', $value) || $value <= 1)
{ {
$value = 0; $value = 0;
if(fetchDatabaseConfig('views_counter', $value)) if(fetchDatabaseConfig('views_counter', $value))
$views_counter = $value; $views_counter = $value;
else else
registerDatabaseConfig('views_counter', 1); // save in the database registerDatabaseConfig('views_counter', 2); // save in the database
} }
else else {
$views_counter = $value; $views_counter = $value;
}
$cache->set('views_counter', ++$views_counter, 60 * 60); $cache->set('views_counter', ++$views_counter, 60 * 60);
if(($views_counter % COUNTER_SYNC) == 0) // sync with database if($views_counter > 1 && ($views_counter % COUNTER_SYNC) == 0) // sync with database
updateDatabaseConfig('views_counter', $views_counter); updateDatabaseConfig('views_counter', $views_counter);
/* /*
{ {

View File

@@ -5,7 +5,7 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');

View File

@@ -5,17 +5,26 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
function success($message) { function success($message, $return = false) {
if($return)
return '<p class="success">' . $message . '</p>';
echo '<p class="success">' . $message . '</p>'; echo '<p class="success">' . $message . '</p>';
} }
function warning($message) { function warning($message, $return = false) {
if($return)
return '<p class="warning">' . $message . '</p>';
echo '<p class="warning">' . $message . '</p>'; echo '<p class="warning">' . $message . '</p>';
} }
function error($message) { function error($message, $return = false) {
if($return)
return '<p class="error">' . $message . '</p>';
echo '<p class="error">' . $message . '</p>'; echo '<p class="error">' . $message . '</p>';
} }
@@ -29,46 +38,27 @@ function generateLink($url, $name, $blank = false) {
return '<a href="' . $url . '"' . ($blank ? ' target="_blank"' : '') . '>' . $name . '</a>'; return '<a href="' . $url . '"' . ($blank ? ' target="_blank"' : '') . '>' . $name . '</a>';
} }
function getLink($page, $name, $blank = false) { function getFullLink($page, $name, $blank = false) {
return generateLink(getPageLink($page), $name, $blank); return generateLink(getLink($page), $name, $blank);
} }
function getPageLink($page, $action = null) function getLink($page, $action = null)
{ {
global $config; global $config;
return BASE_URL . ($config['friendly_urls'] ? '' : '?') . $page . ($action ? '/' . $action : '');
// TODO: tibiacom template is not working correctly with this
if($config['friendly_urls'])
return BASE_URL . $page . ($action ? '/' . $action : '');
return BASE_URL . '?subtopic=' . $page . ($action ? '&action=' . $action : '');
} }
function internalLayoutLink($page, $action = null) {return getPageLink($page, $action);} function internalLayoutLink($page, $action = null) {return getLink($page, $action);}
function getForumThreadLink($thread_id, $page = NULL) function getForumThreadLink($thread_id, $page = NULL)
{ {
global $config; global $config;
return BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
$url = '';
if($config['friendly_urls'])
$url = BASE_URL . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
else
$url = BASE_URL . '?subtopic=forum&action=show_thread&id=' . (int)$thread_id . (isset($page) ? '&page=' . $page : '');
return $url;
} }
function getForumBoardLink($board_id, $page = NULL) function getForumBoardLink($board_id, $page = NULL)
{ {
global $config; global $config;
return BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
$url = '';
if($config['friendly_urls'])
$url = BASE_URL . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
else
$url = BASE_URL . '?subtopic=forum&action=show_board&id=' . (int)$board_id . (isset($page) ? '&page=' . $page : '');
return $url;
} }
function getPlayerLink($name, $generate = true) function getPlayerLink($name, $generate = true)
@@ -83,11 +73,7 @@ function getPlayerLink($name, $generate = true)
$name = $player->getName(); $name = $player->getName();
} }
$url = ''; $url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'characters/' . urlencode($name);
if($config['friendly_urls'])
$url = BASE_URL . 'characters/' . urlencode($name);
else
$url = BASE_URL . '?subtopic=characters&name=' . urlencode($name);
if(!$generate) return $url; if(!$generate) return $url;
return generateLink($url, $name); return generateLink($url, $name);
@@ -107,11 +93,7 @@ function getHouseLink($name, $generate = true)
$name = $house->fetchColumn(); $name = $house->fetchColumn();
} }
$url = ''; $url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'houses/' . urlencode($name);
if($config['friendly_urls'])
$url = BASE_URL . 'houses/' . urlencode($name);
else
$url = BASE_URL . '?subtopic=houses&page=view&house=' . urlencode($name);
if(!$generate) return $url; if(!$generate) return $url;
return generateLink($url, $name); return generateLink($url, $name);
@@ -124,18 +106,12 @@ function getGuildLink($name, $generate = true)
if(is_numeric($name)) if(is_numeric($name))
{ {
$guild = $db->query( $guild = $db->query(
'SELECT ' . $db->fieldName('name') . 'SELECT `name` FROM `guilds` WHERE `id` = ' . (int)$name);
' FROM ' . $db->tableName('guilds') .
' WHERE ' . $db->fieldName('id') . ' = ' . (int)$name);
if($guild->rowCount() > 0) if($guild->rowCount() > 0)
$name = $guild->fetchColumn(); $name = $guild->fetchColumn();
} }
$url = ''; $url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'guilds/' . urlencode($name);
if($config['friendly_urls'])
$url = BASE_URL . 'guilds/' . urlencode($name);
else
$url = BASE_URL . '?subtopic=guilds&action=show&guild=' . urlencode($name);
if(!$generate) return $url; if(!$generate) return $url;
return generateLink($url, $name); return generateLink($url, $name);
@@ -218,10 +194,11 @@ function generateRandomString($length, $lowCase = true, $upCase = false, $numeri
* *
* @return array Forum sections. * @return array Forum sections.
*/ */
function getForumSections() function getForumBoards()
{ {
global $db; global $db, $canEdit;
$sections = $db->query('SELECT `id`, `name`, `description`, `closed` FROM ' . TABLE_PREFIX . 'forum_sections WHERE hidden != 1 ORDER BY `ordering`;'); $sections = $db->query('SELECT `id`, `name`, `description`, `closed`' . ($canEdit ? ', `hidden`, `ordering`' : '') . ' FROM `' . TABLE_PREFIX . 'forum_boards` ' . (!$canEdit ? ' WHERE `hidden` != 1' : '') .
' ORDER BY `ordering`;');
if($sections) if($sections)
return $sections->fetchAll(); return $sections->fetchAll();
@@ -255,7 +232,7 @@ function fetchDatabaseConfig($name, &$value)
*/ */
function getDatabaseConfig($name) function getDatabaseConfig($name)
{ {
$value = NULL; $value = null;
fetchDatabaseConfig($name, $value); fetchDatabaseConfig($name, $value);
return $value; return $value;
} }
@@ -406,303 +383,6 @@ function delete_guild($id)
return true; return true;
} }
/**
* Validate character name.
* Name lenght must be 3-25 chars
*
* @param string $name Name to check
* @param string $error Error description will be placed here
* @return bool Is name valid?
*/
function check_name($name, &$error = '')
{
if(!isset($name[0]))
{
$error = 'Please enter character name.';
return false;
}
$length = strlen($name);
if($length < 3)
{
$error = 'Character name is too short. Min. lenght <b>3</b> characters.';
return false;
}
if($length > 25)
{
$error = 'Character name is too long. Max. lenght <b>25</b> characters.';
return false;
}
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- [ ] '") != $length)
{
$error = 'Invalid name format. Use only A-Z.';
return false;
}
return preg_match("/[A-z ']{1,25}/", $name);
}
/**
* Validate account id
* Id lenght must be 6-10 chars
*
* @param string $name Account name to check
* @param string $error Error description will be placed here
* @return bool Is account name valid?
*/
function check_account_id($id, &$error = '')
{
if(!isset($id[0]))
{
$error = 'Please enter an account.';
return false;
}
if(!check_number($id)) {
$error = 'Invalid account name format. Use only numbers 0-9.';
return false;
}
$length = strlen($id);
if($length < 6)
{
$error = 'Account is too short (min. 6 chars).';
return false;
}
if($length > 10)
{
$error = 'Account is too long (max. 10 chars).';
return false;
}
return true;
}
/**
* Validate account name
* Name lenght must be 3-32 chars
*
* @param string $name Account name to check
* @param string $error Error description will be placed here
* @return bool Is account name valid?
*/
function check_account_name($name, &$error = '')
{
if(!isset($name[0]))
{
$error = 'Please enter an account name.';
return false;
}
$length = strlen($name);
if($length < 3)
{
$error = 'Account name is too short (min. 3 chars).';
return false;
}
if($length > 32)
{
$error = 'Account name is too long (max. 32 chars).';
return false;
}
if(strspn($name, "QWERTYUIOPASDFGHJKLZXCVBNM0123456789") != $length)
{
$error = 'Invalid account name format. Use only A-Z and numbers 0-9.';
return false;
}
return preg_match("/[A-Z0-9]/", $name);
}
//is it valid nick for new char?
function check_name_new_char($name, &$error = '')
{
global $db, $config;
$name_lower = strtolower($name);
$first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-');
foreach($first_words_blocked as $word)
{
if($word == substr($name_lower, 0, strlen($word))) {
$error = 'Your name contains blocked words.';
return false;
}
}
if(substr($name_lower, -1) == "'" || substr($name_lower, -1) == "-") {
$error = 'Your name contains illegal characters.';
return false;
}
if(substr($name_lower, 1, 1) == ' ') {
$error = 'Your name contains illegal space.';
return false;
}
if(substr($name_lower, -2, 1) == " ") {
$error = 'Your name contains illegal space.';
return false;
}
if(strtolower($config['lua']['serverName']) == $name_lower) {
$error = 'Your name cannot be same as server name.';
return false;
}
$names_blocked = array('admin', 'administrator', 'gm', 'cm', 'god', 'tutor');
foreach($names_blocked as $word)
{
if($word == $name_lower) {
$error = 'Your name contains blocked words.';
return false;
}
}
$words_blocked = array('admin', 'administrator', 'gamemaster', 'game master', 'game-master', "game'master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor');
foreach($words_blocked as $word)
{
if(!(strpos($name_lower, $word) === false)) {
$error = 'Your name contains illegal words.';
return false;
}
}
$name_length = strlen($name_lower);
for($i = 0; $i < $name_length; $i++)
{
if(isset($name_lower[$i]) && isset($name_lower[$i + 1]) && $name_lower[$i] == $name_lower[$i + 1] && isset($name_lower[$i + 2]) && $name_lower[$i] == $name_lower[$i + 2]) {
$error = 'Your name is invalid.';
return false;
}
}
for($i = 0; $i < $name_length; $i++)
{
if(isset($name_lower[$i - 1]) && $name_lower[$i - 1] == ' ' && isset($name_lower[$i + 1]) && $name_lower[$i + 1] == ' ') {
$error = 'Your name contains too many spaces.';
return false;
}
}
if(isset($config['monsters']))
{
if(in_array($name_lower, $config['monsters'])) {
$error = 'Your name cannot contains monster name.';
return false;
}
}
$player = new OTS_Player();
$player->find($name);
if($player->isLoaded()) {
$error = 'Player with this name already exist.';
return false;
}
//check if was namelocked previously
if(tableExist('player_namelocks') && fieldExist('name', 'player_namelocks')) {
$namelock = $db->query('SELECT `player_id` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name));
if($namelock->rowCount() > 0) {
$error = 'Character with this name has been namelocked.';
return false;
}
}
$monsters = $db->query(
'SELECT ' . $db->fieldName('name') .
' FROM ' . $db->tableName(TABLE_PREFIX . 'monsters') .
' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($name_lower));
if($monsters->rowCount() > 0) {
$error = 'Your name cannot contains monster name.';
return false;
}
$spells_name = $db->query(
'SELECT ' . $db->fieldName('name') .
' FROM ' . $db->tableName(TABLE_PREFIX . 'spells') .
' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($name_lower));
if($spells_name->rowCount() > 0) {
$error = 'Your name cannot contains spell name.';
return false;
}
$spells_words = $db->query(
'SELECT ' . $db->fieldName('words') .
' FROM ' . $db->tableName(TABLE_PREFIX . 'spells') .
' WHERE ' . $db->fieldName('words') . ' = ' . $db->quote($name_lower));
if($spells_words->rowCount() > 0) {
$error = 'Your name cannot contains spell name.';
return false;
}
if(isset($config['npc']))
{
if(in_array($name_lower, $config['npc'])) {
$error = 'Your name cannot contains NPC name.';
return false;
}
}
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length) {
$error = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.';
return false;
}
if($name_length < 3 || $name_length > 28) {
$error = 'Your name cannot be shorter than 3 characters and longer than 28 characters.';
return false;
}
if(!preg_match("/[A-z ']{3,28}/", $name)) {
$error = 'Your name containst illegal characters.';
return false;
}
return true;
}
function check_rank_name($name)
{
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789-[ ] ") != strlen($name))
return false;
return preg_match("/[A-z ]{1,32}/", $name);
}
function check_guild_name($name)
{
if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0123456789- ") != strlen($name))
return false;
return preg_match("/[A-z ]{3,32}/", $name);
}
function check_password($pass)
{
if(strspn($pass, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890") != strlen($pass))
return false;
return preg_match("/[A-z0-9]/", $pass);
}
function check_mail($email)
{
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[A-z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $email);
//return preg_match("/[A-z0-9._-]+@[A-z0-9-]+\.[A-z]{2,4}/", $email);
}
function check_number($number)
{
return preg_match ("/^([0-9]+)$/", $number);
}
//################### DISPLAY FUNCTIONS ##################### //################### DISPLAY FUNCTIONS #####################
//return shorter text (news ticker) //return shorter text (news ticker)
function short_text($text, $limit) function short_text($text, $limit)
@@ -751,28 +431,6 @@ function news_place()
return $news; return $news;
} }
function output_errors($errors)
{
global $template_path;
?>
<div class="SmallBox" >
<div class="MessageContainer" >
<div class="BoxFrameHorizontal" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-horizontal.gif);" /></div>
<div class="BoxFrameEdgeLeftTop" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-edge.gif);" /></div>
<div class="BoxFrameEdgeRightTop" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-edge.gif);" /></div>
<div class="ErrorMessage" >
<div class="BoxFrameVerticalLeft" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-vertical.gif);" />
</div>
<div class="BoxFrameVerticalRight" style="background-image:url(<?php echo $template_path; ?>/images/content/box-frame-vertical.gif);" /></div>
<div class="AttentionSign" style="background-image:url(<?php echo $template_path; ?>/images/content/attentionsign.gif);" />
</div><b>The Following Errors Have Occurred:</b><br/>
<?php
foreach($errors as $field => $message)
echo $message . '<br/>';
echo '</div> <div class="BoxFrameHorizontal" style="background-image:url('.$template_path.'/images/content/box-frame-horizontal.gif);" /></div> <div class="BoxFrameEdgeRightBottom" style="background-image:url('.$template_path.'/images/content/box-frame-edge.gif);" /></div> <div class="BoxFrameEdgeLeftBottom" style="background-image:url('.$template_path.'/images/content/box-frame-edge.gif);" /></div> </div></div><br/>';
}
/** /**
* Template place holder * Template place holder
* *
@@ -823,11 +481,7 @@ function template_header($is_admin = false)
Please turn it on, or be aware that some features on this website will not work correctly.</div> Please turn it on, or be aware that some features on this website will not work correctly.</div>
</noscript> </noscript>
'; ';
if(admin())
$ret .= '<!--script type="text/javascript" src="' . BASE_URL . 'tools/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="' . BASE_URL . 'tools/jquery.qtip.js" ></script>
<script type="text/javascript" src="' . BASE_URL . 'tools/admin.js"></script-->
';
if($config['recaptcha_enabled']) if($config['recaptcha_enabled'])
$ret .= "<script src='https://www.google.com/recaptcha/api.js'></script>"; $ret .= "<script src='https://www.google.com/recaptcha/api.js'></script>";
return $ret; return $ret;
@@ -838,13 +492,14 @@ function template_header($is_admin = false)
*/ */
function template_footer() function template_footer()
{ {
global $visitors, $config, $views_counter; global $config, $views_counter;
$ret = ''; $ret = '';
if(admin()) if(admin())
$ret .= generateLink(ADMIN_URL, 'Admin Panel', true); $ret .= generateLink(ADMIN_URL, 'Admin Panel', true);
if($config['visitors_counter']) if($config['visitors_counter'])
{ {
global $visitors;
$amount = $visitors->getAmountVisitors(); $amount = $visitors->getAmountVisitors();
$ret .= '<br/>Currently there ' . ($amount > 1 ? 'are' : 'is') . ' ' . $amount . ' visitor' . ($amount > 1 ? 's' : '') . '.'; $ret .= '<br/>Currently there ' . ($amount > 1 ? 'are' : 'is') . ' ' . $amount . ' visitor' . ($amount > 1 ? 's' : '') . '.';
} }
@@ -864,21 +519,11 @@ function template_footer()
function template_ga_code() function template_ga_code()
{ {
global $config; global $config, $twig;
if(!isset($config['google_analytics_id'][0])) if(!isset($config['google_analytics_id'][0]))
return ''; return '';
return " return $twig->render('google_analytics.html.twig');
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '" . $config['google_analytics_id'] . "', 'auto');
ga('send', 'pageview');
</script>";
} }
function template_form() function template_form()
@@ -920,6 +565,8 @@ function getCreatureName($killer, $showStatus = false, $extendedInfo = false)
{ {
global $vowels, $ots, $config; global $vowels, $ots, $config;
$str = ""; $str = "";
$players_rows = '';
if(is_numeric($killer)) if(is_numeric($killer))
{ {
$player = $ots->createObject('Player'); $player = $ots->createObject('Player');
@@ -1122,14 +769,31 @@ function get_templates()
return $ret; return $ret;
} }
/**
* Generates list of installed plugins
* @return array $plugins
*/
function get_plugins()
{
$ret = array();
$path = PLUGINS;
foreach(scandir($path) as $file) {
$file_ext = pathinfo($file, PATHINFO_EXTENSION);
$file_name = pathinfo($file, PATHINFO_FILENAME);
if ($file == '.' || $file == '..' || $file == 'disabled' || $file == 'example.json' || is_dir($path . $file) || $file_ext != 'json')
continue;
$ret[] = str_replace('.json', '', $file_name);
}
return $ret;
}
function getWorldName($id) function getWorldName($id)
{ {
global $config; global $config;
foreach($config['worlds'] as $_id => $details) if(isset($config['worlds'][$id]))
{ return $config['worlds'][$id];
if($id == $_id)
return $details['name'];
}
return $config['lua']['serverName']; return $config['lua']['serverName'];
} }
@@ -1202,7 +866,7 @@ function convert_bytes($size)
function log_append($file, $str) function log_append($file, $str)
{ {
$f = fopen(LOGS . $file, 'a'); $f = fopen(LOGS . $file, 'a');
fwrite($f, $str . PHP_EOL); fwrite($f, '[' . date(DateTime::RFC1123) . '] ' . $str . PHP_EOL);
fclose($f); fclose($f);
} }
@@ -1212,20 +876,73 @@ function load_config_lua($filename)
$config_file = $filename; $config_file = $filename;
if(!@file_exists($config_file)) if(!@file_exists($config_file))
die('ERROR: Cannot find ' . $filename . ' file.'); {
log_append('error.log', '[load_config_file] Fatal error: Cannot load config.lua (' . $filename . '). Error: ' . print_r(error_get_last(), true));
die('ERROR: Cannot find ' . $filename . ' file. More info in system/logs/error.log');
}
$tempFile = @tempnam('/tmp', 'lua'); $result = array();
$file = fopen($tempFile, 'w'); $config_string = file_get_contents($filename);
if(!$file) die('Cannot load server config!'); $config_string = str_replace("\r\n", "\n", $config_string);
$config_string = str_replace("\r", "\n", $config_string);
$lines = explode("\n", $config_string);
if(count($lines) > 0)
foreach($lines as $ln => $line)
{
$tmp_exp = explode('=', $line, 2);
if(strpos($line, 'dofile') !== false)
{
$delimiter = '"';
if(strpos($line, $delimiter) === false)
$delimiter = "'";
// TODO: new parser that will also load dofile() includes $tmp = explode($delimiter, $line);
$result = array_merge($result, load_config_lua($config['server_path'] . $tmp[1]));
}
else if(count($tmp_exp) >= 2)
{
$key = trim($tmp_exp[0]);
if(substr($key, 0, 2) != '--')
{
$value = trim($tmp_exp[1]);
if(strpos($value, '--') !== false) {// found some deep comment
$value = preg_replace('/--.*$/i', '', $value);
}
// strip lua comments to prevent parsing errors if(is_numeric($value))
fwrite($file, preg_replace('/(-)(-)(.*)/', '', file_get_contents($config_file))); $result[$key] = (float) $value;
fclose($file); elseif(in_array(substr($value, 0 , 1), array("'", '"')) && in_array(substr($value, -1 , 1), array("'", '"')))
$result[$key] = (string) substr(substr($value, 1), 0, -1);
elseif(in_array($value, array('true', 'false')))
$result[$key] = ($value == 'true') ? true : false;
else
{
foreach($result as $tmp_key => $tmp_value) // load values definied by other keys, like: dailyFragsToBlackSkull = dailyFragsToRedSkull
$value = str_replace($tmp_key, $tmp_value, $value);
$ret = @eval("return $value;");
if((string) $ret == '') // = parser error
{
die('ERROR: Loading config.lua file. Line <b>' . ($ln + 1) . '</b> of LUA config file is not valid [key: <b>' . $key . '</b>]');
}
$result[$key] = $ret;
}
}
}
}
$result = array_merge(parse_ini_file($tempFile, true), isset($config['lua']) ? $config['lua'] : array());
@unlink($tempFile); $result = array_merge($result, isset($config['lua']) ? $config['lua'] : array());
return $result; return $result;
} }
function str_replace_first($search, $replace, $subject) {
$pos = strpos($subject, $search);
if ($pos !== false) {
return substr_replace($subject, $replace, $pos, strlen($search));
}
return $subject;
}
// validator functions
require_once(LIBS . 'validator.php');
?> ?>

View File

@@ -5,7 +5,7 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
@@ -16,8 +16,14 @@ define('HOOK_AFTER_PAGE', 3);
define('HOOK_FINISH', 4); define('HOOK_FINISH', 4);
define('HOOK_TIBIACOM_ARTICLE', 5); define('HOOK_TIBIACOM_ARTICLE', 5);
define('HOOK_TIBIACOM_BORDER_3', 6); define('HOOK_TIBIACOM_BORDER_3', 6);
define('HOOK_CHARACTERS_BEFORE_INFORMATIONS', 7);
define('HOOK_CHARACTERS_AFTER_INFORMATIONS', 8);
define('HOOK_CHARACTERS_BEFORE_SIGNATURE', 9);
define('HOOK_CHARACTERS_AFTER_SIGNATURE', 10);
define('HOOK_CHARACTERS_AFTER_ACCOUNT', 11);
define('HOOK_CHARACTERS_AFTER_CHARACTERS', 12);
define('HOOK_FIRST', HOOK_STARTUP); define('HOOK_FIRST', HOOK_STARTUP);
define('HOOK_LAST', HOOK_TIBIACOM_BORDER_3); define('HOOK_LAST', HOOK_CHARACTERS_AFTER_CHARACTERS);
$hook_types = array( $hook_types = array(
'STARTUP' => HOOK_STARTUP, 'STARTUP' => HOOK_STARTUP,
@@ -25,7 +31,13 @@ $hook_types = array(
'AFTER_PAGE' => HOOK_AFTER_PAGE, 'AFTER_PAGE' => HOOK_AFTER_PAGE,
'FINISH' => HOOK_FINISH, 'FINISH' => HOOK_FINISH,
'TIBIACOM_ARTICLE' => HOOK_TIBIACOM_ARTICLE, 'TIBIACOM_ARTICLE' => HOOK_TIBIACOM_ARTICLE,
'TIBIACOM_BORDER_3' => HOOK_TIBIACOM_BORDER_3 'TIBIACOM_BORDER_3' => HOOK_TIBIACOM_BORDER_3,
'CHARACTERS_BEFORE_INFORMATIONS' => HOOK_CHARACTERS_BEFORE_INFORMATIONS,
'CHARACTERS_AFTER_INFORMATIONS' => HOOK_CHARACTERS_AFTER_INFORMATIONS,
'CHARACTERS_BEFORE_SIGNATURE' => HOOK_CHARACTERS_BEFORE_SIGNATURE,
'CHARACTERS_AFTER_SIGNATURE' => HOOK_CHARACTERS_AFTER_SIGNATURE,
'CHARACTERS_AFTER_ACCOUNT' => HOOK_CHARACTERS_AFTER_ACCOUNT,
'CHARACTERS_AFTER_CHARACTERS' => HOOK_CHARACTERS_AFTER_CHARACTERS
); );
class Hook class Hook
@@ -46,7 +58,7 @@ class Hook
$ret = $tmp($params); $ret = $tmp($params);
}*/ }*/
global $db, $config, $template_path, $ots; global $db, $config, $template_path, $ots, $content;
if(file_exists(BASE . $this->_file)) { if(file_exists(BASE . $this->_file)) {
require(BASE . $this->_file); require(BASE . $this->_file);
} }
@@ -84,7 +96,7 @@ class Hooks
public function load() public function load()
{ {
global $db; global $db;
$hooks = $db->query('SELECT `name`, `type`, `file` FROM `' . TABLE_PREFIX . 'hooks` WHERE `enabled` = 1;'); $hooks = $db->query('SELECT `name`, `type`, `file` FROM `' . TABLE_PREFIX . 'hooks` WHERE `enabled` = 1 ORDER BY `ordering`;');
foreach($hooks as $hook) foreach($hooks as $hook)
$this->register($hook['name'], $hook['type'], $hook['file']); $this->register($hook['name'], $hook['type'], $hook['file']);
} }

View File

@@ -5,7 +5,7 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');
@@ -14,12 +14,17 @@ require_once(BASE . 'config.php');
if(file_exists(BASE . 'config.local.php')) // user customizations if(file_exists(BASE . 'config.local.php')) // user customizations
require(BASE . 'config.local.php'); require(BASE . 'config.local.php');
if(!isset($config['installed']) || !$config['installed']) {
die('AAC has not been installed yet or there was error during installation. Please install again.');
}
date_default_timezone_set($config['date_timezone']);
// take care of trailing slash at the end // take care of trailing slash at the end
if($config['server_path'][strlen($config['server_path']) - 1] != '/') if($config['server_path'][strlen($config['server_path']) - 1] != '/')
$config['server_path'] .= '/'; $config['server_path'] .= '/';
// enable gzip compression if supported by the browser // enable gzip compression if supported by the browser
if($config['gzip_output'] && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) && function_exists('ob_gzhandler')) if($config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
ob_start('ob_gzhandler'); ob_start('ob_gzhandler');
// cache // cache
@@ -27,12 +32,13 @@ require_once(SYSTEM . 'libs/cache.php');
$cache = Cache::getInstance($config['cache_engine'], $config['cache_prefix']); $cache = Cache::getInstance($config['cache_engine'], $config['cache_prefix']);
// twig // twig
require_once LIBS . 'twig/Autoloader.php'; require_once(LIBS . 'Twig/Autoloader.php');
Twig_Autoloader::register(); Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem(SYSTEM . 'templates'); $twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
$twig = new Twig_Environment($loader, array( $twig = new Twig_Environment($twig_loader, array(
'cache' => CACHE . 'twig/', 'cache' => CACHE . 'twig/',
'auto_reload' => true
)); ));
$function = new Twig_SimpleFunction('getStyle', function ($i) { $function = new Twig_SimpleFunction('getStyle', function ($i) {
@@ -40,6 +46,21 @@ $function = new Twig_SimpleFunction('getStyle', function ($i) {
}); });
$twig->addFunction($function); $twig->addFunction($function);
$function = new Twig_SimpleFunction('getLink', function ($s) {
global $config;
if($config['friendly_urls'])
return $s;
return '?' . $s;
});
$twig->addFunction($function);
$function = new Twig_SimpleFunction('hook', function ($hook) {
global $hooks;
$hooks->trigger($hook);
});
$twig->addFunction($function);
// trim values we receive // trim values we receive
if(isset($_POST)) if(isset($_POST))
{ {
@@ -86,10 +107,12 @@ unset($tmp);
if(isset($config['lua']['servername'])) if(isset($config['lua']['servername']))
$config['lua']['serverName'] = $config['lua']['servername']; $config['lua']['serverName'] = $config['lua']['servername'];
if(isset($config['lua']['houserentperiod'])) if(isset($config['lua']['houserentperiod']))
$config['lua']['houseRentPeriod'] = $config['lua']['houserentperiod']; $config['lua']['houseRentPeriod'] = $config['lua']['houserentperiod'];
if($config['item_images_url'][strlen($config['item_images_url']) - 1] != '/')
$config['item_images_url'] .= '/';
// localize data/ directory // localize data/ directory
if(isset($config['lua']['dataDirectory'][0])) if(isset($config['lua']['dataDirectory'][0]))
{ {

View File

@@ -5,7 +5,7 @@
* @package MyAAC * @package MyAAC
* @author Slawkens <slawkens@gmail.com> * @author Slawkens <slawkens@gmail.com>
* @copyright 2017 MyAAC * @copyright 2017 MyAAC
* @version 0.3.0 * @version 0.6.0
* @link http://my-aac.org * @link http://my-aac.org
*/ */
defined('MYAAC') or die('Direct access not allowed!'); defined('MYAAC') or die('Direct access not allowed!');

Some files were not shown because too many files have changed in this diff Show More