Compare commits
144 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6e221fe469 | ||
![]() |
679e08ec11 | ||
![]() |
603495ca97 | ||
![]() |
4c6af13574 | ||
![]() |
3fcbd42445 | ||
![]() |
e6d2e363d5 | ||
![]() |
0a067577a3 | ||
![]() |
a5b599088a | ||
![]() |
51ba514d2a | ||
![]() |
b83fb05b82 | ||
![]() |
cf12265cd8 | ||
![]() |
e4110a6981 | ||
![]() |
412908026d | ||
![]() |
8a7887cf06 | ||
![]() |
779dd003dd | ||
![]() |
0b2895dc56 | ||
![]() |
fed5d08703 | ||
![]() |
f131f27ac3 | ||
![]() |
19dbbdcf4f | ||
![]() |
d650035980 | ||
![]() |
fbc803d09f | ||
![]() |
df4c594d4f | ||
![]() |
482445cb98 | ||
![]() |
1c002c63a3 | ||
![]() |
cd366b6087 | ||
![]() |
83dc5b7650 | ||
![]() |
d9675b1bc6 | ||
![]() |
036520566c | ||
![]() |
8b302749ff | ||
![]() |
68b3e2cfee | ||
![]() |
9ee6906e4d | ||
![]() |
be38f51cc7 | ||
![]() |
aaed21f752 | ||
![]() |
a1dddd7df8 | ||
![]() |
f26795ca7a | ||
![]() |
7d6bbb3385 | ||
![]() |
37f792d9ce | ||
![]() |
867c86d702 | ||
![]() |
05f8756a12 | ||
![]() |
c581c35a73 | ||
![]() |
b37bd5f0ae | ||
![]() |
56a01e1e64 | ||
![]() |
6aa58bddd8 | ||
![]() |
0515f2825a | ||
![]() |
0d37e07a0d | ||
![]() |
ab69b182e6 | ||
![]() |
7b84614a79 | ||
![]() |
361e536243 | ||
![]() |
39fee6e57d | ||
![]() |
56a0c6e6bf | ||
![]() |
eb8993e746 | ||
![]() |
edeb781600 | ||
![]() |
9aa4e308c1 | ||
![]() |
05abf41b64 | ||
![]() |
ac9c43e280 | ||
![]() |
c05e7f29c5 | ||
![]() |
583f3394fc | ||
![]() |
5e414ebda8 | ||
![]() |
21b1383c9a | ||
![]() |
6c9e09ea73 | ||
![]() |
195ec4b11e | ||
![]() |
bf988a7f6e | ||
![]() |
25f8028ae3 | ||
![]() |
28299744c4 | ||
![]() |
72212f8256 | ||
![]() |
1610a4ab91 | ||
![]() |
87a3d1e5d1 | ||
![]() |
2b6d65e955 | ||
![]() |
cd44d28674 | ||
![]() |
2edeb1b3e2 | ||
![]() |
9f946d4bc4 | ||
![]() |
5266f33af5 | ||
![]() |
85c9a1e84d | ||
![]() |
5951fe21ec | ||
![]() |
c6b6638705 | ||
![]() |
8ab7be9fb8 | ||
![]() |
762fa31c28 | ||
![]() |
c2678aa91f | ||
![]() |
d4900eac84 | ||
![]() |
f9b6e9fa2e | ||
![]() |
cfb460c137 | ||
![]() |
f9e6966687 | ||
![]() |
913b4297cf | ||
![]() |
23c1df72aa | ||
![]() |
cde42ec3fa | ||
![]() |
0104d2fd36 | ||
![]() |
85d1f3419a | ||
![]() |
e45d27b5c7 | ||
![]() |
a3d94db6eb | ||
![]() |
ef904c854b | ||
![]() |
7a7eb4e553 | ||
![]() |
c7f549742d | ||
![]() |
1850ef70d8 | ||
![]() |
0b693a02bd | ||
![]() |
508db95cba | ||
![]() |
bbae0c3ade | ||
![]() |
0239f940a0 | ||
![]() |
1df0c2b313 | ||
![]() |
a9d9ace532 | ||
![]() |
cb83e17710 | ||
![]() |
1727df7082 | ||
![]() |
3d585a3d02 | ||
![]() |
69f822b69c | ||
![]() |
abfe3b08af | ||
![]() |
66a3c46aaf | ||
![]() |
c914a73352 | ||
![]() |
5041ed1564 | ||
![]() |
4daaa67710 | ||
![]() |
dd572b00d0 | ||
![]() |
3fef1a6eec | ||
![]() |
6d81a29bb6 | ||
![]() |
3f1c638a14 | ||
![]() |
7caca74d57 | ||
![]() |
d95aea319e | ||
![]() |
9aed09d250 | ||
![]() |
3ebcd788fb | ||
![]() |
816751f464 | ||
![]() |
f84ae88aa4 | ||
![]() |
315e0400ff | ||
![]() |
22cf7f5d4f | ||
![]() |
6ec829e47f | ||
![]() |
a119d75589 | ||
![]() |
92028a2492 | ||
![]() |
42ef8487c8 | ||
![]() |
e92e5d1040 | ||
![]() |
a1950cf27e | ||
![]() |
27fb0ffb06 | ||
![]() |
6c3439acf9 | ||
![]() |
005356ebb3 | ||
![]() |
f0adabf567 | ||
![]() |
739782109e | ||
![]() |
87ba018ab8 | ||
![]() |
041702615f | ||
![]() |
0a82f306f6 | ||
![]() |
856e72150c | ||
![]() |
e2857f8ca5 | ||
![]() |
04d9ec9c94 | ||
![]() |
e984a467ef | ||
![]() |
8342a7b8a8 | ||
![]() |
269af1930c | ||
![]() |
b7bb950abc | ||
![]() |
4a19458c15 | ||
![]() |
b6db420465 | ||
![]() |
7b234ad41f |
@@ -1,33 +1,7 @@
|
||||
Options -Indexes -MultiViews
|
||||
|
||||
RewriteEngine On
|
||||
#RewriteBase /
|
||||
|
||||
# Page parser
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^([A-Za-z0-9-_+']+)\.png/?$ tools/signature/index.php?name=$1 [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]
|
||||
RewriteRule ^.*$ index.php [L]
|
497
CHANGELOG
@@ -1,194 +1,387 @@
|
||||
[0.7.5 - 04.01.2017]
|
||||
* fixed bug on othire with config.account_premium_days
|
||||
* fixed bug on TFS 1.x when online_afk is enabled
|
||||
* warning about leaving news page with changes
|
||||
* added player status to tibiacom top 5 highscores box
|
||||
* save detected country on create account in session
|
||||
* fixed getPremDays and isPremium functions (newest 11.x engines are bugged when it comes to PACC, its not fault of MyAAC)
|
||||
* fix when there are no changelogs or highscores yet
|
||||
* small fix regarding getTopPlayers function which was ignoring $limit variable
|
||||
* fixed news adding when type != ARTICLE
|
||||
* fixed template path finding
|
||||
* fixed displaying article_text when it was empty saved
|
||||
|
||||
[0.7.4 - 24.12.2017]
|
||||
* fixed mysql fatal error on tibiacom template - top 5 box
|
||||
* fixed displaying of level percent bar on tibian signature
|
||||
* inform user about Twig cache failure on installation, instead of http 500 error
|
||||
* when dir system/cache is not writable by the webserver, then show some nice notice to the user about it instead of http 500 error
|
||||
* remember client version select and usage stats checkbox in session on install
|
||||
* automatically update highscores_ids_hidden for users who installed myaac before (migration)
|
||||
|
||||
[0.7.3 - 18.12.2017]
|
||||
* auto generate myaac cache & session prefix on install to be unique across installations
|
||||
* fixed hiding shop system menu on tibiacom template when disabled in config
|
||||
* prevent adding duplicated newses with installation
|
||||
* some changes to sample characters: chanced town_id to 1, posx: 1000, posy: 1000, posz: 1000 and default group_id to 1 so you can change in-game outfits and they will be used
|
||||
* added version 772 constant to install client choose (OTHire)
|
||||
* better solution for hidding samples (configurable) - highscores_ids_hidden
|
||||
* fixed account.login redirect not working on tibiacom template
|
||||
* installation: warn about wrong admin account name/id and password
|
||||
* fixed last menu closing in tibiacom template
|
||||
* updated polish locale (translation) on install
|
||||
* (internal) removed some duplicated code on install finish
|
||||
* (internal) renamed installation step files to be in correct order
|
||||
* added TODO file
|
||||
|
||||
[0.7.1 - 13.12.2017]
|
||||
* added changelog menu item to kathrine template
|
||||
* fixed some php short tag in changelogs page
|
||||
* fixed guild change description back button
|
||||
* removed duplicated "Support List" menu item from tibiacom template
|
||||
* changed some notice when version check is failed
|
||||
* (internal) moved changelog to twig
|
||||
|
||||
[0.7.0 - 20.11.2017]
|
||||
* moved template menus to database, they're now dynamically loaded
|
||||
* added anonymous usage statistics reporting (only if user agrees, first usage report will be send after 7 days)
|
||||
* you can edit them in Admin Panel under 'Menus' option
|
||||
* you can also add custom links, like http://google.pl
|
||||
* added networks (facebook and twitter) and highscores (top 5) boxes to tibiacom template, configurable in templates/tibiacom/config.php
|
||||
* added news ticker for kathrine template
|
||||
* added featured article to tibiacom template (you can add them with add news button)
|
||||
* added tinymce editor to 'Pages' in admin panel
|
||||
* added links to edit/delete/hide custom page directly from page
|
||||
* update forum post after editing news (when forum post has been created)
|
||||
* enabled code plugin for tinymce which enabled raw html code editing
|
||||
* removed videos pages, as it can be easily added using custom Menus and Pages with insert Media
|
||||
* removed bug_report configurable, its now enabled by default
|
||||
* log some error info when mail cannot be send on account create
|
||||
* twig getLink function will now return with full url (BASE_URL included)
|
||||
* verify install post values directly on config page and display error
|
||||
* updated tinymce to version 4.7.2 (from 4.7.0)
|
||||
* updated phpmailer to version 5.2.26 (from 5.2.23)
|
||||
* (#30) (fix) recovering account on servers that doesn't support salts
|
||||
* (fix) account email confirm function
|
||||
* (fix) showing changelog with urls in Admin Panel
|
||||
* (fix) uninstalling plugin
|
||||
* (fix) polls box in tibiacom template
|
||||
* (fix) remove hooks from db on plugin deinstall
|
||||
* (fix) some weird include possibilities with forum and account actions (verify action name)
|
||||
* (fix) loading hooks from plugin installed from command line
|
||||
* (fix) some changelog PHP Notice warning
|
||||
* (internal) moved uninstall logic to Plugins class
|
||||
* (internal) moved tibiacom boxes to separate directory
|
||||
* (internal) moved news tickers to twig template
|
||||
* (internal) moved Forum class to separate file
|
||||
* (internal) moved deprecated functions to compat.php
|
||||
* (internal) added some compat functions that are used by shop system
|
||||
* (internal) renamed constant TICKET -> TICKER
|
||||
* (internal) shortened message functions
|
||||
|
||||
[0.6.6 - 22.10.2017]
|
||||
* fixed some php fatal error on spells page
|
||||
* changed spells.vocations field in db size to 300
|
||||
* please reload your spells after this update!
|
||||
|
||||
[0.6.5 - 21.10.2017]
|
||||
* fixed displaying custom pages
|
||||
* fixed adding new group forum board
|
||||
|
||||
[0.6.4 - 20.10.2017]
|
||||
* reverted OTS_Account::getLastLogin() cause its used by tibia11-login plugin
|
||||
|
||||
[0.6.3 - 20.10.2017]
|
||||
* fixed creating account
|
||||
* fixed viewing thread without being logged
|
||||
* fixed showing premium account status
|
||||
|
||||
[0.6.2 - 20.10.2017]
|
||||
* added forums for guilds and groups
|
||||
* added nice looking menu for my account page in default template
|
||||
* new command line tool: install_plugin.php - can be used to install plugins from command line. Usage: "php install_plugin.php path_to_file"
|
||||
* added new tooltip to view characters equipment item name and monster loot
|
||||
* added items.xml loader class and weapons.xml loader class
|
||||
* minimum PHP version to install AAC is now 5.3.0 cause of Anonymous functions used by Twig
|
||||
* Added 'Are you sure?' popup when uninstalling plugin
|
||||
* added some warnings when plugin json file is incomplete
|
||||
* fixed showing in characters ban expires when is unlimited
|
||||
* fixed displaying monster loot when item.name in loot is used instead of item.id
|
||||
* load also runes into spells table
|
||||
* display plugin uninstall option only if its possible
|
||||
* after changing template you will be redirected to latest viewed page
|
||||
* display gallery add image form only on main gallery page
|
||||
* (internal) moved most of guilds html-in-php code to twig
|
||||
* (internal) moved spells page to twig template
|
||||
* (internal) removed useless spells.spell column that was duplicate of spells.words
|
||||
* (internal) save monster loot in database in json format instead loading it every time from xml file
|
||||
* (internal) store monster voices and immunities in json format
|
||||
* (internal) moved buttons to separate template
|
||||
* (internal) moved online search form to twig
|
||||
* (internal) added new function getItemNameById($id)
|
||||
* (internal) Moved plugin install logic to a new class: Plugins
|
||||
* (internal) changed spells.vocations database field to store json data instead of comma separated
|
||||
* (internal) removed $hook_types array, using defined() and constant() functions now
|
||||
* (internal) removed useless monsters.gfx_name field from database
|
||||
* (internal) renamed database field monsters.hide_creature to hidden
|
||||
* (internal) renamed existing Items class to Items_Images
|
||||
* (internal) optimized Spells class
|
||||
* (internal) new function: OTS_Guild::hasMember(OTS_Player $player)
|
||||
* (internal) new function: Forum::hasAccess($board_id)
|
||||
|
||||
[0.6.1 - 17.10.2017]
|
||||
* fixed signatures loading
|
||||
* new configurable: session_prefix, to allow more websites on one machine (must be unique for every website on your dedicated server!)
|
||||
* better error handling for monsters and spells loader (save errors to system/logs/error.log)
|
||||
* check if file exist before loading (monsters and spells)
|
||||
* (internal) Account::getAccess() = Account::getGroupId()
|
||||
* (internal) moved account actions (pages) to account/ directory
|
||||
* (internal) moved forum actions (pages) to forum/ directory
|
||||
* (internal) moved forum.edit_post to twig templates
|
||||
|
||||
[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
|
||||
* 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
|
||||
* updated version number
|
||||
|
||||
[0.4.1 - 13.09.2017]
|
||||
- fixed log in to admin panel
|
||||
- fixed File is not .zip plugin upload error
|
||||
* 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
|
||||
* 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]
|
||||
- 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
|
||||
- automatically detect player country based on user location (IP) on create account
|
||||
- player sex (gender) is now configurable at $config['genders']
|
||||
- fixed recovering account and changing password when salt is enabled
|
||||
- fixed installing samples when for example Rook Sample already exist and other samples not
|
||||
- fixed some mysql error when character you trying to create already exist
|
||||
- fixed some warning when you select nonexistent country
|
||||
- password change minimal/maximal length notice is now more precise
|
||||
- added 'enabled' field in myaac_hooks table, which can enable or disable specified hook
|
||||
- removed DEFAULT '' for TEXT field. It didn't worked under some systems like MAC OS X.
|
||||
- minimum PHP version to install the MyAAC is now 5.2.0 cause of pathinfo (extension) function
|
||||
- removed unused admin stylish template
|
||||
- removed some unused cities field from myaac_spells table
|
||||
- moved news adding at installation from schema.sql to finish.php
|
||||
- some optimizations
|
||||
* 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
|
||||
* automatically detect player country based on user location (IP) on create account
|
||||
* player sex (gender) is now configurable at $config['genders']
|
||||
* fixed recovering account and changing password when salt is enabled
|
||||
* fixed installing samples when for example Rook Sample already exist and other samples not
|
||||
* fixed some mysql error when character you trying to create already exist
|
||||
* fixed some warning when you select nonexistent country
|
||||
* password change minimal/maximal length notice is now more precise
|
||||
* added 'enabled' field in myaac_hooks table, which can enable or disable specified hook
|
||||
* removed DEFAULT '' for TEXT field. It didn't worked under some systems like MAC OS X.
|
||||
* minimum PHP version to install the MyAAC is now 5.2.0 cause of pathinfo (extension) function
|
||||
* removed unused admin stylish template
|
||||
* removed some unused cities field from myaac_spells table
|
||||
* moved news adding at installation from schema.sql to finish.php
|
||||
* some optimizations
|
||||
|
||||
[0.2.4 - 09.06.2017]
|
||||
- fixed invite to guild
|
||||
- added id field on monsters, so you can delete them in phpmyadmin
|
||||
- fixed adding some creatures with ' and "
|
||||
- fixed when there are spaces at beginning of the file (creatures)
|
||||
- fixed when file is unable to parse (creatures)
|
||||
- fixed typo loss_items => loss_containers
|
||||
- more elegant way of showing message on reload creatures and spells
|
||||
* fixed invite to guild
|
||||
* added id field on monsters, so you can delete them in phpmyadmin
|
||||
* fixed adding some creatures with ' and "
|
||||
* fixed when there are spaces at beginning of the file (creatures)
|
||||
* fixed when file is unable to parse (creatures)
|
||||
* fixed typo loss_items => loss_containers
|
||||
* more elegant way of showing message on reload creatures and spells
|
||||
|
||||
[0.2.3 - 31.05.2017]
|
||||
- fixed guild management on OTHire 0.0.3
|
||||
- set default skills to 10 when creating new character
|
||||
- fixed displaying of "Create forum thread" in newses
|
||||
- fixed deleting guild on servers that use players.rank_id field
|
||||
- fixed phpmailer class loading (https://otland.net/threads/myaac-v0-0-1.251454/page-8#post-2445222)
|
||||
- fixed displaying vocation amount on online page
|
||||
- better support for custom vocations, you just need to set in config vocations_amount to yours.
|
||||
- fixed huge space in player name (https://otland.net/threads/myaac-v0-0-1.251454/page-7#post-2444328)
|
||||
- fixed Undefined variable (https://otland.net/threads/myaac-v0-0-1.251454/page-7#post-2444034)
|
||||
- fixed Undefined offset (https://otland.net/threads/myaac-v0-0-1.251454/page-7#post-2444035)
|
||||
* fixed guild management on OTHire 0.0.3
|
||||
* set default skills to 10 when creating new character
|
||||
* fixed displaying of "Create forum thread" in newses
|
||||
* fixed deleting guild on servers that use players.rank_id field
|
||||
* fixed phpmailer class loading (https://otland.net/threads/myaac-v0-0-1.251454/page-8#post-2445222)
|
||||
* fixed displaying vocation amount on online page
|
||||
* better support for custom vocations, you just need to set in config vocations_amount to yours.
|
||||
* fixed huge space in player name (https://otland.net/threads/myaac-v0-0-1.251454/page-7#post-2444328)
|
||||
* fixed Undefined variable (https://otland.net/threads/myaac-v0-0-1.251454/page-7#post-2444034)
|
||||
* fixed Undefined offset (https://otland.net/threads/myaac-v0-0-1.251454/page-7#post-2444035)
|
||||
|
||||
[0.2.2 - 22.05.2017]
|
||||
- added missing cache/signature directory
|
||||
- fixed https://otland.net/threads/myaac-v0-0-1.251454/page-7#post-2443868
|
||||
* added missing cache/signature directory
|
||||
* fixed https://otland.net/threads/myaac-v0-0-1.251454/page-7#post-2443868
|
||||
|
||||
[0.2.1 - 21.05.2017]
|
||||
- added Swedish translation by Sizaro
|
||||
- fixed some bugs with installlation & characters & houses
|
||||
* added Swedish translation by Sizaro
|
||||
* fixed some bugs with installlation & characters & houses
|
||||
|
||||
[0.2.0 - 21.05.2017]
|
||||
- added option to change character sex for premium points
|
||||
- moved site_closed to database, now you can close your site through admin panel
|
||||
- added option to admin panel: clear cache
|
||||
- added experiencetable_rows configurable
|
||||
- optimized OTS_Account->getGroupId(), now its using like 20 queries less
|
||||
- optimized OTS_Player->load($id) function, should be much faster now
|
||||
- fixed displaying on highscores special outfits
|
||||
- fixed skull images displaying
|
||||
- fixed displaying unlimited premium account
|
||||
- fixed bug where players.lookaddons doesn't exist (OTHire etc.) (https://otland.net/threads/myaac-v0-0-1.251454/page-6#post-2442407)
|
||||
- fixed signature tibian for OTHire and other servers that doesnt use accounts.premdays field
|
||||
- fixed when player name in signature containst space
|
||||
- don't show "Create forum thread" when editing
|
||||
- fixed red color table after create account
|
||||
- updated download links, as clients.halfaway.net isn't working anymore
|
||||
- fixed some bugs while installing when field `email_next` or `hidden` already exist
|
||||
- fixed movies unexpected comment
|
||||
- added template_place_holder('center_top') to kathrine template
|
||||
* added option to change character sex for premium points
|
||||
* moved site_closed to database, now you can close your site through admin panel
|
||||
* added option to admin panel: clear cache
|
||||
* added experiencetable_rows configurable
|
||||
* optimized OTS_Account->getGroupId(), now its using like 20 queries less
|
||||
* optimized OTS_Player->load($id) function, should be much faster now
|
||||
* fixed displaying on highscores special outfits
|
||||
* fixed skull images displaying
|
||||
* fixed displaying unlimited premium account
|
||||
* fixed bug where players.lookaddons doesn't exist (OTHire etc.) (https://otland.net/threads/myaac-v0-0-1.251454/page-6#post-2442407)
|
||||
* fixed signature tibian for OTHire and other servers that doesnt use accounts.premdays field
|
||||
* fixed when player name in signature containst space
|
||||
* don't show "Create forum thread" when editing
|
||||
* fixed red color table after create account
|
||||
* updated download links, as clients.halfaway.net isn't working anymore
|
||||
* fixed some bugs while installing when field `email_next` or `hidden` already exist
|
||||
* fixed movies unexpected comment
|
||||
* added template_place_holder('center_top') to kathrine template
|
||||
|
||||
[0.1.5 - 13.05.2017]
|
||||
- fixed bug with "Integrity constraint violation: 1048 Column 'ip' cannot be null"
|
||||
* fixed bug with "Integrity constraint violation: 1048 Column 'ip' cannot be null"
|
||||
|
||||
[0.1.4 - 13.05.2017]
|
||||
- added outfit shower, in characters, online, and highscores
|
||||
- updated database to version 2
|
||||
- fixed item images (now using item-images.ots.me host by default)
|
||||
- fixed news ticket and posting long newses (https://otland.net/threads/myaac-v0-0-1.251454/page-5#post-2442026)
|
||||
- news body limit increased to 65535 (mysql text field)
|
||||
- removed some unused code from my old server
|
||||
- added spells & monsters to kathrine template
|
||||
* added outfit shower, in characters, online, and highscores
|
||||
* updated database to version 2
|
||||
* fixed item images (now using item-images.ots.me host by default)
|
||||
* fixed news ticket and posting long newses (https://otland.net/threads/myaac-v0-0-1.251454/page-5#post-2442026)
|
||||
* news body limit increased to 65535 (mysql text field)
|
||||
* removed some unused code from my old server
|
||||
* added spells & monsters to kathrine template
|
||||
|
||||
[0.1.3 - 11.05.2017]
|
||||
- this is just release to update version number
|
||||
* this is just release to update version number
|
||||
|
||||
[0.1.2 - 11.05.2017]
|
||||
- forgot to update CHANGELOG and MYAAC_VERSION
|
||||
* forgot to update CHANGELOG and MYAAC_VERSION
|
||||
|
||||
[0.1.1 - 11.05.2017]
|
||||
- fixed updating myaac_config with database_version to 1
|
||||
- fixed database updater
|
||||
* fixed updating myaac_config with database_version to 1
|
||||
* fixed database updater
|
||||
|
||||
[0.1.0 - 11.05.2017]
|
||||
- added new feature: change character name for premium points (disabled by default, you can enable it in config under account_change_character_name in config.php)
|
||||
- added automatic database updater (data migrations)
|
||||
- renamed events to hooks
|
||||
- moved hooks to database
|
||||
- now you can use hooks in plugins
|
||||
- set account.type field to 5 on install, if TFS 1.0+
|
||||
- added example plugin
|
||||
- new, latest google analytics code
|
||||
- fixed bug with loading account.name that has numbers in it
|
||||
- fixed many bugs in player editor in admin panel
|
||||
- added error handling to plugin manager and some more verification in
|
||||
- file has been correctly unpacked/uploaded
|
||||
- fixed Statistics page in admin panel when using account.number
|
||||
- fixed bug when creating/recovering account on servers with
|
||||
- account.salt field (TFS 0.3 for example)
|
||||
- fixed forum showing thread with html tags (added from news manager)
|
||||
- new, latest code for youtube videos in movies page
|
||||
- fixed showing vocation images when using $config['online_vocations_images']
|
||||
- many fixes in polls (also importing proper schema)
|
||||
- fixed hovering on buttons in kathrine template (on accountmanagement page)
|
||||
- fixed signatures (many fixes)
|
||||
- added missing gesior signature system
|
||||
* added new feature: change character name for premium points (disabled by default, you can enable it in config under account_change_character_name in config.php)
|
||||
* added automatic database updater (data migrations)
|
||||
* renamed events to hooks
|
||||
* moved hooks to database
|
||||
* now you can use hooks in plugins
|
||||
* set account.type field to 5 on install, if TFS 1.0+
|
||||
* added example plugin
|
||||
* new, latest google analytics code
|
||||
* fixed bug with loading account.name that has numbers in it
|
||||
* fixed many bugs in player editor in admin panel
|
||||
* added error handling to plugin manager and some more verification in
|
||||
* file has been correctly unpacked/uploaded
|
||||
* fixed Statistics page in admin panel when using account.number
|
||||
* fixed bug when creating/recovering account on servers with
|
||||
* account.salt field (TFS 0.3 for example)
|
||||
* fixed forum showing thread with html tags (added from news manager)
|
||||
* new, latest code for youtube videos in movies page
|
||||
* fixed showing vocation images when using $config['online_vocations_images']
|
||||
* many fixes in polls (also importing proper schema)
|
||||
* fixed hovering on buttons in kathrine template (on accountmanagement page)
|
||||
* fixed signatures (many fixes)
|
||||
* added missing gesior signature system
|
||||
|
||||
[0.0.6 - 06.05.2017]
|
||||
- fixed bug while installing (https://otland.net/threads/myaac-v0-0-1.251454/page-3#post-2440543)
|
||||
- fixed bug when creating character (not showing errors) (one more time)
|
||||
- fixed support for TFS 0.2 series
|
||||
- added FAQ link
|
||||
* fixed bug while installing (https://otland.net/threads/myaac-v0-0-1.251454/page-3#post-2440543)
|
||||
* fixed bug when creating character (not showing errors) (one more time)
|
||||
* fixed support for TFS 0.2 series
|
||||
* added FAQ link
|
||||
|
||||
[0.0.5 - 05.05.2017]
|
||||
- fixed bug when creating character (not showing errors)
|
||||
- Fixed characters loading with names that has been created with other AAC
|
||||
- fixed links to shop in default template
|
||||
- fixed some weird PHP 7.1 warnings/notices
|
||||
- Fixed config loading with some weird comments
|
||||
- fixed bug with status info utf8 encoding (https://otland.net/threads/myaac-v0-0-1.251454/page-2#post-2440259)
|
||||
- fixed when ip in log_action is NULL (https://otland.net/threads/myaac-v0-0-1.251454/page-2#post-2440357)
|
||||
- fixed bug when guild doesn't exist on characters page (https://otland.net/threads/myaac-v0-0-1.251454/page-2#post-2440320)
|
||||
- disabled friendly_urls by default
|
||||
- fixes when $config['database_*'] is set
|
||||
- added CHANGELOG
|
||||
* fixed bug when creating character (not showing errors)
|
||||
* Fixed characters loading with names that has been created with other AAC
|
||||
* fixed links to shop in default template
|
||||
* fixed some weird PHP 7.1 warnings/notices
|
||||
* Fixed config loading with some weird comments
|
||||
* fixed bug with status info utf8 encoding (https://otland.net/threads/myaac-v0-0-1.251454/page-2#post-2440259)
|
||||
* fixed when ip in log_action is NULL (https://otland.net/threads/myaac-v0-0-1.251454/page-2#post-2440357)
|
||||
* fixed bug when guild doesn't exist on characters page (https://otland.net/threads/myaac-v0-0-1.251454/page-2#post-2440320)
|
||||
* disabled friendly_urls by default
|
||||
* fixes when $config['database_*'] is set
|
||||
* added CHANGELOG
|
||||
|
||||
[0.0.3 - 03.05.2017]
|
||||
- Full support for OTHire 0.0.3
|
||||
- added support for otservers that doesn't use account.name field, instead just account number will be used
|
||||
- fixed encryption detection on TFS 0.3
|
||||
- fixed bug when server_config table doesn't exist
|
||||
- (install) moved admin account creation to new step
|
||||
- fixed news comment link
|
||||
- by default, the installer creates now the Admin player, for admin account
|
||||
- fixed installation errors
|
||||
- fixed config.lua loading with some weird comments
|
||||
* Full support for OTHire 0.0.3
|
||||
* added support for otservers that doesn't use account.name field, instead just account number will be used
|
||||
* fixed encryption detection on TFS 0.3
|
||||
* fixed bug when server_config table doesn't exist
|
||||
* (install) moved admin account creation to new step
|
||||
* fixed news comment link
|
||||
* by default, the installer creates now the Admin player, for admin account
|
||||
* fixed installation errors
|
||||
* fixed config.lua loading with some weird comments
|
||||
|
||||
[0.0.2 - 02.05.2017]
|
||||
- updated forum links to use friendly_urls
|
||||
- some more info will be shown when cannot connect to database
|
||||
- show more error infos when creating character
|
||||
- fixed forum link on newses
|
||||
- fixed spells loading when there's vocation name instead of id
|
||||
- fixed bug when you have changed template but it doesn't exist anymore
|
||||
- fixed vocations with promotion loading
|
||||
- fixed support for gesior pages and templates
|
||||
- added function OTS_Acount:getGroupId()
|
||||
* updated forum links to use friendly_urls
|
||||
* some more info will be shown when cannot connect to database
|
||||
* show more error infos when creating character
|
||||
* fixed forum link on newses
|
||||
* fixed spells loading when there's vocation name instead of id
|
||||
* fixed bug when you have changed template but it doesn't exist anymore
|
||||
* fixed vocations with promotion loading
|
||||
* fixed support for gesior pages and templates
|
||||
* added function OTS_Acount:getGroupId()
|
||||
|
||||
[0.0.1 - 01.05.2017]
|
||||
This is first official release of MyAAC.
|
||||
|
@@ -1,11 +1,11 @@
|
||||
# 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
|
||||
|
||||
- PHP 5.2.0 or later
|
||||
- PHP 5.3.0 or later
|
||||
- MySQL database
|
||||
- PDO PHP Extension
|
||||
- XML PHP Extension
|
||||
@@ -27,7 +27,7 @@ Official website: http://my-aac.org
|
||||
chmod 660 config.local.php
|
||||
chmod 660 images/guilds
|
||||
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.
|
||||
|
||||
|
37
TODO
Normal file
@@ -0,0 +1,37 @@
|
||||
// MyAAC TODO
|
||||
|
||||
0.*
|
||||
* support duplicated vocation names with different ids
|
||||
* plugins: option to define custom requirements check in json file, to check if system meets the requirement
|
||||
* add support for defining max myaac version in plugin.json file
|
||||
* cache Menus in templates
|
||||
* don't show error indicators on first time load - createaccount page
|
||||
* update Twig to the latest version from 1.x branch
|
||||
* semantic versioning support for plugins (github.com/composer/semver)
|
||||
* add some notice to the user that installing step "Import Schema" will take some time
|
||||
* check user IP on installing to prevent install by random user
|
||||
|
||||
1.0:
|
||||
* i18n support (issue #1 on github)
|
||||
* New Admin Panel layout and interface
|
||||
* add changelog management interface
|
||||
* remove tibiacom template, and include it as a plugin
|
||||
|
||||
2.0
|
||||
* remove compat functions
|
||||
* folder restructure:
|
||||
* var/ (for logs, cache and data), config/, bin, public/ (for index and images and other public content), system/ (for php files and classess)
|
||||
* rename templates to layouts as templates is meant to be used for twig templates
|
||||
* change gifts_system to shop_system configurable
|
||||
* move most used options in system/templates dir to separate directories (more transparent)
|
||||
|
||||
At any time between (version not specified):
|
||||
* better news archive with search function (like on tibia.com)
|
||||
* guild wars management (issue #13 on github)
|
||||
* update account.management page to be more realistic (like on tibia.com)
|
||||
* update guilds page to be more realistic (like on tibia.com)
|
||||
* possibility to add extra cache engines with plugins
|
||||
* preferably configurable (enable/disable) forum TinyMCE editor
|
||||
* new cache engine - plain php, is good with pure php 7.0+ and opcache
|
||||
* OTAdmin support in Admin Panel
|
||||
* database towns table support for TFS 1.3
|
@@ -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!');
|
||||
}
|
||||
|
||||
define('ADMIN_PANEL', true);
|
||||
|
||||
$content = '';
|
||||
|
||||
// validate page
|
||||
|
@@ -28,7 +28,7 @@ h1, h2, h3, h4, h5, h6 {color: #313334; font-weight: bold;}
|
||||
margin-left:5px;
|
||||
}
|
||||
|
||||
.button { background:#eee url(images/button.gif) repeat-x 0 0; border:solid 1px #b1a874; color:#7f7f7f; font-size:11px; padding:2px 6px 2px 6px; cursor:pointer; line-height:14px !important; }
|
||||
.button { background:#eee repeat-x 0 0; border:solid 1px #b1a874; color:#7f7f7f; font-size:11px; padding:2px 6px 2px 6px; cursor:pointer; line-height:14px !important; }
|
||||
.button:hover { color:#333; border-color:#857b42; }
|
||||
|
||||
.field, .button { -moz-border-radius:4px; -webkit-border-radius:4px; }
|
||||
@@ -126,7 +126,7 @@ a.ico:hover { color:#333;}
|
||||
font-size: 12px;
|
||||
}
|
||||
#status .success {
|
||||
margin: 0px:
|
||||
margin: 0px;
|
||||
}
|
||||
#version {
|
||||
position: absolute; top: 10px; right: 10px;
|
||||
|
@@ -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>
|
||||
</div>
|
||||
<?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 id="wrapper">
|
||||
<?php
|
||||
@@ -39,10 +39,12 @@
|
||||
'Dashboard' => 'dashboard',
|
||||
'Mailer' => 'mailer',
|
||||
'Pages' => 'pages',
|
||||
'Menus' => 'menus',
|
||||
'Plugins' => 'plugins',
|
||||
'Statistics' => 'statistics',
|
||||
'Visitors' => 'visitors',
|
||||
'Players' => 'players',
|
||||
'Items' => 'items',
|
||||
'Tools' => array(
|
||||
'phpinfo' => 'phpinfo'
|
||||
),
|
||||
@@ -78,6 +80,19 @@
|
||||
}
|
||||
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>
|
||||
</div>
|
||||
|
41
common.php
@@ -21,14 +21,13 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
session_start();
|
||||
|
||||
define('MYAAC', true);
|
||||
define('MYAAC_VERSION', '0.4.3');
|
||||
define('DATABASE_VERSION', 9);
|
||||
define('MYAAC_VERSION', '0.7.5');
|
||||
define('DATABASE_VERSION', 20);
|
||||
define('TABLE_PREFIX', 'myaac_');
|
||||
define('START_TIME', microtime(true));
|
||||
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX'));
|
||||
@@ -43,12 +42,14 @@ define('FLAG_CONTENT_FORUM', 32);
|
||||
define('FLAG_CONTENT_COMMANDS', 64);
|
||||
define('FLAG_CONTENT_SPELLS', 128);
|
||||
define('FLAG_CONTENT_MONSTERS', 256);
|
||||
define('FLAG_CONTENT_SCREENSHOTS', 512);
|
||||
define('FLAG_CONTENT_MOVIES', 1024);
|
||||
define('FLAG_CONTENT_GALLERY', 512);
|
||||
define('FLAG_CONTENT_VIDEOS', 1024);
|
||||
define('FLAG_CONTENT_FAQ', 2048);
|
||||
define('FLAG_CONTENT_MENUS', 4096);
|
||||
|
||||
// news
|
||||
define('NEWS', 1);
|
||||
define('TICKET', 2);
|
||||
define('TICKER', 2);
|
||||
define('ARTICLE', 3);
|
||||
|
||||
// directories
|
||||
@@ -59,10 +60,19 @@ define('CACHE', SYSTEM . 'cache/');
|
||||
define('LOCALE', SYSTEM . 'locale/');
|
||||
define('LIBS', SYSTEM . 'libs/');
|
||||
define('LOGS', SYSTEM . 'logs/');
|
||||
define('PAGES', SYSTEM . 'pages/');
|
||||
define('PLUGINS', BASE . 'plugins/');
|
||||
define('TEMPLATES', BASE . 'templates/');
|
||||
define('TOOLS', BASE . 'tools/');
|
||||
|
||||
// menu categories
|
||||
define('MENU_CATEGORY_NEWS', 1);
|
||||
define('MENU_CATEGORY_ACCOUNT', 2);
|
||||
define('MENU_CATEGORY_COMMUNITY', 3);
|
||||
define('MENU_CATEGORY_FORUM', 4);
|
||||
define('MENU_CATEGORY_LIBRARY', 5);
|
||||
define('MENU_CATEGORY_SHOP', 6);
|
||||
|
||||
// otserv versions
|
||||
define('OTSERV', 1);
|
||||
define('OTSERV_06', 2);
|
||||
@@ -84,12 +94,15 @@ $basedir = str_replace('/admin', '', $basedir);
|
||||
$basedir = str_replace('/install', '', $basedir);
|
||||
define('BASE_DIR', $basedir);
|
||||
|
||||
if(isset($_SERVER['HTTPS'][0]) && $_SERVER['HTTPS'] == 'on')
|
||||
define('SERVER_URL', 'https://' . $_SERVER['HTTP_HOST']);
|
||||
else
|
||||
define('SERVER_URL', 'http://' . $_SERVER['HTTP_HOST']);
|
||||
|
||||
define('BASE_URL', SERVER_URL . BASE_DIR . '/');
|
||||
define('ADMIN_URL', SERVER_URL . BASE_DIR . '/admin/');
|
||||
//define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']);
|
||||
if(isset($_SERVER['HTTP_HOST'])) {
|
||||
if (isset($_SERVER['HTTPS'][0]) && $_SERVER['HTTPS'] == 'on')
|
||||
define('SERVER_URL', 'https://' . $_SERVER['HTTP_HOST']);
|
||||
else
|
||||
define('SERVER_URL', 'http://' . $_SERVER['HTTP_HOST']);
|
||||
|
||||
define('BASE_URL', SERVER_URL . BASE_DIR . '/');
|
||||
define('ADMIN_URL', SERVER_URL . BASE_DIR . '/admin/');
|
||||
|
||||
//define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']);
|
||||
}
|
||||
?>
|
||||
|
18
config.php
@@ -13,7 +13,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
|
||||
@@ -30,6 +29,7 @@ $config = array(
|
||||
// used for the Downloads page and some templates aswell
|
||||
'client' => 1098, // 954 = client 9.54
|
||||
|
||||
'session_prefix' => 'myaac_', // must be unique for every site on your server
|
||||
'friendly_urls' => false, // mod_rewrite is required for this, it makes links looks more elegant to eye, and also are SEO friendly (example: http://my-aac.org/guilds/Testing instead of http://my-aac.org/?subtopic=guilds&name=Testing). Remember to rename .htaccess.dist to .htaccess
|
||||
'gzip_output' => false, // gzip page content before sending it to the browser, uses less bandwidth but more cpu cycles
|
||||
|
||||
@@ -73,9 +73,9 @@ $config = array(
|
||||
//'2' => 'Your Second World Name'
|
||||
),
|
||||
|
||||
// items
|
||||
// images
|
||||
'outfit_images_url' => 'http://outfit-images.ots.me/outfit.php', // set to animoutfit.php for animated outfit
|
||||
'item_images_url' => 'http://item-images.ots.me/960/', // set to images/items if you host your own items in images folder
|
||||
'item_images_url' => 'http://item-images.ots.me/1092/', // set to images/items if you host your own items in images folder
|
||||
|
||||
// account
|
||||
'account_management' => true, // disable if you're using other method to manage users (fe. tfs account manager)
|
||||
@@ -110,7 +110,7 @@ $config = array(
|
||||
|
||||
// reCAPTCHA (prevent spam bots)
|
||||
'recaptcha_enabled' => false, // enable recaptcha verification code
|
||||
'recaptcha_site_key' => '', // get your own public and private keys at https://www.google.com/recaptcha
|
||||
'recaptcha_site_key' => '', // get your own site and secret keys at https://www.google.com/recaptcha
|
||||
'recaptcha_secret_key' => '',
|
||||
'recaptcha_theme' => 'light', // light, dark
|
||||
|
||||
@@ -158,7 +158,8 @@ $config = array(
|
||||
|
||||
'signature_enabled' => true,
|
||||
'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_record' => true, // display players record?
|
||||
@@ -185,6 +186,8 @@ $config = array(
|
||||
'highscores_outfit' => true, // show player outfit?
|
||||
'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_ids_hidden' => array(0), // this ids of players will be hidden on the highscores (should be ids of samples)
|
||||
'highscores_length' => 100, // how many records per page on highscores
|
||||
|
||||
// characters page
|
||||
'characters' => array( // what things to display on character view page (true/false in each option)
|
||||
@@ -211,8 +214,8 @@ $config = array(
|
||||
'gifts_system' => false,
|
||||
|
||||
// support/system
|
||||
'bug_report' => true,
|
||||
|
||||
'bug_report' => true, // this configurable has no effect, its always enabled
|
||||
|
||||
// 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
|
||||
@@ -228,6 +231,7 @@ $config = array(
|
||||
'status_port' => '',
|
||||
|
||||
// other
|
||||
'anonymous_usage_statistics' => true,
|
||||
'email_lai_sec_interval' => 60, // time in seconds between e-mails to one account from lost account interface, block spam
|
||||
'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)
|
||||
|
BIN
images/changelog/unknown.png
Normal file
After Width: | Height: | Size: 797 B |
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 122 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
BIN
images/global/general/blank.gif
Executable file
After Width: | Height: | Size: 71 B |
BIN
images/global/general/box-bottom.gif
Executable file
After Width: | Height: | Size: 2.0 KiB |
BIN
images/global/general/box-top.gif
Executable file
After Width: | Height: | Size: 2.0 KiB |
BIN
images/global/general/chain.gif
Executable file
After Width: | Height: | Size: 845 B |
BIN
images/global/general/favicon.ico
Executable file
After Width: | Height: | Size: 3.6 KiB |
BIN
images/global/general/hide.gif
Executable file
After Width: | Height: | Size: 469 B |
BIN
images/global/general/minus.gif
Executable file
After Width: | Height: | Size: 224 B |
BIN
images/global/general/nok.gif
Executable file
After Width: | Height: | Size: 117 B |
BIN
images/global/general/ok.gif
Executable file
After Width: | Height: | Size: 113 B |
BIN
images/global/general/plus.gif
Executable file
After Width: | Height: | Size: 224 B |
BIN
images/global/general/show.gif
Executable file
After Width: | Height: | Size: 681 B |
BIN
images/news/announcement.jpg
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
images/plus.png
Normal file
After Width: | Height: | Size: 9.1 KiB |
174
index.php
@@ -21,7 +21,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
|
||||
@@ -31,29 +30,142 @@
|
||||
// error_reporting(E_ALL);
|
||||
|
||||
require_once('common.php');
|
||||
require_once(BASE . 'config.local.php');
|
||||
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 = str_replace(array('index.php/', '?'), '', $uri);
|
||||
define('URI', $uri);
|
||||
|
||||
if(preg_match("/^[A-Za-z0-9-_%\'+]+\.png$/i", $uri)) {
|
||||
$tmp = explode('.', $uri);
|
||||
$_REQUEST['name'] = urldecode($tmp[0]);
|
||||
|
||||
chdir(TOOLS . 'signature');
|
||||
include(TOOLS . 'signature/index.php');
|
||||
exit();
|
||||
}
|
||||
else if(preg_match("/^(.*)\.(gif|jpg|png|jpeg|tiff|bmp|css|js|less|map|html|php|zip|rar|gz|ttf|woff|ico)$/i", $_SERVER['REQUEST_URI'])) {
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once(BASE . 'config.local.php');
|
||||
if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed']))
|
||||
{
|
||||
header('Location: ' . BASE_URL . 'install/');
|
||||
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!');
|
||||
}
|
||||
|
||||
$found = false;
|
||||
if(empty($uri) || isset($_REQUEST['template'])) {
|
||||
$_REQUEST['p'] = 'news';
|
||||
$found = true;
|
||||
}
|
||||
else {
|
||||
$tmp = strtolower($uri);
|
||||
if(!preg_match('/[^A-z0-9_\-]/', $uri) && file_exists(SYSTEM . 'pages/' . $tmp . '.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' => 'change_password'),
|
||||
'/^account\/register\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'register'),
|
||||
'/^account\/register\/new\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'register_new'),
|
||||
'/^account\/email\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_email'),
|
||||
'/^account\/info\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_info'),
|
||||
'/^account\/character\/create\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'create_character'),
|
||||
'/^account\/character\/name\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_name'),
|
||||
'/^account\/character\/sex\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_sex'),
|
||||
'/^account\/character\/delete\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'delete_character'),
|
||||
'/^account\/character\/comment\/[A-Za-z0-9-_%+\']+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_comment', 'name' => '$3'),
|
||||
'/^account\/character\/comment\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'change_comment'),
|
||||
'/^account\/confirm_email\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'confirm_email', 'v' => '$2'),
|
||||
'/^characters\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'characters', 'name' => '$1'),
|
||||
'/^changelog\/[0-9]+\/?$/' => array('subtopic' => 'changelog', 'page' => '$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'),
|
||||
'/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2'),
|
||||
'/^gifts\/history\/?$/' => array('subtopic' => 'gifts', 'action' => 'show_history'),
|
||||
);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// define page visited, so it can be used within events system
|
||||
$page = isset($_REQUEST['subtopic']) ? $_REQUEST['subtopic'] : (isset($_GET['p']) ? $_GET['p'] : '');
|
||||
if(empty($page) || preg_match('/[^A-z0-9_\-]/', $page))
|
||||
$page = 'news';
|
||||
$page = isset($_REQUEST['subtopic']) ? $_REQUEST['subtopic'] : (isset($_REQUEST['p']) ? $_REQUEST['p'] : '');
|
||||
if(empty($page) || !preg_match('/^[A-z0-9\_\-]+$/', $page)) {
|
||||
$tmp = URI;
|
||||
if(!empty($tmp)) {
|
||||
$page = $tmp;
|
||||
}
|
||||
else {
|
||||
if(!$found)
|
||||
$page = '404';
|
||||
else
|
||||
$page = 'news';
|
||||
}
|
||||
}
|
||||
|
||||
$page = strtolower($page);
|
||||
define('PAGE', $page);
|
||||
|
||||
$template_place_holders = array();
|
||||
|
||||
require_once(SYSTEM . 'functions.php');
|
||||
require_once(SYSTEM . 'init.php');
|
||||
require_once(SYSTEM . 'template.php');
|
||||
require_once(SYSTEM . 'login.php');
|
||||
require_once(SYSTEM . 'status.php');
|
||||
require_once(SYSTEM . 'template.php');
|
||||
|
||||
$twig->addGlobal('config', $config);
|
||||
$twig->addGlobal('status', $status);
|
||||
@@ -87,6 +199,41 @@ $hooks = new Hooks();
|
||||
$hooks->load();
|
||||
$hooks->trigger(HOOK_STARTUP);
|
||||
|
||||
// anonymous usage statistics
|
||||
// sent only when user agrees
|
||||
if(isset($config['anonymous_usage_statistics']) && $config['anonymous_usage_statistics']) {
|
||||
$report_time = 30 * 24 * 60 * 60; // report one time per 30 days
|
||||
$should_report = true;
|
||||
|
||||
$value = '';
|
||||
if($cache->enabled() && $cache->fetch('last_usage_report', $value)) {
|
||||
$should_report = time() > (int)$value + $report_time;
|
||||
}
|
||||
else {
|
||||
$value = '';
|
||||
if(fetchDatabaseConfig('last_usage_report', $value)) {
|
||||
$should_report = time() > (int)$value + $report_time;
|
||||
if($cache->enabled()) {
|
||||
$cache->set('last_usage_report', $value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
registerDatabaseConfig('last_usage_report', time() - ($report_time - (7 * 24 * 60 * 60))); // first report after a week
|
||||
$should_report = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($should_report) {
|
||||
require_once(LIBS . 'usage_statistics.php');
|
||||
Usage_Statistics::report();
|
||||
|
||||
updateDatabaseConfig('last_usage_report', time());
|
||||
if($cache->enabled()) {
|
||||
$cache->set('last_usage_report', time());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($config['views_counter'])
|
||||
require_once(SYSTEM . 'counter.php');
|
||||
|
||||
@@ -132,6 +279,7 @@ if($config['backward_support']) {
|
||||
$layout_header = template_header();
|
||||
$layout_name = $template_path;
|
||||
$news_content = '';
|
||||
$tickers_content = '';
|
||||
$subtopic = PAGE;
|
||||
$main_content = '';
|
||||
|
||||
@@ -156,7 +304,7 @@ if($config['backward_support']) {
|
||||
$config['site']['screenshot_page'] = true;
|
||||
|
||||
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)
|
||||
$config['status']['serverStatus_' . $key] = $value;
|
||||
@@ -172,14 +320,14 @@ if($load_it)
|
||||
|
||||
$ignore = false;
|
||||
|
||||
$logged_access = 0;
|
||||
$logged_access = 1;
|
||||
if($logged && $account_logged && $account_logged->isLoaded()) {
|
||||
$logged_access = $account_logged->getAccess();
|
||||
}
|
||||
|
||||
$query =
|
||||
$db->query(
|
||||
'SELECT `title`, `body`, `php`' .
|
||||
'SELECT `id`, `title`, `body`, `php`, `hidden`' .
|
||||
' FROM `' . TABLE_PREFIX . 'pages`' .
|
||||
' WHERE `name` LIKE ' . $db->quote($page) . ' AND `hidden` != 1 AND `access` <= ' . $db->quote($logged_access));
|
||||
if($query->rowCount() > 0) // found page
|
||||
@@ -219,6 +367,12 @@ if($load_it)
|
||||
}
|
||||
else
|
||||
$content .= $query['body']; // plain html
|
||||
|
||||
if(hasFlag(FLAG_CONTENT_PAGES) || superAdmin()) {
|
||||
$content = $twig->render('admin.pages.links.html.twig', array(
|
||||
'page' => array('id' => $query['id'], 'hidden' => $query['hidden'])
|
||||
)) . $content;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -1,12 +1,17 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(!isset($_SESSION['var_server_path'])) {
|
||||
error($locale['step_database_error_config']);
|
||||
$error = true;
|
||||
}
|
||||
|
||||
$config['server_path'] = $_SESSION['var_server_path'];
|
||||
// take care of trailing slash at the end
|
||||
if($config['server_path'][strlen($config['server_path']) - 1] != '/')
|
||||
$config['server_path'] .= '/';
|
||||
|
||||
if(!file_exists($config['server_path'] . 'config.lua')) {
|
||||
if((!isset($error) || !$error) && !file_exists($config['server_path'] . 'config.lua')) {
|
||||
error($locale['step_database_error_config']);
|
||||
$error = true;
|
||||
}
|
||||
|
@@ -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'] . '" />';
|
||||
*/
|
||||
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="« ' . $locale['previous'] . '" />';
|
||||
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'] . ' »" />';
|
||||
|
||||
$ret .= '</div>';
|
||||
return $ret;
|
||||
@@ -78,4 +78,23 @@ function next_form($previous = true, $next = true)
|
||||
<input type="hidden" name="step" id="step" value="' . $step . '" />' . next_buttons($previous, $next) . '
|
||||
</form>';
|
||||
}
|
||||
?>
|
||||
|
||||
function win_is_writable($path) {
|
||||
if($path[strlen( $path ) - 1] == '/') { // if it looks like a directory, check a random file within the directory
|
||||
return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
|
||||
} elseif(is_dir( $path )) { // If it's a directory (and not a file) check a random file within the directory
|
||||
return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
|
||||
}
|
||||
|
||||
// check tmp file for read/write capabilities
|
||||
$should_delete_tmp_file = !file_exists( $path );
|
||||
$f = @fopen( $path, 'a' );
|
||||
if ( $f === false )
|
||||
return false;
|
||||
|
||||
fclose( $f );
|
||||
if($should_delete_tmp_file)
|
||||
unlink($path);
|
||||
|
||||
return true;
|
||||
}
|
@@ -1,11 +1,22 @@
|
||||
CREATE TABLE `myaac_account_actions`
|
||||
(
|
||||
`account_id` INT(11) NOT NULL,
|
||||
`ip` INT(11) NOT NULL DEFAULT 0,
|
||||
`ipv6` BINARY(16) NOT NULL DEFAULT 0,
|
||||
`date` INT(11) NOT NULL DEFAULT 0,
|
||||
`action` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
KEY (`account_id`)
|
||||
`account_id` INT(11) NOT NULL,
|
||||
`ip` INT(11) NOT NULL DEFAULT 0,
|
||||
`ipv6` BINARY(16) NOT NULL DEFAULT 0,
|
||||
`date` INT(11) NOT NULL DEFAULT 0,
|
||||
`action` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
KEY (`account_id`)
|
||||
) 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`
|
||||
@@ -20,7 +31,7 @@ CREATE TABLE `myaac_bugtracker`
|
||||
`who` INT(11) NOT NULL DEFAULT 0,
|
||||
`uid` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`tag` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`uid`)
|
||||
PRIMARY KEY (`uid`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_changelog`
|
||||
@@ -73,6 +84,8 @@ CREATE TABLE `myaac_forum_boards`
|
||||
`name` VARCHAR(32) NOT NULL,
|
||||
`description` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
`guild` INT(11) NOT NULL DEFAULT 0,
|
||||
`access` INT(11) NOT NULL DEFAULT 0,
|
||||
`closed` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`hidden` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
@@ -94,7 +107,7 @@ CREATE TABLE `myaac_forum`
|
||||
`author_aid` int(20) NOT NULL default '0',
|
||||
`author_guid` int(20) NOT NULL default '0',
|
||||
`post_text` text NOT NULL,
|
||||
`post_topic` varchar(255) NOT NULL,
|
||||
`post_topic` varchar(255) NOT NULL DEFAULT '',
|
||||
`post_smile` tinyint(1) NOT NULL default '0',
|
||||
`post_date` int(20) NOT NULL default '0',
|
||||
`last_edit_aid` int(20) NOT NULL default '0',
|
||||
@@ -112,30 +125,121 @@ CREATE TABLE `myaac_hooks`
|
||||
`name` VARCHAR(30) NOT NULL DEFAULT '',
|
||||
`type` INT(2) NOT NULL DEFAULT 0,
|
||||
`file` VARCHAR(100) NOT NULL,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
`enabled` INT(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_items`
|
||||
(
|
||||
`id` INT(11) NOT NULL,
|
||||
`article` VARCHAR(5) NOT NULL DEFAULT '',
|
||||
`name` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`plural` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`attributes` VARCHAR(500) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_menu`
|
||||
(
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`template` VARCHAR(255) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`link` VARCHAR(255) NOT NULL,
|
||||
`category` INT(11) NOT NULL DEFAULT 1,
|
||||
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||
`enabled` INT(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
/* MENU_CATEGORY_NEWS kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Latest News', 'news', 1, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'News Archive', 'news/archive', 1, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Changelog', 'changelog', 1, 2);
|
||||
/* MENU_CATEGORY_ACCOUNT kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Account Management', 'account/manage', 2, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Create Account', 'account/create', 2, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Lost Account?', 'account/lost', 2, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Server Rules', 'rules', 2, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Downloads', 'downloads', 5, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Report Bug', 'bugtracker', 2, 5);
|
||||
/* MENU_CATEGORY_COMMUNITY kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Who is Online?', 'online', 3, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Characters', 'characters', 3, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Guilds', 'guilds', 3, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Highscores', 'highscores', 3, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Last Deaths', 'lastkills', 3, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Houses', 'houses', 3, 5);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Bans', 'bans', 3, 6);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Forum', 'forum', 3, 7);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Team', 'team', 3, 8);
|
||||
/* MENU_CATEGORY_LIBRARY kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Monsters', 'creatures', 5, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Spells', 'spells', 5, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Server Info', 'serverInfo', 5, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Commands', 'commands', 5, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Gallery', 'gallery', 5, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Experience Table', 'experienceTable', 5, 5);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'FAQ', 'faq', 5, 6);
|
||||
/* MENU_CATEGORY_SHOP kathrine */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Buy Points', 'points', 6, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Shop Offer', 'gifts', 6, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('kathrine', 'Shop History', 'gifts/history', 6, 2);
|
||||
/* MENU_CATEGORY_NEWS tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Latest News', 'news', 1, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'News Archive', 'news/archive', 1, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Changelog', 'changelog', 1, 2);
|
||||
/* MENU_CATEGORY_ACCOUNT tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Account Management', 'account/manage', 2, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Create Account', 'account/create', 2, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Lost Account?', 'account/lost', 2, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Server Rules', 'rules', 2, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Downloads', 'downloads', 2, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Report Bug', 'bugtracker', 2, 5);
|
||||
/* MENU_CATEGORY_COMMUNITY tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Characters', 'characters', 3, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Who Is Online?', 'online', 3, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Highscores', 'highscores', 3, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Last Kills', 'lastkills', 3, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Houses', 'houses', 3, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Guilds', 'guilds', 3, 5);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Polls', 'polls', 3, 6);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Bans', 'bans', 3, 7);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Support List', 'team', 3, 8);
|
||||
/* MENU_CATEGORY_FORUM tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Forum', 'forum', 4, 0);
|
||||
/* MENU_CATEGORY_LIBRARY tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Creatures', 'creatures', 5, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Spells', 'spells', 5, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Commands', 'commands', 5, 2);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Exp Stages', 'experienceStages', 5, 3);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Gallery', 'gallery', 5, 4);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Server Info', 'serverInfo', 5, 5);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Experience Table', 'experienceTable', 5, 6);
|
||||
/* MENU_CATEGORY_SHOP tibiacom */
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Buy Points', 'points', 6, 0);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Shop Offer', 'gifts', 6, 1);
|
||||
INSERT INTO `myaac_menu` (`template`, `name`, `link`, `category`, `ordering`) VALUES ('tibiacom', 'Shop History', 'gifts/history', 6, 2);
|
||||
|
||||
CREATE TABLE `myaac_monsters` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`hide_creature` tinyint(1) NOT NULL default '0',
|
||||
`hidden` tinyint(1) NOT NULL default 0,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`mana` int(11) NOT NULL,
|
||||
`mana` int(11) NOT NULL DEFAULT 0,
|
||||
`exp` int(11) NOT NULL,
|
||||
`health` int(11) NOT NULL,
|
||||
`speed_lvl` int(11) NOT NULL default '1',
|
||||
`speed_lvl` int(11) NOT NULL default 1,
|
||||
`use_haste` tinyint(1) NOT NULL,
|
||||
`voices` text NOT NULL,
|
||||
`immunities` varchar(255) NOT NULL,
|
||||
`summonable` tinyint(1) NOT NULL,
|
||||
`convinceable` tinyint(1) NOT NULL,
|
||||
`race` varchar(255) NOT NULL,
|
||||
`gfx_name` varchar(255) NOT NULL,
|
||||
`file_path` varchar(255) NOT NULL,
|
||||
`loot` varchar(500) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_movies`
|
||||
CREATE TABLE `myaac_videos`
|
||||
(
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`title` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
@@ -151,13 +255,15 @@ CREATE TABLE `myaac_news`
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`title` VARCHAR(100) NOT NULL,
|
||||
`body` TEXT NOT NULL,
|
||||
`type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - news, 2 - ticket, 3 - article',
|
||||
`type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - news, 2 - ticker, 3 - article',
|
||||
`date` INT(11) NOT NULL DEFAULT 0,
|
||||
`category` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`player_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`last_modified_by` INT(11) NOT NULL DEFAULT 0,
|
||||
`last_modified_date` INT(11) NOT NULL DEFAULT 0,
|
||||
`comments` VARCHAR(50) NOT NULL,
|
||||
`comments` VARCHAR(50) NOT NULL DEFAULT '',
|
||||
`article_text` VARCHAR(300) NOT NULL DEFAULT '',
|
||||
`article_image` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`hidden` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
@@ -202,7 +308,7 @@ CREATE TABLE `myaac_pages`
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_screenshots`
|
||||
CREATE TABLE `myaac_gallery`
|
||||
(
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`comment` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
@@ -214,7 +320,7 @@ CREATE TABLE `myaac_screenshots`
|
||||
PRIMARY KEY (`id`)
|
||||
) 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`
|
||||
(
|
||||
@@ -223,17 +329,18 @@ CREATE TABLE `myaac_spells`
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`words` VARCHAR(255) NOT NULL,
|
||||
`category` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - attack, 2 - healing, 3 - summon, 4 - supply, 5 - support',
|
||||
`type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - instant, 2 - rune',
|
||||
`type` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '1 - instant, 2 - conjure, 3 - rune',
|
||||
`level` INT(11) NOT NULL DEFAULT 0,
|
||||
`maglevel` INT(11) NOT NULL DEFAULT 0,
|
||||
`mana` INT(11) NOT NULL DEFAULT 0,
|
||||
`soul` TINYINT(3) NOT NULL DEFAULT 0,
|
||||
`conjure_count` TINYINT(3) NOT NULL DEFAULT 0,
|
||||
`item_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`premium` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`vocations` VARCHAR(32) NOT NULL,
|
||||
`vocations` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
`hidden` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE (`spell`)
|
||||
UNIQUE (`name`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_visitors`
|
||||
@@ -243,3 +350,12 @@ CREATE TABLE `myaac_visitors`
|
||||
`page` VARCHAR(100) NOT NULL,
|
||||
UNIQUE (`ip`)
|
||||
) ENGINE = MyISAM;
|
||||
|
||||
CREATE TABLE `myaac_weapons`
|
||||
(
|
||||
`id` INT(11) NOT NULL,
|
||||
`level` INT(11) NOT NULL DEFAULT 0,
|
||||
`maglevel` INT(11) NOT NULL DEFAULT 0,
|
||||
`vocations` VARCHAR(100) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MyISAM;
|
||||
|
11
install/includes/twig_error.html
Normal file
@@ -0,0 +1,11 @@
|
||||
We have detected that you don't have access to write to the system/cache directory. Under linux you can fix it by using this two command, where first one should be enough (for apache):<br/><br/><span class="console">chown -R www-data.www-data /var/www/*</span><br/><span class="console">chmod -R 660 system/cache</span>
|
||||
|
||||
<style type="text/css">
|
||||
.console {
|
||||
font-family:Courier;
|
||||
color: #CCCCCC;
|
||||
background: #000000;
|
||||
border: 3px double #CCCCCC;
|
||||
padding: 0px;
|
||||
}
|
||||
</style>
|
@@ -1,48 +1,109 @@
|
||||
<?php
|
||||
require('../common.php');
|
||||
|
||||
// step
|
||||
$step = isset($_POST['step']) ? $_POST['step'] : 'welcome';
|
||||
|
||||
// includes
|
||||
require(SYSTEM . 'functions.php');
|
||||
require(BASE . 'install/includes/functions.php');
|
||||
require(BASE . 'install/includes/locale.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']))
|
||||
{
|
||||
foreach($_POST['vars'] as $key => $value)
|
||||
$_SESSION['var_' . $key] = $value;
|
||||
}
|
||||
|
||||
// step
|
||||
$step = isset($_POST['step']) ? $_POST['step'] : 'welcome';
|
||||
|
||||
$steps = array(1 => 'welcome', 2 => 'license', 3 => 'requirements', 4 => 'config', 5 => 'database', 6 => 'admin', 7 => 'finish');
|
||||
if(!in_array($step, $steps)) // check if step is valid
|
||||
die('ERROR: Unknown step.');
|
||||
|
||||
$errors = array();
|
||||
if($step == 'database')
|
||||
{
|
||||
foreach($_POST['vars'] as $key => $value)
|
||||
{
|
||||
if(empty($value))
|
||||
if($key != 'usage' && empty($value))
|
||||
{
|
||||
$step = 'config';
|
||||
$errors = '<p class="error">' . $locale['please_fill_all'] . '</p>';
|
||||
$errors[] = $locale['please_fill_all'];
|
||||
break;
|
||||
}
|
||||
else if($key == 'mail_admin' && !Validator::email($value))
|
||||
{
|
||||
$errors[] = $locale['step_config_mail_admin_error'];
|
||||
break;
|
||||
}
|
||||
else if($key == 'mail_address' && !Validator::email($value))
|
||||
{
|
||||
$errors[] = $locale['step_config_mail_address_error'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($errors)) {
|
||||
$step = 'config';
|
||||
}
|
||||
}
|
||||
else if($step == 'finish') {
|
||||
// password
|
||||
$password = $_SESSION['var_password'];
|
||||
|
||||
if(isset($_SESSION['var_account'])) {
|
||||
if(!Validator::accountName($_SESSION['var_account'])) {
|
||||
$errors[] = $locale['step_admin_account_error_format'];
|
||||
}
|
||||
else if(strtoupper($_SESSION['var_account']) == strtoupper($password)) {
|
||||
$errors[] = $locale['step_admin_account_error_same'];
|
||||
}
|
||||
}
|
||||
else if(isset($_SESSION['var_account_id'])) {
|
||||
if(!Validator::accountId($_SESSION['var_account_id'])) {
|
||||
$errors[] = $locale['step_admin_account_id_error_format'];
|
||||
}
|
||||
else if($_SESSION['var_account_id'] == $password) {
|
||||
$errors[] = $locale['step_admin_account_id_error_same'];
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($password)) {
|
||||
$errors[] = $locale['step_admin_password_error_empty'];
|
||||
}
|
||||
else if(!Validator::password($password)) {
|
||||
$errors[] = $locale['step_admin_password_error_format'];
|
||||
}
|
||||
|
||||
if(!empty($errors)) {
|
||||
$step = 'admin';
|
||||
}
|
||||
}
|
||||
|
||||
$error = false;
|
||||
|
||||
// step include
|
||||
ob_start();
|
||||
require('steps/' . $step . '.php');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
clearstatcache();
|
||||
if(is_writable(CACHE) && (MYAAC_OS != 'WINDOWS' || win_is_writable(CACHE))) {
|
||||
ob_start();
|
||||
|
||||
$step_id = array_search($step, $steps);
|
||||
require('steps/' . $step_id . '-' . $step . '.php');
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
else {
|
||||
$content = error(file_get_contents(BASE . 'install/includes/twig_error.html'), true);
|
||||
}
|
||||
|
||||
// render
|
||||
require('template/template.php');
|
||||
//$_SESSION['laststep'] = $step;
|
||||
|
||||
?>
|
||||
//$_SESSION['laststep'] = $step;
|
27
install/steps/1-welcome.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['saved'])) {
|
||||
echo '<p class="warning">' . $locale['already_installed'] . '</p>';
|
||||
}
|
||||
else {
|
||||
unset($_SESSION['saved']);
|
||||
|
||||
$locales = array();
|
||||
foreach(get_locales() as $tmp_locale)
|
||||
{
|
||||
$lang_file_main = LOCALE . $tmp_locale . '/main.php';
|
||||
$lang_file_install = LOCALE . $tmp_locale . '/install.php';
|
||||
if(@file_exists($lang_file_main)
|
||||
&& @file_exists($lang_file_install))
|
||||
{
|
||||
require($lang_file_main);
|
||||
$locales[] = array('id' => $tmp_locale, 'name' => $locale['name']);
|
||||
}
|
||||
}
|
||||
echo $twig->render('install.welcome.html.twig', array(
|
||||
'locales' => $locales,
|
||||
'locale' => $locale,
|
||||
'buttons' => next_buttons(false, true)
|
||||
));
|
||||
}
|
||||
?>
|
8
install/steps/2-license.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
echo $twig->render('install.license.html.twig', array(
|
||||
'license' => file_get_contents(BASE . 'LICENSE'),
|
||||
'buttons' => next_buttons()
|
||||
));
|
||||
?>
|
@@ -22,8 +22,8 @@ function version_check($name, $ok, $info = '', $warning = false)
|
||||
$failed = false;
|
||||
|
||||
// start validating
|
||||
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)
|
||||
version_check($locale['step_requirements_php_version'], (PHP_VERSION_ID >= 50300), PHP_VERSION);
|
||||
foreach(array('config.local.php', 'images/guilds', 'images/houses', 'images/gallery') as $value)
|
||||
{
|
||||
$perms = (int) substr(decoct(fileperms(BASE . $value)), 2);
|
||||
version_check($locale['step_requirements_write_perms'] . ': ' . $value, $perms >= 660);
|
86
install/steps/4-config.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$clients_list = array(
|
||||
710,
|
||||
740,
|
||||
750,
|
||||
760,
|
||||
770,
|
||||
772,
|
||||
780,
|
||||
7920,
|
||||
800,
|
||||
810,
|
||||
821,
|
||||
822,
|
||||
831,
|
||||
840,
|
||||
841,
|
||||
842,
|
||||
850,
|
||||
852,
|
||||
853,
|
||||
854,
|
||||
855,
|
||||
857,
|
||||
860,
|
||||
870,
|
||||
|
||||
900,
|
||||
910,
|
||||
920,
|
||||
930,
|
||||
940,
|
||||
942,
|
||||
944,
|
||||
946,
|
||||
950,
|
||||
952,
|
||||
953,
|
||||
954,
|
||||
960,
|
||||
970,
|
||||
980,
|
||||
|
||||
1000,
|
||||
1010,
|
||||
1021,
|
||||
1031,
|
||||
1034,
|
||||
1041,
|
||||
1050,
|
||||
1053,
|
||||
1054,
|
||||
1058,
|
||||
1075,
|
||||
1077,
|
||||
1079,
|
||||
1080,
|
||||
1090,
|
||||
1093,
|
||||
1094,
|
||||
1095,
|
||||
1096,
|
||||
1097,
|
||||
1098,
|
||||
1100,
|
||||
);
|
||||
|
||||
$clients = array();
|
||||
foreach($clients_list as $client) {
|
||||
$client_version = (string)($client / 100);
|
||||
if(strpos($client_version, '.') == false)
|
||||
$client_version .= '.0';
|
||||
|
||||
$clients[$client] = $client_version;
|
||||
}
|
||||
|
||||
echo $twig->render('install.config.html.twig', array(
|
||||
'clients' => $clients,
|
||||
'locale' => $locale,
|
||||
'session' => $_SESSION,
|
||||
'errors' => isset($errors) ? $errors : null,
|
||||
'buttons' => next_buttons()
|
||||
));
|
||||
?>
|
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
//ini_set('display_errors', false);
|
||||
ini_set('max_execution_time', 300);
|
||||
$error = false;
|
||||
@@ -10,7 +11,8 @@ if(!isset($_SESSION['var_server_path'])) {
|
||||
}
|
||||
|
||||
if(!$error) {
|
||||
$content = "<?php\n";
|
||||
$content = "<?php";
|
||||
$content .= PHP_EOL;
|
||||
foreach($_SESSION as $key => $value)
|
||||
{
|
||||
if(strpos($key, 'var_') !== false)
|
||||
@@ -22,7 +24,11 @@ if(!$error) {
|
||||
$value .= "/";
|
||||
}
|
||||
|
||||
if($key != 'var_account' && $key != 'var_account_id' && $key != 'var_password') {
|
||||
if($key == 'var_usage') {
|
||||
$content .= '$config[\'anonymous_usage_statistics\'] = ' . ((int)$value == 1 ? 'true' : 'false') . ';';
|
||||
$content .= PHP_EOL;
|
||||
}
|
||||
else if($key != 'var_account' && $key != 'var_account_id' && $key != 'var_password') {
|
||||
$content .= '$config[\'' . str_replace('var_', '', $key) . '\'] = \'' . $value . '\';';
|
||||
$content .= PHP_EOL;
|
||||
}
|
||||
@@ -84,7 +90,7 @@ if(!$error) {
|
||||
|
||||
if(!fieldExist('blocked', 'accounts')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `blocked` TINYINT(1) NOT NULL DEFAULT FALSE COMMENT 'internal usage' AFTER `key`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.created...');
|
||||
success($locale['step_database_adding_field'] . ' accounts.blocked...');
|
||||
}
|
||||
|
||||
if(!fieldExist('created', 'accounts')) {
|
||||
@@ -221,11 +227,11 @@ if(!$error) {
|
||||
|
||||
$content .= '$config[\'mail_enabled\'] = true;';
|
||||
$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 = true;
|
||||
}
|
||||
if(!check_mail($_SESSION['var_mail_address'])) {
|
||||
if(!Validator::email($_SESSION['var_mail_address'])) {
|
||||
error($locale['step_config_mail_address_error']);
|
||||
$error = true;
|
||||
}
|
||||
@@ -234,9 +240,11 @@ if(!$error) {
|
||||
$content .= PHP_EOL;
|
||||
$content .= '$config[\'client_download_linux\'] = \'http://tibia-clients.com/clients/download/\'. $config[\'client\'] . \'/tar/linux\';';
|
||||
$content .= PHP_EOL;
|
||||
$content .= '// place for your configuration directives, so you can later easily update myaac';
|
||||
$content .= '$config[\'session_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '_\';';
|
||||
$content .= PHP_EOL;
|
||||
$content .= "?>";
|
||||
$content .= '$config[\'cache_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '_\';';
|
||||
$content .= PHP_EOL;
|
||||
|
||||
$file = fopen(BASE . 'config.local.php', 'a+');
|
||||
if($file) {
|
||||
if(!$error) {
|
15
install/steps/6-admin.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
require(BASE . 'install/includes/config.php');
|
||||
if(!$error) {
|
||||
require(BASE . 'install/includes/database.php');
|
||||
|
||||
echo $twig->render('install.admin.html.twig', array(
|
||||
'locale' => $locale,
|
||||
'session' => $_SESSION,
|
||||
'errors' => isset($errors) ? $errors : null,
|
||||
'buttons' => next_buttons(true, $error ? false : true)
|
||||
));
|
||||
}
|
||||
?>
|
227
install/steps/7-finish.php
Normal file
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['saved'])) {
|
||||
warning($locale['already_installed']);
|
||||
}
|
||||
else {
|
||||
require(SYSTEM . 'init.php');
|
||||
if(!$error) {
|
||||
if(USE_ACCOUNT_NAME)
|
||||
$account = isset($_SESSION['var_account']) ? $_SESSION['var_account'] : null;
|
||||
else
|
||||
$account_id = isset($_SESSION['var_account_id']) ? $_SESSION['var_account_id'] : null;
|
||||
|
||||
$password = $_SESSION['var_password'];
|
||||
|
||||
$config_salt_enabled = fieldExist('salt', 'accounts');
|
||||
if($config_salt_enabled)
|
||||
{
|
||||
$salt = generateRandomString(10, false, true, true);
|
||||
$password = $salt . $password;
|
||||
}
|
||||
|
||||
$account_db = new OTS_Account();
|
||||
if(isset($account))
|
||||
$account_db->find($account);
|
||||
else
|
||||
$account_db->load($account_id);
|
||||
|
||||
$player_db = new OTS_Player();
|
||||
$player_db->find('Admin');
|
||||
$groups = new OTS_Groups_List();
|
||||
if(!$player_db->isLoaded())
|
||||
{
|
||||
$player = new OTS_Player();
|
||||
$player->setName('Admin');
|
||||
|
||||
$player_used = &$player;
|
||||
}
|
||||
else {
|
||||
$player_used = &$player_db;
|
||||
}
|
||||
|
||||
$player_used->setGroupId($groups->getHighestId());
|
||||
|
||||
if($account_db->isLoaded()) {
|
||||
$account_db->setPassword(encrypt($password));
|
||||
$account_db->setEMail($_SESSION['var_mail_admin']);
|
||||
$account_db->save();
|
||||
|
||||
$account_used = &$account_db;
|
||||
}
|
||||
else {
|
||||
$new_account = new OTS_Account();
|
||||
if(USE_ACCOUNT_NAME) {
|
||||
$new_account->create($account);
|
||||
}
|
||||
else {
|
||||
$new_account->create(null, $account_id);
|
||||
}
|
||||
|
||||
$new_account->setPassword(encrypt($password));
|
||||
$new_account->setEMail($_SESSION['var_mail_admin']);
|
||||
|
||||
$new_account->unblock();
|
||||
$new_account->save();
|
||||
|
||||
$new_account->setCustomField('created', time());
|
||||
$new_account->logAction('Account created.');
|
||||
|
||||
$account_used = &$new_account;
|
||||
}
|
||||
|
||||
if($config_salt_enabled)
|
||||
$account_used->setCustomField('salt', $salt);
|
||||
|
||||
$account_used->setCustomField('web_flags', FLAG_ADMIN + FLAG_SUPER_ADMIN);
|
||||
$account_used->setCustomField('country', 'us');
|
||||
if(fieldExist('group_id', 'accounts'))
|
||||
$account_used->setCustomField('group_id', $groups->getHighestId());
|
||||
if(fieldExist('type', 'accounts'))
|
||||
$account_used->setCustomField('type', 5);
|
||||
|
||||
if(!$player_db->isLoaded())
|
||||
$player->setAccountId($account_used->getId());
|
||||
else
|
||||
$player_db->setAccountId($account_used->getId());
|
||||
|
||||
success($locale['step_database_created_account']);
|
||||
|
||||
setSession('account', $account_used->getId());
|
||||
setSession('password', encrypt($password));
|
||||
setSession('remember_me', true);
|
||||
|
||||
if($player_db->isLoaded()) {
|
||||
$player_db->save();
|
||||
}
|
||||
else {
|
||||
$player->save();
|
||||
}
|
||||
|
||||
$player_id = 0;
|
||||
$query = $db->query("SELECT `id` FROM `players` WHERE `name` = " . $db->quote('Admin') . ";");
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$player_id = $query['id'];
|
||||
}
|
||||
|
||||
$query = $db->query("SELECT `id` FROM `" . TABLE_PREFIX ."news` WHERE `title` LIKE 'Hello!';");
|
||||
if($query->rowCount() == 0) {
|
||||
if(query("INSERT INTO `" . TABLE_PREFIX ."news` (`id`, `type`, `date`, `category`, `title`, `body`, `player_id`, `comments`, `hidden`) VALUES (NULL, '1', UNIX_TIMESTAMP(), '2', 'Hello!', 'MyAAC is just READY to use!', " . $player_id . ", 'http://my-aac.org', '0');
|
||||
INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `player_id`, `comments`, `hidden`) VALUES (NULL, '2', UNIX_TIMESTAMP(), '4', 'Hello tickets!', 'http://my-aac.org', " . $player_id . ", '', '0');")) {
|
||||
success($locale['step_database_created_news']);
|
||||
}
|
||||
}
|
||||
|
||||
$deleted = 'deleted';
|
||||
if(fieldExist('deletion', 'players'))
|
||||
$deleted = 'deletion';
|
||||
|
||||
$insert_into_players = "INSERT INTO `players` (`id`, `name`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `lastlogout`, `balance`, `$deleted`, `created`, `hidden`, `comment`) VALUES ";
|
||||
$success = true;
|
||||
|
||||
$highscores_ignored_ids = array();
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Rook Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Rook Sample', 1, " . getSession('account') . ", 1, 0, 150, 150, 4200, 118, 114, 38, 57, 130, 0, 0, 0, 0, 100, 1, 1000, 1000, 7, '', 400, 1, 1255179613, 2453925456, 1, 1255179614, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
else {
|
||||
$highscores_ignored_ids[] = $db->lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Sorcerer Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Sorcerer Sample', 1, " . getSession('account') . ", 8, 1, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 1, 1000, 1000, 7, '', 470, 1, 1255179571, 2453925456, 1, 1255179612, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
else {
|
||||
$highscores_ignored_ids[] = $db->lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Druid Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Druid Sample', 1, " . getSession('account') . ", 8, 2, 185, 185, 4200, 118, 114, 38, 57, 130, 0, 35, 35, 0, 100, 1, 1000, 1000, 7, '', 470, 1, 1255179655, 2453925456, 1, 1255179658, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
else {
|
||||
$highscores_ignored_ids[] = $db->lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Paladin Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Paladin Sample', 1, " . getSession('account') . ", 8, 3, 185, 185, 4200, 118, 114, 38, 57, 129, 0, 35, 35, 0, 100, 1, 1000, 1000, 7, '', 470, 1, 1255179854, 2453925456, 1, 1255179858, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
else {
|
||||
$highscores_ignored_ids[] = $db->lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Knight Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Knight Sample', 1, " . getSession('account') . ", 8, 4, 185, 185, 4200, 118, 114, 38, 57, 131, 0, 35, 35, 0, 100, 1, 1000, 1000, 7, '', 470, 1, 1255179620, 2453925456, 1, 1255179654, 0, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
else {
|
||||
$highscores_ignored_ids[] = $db->lastInsertId();
|
||||
}
|
||||
}
|
||||
|
||||
if($success) {
|
||||
success($locale['step_database_imported_players']);
|
||||
}
|
||||
|
||||
require(LIBS . 'creatures.php');
|
||||
if(Creatures::loadFromXML()) {
|
||||
success($locale['step_database_loaded_monsters']);
|
||||
|
||||
if(Creatures::getMonstersList()->hasErrors()) {
|
||||
$locale['step_database_error_monsters'] = str_replace('$LOG$', 'system/logs/error.log', $locale['step_database_error_monsters']);
|
||||
warning($locale['step_database_error_monsters']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
error(Creatures::getLastError());
|
||||
}
|
||||
|
||||
require(LIBS . 'spells.php');
|
||||
if(Spells::loadFromXML()) {
|
||||
success($locale['step_database_loaded_spells']);
|
||||
}
|
||||
else {
|
||||
error(Spells::getLastError());
|
||||
}
|
||||
|
||||
$content = PHP_EOL;
|
||||
$content .= '$config[\'highscores_ids_hidden\'] = array(' . implode(', ', $highscores_ignored_ids) . ');';
|
||||
$content .= PHP_EOL;
|
||||
|
||||
$file = fopen(BASE . 'config.local.php', 'a+');
|
||||
if($file) {
|
||||
fwrite($file, $content);
|
||||
}
|
||||
else {
|
||||
$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.local.php</b>', $locale['step_database_error_file']);
|
||||
warning($locale['step_database_error_file'] . '<br/>
|
||||
<textarea cols="70" rows="10">' . $content . '</textarea>');
|
||||
}
|
||||
|
||||
$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('$LINK$', generateLink('http://my-aac.org', 'http://my-aac.org', true), $locale['step_finish_desc']);
|
||||
|
||||
success($locale['step_finish_desc']);
|
||||
|
||||
if(!isset($_SESSION['installed'])) {
|
||||
file_get_contents('http://my-aac.org/report_install.php?v=' . MYAAC_VERSION . '&b=' . urlencode(BASE_URL));
|
||||
$_SESSION['installed'] = true;
|
||||
}
|
||||
|
||||
foreach($_SESSION as $key => $value) {
|
||||
if(strpos($key, 'var_') !== false)
|
||||
unset($_SESSION[$key]);
|
||||
}
|
||||
unset($_SESSION['saved']);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
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');
|
||||
if(!$error) {
|
||||
require(BASE . 'install/includes/database.php');
|
||||
|
||||
foreach(array(USE_ACCOUNT_NAME ? 'account' : 'account_id', 'password') as $value)
|
||||
echo '
|
||||
<tr>
|
||||
<td>
|
||||
<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>
|
@@ -1,115 +0,0 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$clients = array(
|
||||
710,
|
||||
740,
|
||||
750,
|
||||
760,
|
||||
770,
|
||||
780,
|
||||
7920,
|
||||
800,
|
||||
810,
|
||||
821,
|
||||
822,
|
||||
831,
|
||||
840,
|
||||
841,
|
||||
842,
|
||||
850,
|
||||
852,
|
||||
853,
|
||||
854,
|
||||
855,
|
||||
857,
|
||||
860,
|
||||
870,
|
||||
|
||||
900,
|
||||
910,
|
||||
920,
|
||||
930,
|
||||
940,
|
||||
942,
|
||||
944,
|
||||
946,
|
||||
950,
|
||||
952,
|
||||
953,
|
||||
954,
|
||||
960,
|
||||
970,
|
||||
980,
|
||||
|
||||
1000,
|
||||
1010,
|
||||
1021,
|
||||
1031,
|
||||
1034,
|
||||
1041,
|
||||
1050,
|
||||
1053,
|
||||
1054,
|
||||
1058,
|
||||
1075,
|
||||
1077,
|
||||
1079,
|
||||
1080,
|
||||
1090,
|
||||
1093,
|
||||
1094,
|
||||
1095,
|
||||
1096,
|
||||
1097,
|
||||
1098,
|
||||
);
|
||||
|
||||
?>
|
||||
<form action="<?php echo BASE_URL; ?>install/" method="post" autocomplete="off">
|
||||
<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);
|
||||
if(strpos($client_version, '.') == false)
|
||||
$client_version .= '.0';
|
||||
echo '<option value="' . $client . '">' . $client_version . '</option>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</td>
|
||||
<td>
|
||||
<em>' . $locale['step_config_client_desc'] . '</em>
|
||||
</td>
|
||||
</tr>';
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
echo next_buttons(true, true);
|
||||
?>
|
||||
</form>
|
@@ -1,199 +0,0 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['saved'])) {
|
||||
warning($locale['already_installed']);
|
||||
}
|
||||
else {
|
||||
require(SYSTEM . 'init.php');
|
||||
//require(BASE . 'install/includes/config.php');
|
||||
if(!$error) {
|
||||
//require(BASE . 'install/includes/database.php');
|
||||
|
||||
if(USE_ACCOUNT_NAME)
|
||||
$account = isset($_SESSION['var_account']) ? $_SESSION['var_account'] : NULL;
|
||||
else
|
||||
$account_id = isset($_SESSION['var_account_id']) ? $_SESSION['var_account_id'] : NULL;
|
||||
|
||||
$password = $_SESSION['var_password'];
|
||||
|
||||
$config_salt_enabled = fieldExist('salt', 'accounts');
|
||||
if($config_salt_enabled)
|
||||
{
|
||||
$salt = generateRandomString(10, false, true, true);
|
||||
$password = $salt . $password;
|
||||
}
|
||||
|
||||
$account_db = new OTS_Account();
|
||||
$account_db->load(1);
|
||||
if($account_db->isLoaded()) {
|
||||
if(USE_ACCOUNT_NAME)
|
||||
$account_db->setName('dummy_account');
|
||||
|
||||
$account_db->setPassword('for sample characters. ' . generateRandomString(10));
|
||||
$account_db->save();
|
||||
}
|
||||
else {
|
||||
$new_account = new OTS_Account();
|
||||
if(USE_ACCOUNT_NAME)
|
||||
$new_account->create('dummy_account', 1);
|
||||
else
|
||||
$new_account->create(NULL, 1);
|
||||
|
||||
$new_account->setPassword('for sample characters. ' . generateRandomString(10));
|
||||
$new_account->save();
|
||||
}
|
||||
|
||||
$account_db = new OTS_Account();
|
||||
if(isset($account))
|
||||
$account_db->find($account);
|
||||
else
|
||||
$account_db->load($account_id);
|
||||
|
||||
$player_db = new OTS_Player();
|
||||
$player_db->find('Admin');
|
||||
$groups = new OTS_Groups_List();
|
||||
if(!$player_db->isLoaded())
|
||||
{
|
||||
$player = new OTS_Player();
|
||||
$player->setName('Admin');
|
||||
|
||||
$player->setGroupId($groups->getHighestId());
|
||||
}
|
||||
|
||||
if($account_db->isLoaded()) {
|
||||
$account_db->setPassword(encrypt($password));
|
||||
$account_db->setEMail($_SESSION['var_mail_admin']);
|
||||
$account_db->save();
|
||||
|
||||
if($config_salt_enabled)
|
||||
$account_db->setCustomField('salt', $salt);
|
||||
|
||||
$account_db->setCustomField('web_flags', 3);
|
||||
$account_db->setCustomField('country', 'us');
|
||||
if(fieldExist('group_id', 'accounts'))
|
||||
$account_db->setCustomField('group_id', $groups->getHighestId());
|
||||
if(fieldExist('type', 'accounts'))
|
||||
$account_db->setCustomField('type', 5);
|
||||
|
||||
if(!$player_db->isLoaded())
|
||||
$player->setAccountId($account_db->getId());
|
||||
else
|
||||
$player_db->setAccountId($account_db->getId());
|
||||
|
||||
$_SESSION['account'] = $account_db->getId();
|
||||
}
|
||||
else {
|
||||
$new_account = new OTS_Account();
|
||||
$new_account->create($account);
|
||||
|
||||
$new_account->setPassword(encrypt($password));
|
||||
$new_account->setEMail($_SESSION['var_mail_admin']);
|
||||
|
||||
$new_account->unblock();
|
||||
$new_account->save();
|
||||
|
||||
if($config_salt_enabled)
|
||||
$new_account->setCustomField('salt', $salt);
|
||||
|
||||
$new_account->setCustomField('created', time());
|
||||
$new_account->setCustomField('web_flags', 3);
|
||||
$new_account->setCustomField('country', 'us');
|
||||
if(fieldExist('group_id', 'accounts'))
|
||||
$new_account->setCustomField('group_id', $groups->getHighestId());
|
||||
if(fieldExist('type', 'accounts'))
|
||||
$new_account->setCustomField('type', 5);
|
||||
|
||||
$new_account->logAction('Account created.');
|
||||
|
||||
if(!$player_db->isLoaded())
|
||||
$player->setAccountId($new_account->getId());
|
||||
else
|
||||
$player_db->setAccountId($new_account->getId());
|
||||
|
||||
$_SESSION['account'] = $new_account->getId();
|
||||
}
|
||||
|
||||
success($locale['step_database_created_account']);
|
||||
$_SESSION['password'] = encrypt($password);
|
||||
$_SESSION['remember_me'] = true;
|
||||
|
||||
if($player_db->isLoaded()) {
|
||||
$player_db->save();
|
||||
}
|
||||
else {
|
||||
$player->save();
|
||||
}
|
||||
|
||||
$player_id = 0;
|
||||
$query = $db->query("SELECT `id` FROM `players` WHERE `name` = " . $db->quote('Admin') . ";");
|
||||
if($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$player_id = $query['id'];
|
||||
}
|
||||
|
||||
if(query("INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `player_id`, `comments`, `hidden`) VALUES (NULL, '1', UNIX_TIMESTAMP(), '2', 'Hello!', 'MyAAC is just READY to use!', " . $player_id . ", 'http://my-aac.org', '0');
|
||||
INSERT INTO `myaac_news` (`id`, `type`, `date`, `category`, `title`, `body`, `player_id`, `comments`, `hidden`) VALUES (NULL, '2', UNIX_TIMESTAMP(), '4', 'Hello tickets!', 'http://my-aac.org', " . $player_id . ", '', '0');")) {
|
||||
success($locale['step_database_created_news']);
|
||||
}
|
||||
|
||||
$deleted = 'deleted';
|
||||
if(fieldExist('deletion', 'players'))
|
||||
$deleted = 'deletion';
|
||||
|
||||
$insert_into_players = "INSERT INTO `players` (`id`, `name`, `group_id`, `account_id`, `level`, `vocation`, `health`, `healthmax`, `experience`, `lookbody`, `lookfeet`, `lookhead`, `looklegs`, `looktype`, `maglevel`, `mana`, `manamax`, `manaspent`, `soul`, `town_id`, `posx`, `posy`, `posz`, `conditions`, `cap`, `sex`, `lastlogin`, `lastip`, `save`, `lastlogout`, `balance`, `$deleted`, `created`, `hidden`, `comment`) VALUES ";
|
||||
$success = true;
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Rook Sample'));
|
||||
if($query->rowCount() == 0) {
|
||||
if(!query($insert_into_players . "(null, 'Rook Sample', 1, 1, 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;
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Sorcerer Sample'));
|
||||
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, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Druid Sample'));
|
||||
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, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Paladin Sample'));
|
||||
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, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
$query = $db->query('SELECT `id` FROM `players` WHERE `name` = ' . $db->quote('Knight Sample'));
|
||||
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, 0, UNIX_TIMESTAMP(), 1, '');"))
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if($success) {
|
||||
success($locale['step_database_imported_players']);
|
||||
}
|
||||
|
||||
$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('$LINK$', generateLink('http://my-aac.org', 'http://my-aac.org', true), $locale['step_finish_desc']);
|
||||
|
||||
success($locale['step_finish_desc']);
|
||||
|
||||
if(!isset($_SESSION['installed'])) {
|
||||
file_get_contents('http://my-aac.org/report_install.php?v=' . MYAAC_VERSION . '&b=' . urlencode(BASE_URL));
|
||||
$_SESSION['installed'] = true;
|
||||
}
|
||||
|
||||
foreach($_SESSION as $key => $value) {
|
||||
if(strpos($key, 'var_') !== false)
|
||||
unset($_SESSION[$key]);
|
||||
}
|
||||
unset($_SESSION['saved']);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
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();
|
||||
?>
|
||||
</form>
|
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['saved'])) {
|
||||
echo '<p class="warning">' . $locale['already_installed'] . '</p>';
|
||||
}
|
||||
else {
|
||||
unset($_SESSION['saved']);
|
||||
?>
|
||||
<form action="<?php echo BASE_URL; ?>install/" method="post">
|
||||
<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)
|
||||
{
|
||||
$lang_file_main = LOCALE . $tmp_locale . '/main.php';
|
||||
$lang_file_install = LOCALE . $tmp_locale . '/install.php';
|
||||
if(@file_exists($lang_file_main)
|
||||
&& @file_exists($lang_file_install))
|
||||
{
|
||||
require($lang_file_main);
|
||||
echo '<option value="' . $tmp_locale . '">' . $locale['name'] . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<?php echo next_buttons(false, true); ?>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
@@ -1,11 +1,20 @@
|
||||
{
|
||||
"name": "Example Plugin",
|
||||
"description": "This is just an example of a Plugin for MyAAC.",
|
||||
"version": "1.0",
|
||||
"author": "nobody",
|
||||
"contact": "nobody@example.org",
|
||||
"install": "plugins/example/install.php",
|
||||
"hooks": {
|
||||
"name": "Example Plugin",
|
||||
"description": "This is just an example of a Plugin for MyAAC.",
|
||||
"version": "1.0",
|
||||
"author": "nobody",
|
||||
"contact": "nobody@example.org",
|
||||
"require": {
|
||||
"myaac": "0.4.3",
|
||||
"php": "5.2.0"
|
||||
},
|
||||
"install": "plugins/example/install.php",
|
||||
"uninstall": [
|
||||
"plugins/example.json",
|
||||
"plugins/example/install.php",
|
||||
"plugins/example/before.php"
|
||||
],
|
||||
"hooks": {
|
||||
"Example Hook": {
|
||||
"type": "BEFORE_PAGE",
|
||||
"file": "plugins/example/before.php"
|
||||
|
39
system/bin/install_plugin.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
if(php_sapi_name() != "cli") {
|
||||
die('This script can be run only in command line mode.');
|
||||
}
|
||||
|
||||
require_once('../../common.php');
|
||||
require_once(SYSTEM . 'functions.php');
|
||||
require_once(SYSTEM . 'init.php');
|
||||
require_once(SYSTEM . 'hooks.php');
|
||||
require_once(LIBS . 'plugins.php');
|
||||
|
||||
if($argc != 2) {
|
||||
exit('This command expects one parameter: zip file name (plugin)' . PHP_EOL);
|
||||
}
|
||||
|
||||
$path_to_file = $argv[1];
|
||||
$ext = strtolower(pathinfo($path_to_file, PATHINFO_EXTENSION));
|
||||
if($ext != 'zip') {// check if it is zipped/compressed file
|
||||
exit('Please install only .zip files.' . PHP_EOL);
|
||||
}
|
||||
|
||||
if(!file_exists($path_to_file)) {
|
||||
exit('ERROR: File ' . $path_to_file . ' does not exist' . PHP_EOL);
|
||||
}
|
||||
|
||||
if(Plugins::install($path_to_file)) {
|
||||
foreach(Plugins::getWarnings() as $warning) {
|
||||
echo 'WARNING: ' . $warning;
|
||||
}
|
||||
|
||||
$info = Plugins::getPluginInfo();
|
||||
echo (isset($info['name']) ? $info['name'] . ' p' : 'P') . 'lugin has been successfully installed.';
|
||||
}
|
||||
else
|
||||
echo 'ERROR: ' . Plugins::getError();
|
||||
|
||||
echo PHP_EOL;
|
||||
?>
|
63
system/compat.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Deprecated functions (compat)
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
function check_name($name, &$errors = '') {
|
||||
if(Validator::characterName($name))
|
||||
return true;
|
||||
|
||||
$errors = Validator::getLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_account_id($id, &$errors = '') {
|
||||
if(Validator::accountId($id))
|
||||
return true;
|
||||
|
||||
$errors = Validator::getLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_account_name($name, &$errors = '') {
|
||||
if(Validator::accountName($name))
|
||||
return true;
|
||||
|
||||
$errors = Validator::getLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_name_new_char($name, &$errors = '') {
|
||||
if(Validator::newCharacterName($name))
|
||||
return true;
|
||||
|
||||
$errors = Validator::getLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_rank_name($name, &$errors = '') {
|
||||
if(Validator::rankName($name))
|
||||
return true;
|
||||
|
||||
$errors = Validator::getLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_guild_name($name, &$errors = '') {
|
||||
if(Validator::guildName($name))
|
||||
return true;
|
||||
|
||||
$errors = Validator::getLastError();
|
||||
return false;
|
||||
}
|
||||
|
||||
function news_place() {
|
||||
return tickers();
|
||||
}
|
||||
?>
|
@@ -5,7 +5,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -15,19 +14,20 @@ $views_counter = 1; // default value, must be here!
|
||||
if($cache->enabled())
|
||||
{
|
||||
$value = 0;
|
||||
if(!$cache->fetch('views_counter', $value))
|
||||
if(!$cache->fetch('views_counter', $value) || $value <= 1)
|
||||
{
|
||||
$value = 0;
|
||||
if(fetchDatabaseConfig('views_counter', $value))
|
||||
$views_counter = $value;
|
||||
else
|
||||
registerDatabaseConfig('views_counter', 1); // save in the database
|
||||
registerDatabaseConfig('views_counter', 2); // save in the database
|
||||
}
|
||||
else
|
||||
else {
|
||||
$views_counter = $value;
|
||||
}
|
||||
|
||||
$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);
|
||||
/*
|
||||
{
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -1,4 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Database connection
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
if(!isset($config['database_type'][0]) || !isset($config['database_user'][0]) || !isset($config['database_password'][0]) || !isset($config['database_name'][0]))
|
||||
|
@@ -5,27 +5,29 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
function success($message, $return = false) {
|
||||
|
||||
function message($message, $type, $return)
|
||||
{
|
||||
if($return)
|
||||
return '<p class="success">' . $message . '</p>';
|
||||
return '<p class="' . $type . '">' . $message . '</p>';
|
||||
|
||||
echo '<p class="success">' . $message . '</p>';
|
||||
echo '<p class="' . $type . '">' . $message . '</p>';
|
||||
return true;
|
||||
}
|
||||
function success($message, $return = false) {
|
||||
return message($message, 'success', $return);
|
||||
}
|
||||
function warning($message, $return = false) {
|
||||
if($return)
|
||||
return '<p class="warning">' . $message . '</p>';
|
||||
|
||||
echo '<p class="warning">' . $message . '</p>';
|
||||
return message($message, 'warning', $return);
|
||||
}
|
||||
function note($message, $return = false) {
|
||||
return message($message, 'note', $return);
|
||||
}
|
||||
function error($message, $return = false) {
|
||||
if($return)
|
||||
return '<p class="error">' . $message . '</p>';
|
||||
|
||||
echo '<p class="error">' . $message . '</p>';
|
||||
return message($message, 'error', $return);
|
||||
}
|
||||
|
||||
function longToIp($ip)
|
||||
@@ -38,46 +40,27 @@ function generateLink($url, $name, $blank = false) {
|
||||
return '<a href="' . $url . '"' . ($blank ? ' target="_blank"' : '') . '>' . $name . '</a>';
|
||||
}
|
||||
|
||||
function getLink($page, $name, $blank = false) {
|
||||
return generateLink(getPageLink($page), $name, $blank);
|
||||
function getFullLink($page, $name, $blank = false) {
|
||||
return generateLink(getLink($page), $name, $blank);
|
||||
}
|
||||
|
||||
function getPageLink($page, $action = null)
|
||||
function getLink($page, $action = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
// 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 : '');
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : '?') . $page . ($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)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$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;
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
|
||||
}
|
||||
|
||||
function getForumBoardLink($board_id, $page = NULL)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$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;
|
||||
return BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
|
||||
}
|
||||
|
||||
function getPlayerLink($name, $generate = true)
|
||||
@@ -91,12 +74,8 @@ function getPlayerLink($name, $generate = true)
|
||||
if($player->isLoaded())
|
||||
$name = $player->getName();
|
||||
}
|
||||
|
||||
$url = '';
|
||||
if($config['friendly_urls'])
|
||||
$url = BASE_URL . 'characters/' . urlencode($name);
|
||||
else
|
||||
$url = BASE_URL . '?subtopic=characters&name=' . urlencode($name);
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'characters/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
@@ -115,13 +94,9 @@ function getHouseLink($name, $generate = true)
|
||||
if($house->rowCount() > 0)
|
||||
$name = $house->fetchColumn();
|
||||
}
|
||||
|
||||
$url = '';
|
||||
if($config['friendly_urls'])
|
||||
$url = BASE_URL . 'houses/' . urlencode($name);
|
||||
else
|
||||
$url = BASE_URL . '?subtopic=houses&page=view&house=' . urlencode($name);
|
||||
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'houses/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
@@ -138,24 +113,38 @@ function getGuildLink($name, $generate = true)
|
||||
$name = $guild->fetchColumn();
|
||||
}
|
||||
|
||||
$url = '';
|
||||
if($config['friendly_urls'])
|
||||
$url = BASE_URL . 'guilds/' . urlencode($name);
|
||||
else
|
||||
$url = BASE_URL . '?subtopic=guilds&action=show&guild=' . urlencode($name);
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'guilds/' . urlencode($name);
|
||||
|
||||
if(!$generate) return $url;
|
||||
return generateLink($url, $name);
|
||||
}
|
||||
|
||||
function getItemNameById($id) {
|
||||
global $db;
|
||||
$query = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'items` WHERE `id` = ' . $db->quote($id) . ' LIMIT 1;');
|
||||
if($query->rowCount() == 1) {
|
||||
$item = $query->fetch();
|
||||
return $item['name'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getItemImage($id, $count = 1)
|
||||
{
|
||||
$tooltip = '';
|
||||
|
||||
$name = getItemNameById($id);
|
||||
if(!empty($name)) {
|
||||
$tooltip = ' class="tooltip" title="' . $name . '"';
|
||||
}
|
||||
|
||||
$file_name = $id;
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
global $config;
|
||||
return '<img src="' . $config['item_images_url'] . $file_name . '.gif" width="32" height="32" border="0" alt=" ' .$id . '" />';
|
||||
return '<img src="' . $config['item_images_url'] . $file_name . '.gif"' . $tooltip . ' width="32" height="32" border="0" alt=" ' .$id . '" />';
|
||||
}
|
||||
|
||||
function getFlagImage($country)
|
||||
@@ -228,7 +217,7 @@ function generateRandomString($length, $lowCase = true, $upCase = false, $numeri
|
||||
function getForumBoards()
|
||||
{
|
||||
global $db, $canEdit;
|
||||
$sections = $db->query('SELECT `id`, `name`, `description`, `closed`' . ($canEdit ? ', `hidden`, `ordering`' : '') . ' FROM `' . TABLE_PREFIX . 'forum_boards` ' . (!$canEdit ? ' WHERE `hidden` != 1' : '') .
|
||||
$sections = $db->query('SELECT `id`, `name`, `description`, `closed`, `guild`, `access`' . ($canEdit ? ', `hidden`, `ordering`' : '') . ' FROM `' . TABLE_PREFIX . 'forum_boards` ' . (!$canEdit ? ' WHERE `hidden` != 1' : '') .
|
||||
' ORDER BY `ordering`;');
|
||||
if($sections)
|
||||
return $sections->fetchAll();
|
||||
@@ -263,7 +252,7 @@ function fetchDatabaseConfig($name, &$value)
|
||||
*/
|
||||
function getDatabaseConfig($name)
|
||||
{
|
||||
$value = NULL;
|
||||
$value = null;
|
||||
fetchDatabaseConfig($name, $value);
|
||||
return $value;
|
||||
}
|
||||
@@ -414,294 +403,6 @@ function delete_guild($id)
|
||||
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 ']/", $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 = 'Character 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 `name` FROM `' . TABLE_PREFIX . 'monsters` WHERE `name` LIKE ' . $db->quote($name_lower));
|
||||
if($monsters->rowCount() > 0) {
|
||||
$error = 'Your name cannot contains monster name.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$spells_name = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'spells` WHERE `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 `words` FROM `' . TABLE_PREFIX . 'spells` WHERE `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 #####################
|
||||
//return shorter text (news ticker)
|
||||
function short_text($text, $limit)
|
||||
@@ -712,42 +413,16 @@ function short_text($text, $limit)
|
||||
return $text;
|
||||
}
|
||||
|
||||
function news_place()
|
||||
function tickers()
|
||||
{
|
||||
global $template_path, $news_content;
|
||||
|
||||
$news = '';
|
||||
if(PAGE == 'news')
|
||||
{
|
||||
//add tickers to site - without it tickers will not be showed
|
||||
if(isset($news_content))
|
||||
$news .= $news_content;
|
||||
|
||||
//featured article
|
||||
/* $news .= ' <div id="featuredarticle" class="Box">
|
||||
<div class="Corner-tl" style="background-image:url('.$template_path.'/images/content/corner-tl.gif);"></div>
|
||||
<div class="Corner-tr" style="background-image:url('.$template_path.'/images/content/corner-tr.gif);"></div>
|
||||
<div class="Border_1" style="background-image:url('.$template_path.'/images/content/border-1.gif);"></div>
|
||||
<div class="BorderTitleText" style="background-image:url('.$template_path.'/images/content/title-background-green.gif);"></div>
|
||||
<img class="Title" src="'.$template_path.'/images/strings/headline-featuredarticle.gif" alt="Contentbox headline" />
|
||||
<div class="Border_2">
|
||||
<div class="Border_3">
|
||||
<div class="BoxContent" style="background-image:url('.$template_path.'/images/content/scroll.gif);">
|
||||
<div id=\'TeaserThumbnail\'><img src="'.$template_path.'/images/news/features.jpg" width=150 height=100 border=0 alt="" /></div><div id=\'TeaserText\'><div style="position: relative; top: -2px; margin-bottom: 2px;" >
|
||||
<b>Tutaj wpisz tytul</b></div>
|
||||
tutaj wpisz tresc newsa<br>
|
||||
zdjecie laduje sie w <i>tibiacom/images/news/features.jpg</i><br>
|
||||
skad sie laduje mozesz zmienic linijke ponad komentarzem
|
||||
</div> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="Border_1" style="background-image:url('.$template_path.'/images/content/border-1.gif);"></div>
|
||||
<div class="CornerWrapper-b"><div class="Corner-bl" style="background-image:url('.$template_path.'/images/content/corner-bl.gif);"></div></div>
|
||||
<div class="CornerWrapper-b"><div class="Corner-br" style="background-image:url('.$template_path.'/images/content/corner-br.gif);"></div></div>
|
||||
</div>';*/
|
||||
global $tickers_content, $featured_article;
|
||||
|
||||
if(PAGE == 'news') {
|
||||
if(isset($tickers_content))
|
||||
return $tickers_content . $featured_article;
|
||||
}
|
||||
|
||||
return $news;
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -786,8 +461,8 @@ function template_header($is_admin = false)
|
||||
<meta http-equiv="content-type" content="text/html; charset=' . $charset . '" />';
|
||||
if(!$is_admin)
|
||||
$ret .= '
|
||||
<title>' . $title_full . '</title>
|
||||
<base href="' . BASE_URL . '" />';
|
||||
<base href="' . BASE_URL . '" />
|
||||
<title>' . $title_full . '</title>';
|
||||
|
||||
$ret .= '
|
||||
<meta name="description" content="' . $config['meta_description'] . '" />
|
||||
@@ -995,7 +670,7 @@ function getSkillName($skillId, $suffix = true)
|
||||
*/
|
||||
function hasFlag($flag) {
|
||||
global $logged, $logged_flags;
|
||||
return $logged && ($logged_flags & $flag) == $flag;
|
||||
return ($logged && ($logged_flags & $flag) == $flag);
|
||||
}
|
||||
/**
|
||||
* Check if current logged user have got admin flag set.
|
||||
@@ -1088,6 +763,26 @@ function get_templates()
|
||||
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)
|
||||
{
|
||||
global $config;
|
||||
@@ -1175,7 +870,10 @@ function load_config_lua($filename)
|
||||
|
||||
$config_file = $filename;
|
||||
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');
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$config_string = file_get_contents($filename);
|
||||
@@ -1201,6 +899,10 @@ function load_config_lua($filename)
|
||||
if(substr($key, 0, 2) != '--')
|
||||
{
|
||||
$value = trim($tmp_exp[1]);
|
||||
if(strpos($value, '--') !== false) {// found some deep comment
|
||||
$value = preg_replace('/--.*$/i', '', $value);
|
||||
}
|
||||
|
||||
if(is_numeric($value))
|
||||
$result[$key] = (float) $value;
|
||||
elseif(in_array(substr($value, 0 , 1), array("'", '"')) && in_array(substr($value, -1 , 1), array("'", '"')))
|
||||
@@ -1226,4 +928,94 @@ function load_config_lua($filename)
|
||||
$result = array_merge($result, isset($config['lua']) ? $config['lua'] : array());
|
||||
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;
|
||||
}
|
||||
|
||||
function setSession($key, $data) {
|
||||
global $config;
|
||||
$_SESSION[$config['session_prefix'] . $key] = $data;
|
||||
}
|
||||
function getSession($key) {
|
||||
global $config;
|
||||
return (isset($_SESSION[$config['session_prefix'] . $key])) ? $_SESSION[$config['session_prefix'] . $key] : false;
|
||||
}
|
||||
function unsetSession($key) {
|
||||
global $config;
|
||||
unset($_SESSION[$config['session_prefix'] . $key]);
|
||||
}
|
||||
|
||||
function getTopPlayers($limit = 5) {
|
||||
global $cache, $config, $db;
|
||||
|
||||
$fetch_from_db = true;
|
||||
if($cache->enabled())
|
||||
{
|
||||
$tmp = '';
|
||||
if($cache->fetch('top_' . $limit . '_level', $tmp))
|
||||
{
|
||||
$players = unserialize($tmp);
|
||||
$fetch_from_db = false;
|
||||
}
|
||||
}
|
||||
|
||||
if($fetch_from_db)
|
||||
{
|
||||
$deleted = 'deleted';
|
||||
if(fieldExist('deletion', 'players'))
|
||||
$deleted = 'deletion';
|
||||
|
||||
$is_tfs10 = tableExist('players_online');
|
||||
$players = $db->query('SELECT `id`, `name`, `level`, `experience`' . ($is_tfs10 ? '' : ', `online`') . ' FROM `players` WHERE `group_id` < ' . $config['highscores_groups_hidden'] . ' AND `id` NOT IN (' . implode(', ', $config['highscores_ids_hidden']) . ') AND `' . $deleted . '` = 0 AND `account_id` != 1 ORDER BY `experience` DESC LIMIT ' . (int)$limit)->fetchAll();
|
||||
|
||||
if($is_tfs10) {
|
||||
foreach($players as &$player) {
|
||||
$query = $db->query('SELECT `player_id` FROM `players_online` WHERE `player_id` = ' . $player['id']);
|
||||
$player['online'] = ($query->rowCount() > 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
foreach($players as &$player) {
|
||||
$player['rank'] = ++$i;
|
||||
}
|
||||
|
||||
if($cache->enabled())
|
||||
$cache->set('top_' . $limit . '_level', serialize($players), 120);
|
||||
}
|
||||
|
||||
return $players;
|
||||
}
|
||||
|
||||
function deleteDirectory($dir) {
|
||||
if(!file_exists($dir)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!is_dir($dir)) {
|
||||
return unlink($dir);
|
||||
}
|
||||
|
||||
foreach(scandir($dir) as $item) {
|
||||
if($item == '.' || $item == '..') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return rmdir($dir);
|
||||
}
|
||||
|
||||
// validator functions
|
||||
require_once(LIBS . 'validator.php');
|
||||
require_once(SYSTEM . 'compat.php');
|
||||
?>
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -16,17 +15,14 @@ define('HOOK_AFTER_PAGE', 3);
|
||||
define('HOOK_FINISH', 4);
|
||||
define('HOOK_TIBIACOM_ARTICLE', 5);
|
||||
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_LAST', HOOK_TIBIACOM_BORDER_3);
|
||||
|
||||
$hook_types = array(
|
||||
'STARTUP' => HOOK_STARTUP,
|
||||
'BEFORE_PAGE' => HOOK_BEFORE_PAGE,
|
||||
'AFTER_PAGE' => HOOK_AFTER_PAGE,
|
||||
'FINISH' => HOOK_FINISH,
|
||||
'TIBIACOM_ARTICLE' => HOOK_TIBIACOM_ARTICLE,
|
||||
'TIBIACOM_BORDER_3' => HOOK_TIBIACOM_BORDER_3
|
||||
);
|
||||
define('HOOK_LAST', HOOK_CHARACTERS_AFTER_CHARACTERS);
|
||||
|
||||
class Hook
|
||||
{
|
||||
@@ -84,7 +80,7 @@ class Hooks
|
||||
public function load()
|
||||
{
|
||||
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)
|
||||
$this->register($hook['name'], $hook['type'], $hook['file']);
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
@@ -14,6 +13,10 @@ require_once(BASE . 'config.php');
|
||||
if(file_exists(BASE . 'config.local.php')) // user customizations
|
||||
require(BASE . 'config.local.php');
|
||||
|
||||
if(!isset($config['installed']) || !$config['installed']) {
|
||||
die('MyAAC 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
|
||||
if($config['server_path'][strlen($config['server_path']) - 1] != '/')
|
||||
@@ -28,7 +31,7 @@ require_once(SYSTEM . 'libs/cache.php');
|
||||
$cache = Cache::getInstance($config['cache_engine'], $config['cache_prefix']);
|
||||
|
||||
// twig
|
||||
require_once LIBS . 'Twig/Autoloader.php';
|
||||
require_once(LIBS . 'Twig/Autoloader.php');
|
||||
Twig_Autoloader::register();
|
||||
|
||||
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
|
||||
@@ -42,6 +45,22 @@ $function = new Twig_SimpleFunction('getStyle', function ($i) {
|
||||
});
|
||||
$twig->addFunction($function);
|
||||
|
||||
$function = new Twig_SimpleFunction('getLink', function ($s) {
|
||||
return getLink($s);
|
||||
});
|
||||
$twig->addFunction($function);
|
||||
|
||||
$function = new Twig_SimpleFunction('hook', function ($hook) {
|
||||
global $hooks;
|
||||
$hooks->trigger($hook);
|
||||
});
|
||||
$twig->addFunction($function);
|
||||
|
||||
$filter = new Twig_SimpleFilter('urlencode', function ($s) {
|
||||
return urlencode($s);
|
||||
});
|
||||
$twig->addFilter($filter);
|
||||
|
||||
// trim values we receive
|
||||
if(isset($_POST))
|
||||
{
|
||||
@@ -128,6 +147,11 @@ else
|
||||
$config['data_path'] = $tmp;
|
||||
unset($tmp);
|
||||
|
||||
// new config values for compability
|
||||
if(!isset($config['highscores_ids_hidden']) || count($config['highscores_ids_hidden']) == 0) {
|
||||
$config['highscores_ids_hidden'] = array(0);
|
||||
}
|
||||
|
||||
// POT
|
||||
require_once(SYSTEM . 'libs/pot/OTS.php');
|
||||
$ots = POT::getInstance();
|
||||
|
@@ -5,21 +5,20 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
require_once(SYSTEM . 'libs/items.php');
|
||||
require_once(SYSTEM . 'libs/items_images.php');
|
||||
|
||||
Items::$files = array(
|
||||
Items_Images::$files = array(
|
||||
'otb' => SYSTEM . 'data/items.otb',
|
||||
'spr' => SYSTEM . 'data/Tibia.spr',
|
||||
'dat' => SYSTEM . 'data/Tibia.dat'
|
||||
);
|
||||
Items::$outputDir = BASE . 'images/items/';
|
||||
Items_Images::$outputDir = BASE . 'images/items/';
|
||||
|
||||
function generateItem($id = 100, $count = 1) {
|
||||
Items::generate($id, $count);
|
||||
Items_Images::generate($id, $count);
|
||||
}
|
||||
|
||||
function itemImageExists($id, $count = 1)
|
||||
@@ -31,7 +30,7 @@ function itemImageExists($id, $count = 1)
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
$file_name = Items::$outputDir . $file_name . '.gif';
|
||||
$file_name = Items_Images::$outputDir . $file_name . '.gif';
|
||||
return file_exists($file_name);
|
||||
}
|
||||
|
||||
@@ -43,7 +42,7 @@ function outputItem($id = 100, $count = 1)
|
||||
if(!itemImageExists($id, $count))
|
||||
{
|
||||
//echo 'plik istnieje';
|
||||
Items::generate($id, $count);
|
||||
Items_Images::generate($id, $count);
|
||||
}
|
||||
|
||||
$expires = 60 * 60 * 24 * 30; // 30 days
|
||||
@@ -56,7 +55,7 @@ function outputItem($id = 100, $count = 1)
|
||||
if($count > 1)
|
||||
$file_name .= '-' . $count;
|
||||
|
||||
$file_name = Items::$outputDir . $file_name . '.gif';
|
||||
$file_name = Items_Images::$outputDir . $file_name . '.gif';
|
||||
readfile($file_name);
|
||||
}
|
||||
?>
|
||||
|
@@ -6,7 +6,6 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Mark Samman (Talaturen) <marksamman@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,6 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Mark Samman (Talaturen) <marksamman@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,6 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Mark Samman (Talaturen) <marksamman@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -5,7 +5,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -6,7 +6,6 @@
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @author Mark Samman (Talaturen) <marksamman@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
135
system/libs/creatures.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Creatures class
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Gesior <jerzyskalski@wp.pl>
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Creatures {
|
||||
private static $monstersList = null;
|
||||
private static $lastError = '';
|
||||
|
||||
public static function loadFromXML($show = false) {
|
||||
global $config, $db;
|
||||
|
||||
try { $db->query("DELETE FROM `myaac_monsters`;"); } catch(PDOException $error) {}
|
||||
|
||||
if($show) {
|
||||
echo '<h2>Reload monsters.</h2>';
|
||||
echo "<h2>All records deleted from table 'myaac_monsters' in database.</h2>";
|
||||
}
|
||||
|
||||
try {
|
||||
self::$monstersList = new OTS_MonstersList($config['data_path'].'monster/');
|
||||
}
|
||||
catch(Exception $e) {
|
||||
self::$lastError = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
$items = array();
|
||||
$items_db = $db->query('SELECT `id`, `name` FROM `' . TABLE_PREFIX . 'items`;');
|
||||
foreach($items_db->fetchAll() as $item) {
|
||||
$items[$item['name']] = $item['id'];
|
||||
}
|
||||
|
||||
//$names_added must be an array
|
||||
$names_added[] = '';
|
||||
//add monsters
|
||||
foreach(self::$monstersList as $lol) {
|
||||
$monster = self::$monstersList->current();
|
||||
if(!$monster->loaded()) {
|
||||
if($show) {
|
||||
warning('Error while adding monster: ' . self::$monstersList->currentFile());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//load monster mana needed to summon/convince
|
||||
$mana = $monster->getManaCost();
|
||||
|
||||
//load monster name
|
||||
$name = $monster->getName();
|
||||
//load monster health
|
||||
$health = $monster->getHealth();
|
||||
//load monster speed and calculate "speed level"
|
||||
$speed_ini = $monster->getSpeed();
|
||||
if($speed_ini <= 220) {
|
||||
$speed_lvl = 1;
|
||||
} else {
|
||||
$speed_lvl = ($speed_ini - 220) / 2;
|
||||
}
|
||||
//check "is monster use haste spell"
|
||||
$defenses = $monster->getDefenses();
|
||||
$use_haste = 0;
|
||||
foreach($defenses as $defense) {
|
||||
if($defense == 'speed') {
|
||||
$use_haste = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//load race
|
||||
$race = $monster->getRace();
|
||||
|
||||
//load monster flags
|
||||
$flags = $monster->getFlags();
|
||||
if(!isset($flags['summonable']))
|
||||
$flags['summonable'] = '0';
|
||||
if(!isset($flags['convinceable']))
|
||||
$flags['convinceable'] = '0';
|
||||
|
||||
$loot = $monster->getLoot();
|
||||
foreach($loot as &$item) {
|
||||
if(!Validator::number($item['id'])) {
|
||||
if(isset($items[$item['id']])) {
|
||||
$item['id'] = $items[$item['id']];
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!in_array($name, $names_added)) {
|
||||
try {
|
||||
$db->insert(TABLE_PREFIX . 'monsters', array(
|
||||
'name' => $name,
|
||||
'mana' => empty($mana) ? 0 : $mana,
|
||||
'exp' => $monster->getExperience(),
|
||||
'health' => $health,
|
||||
'speed_lvl' => $speed_lvl,
|
||||
'use_haste' => $use_haste,
|
||||
'voices' => json_encode($monster->getVoices()),
|
||||
'immunities' => json_encode($monster->getImmunities()),
|
||||
'summonable' => $flags['summonable'] > 0 ? 1 : 0,
|
||||
'convinceable' => $flags['convinceable'] > 0 ? 1 : 0,
|
||||
'race' => $race,
|
||||
'loot' => json_encode($loot)
|
||||
));
|
||||
|
||||
if($show) {
|
||||
success('Added: ' . $name . '<br/>');
|
||||
}
|
||||
}
|
||||
catch(PDOException $error) {
|
||||
if($show) {
|
||||
warning('Error while adding monster (' . $name . '): ' . $error->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$names_added[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getMonstersList() {
|
||||
return self::$monstersList;
|
||||
}
|
||||
|
||||
public static function getLastError() {
|
||||
return self::$lastError;
|
||||
}
|
||||
}
|
@@ -5,7 +5,6 @@
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2017 MyAAC
|
||||
* @version 0.4.3
|
||||
* @link http://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
@@ -1 +0,0 @@
|
||||
deny from all
|
@@ -1,508 +0,0 @@
|
||||
[2010-02-07] 1.1.1
|
||||
+ Added {optional} plugin that just prints an optional var without any
|
||||
notice if it doesn't exist
|
||||
+ Added Dwoo::setTemplate() for testing purposes mostly
|
||||
* Fixed an {extends} parsing bug that prevented the use of single-quotes
|
||||
around the parent template's filename
|
||||
* Fixed a security issue, if you didn't use a custom compiler factory but
|
||||
passed the compiler directly to the get method with autoEscape enabled,
|
||||
the autoEscape was disabled in included templates - Thanks to Fabien
|
||||
Potencier for notifying me.
|
||||
* Fixed a bug in {safe} when using variable-variables it would sometimes
|
||||
corrupt the var name resulting in blank output
|
||||
* Fixed a bug when accessing array indices that contain a minus sign, it
|
||||
is now possible to access those using {$var[index-foo]},
|
||||
{$var['index-foo']} or {$index="index-foo"} {$var[$index]}
|
||||
* Fixed a bug in {tif} that didn't work when 0 was given as the true or
|
||||
false value
|
||||
* Fixed a bug when using the autoEscape feature with sub-templates (the
|
||||
compiled sub-template couldn't access the dwoo charset property,
|
||||
resulting in a fatal error)
|
||||
* Fixed a property reading bug on objects that implemented __get but not
|
||||
__isset, implementing __isset is however very much recommended
|
||||
* Fixed a Dwoo_Data bug in the append method when the index didn't exist
|
||||
yet it threw a notice
|
||||
* Fixed a bug when accessing global vars from a sub-template
|
||||
* Fixed a couple bugs in the {dynamic} plugin with regard to using plugins
|
||||
within a dynamic block
|
||||
* Fixed a compilation bug when using a PluginProxy with highly nested calls
|
||||
* Fixed a {load_templates} bug, plugins used in external templates were not
|
||||
loaded correctly, same for custom user plugins
|
||||
* Cached templates now check the source template for modification before
|
||||
outputting the cached version
|
||||
* Removed a couple of @-operator calls to file_get_contents
|
||||
|
||||
[2009-07-18] 1.1.0
|
||||
! BC Break: Dwoo::initGlobals() is only called once during the Dwoo object
|
||||
construction. If you had overriden it and need to update global data
|
||||
before each template is executed you should instead override
|
||||
Dwoo::initRuntimeVars() and push stuff in the globals array there. Also
|
||||
be aware that this means captured data, foreach values and so-on will
|
||||
persist from a parent template to an included one (but the include's
|
||||
changes will not be reflected on the parent), and from a template
|
||||
to the next if you render several in series.
|
||||
+ Added {template} plugin that allows you to define sub-templates and then
|
||||
call them (works recursively too, good for menus and lists)
|
||||
+ Added {load_templates} to load external sub-templates into your file
|
||||
+ Allowed string concatenation assignments with {$foo.="bar"}
|
||||
+ Allowed access of static properties as {Foo::$bar}
|
||||
+ Plugins/Helpers that use a dynamic number of arguments through
|
||||
func_get_args are now working since the compiler lets any arguments in
|
||||
excess pass through
|
||||
+ Adapters: CodeIgniter: the adapter by Stefan Verstege has been added to
|
||||
core and he will be its maintainer from now on
|
||||
+ Adapters: CakePHP: this adapter is now added to core and is designed to
|
||||
work with CakePHP 1.2
|
||||
* Adapters: Zend: Denis Arh is now appointed maintainer of that part and
|
||||
fixed a few things since 1.0.1
|
||||
* The include_path isn't altered anymore, hopefully saving some stat calls
|
||||
* User classes extending Dwoo_Template_File are now supported better with
|
||||
regard to includes - Thanks to the Kayako.com team for the patch
|
||||
* Objects now act like arrays when you access non-existing properties on
|
||||
them (i.e. it outputs a notice only if it's output straight, and none
|
||||
when passed to a function)
|
||||
* For can now iterate backwards if you input numbers, it won't work with
|
||||
variables though
|
||||
* Slight performance improvement with big inheritance trees
|
||||
* No more double-slashes in template paths since this seemed to cause
|
||||
slight performance issues
|
||||
* Fixed a bug with parsing AND/OR keywords in conditionals when they were
|
||||
followed by round brackets
|
||||
* Fixed assignments not handling multi-line values correctly
|
||||
* Fixed parameter parsing issue when a plugin name was all uppercased
|
||||
* Fixed assignments failing with autoEscape enabled
|
||||
* Fixed parsing of vars with string keys that was too greedy
|
||||
* Fixed an optimization causing foreach/for/loop variables not being
|
||||
accessible when the foreach/.. name was set dynamically
|
||||
* Fixed parsing of comments that were on top of the file when there are
|
||||
spaces at the end of it
|
||||
* Dwoo_Template::$chmod is now enforced for directories as well (#18)
|
||||
* Many new unit tests to improve code coverage and a bunch of bug fixes
|
||||
that resulted, but I didn't really keep track of them
|
||||
|
||||
[2008-12-24] 1.0.1
|
||||
* Direct assignments like {$foo = 5} now allow spaces around the operator
|
||||
* Fixed a {foreach} bug with the implode argument
|
||||
* Fixed modulo operator in if statements
|
||||
* Fixed date_format handling of negative and small unix timestamps
|
||||
* Fixed a weird reference bug with ZF and includes.. whatever but thanks
|
||||
to Denis Arh for the patch
|
||||
|
||||
[2008-10-23] 1.0.0
|
||||
! BC Break: Small one that probably won't affect anyone, but it makes the
|
||||
PluginProxy feature much stronger. Basically if you used a custom one you
|
||||
will get a fatal error and need to update it to conform to the new
|
||||
IPluginProxy interface, that's it
|
||||
+ Compiler: the modifier syntax (|foo) can now be applied on functions and on
|
||||
complex variables i.e. {$obj->getStuff()|upper} or {lower('foo')|upper}
|
||||
+ SmartyCompat: Added a {section} plugin but I strongly discourage using it,
|
||||
it was really made to support legacy templates, since {for} doesn't have to
|
||||
handle {section}-BC anymore, it has been cleaned up a lot and the last
|
||||
$skip parameter has been dropped
|
||||
* The core Dwoo class doesn't need writable compile/cache dirs in the
|
||||
constructor anymore so you can provide custom ones later through
|
||||
->setCompile(/Cache)Dir - thanks to Denis Arh for the patch
|
||||
* Adapters: Zend: major overhaul thanks to Denis Arh, templates files should
|
||||
probably be moved in the scripts subfolder after this update though, and
|
||||
the settings array has changed a bit, you will get warnings if you don't
|
||||
update the code anyway
|
||||
* Plugins: improved the dump plugin, it now displays object's properties
|
||||
and optionally public methods (if the new show_methods arg is set to true)
|
||||
- thanks to Stephan Wentz for the patch
|
||||
* Adapters: Zend: Added parameters to provide a custom engine (extends Dwoo)
|
||||
or a custom data class (extends Dwoo_Data) - thanks to Maxime Merian for
|
||||
the patch
|
||||
* Compiler: added Dwoo_Compiler->setNestedCommentsHandling(true) to enable
|
||||
parsing of nested comments (i.e. {* {* *} *} becomes a valid comment, useful
|
||||
to comment out big chunks of code containing comments)
|
||||
* Lines containing only comments and whitespace are now entirely removed
|
||||
* Removed comments do not mess up the line count anymore (for error messages)
|
||||
* Fixed parsing bug in {func()->propertyOfReturnedObject}
|
||||
* Fixed file template class reading from the string compiler factory - thanks
|
||||
to MrOxiMoron for the patch
|
||||
* Fixed handling of variable variables that contained non standard characters
|
||||
* Fixed a 1.0.0beta regression that messed with custom plugin directories
|
||||
on Windows
|
||||
* SmartyCompat: Fixed a few bugs in the adapter and processor - thanks to
|
||||
Stefan Moonen for the patches
|
||||
|
||||
[2008-09-08] 1.0.0beta
|
||||
! Important note : Dwoo.php should not be included directly anymore, please
|
||||
read the UPGRADE_NOTES file for more infos on the matter, if you don't
|
||||
your Dwoo install will most likely break after the update anyway
|
||||
! BC Break: {include} and {extends} now support the include path properly,
|
||||
which means that if you include "foo/bar.html" from _any_ template and you
|
||||
have an include path set on your template object, it will look in all those
|
||||
paths for foo/bar.html. If you use relative paths, for example
|
||||
if you include "../foo/bar.html" AND have an include path set, you will now
|
||||
have a problem, because you can't mix both approaches, otherwise you should
|
||||
be fine, so to fix this you should convert your relative includes/extends
|
||||
+ Adapters: Added the Agavi interface for Dwoo
|
||||
(see /Dwoo/Adapters/Agavi/README)
|
||||
+ API: Added Dwoo_Compilation_Exception methods getCompiler() and
|
||||
getTemplate() so you can catch the exception and use those to build a nicer
|
||||
error view with all the details you want
|
||||
+ Plugins: Added a mode parameter to {strip} to allow stripping of javascript
|
||||
code blocks that use "// comments", because without this special mode the
|
||||
comments result in syntax errors
|
||||
* The Compiler now ensures that a template starting with <?xml will not
|
||||
conflict with php using the short_open_tag=On setting
|
||||
* Complex arrays keys can be read using {$var["Long|Key*With.some)Crap"]},
|
||||
however since it is really bad practice I won't spend time fixing edge
|
||||
cases, which are $ and '/" characters inside the string. Those will break
|
||||
it and that's it.. if you really care feel free to send a patch
|
||||
* Dwoo->get() is now stricter as to what it accepts as a "template", only
|
||||
Dwoo_ITemplate objects or valid filenames are accepted
|
||||
* Foreach and other similar plugins that support "else" now only count()
|
||||
their input before processing when an else block follows
|
||||
* Various optimizations
|
||||
* Fixed compiler bug that created a parse error when you had comments in an
|
||||
extended template
|
||||
* Fixed extends bug when extending files in other directories using relative
|
||||
paths
|
||||
* Fixed parsing bug with "|modifier:param|modifier2} with:colon after it"
|
||||
* Bug fixed with smarty functions called with no parameters (in compat mode)
|
||||
* Fixed Dwoo::isArray() check, objects implementing ArrayAccess are now
|
||||
valid (thanks to Daniel Cousineau for the patch)
|
||||
* Fixed compiler warning when doing {func()->method()} or {func()->property}
|
||||
* Fixed compiled/cached files being written in the wrong place when the path
|
||||
to the template contains "../"s
|
||||
* Fixed {if} failing with conditions using upper case operators (i.e. AND)
|
||||
|
||||
[2008-08-03] 0.9.3
|
||||
+ Adapters: Added the ZendFramework interface for Dwoo
|
||||
(see /Dwoo/Adapters/ZendFramework/README)
|
||||
+ Plugins: Added the {a} block plugin to generate <a> tags
|
||||
+ Syntax: Added the ";" token that allows to group multiple instructions in one
|
||||
single template tag, example: {if $foo; "> $foo";$bar;/} is equal to:
|
||||
{if $foo}> {$foo}{$bar}{/} - This also allow block operations such as:
|
||||
{a http://url.com; "Text" /} which equals to {a http://url.com}Text{/}
|
||||
+ Syntax: Block plugins that you want to call without content can be
|
||||
self-closed just like XML tags (e.g. {a "http://url.com" /} ). Be careful not
|
||||
to close a non-block plugin like that however, since it will close it's
|
||||
parent block
|
||||
+ Syntax: Static methods can be called using {Class::method()}
|
||||
+ Syntax: It is now possible to use a plugin's result as an object and call
|
||||
a method or read a property from it, i.e. {fetchObject()->doStuff()}
|
||||
+ API: Added Dwoo_Plugin::paramsToAttributes() utility function to help
|
||||
with the creation of compilable xml/html-related plugins
|
||||
+ API: Added Dwoo->setPluginProxy() and Dwoo_IPluginProxy that allow you to
|
||||
hook into the compiler's plugin subsystem to provide your own plugin calls.
|
||||
Thanks to Denis Arh for the patch
|
||||
=> http://forum.dwoo.org/viewtopic.php?id=70
|
||||
+ API: Dwoo->addPlugin() has a third parameter to mark a plugin as compilable
|
||||
+ Compiler supports method calls into a method call's parameters
|
||||
* Dwoo_Compiler::implode_r is now public/static so it can be used in other
|
||||
places such as plugin proxies
|
||||
* Syntax: Math expressions in strings are now only allowed when the entire
|
||||
expression is delimited, e.g. {"/$foo/$bar"} evaluates as just that while
|
||||
{"/`$foo/$bar`"} will result in "/".($foo/$bar), therefore processing the /
|
||||
as a division, this is better since URLs using / are far more common than
|
||||
math in strings
|
||||
=> http://forum.dwoo.org/viewtopic.php?id=50
|
||||
* Compiler now allows the use of the right delimiter inside strings (e.g. {"}"})
|
||||
* Fixed a bug preventing if blocks containing a {elseif} followed by {else}
|
||||
* Fixed the Dwoo_ILoader interface and implemented it in Dwoo_Loader now
|
||||
=> http://forum.dwoo.org/viewtopic.php?id=70
|
||||
* Fixed a compileId auto-generation creating conflicts
|
||||
* Include allows paths going in upper levels now such as : "../foo.html"
|
||||
* Some compiler fixes regarding custom plugins
|
||||
|
||||
[2008-06-28] 0.9.2
|
||||
! BC Break: Renamed the {strip} modifier/function to {whitespace}, this does
|
||||
not affect the strip block, that has been moved off the compiler into a
|
||||
plugin. Which is why the name conflict had to be resolved. Please report
|
||||
any issue you might encounter when using the strip block
|
||||
! BC Break: Changed the function signature of Dwoo_Block_Plugin::postProcessing
|
||||
it only affects you if you had any custom block plugins, see UPGRADE_NOTES
|
||||
for more details
|
||||
! BC Break: Dwoo_ITemplate::cache() must now return the cached file name or
|
||||
false if caching failed, only affects you if you had a custom template class
|
||||
and implemented cache() yourself
|
||||
! BC Break: Dwoo_Loader is not static anymore so anything you did on it directly
|
||||
will break. Use $dwoo->getLoader()->addDirectory() instead of
|
||||
Dwoo_Loader::addDirectory() for example
|
||||
! BC Break: DWOO_COMPILE_DIRECTORY and DWOO_CACHE_DIRECTORY are gone, set those
|
||||
paths in Dwoo's constructor (i.e. new Dwoo('compiledir', 'cachedir')) if you
|
||||
need to override the default ones
|
||||
+ Plugins: Added {dynamic} that allows cached templates to have dynamic
|
||||
(non-cached) parts, when rendering a cached page, the dynamic parts can still
|
||||
use the variables you provides
|
||||
+ Plugins: Added {tif} that acts as a ternary if / allows you to use a ternary
|
||||
operator inside it
|
||||
+ API: Added a Dwoo_ILoader interface if you want to provide a custom plugin
|
||||
loading solution (use $dwoo->setLoader($myLoader))
|
||||
+ Added line numbers in compilation errors and improved several error messages
|
||||
+ Added magic object-access methods to Dwoo_Data, so you can assign values by
|
||||
doing $data->var = $val; instead of $data->assign('var', $val);
|
||||
+ Added get()/unassign()/isAssigned() methods to read, remove and check for the
|
||||
presence of a var inside a Dwoo_Data object
|
||||
* Plugins: added a fifth 'string $implode' parameter to {foreach}, it prints
|
||||
whatever you provide it between each item of the foreach, just like implode()
|
||||
* Plugins: added a fourth 'bool $case_sensitive' parameter to {replace}
|
||||
* Plugins: added a fourth 'bool $trim' parameter to {capture} that trims
|
||||
the captured text
|
||||
* Made the dependency on the hash extension optional
|
||||
* Fixed compiler bug that prevented method calls combined with named parameters
|
||||
* Fixed compiler bug that prevented the % shortcut for constants to work within
|
||||
function calls (basically it only worked as {%CONST})
|
||||
* Fixed compiler bug that prevented empty() to be called
|
||||
* Fixed several modifier parsing bugs
|
||||
=> http://forum.dwoo.org/viewtopic.php?id=27
|
||||
* Fixed empty string parsing in modifier applied to variables
|
||||
* Fixed compiler handling of <?php echo "foo" ?>{template_tag} where there was
|
||||
no ';' at the end of the php tag
|
||||
* Allowed method calls to work with named parameters
|
||||
* Removed checks for methods/properties being present on objects before calling
|
||||
them since these can be handled by __get() and __call()
|
||||
=> http://forum.dwoo.org/viewtopic.php?id=22
|
||||
* Calling {func (params)} (with the space between function and params) is now
|
||||
allowed
|
||||
=> http://forum.dwoo.org/viewtopic.php?id=21
|
||||
* The compiler now allows \r, \n and \t to be parameter splitters as well as
|
||||
"," and " ". You can therefore split complex function calls on multiple lines
|
||||
* Converted most of the code to follow PEAR Coding Standards, hopefully this
|
||||
didn't break anything that the tests missed
|
||||
* A few other minor or internal changes
|
||||
|
||||
[2008-05-30] 0.9.1
|
||||
+ API: Added Dwoo_Compiler->setAutoEscape() and getAutoEscape() to modify the
|
||||
automatic html entity escaping setting. This is disabled by default, and when
|
||||
enabled can be overriden with the {safe $var} plugin or the
|
||||
{auto_escape disable} block plugin. The block plugin can also be used to
|
||||
enable this mode from within a template
|
||||
+ Syntax: Mixing named and unnamed parameters is now allowed, as long as the
|
||||
unnamed ones appear first
|
||||
+ Syntax: Added {/} shortcut that closes the last opened block
|
||||
* Optimized scope-handling functions, {loop} and {with} are now slightly faster
|
||||
* Fixed a bug in {date_format} that prevented anything but unix timestamps to
|
||||
work
|
||||
* {literal} and {strip} now follow the LooseOpeningsHandling setting
|
||||
* Fixed complex variables (i.e. {$_root[$c[$x.0]].0}) parsing bugs
|
||||
* Fixed $dwoo->addResource() breaking if the resource class was not loaded yet,
|
||||
autoload should now be called (thanks mike)
|
||||
* Fixed a block stack bug that messed up {textformat} and possibly usermade
|
||||
block plugins
|
||||
|
||||
[2008-05-10] 0.9.0
|
||||
! BC Break: changed all class names to be PEAR compliant (aka use underscores
|
||||
to separate words/paths), sorry about that but I better do it now than in
|
||||
six months
|
||||
! BC Break: $dwoo->output() and get() have been swapped internally, but it
|
||||
doesn't change anything for you unless you called output(*, *, *, true)
|
||||
directly to emulate get(). This was done to reduce some overhead
|
||||
! BC Break: $dwoo->getTemplate() changed to $dwoo->templateFactory() and
|
||||
$dwoo->getCurrentTemplate() changed to $dwoo->getTemplate() for consistency
|
||||
among all classes and factory functions
|
||||
+ Added a compiled version of Dwoo that loads faster (especially with opcode
|
||||
caches such as APC), include Dwoo.compiled.php instead of Dwoo.php on
|
||||
production but if you want to file a bug use Dwoo.php please as it allows
|
||||
you to get the proper file/line number where an error occurs. Do not remove
|
||||
all other files however since they are not all included in the compiled
|
||||
package
|
||||
+ Plugins: Added {extends} and {block} to handle template inheritance, read
|
||||
more about it at http://wiki.dwoo.org/index.php/TemplateInheritance
|
||||
+ Plugins: Added {loop} that combines {foreach} and {with}, see
|
||||
http://wiki.dwoo.org/index.php/Block:loop for details
|
||||
+ Plugins: Added {do} that executes whatever you feed it whitout echoing the
|
||||
result, used internally for extends but you can use it if required
|
||||
+ Plugins: Added {eol} that prints an end of line character (OS-specific)
|
||||
+ Syntax: Added shortcut for {$dwoo.const.*} using '%', for example you can use
|
||||
{%FOO} instead of {$dwoo.const.FOO}
|
||||
+ Syntax: When using named parameters, typing a parameter name without any
|
||||
value is the same as typing param=true, for example {foo name="test" bar} and
|
||||
{foo name="test" bar=true} are equals, can be useful for very complex plugins
|
||||
with huge amounts of parameters.
|
||||
+ Syntax: Added support for {$foo+=5}, {$foo="a"}, {$foo++} and {$foo--}
|
||||
+ Syntax: Added shortcut for $dwoo.*, you can now use {$.foreach.foo} instead
|
||||
of {$dwoo.foreach.foo} for example, applies to all $dwoo.* vars
|
||||
+ Syntax: Added $ as a shortcut for current scope, $_ for $_parent and $__ for
|
||||
$_root
|
||||
+ API: Added getSource(), getUid() and getResourceIdentifier() to Dwoo_ITemplate
|
||||
+ API: Added setSecurityPolicy() too Dwoo_ICompiler and modified the arguments
|
||||
of its compile() method
|
||||
+ API: Added a bunch of utility functions to Dwoo_Compiler, allowing compiled
|
||||
plugins to access more of the compiler internals
|
||||
+ Both cache and compile IDs can now have slashes in them to create subfolders
|
||||
in the cache/compile dirs
|
||||
+ Added a DWOO_CHMOD constant that, if set before you include Dwoo, allows you
|
||||
to define the file mode of all the file/directories Dwoo will write, defaults
|
||||
to 0777
|
||||
+ Added a 'data' argument to {include} to be able to feed data directly into it
|
||||
* The compiler now throws Dwoo_Compilation_Exception exceptions upon failure
|
||||
and security problems lead to a Dwoo_Security_Exception being thrown. Runtime
|
||||
plugin errors and such trigger simple php errors to allow the template
|
||||
execution to complete
|
||||
* Fixed a potential concurrency issue (thanks to Rasmus Schultz for the patch)
|
||||
* Moved all files to Dwoo/Class.php excepted for the core Dwoo.php file
|
||||
* Various performance improvements, including the removal of a lot of isset()
|
||||
calls. Doing {$foo} if foo is undefined will now display a PHP warning, but
|
||||
doing {foreach $foo}..{/foreach} will not however, that way you don't have
|
||||
to do {if isset($foo)} before the foreach, but automated isset() calls don't
|
||||
impact performance as much as they did before.
|
||||
* API: Dwoo_ITemplate->clearCache now requires a Dwoo instance as its first arg,
|
||||
should not affect you unless you built a custom template class from scratch
|
||||
* Reworked Dwoo template rendering to avoid variable conflicts with plugins
|
||||
* {include} now uses the current resource if none is provided instead of using
|
||||
file as it did before
|
||||
* Dwoo uses include path instead of absolute includes
|
||||
* Changed all line endings to Unix (line feed only) and all spaces left have
|
||||
been converted to tabs (tabspace 4)
|
||||
* TestFest happened early for Dwoo, lots of new tests and more code covered
|
||||
* Fixed a regression in the handling of custom class plugins
|
||||
* Fixed various bugs in the Adapter class and related smarty compatibility
|
||||
features
|
||||
* Fixed a classpath rebuilding bug that occured on some UNIX platforms due to
|
||||
glob() returning false sometimes for empty folders
|
||||
* Fixed a bug in Dwoo_Security_Policy->getAllowedDirectories(), no security
|
||||
issue though
|
||||
* Fixed a bug in Dwoo::setScope affecting {loop} and {with}
|
||||
* Fixed a parsing bug when doing {"string"|modifier:$var}
|
||||
|
||||
[2008-04-09] 0.3.4
|
||||
! BC Break: DWOO_PATH constant changed to DWOO_DIRECTORY
|
||||
! BC Break: Smarty's @ operator for modifiers is now reversed, for example
|
||||
$array|reverse will reverse the items of that array while $array|@reverse
|
||||
will reverse each item of the given array (as if you used array_map)
|
||||
+ Syntax: Added support for method calls on objects i.e. {$foo->bar()}
|
||||
+ Added support for smarty security features, see the DwooSecurityPolicy class
|
||||
and $dwoo->setSecurityPolicy()
|
||||
+ API: Added a DwooCompiler->setLooseOpeningHandling() method that, if set to
|
||||
true, allows tags to contain spaces between the opening bracket and the
|
||||
content. Turned off by default as it allows to compile files containing
|
||||
css and javascript without the need to escape it through {literal} or \{
|
||||
+ Added DWOO_CACHE_DIRECTORY and DWOO_COMPILE_DIRECTORY constants that you can
|
||||
set before including Dwoo.php to override the defaults (although
|
||||
Dwoo->setCacheDir/setCompileDir() still work to change that if required)
|
||||
+ Added the DwooException class
|
||||
+ Smarty: Added partial support for register_object(), unregister_object() and
|
||||
get_registered_object(). All features can not be supported by the adapter
|
||||
though so you might get compatibility warnings
|
||||
* Fixed {elseif} bug that appeared when multiple elseif tags were used in a row
|
||||
* Syntax: Improved simple math support to work within variable variables
|
||||
(i.e. you can do {$array[$index+1]}) and within strings as well. To prevent
|
||||
this enclose the variables in backticks (i.e. {"$foo/$bar"} will do the math
|
||||
while {"`$foo`/$bar"} won't as $foo is properly delimited)
|
||||
* Changed DwooLoader::addDirectory() so that it writes the class paths cache
|
||||
into DWOO_COMPILE_DIRECTORY, that way you don't have to make your plugin
|
||||
directory writable
|
||||
* Made all the error triggering more consistent
|
||||
* Changed automatic cacheId generation in DwooTemplateFile/String to be faster
|
||||
|
||||
[2008-03-19] 0.3.3
|
||||
+ Syntax: Added support for $dwoo.const.CONSTANT and
|
||||
$dwoo.const.Class::CONSTANT to read PHP constants from the template
|
||||
+ Syntax: Added support for on/off/yes/no, that work as aliases for true/false
|
||||
+ Syntax: Added the $dwoo.charset global variable
|
||||
+ Plugins: Added {withelse} and made {with} compatible with {else} also
|
||||
+ API: Added left/right delimiters customization, see DwooCompiler->setDelimiters()
|
||||
+ API: Added DwooCompiler->triggerError()
|
||||
+ API: Added Dwoo->clearCache() and DwooITemplate->clearCache() methods
|
||||
+ Smarty: The smartyCompat prefilter converts {section} tags into {for} tags on the
|
||||
fly, however it's not guaranteed to work with *all* section tags, let me know if
|
||||
it breaks for you
|
||||
* {with} now skips the entire block if it's variable doesn't exist, so by
|
||||
itself it acts as if you would do {if $var}{with $var}{/with}{/if}
|
||||
* Each resource has a compiler factory function assigned to it, allowing you to
|
||||
easily provide a custom compiler without loading it on every page
|
||||
* OutputFilters are now simply called Filters (they still use DwooFilter)
|
||||
* Pre/PostFilters have become Pre/PostProcessors (they now use DwooProcessor)
|
||||
* Compiler: Fixed parsing bug that prevented function names of 1character
|
||||
* Compiler: Changed internal handling of variables to fix some errors being
|
||||
thrown with specific cases
|
||||
* Reorganized Dwoo/DwooCompiler and fully commented all the core classes
|
||||
and interfaces
|
||||
|
||||
[2008-03-09] 0.3.2
|
||||
+ Added access to superglobals through $dwoo.get.value, $dwoo.post.value,
|
||||
etc.
|
||||
+ Added outputFilters to Dwoo (use Dwoo->addOutputFilter and
|
||||
Dwoo->removeOutputFilter)
|
||||
+ Added preFilters and postFilters to DwooCompiler (use
|
||||
DwooCompiler->addPreFilter, etc)
|
||||
+ Added a html_format output filter that intends properly the html code,
|
||||
use it only on full page templates
|
||||
+ Plugins: Added {for} and {forelse} which allow to loop over an array or to
|
||||
loop over a range of numbers
|
||||
+ Plugins: Added {mailto}, {counter}, {eval}, {fetch} and {include}
|
||||
+ Syntax : Enhanced support for implicit math operations,
|
||||
{$var+$var2*var3+5} now works. Operations are executed from left to right
|
||||
though, there is no operator priority. (i.e. 1+1*2 = (1+1)*2 = 4, not 3)
|
||||
+ API: Added resources support through DwooITemplate implementations and
|
||||
Dwoo->addResource()
|
||||
+ API: Added Dwoo->getTemplate() to get the currently running template object
|
||||
+ API: Added DwooCompiler::getInstance() to use only one compiler object when
|
||||
rendering from the default compiler and to provide you with a singleton if
|
||||
it's easier, however the class is not a singleton in the sense that it can
|
||||
be instantiated separately
|
||||
+ API: Added a factory method on DwooITemplate to support resources creation
|
||||
+ Added a release tag so that all compiled templates are forced to recompile
|
||||
after an update, however it is recommended to cleanup your "compiled"
|
||||
directory now and then as each release uses new filenames
|
||||
+ Added an abstract DwooFilter class that you can extend to build filters
|
||||
* PHP function calls are now case insensitive
|
||||
* Syntax: The compiler now parses expressions before modifiers, allowing for
|
||||
{$var/2|number_format} for example
|
||||
* DwooTemplateFile now extends DwooTemplateString instead of the other way
|
||||
around as it was before
|
||||
* {else} is now a general purpose plugin that can act as 'else' for foreach,
|
||||
for and if/elseif, foreachelse is still available though
|
||||
|
||||
[2008-03-05] 0.3.1
|
||||
+ Added {cycle} function
|
||||
+ Syntax : Enabled support for associative arrays using
|
||||
array(key="value", key2=5) for example, which you can assign or use in a
|
||||
foreach directly
|
||||
+ Syntax : Added support for {$var +-/*% X} (i.e. {$var + 4}), useful for
|
||||
simple math operations without the math plugin
|
||||
+ API : Added append/appendByRef to DwooData
|
||||
+ Completely rebuilt DwooSmartyAdapter, it should "work" and fail silently if
|
||||
you use a non supported function now, however you can set
|
||||
$smarty->show_compat_errors=true; on it to receive notices about unsupported
|
||||
features that you use
|
||||
* Bug fixed in {literal} parsing
|
||||
* Bug fixed in smarty functions handling
|
||||
* API : Moved Plugin types constants to Dwoo so the compiler doesn't have to
|
||||
be loaded unles really required
|
||||
* API : Moved globals and var reinitialization in Dwoo into their own methods
|
||||
so that child classes can easily add globals
|
||||
* Some improvements in the compiler output
|
||||
* Some changes in the cache handling of DwooTemplateFile
|
||||
- Special thanks to Andrew Collins that found many of the bugs fixed in this
|
||||
release
|
||||
|
||||
[2008-03-02] 0.3.0
|
||||
+ Full template cache support
|
||||
+ DwooTemplateString class to load templates from a string
|
||||
+ Dwoo::VERSION constant
|
||||
+ {dump} plugin to print out variables
|
||||
+ Unit tests (with PHPUnit) covering 73% of the codebase right now, which
|
||||
should help reducing regression bugs in the next versions.
|
||||
+ Started commenting (with phpdocs) properly all the classes, should be
|
||||
complete for 0.4.0
|
||||
* {capture} is now compilable and has a new boolean flag to append output into
|
||||
the target variable instead of overwriting
|
||||
* {foreach} supports direct input (instead of only variables), allowing
|
||||
constructs like {foreach array(a,b,c) val}{$val}{/foreach} for example that
|
||||
would output abc.
|
||||
* pre/postProcessing functions in block plugins now receive an array of named
|
||||
parameters instead of numbered
|
||||
* Major refactoring of DwooTemplateFile and DwooCompiler
|
||||
* Cleaned up members visibility in Dwoo/DwooCompiler
|
||||
* Fixes in the compiler parsing and general variables handling
|
||||
* Multiple bugfixes here and there thanks to the unit tests
|
||||
* Optimized {foreach} a lot
|
||||
|
||||
[2008-02-19] 0.2.1
|
||||
* Compiler fixes for argument parsing and handling of Smarty plugins
|
||||
|
||||
[2008-02-14] 0.2.0
|
||||
+ Added support for plugins made for Smarty (that includes modifiers,
|
||||
functions and blocks). Not thoroughly tested.
|
||||
+ Major API changes in the way Dwoo must be run, it's now much more
|
||||
flexible and should not change too much in the future.
|
||||
+ Added support for custom plugins, filters should come in the next version
|
||||
although the API to register them is already in.
|
||||
|
||||
[2008-02-08] 0.1.0
|
||||
Initial release
|
@@ -1,196 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dwoo adapter for Agavi
|
||||
*
|
||||
* Install instructions :
|
||||
* - download dwoo from dwoo.org and unzip it somewhere in your agavi app
|
||||
* - add a renderer to your output_types.xml as such :
|
||||
* <renderer name="dwoo" class="DwooRenderer">
|
||||
* <parameter name="assigns">
|
||||
* <parameter name="routing">ro</parameter>
|
||||
* <parameter name="request">rq</parameter>
|
||||
* <parameter name="controller">ct</parameter>
|
||||
* <parameter name="user">us</parameter>
|
||||
* <parameter name="translation_manager">tm</parameter>
|
||||
* <parameter name="request_data">rd</parameter>
|
||||
* </parameter>
|
||||
* <parameter name="extract_vars">true</parameter>
|
||||
* <parameter name="plugin_dir">%core.lib_dir%/dwoo_plugins</parameter>
|
||||
* </renderer>
|
||||
*
|
||||
* - add dwoo's directory to your include path or include dwooAutoload.php yourself
|
||||
* either through agavi's autoload.xml (with name="Dwoo") or through your index.php
|
||||
*
|
||||
* Notes:
|
||||
* - you can copy the /Dwoo/Adapters/Agavi/dwoo_plugins directory to your agavi app's
|
||||
* lib directory, or change the plugin_dir parameter in the output_types.xml file.
|
||||
* these plugins are agavi-specific helpers that shortens the syntax to call common
|
||||
* agavi helpers (i18n, routing, ..)
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the
|
||||
* use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.1.0
|
||||
* @date 2009-07-18
|
||||
* @package Dwoo
|
||||
*/
|
||||
class DwooRenderer extends AgaviRenderer implements AgaviIReusableRenderer
|
||||
{
|
||||
/**
|
||||
* @constant string The directory inside the cache dir where templates will
|
||||
* be stored in compiled form.
|
||||
*/
|
||||
const COMPILE_DIR = 'templates';
|
||||
|
||||
/**
|
||||
* @constant string The subdirectory inside the compile dir where templates
|
||||
* will be stored in compiled form.
|
||||
*/
|
||||
const COMPILE_SUBDIR = 'dwoo';
|
||||
|
||||
/**
|
||||
* @constant string The directory inside the cache dir where cached content
|
||||
* will be stored.
|
||||
*/
|
||||
const CACHE_DIR = 'dwoo';
|
||||
|
||||
/**
|
||||
* @var Dwoo Dwoo template engine.
|
||||
*/
|
||||
protected $dwoo = null;
|
||||
|
||||
/**
|
||||
* @var string A string with the default template file extension,
|
||||
* including the dot.
|
||||
*/
|
||||
protected $defaultExtension = '.html';
|
||||
|
||||
/**
|
||||
* stores the (optional) plugin directory to add to the Dwoo_Loader
|
||||
*/
|
||||
protected $plugin_dir = null;
|
||||
|
||||
/**
|
||||
* Pre-serialization callback.
|
||||
*
|
||||
* Excludes the Dwoo instance to prevent excessive serialization load.
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
$keys = parent::__sleep();
|
||||
unset($keys[array_search('dwoo', $keys)]);
|
||||
return $keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this Renderer.
|
||||
*
|
||||
* @param AgaviContext The current application context.
|
||||
* @param array An associative array of initialization parameters.
|
||||
*/
|
||||
public function initialize(AgaviContext $context, array $parameters = array())
|
||||
{
|
||||
parent::initialize($context, $parameters);
|
||||
|
||||
$this->plugin_dir = $this->getParameter('plugin_dir', $this->plugin_dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* provides a custom compiler to the dwoo renderer with optional settings
|
||||
* you can set in the agavi output_types.xml config file
|
||||
*
|
||||
* @return Dwoo_Compiler
|
||||
*/
|
||||
public function compilerFactory()
|
||||
{
|
||||
if (class_exists('Dwoo_Compiler', false) === false) {
|
||||
include DWOO_DIRECTORY . 'Dwoo/Compiler.php';
|
||||
}
|
||||
$compiler = Dwoo_Compiler::compilerFactory();
|
||||
$compiler->setAutoEscape((bool) $this->getParameter('auto_escape', false));
|
||||
return $compiler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab a cleaned up dwoo instance.
|
||||
*
|
||||
* @return Dwoo A Dwoo instance.
|
||||
*/
|
||||
protected function getEngine()
|
||||
{
|
||||
if($this->dwoo) {
|
||||
return $this->dwoo;
|
||||
}
|
||||
|
||||
if(!class_exists('Dwoo')) {
|
||||
if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) {
|
||||
// file was dropped with the entire dwoo package
|
||||
require dirname(__FILE__).'/../../../dwooAutoload.php';
|
||||
} else {
|
||||
// assume the dwoo package is in the include path
|
||||
require 'dwooAutoload.php';
|
||||
}
|
||||
}
|
||||
|
||||
$parentMode = fileperms(AgaviConfig::get('core.cache_dir'));
|
||||
|
||||
$compileDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR;
|
||||
AgaviToolkit::mkdir($compileDir, $parentMode, true);
|
||||
|
||||
$cacheDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::CACHE_DIR;
|
||||
AgaviToolkit::mkdir($cacheDir, $parentMode, true);
|
||||
|
||||
$this->dwoo = new Dwoo($compileDir, $cacheDir);
|
||||
|
||||
if (!empty($this->plugin_dir)) {
|
||||
$this->dwoo->getLoader()->addDirectory($this->plugin_dir);
|
||||
}
|
||||
|
||||
$this->dwoo->setDefaultCompilerFactory('file', array($this, 'compilerFactory'));
|
||||
|
||||
return $this->dwoo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the presentation and return the result.
|
||||
*
|
||||
* @param AgaviTemplateLayer The template layer to render.
|
||||
* @param array The template variables.
|
||||
* @param array The slots.
|
||||
* @param array Associative array of additional assigns.
|
||||
*
|
||||
* @return string A rendered result.
|
||||
*/
|
||||
public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array())
|
||||
{
|
||||
$engine = $this->getEngine();
|
||||
|
||||
$data = array();
|
||||
if($this->extractVars) {
|
||||
$data = $attributes;
|
||||
} else {
|
||||
$data[$this->varName] = &$attributes;
|
||||
}
|
||||
|
||||
$data[$this->slotsVarName] =& $slots;
|
||||
|
||||
foreach($this->assigns as $key => $getter) {
|
||||
$data[$key] = $this->context->$getter();
|
||||
}
|
||||
|
||||
foreach($moreAssigns as $key => &$value) {
|
||||
if(isset($this->moreAssignNames[$key])) {
|
||||
$key = $this->moreAssignNames[$key];
|
||||
}
|
||||
$data[$key] =& $value;
|
||||
}
|
||||
|
||||
return $engine->get($layer->getResourceStreamIdentifier(), $data);
|
||||
}
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
// ------------------------
|
||||
// Install notes :
|
||||
// ------------------------
|
||||
|
||||
- drop dwoo's directory in app/lib/renderer (create if needed)
|
||||
|
||||
- add a renderer to app/config/output_types.xml as such :
|
||||
<renderer name="dwoo" class="DwooRenderer">
|
||||
<parameter name="assigns">
|
||||
<parameter name="routing">ro</parameter>
|
||||
<parameter name="request">rq</parameter>
|
||||
<parameter name="controller">ct</parameter>
|
||||
<parameter name="user">us</parameter>
|
||||
<parameter name="translation_manager">tm</parameter>
|
||||
<parameter name="request_data">rd</parameter>
|
||||
</parameter>
|
||||
<parameter name="extract_vars">true</parameter>
|
||||
<parameter name="plugin_dir">%core.lib_dir%/dwoo_plugins</parameter>
|
||||
</renderer>
|
||||
|
||||
- add the renderer to app/config/autoload.xml as such :
|
||||
<autoload name="DwooRenderer">%core.lib_dir%/renderer/dwoo/Dwoo/Adapter/Agavi/DwooRenderer.php</autoload>
|
||||
|
||||
- you can copy the /Dwoo/Adapters/Agavi/dwoo_plugins directory to your agavi app's
|
||||
lib directory, or change the plugin_dir parameter in the output_types.xml file.
|
||||
these plugins are agavi-specific helpers that shortens the syntax to call common
|
||||
agavi helpers (i18n, routing, ..)
|
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <strong>Agavi specific plugin</strong>
|
||||
*
|
||||
* uses AgaviTranslationManager to localize a string
|
||||
*
|
||||
* <pre>
|
||||
* * string : the string to localize
|
||||
* </pre>
|
||||
*
|
||||
* Examples:
|
||||
* <code>
|
||||
* {t "Hello"}
|
||||
* {t $header}
|
||||
* </code>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
function Dwoo_Plugin_t_compile(Dwoo_Compiler $compiler, $string)
|
||||
{
|
||||
return '$this->data[\'tm\']->_('.$string.')';
|
||||
}
|
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <strong>Agavi specific plugin</strong>
|
||||
*
|
||||
* uses AgaviRouting to create an url
|
||||
*
|
||||
* <pre>
|
||||
* * route : the route name, optional (by default the current url is returned)
|
||||
* * params : an array with variables to build the route, optional
|
||||
* * options : an array of options to pass to the routing object, optional
|
||||
* * rest : for convenience, you can just pass named parameters that will be used as
|
||||
* the params array, but you must not provide the params array in this case
|
||||
* </pre>
|
||||
*
|
||||
* Examples:
|
||||
* <code>
|
||||
* {a url("route.name" array(param="Value", param2=$otherVal))}Here is a link{/a}
|
||||
* <form action="{url}"> {* without any parameter it just returns the current url *}
|
||||
* </code>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
function Dwoo_Plugin_url_compile(Dwoo_Compiler $compiler, $route = null, $params = null, $options = null, array $rest = array())
|
||||
{
|
||||
if ($params == 'null') {
|
||||
if (count($rest)) {
|
||||
$params = array();
|
||||
foreach ($rest as $k=>$v) {
|
||||
if (is_numeric($k)) {
|
||||
$params[] = $k.'=>'.$v;
|
||||
} else {
|
||||
$params[] = '"'.$k.'"=>'.$v;
|
||||
}
|
||||
}
|
||||
$params = 'array('.implode(', ', $params).')';
|
||||
} else {
|
||||
$params = 'array()';
|
||||
}
|
||||
}
|
||||
if ($options == 'null') {
|
||||
$options = 'array()';
|
||||
}
|
||||
return '$this->data[\'ro\']->gen('.$route.', '.$params.', '.$options.')';
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
// CakePHP Dwoo bridge - v0.2
|
||||
// ------------------------
|
||||
// Installation :
|
||||
// ------------------------
|
||||
// 1. Download and install the dwoo library, preferably on the
|
||||
// 'vendors' directory of CakePHP. However you can place it
|
||||
// anywhere you want; if you do, make sure to change the App::import
|
||||
// line in dwoo.php to include the dwoo library properly.
|
||||
//
|
||||
// 2. Place this file in the app/views directory, or on cake/libs/view.
|
||||
//
|
||||
// 3. Create the app/tmp/dwoo/cache and app/tmp/dwoo/compile directories
|
||||
// and make sure they are writable.
|
||||
// ------------------------
|
||||
// Usage example :
|
||||
// ------------------------
|
||||
|
||||
// In your controller class you need to change the view property to
|
||||
// use Dwoo at some point in the execution using :
|
||||
|
||||
$this->view = 'Dwoo';
|
||||
|
||||
// Or you can also override the view property in your AppController class as such :
|
||||
|
||||
class AppController extends Controller {
|
||||
public $view = 'Dwoo';
|
||||
}
|
||||
|
||||
// If you want another template extension (default is .tpl) you must
|
||||
// edit the dwoo.php file at line 44 and change it to :
|
||||
$this->ext = ".html";
|
||||
|
||||
//{include $templatedir."index.tpl"}
|
@@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
App::import('vendor', 'dwoo', array("file" => 'dwoo/dwooAutoload.php'));
|
||||
|
||||
/**
|
||||
* Dwoo adapter for CakePHP
|
||||
*
|
||||
* Based on SmartyView by Mark John S. Buenconsejo <mjwork@simpleteq.com>
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* This file is released under the LGPL
|
||||
* "GNU Lesser General Public License"
|
||||
* More information can be found here:
|
||||
* {@link http://www.gnu.org/copyleft/lesser.html}
|
||||
*
|
||||
* @author Mark John S. Buenconsejo <mjwork@simpleteq.com>
|
||||
* @author Giangi <giangi@qwerg.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.1.0
|
||||
* @date 2009-07-18
|
||||
* @package Dwoo
|
||||
*/
|
||||
class DwooView extends View
|
||||
{
|
||||
protected $_sv_template_dir;
|
||||
protected $_sv_layout_dir;
|
||||
protected $_sv_compile_dir;
|
||||
protected $_sv_cache_dir;
|
||||
protected $_sv_compile_id;
|
||||
|
||||
protected $_dwoo;
|
||||
|
||||
public $sv_processedTpl;
|
||||
|
||||
public function __construct(&$controller)
|
||||
{
|
||||
parent::__construct($controller);
|
||||
|
||||
$this->ext = '.tpl';
|
||||
|
||||
$this->_sv_template_dir = array
|
||||
(
|
||||
VIEWS . $this->viewPath . DS . $this->subDir,
|
||||
VIEWS . $this->viewPath,
|
||||
VIEWS
|
||||
);
|
||||
|
||||
$this->_sv_layout_dir = array
|
||||
(
|
||||
LAYOUTS . $this->subDir,
|
||||
VIEWS
|
||||
);
|
||||
|
||||
$this->_sv_compile_dir = TMP . 'dwoo' . DS . 'compile';
|
||||
$this->_sv_cache_dir = TMP . 'dwoo' . DS . 'cache';
|
||||
|
||||
$this->_dwoo = new Dwoo($this->_sv_compile_dir, $this->_sv_cache_dir);
|
||||
|
||||
$this->_sv_compile_id = $controller->name;
|
||||
|
||||
$this->_dwoo->sv_this = $this;
|
||||
$this->_dwoo->setSecurityPolicy();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* changes the template directory
|
||||
*/
|
||||
public function setTemplateDir($path = VIEW) {
|
||||
$old = $this->_sv_template_dir;
|
||||
$this->_sv_template_dir = $path;
|
||||
|
||||
return $old;
|
||||
}
|
||||
|
||||
public function getTemplateDir() {
|
||||
return $this->_sv_template_dir ;
|
||||
}
|
||||
|
||||
public function _render($___viewFn, $___data_for_view, $___play_safe = true, $loadHelpers = true)
|
||||
{
|
||||
// let's determine if this is a layout call or a template call
|
||||
// and change the template dir accordingly
|
||||
$layout = false;
|
||||
if(isset($___data_for_view['content_for_layout'])) {
|
||||
$this->_sv_template_dir = $this->_sv_layout_dir;
|
||||
$layout = true;
|
||||
}
|
||||
|
||||
$tpl = new Dwoo_Template_File($___viewFn);
|
||||
$data = $___data_for_view;
|
||||
|
||||
$data['view'] = $this;
|
||||
|
||||
if ($this->helpers != false && $loadHelpers === true) {
|
||||
$loadedHelpers = array();
|
||||
$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
|
||||
|
||||
foreach (array_keys($loadedHelpers) as $helper) {
|
||||
$camelBackedHelper = strtolower(substr($helper, 0, 1)) . substr($helper, 1);
|
||||
|
||||
${$camelBackedHelper} = $loadedHelpers[$helper];
|
||||
|
||||
if (is_array(${$camelBackedHelper}->helpers) && !empty(${$camelBackedHelper}->helpers)) {
|
||||
$subHelpers = ${$camelBackedHelper}->helpers;
|
||||
foreach ($subHelpers as $subHelper) {
|
||||
${$camelBackedHelper}->{$subHelper} = $loadedHelpers[$subHelper];
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($this->passedArgs)) {
|
||||
${$camelBackedHelper}->passedArgs = $this->passedArgs;
|
||||
}
|
||||
|
||||
$this->loaded[$camelBackedHelper] = ${$camelBackedHelper};
|
||||
|
||||
$data[$camelBackedHelper] = ${$camelBackedHelper};
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->helpers != false && $loadHelpers === true) {
|
||||
foreach ($loadedHelpers as $helper) {
|
||||
if (is_object($helper)) {
|
||||
if (is_subclass_of($helper, 'Helper') || is_subclass_of($helper, 'helper')) {
|
||||
$helper->beforeRender();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_dwoo->get($tpl, $data);
|
||||
}
|
||||
|
||||
public function get(){
|
||||
return $this->_dwoo;
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
CodeIgniter/Dwoo adapater
|
||||
-------------------------
|
||||
Integration of Dwoo into Codeigniter (1.7.0 >)
|
||||
|
||||
Links:
|
||||
Dwoo - http://dwoo.org
|
||||
CodeIgniter - http://codeigniter.com
|
||||
|
||||
Installation:
|
||||
1) Extract package into your application directory (i.e. $webroot/application or
|
||||
$webroot/system/application)
|
||||
2) Change the parameters in config/dwootemplate.php
|
||||
3) Create the compile and cache directory you set in your config file in step 2
|
||||
and give it the correct rights (chmod 777 when on *nix)
|
||||
4) Extract/copy the Dwoo package into application/libraries/dwoo
|
||||
5) Browse to : http://[yoururl]/dwoowelcome
|
||||
|
||||
|
||||
Version info
|
||||
1.0.2 [11-03-2009] Fixed a problem with $data attribute (which Dwoo also used)
|
||||
1.0.1 [12-11-2008] Removed some & in the dwootemplate
|
||||
Changed licencse
|
||||
Changed 'output' in 'get' in the dwootemplate (line 122)
|
||||
1.0.0 [11-11-2008] Initial release
|
||||
|
||||
|
||||
Questions/Remarks?
|
||||
mail to: stefan.verstege@newmedia.nl
|
||||
IM me on GTALK: verstege@gmail.com
|
||||
Contact me on the Dwoo forums: stefanv
|
||||
|
||||
---------[ copyright notice ]-----------------------------------------------------------------------
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
License http://dwoo.org/LICENSE Modified BSD License
|
@@ -1,12 +0,0 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
// The name of the directory where templates are located.
|
||||
$config['template_dir'] = dirname(FCPATH) . '/../application/views/';
|
||||
|
||||
// The directory where compiled templates are located
|
||||
$config['compileDir'] = dirname(FCPATH) . '/../compile/';
|
||||
|
||||
//This tells Dwoo whether or not to cache the output of the templates to the $cache_dir.
|
||||
$config['caching'] = 0;
|
||||
$config['cacheDir'] = dirname(FCPATH) . '/../cache/';
|
||||
$config['cacheTime'] = 0;
|
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Dwoowelcome extends Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::Controller();
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$this->load->library('Dwootemplate');
|
||||
$this->dwootemplate->assign('itshowlate', date('H:i:s'));
|
||||
$this->dwootemplate->display('dwoowelcome.tpl');
|
||||
}
|
||||
}
|
@@ -1,172 +0,0 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
require "dwoo/dwooAutoload.php";
|
||||
|
||||
/**
|
||||
* Creates an template interface from Codeigniter to DWOO.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* @author Stefan Verstege <stefan.verstege@newmedia.nl>
|
||||
* @copyright Copyright (c) 2008, Stefan Verstege
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://www.newmedia.nl/
|
||||
* @version 1.1.0
|
||||
* @date 2009-07-18
|
||||
* @package Dwoo
|
||||
*
|
||||
* @uses the dwoo package from http://dwoo.org
|
||||
*/
|
||||
class Dwootemplate extends Dwoo {
|
||||
protected $dwoo_data = array();
|
||||
|
||||
/**
|
||||
* Constructor for the DwooTemplate engine
|
||||
*
|
||||
*/
|
||||
public function __construct() {
|
||||
// Call parents constructor
|
||||
parent::__construct();
|
||||
|
||||
// Set the config settings
|
||||
$this->initialize();
|
||||
|
||||
// Assign some defaults to dwoo
|
||||
$CI = get_instance();
|
||||
$this->dwoo_data = new Dwoo_Data();
|
||||
$this->dwoo_data->js_files = array();
|
||||
$this->dwoo_data->css_files = array();
|
||||
$this->dwoo_data->CI = $CI;
|
||||
$this->dwoo_data->site_url = $CI->config->site_url(); // so we can get the full path to CI easily
|
||||
$this->dwoo_data->uniqid = uniqid();
|
||||
$this->dwoo_data->timestamp = mktime();
|
||||
|
||||
log_message('debug', "Dwoo Template Class Initialized");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign data to dwoo data object
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function assign($key, $value) {
|
||||
$this->dwoo_data->$key = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Javascript files to template
|
||||
*
|
||||
* @param string $js
|
||||
*/
|
||||
public function add_js($js) {
|
||||
$current = $this->dwoo_data->js_files;
|
||||
$current[] = $js;
|
||||
$this->dwoo_data->js_files = $current;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add Css stylesheets to template
|
||||
*
|
||||
* @param string $css
|
||||
*/
|
||||
public function add_css($css) {
|
||||
$current = $this->dwoo_data->css_files;
|
||||
$current[] = $css;
|
||||
$this->dwoo_data->css_files = $current;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display or return the compiled template
|
||||
* Since we assign the results to the standard CI output module
|
||||
* you can also use the helper from CI in your templates!!
|
||||
*
|
||||
* @param string $sTemplate
|
||||
* @param boolean $return
|
||||
* @return mixed
|
||||
*/
|
||||
public function display($sTemplate, $return = FALSE) {
|
||||
// Start benchmark
|
||||
$CI = get_instance();
|
||||
$CI->benchmark->mark('dwoo_parse_start');
|
||||
|
||||
// Check if file exists
|
||||
if ( !file_exists($this->template_dir . $sTemplate ) ) {
|
||||
$message = sprintf('Template file \'%s\' not found.', $sTemplate);
|
||||
show_error($message);
|
||||
log_message('error', $message);
|
||||
}
|
||||
|
||||
// Create new template
|
||||
$tpl = new Dwoo_Template_File($this->template_dir . $sTemplate);
|
||||
|
||||
// render the template
|
||||
$template = $this->get($tpl, $this->dwoo_data);
|
||||
|
||||
// Finish benchmark
|
||||
$CI->benchmark->mark('dwoo_parse_end');
|
||||
|
||||
// Return results or not ?
|
||||
if ($return == FALSE) {
|
||||
$CI->output->final_output = $template;
|
||||
} else {
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggle Codeigniter profiler on/off
|
||||
*
|
||||
*/
|
||||
public function enable_profiler($toggle = TRUE) {
|
||||
$CI = get_instance();
|
||||
$CI->output->enable_profiler($toggle);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set http header
|
||||
*
|
||||
* @example $this->output->set_header("HTTP/1.1 200 OK");
|
||||
* @example $this->output->set_header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_update).' GMT');
|
||||
* @param string $header
|
||||
*/
|
||||
public function set_header($header) {
|
||||
$CI = get_instance();
|
||||
$CI->output->set_header($header);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set status header
|
||||
*
|
||||
* @example $this->output->set_status_header('401');
|
||||
* @example // Sets the header as: Unauthorized
|
||||
* @param string $header
|
||||
*/
|
||||
public function set_status_header($header) {
|
||||
$CI = get_instance();
|
||||
$CI->output->set_status_header($header);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign the dwootemplate config items to the instance
|
||||
*
|
||||
*/
|
||||
private function initialize() {
|
||||
$CI = get_instance();
|
||||
$CI->config->load('dwootemplate', TRUE);
|
||||
$config = $CI->config->item('dwootemplate');
|
||||
foreach ($config as $key => $val) {
|
||||
$this->$key = $val;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
{extends "page.tpl"}
|
||||
|
||||
{block "title"}
|
||||
Welcome to Dwoo-ed CodeIgniter
|
||||
{/block}
|
||||
|
||||
{block "content"}
|
||||
<h1>Welcome to Dwoo-ed CodeIgniter!</h1>
|
||||
|
||||
<p>The page you are looking at is being generated dynamically by <b>CodeIgniter</b> in combination with the 'Smarty-killer' <b>Dwoo</b> template engine.
|
||||
The page is rendered at {$itshowlate} by the Dwoo_compiler.</p>
|
||||
|
||||
<p>If you would like to edit this page you'll find it located at:</p>
|
||||
<code>application/views/dwoowelcome.tpl</code>
|
||||
|
||||
<p>The corresponding controller for this page is found at:</p>
|
||||
<code>application/controllers/dwoowelcome.php</code>
|
||||
|
||||
<p>The library for Dwoo integration can be found at:</p>
|
||||
<code>application/libraries/Dwootemplate.php</code>
|
||||
|
||||
<p>If you are exploring Dwoo for the very first time, you should start by reading the {anchor uri='http://dwoo.org/' title='Dwoo website'}.</p>
|
||||
<p>If you are exploring CodeIgniter for the very first time, you should start by reading the {anchor uri='http://codeigniter.com/user_guide/' title='User Guide'}.</p>
|
||||
|
||||
<pre>
|
||||
<b>Usage</b>:
|
||||
$this->load->library('Dwootemplate');
|
||||
$this->dwootemplate->assign('test', 'test');
|
||||
$this->dwootemplate->display('dwoowelcome.tpl');
|
||||
</pre>
|
||||
{/block}
|
@@ -1,57 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>{block "title"}Here come the title{/block}</title>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
background-color: #fff;
|
||||
margin: 40px;
|
||||
font-family: Lucida Grande, Verdana, Sans-serif;
|
||||
font-size: 14px;
|
||||
color: #4F5155;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #003399;
|
||||
background-color: transparent;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #444;
|
||||
background-color: transparent;
|
||||
border-bottom: 1px solid #D0D0D0;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin: 24px 0 2px 0;
|
||||
padding: 5px 0 6px 0;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: Monaco, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #D0D0D0;
|
||||
color: #002166;
|
||||
display: block;
|
||||
margin: 14px 0 14px 0;
|
||||
padding: 12px 10px 12px 10px;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: Monaco, Verdana, Sans-serif;
|
||||
font-size: 12px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #D0D0D0;
|
||||
color: #B9BAA4;
|
||||
display: block;
|
||||
margin: 14px 0 14px 0;
|
||||
padding: 12px 10px 12px 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{block "content"}Here comes the content{/block}
|
||||
</body>
|
||||
</html>
|
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PluginProxy class for Zend View
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the
|
||||
* use of this software.
|
||||
*
|
||||
* @author Denis Arh <denis@arh.cc>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Denis Arh, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Adapters_ZendFramework_PluginProxy implements Dwoo_IPluginProxy
|
||||
{
|
||||
/**
|
||||
* reference to the zend view owning this proxy
|
||||
*
|
||||
* @var Zend_View_Interface
|
||||
*/
|
||||
public $view;
|
||||
|
||||
/**
|
||||
* Dwoo_Adapters_ZendFramework_PluginProxy's constructor.
|
||||
*
|
||||
* @param Zend_View_Interface $view
|
||||
*/
|
||||
public function __construct(Zend_View_Interface $view) {
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from Dwoo_Compiler to check if the requested plugin is available
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function handles($name) {
|
||||
try {
|
||||
$this->view->getHelper($name);
|
||||
} catch (Zend_Loader_PluginLoader_Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the code (as a string) to call the plugin
|
||||
* (this will be executed at runtime inside the Dwoo class)
|
||||
*
|
||||
* @param string $name the plugin name
|
||||
* @param array $params a parameter array, array key "*" is the rest array
|
||||
* @return string
|
||||
*/
|
||||
public function getCode($name, $params) {
|
||||
return '$this->getPluginProxy()->view->'. $name .'('.Dwoo_Compiler::implode_r($params).')';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a callback to the plugin, this is used with the reflection API to
|
||||
* find out about the plugin's parameter names etc.
|
||||
*
|
||||
* should you need a rest array (i.e. for ZendFramework helpers) without the
|
||||
* possibility to edit the plugin's code, you can provide a callback to some
|
||||
* other function with the correct parameter signature, i.e. :
|
||||
* <code>
|
||||
* return array($this, "callbackHelper");
|
||||
* // and callbackHelper would be as such:
|
||||
* public function callbackHelper(array $rest=array()){}
|
||||
* </code>
|
||||
*
|
||||
* @param string $name the plugin name
|
||||
* @return callback
|
||||
*/
|
||||
public function getCallback($name) {
|
||||
return array($this->view->getHelper($name), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns some code that will check if the plugin is loaded and if not load it
|
||||
* this is optional, if your plugins are autoloaded or whatever, just return an
|
||||
* empty string
|
||||
*
|
||||
* @param string $name the plugin name
|
||||
* @return string
|
||||
*/
|
||||
public function getLoader($name) {
|
||||
return '';
|
||||
}
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
// ------------------------
|
||||
// Usage example :
|
||||
// ------------------------
|
||||
// Note that you might need to manually include 'lib/Dwoo.php',
|
||||
// 'lib/Dwoo/Adapters/ZendFramework/View.php' and
|
||||
// 'lib/Dwoo/Adapters/ZendFramework/PluginProxy.php' for this to
|
||||
// work as expected, depending on your ZF setup
|
||||
//
|
||||
// If anyone writes a more advanced how-to please let me know
|
||||
// ------------------------
|
||||
|
||||
$view = new Dwoo_Adapters_ZendFramework_View(array(
|
||||
'compileDir' => 'path/to/compile_dir' // set to null or remove this line to use defaults
|
||||
'cacheDir' => 'path/to/cache_dir' // set to null or remove this line to use defaults
|
||||
));
|
||||
|
||||
// This allows you to use ZF's helpers as if they were Dwoo plugins (i.e. {doctype} will call the doctype helper)
|
||||
|
||||
$view->setPluginProxy(new Dwoo_Adapters_ZendFramework_PluginProxy(new Zend_View()));
|
||||
|
||||
|
||||
// 1. example - used with the Zend Controller
|
||||
|
||||
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
|
||||
|
||||
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
|
||||
|
||||
|
||||
// 2. example - used manually
|
||||
|
||||
$view->assign('foo', 'bar');
|
||||
$view->display('foobar.phtml');
|
@@ -1,512 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dwoo adapter for ZendFramework
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the
|
||||
* use of this software.
|
||||
*
|
||||
* @author Denis Arh <denis@arh.cc>
|
||||
* @author Stephan Wentz <stephan@wentz.it>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.1.0
|
||||
* @date 2009-07-18
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Adapters_ZendFramework_View extends Zend_View_Abstract
|
||||
{
|
||||
/**
|
||||
* @var Dwoo
|
||||
*/
|
||||
protected $_engine = null;
|
||||
|
||||
/**
|
||||
* @var Dwoo_Data
|
||||
*/
|
||||
protected $_dataProvider = null;
|
||||
|
||||
/**
|
||||
* @var Dwoo_Compiler
|
||||
*/
|
||||
protected $_compiler = null;
|
||||
|
||||
/**
|
||||
* Changing Filter's scope to play nicely
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_filter = array();
|
||||
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_templateFileClass = 'Dwoo_Template_File';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_templateFileSettings = array();
|
||||
|
||||
/**
|
||||
* @var Dwoo_IPluginProxy
|
||||
*/
|
||||
protected $_pluginProxy = null;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
* See setOptions for $opt details
|
||||
*
|
||||
* @see setOptions
|
||||
* @param array|Zend_Config List of options or Zend_Config instance
|
||||
*/
|
||||
public function __construct($opt = array())
|
||||
{
|
||||
|
||||
if (is_array($opt)) {
|
||||
$this->setOptions($opt);
|
||||
} elseif ($opt instanceof Zend_Config) {
|
||||
$this->setConfig($opt);
|
||||
}
|
||||
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object state from options array
|
||||
* - engine = engine class name|engine object|array of options for engine
|
||||
* - dataProvider = data provider class name|data provider object|array of options for data provider
|
||||
* - compiler = compiler class name|compiler object|array of options for compiler
|
||||
* - templateFile =
|
||||
*
|
||||
* Array of options:
|
||||
* - type class name or object for engine, dataProvider or compiler
|
||||
* - any set* method (compileDir for setCompileDir ...)
|
||||
*
|
||||
* @param array $options
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function setOptions(array $opt = array())
|
||||
{
|
||||
// BC checks
|
||||
// TODO remove in 1.1
|
||||
if (isset($opt['compileDir']) || isset($opt['compile_dir'])) {
|
||||
trigger_error('Dwoo ZF Adapter: the compile dir should be set in the $options[\'engine\'][\'compileDir\'] value the adapter settings', E_USER_WARNING);
|
||||
}
|
||||
|
||||
if (isset($opt['cacheDir']) || isset($opt['cache_dir'])) {
|
||||
trigger_error('Dwoo ZF Adapter: the cache dir should be set in the $options[\'engine\'][\'cacheDir\'] value the adapter settings', E_USER_WARNING);
|
||||
}
|
||||
// end BC
|
||||
|
||||
// Making sure that everything is loaded.
|
||||
$classes = array('engine', 'dataProvider', 'compiler');
|
||||
|
||||
// Setting options to Dwoo objects...
|
||||
foreach ($opt as $type => $settings) {
|
||||
if (!method_exists($this, 'set' . $type)) {
|
||||
throw new Dwoo_Exception("Unknown type $type");
|
||||
}
|
||||
|
||||
if (is_string($settings) || is_object($settings)) {
|
||||
call_user_func(array($this, 'set' . $type), $settings);
|
||||
} elseif (is_array($settings)) {
|
||||
// Set requested class
|
||||
if (array_key_exists('type', $settings)) {
|
||||
call_user_func(array($this, 'set' . $type), $settings['type']);
|
||||
}
|
||||
|
||||
if (in_array($type, $classes)) {
|
||||
// Call get so that the class is initialized
|
||||
$rel = call_user_func(array($this, 'get' . $type));
|
||||
|
||||
// Call set*() methods so that all the settings are set.
|
||||
foreach ($settings as $method => $value) {
|
||||
if (method_exists($rel, 'set' . $method)) {
|
||||
call_user_func(array($rel, 'set' . $method), $value);
|
||||
}
|
||||
}
|
||||
} elseif ('templateFile' == $type) {
|
||||
// Remember the settings for the templateFile
|
||||
$this->_templateFileSettings = $settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set object state from Zend_Config object
|
||||
*
|
||||
* @param Zend_Config $config
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function setConfig(Zend_Config $config)
|
||||
{
|
||||
return $this->setOptions($config->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before template rendering
|
||||
*
|
||||
* Binds plugin proxy to the Dwoo.
|
||||
*
|
||||
* @see Dwoo_Adapters_ZendFramework_View::getPluginProxy();
|
||||
* @see Dwoo::setPluginProxy();
|
||||
*/
|
||||
protected function preRender()
|
||||
{
|
||||
$this->getEngine()->setPluginProxy($this->getPluginProxy());
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraper for Dwoo_Data::__set()
|
||||
* allows to assign variables using the object syntax
|
||||
*
|
||||
* @see Dwoo_Data::__set()
|
||||
* @param string $name the variable name
|
||||
* @param string $value the value to assign to it
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->getDataProvider()->__set($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sraper for Dwoo_Data::__get() allows to read variables using the object
|
||||
* syntax
|
||||
*
|
||||
* @see Dwoo_Data::__get()
|
||||
* @param string $name the variable name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->getDataProvider()->__get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraper for Dwoo_Data::__isset()
|
||||
* supports calls to isset($dwooData->var)
|
||||
*
|
||||
* @see Dwoo_Data::__isset()
|
||||
* @param string $name the variable name
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
return $this->getDataProvider()->__isset($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraper for Dwoo_Data::_unset()
|
||||
* supports unsetting variables using the object syntax
|
||||
*
|
||||
* @see Dwoo_Data::__unset()
|
||||
* @param string $name the variable name
|
||||
*/
|
||||
public function __unset($name)
|
||||
{
|
||||
$this->getDataProvider()->__unset($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Catches clone request and clones data provider
|
||||
*/
|
||||
public function __clone() {
|
||||
$this->setDataProvider(clone $this->getDataProvider());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns plugin proxy interface
|
||||
*
|
||||
* @return Dwoo_IPluginProxy
|
||||
*/
|
||||
public function getPluginProxy()
|
||||
{
|
||||
if (!$this->_pluginProxy) {
|
||||
$this->_pluginProxy = new Dwoo_Adapters_ZendFramework_PluginProxy($this);
|
||||
}
|
||||
|
||||
return $this->_pluginProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets plugin proxy
|
||||
*
|
||||
* @param Dwoo_IPluginProxy
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function setPluginProxy(Dwoo_IPluginProxy $pluginProxy)
|
||||
{
|
||||
$this->_pluginProxy = $pluginProxy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets template engine
|
||||
*
|
||||
* @param string|Dwoo Object or name of the class
|
||||
*/
|
||||
public function setEngine($engine)
|
||||
{
|
||||
// if param given as an object
|
||||
if ($engine instanceof Dwoo) {
|
||||
$this->_engine = $engine;
|
||||
}
|
||||
//
|
||||
elseif (is_subclass_of($engine, 'Dwoo') || 'Dwoo' === $engine) {
|
||||
$this->_engine = new $engine();
|
||||
}
|
||||
else {
|
||||
throw new Dwoo_Exception("Custom engine must be a subclass of Dwoo");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Dwoo template engine object
|
||||
*
|
||||
* @return Dwoo
|
||||
*/
|
||||
public function getEngine()
|
||||
{
|
||||
if (null === $this->_engine) {
|
||||
$this->_engine = new Dwoo();
|
||||
}
|
||||
|
||||
return $this->_engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Dwoo data object
|
||||
*
|
||||
* @param string|Dwoo_Data Object or name of the class
|
||||
*/
|
||||
public function setDataProvider($data)
|
||||
{
|
||||
if ($data instanceof Dwoo_IDataProvider) {
|
||||
$this->_dataProvider = $data;
|
||||
}
|
||||
elseif (is_subclass_of($data, 'Dwoo_Data') || 'Dwoo_Data' == $data) {
|
||||
$this->_dataProvider = new $data();
|
||||
}
|
||||
else {
|
||||
throw new Dwoo_Exception("Custom data provider must be a subclass of Dwoo_Data or instance of Dwoo_IDataProvider");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Dwoo data object
|
||||
*
|
||||
* @return Dwoo_Data
|
||||
*/
|
||||
public function getDataProvider()
|
||||
{
|
||||
if (null === $this->_dataProvider) {
|
||||
$this->_dataProvider = new Dwoo_Data;
|
||||
}
|
||||
|
||||
return $this->_dataProvider;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets Dwoo compiler
|
||||
*
|
||||
* @param string|Dwoo_Compiler Object or name of the class
|
||||
*/
|
||||
public function setCompiler($compiler)
|
||||
{
|
||||
|
||||
// if param given as an object
|
||||
if ($compiler instanceof Dwoo_ICompiler) {
|
||||
$this->_compiler = $compiler;
|
||||
}
|
||||
// if param given as a string
|
||||
elseif (is_subclass_of($compiler, 'Dwoo_Compiler') || 'Dwoo_Compiler' == $compiler) {
|
||||
$this->_compiler = new $compiler;
|
||||
}
|
||||
else {
|
||||
throw new Dwoo_Exception("Custom compiler must be a subclass of Dwoo_Compiler or instance of Dwoo_ICompiler");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Dwoo compiler object
|
||||
*
|
||||
* @return Dwoo_Data
|
||||
*/
|
||||
public function getCompiler()
|
||||
{
|
||||
if (null === $this->_compiler) {
|
||||
$this->_compiler = Dwoo_Compiler::compilerFactory();
|
||||
}
|
||||
|
||||
return $this->_compiler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes Dwoo_ITemplate type of class and sets properties from _templateFileSettings
|
||||
*
|
||||
* @param string Template location
|
||||
* @return Dwoo_ITemplate
|
||||
*/
|
||||
public function getTemplateFile($template) {
|
||||
$templateFileClass = $this->_templateFileClass;
|
||||
|
||||
$dwooTemplateFile = new $templateFileClass($template);
|
||||
|
||||
if (!($dwooTemplateFile instanceof Dwoo_ITemplate)) {
|
||||
throw new Dwoo_Exception("Custom templateFile class must be a subclass of Dwoo_ITemplate");
|
||||
}
|
||||
|
||||
foreach ($this->_templateFileSettings as $method => $value) {
|
||||
if (method_exists($dwooTemplateFile, 'set' . $method)) {
|
||||
call_user_func(array($dwooTemplateFile, 'set' . $method), $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $dwooTemplateFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dwoo_ITemplate type of class
|
||||
*
|
||||
* @param string Name of the class
|
||||
* @return void
|
||||
*/
|
||||
public function setTemplateFile($tempateFileClass) {
|
||||
$this->_templateFileClass = $tempateFileClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes data to Dwoo_Data object
|
||||
*
|
||||
* @see Dwoo_Data::assign()
|
||||
* @param array|string $name
|
||||
* @param mixed $val
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function assign($name, $val = null)
|
||||
{
|
||||
$this->getDataProvider()->assign($name, $val);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of all assigned variables
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getVars()
|
||||
{
|
||||
return $this->_dataProvider->getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all assigned variables
|
||||
*
|
||||
* Clears all variables assigned to Zend_View either via {@link assign()} or
|
||||
* property overloading ({@link __get()}/{@link __set()}).
|
||||
*
|
||||
* @return void
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function clearVars()
|
||||
{
|
||||
$this->getDataProvider()->clear();
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraper for parent's render method so preRender method
|
||||
* can be called (that will bind the plugin proxy to the
|
||||
* engine.
|
||||
*
|
||||
* @see Zend_View_Abstract::render
|
||||
* @return string The script output.
|
||||
*/
|
||||
public function render($name)
|
||||
{
|
||||
$this->preRender();
|
||||
return parent::render($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a view script and outputs it. Output is then
|
||||
* passed through filters.
|
||||
*
|
||||
* @param string $name The script script name to process.
|
||||
* @return string The script output.
|
||||
*/
|
||||
public function _run()
|
||||
{
|
||||
echo $this->_engine->get(
|
||||
$this->getTemplateFile(func_get_arg(0)),
|
||||
$this->getDataProvider(),
|
||||
$this->getCompiler()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add plugin path
|
||||
*
|
||||
* @param string $dir Directory
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function addPluginDir($dir)
|
||||
{
|
||||
$this->getEngine()->getLoader()->addDirectory($dir);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set compile path
|
||||
*
|
||||
* @param string $dir Directory
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function setCompileDir($dir)
|
||||
{
|
||||
$this->getEngine()->setCompileDir($dir);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache path
|
||||
*
|
||||
* @param string $dir Directory
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function setCacheDir($dir)
|
||||
{
|
||||
$this->getEngine()->setCacheDir($dir);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache lifetime
|
||||
*
|
||||
* @param string $seconds Lifetime in seconds
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function setCacheLifetime($seconds)
|
||||
{
|
||||
$this->getEngine()->setCacheTime($seconds);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set charset
|
||||
*
|
||||
* @param string $charset
|
||||
* @return Dwoo_Adapters_ZendFramework_View
|
||||
*/
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$this->_engine->setCharset($charset);
|
||||
return $this;
|
||||
}
|
||||
}
|
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* base class for block plugins
|
||||
*
|
||||
* you have to implement the <em>init()</em> method, it will receive the parameters that
|
||||
* are in the template code and is called when the block starts
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
abstract class Dwoo_Block_Plugin extends Dwoo_Plugin
|
||||
{
|
||||
/**
|
||||
* stores the contents of the block while it runs
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $buffer = '';
|
||||
|
||||
/**
|
||||
* buffers input, override only if necessary
|
||||
*
|
||||
* @var string $input the content that must be buffered
|
||||
*/
|
||||
public function buffer($input)
|
||||
{
|
||||
$this->buffer .= $input;
|
||||
}
|
||||
|
||||
// initialization code, receives the parameters from {block param1 param2}
|
||||
// public function init($arg, $arg, ...);
|
||||
|
||||
/**
|
||||
* called when the block ends, this is most of the time followed right away by a call
|
||||
* of <em>process()</em> but not always, so this should be used to do any shutdown operations on the
|
||||
* block object, if required.
|
||||
*/
|
||||
public function end()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* called when the block output is required by a parent block
|
||||
*
|
||||
* this must read $this->buffer and return it processed
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function process()
|
||||
{
|
||||
return $this->buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* called at compile time to define what the block should output in the compiled template code, happens when the block is declared
|
||||
*
|
||||
* basically this will replace the {block arg arg arg} tag in the template
|
||||
*
|
||||
* @param Dwoo_Compiler $compiler the compiler instance that calls this function
|
||||
* @param array $params an array containing original and compiled parameters
|
||||
* @param string $prepend that is just meant to allow a child class to call
|
||||
* parent::postProcessing($compiler, $params, "foo();") to add a command before the
|
||||
* default commands are executed
|
||||
* @param string $append that is just meant to allow a child class to call
|
||||
* parent::postProcessing($compiler, $params, null, "foo();") to add a command after the
|
||||
* default commands are executed
|
||||
* @param string $type the type is the plugin class name used
|
||||
*/
|
||||
public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type)
|
||||
{
|
||||
return Dwoo_Compiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.Dwoo_Compiler::implode_r($compiler->getCompiledParams($params)).'));'.$append.Dwoo_Compiler::PHP_CLOSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* called at compile time to define what the block should output in the compiled template code, happens when the block is ended
|
||||
*
|
||||
* basically this will replace the {/block} tag in the template
|
||||
*
|
||||
* @see preProcessing
|
||||
* @param Dwoo_Compiler $compiler the compiler instance that calls this function
|
||||
* @param array $params an array containing original and compiled parameters, see preProcessing() for more details
|
||||
* @param string $prepend that is just meant to allow a child class to call
|
||||
* parent::postProcessing($compiler, $params, "foo();") to add a command before the
|
||||
* default commands are executed
|
||||
* @param string $append that is just meant to allow a child class to call
|
||||
* parent::postProcessing($compiler, $params, null, "foo();") to add a command after the
|
||||
* default commands are executed
|
||||
* @param string $content the entire content of the block being closed
|
||||
*/
|
||||
public static function postProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $content)
|
||||
{
|
||||
return $content . Dwoo_Compiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.Dwoo_Compiler::PHP_CLOSE;
|
||||
}
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* dwoo compilation exception class
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Compilation_Exception extends Dwoo_Exception
|
||||
{
|
||||
protected $compiler;
|
||||
protected $template;
|
||||
|
||||
public function __construct(Dwoo_Compiler $compiler, $message)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->template = $compiler->getDwoo()->getTemplate();
|
||||
parent::__construct('Compilation error at line '.$compiler->getLine().' in "'.$this->template->getResourceName().':'.$this->template->getResourceIdentifier().'" : '.$message);
|
||||
}
|
||||
|
||||
public function getCompiler()
|
||||
{
|
||||
return $this->compiler;
|
||||
}
|
||||
|
||||
public function getTemplate()
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
}
|
@@ -1,250 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* dwoo data object, use it for complex data assignments or if you want to easily pass it
|
||||
* around multiple functions to avoid passing an array by reference
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Data implements Dwoo_IDataProvider
|
||||
{
|
||||
/**
|
||||
* data array
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
/**
|
||||
* returns the data array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* clears a the entire data or only the given key
|
||||
*
|
||||
* @param array|string $name clears only one value if you give a name, multiple values if
|
||||
* you give an array of names, or the entire data if left null
|
||||
*/
|
||||
public function clear($name = null)
|
||||
{
|
||||
if ($name === null) {
|
||||
$this->data = array();
|
||||
} elseif (is_array($name)) {
|
||||
foreach ($name as $index)
|
||||
unset($this->data[$index]);
|
||||
} else {
|
||||
unset($this->data[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* overwrites the entire data with the given array
|
||||
*
|
||||
* @param array $data the new data array to use
|
||||
*/
|
||||
public function setData(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* merges the given array(s) with the current data with array_merge
|
||||
*
|
||||
* @param array $data the array to merge
|
||||
* @param array $data2 $data3 ... other arrays to merge, optional, etc.
|
||||
*/
|
||||
public function mergeData(array $data)
|
||||
{
|
||||
$args = func_get_args();
|
||||
while (list(,$v) = each($args)) {
|
||||
if (is_array($v)) {
|
||||
$this->data = array_merge($this->data, $v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* assigns a value or an array of values to the data object
|
||||
*
|
||||
* @param array|string $name an associative array of multiple (index=>value) or a string
|
||||
* that is the index to use, i.e. a value assigned to "foo" will be
|
||||
* accessible in the template through {$foo}
|
||||
* @param mixed $val the value to assign, or null if $name was an array
|
||||
*/
|
||||
public function assign($name, $val = null)
|
||||
{
|
||||
if (is_array($name)) {
|
||||
reset($name);
|
||||
while (list($k,$v) = each($name))
|
||||
$this->data[$k] = $v;
|
||||
} else {
|
||||
$this->data[$name] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* allows to assign variables using the object syntax
|
||||
*
|
||||
* @param string $name the variable name
|
||||
* @param string $value the value to assign to it
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->assign($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* assigns a value by reference to the data object
|
||||
*
|
||||
* @param string $name the index to use, i.e. a value assigned to "foo" will be
|
||||
* accessible in the template through {$foo}
|
||||
* @param mixed $val the value to assign by reference
|
||||
*/
|
||||
public function assignByRef($name, &$val)
|
||||
{
|
||||
$this->data[$name] =& $val;
|
||||
}
|
||||
|
||||
/**
|
||||
* appends values or an array of values to the data object
|
||||
*
|
||||
* @param array|string $name an associative array of multiple (index=>value) or a string
|
||||
* that is the index to use, i.e. a value assigned to "foo" will be
|
||||
* accessible in the template through {$foo}
|
||||
* @param mixed $val the value to assign, or null if $name was an array
|
||||
* @param bool $merge true to merge data or false to append, defaults to false
|
||||
*/
|
||||
public function append($name, $val = null, $merge = false)
|
||||
{
|
||||
if (is_array($name)) {
|
||||
foreach ($name as $key=>$val) {
|
||||
if (isset($this->data[$key]) && !is_array($this->data[$key])) {
|
||||
settype($this->data[$key], 'array');
|
||||
}
|
||||
|
||||
if ($merge === true && is_array($val)) {
|
||||
$this->data[$key] = $val + $this->data[$key];
|
||||
} else {
|
||||
$this->data[$key][] = $val;
|
||||
}
|
||||
}
|
||||
} elseif ($val !== null) {
|
||||
if (isset($this->data[$name]) && !is_array($this->data[$name])) {
|
||||
settype($this->data[$name], 'array');
|
||||
} elseif (!isset($this->data[$name])) {
|
||||
$this->data[$name] = array();
|
||||
}
|
||||
|
||||
if ($merge === true && is_array($val)) {
|
||||
$this->data[$name] = $val + $this->data[$name];
|
||||
} else {
|
||||
$this->data[$name][] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* appends a value by reference to the data object
|
||||
*
|
||||
* @param string $name the index to use, i.e. a value assigned to "foo" will be
|
||||
* accessible in the template through {$foo}
|
||||
* @param mixed $val the value to append by reference
|
||||
* @param bool $merge true to merge data or false to append, defaults to false
|
||||
*/
|
||||
public function appendByRef($name, &$val, $merge = false)
|
||||
{
|
||||
if (isset($this->data[$name]) && !is_array($this->data[$name])) {
|
||||
settype($this->data[$name], 'array');
|
||||
}
|
||||
|
||||
if ($merge === true && is_array($val)) {
|
||||
foreach ($val as $key => &$val) {
|
||||
$this->data[$name][$key] =& $val;
|
||||
}
|
||||
} else {
|
||||
$this->data[$name][] =& $val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true if the variable has been assigned already, false otherwise
|
||||
*
|
||||
* @param string $name the variable name
|
||||
* @return bool
|
||||
*/
|
||||
public function isAssigned($name)
|
||||
{
|
||||
return isset($this->data[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* supports calls to isset($dwooData->var)
|
||||
*
|
||||
* @param string $name the variable name
|
||||
*/
|
||||
public function __isset($name)
|
||||
{
|
||||
return isset($this->data[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* unassigns/removes a variable
|
||||
*
|
||||
* @param string $name the variable name
|
||||
*/
|
||||
public function unassign($name)
|
||||
{
|
||||
unset($this->data[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* supports unsetting variables using the object syntax
|
||||
*
|
||||
* @param string $name the variable name
|
||||
*/
|
||||
public function __unset($name)
|
||||
{
|
||||
unset($this->data[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a variable if it was assigned
|
||||
*
|
||||
* @param string $name the variable name
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($name)
|
||||
{
|
||||
return $this->__get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* allows to read variables using the object syntax
|
||||
*
|
||||
* @param string $name the variable name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (isset($this->data[$name])) {
|
||||
return $this->data[$name];
|
||||
} else {
|
||||
throw new Dwoo_Exception('Tried to read a value that was not assigned yet : "'.$name.'"');
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* main dwoo exception class
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Exception extends Exception
|
||||
{
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* base class for filters
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
abstract class Dwoo_Filter
|
||||
{
|
||||
/**
|
||||
* the dwoo instance that runs this filter
|
||||
*
|
||||
* @var Dwoo
|
||||
*/
|
||||
protected $dwoo;
|
||||
|
||||
/**
|
||||
* constructor, if you override it, call parent::__construct($dwoo); or assign
|
||||
* the dwoo instance yourself if you need it
|
||||
*
|
||||
* @param Dwoo $dwoo the dwoo instance that runs this plugin
|
||||
*/
|
||||
public function __construct(Dwoo $dwoo)
|
||||
{
|
||||
$this->dwoo = $dwoo;
|
||||
}
|
||||
|
||||
/**
|
||||
* processes the input and returns it filtered
|
||||
*
|
||||
* @param string $input the template to process
|
||||
* @return string
|
||||
*/
|
||||
abstract public function process($input);
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* interface that represents a compilable plugin
|
||||
*
|
||||
* implement this to notify the compiler that this plugin does not need to be loaded at runtime.
|
||||
*
|
||||
* to implement it right, you must implement <em>public static function compile(Dwoo_Compiler $compiler, $arg, $arg, ...)</em>,
|
||||
* which replaces the <em>process()</em> method (that means <em>compile()</em> should have all arguments it requires).
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
interface Dwoo_ICompilable
|
||||
{
|
||||
// this replaces the process function
|
||||
//public static function compile(Dwoo_Compiler $compiler, $arg, $arg, ...);
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* interface that represents a compilable block plugin
|
||||
*
|
||||
* implement this to notify the compiler that this plugin does not need to be loaded at runtime.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
interface Dwoo_ICompilable_Block
|
||||
{
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* interface that represents a dwoo compiler
|
||||
*
|
||||
* while implementing this is enough to interact with Dwoo/Dwoo_Templates, it is not
|
||||
* sufficient to interact with Dwoo_Plugins, however the main purpose of creating a
|
||||
* new compiler would be to interact with other/different plugins, that is why this
|
||||
* interface has been left with the minimum requirements.
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
interface Dwoo_ICompiler
|
||||
{
|
||||
/**
|
||||
* compiles the provided string down to php code
|
||||
*
|
||||
* @param string $templateStr the template to compile
|
||||
* @return string a compiled php code string
|
||||
*/
|
||||
public function compile(Dwoo $dwoo, Dwoo_ITemplate $template);
|
||||
|
||||
/**
|
||||
* adds the custom plugins loaded into Dwoo to the compiler so it can load them
|
||||
*
|
||||
* @see Dwoo::addPlugin
|
||||
* @param array $customPlugins an array of custom plugins
|
||||
*/
|
||||
public function setCustomPlugins(array $customPlugins);
|
||||
|
||||
/**
|
||||
* sets the security policy object to enforce some php security settings
|
||||
*
|
||||
* use this if untrusted persons can modify templates,
|
||||
* set it on the Dwoo object as it will be passed onto the compiler automatically
|
||||
*
|
||||
* @param Dwoo_Security_Policy $policy the security policy object
|
||||
*/
|
||||
public function setSecurityPolicy(Dwoo_Security_Policy $policy = null);
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* interface that represents a dwoo data object
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
interface Dwoo_IDataProvider
|
||||
{
|
||||
/**
|
||||
* returns the data as an associative array that will be used in the template
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData();
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* interface that represents a block plugin that supports the else functionality
|
||||
*
|
||||
* the else block will enter an "hasElse" parameter inside the parameters array
|
||||
* of the closest parent implementing this interface, the hasElse parameter contains
|
||||
* the else output that should be appended to the block's content (see foreach or other
|
||||
* block for examples)
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
interface Dwoo_IElseable
|
||||
{
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* interface for dwoo plugin loaders
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
interface Dwoo_ILoader
|
||||
{
|
||||
/**
|
||||
* loads a plugin file
|
||||
*
|
||||
* the second parameter is used to avoid permanent rehashing when using php functions,
|
||||
* however this means that if you have add a plugin that overrides a php function you have
|
||||
* to delete the classpath.cache file(s) by hand to force a rehash of the plugins
|
||||
*
|
||||
* @param string $class the plugin name, without the Dwoo_Plugin_ prefix
|
||||
* @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it has just been added, defaults to true
|
||||
*/
|
||||
public function loadPlugin($class, $forceRehash = true);
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* interface that represents a dwoo plugin proxy
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Denis Arh <denis@arh.cc>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Denis Arh, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
interface Dwoo_IPluginProxy
|
||||
{
|
||||
/**
|
||||
* returns true or false to say whether the given plugin is handled by this proxy or not
|
||||
*
|
||||
* @param string $name the plugin name
|
||||
* @return bool true if the plugin is known and usable, otherwise false
|
||||
*/
|
||||
public function handles($name);
|
||||
|
||||
/**
|
||||
* returns the code (as a string) to call the plugin
|
||||
* (this will be executed at runtime inside the Dwoo class)
|
||||
*
|
||||
* @param string $name the plugin name
|
||||
* @param array $params a parameter array, array key "*" is the rest array
|
||||
* @return string
|
||||
*/
|
||||
public function getCode($name, $params);
|
||||
|
||||
/**
|
||||
* returns a callback to the plugin, this is used with the reflection API to
|
||||
* find out about the plugin's parameter names etc.
|
||||
*
|
||||
* should you need a rest array without the possibility to edit the
|
||||
* plugin's code, you can provide a callback to some
|
||||
* other function with the correct parameter signature, i.e. :
|
||||
* <code>
|
||||
* return array($this, "callbackHelper");
|
||||
* // and callbackHelper would be as such:
|
||||
* public function callbackHelper(array $rest=array()){}
|
||||
* </code>
|
||||
*
|
||||
* @param string $name the plugin name
|
||||
* @return callback
|
||||
*/
|
||||
public function getCallback($name);
|
||||
|
||||
/**
|
||||
* returns some code that will check if the plugin is loaded and if not load it
|
||||
* this is optional, if your plugins are autoloaded or whatever, just return an
|
||||
* empty string
|
||||
*
|
||||
* @param string $name the plugin name
|
||||
* @return string
|
||||
*/
|
||||
public function getLoader($name);
|
||||
}
|
@@ -1,150 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* interface that represents a dwoo template
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.1.0
|
||||
* @date 2009-07-18
|
||||
* @package Dwoo
|
||||
*/
|
||||
interface Dwoo_ITemplate
|
||||
{
|
||||
/**
|
||||
* returns the cache duration for this template
|
||||
*
|
||||
* defaults to null if it was not provided
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCacheTime();
|
||||
|
||||
/**
|
||||
* sets the cache duration for this template
|
||||
*
|
||||
* can be used to set it after the object is created if you did not provide
|
||||
* it in the constructor
|
||||
*
|
||||
* @param int $seconds duration of the cache validity for this template, if
|
||||
* null it defaults to the Dwoo instance's cache time. 0 = disable and
|
||||
* -1 = infinite cache
|
||||
*/
|
||||
public function setCacheTime($seconds = null);
|
||||
|
||||
/**
|
||||
* returns the cached template output file name, true if it's cache-able but not cached
|
||||
* or false if it's not cached
|
||||
*
|
||||
* @param Dwoo $dwoo the dwoo instance that requests it
|
||||
* @return string|bool
|
||||
*/
|
||||
public function getCachedTemplate(Dwoo $dwoo);
|
||||
|
||||
/**
|
||||
* caches the provided output into the cache file
|
||||
*
|
||||
* @param Dwoo $dwoo the dwoo instance that requests it
|
||||
* @param string $output the template output
|
||||
* @return mixed full path of the cached file or false upon failure
|
||||
*/
|
||||
public function cache(Dwoo $dwoo, $output);
|
||||
|
||||
/**
|
||||
* clears the cached template if it's older than the given time
|
||||
*
|
||||
* @param Dwoo $dwoo the dwoo instance that was used to cache that template
|
||||
* @param int $olderThan minimum time (in seconds) required for the cache to be cleared
|
||||
* @return bool true if the cache was not present or if it was deleted, false if it remains there
|
||||
*/
|
||||
public function clearCache(Dwoo $dwoo, $olderThan = -1);
|
||||
|
||||
/**
|
||||
* returns the compiled template file name
|
||||
*
|
||||
* @param Dwoo $dwoo the dwoo instance that requests it
|
||||
* @param Dwoo_ICompiler $compiler the compiler that must be used
|
||||
* @return string
|
||||
*/
|
||||
public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null);
|
||||
|
||||
/**
|
||||
* returns the template name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* returns the resource name for this template class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName();
|
||||
|
||||
/**
|
||||
* returns the resource identifier for this template or false if it has no identifier
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public function getResourceIdentifier();
|
||||
|
||||
/**
|
||||
* returns the template source of this template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource();
|
||||
|
||||
/**
|
||||
* returns an unique string identifying the current version of this template,
|
||||
* for example a timestamp of the last modified date or a hash of the template source
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUid();
|
||||
|
||||
/**
|
||||
* returns the compiler used by this template, if it was just compiled, or null
|
||||
*
|
||||
* @return Dwoo_ICompiler
|
||||
*/
|
||||
public function getCompiler();
|
||||
|
||||
/**
|
||||
* returns some php code that will check if this template has been modified or not
|
||||
*
|
||||
* if the function returns null, the template will be instanciated and then the Uid checked
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIsModifiedCode();
|
||||
|
||||
/**
|
||||
* returns a new template object from the given resource identifier, null if no include is
|
||||
* possible (resource not found), or false if include is not permitted by this resource type
|
||||
*
|
||||
* this method should also check if $dwoo->getSecurityPolicy() is null or not and do the
|
||||
* necessary permission checks if required, if the security policy prevents the template
|
||||
* generation it should throw a new Dwoo_Security_Exception with a relevant message
|
||||
*
|
||||
* @param mixed $resourceId the resource identifier
|
||||
* @param int $cacheTime duration of the cache validity for this template,
|
||||
* if null it defaults to the Dwoo instance that will
|
||||
* render this template
|
||||
* @param string $cacheId the unique cache identifier of this page or anything else that
|
||||
* makes this template's content unique, if null it defaults
|
||||
* to the current url
|
||||
* @param string $compileId the unique compiled identifier, which is used to distinguish this
|
||||
* template from others, if null it defaults to the filename+bits of the path
|
||||
* @param Dwoo_ITemplate $parentTemplate the template that is requesting a new template object (through
|
||||
* an include, extends or any other plugin)
|
||||
* @return Dwoo_ITemplate|null|false
|
||||
*/
|
||||
public static function templateFactory(Dwoo $dwoo, $resourceId, $cacheTime = null, $cacheId = null, $compileId = null, Dwoo_ITemplate $parentTemplate = null);
|
||||
}
|
@@ -1,147 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* handles plugin loading and caching of plugins names/paths relationships
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.1.0
|
||||
* @date 2009-07-18
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Loader implements Dwoo_ILoader
|
||||
{
|
||||
/**
|
||||
* stores the plugin directories
|
||||
*
|
||||
* @see addDirectory
|
||||
* @var array
|
||||
*/
|
||||
protected $paths = array();
|
||||
|
||||
/**
|
||||
* stores the plugins names/paths relationships
|
||||
* don't edit this on your own, use addDirectory
|
||||
*
|
||||
* @see addDirectory
|
||||
* @var array
|
||||
*/
|
||||
protected $classPath = array();
|
||||
|
||||
/**
|
||||
* path where class paths cache files are written
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $cacheDir;
|
||||
|
||||
protected $corePluginDir;
|
||||
|
||||
public function __construct($cacheDir)
|
||||
{
|
||||
$this->corePluginDir = DWOO_DIRECTORY . 'plugins';
|
||||
$this->cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
|
||||
// include class paths or rebuild paths if the cache file isn't there
|
||||
$cacheFile = $this->cacheDir.'classpath.cache.d'.Dwoo::RELEASE_TAG.'.php';
|
||||
if (file_exists($cacheFile)) {
|
||||
$classpath = file_get_contents($cacheFile);
|
||||
$this->classPath = unserialize($classpath) + $this->classPath;
|
||||
} else {
|
||||
$this->rebuildClassPathCache($this->corePluginDir, $cacheFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* rebuilds class paths, scans the given directory recursively and saves all paths in the given file
|
||||
*
|
||||
* @param string $path the plugin path to scan
|
||||
* @param string $cacheFile the file where to store the plugin paths cache, it will be overwritten
|
||||
*/
|
||||
protected function rebuildClassPathCache($path, $cacheFile)
|
||||
{
|
||||
if ($cacheFile!==false) {
|
||||
$tmp = $this->classPath;
|
||||
$this->classPath = array();
|
||||
}
|
||||
|
||||
// iterates over all files/folders
|
||||
$list = glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*');
|
||||
if (is_array($list)) {
|
||||
foreach ($list as $f) {
|
||||
if (is_dir($f)) {
|
||||
$this->rebuildClassPathCache($f, false);
|
||||
} else {
|
||||
$this->classPath[str_replace(array('function.','block.','modifier.','outputfilter.','filter.','prefilter.','postfilter.','pre.','post.','output.','shared.','helper.'), '', basename($f, '.php'))] = $f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save in file if it's the first call (not recursed)
|
||||
if ($cacheFile!==false) {
|
||||
if (!file_put_contents($cacheFile, serialize($this->classPath))) {
|
||||
throw new Dwoo_Exception('Could not write into '.$cacheFile.', either because the folder is not there (create it) or because of the chmod configuration (please ensure this directory is writable by php), alternatively you can change the directory used with $dwoo->setCompileDir() or provide a custom loader object with $dwoo->setLoader()');
|
||||
}
|
||||
$this->classPath += $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* loads a plugin file
|
||||
*
|
||||
* @param string $class the plugin name, without the Dwoo_Plugin_ prefix
|
||||
* @param bool $forceRehash if true, the class path caches will be rebuilt if the plugin is not found, in case it has just been added, defaults to true
|
||||
*/
|
||||
public function loadPlugin($class, $forceRehash = true)
|
||||
{
|
||||
// a new class was added or the include failed so we rebuild the cache
|
||||
if (!isset($this->classPath[$class]) || !(include $this->classPath[$class])) {
|
||||
if ($forceRehash) {
|
||||
$this->rebuildClassPathCache($this->corePluginDir, $this->cacheDir . 'classpath.cache.d'.Dwoo::RELEASE_TAG.'.php');
|
||||
foreach ($this->paths as $path=>$file) {
|
||||
$this->rebuildClassPathCache($path, $file);
|
||||
}
|
||||
if (isset($this->classPath[$class])) {
|
||||
include $this->classPath[$class];
|
||||
} else {
|
||||
throw new Dwoo_Exception('Plugin <em>'.$class.'</em> can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
throw new Dwoo_Exception('Plugin <em>'.$class.'</em> can not be found, maybe you forgot to bind it if it\'s a custom plugin ?', E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a plugin directory, the plugins found in the new plugin directory
|
||||
* will take precedence over the other directories (including the default
|
||||
* dwoo plugin directory), you can use this for example to override plugins
|
||||
* in a specific directory for a specific application while keeping all your
|
||||
* usual plugins in the same place for all applications.
|
||||
*
|
||||
* TOCOM don't forget that php functions overrides are not rehashed so you
|
||||
* need to clear the classpath caches by hand when adding those
|
||||
*
|
||||
* @param string $pluginDirectory the plugin path to scan
|
||||
*/
|
||||
public function addDirectory($pluginDirectory)
|
||||
{
|
||||
$pluginDir = realpath($pluginDirectory);
|
||||
if (!$pluginDir) {
|
||||
throw new Dwoo_Exception('Plugin directory does not exist or can not be read : '.$pluginDirectory);
|
||||
}
|
||||
$cacheFile = $this->cacheDir . 'classpath-'.substr(strtr($pluginDir, '/\\:'.PATH_SEPARATOR, '----'), strlen($pluginDir) > 80 ? -80 : 0).'.d'.Dwoo::RELEASE_TAG.'.php';
|
||||
$this->paths[$pluginDir] = $cacheFile;
|
||||
if (file_exists($cacheFile)) {
|
||||
$classpath = file_get_contents($cacheFile);
|
||||
$this->classPath = unserialize($classpath) + $this->classPath;
|
||||
} else {
|
||||
$this->rebuildClassPathCache($pluginDir, $cacheFile);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* base plugin class
|
||||
*
|
||||
* you have to implement the <em>process()</em> method, it will receive the parameters that
|
||||
* are in the template code
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
abstract class Dwoo_Plugin
|
||||
{
|
||||
/**
|
||||
* the dwoo instance that runs this plugin
|
||||
*
|
||||
* @var Dwoo
|
||||
*/
|
||||
protected $dwoo;
|
||||
|
||||
/**
|
||||
* constructor, if you override it, call parent::__construct($dwoo); or assign
|
||||
* the dwoo instance yourself if you need it
|
||||
*
|
||||
* @param Dwoo $dwoo the dwoo instance that runs this plugin
|
||||
*/
|
||||
public function __construct(Dwoo $dwoo)
|
||||
{
|
||||
$this->dwoo = $dwoo;
|
||||
}
|
||||
|
||||
// plugins should always implement :
|
||||
// public function process($arg, $arg, ...)
|
||||
// or for block plugins :
|
||||
// public function init($arg, $arg, ...)
|
||||
|
||||
// this could be enforced with :
|
||||
// abstract public function process(...);
|
||||
// if my feature request gets enough interest one day
|
||||
// see => http://bugs.php.net/bug.php?id=44043
|
||||
|
||||
/**
|
||||
* utility function that converts an array of compiled parameters (or rest array) to a string of xml/html tag attributes
|
||||
*
|
||||
* this is to be used in preProcessing or postProcessing functions, example :
|
||||
* $p = $compiler->getCompiledParams($params);
|
||||
* // get only the rest array as attributes
|
||||
* $attributes = Dwoo_Plugin::paramsToAttributes($p['*']);
|
||||
* // get all the parameters as attributes (if there is a rest array, it will be included)
|
||||
* $attributes = Dwoo_Plugin::paramsToAttributes($p);
|
||||
*
|
||||
* @param array $params an array of attributeName=>value items that will be compiled to be ready for inclusion in a php string
|
||||
* @param string $delim the string delimiter you want to use (defaults to ')
|
||||
* @return string
|
||||
*/
|
||||
public static function paramsToAttributes(array $params, $delim = '\'')
|
||||
{
|
||||
if (isset($params['*'])) {
|
||||
$params = array_merge($params, $params['*']);
|
||||
unset($params['*']);
|
||||
}
|
||||
|
||||
$out = '';
|
||||
foreach ($params as $attr=>$val) {
|
||||
$out .= ' '.$attr.'=';
|
||||
if (trim($val, '"\'')=='' || $val=='null') {
|
||||
$out .= str_replace($delim, '\\'.$delim, '""');
|
||||
} elseif (substr($val, 0, 1) === $delim && substr($val, -1) === $delim) {
|
||||
$out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, -1).'"');
|
||||
} else {
|
||||
$out .= str_replace($delim, '\\'.$delim, '"') . $delim . '.'.$val.'.' . $delim . str_replace($delim, '\\'.$delim, '"');
|
||||
}
|
||||
}
|
||||
|
||||
return ltrim($out);
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* base class for processors
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
abstract class Dwoo_Processor
|
||||
{
|
||||
/**
|
||||
* the compiler instance that runs this processor
|
||||
*
|
||||
* @var Dwoo
|
||||
*/
|
||||
protected $compiler;
|
||||
|
||||
/**
|
||||
* constructor, if you override it, call parent::__construct($dwoo); or assign
|
||||
* the dwoo instance yourself if you need it
|
||||
*
|
||||
* @param Dwoo $dwoo the dwoo instance that runs this plugin
|
||||
*/
|
||||
public function __construct(Dwoo_Compiler $compiler)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
}
|
||||
|
||||
/**
|
||||
* processes the input and returns it filtered
|
||||
*
|
||||
* @param string $input the template to process
|
||||
* @return string
|
||||
*/
|
||||
abstract public function process($input);
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* dwoo security exception class
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Security_Exception extends Dwoo_Exception
|
||||
{
|
||||
}
|
@@ -1,199 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* represents the security settings of a dwoo instance, it can be passed around to different dwoo instances
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Security_Policy
|
||||
{
|
||||
/**#@+
|
||||
* php handling constants, defaults to PHP_REMOVE
|
||||
*
|
||||
* PHP_REMOVE : remove all <?php ?> (+ short tags if your short tags option is on) from the input template
|
||||
* PHP_ALLOW : leave them as they are
|
||||
* PHP_ENCODE : run htmlentities over them
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const PHP_ENCODE = 1;
|
||||
const PHP_REMOVE = 2;
|
||||
const PHP_ALLOW = 3;
|
||||
/**#@-*/
|
||||
|
||||
/**#@+
|
||||
* constant handling constants, defaults to CONST_DISALLOW
|
||||
*
|
||||
* CONST_DISALLOW : throw an error if {$dwoo.const.*} is used in the template
|
||||
* CONST_ALLOW : allow {$dwoo.const.*} calls
|
||||
*/
|
||||
const CONST_DISALLOW = false;
|
||||
const CONST_ALLOW = true;
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* php functions that are allowed to be used within the template
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $allowedPhpFunctions = array
|
||||
(
|
||||
'str_repeat', 'number_format', 'htmlentities', 'htmlspecialchars',
|
||||
'long2ip', 'strlen', 'list', 'empty', 'count', 'sizeof', 'in_array', 'is_array',
|
||||
);
|
||||
|
||||
/**
|
||||
* paths that are safe to use with include or other file-access plugins
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $allowedDirectories = array();
|
||||
|
||||
/**
|
||||
* stores the php handling level
|
||||
*
|
||||
* defaults to Dwoo_Security_Policy::PHP_REMOVE
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $phpHandling = self::PHP_REMOVE;
|
||||
|
||||
/**
|
||||
* stores the constant handling level
|
||||
*
|
||||
* defaults to Dwoo_Security_Policy::CONST_DISALLOW
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $constHandling = self::CONST_DISALLOW;
|
||||
|
||||
/**
|
||||
* adds a php function to the allowed list
|
||||
*
|
||||
* @param mixed $func function name or array of function names
|
||||
*/
|
||||
public function allowPhpFunction($func)
|
||||
{
|
||||
if (is_array($func))
|
||||
foreach ($func as $fname)
|
||||
$this->allowedPhpFunctions[strtolower($fname)] = true;
|
||||
else
|
||||
$this->allowedPhpFunctions[strtolower($func)] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a php function from the allowed list
|
||||
*
|
||||
* @param mixed $func function name or array of function names
|
||||
*/
|
||||
public function disallowPhpFunction($func)
|
||||
{
|
||||
if (is_array($func))
|
||||
foreach ($func as $fname)
|
||||
unset($this->allowedPhpFunctions[strtolower($fname)]);
|
||||
else
|
||||
unset($this->allowedPhpFunctions[strtolower($func)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the list of php functions allowed to run, note that the function names
|
||||
* are stored in the array keys and not values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllowedPhpFunctions()
|
||||
{
|
||||
return $this->allowedPhpFunctions;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a directory to the safelist for includes and other file-access plugins
|
||||
*
|
||||
* note that all the includePath directories you provide to the Dwoo_Template_File class
|
||||
* are automatically marked as safe
|
||||
*
|
||||
* @param mixed $path a path name or an array of paths
|
||||
*/
|
||||
public function allowDirectory($path)
|
||||
{
|
||||
if (is_array($path))
|
||||
foreach ($path as $dir)
|
||||
$this->allowedDirectories[realpath($dir)] = true;
|
||||
else
|
||||
$this->allowedDirectories[realpath($path)] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* removes a directory from the safelist
|
||||
*
|
||||
* @param mixed $path a path name or an array of paths
|
||||
*/
|
||||
public function disallowDirectory($path)
|
||||
{
|
||||
if (is_array($path))
|
||||
foreach ($path as $dir)
|
||||
unset($this->allowedDirectories[realpath($dir)]);
|
||||
else
|
||||
unset($this->allowedDirectories[realpath($path)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the list of safe paths, note that the paths are stored in the array
|
||||
* keys and not values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAllowedDirectories()
|
||||
{
|
||||
return $this->allowedDirectories;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the php handling level, defaults to REMOVE
|
||||
*
|
||||
* @param int $level one of the Dwoo_Security_Policy::PHP_* constants
|
||||
*/
|
||||
public function setPhpHandling($level = self::PHP_REMOVE)
|
||||
{
|
||||
$this->phpHandling = $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the php handling level
|
||||
*
|
||||
* @return int the current level, one of the Dwoo_Security_Policy::PHP_* constants
|
||||
*/
|
||||
public function getPhpHandling()
|
||||
{
|
||||
return $this->phpHandling;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the constant handling level, defaults to CONST_DISALLOW
|
||||
*
|
||||
* @param bool $level one of the Dwoo_Security_Policy::CONST_* constants
|
||||
*/
|
||||
public function setConstantHandling($level = self::CONST_DISALLOW)
|
||||
{
|
||||
$this->constHandling = $level;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the constant handling level
|
||||
*
|
||||
* @return bool the current level, one of the Dwoo_Security_Policy::CONST_* constants
|
||||
*/
|
||||
public function getConstantHandling()
|
||||
{
|
||||
return $this->constHandling;
|
||||
}
|
||||
}
|
@@ -1,518 +0,0 @@
|
||||
<?php
|
||||
|
||||
if (!defined('DIR_SEP')) {
|
||||
define('DIR_SEP', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
if (!defined('SMARTY_PHP_PASSTHRU')) {
|
||||
define('SMARTY_PHP_PASSTHRU', 0);
|
||||
define('SMARTY_PHP_QUOTE', 1);
|
||||
define('SMARTY_PHP_REMOVE', 2);
|
||||
define('SMARTY_PHP_ALLOW', 3);
|
||||
}
|
||||
|
||||
if (class_exists('Dwoo_Compiler', false) === false) {
|
||||
require dirname(dirname(__FILE__)) . '/Compiler.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* a Smarty compatibility layer for Dwoo
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.1.0
|
||||
* @date 2009-07-18
|
||||
* @package Dwoo
|
||||
*/
|
||||
class Dwoo_Smarty__Adapter extends Dwoo
|
||||
{
|
||||
// magic get/set/call functions that handle unsupported features
|
||||
public function __set($p, $v)
|
||||
{
|
||||
if ($p==='scope') {
|
||||
$this->scope = $v;
|
||||
return;
|
||||
}
|
||||
if ($p==='data') {
|
||||
$this->data = $v;
|
||||
return;
|
||||
}
|
||||
if (array_key_exists($p, $this->compat['properties']) !== false) {
|
||||
if ($this->show_compat_errors) {
|
||||
$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
|
||||
}
|
||||
$this->compat['properties'][$p] = $v;
|
||||
} else {
|
||||
if ($this->show_compat_errors) {
|
||||
$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __get($p)
|
||||
{
|
||||
if (array_key_exists($p, $this->compat['properties']) !== false) {
|
||||
if ($this->show_compat_errors) {
|
||||
$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
|
||||
}
|
||||
return $this->compat['properties'][$p];
|
||||
} else {
|
||||
if ($this->show_compat_errors) {
|
||||
$this->triggerError('Property '.$p.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function __call($m, $a)
|
||||
{
|
||||
if (method_exists($this->dataProvider, $m)) {
|
||||
call_user_func_array(array($this->dataProvider, $m), $a);
|
||||
} elseif ($this->show_compat_errors) {
|
||||
if (array_search($m, $this->compat['methods']) !== false) {
|
||||
$this->triggerError('Method '.$m.' is not available in the Dwoo_Smarty_Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE);
|
||||
} else {
|
||||
$this->triggerError('Method '.$m.' is not available in the Dwoo_Smarty_Adapter, but it is not listed as such, so you might want to tell me about it at j.boggiano@seld.be', E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// list of unsupported properties and methods
|
||||
protected $compat = array
|
||||
(
|
||||
'methods' => array
|
||||
(
|
||||
'register_resource', 'unregister_resource', 'load_filter', 'clear_compiled_tpl',
|
||||
'clear_config', 'get_config_vars', 'config_load'
|
||||
),
|
||||
'properties' => array
|
||||
(
|
||||
'cache_handler_func' => null,
|
||||
'debugging' => false,
|
||||
'error_reporting' => null,
|
||||
'debugging_ctrl' => 'NONE',
|
||||
'request_vars_order' => 'EGPCS',
|
||||
'request_use_auto_globals' => true,
|
||||
'use_sub_dirs' => false,
|
||||
'autoload_filters' => array(),
|
||||
'default_template_handler_func' => '',
|
||||
'debug_tpl' => '',
|
||||
'cache_modified_check' => false,
|
||||
'default_modifiers' => array(),
|
||||
'default_resource_type' => 'file',
|
||||
'config_overwrite' => true,
|
||||
'config_booleanize' => true,
|
||||
'config_read_hidden' => false,
|
||||
'config_fix_newlines' => true,
|
||||
'config_class' => 'Config_File',
|
||||
),
|
||||
);
|
||||
|
||||
// security vars
|
||||
public $security = false;
|
||||
public $trusted_dir = array();
|
||||
public $secure_dir = array();
|
||||
public $php_handling = SMARTY_PHP_PASSTHRU;
|
||||
public $security_settings = array
|
||||
(
|
||||
'PHP_HANDLING' => false,
|
||||
'IF_FUNCS' => array
|
||||
(
|
||||
'list', 'empty', 'count', 'sizeof',
|
||||
'in_array', 'is_array',
|
||||
),
|
||||
'INCLUDE_ANY' => false,
|
||||
'PHP_TAGS' => false,
|
||||
'MODIFIER_FUNCS' => array(),
|
||||
'ALLOW_CONSTANTS' => false
|
||||
);
|
||||
|
||||
// paths
|
||||
public $template_dir = 'templates';
|
||||
public $compile_dir = 'templates_c';
|
||||
public $config_dir = 'configs';
|
||||
public $cache_dir = 'cache';
|
||||
public $plugins_dir = array();
|
||||
|
||||
// misc options
|
||||
public $left_delimiter = '{';
|
||||
public $right_delimiter = '}';
|
||||
public $compile_check = true;
|
||||
public $force_compile = false;
|
||||
public $caching = 0;
|
||||
public $cache_lifetime = 3600;
|
||||
public $compile_id = null;
|
||||
public $compiler_file = null;
|
||||
public $compiler_class = null;
|
||||
|
||||
// dwoo/smarty compat layer
|
||||
public $show_compat_errors = false;
|
||||
protected $dataProvider;
|
||||
protected $_filters = array('pre'=>array(), 'post'=>array(), 'output'=>array());
|
||||
protected static $tplCache = array();
|
||||
protected $compiler = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->charset = 'iso-8859-1';
|
||||
$this->dataProvider = new Dwoo_Data();
|
||||
$this->compiler = new Dwoo_Compiler();
|
||||
}
|
||||
|
||||
public function display($filename, $cacheId=null, $compileId=null)
|
||||
{
|
||||
$this->fetch($filename, $cacheId, $compileId, true);
|
||||
}
|
||||
|
||||
public function fetch($filename, $cacheId=null, $compileId=null, $display=false)
|
||||
{
|
||||
$this->setCacheDir($this->cache_dir);
|
||||
$this->setCompileDir($this->compile_dir);
|
||||
|
||||
if ($this->security) {
|
||||
$policy = new Dwoo_Security_Policy();
|
||||
$policy->addPhpFunction(array_merge($this->security_settings['IF_FUNCS'], $this->security_settings['MODIFIER_FUNCS']));
|
||||
|
||||
$phpTags = $this->security_settings['PHP_HANDLING'] ? SMARTY_PHP_ALLOW : $this->php_handling;
|
||||
if ($this->security_settings['PHP_TAGS']) {
|
||||
$phpTags = SMARTY_PHP_ALLOW;
|
||||
}
|
||||
switch($phpTags) {
|
||||
case SMARTY_PHP_ALLOW:
|
||||
case SMARTY_PHP_PASSTHRU:
|
||||
$phpTags = Dwoo_Security_Policy::PHP_ALLOW;
|
||||
break;
|
||||
case SMARTY_PHP_QUOTE:
|
||||
$phpTags = Dwoo_Security_Policy::PHP_ENCODE;
|
||||
break;
|
||||
case SMARTY_PHP_REMOVE:
|
||||
default:
|
||||
$phpTags = Dwoo_Security_Policy::PHP_REMOVE;
|
||||
break;
|
||||
}
|
||||
$policy->setPhpHandling($phpTags);
|
||||
|
||||
$policy->setConstantHandling($this->security_settings['ALLOW_CONSTANTS']);
|
||||
|
||||
if ($this->security_settings['INCLUDE_ANY']) {
|
||||
$policy->allowDirectory(preg_replace('{^((?:[a-z]:)?[\\\\/]).*}i', '$1', __FILE__));
|
||||
} else {
|
||||
$policy->allowDirectory($this->secure_dir);
|
||||
}
|
||||
|
||||
$this->setSecurityPolicy($policy);
|
||||
}
|
||||
|
||||
if (!empty($this->plugins_dir)) {
|
||||
foreach ($this->plugins_dir as $dir) {
|
||||
$this->getLoader()->addDirectory(rtrim($dir, '\\/'));
|
||||
}
|
||||
}
|
||||
|
||||
$tpl = $this->makeTemplate($filename, $cacheId, $compileId);
|
||||
if ($this->force_compile) {
|
||||
$tpl->forceCompilation();
|
||||
}
|
||||
|
||||
if ($this->caching > 0) {
|
||||
$this->cacheTime = $this->cache_lifetime;
|
||||
} else {
|
||||
$this->cacheTime = 0;
|
||||
}
|
||||
|
||||
if ($this->compiler_class !== null) {
|
||||
if ($this->compiler_file !== null && !class_exists($this->compiler_class, false)) {
|
||||
include $this->compiler_file;
|
||||
}
|
||||
$this->compiler = new $this->compiler_class;
|
||||
} else {
|
||||
$this->compiler->addPreProcessor('smarty_compat', true);
|
||||
$this->compiler->setLooseOpeningHandling(true);
|
||||
}
|
||||
|
||||
$this->compiler->setDelimiters($this->left_delimiter, $this->right_delimiter);
|
||||
|
||||
return $this->get($tpl, $this->dataProvider, $this->compiler, $display===true);
|
||||
}
|
||||
|
||||
public function get($_tpl, $data = array(), $_compiler = null, $_output = false)
|
||||
{
|
||||
if ($_compiler === null) {
|
||||
$_compiler = $this->compiler;
|
||||
}
|
||||
return parent::get($_tpl, $data, $_compiler, $_output);
|
||||
}
|
||||
|
||||
public function register_function($name, $callback, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_FUNCTION) {
|
||||
throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
|
||||
}
|
||||
$this->plugins[$name] = array('type'=>self::SMARTY_FUNCTION, 'callback'=>$callback);
|
||||
}
|
||||
|
||||
public function unregister_function($name)
|
||||
{
|
||||
unset($this->plugins[$name]);
|
||||
}
|
||||
|
||||
public function register_block($name, $callback, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_BLOCK) {
|
||||
throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
|
||||
}
|
||||
$this->plugins[$name] = array('type'=>self::SMARTY_BLOCK, 'callback'=>$callback);
|
||||
}
|
||||
|
||||
public function unregister_block($name)
|
||||
{
|
||||
unset($this->plugins[$name]);
|
||||
}
|
||||
|
||||
public function register_modifier($name, $callback)
|
||||
{
|
||||
if (isset($this->plugins[$name]) && $this->plugins[$name][0] !== self::SMARTY_MODIFIER) {
|
||||
throw new Dwoo_Exception('Multiple plugins of different types can not share the same name');
|
||||
}
|
||||
$this->plugins[$name] = array('type'=>self::SMARTY_MODIFIER, 'callback'=>$callback);
|
||||
}
|
||||
|
||||
public function unregister_modifier($name)
|
||||
{
|
||||
unset($this->plugins[$name]);
|
||||
}
|
||||
|
||||
public function register_prefilter($callback)
|
||||
{
|
||||
$processor = new Dwoo_SmartyProcessorAdapter($this->compiler);
|
||||
$processor->registerCallback($callback);
|
||||
$this->_filters['pre'][] = $processor;
|
||||
$this->compiler->addPreProcessor($processor);
|
||||
}
|
||||
|
||||
public function unregister_prefilter($callback)
|
||||
{
|
||||
foreach ($this->_filters['pre'] as $index => $processor)
|
||||
if ($processor->callback === $callback) {
|
||||
$this->compiler->removePostProcessor($processor);
|
||||
unset($this->_filters['pre'][$index]);
|
||||
}
|
||||
}
|
||||
|
||||
public function register_postfilter($callback)
|
||||
{
|
||||
$processor = new Dwoo_SmartyProcessorAdapter($this->compiler);
|
||||
$processor->registerCallback($callback);
|
||||
$this->_filters['post'][] = $processor;
|
||||
$this->compiler->addPostProcessor($processor);
|
||||
}
|
||||
|
||||
public function unregister_postfilter($callback)
|
||||
{
|
||||
foreach ($this->_filters['post'] as $index => $processor)
|
||||
if ($processor->callback === $callback) {
|
||||
$this->compiler->removePostProcessor($processor);
|
||||
unset($this->_filters['post'][$index]);
|
||||
}
|
||||
}
|
||||
|
||||
public function register_outputfilter($callback)
|
||||
{
|
||||
$filter = new Dwoo_SmartyFilterAdapter($this);
|
||||
$filter->registerCallback($callback);
|
||||
$this->_filters['output'][] = $filter;
|
||||
$this->addFilter($filter);
|
||||
}
|
||||
|
||||
public function unregister_outputfilter($callback)
|
||||
{
|
||||
foreach ($this->_filters['output'] as $index => $filter)
|
||||
if ($filter->callback === $callback) {
|
||||
$this->removeOutputFilter($filter);
|
||||
unset($this->_filters['output'][$index]);
|
||||
}
|
||||
}
|
||||
|
||||
function register_object($object, $object_impl, $allowed = array(), $smarty_args = false, $block_methods = array())
|
||||
{
|
||||
settype($allowed, 'array');
|
||||
settype($block_methods, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
|
||||
if (!empty($allowed) && $this->show_compat_errors) {
|
||||
$this->triggerError('You can register objects but can not restrict the method/properties used, this is PHP5, you have proper OOP access restrictions so use them.', E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if ($smarty_args) {
|
||||
$this->triggerError('You can register objects but methods will be called using method($arg1, $arg2, $arg3), not as an argument array like smarty did.', E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if (!empty($block_methods)) {
|
||||
$this->triggerError('You can register objects but can not use methods as being block methods, you have to build a plugin for that.', E_USER_NOTICE);
|
||||
}
|
||||
|
||||
$this->dataProvider->assign($object, $object_impl);
|
||||
}
|
||||
|
||||
function unregister_object($object)
|
||||
{
|
||||
$this->dataProvider->clear($object);
|
||||
}
|
||||
|
||||
function get_registered_object($name) {
|
||||
$data = $this->dataProvider->getData();
|
||||
if (isset($data[$name]) && is_object($data[$name])) {
|
||||
return $data[$name];
|
||||
} else {
|
||||
trigger_error('Dwoo_Compiler: object "'.$name.'" was not registered or is not an object', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public function template_exists($filename)
|
||||
{
|
||||
if (!is_array($this->template_dir)) {
|
||||
return file_exists($this->template_dir.DIRECTORY_SEPARATOR.$filename);
|
||||
} else {
|
||||
foreach ($this->template_dir as $tpl_dir) {
|
||||
if (file_exists($tpl_dir.DIRECTORY_SEPARATOR.$filename)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function is_cached($tpl, $cacheId = null, $compileId = null)
|
||||
{
|
||||
return $this->isCached($this->makeTemplate($tpl, $cacheId, $compileId));
|
||||
}
|
||||
|
||||
public function append_by_ref($var, &$value, $merge=false)
|
||||
{
|
||||
$this->dataProvider->appendByRef($var, $value, $merge);
|
||||
}
|
||||
|
||||
public function assign_by_ref($name, &$val)
|
||||
{
|
||||
$this->dataProvider->assignByRef($name, $val);
|
||||
}
|
||||
|
||||
public function clear_assign($var)
|
||||
{
|
||||
$this->dataProvider->clear($var);
|
||||
}
|
||||
|
||||
public function clear_all_assign()
|
||||
{
|
||||
$this->dataProvider->clear();
|
||||
}
|
||||
|
||||
public function get_template_vars($name=null)
|
||||
{
|
||||
if ($this->show_compat_errors) {
|
||||
trigger_error('get_template_vars does not return values by reference, if you try to modify the data that way you should modify your code.', E_USER_NOTICE);
|
||||
}
|
||||
|
||||
$data = $this->dataProvider->getData();
|
||||
if ($name === null)
|
||||
return $data;
|
||||
elseif (isset($data[$name]))
|
||||
return $data[$name];
|
||||
return null;
|
||||
}
|
||||
|
||||
public function clear_all_cache($olderThan = 0)
|
||||
{
|
||||
$this->clearCache($olderThan);
|
||||
}
|
||||
|
||||
public function clear_cache($template, $cacheId = null, $compileId = null, $olderThan = 0)
|
||||
{
|
||||
$this->makeTemplate($template, $cacheId, $compileId)->clearCache($olderThan);
|
||||
}
|
||||
|
||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
$this->triggerError($error_msg, $error_type);
|
||||
}
|
||||
|
||||
protected function initGlobals()
|
||||
{
|
||||
parent::initGlobals();
|
||||
$this->globals['ldelim'] = '{';
|
||||
$this->globals['rdelim'] = '}';
|
||||
}
|
||||
|
||||
protected function makeTemplate($file, $cacheId, $compileId)
|
||||
{
|
||||
if ($compileId === null)
|
||||
$compileId = $this->compile_id;
|
||||
|
||||
$hash = bin2hex(md5($file.$cacheId.$compileId, true));
|
||||
if (!isset(self::$tplCache[$hash])) {
|
||||
// abs path
|
||||
if (substr($file, 0, 1) === '/' || substr($file, 1, 1) === ':') {
|
||||
self::$tplCache[$hash] = new Dwoo_Template_File($file, null, $cacheId, $compileId);
|
||||
} elseif (is_string($this->template_dir) || is_array($this->template_dir)) {
|
||||
self::$tplCache[$hash] = new Dwoo_Template_File($file, null, $cacheId, $compileId, $this->template_dir);
|
||||
} else {
|
||||
throw new Exception('Unable to load "'.$file.'", check the template_dir');
|
||||
}
|
||||
}
|
||||
return self::$tplCache[$hash];
|
||||
}
|
||||
|
||||
public function triggerError($message, $level=E_USER_NOTICE)
|
||||
{
|
||||
if (is_object($this->template)) {
|
||||
return parent::triggerError($message, $level);
|
||||
}
|
||||
trigger_error('Dwoo error : '.$message, $level);
|
||||
}
|
||||
}
|
||||
|
||||
class Dwoo_Smarty_Filter_Adapter extends Dwoo_Filter
|
||||
{
|
||||
public $callback;
|
||||
|
||||
public function process($input)
|
||||
{
|
||||
return call_user_func($this->callback, $input);
|
||||
}
|
||||
|
||||
public function registerCallback($callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
}
|
||||
|
||||
class Dwoo_Smarty_Processor_Adapter extends Dwoo_Processor
|
||||
{
|
||||
public $callback;
|
||||
|
||||
public function process($input)
|
||||
{
|
||||
return call_user_func($this->callback, $input);
|
||||
}
|
||||
|
||||
public function registerCallback($callback)
|
||||
{
|
||||
$this->callback = $callback;
|
||||
}
|
||||
}
|
||||
|
||||
// cloaks the adapter if possible with the smarty name to fool type-hinted plugins
|
||||
if (class_exists('Smarty', false) === false)
|
||||
{
|
||||
interface Smarty {}
|
||||
class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter implements Smarty {}
|
||||
}
|
||||
else
|
||||
{
|
||||
class Dwoo_Smarty_Adapter extends Dwoo_Smarty__Adapter {}
|
||||
}
|