From e4478369d8fb5decfa1d632a02cf6b0c9f3429b8 Mon Sep 17 00:00:00 2001
From: Neo <321592+Neo-Desktop@users.noreply.github.com>
Date: Fri, 19 Dec 2025 00:38:12 -0800
Subject: [PATCH] Version 3.4.5
---
upload/admin/Thumbs.db | Bin 2560 -> 0 bytes
upload/admin/api/api_core.php | 2 +-
upload/admin/api/forums/api_topic_view.php | 30 +-
.../core/extensions/admin/group_form.php | 2 +-
.../core/extensions/admin/member_form.php | 6 +-
.../core/extensions/comments/reports.php | 72 +-
.../core/extensions/coreExtensions.php | 12 +-
.../core/extensions/coreVariables.php | 6 +-
.../extensions/dashboardNotifications.php | 564 +-
.../core/extensions/editorSections.php | 6 +-
.../core/extensions/enhancements/facebook.php | 38 +
.../enhancements/googleanalytics.php | 38 +
.../extensions/enhancements/ipsbackup.php | 42 +
.../core/extensions/enhancements/ipscdn.php | 167 +
.../core/extensions/enhancements/twitter.php | 38 +
.../core/extensions/enhancements/viglink.php | 114 +
.../extensions/enhancements/windowslive.php | 140 +
.../core/extensions/furlTemplates.php | 23 +-
.../core/extensions/furlTemplatesID.php | 106 +
.../core/extensions/like/default.php | 2 +-
.../core/extensions/navigation/generate.php | 15 +-
.../core/extensions/notifications.php | 10 +-
.../core/extensions/reportPlugins/default.php | 22 +-
.../core/extensions/rssOutput.php | 6 +-
.../core/extensions/search/config.php | 6 +-
.../core/extensions/search/engines/sql.php | 6 +-
.../core/extensions/search/form.php | 6 +-
.../core/extensions/search/format.php | 6 +-
.../sharedmedia/plugin_attachments.php | 15 +-
.../sitemapPlugins/blog_entries.php | 92 +
.../core/extensions/sitemapPlugins/blogs.php | 57 +
.../extensions/sitemapPlugins/calendar.php | 92 +
.../core/extensions/sitemapPlugins/chat.php | 17 +
.../content_database_categories.php | 68 +
.../content_database_records.php | 169 +
.../sitemapPlugins/content_pages.php | 61 +
.../core/extensions/sitemapPlugins/core.php | 17 +
.../sitemapPlugins/downloads_categories.php | 39 +
.../sitemapPlugins/downloads_files.php | 69 +
.../core/extensions/sitemapPlugins/forums.php | 49 +
.../sitemapPlugins/gallery_albums.php | 57 +
.../sitemapPlugins/gallery_images.php | 69 +
.../extensions/sitemapPlugins}/index.html | 0
.../sitemapPlugins/nexus_categories.php | 32 +
.../sitemapPlugins/nexus_products.php | 33 +
.../core/extensions/sitemapPlugins/topics.php | 194 +
.../core/extensions/sphinxTemplate.php | 8 +-
.../core/extensions/usercpForms.php | 6494 ++--
.../applications/core/extensions/warnings.php | 12 +-
.../core/js/IPB3TemplateDiffResults.js | 4 +-
.../applications/core/js/acp.homepage.js | 2 +-
upload/admin/applications/core/js/ipb3CSS.js | 16 +-
.../applications/core/js/ipb3TemplateDiff.js | 6 +-
.../applications/core/js/ipb3TemplateSandR.js | 2 +-
.../applications/core/js/ipb3Templates.js | 16 +-
.../core/modules_admin/ajax/bookmarks.php | 138 +
.../core/modules_admin/ajax/compare.php | 6 +-
.../core/modules_admin/ajax/css.php | 6 +-
.../core/modules_admin/ajax/editor.php | 31 +
.../core/modules_admin/ajax/findnames.php | 228 +-
.../core/modules_admin/ajax/hooks.php | 10 +-
.../core/modules_admin/ajax/livesearch.php | 1130 +-
.../core/modules_admin/ajax/replacements.php | 8 +-
.../core/modules_admin/ajax/skinsets.php | 2 +-
.../core/modules_admin/ajax/tabs.php | 2 +-
.../core/modules_admin/ajax/templatediff.php | 9 +-
.../core/modules_admin/ajax/templates.php | 6 +-
.../core/modules_admin/ajax/templatesandr.php | 6 +-
.../core/modules_admin/ajax/uagents.php | 6 +-
.../applications/applications.php | 43 +-
.../core/modules_admin/applications/blog.php | 6 +-
.../core/modules_admin/applications/ccs.php | 6 +-
.../modules_admin/applications/copyright.php | 6 +-
.../applications/defaultSection.php | 2 +-
.../modules_admin/applications/downloads.php | 6 +-
.../applications/enhancements.php | 178 +
.../modules_admin/applications/gallery.php | 6 +-
.../core/modules_admin/applications/hooks.php | 7052 ++--
.../core/modules_admin/applications/nexus.php | 6 +-
.../core/modules_admin/applications/setup.php | 2335 +-
.../modules_admin/applications/xml/menu.xml | 21 +-
.../applications/xml/permissions.xml | 36 +-
.../core/modules_admin/attach/attach.php | 41 +
.../core/modules_admin/attach}/index.html | 0
.../diagnostics/defaultSection.php | 2 +-
.../modules_admin/diagnostics/diagnostics.php | 1633 +-
.../modules_admin/diagnostics/xml/menu.xml | 28 +-
.../diagnostics/xml/permissions.xml | 14 +-
.../modules_admin/help/defaultSection.php | 2 +-
.../core/modules_admin/help/quickhelp.php | 6 +-
.../core/modules_admin/help/xml/menu.xml | 152 +-
.../languages/defaultSection.php | 2 +-
.../languages/manage_languages.php | 6085 ++--
.../core/modules_admin/languages/xml/menu.xml | 4 +-
.../languages/xml/permissions.xml | 8 +-
.../modules_admin/login/manualResolver.php | 863 +-
.../core/modules_admin/logs/adminlogs.php | 6 +-
.../modules_admin/logs/defaultSection.php | 8 +-
.../modules_admin/logs/emailerrorlogs.php | 6 +-
.../core/modules_admin/logs/errorlogs.php | 9 +-
.../core/modules_admin/logs/loginlog.php | 13 +-
.../core/modules_admin/logs/logsSplash.php | 2 +-
.../core/modules_admin/logs/mobilelogs.php | 6 +-
.../core/modules_admin/logs/modlogs.php | 6 +-
.../core/modules_admin/logs/spamlogs.php | 8 +-
.../core/modules_admin/logs/spiderlogs.php | 560 +-
.../core/modules_admin/logs/sqlerror.php | 10 +-
.../core/modules_admin/logs/tasklogs.php | 14 +-
.../core/modules_admin/logs/warnlogs.php | 8 +-
.../core/modules_admin/logs/xml/menu.xml | 4 +-
.../modules_admin/logs/xml/permissions.xml | 46 +-
.../core/modules_admin/logs/xmlrpclogs.php | 12 +-
.../mobileapp/defaultSection.php | 2 +-
.../core/modules_admin/mobileapp/images.php | 2 +-
.../core/modules_admin/mobileapp/xml/menu.xml | 4 +-
.../mobileapp/xml/permissions.xml | 4 +-
.../core/modules_admin/mycp/dashboard.php | 14 +-
.../modules_admin/mycp/defaultSection.php | 2 +-
.../core/modules_admin/mycp/details.php | 6 +-
.../core/modules_admin/mycp/tabs.php | 143 +
.../core/modules_admin/mycp/xml/menu.xml | 8 +-
.../modules_admin/mycp/xml/permissions.xml | 4 +-
.../core/modules_admin/posts/acronyms.php | 245 +
.../core/modules_admin/posts/badwords.php | 6 +-
.../core/modules_admin/posts/bbcode.php | 6 +-
.../modules_admin/posts/defaultSection.php | 2 +-
.../core/modules_admin/posts/emoticons.php | 2760 +-
.../core/modules_admin/posts/media.php | 8 +-
.../core/modules_admin/posts/xml/menu.xml | 29 +-
.../modules_admin/posts/xml/permissions.xml | 38 +-
.../modules_admin/report/defaultSection.php | 2 +-
.../core/modules_admin/report/reports.php | 49 +-
.../core/modules_admin/report/xml/menu.xml | 8 +-
.../modules_admin/report/xml/permissions.xml | 12 +-
.../core/modules_admin/seo/activity.php | 650 +
.../core/modules_admin/seo/advice.php | 217 +
.../core/modules_admin/seo/defaultSection.php | 5 +
.../core/modules_admin/seo/upgrade.php | 65 +
.../core/modules_admin/seo/xml/menu.xml | 31 +
.../modules_admin/seo/xml/permissions.xml | 17 +
.../modules_admin/settings/defaultSection.php | 2 +-
.../core/modules_admin/settings/settings.php | 4207 +--
.../core/modules_admin/settings/xml/menu.xml | 4 +-
.../settings/xml/permissions.xml | 14 +-
.../core/modules_admin/sql/defaultSection.php | 2 +-
.../core/modules_admin/sql/mysql.php | 105 +-
.../core/modules_admin/sql/toolbox.php | 6 +-
.../core/modules_admin/sql/xml/menu.xml | 16 +-
.../core/modules_admin/system/charts.php | 2 +-
.../modules_admin/system/defaultSection.php | 2 +-
.../core/modules_admin/system/security.php | 84 +-
.../core/modules_admin/system/taskmanager.php | 8 +-
.../core/modules_admin/system/xml/menu.xml | 12 +-
.../modules_admin/system/xml/permissions.xml | 32 +-
.../templates/defaultSection.php | 2 +-
.../core/modules_admin/templates/easylogo.php | 8 +-
.../core/modules_admin/templates/external.php | 2 +-
.../modules_admin/templates/importexport.php | 8 +-
.../core/modules_admin/templates/meta.php | 188 +
.../modules_admin/templates/replacements.php | 6 +-
.../templates/searchandreplace.php | 6 +-
.../core/modules_admin/templates/skindiff.php | 11 +-
.../core/modules_admin/templates/skinsets.php | 19 +-
.../templates/systemTemplates.php | 229 +
.../modules_admin/templates/templates.php | 6 +-
.../core/modules_admin/templates/tools.php | 14 +-
.../core/modules_admin/templates/urlmap.php | 6 +-
.../modules_admin/templates/useragents.php | 6 +-
.../core/modules_admin/templates/xml/menu.xml | 54 +-
.../templates/xml/permissions.xml | 46 +-
.../core/modules_admin/tools/api.php | 6 +-
.../core/modules_admin/tools/cache.php | 12 +-
.../modules_admin/tools/defaultSection.php | 2 +-
.../core/modules_admin/tools/help.php | 69 +-
.../modules_admin/tools/incomingEmails.php | 6 +-
.../core/modules_admin/tools/licensekey.php | 51 +-
.../core/modules_admin/tools/login.php | 75 +-
.../core/modules_admin/tools/logsSplash.php | 6 +-
.../core/modules_admin/tools/performance.php | 8 +-
.../core/modules_admin/tools/qanda.php | 6 +-
.../core/modules_admin/tools/rebuild.php | 6089 ++--
.../core/modules_admin/tools/sharelinks.php | 12 +-
.../core/modules_admin/tools/uagents.php | 6 +-
.../core/modules_admin/tools/xml/menu.xml | 48 +-
.../modules_admin/tools/xml/permissions.xml | 84 +-
.../core/modules_public/ajax/attach.php | 57 +-
.../core/modules_public/ajax/captcha.php | 6 +-
.../core/modules_public/ajax/comments.php | 19 +-
.../modules_public/ajax/defaultSection.php | 2 +-
.../core/modules_public/ajax/editor.php | 15 +-
.../core/modules_public/ajax/facebook.php | 6 +-
.../core/modules_public/ajax/findnames.php | 218 +-
.../core/modules_public/ajax/like.php | 2 +-
.../core/modules_public/ajax/login.php | 6 +-
.../core/modules_public/ajax/media.php | 8 +-
.../core/modules_public/ajax/modcp.php | 348 +-
.../core/modules_public/ajax/navigation.php | 2 +-
.../modules_public/ajax/notifications.php | 8 +-
.../core/modules_public/ajax/register.php | 12 +-
.../core/modules_public/ajax/reports.php | 6 +-
.../core/modules_public/ajax/reputation.php | 6 +-
.../core/modules_public/ajax/search.php | 93 +-
.../core/modules_public/ajax/sharelinks.php | 10 +-
.../core/modules_public/ajax/skin.php | 22 +-
.../core/modules_public/ajax/skingen.php | 2 +-
.../core/modules_public/ajax/tags.php | 6 +-
.../core/modules_public/ajax/templates.php | 2 +-
.../core/modules_public/ajax/usercp.php | 220 +-
.../core/modules_public/attach/attach.php | 318 +-
.../modules_public/attach/defaultSection.php | 2 +-
.../core/modules_public/global/captcha.php | 6 +-
.../core/modules_public/global/comments.php | 26 +-
.../modules_public/global/defaultSection.php | 2 +-
.../core/modules_public/global/like.php | 12 +-
.../core/modules_public/global/login.php | 1081 +-
.../core/modules_public/global/lostpass.php | 981 +-
.../core/modules_public/global/meta.php | 125 +
.../core/modules_public/global/navigation.php | 16 +-
.../core/modules_public/global/privacy.php | 2 +-
.../core/modules_public/global/register.php | 4199 +--
.../core/modules_public/global/reputation.php | 8 +-
.../core/modules_public/global/rss.php | 6 +-
.../core/modules_public/global/share.php | 14 +-
.../core/modules_public/global/sitemap.php | 56 +
.../core/modules_public/global/skin.php | 10 +-
.../modules_public/global/unsubscribe.php | 45 +
.../modules_public/help/defaultSection.php | 2 +-
.../core/modules_public/help/help.php | 10 +-
.../modules_public/modcp/defaultSection.php | 2 +-
.../core/modules_public/modcp/modcp.php | 107 +-
.../modules_public/reports/defaultSection.php | 2 +-
.../core/modules_public/reports/reports.php | 48 +-
.../modules_public/search/defaultSection.php | 2 +-
.../core/modules_public/search/search.php | 2525 +-
.../modules_public/task/manualResolver.php | 6 +-
.../modules_public/usercp/manualResolver.php | 12 +-
.../applications/core/setup/upgradeCheck.php | 8 +-
.../install/sql/core_mysql_inserts.php | 75 +-
.../install/sql/core_mysql_tables.php | 106 +-
.../upg_10002/version_upgrade_mysql.php | 55 +-
.../upg_10004/version_upgrade_mysql.php | 51 +-
.../versions/upg_20004/mysql_updates.php | 2 +-
.../versions/upg_20005/mysql_updates.php | 2 +-
.../versions/upg_20007/mysql_updates.php | 2 +-
.../versions/upg_20009/mysql_updates.php | 2 +-
.../versions/upg_20010/mysql_updates.php | 2 +-
.../versions/upg_20012/mysql_updates.php | 2 +-
.../versions/upg_21003/mysql_updates.php | 2 +-
.../versions/upg_21003/mysql_updates_1.php | 2 +-
.../versions/upg_21003/mysql_updates_2.php | 2 +-
.../versions/upg_21003/mysql_updates_3.php | 2 +-
.../versions/upg_21003/mysql_updates_4.php | 2 +-
.../versions/upg_21003/version_upgrade.php | 921 +-
.../versions/upg_21005/mysql_updates.php | 2 +-
.../versions/upg_21007/mysql_updates.php | 2 +-
.../versions/upg_21007/version_upgrade.php | 184 +-
.../versions/upg_21008/mysql_updates.php | 2 +-
.../versions/upg_21009/mysql_updates.php | 2 +-
.../versions/upg_21010/mysql_updates.php | 2 +-
.../versions/upg_21011/mysql_updates.php | 2 +-
.../versions/upg_22005/mysql_updates.php | 2 +-
.../versions/upg_22005/mysql_updates_1.php | 2 +-
.../versions/upg_22005/mysql_updates_2.php | 2 +-
.../versions/upg_22005/mysql_updates_3.php | 2 +-
.../versions/upg_22005/version_upgrade.php | 770 +-
.../versions/upg_22006/mysql_updates.php | 2 +-
.../versions/upg_22007/mysql_updates.php | 2 +-
.../versions/upg_22009/mysql_updates.php | 2 +-
.../versions/upg_22010/mysql_updates.php | 2 +-
.../versions/upg_22011/mysql_updates.php | 2 +-
.../versions/upg_23000/mysql_updates.php | 2 +-
.../versions/upg_23002/mysql_updates.php | 2 +-
.../versions/upg_23003/mysql_updates.php | 2 +-
.../versions/upg_23005/mysql_updates.php | 2 +-
.../versions/upg_23008/mysql_updates.php | 2 +-
.../versions/upg_23010/mysql_updates.php | 2 +-
.../versions/upg_30001/mysql_updates.php | 2 +-
.../versions/upg_30001/mysql_updates_1.php | 2 +-
.../versions/upg_30001/mysql_updates_2.php | 2 +-
.../versions/upg_30001/mysql_updates_3.php | 2 +-
.../versions/upg_30001/mysql_updates_4.php | 2 +-
.../versions/upg_30001/mysql_updates_5.php | 42 +-
.../versions/upg_30001/mysql_updates_6.php | 2 +-
.../upg_30001/mysql_version_upgrade.php | 7 +-
.../versions/upg_30001/version_class.php | 322 +-
.../versions/upg_30001/version_upgrade.php | 3432 +-
.../versions/upg_30003/mysql_updates.php | 2 +-
.../versions/upg_30004/mysql_updates.php | 2 +-
.../versions/upg_30005/mysql_updates.php | 2 +-
.../versions/upg_30006/mysql_updates.php | 2 +-
.../versions/upg_30007/mysql_updates.php | 2 +-
.../versions/upg_30008/mysql_updates.php | 2 +-
.../versions/upg_30008/version_upgrade.php | 166 +-
.../versions/upg_30009/mysql_updates.php | 2 +-
.../versions/upg_30010/mysql_updates.php | 2 +-
.../versions/upg_30011/mysql_updates.php | 2 +-
.../versions/upg_30012/mysql_updates.php | 2 +-
.../versions/upg_31000/mysql_updates.php | 13 +-
.../versions/upg_31003/mysql_updates.php | 11 +-
.../versions/upg_31004/mysql_updates.php | 2 +-
.../versions/upg_31005/mysql_updates.php | 2 +-
.../versions/upg_31006/mysql_updates.php | 2 +-
.../versions/upg_31007/mysql_updates.php | 2 +-
.../versions/upg_32000/mysql_updates.php | 2 +-
.../versions/upg_32000/mysql_updates_1.php | 2 +-
.../versions/upg_32000/mysql_updates_2.php | 2 +-
.../versions/upg_32000/mysql_updates_3.php | 2 +-
.../versions/upg_32000/mysql_updates_4.php | 2 +-
.../versions/upg_32000/mysql_updates_5.php | 2 +-
.../versions/upg_32000/mysql_updates_6.php | 2 +-
.../upg_32000/mysql_updates_logs_1.php | 2 +-
.../upg_32000/mysql_updates_logs_10.php | 2 +-
.../upg_32000/mysql_updates_logs_2.php | 2 +-
.../upg_32000/mysql_updates_logs_3.php | 2 +-
.../upg_32000/mysql_updates_logs_4.php | 2 +-
.../upg_32000/mysql_updates_logs_5.php | 2 +-
.../upg_32000/mysql_updates_logs_6.php | 2 +-
.../upg_32000/mysql_updates_logs_7.php | 2 +-
.../upg_32000/mysql_updates_logs_8.php | 2 +-
.../upg_32000/mysql_updates_logs_9.php | 2 +-
.../versions/upg_32000/version_class.php | 226 +-
.../versions/upg_32000/version_upgrade.php | 1883 +-
.../versions/upg_32001/mysql_updates.php | 7 +-
.../versions/upg_32001/version_upgrade.php | 232 +-
.../versions/upg_32002/mysql_updates.php | 2 +-
.../versions/upg_32003/mysql_updates.php | 2 +-
.../versions/upg_32004/mysql_updates.php | 2 +-
.../versions/upg_32005/mysql_updates.php | 2 +-
.../versions/upg_32006/mysql_updates.php | 2 +-
.../versions/upg_32007/mysql_updates.php | 2 +-
.../versions/upg_33000/mysql_updates.php | 10 +-
.../versions/upg_33000/mysql_updates_1.php | 2 +-
.../versions/upg_33000/mysql_updates_2.php | 2 +-
.../versions/upg_33000/version_class.php | 237 +-
.../versions/upg_33000/version_upgrade.php | 2 +-
.../versions/upg_33007/version_upgrade.php | 2 +-
.../versions/upg_33010/version_class.php | 162 +-
.../core/setup/versions/upg_33016/index.html | 10 +
.../versions/upg_33016/mysql_updates.php | 19 +
.../versions/upg_34000/mysql_updates.php | 89 +
.../versions/upg_34000/version_class.php | 82 +
.../versions/upg_34000/version_upgrade.php | 169 +
.../versions/upg_34005/mysql_updates.php | 34 +
.../versions/upg_34007/mysql_updates.php | 6 +
.../versions/upg_34008/mysql_updates.php | 18 +
.../versions/upg_34009/mysql_updates.php | 19 +
.../versions/upg_34010/mysql_updates.php | 6 +
.../versions/upg_34011/mysql_updates.php | 18 +
.../core/skin_cp/cp_skin_adminlogs.php | 10 +-
.../applications/core/skin_cp/cp_skin_api.php | 6 +-
.../core/skin_cp/cp_skin_applications.php | 6156 ++--
.../core/skin_cp/cp_skin_badwords.php | 6 +-
.../core/skin_cp/cp_skin_bbcode.php | 8 +-
.../core/skin_cp/cp_skin_diagnostics.php | 1542 +-
.../core/skin_cp/cp_skin_emailerrorlogs.php | 6 +-
.../core/skin_cp/cp_skin_emoticons.php | 8 +-
.../core/skin_cp/cp_skin_errorlogs.php | 6 +-
.../core/skin_cp/cp_skin_group_core.php | 6 +-
.../core/skin_cp/cp_skin_help_files.php | 12 +-
.../core/skin_cp/cp_skin_hooks_export.php | 6 +-
.../core/skin_cp/cp_skin_mobileapp.php | 6 +-
.../core/skin_cp/cp_skin_mobilelogs.php | 6 +-
.../core/skin_cp/cp_skin_modlogs.php | 6 +-
.../core/skin_cp/cp_skin_mycp.php | 88 +-
.../core/skin_cp/cp_skin_performance.php | 6 +-
.../core/skin_cp/cp_skin_qanda.php | 6 +-
.../core/skin_cp/cp_skin_rebuild.php | 16 +-
.../core/skin_cp/cp_skin_reports.php | 120 +-
.../core/skin_cp/cp_skin_security.php | 14 +-
.../applications/core/skin_cp/cp_skin_seo.php | 954 +
.../core/skin_cp/cp_skin_settings.php | 1287 +-
.../core/skin_cp/cp_skin_setup.php | 6 +-
.../core/skin_cp/cp_skin_spamlogs.php | 6 +-
.../core/skin_cp/cp_skin_spiderlogs.php | 6 +-
.../applications/core/skin_cp/cp_skin_sql.php | 102 +-
.../core/skin_cp/cp_skin_system.php | 73 +-
.../core/skin_cp/cp_skin_templates.php | 153 +-
.../core/skin_cp/cp_skin_tools.php | 36 +-
.../core/skin_cp/cp_skin_warnlogs.php | 18 +-
.../applications/core/skin_cp/images/bad.png | Bin 0 -> 696 bytes
.../core/skin_cp/images/calendar-d.png | Bin 0 -> 635 bytes
.../core/skin_cp/images/calendar-m.png | Bin 0 -> 627 bytes
.../core/skin_cp/images/calendar-w.png | Bin 0 -> 638 bytes
.../core/skin_cp/images/calendar.png | Bin 0 -> 483 bytes
.../core/skin_cp/images/index.html | 10 +
.../applications/core/skin_cp/images/wand.png | Bin 0 -> 610 bytes
.../applications/core/skin_cp/images/warn.png | Bin 0 -> 654 bytes
.../sources/classes/attach/class_attach.php | 3396 +-
.../sources/classes/attach/controller.php | 370 +
.../core/sources/classes/hooks/gateway.php | 6 +-
.../core/sources/classes/hooksFunctions.php | 6 +-
.../core/sources/classes/reportLibrary.php | 18 +-
.../sources/classes/reportNotifications.php | 78 +-
.../core/sql/mysql_report_queries.php | 14 +-
.../core/sql/mysql_seo_queries.php | 45 +
.../core/sql/mysql_tag_queries.php | 13 +-
.../admin/applications/core/tasks/archive.php | 230 +-
.../admin/applications/core/tasks/backup.php | 108 +
.../applications/core/tasks/cleanout.php | 17 +-
.../applications/core/tasks/contentcache.php | 2 +-
.../applications/core/tasks/itemmarkers.php | 2 +-
.../applications/core/tasks/logprune.php | 17 +-
.../applications/core/tasks/minifycleanup.php | 8 +-
.../applications/core/tasks/mysqlcleanup.php | 2 +-
.../applications/core/tasks/optimize.php | 10 +-
.../applications/core/tasks/pop3email.php | 8 +-
.../applications/core/tasks/rebuildstats.php | 2 +-
.../core/tasks/sitemapgenerator.php | 799 +
.../core/xml/admin_core_language_pack.xml | 27649 ++++++++--------
.../applications/core/xml/core_bbcode.xml | 494 +-
.../admin/applications/core/xml/core_help.xml | 212 +-
.../applications/core/xml/core_mediatag.xml | 38 +-
.../applications/core/xml/core_mobile_css.xml | 133 +-
.../core/xml/core_mobile_templates.xml | 565 +-
.../applications/core/xml/core_modules.xml | 83 +-
.../applications/core/xml/core_root_css.xml | 323 +-
.../core/xml/core_root_templates.xml | 1374 +-
.../applications/core/xml/core_settings.xml | 4657 ++-
.../applications/core/xml/core_tasks.xml | 136 +-
.../core/xml/core_xmlskin_css.xml | 44 +-
.../core/xml/core_xmlskin_templates.xml | 204 +-
upload/admin/applications/core/xml/hooks.xml | 4 +
.../core/xml/hooks/adcodesidebar.xml | 4 +-
.../applications/core/xml/hooks/vkontakte.xml | 206 +
.../applications/core/xml/information.xml | 10 +-
.../core/xml/public_core_language_pack.xml | 26549 +++++++--------
.../admin/applications/core/xml/versions.xml | 52 +-
.../applications/forums/app_class_forums.php | 449 +-
.../forums/extensions/admin/group_form.php | 2 +-
.../forums/extensions/admin/member_form.php | 6 +-
.../extensions/attachments/plugin_post.php | 20 +-
.../forums/extensions/bulkMailFilters.php | 100 +
.../extensions/content/feed_blocks/forums.php | 21 +-
.../plugin_blocks/site_poll/plugin.php | 8 +
.../forums/extensions/coreExtensions.php | 24 +-
.../forums/extensions/coreVariables.php | 17 +-
.../forums/extensions/dataHookLocations.php | 6 +-
.../forums/extensions/editorSections.php | 6 +-
.../forums/extensions/emailLists.php | 68 +
.../forums/extensions/furlRedirect.php | 412 +-
.../forums/extensions/furlTemplates.php | 29 +-
.../forums/extensions/furlTemplatesID.php | 82 +
.../forums/extensions/like/forums.php | 28 +-
.../forums/extensions/like/topics.php | 10 +-
.../forums/extensions/memberSync.rename.php | 8 +-
.../extensions/modcp/plugin_announcements.php | 23 +-
.../extensions/modcp/plugin_deletedposts.php | 8 +-
.../extensions/modcp/plugin_deletedtopics.php | 8 +-
.../modcp/plugin_unapprovedposts.php | 12 +-
.../modcp/plugin_unapprovedtopics.php | 14 +-
.../forums/extensions/navigation/generate.php | 2 +-
.../forums/extensions/notifications.php | 6 +-
.../extensions/profileTabs/posts.conf.php | 6 +-
.../forums/extensions/profileTabs/posts.php | 148 +-
.../extensions/profileTabs/topics.conf.php | 6 +-
.../forums/extensions/profileTabs/topics.php | 162 +-
.../forums/extensions/reportPlugins/post.php | 45 +-
.../forums/extensions/reputation.php | 20 +-
.../forums/extensions/rssOutput.php | 6 +-
.../forums/extensions/search/config.php | 6 +-
.../extensions/search/engines/sphinx.php | 53 +-
.../forums/extensions/search/engines/sql.php | 144 +-
.../forums/extensions/search/form.php | 6 +-
.../forums/extensions/search/format.php | 16 +-
.../forums/extensions/sphinxTemplate.php | 8 +-
.../forums/extensions/tags/topics.php | 6 +-
.../forums/extensions/warnings.php | 8 +-
.../applications/forums/js/acp.forums.js | 59 +
.../forums/modules_admin/ajax/archive.php | 2 +-
.../modules_admin/ajax/member_editform.php | 6 +-
.../forums/modules_admin/archive/archive.php | 788 +-
.../modules_admin/archive/defaultSection.php | 2 +-
.../forums/modules_admin/archive/xml/menu.xml | 8 +-
.../modules_admin/archive/xml/permissions.xml | 8 +-
.../attachments/defaultSection.php | 2 +-
.../modules_admin/attachments/search.php | 708 +-
.../modules_admin/attachments/stats.php | 6 +-
.../modules_admin/attachments/types.php | 6 +-
.../modules_admin/attachments/xml/menu.xml | 12 +-
.../attachments/xml/permissions.xml | 22 +-
.../modules_admin/forums/defaultSection.php | 2 +-
.../forums/modules_admin/forums/forums.php | 62 +-
.../forums/modules_admin/forums/moderator.php | 51 +-
.../forums/modules_admin/forums/multimods.php | 6 +-
.../forums/modules_admin/forums/xml/menu.xml | 8 +-
.../modules_admin/forums/xml/permissions.xml | 38 +-
.../modules_admin/rss/defaultSection.php | 2 +-
.../forums/modules_admin/rss/export.php | 35 +-
.../forums/modules_admin/rss/import.php | 2560 +-
.../forums/modules_admin/rss/xml/menu.xml | 8 +-
.../modules_admin/rss/xml/permissions.xml | 12 +-
.../statistics/defaultSection.php | 2 +-
.../forums/modules_admin/statistics/stats.php | 28 +-
.../modules_admin/statistics/xml/menu.xml | 24 +-
.../statistics/xml/permissions.xml | 56 +-
.../modules_admin/tools/defaultSection.php | 2 +-
.../forums/modules_admin/tools/tools.php | 6 +-
.../modules_admin/tools/xml/permissions.xml | 8 +-
.../modules_public/ajax/attachments.php | 6 +-
.../modules_public/ajax/defaultSection.php | 2 +-
.../forums/modules_public/ajax/emoticons.php | 6 +-
.../forums/modules_public/ajax/forums.php | 11 +-
.../forums/modules_public/ajax/markasread.php | 6 +-
.../forums/modules_public/ajax/stats.php | 6 +-
.../forums/modules_public/ajax/topics.php | 2833 +-
.../forums/modules_public/extras/answer.php | 153 +
.../modules_public/extras/boardrules.php | 22 +-
.../modules_public/extras/defaultSection.php | 2 +-
.../forums/modules_public/extras/forward.php | 22 +-
.../forums/modules_public/extras/legends.php | 22 +-
.../forums/modules_public/extras/rating.php | 12 +-
.../forums/modules_public/extras/stats.php | 221 +-
.../forums/modules_public/extras/toggle.php | 6 +-
.../forums/modules_public/extras/vote.php | 16 +-
.../modules_public/forums/announcements.php | 6 +-
.../forums/modules_public/forums/attach.php | 6 +-
.../forums/modules_public/forums/boards.php | 37 +-
.../modules_public/forums/defaultSection.php | 2 +-
.../forums/modules_public/forums/findpost.php | 117 +-
.../forums/modules_public/forums/forums.php | 144 +-
.../modules_public/forums/markasread.php | 10 +-
.../forums/modules_public/forums/rules.php | 27 +-
.../forums/modules_public/forums/topics.php | 448 +-
.../moderate/defaultSection.php | 2 +-
.../modules_public/moderate/moderate.php | 205 +-
.../modules_public/moderate/multimod.php | 10 +-
.../modules_public/post/defaultSection.php | 2 +-
.../forums/modules_public/post/post.php | 43 +-
.../install/sql/forums_mysql_inserts.php | 20 +-
.../install/sql/forums_mysql_tables.php | 10 +-
.../forums/skin_cp/cp_skin_archive.php | 995 +-
.../forums/skin_cp/cp_skin_attachments.php | 6 +-
.../forums/skin_cp/cp_skin_forums.php | 75 +-
.../forums/skin_cp/cp_skin_group_form.php | 6 +-
.../forums/skin_cp/cp_skin_member_form.php | 6 +-
.../forums/skin_cp/cp_skin_multimods.php | 8 +-
.../forums/skin_cp/cp_skin_rss.php | 10 +-
.../forums/skin_cp/cp_skin_stats.php | 6 +-
.../classes/forums/admin_forum_functions.php | 8 +-
.../sources/classes/forums/class_forums.php | 107 +-
.../forums/sources/classes/hooks/gateway.php | 6 +-
.../forums/sources/classes/moderate.php | 8 +-
.../forums/sources/classes/post/classPost.php | 7487 ++---
.../sources/classes/post/classPostForms.php | 121 +-
.../forums/sources/classes/topics.php | 603 +-
.../forums/sql/mysql_topics_queries.php | 2 +-
.../forums/tasks/announcements.php | 2 +-
.../forums/tasks/dailycleanout.php | 2 +-
.../applications/forums/tasks/dailydigest.php | 10 +-
.../applications/forums/tasks/permadelete.php | 15 +-
.../applications/forums/tasks/rssimport.php | 2 +-
.../applications/forums/tasks/updateviews.php | 2 +-
.../forums/tasks/weeklydigest.php | 8 +-
.../forums/xml/admin_forums_language_pack.xml | 7767 ++---
.../applications/forums/xml/forums_help.xml | 162 +-
.../forums/xml/forums_mobile_templates.xml | 420 +-
.../forums/xml/forums_modules.xml | 32 +-
.../forums/xml/forums_root_templates.xml | 588 +-
.../forums/xml/forums_settings.xml | 558 +-
.../applications/forums/xml/forums_tasks.xml | 72 +-
.../forums/xml/forums_xmlskin_templates.xml | 82 +-
.../forums/xml/hooks/facebook_activity.xml | 4 +-
.../forums/xml/hooks/recent_topics.xml | 106 +-
.../applications/forums/xml/hooks/tags.xml | 40 +-
.../applications/forums/xml/information.xml | 10 +-
.../xml/public_forums_language_pack.xml | 6114 ++--
.../applications/forums/xml/versions.xml | 44 +
.../members/extensions/admin/member_form.php | 14 +-
.../extensions/attachments/plugin_msg.php | 8 +-
.../members/extensions/bulkMailFilters.php | 286 +
.../members/extensions/coreExtensions.php | 16 +-
.../members/extensions/coreVariables.php | 6 +-
.../extensions/dashboardNotifications.php | 4 +-
.../members/extensions/dataHookLocations.php | 6 +-
.../members/extensions/editorSections.php | 6 +-
.../members/extensions/emailLists.php | 117 +
.../extensions/enhancements/mandrill.php | 130 +
.../enhancements/spammonitoring.php | 69 +
.../members/extensions/furlRedirect.php | 6 +-
.../members/extensions/furlTemplates.php | 230 +-
.../members/extensions/furlTemplatesID.php | 124 +
.../members/extensions/memberSync.php | 19 +-
.../extensions/modcp/plugin_banned.php | 2 +-
.../extensions/modcp/plugin_iplookup.php | 8 +-
.../extensions/modcp/plugin_modposts.php | 2 +-
.../extensions/modcp/plugin_restrictposts.php | 2 +-
.../extensions/modcp/plugin_suspended.php | 2 +-
.../members/extensions/modcp/plugin_warn.php | 2 +-
.../extensions/notifications/config.php | 41 +-
.../members/extensions/notifications/pm.php | 6 +-
.../extensions/profileTabs/friends.conf.php | 6 +-
.../extensions/profileTabs/friends.php | 12 +-
.../profileTabs/reputation.conf.php | 6 +-
.../extensions/profileTabs/reputation.php | 12 +-
.../extensions/profileTabs/status.conf.php | 6 +-
.../members/extensions/profileTabs/status.php | 7 +-
.../extensions/reportPlugins/messages.php | 20 +-
.../extensions/reportPlugins/profiles.php | 33 +-
.../members/extensions/search/config.php | 14 +-
.../members/extensions/search/engines/sql.php | 1054 +-
.../members/extensions/search/form.php | 6 +-
.../members/extensions/search/format.php | 6 +-
.../members/extensions/sphinxTemplate.php | 2 +-
.../members/extensions/warnings.php | 2 +-
.../applications/members/js/ipsEditGroup.js | 6 +-
.../members/modules_admin/ajax/bulkmail.php | 98 +
.../modules_admin/ajax/defaultSection.php | 2 +-
.../members/modules_admin/ajax/editform.php | 14 +-
.../members/modules_admin/ajax/members.php | 10 +-
.../modules_admin/bulkmail/bulkmail.php | 818 +-
.../modules_admin/bulkmail/defaultSection.php | 2 +-
.../modules_admin/bulkmail/xml/menu.xml | 5 +-
.../bulkmail/xml/permissions.xml | 18 +-
.../modules_admin/cfields/customfields.php | 10 +-
.../modules_admin/cfields/defaultSection.php | 2 +-
.../modules_admin/cfields/xml/menu.xml | 4 +-
.../modules_admin/cfields/xml/permissions.xml | 20 +-
.../modules_admin/groups/defaultSection.php | 2 +-
.../members/modules_admin/groups/groups.php | 56 +-
.../modules_admin/groups/permissions.php | 9 +-
.../members/modules_admin/groups/xml/menu.xml | 8 +-
.../modules_admin/groups/xml/permissions.xml | 20 +-
.../modules_admin/members/banfilters.php | 2 +-
.../modules_admin/members/defaultSection.php | 2 +-
.../modules_admin/members/editform.php | 24 +-
.../members/modules_admin/members/members.php | 257 +-
.../modules_admin/members/notifications.php | 6 +-
.../members/modules_admin/members/ranks.php | 14 +-
.../modules_admin/members/reputation.php | 6 +-
.../members/modules_admin/members/tools.php | 2805 +-
.../modules_admin/members/xml/menu.xml | 28 +-
.../modules_admin/members/xml/permissions.xml | 78 +-
.../restrictions/defaultSection.php | 2 +-
.../restrictions/restrictions.php | 1726 +-
.../modules_admin/restrictions/xml/menu.xml | 4 +-
.../restrictions/xml/permissions.xml | 14 +-
.../modules_admin/warnings/actions.php | 14 +-
.../modules_admin/warnings/defaultSection.php | 8 +-
.../modules_admin/warnings/reasons.php | 6 +-
.../modules_admin/warnings/xml/menu.xml | 8 +-
.../warnings/xml/permissions.xml | 20 +-
.../members/modules_public/ajax/card.php | 8 +-
.../members/modules_public/ajax/dname.php | 6 +-
.../members/modules_public/ajax/dst.php | 6 +-
.../members/modules_public/ajax/friends.php | 6 +-
.../members/modules_public/ajax/ignore.php | 6 +-
.../members/modules_public/ajax/load.php | 6 +-
.../members/modules_public/ajax/messenger.php | 16 +-
.../members/modules_public/ajax/photo.php | 8 +-
.../members/modules_public/ajax/rate.php | 10 +-
.../members/modules_public/ajax/status.php | 34 +-
.../members/modules_public/ajax/warnings.php | 8 +-
.../modules_public/list/defaultSection.php | 2 +-
.../members/modules_public/list/view.php | 1146 +-
.../messaging/defaultSection.php | 2 +-
.../modules_public/messaging/markasread.php | 6 +-
.../modules_public/messaging/search.php | 6 +-
.../members/modules_public/messaging/send.php | 100 +-
.../members/modules_public/messaging/view.php | 1672 +-
.../modules_public/online/defaultSection.php | 2 +-
.../members/modules_public/online/online.php | 6 +-
.../modules_public/profile/defaultSection.php | 2 +-
.../members/modules_public/profile/dname.php | 6 +-
.../modules_public/profile/friends.php | 6 +-
.../members/modules_public/profile/ignore.php | 6 +-
.../members/modules_public/profile/photo.php | 8 +-
.../members/modules_public/profile/status.php | 84 +-
.../members/modules_public/profile/view.php | 1498 +-
.../modules_public/profile/warnings.php | 26 +-
.../modules_public/reputation/most.php | 14 +-
.../members/skin_cp/cp_skin_banfilters.php | 6 +-
.../members/skin_cp/cp_skin_bulkmail.php | 1472 +-
.../members/skin_cp/cp_skin_groups.php | 14 +-
.../members/skin_cp/cp_skin_member.php | 4530 +--
.../members/skin_cp/cp_skin_member_form.php | 6 +-
.../members/skin_cp/cp_skin_notifications.php | 6 +-
.../members/skin_cp/cp_skin_permissions.php | 8 +-
.../members/skin_cp/cp_skin_profilefields.php | 34 +-
.../members/skin_cp/cp_skin_ranks.php | 6 +-
.../members/skin_cp/cp_skin_reputation.php | 6 +-
.../members/skin_cp/cp_skin_restrictions.php | 1007 +-
.../members/skin_cp/cp_skin_tools.php | 15 +-
.../skin_cp/cp_skin_warnings_actions.php | 6 +-
.../skin_cp/cp_skin_warnings_reasons.php | 6 +-
.../members/sources/adminManage.php | 1722 +-
.../members/sources/adminSearch.php | 1897 +-
.../sources/classes/bulkMailFilter.php | 59 +
.../members/sources/classes/hooks/gateway.php | 6 +-
.../members/sources/classes/mandrill.php | 80 +
.../classes/messaging/messengerFunctions.php | 7996 +++--
.../applications/members/sources/friends.php | 6 +-
.../sources/tabs/pluginParentClass.php | 6 +-
.../members/sql/messengerSearch_mysql.php | 6 +-
.../applications/members/tasks/bulkmail.php | 10 +-
.../members/tasks/mobile_notifications.php | 10 +-
.../members/tasks/prunenotifications.php | 2 +-
.../members/tasks/removelocked.php | 2 +-
.../members/tasks/removevalidating.php | 48 +-
.../members/tasks/twitfacesync.php | 12 +-
.../members/tasks/update_profile_views.php | 2 +-
.../applications/members/tasks/warnings.php | 16 +-
.../xml/admin_members_language_pack.xml | 12234 +++----
.../admin/applications/members/xml/hooks.xml | 4 +
.../members/xml/hooks/mlist_alpharu.xml | 134 +
.../members/xml/hooks/status_updates.xml | 4 +-
.../applications/members/xml/information.xml | 10 +-
.../applications/members/xml/members_help.xml | 125 +-
.../members/xml/members_mobile_templates.xml | 159 +-
.../members/xml/members_modules.xml | 40 +-
.../members/xml/members_root_css.xml | 16 +-
.../members/xml/members_root_templates.xml | 382 +-
.../members/xml/members_settings.xml | 820 +-
.../members/xml/members_tasks.xml | 88 +-
.../members/xml/members_xmlskin_css.xml | 16 +-
.../members/xml/members_xmlskin_templates.xml | 69 +-
.../xml/public_members_language_pack.xml | 4073 +--
.../applications/members/xml/versions.xml | 44 +
upload/admin/extensions/coreVariables.php | 74 +-
.../admin/extensions/romanization.rename.php | 153 +
upload/admin/extensions/sphinxTemplate.php | 6 +-
upload/admin/extensions/userAgents.php | 116 +-
upload/admin/index.php | 9 +-
upload/admin/install/index.php | 7 +-
.../admin/js/3rd_party/jquery-ui-core.min.js | 2 +
upload/admin/js/3rd_party/jquery-ui.min.js | 396 +-
upload/admin/js/3rd_party/jquery.min.js | 20 +-
upload/admin/js/acp.hooks.js | 2 +-
upload/admin/js/acp.inlineforms.js | 10 +-
upload/admin/js/acp.jquery.js | 602 +-
upload/admin/js/acp.jquery.members.js | 30 +-
upload/admin/js/acp.jquery.tabprefs.js | 115 +
upload/admin/js/acp.js | 6 +-
upload/admin/js/acp.languages.js | 2 +-
upload/admin/js/acp.permissions.js | 2 +-
upload/admin/js/acp.permissions2.js | 2 +-
upload/admin/js/acp.replacements.js | 24 +-
upload/admin/js/acp.tabbed_basic_editor.js | 9 +
upload/admin/js/acp.templates.js | 12 +-
upload/admin/js/acp.uagents.js | 1 +
upload/admin/js/acp.upgrade.js | 14 +-
.../applications/install/sections/address.php | 182 +-
.../applications/install/sections/admin.php | 174 +-
.../applications/install/sections/apps.php | 306 +-
.../applications/install/sections/db.php | 560 +-
.../applications/install/sections/done.php | 94 +-
.../applications/install/sections/eula.php | 70 +-
.../applications/install/sections/index.php | 316 +-
.../applications/install/sections/install.php | 4021 +--
.../applications/install/sections/license.php | 85 +-
.../applications/upgrade/sections/apps.php | 756 +-
.../applications/upgrade/sections/convert.php | 101 +
.../applications/upgrade/sections/done.php | 188 +-
.../applications/upgrade/sections/index.php | 152 +-
.../applications/upgrade/sections/license.php | 85 +-
.../upgrade/sections/overview.php | 345 +-
.../applications/upgrade/sections/upgrade.php | 3272 +-
upload/admin/setup/cli/install.php | 20 +-
upload/admin/setup/cli/output.php | 8 +-
upload/admin/setup/sources/base/install.php | 444 +-
.../sources/base/ipsController_setup.php | 600 +-
.../setup/sources/base/ipsRegistry_setup.php | 5225 +--
upload/admin/setup/sources/base/setup.php | 35 +-
.../setup/sources/classes/output/output.php | 1668 +-
.../sources/classes/session/sessions.php | 528 +-
upload/admin/setup/sources/legacy/1xx.php | 442 +-
upload/admin/setup/sources/legacy/2xx.php | 528 +-
upload/admin/setup/sources/legacy/3xx.php | 510 +-
upload/admin/setup/sql/ipb3_mysql.php | 8 +-
upload/admin/setup/sql/mysql_install.php | 568 +-
upload/admin/setup/templates/skin_setup.php | 516 +-
upload/admin/setup/xml/config.xml | 4 +-
upload/admin/setup/xml/groups.xml | 12 +-
upload/admin/setup/xml/loginauth.xml | 47 +-
upload/admin/setup/xml/requiredextensions.php | 16 +-
upload/admin/setup/xml/sequence.xml | 94 +-
.../setup/xml/skins/replacements_mobile.xml | 6 +
.../setup/xml/skins/replacements_root.xml | 6 +
upload/admin/setup/xml/skins/setsData.xml | 20 +-
upload/admin/setup/xml/system_templates.xml | 431 +
upload/admin/setup/xml/upgrade_sequence.xml | 69 +-
upload/admin/setup/xml/writeablefiles.xml | 8 +
upload/admin/skin_cp/acp.css | 200 +-
upload/admin/skin_cp/cp_skin_global.php | 323 +-
.../skin_cp/images/icons/bookmark_grey_20.png | Bin 0 -> 393 bytes
.../images/icons/bookmark_white_20.png | Bin 0 -> 302 bytes
.../skin_cp/images/members/vkontakte.png | Bin 0 -> 853 bytes
upload/admin/sources/base/core.php | 681 +-
upload/admin/sources/base/darkLAE.php | 172 +
upload/admin/sources/base/ipsController.php | 956 +-
upload/admin/sources/base/ipsMember.php | 8833 ++---
upload/admin/sources/base/ipsMobileApp.php | 8 +-
upload/admin/sources/base/ipsRegistry.php | 9286 +++---
.../admin/sources/classes/admin/bookmarks.php | 295 +
upload/admin/sources/classes/ads.php | 4 +-
.../admin/sources/classes/archive/reader.php | 2 +-
.../sources/classes/archive/reader/sql.php | 12 +-
.../admin/sources/classes/archive/restore.php | 858 +-
.../sources/classes/archive/restore/sql.php | 350 +-
.../admin/sources/classes/archive/writer.php | 1396 +-
.../sources/classes/archive/writer/sql.php | 2 +-
upload/admin/sources/classes/backup.php | 742 +
upload/admin/sources/classes/backup/db.php | 339 +
upload/admin/sources/classes/bbcode/core.php | 5597 ++--
.../sources/classes/bbcode/custom/ccs.php | 6 +-
.../classes/bbcode/custom/defaults.php | 5742 ++--
.../admin/sources/classes/bbcode/legacy.php | 1370 +-
upload/admin/sources/classes/cache/simple.php | 6 +-
.../sources/classes/class_admin_functions.php | 18 +-
.../sources/classes/class_localization.php | 1815 +-
.../sources/classes/class_permissions.php | 47 +-
.../classes/class_public_permissions.php | 4 +-
.../classes/class_reputation_cache.php | 23 +-
.../sources/classes/class_taskmanager.php | 12 +-
.../sources/classes/comments/bootstrap.php | 93 +-
.../classes/customfields/profileFields.php | 24 +-
.../sources/classes/editor/class_editor.php | 6 +-
.../classes/editor/class_editor_rte.php | 8 +-
.../classes/editor/class_editor_std.php | 6 +-
.../sources/classes/editor/composite.php | 3176 +-
.../sources/classes/facebook/connect.php | 2075 +-
.../classes/incomingEmail/incomingEmail.php | 231 +-
.../classes/itemmarking/classItemMarking.php | 23 +-
.../admin/sources/classes/like/composite.php | 207 +-
.../sources/classes/mapping/bootstrap.php | 6 +-
.../sources/classes/mapping/engines/bing.php | 16 +-
.../classes/mapping/engines/google.php | 6 +-
.../classes/member/memberFunctions.php | 1937 +-
.../sources/classes/member/notifications.php | 119 +-
upload/admin/sources/classes/member/photo.php | 2252 +-
.../admin/sources/classes/member/status.php | 186 +-
.../sources/classes/mobile/iosImages.php | 2 +-
.../sources/classes/navigation/build.php | 6 +-
.../sources/classes/nodes/classNodes.php | 1204 -
.../sources/classes/output/adminOutput.php | 362 +-
.../classes/output/formats/coreOutput.php | 35 +-
.../classes/output/formats/html/conf.php | 6 +-
.../output/formats/html/htmlOutput.php | 2054 +-
.../classes/output/formats/xml/conf.php | 6 +-
.../classes/output/formats/xml/xmlOutput.php | 6 +-
.../sources/classes/output/publicOutput.php | 7780 ++---
.../classes/output/systemTemplates.php | 245 +
upload/admin/sources/classes/rss/import.php | 31 +-
.../classes/sabre/directory/groups.php | 6 +-
.../classes/sabre/directory/templates.php | 6 +-
.../sources/classes/sabre/files/templates.php | 6 +-
.../sources/classes/sabre/lock/nolocks.php | 6 +-
.../sources/classes/sabre/root/skins.php | 6 +-
.../sources/classes/search/controller.php | 12 +-
.../sources/classes/search/engines/sphinx.php | 11 +-
.../sources/classes/search/engines/sql.php | 15 +-
.../admin/sources/classes/search/format.php | 6 +-
.../sources/classes/session/adminSessions.php | 10 +-
upload/admin/sources/classes/session/api.php | 28 +-
.../classes/session/convergeSessions.php | 75 -
.../classes/session/publicSessions.php | 3378 +-
.../sources/classes/session/sso.rename.php | 6 +-
.../session/ssoMobileAppLogIn.rename.php | 2 +-
upload/admin/sources/classes/share/links.php | 75 +-
.../classes/share/plugins/blogthis.php | 15 +-
.../classes/share/plugins/bobrdobr.php | 91 +
.../sources/classes/share/plugins/buzz.php | 6 +-
.../classes/share/plugins/delicious.php | 6 +-
.../sources/classes/share/plugins/digg.php | 6 +-
.../classes/share/plugins/download.php | 13 +-
.../sources/classes/share/plugins/email.php | 6 +-
.../classes/share/plugins/facebook.php | 6 +-
.../classes/share/plugins/googleplusone.php | 2 +-
.../sources/classes/share/plugins/memori.php | 91 +
.../sources/classes/share/plugins/print.php | 11 +-
.../sources/classes/share/plugins/reddit.php | 6 +-
.../sources/classes/share/plugins/stumble.php | 6 +-
.../sources/classes/share/plugins/twitter.php | 21 +-
.../classes/share/plugins/vkontakte.php | 91 +
.../sources/classes/skins/skinCaching.php | 61 +-
.../sources/classes/skins/skinDifferences.php | 8 +-
.../sources/classes/skins/skinFunctions.php | 33 +-
.../sources/classes/skins/skinGenerator.php | 274 +-
.../classes/skins/skinImportExport.php | 13 +-
.../admin/sources/classes/tags/abstract.php | 94 +-
.../admin/sources/classes/tags/bootstrap.php | 6 +-
upload/admin/sources/classes/tags/cloud.php | 6 +-
.../classes/tags/extensions/default.php | 6 +-
.../sources/classes/tags/search/bootstrap.php | 6 +-
.../sources/classes/tags/search/sphinx.php | 26 +-
.../admin/sources/classes/tags/search/sql.php | 16 +-
upload/admin/sources/classes/text/parser.php | 2568 ++
.../sources/classes/text/parser/bbcode.php | 1695 +
.../classes/text/parser/bbcode/ccs.php | 148 +
.../classes/text/parser/bbcode/defaults.php | 2998 ++
.../sources/classes/text/parser/html.php | 1458 +
.../sources/classes/text/parser/legacy.php | 145 +
.../sources/classes/tiers/recursiveTiers.php | 1318 +-
.../admin/sources/classes/twitter/connect.php | 1511 +-
.../sources/classes/url/apis/bitly/api.php | 8 +-
.../sources/classes/url/apis/bitly/conf.php | 6 +-
.../sources/classes/url/apis/topic/api.php | 146 +-
.../sources/classes/url/apis/topic/conf.php | 6 +-
.../sources/classes/url/apis/topic/index.html | 18 +-
upload/admin/sources/classes/url/shorten.php | 6 +-
.../classes/useragents/userAgentFunctions.php | 23 +-
.../classes/virusChecker/lib_known_names.php | 8 +-
.../virusChecker/lib_writeable_dirs.php | 13 +-
.../classes/virusChecker/plugins/example.php | 6 +-
.../classes/virusChecker/virusChecker.php | 6 +-
.../sources/classes/vkontakte/connect.php | 733 +
upload/admin/sources/handlers/han_editor.php | 332 -
upload/admin/sources/handlers/han_email.php | 2033 +-
upload/admin/sources/handlers/han_login.php | 144 +-
.../sources/handlers/han_parse_bbcode.php | 9 +-
.../admin/download_category_form.php | 2 +-
.../sources/interfaces/admin/forum_form.php | 2 +-
.../sources/interfaces/admin/group_form.php | 2 +-
.../sources/interfaces/admin/member_form.php | 2 +-
.../sources/interfaces/interface_bbcode.php | 6 +-
.../sources/interfaces/interface_output.php | 6 +-
.../sources/interfaces/interface_usercp.php | 6 +-
.../admin/sources/loginauth/convert/auth.php | 1790 +-
.../sources/loginauth/convert/auth_sha256.php | 6 +-
.../loginauth/convert/loginauth_install.xml | 6 +-
.../sources/loginauth/convert/newauth.php | 15 +-
.../admin/sources/loginauth/external/acp.php | 188 +-
.../admin/sources/loginauth/external/auth.php | 490 +-
.../loginauth/external/loginauth_install.xml | 6 +-
.../admin/sources/loginauth/internal/auth.php | 232 +-
.../loginauth/internal/loginauth_install.xml | 6 +-
.../sources/loginauth/ipconverge/auth.php | 671 -
.../ipconverge/loginauth_install.xml | 21 -
.../sources/loginauth/ipsconnect/acp.php | 24 +
.../sources/loginauth/ipsconnect/auth.php | 595 +
.../sources/loginauth/ipsconnect}/index.html | 0
.../ipsconnect/loginauth_install.xml | 23 +
upload/admin/sources/loginauth/ldap/acp.php | 244 +-
upload/admin/sources/loginauth/ldap/auth.php | 772 +-
.../loginauth/ldap/loginauth_install.xml | 6 +-
upload/admin/sources/loginauth/live/acp.php | 59 +-
upload/admin/sources/loginauth/live/auth.php | 566 +-
.../loginauth/live/loginauth_install.xml | 4 +-
upload/admin/sources/loginauth/login_core.php | 29 +-
.../sources/loginauth/login_interface.php | 6 +-
.../sources/template_plugins/tp_addtohead.php | 6 +-
.../sources/template_plugins/tp_currency.php | 6 +-
.../sources/template_plugins/tp_date.php | 10 +-
.../sources/template_plugins/tp_editor.php | 6 +-
.../template_plugins/tp_expression.php | 6 +-
.../template_plugins/tp_format_number.php | 6 +-
.../sources/template_plugins/tp_include.php | 6 +-
.../sources/template_plugins/tp_ipcmedia.php | 2 +-
.../sources/template_plugins/tp_js_module.php | 6 +-
.../sources/template_plugins/tp_lang.php | 6 +-
.../template_plugins/tp_replacement.php | 6 +-
.../template_plugins/tp_resize_image.php | 6 +-
.../sources/template_plugins/tp_striping.php | 6 +-
.../sources/template_plugins/tp_template.php | 11 +-
.../admin/sources/template_plugins/tp_url.php | 15 +-
.../sources/template_plugins/tp_variable.php | 6 +-
upload/admin/upgrade/index.php | 7 +-
upload/cache/skin_cache/emailWrapper.php | 187 -
upload/cache/skin_cache/ipsDriverError.php | 185 -
upload/cache/skin_cache/ipsServerError.php | 171 -
upload/cache/skin_cache/masterMap.php | 13 +-
.../converge_local/apis/allowed_methods.php | 198 -
.../converge_local/apis/server_functions.php | 934 -
upload/converge_local/converge.php | 547 -
upload/converge_local/converge_server.php | 103 -
upload/dav.php | 21 +-
upload/index.php | 10 +-
upload/initdata.php | 52 +-
upload/interface/board/index.php | 6 +-
upload/interface/board/live.php | 6 +-
upload/interface/board/modules/ipb/api.php | 118 +-
upload/interface/board/modules/ipb/config.php | 6 +-
.../interface/board/modules/ipb/methods.php | 10 +-
upload/interface/facebook/channel.php | 2 +-
upload/interface/facebook/index.php | 6 +-
upload/interface/facebook/xd_receiver.php | 6 +-
upload/interface/facebook/xd_receiver_ssl.php | 6 +-
upload/interface/ips.php | 76 +-
upload/interface/ipsconnect/custom.rename.php | 48 +
.../ipsconnect}/index.html | 0
upload/interface/ipsconnect/ipsconnect.php | 775 +
upload/interface/mobile/index.php | 6 +-
upload/interface/task.php | 12 +-
upload/interface/twitter/index.php | 12 +-
upload/interface/vkontakte/index.php | 76 +
.../HTMLPurifier/AttrDef/URI/Host.php | 203 +-
.../AttrTransform/TargetBlank.php | 2 +-
.../HTMLPurifier/Injector/Linkify.php | 145 +-
.../HTMLPurifier/HTMLPurifier/Lexer/PH5P.php | 1 -
upload/ips_kernel/PEAR/Mail/mime.php | 73 +-
upload/ips_kernel/PEAR/Mail/mimeDecode.php | 2 +-
upload/ips_kernel/PEAR/Mail/mimePart.php | 103 +-
.../ips_kernel/PEAR/Net_IDNA2/Net/IDNA2.php | 3403 ++
.../PEAR/Net_IDNA2/Net/IDNA2/Exception.php | 4 +
.../Net/IDNA2/Exception/Nameprep.php | 6 +
.../Net_IDNA2/docs/examples/example_web.php | 146 +
.../PEAR/Net_IDNA2/tests/AllTests.php | 32 +
.../PEAR/Net_IDNA2/tests/Net_IDNA2Test.php | 68 +
upload/ips_kernel/classAjax.php | 848 +-
upload/ips_kernel/classApiServer.php | 10 +-
upload/ips_kernel/classCacheApc.php | 6 +-
upload/ips_kernel/classCacheDiskcache.php | 6 +-
upload/ips_kernel/classCacheEaccelerator.php | 6 +-
upload/ips_kernel/classCacheMemcache.php | 6 +-
upload/ips_kernel/classCacheWincache.php | 6 +-
upload/ips_kernel/classCacheXcache.php | 6 +-
upload/ips_kernel/classCaptcha.php | 202 +-
.../ips_kernel/classCaptchaPlugin/default.php | 2 +-
.../classCaptchaPlugin/keycaptcha.php | 262 +
.../classCaptchaPlugin/recaptcha.php | 13 +-
upload/ips_kernel/classConvertCharset.php | 26 +-
upload/ips_kernel/classCustomFields.php | 1810 +-
upload/ips_kernel/classDb.php | 3967 +--
upload/ips_kernel/classDbMysql.php | 157 +-
upload/ips_kernel/classDbMysqlClient.php | 1216 +-
upload/ips_kernel/classDbMysqliClient.php | 1334 +-
upload/ips_kernel/classDifference.php | 870 +-
upload/ips_kernel/classEmail.php | 2742 +-
upload/ips_kernel/classFileManagement.php | 1841 +-
upload/ips_kernel/classFtp.php | 16 +-
upload/ips_kernel/classGraph.php | 6164 ++--
upload/ips_kernel/classImage.php | 6 +-
upload/ips_kernel/classImageGd.php | 47 +-
upload/ips_kernel/classImageImagemagick.php | 12 +-
upload/ips_kernel/classMerge.php | 6 +-
upload/ips_kernel/classRss.php | 2316 +-
upload/ips_kernel/classTemplateEngine.php | 14 +-
upload/ips_kernel/classUpload.php | 10 +-
upload/ips_kernel/classXML.php | 18 +-
upload/ips_kernel/classXMLArchive.php | 6 +-
upload/ips_kernel/classXmlRpc.php | 2108 +-
upload/ips_kernel/class_xml.php | 2962 +-
upload/ips_kernel/db_lib/mysql_tools.php | 31 +-
upload/ips_kernel/facebook/facebook.php | 2 +-
.../ips_kernel/interfaces/interfaceCache.php | 6 +-
upload/ips_kernel/twitter/twitteroauth.php | 4 +-
upload/ips_kernel/vkontakte/OAuth2Client.php | 799 +
.../vkontakte/OAuth2ClientNOSSL.php | 802 +
upload/ips_kernel/vkontakte/oauth2.php | 105 +
upload/lofiversion/index.php | 2 +-
upload/public/flowplayer/LICENSE.txt | 14 -
upload/public/flowplayer/README.txt | 113 +-
.../flowplayer/flowplayer-3.2.11.min.js | 24 +
.../public/flowplayer/flowplayer-3.2.15.swf | Bin 0 -> 126738 bytes
upload/public/flowplayer/flowplayer-3.2.7.swf | Bin 120221 -> 0 bytes
.../flowplayer/flowplayer.controls-3.2.14.swf | Bin 0 -> 38345 bytes
.../flowplayer/flowplayer.controls-3.2.5.swf | Bin 36843 -> 0 bytes
upload/public/ipc_blocks/core.js | 14 +-
.../calendar_date_select/format_american.js | 2 +-
.../calendar_date_select/format_danish.js | 2 +-
.../calendar_date_select/format_db.js | 2 +-
.../calendar_date_select/format_finnish.js | 2 +-
.../format_hyphen_ampm.js | 2 +-
.../calendar_date_select/format_ipb.js | 34 +
.../calendar_date_select/format_italian.js | 2 +-
.../public/js/3rd_party/ckeditor/ckeditor.js | 281 +-
.../js/3rd_party/ckeditor/ckeditor_basic.js | 6 +-
.../ckeditor/ckeditor_basic_source.js | 20 +
.../js/3rd_party/ckeditor/ckeditor_source.js | 4 +-
.../public/js/3rd_party/ckeditor/contents.css | 169 +-
.../js/3rd_party/ckeditor/ips_config.js | 57 +-
.../plugins/a11yhelp/dialogs/a11yhelp.js | 2 +-
.../a11yhelp/lang/_translationstatus.txt | 28 +
.../ckeditor/plugins/a11yhelp/lang/cs.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/cy.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/da.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/de.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/el.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/en.js | 6 +-
.../ckeditor/plugins/a11yhelp/lang/eo.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/fa.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/fi.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/fr.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/gu.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/he.js | 139 +-
.../ckeditor/plugins/a11yhelp/lang/it.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/ku.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/lv.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/mk.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/nb.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/nl.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/no.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/pt-br.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/ro.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/sk.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/tr.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/ug.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/vi.js | 89 +
.../ckeditor/plugins/a11yhelp/lang/zh-cn.js | 89 +
.../ckeditor/plugins/about/dialogs/about.js | 2 +-
.../ckeditor/plugins/adobeair/plugin.js | 2 +-
.../3rd_party/ckeditor/plugins/ajax/plugin.js | 2 +-
.../ckeditor/plugins/autogrow/plugin.js | 36 +-
.../ckeditor/plugins/bbcode/plugin.js | 56 +-
.../plugins/clipboard/dialogs/paste.js | 4 +-
.../colordialog/dialogs/colordialog.js | 233 +-
.../devtools/lang/_translationstatus.txt | 31 +
.../ckeditor/plugins/devtools/lang/bg.js | 16 +
.../ckeditor/plugins/devtools/lang/cs.js | 16 +
.../ckeditor/plugins/devtools/lang/cy.js | 16 +
.../ckeditor/plugins/devtools/lang/da.js | 16 +
.../ckeditor/plugins/devtools/lang/de.js | 16 +
.../ckeditor/plugins/devtools/lang/el.js | 16 +
.../ckeditor/plugins/devtools/lang/en.js | 2 +-
.../ckeditor/plugins/devtools/lang/eo.js | 16 +
.../ckeditor/plugins/devtools/lang/et.js | 16 +
.../ckeditor/plugins/devtools/lang/fa.js | 16 +
.../ckeditor/plugins/devtools/lang/fi.js | 16 +
.../ckeditor/plugins/devtools/lang/fr.js | 16 +
.../ckeditor/plugins/devtools/lang/gu.js | 16 +
.../ckeditor/plugins/devtools/lang/he.js | 16 +
.../ckeditor/plugins/devtools/lang/hr.js | 16 +
.../ckeditor/plugins/devtools/lang/it.js | 16 +
.../ckeditor/plugins/devtools/lang/ku.js | 16 +
.../ckeditor/plugins/devtools/lang/lv.js | 16 +
.../ckeditor/plugins/devtools/lang/nb.js | 16 +
.../ckeditor/plugins/devtools/lang/nl.js | 16 +
.../ckeditor/plugins/devtools/lang/no.js | 16 +
.../ckeditor/plugins/devtools/lang/pl.js | 16 +
.../ckeditor/plugins/devtools/lang/pt-br.js | 16 +
.../ckeditor/plugins/devtools/lang/sk.js | 16 +
.../ckeditor/plugins/devtools/lang/tr.js | 16 +
.../ckeditor/plugins/devtools/lang/ug.js | 16 +
.../ckeditor/plugins/devtools/lang/uk.js | 16 +
.../ckeditor/plugins/devtools/lang/vi.js | 16 +
.../ckeditor/plugins/devtools/lang/zh-cn.js | 16 +
.../ckeditor/plugins/devtools/plugin.js | 4 +-
.../plugins/dialog/dialogDefinition.js | 2 +-
.../ckeditor/plugins/div/dialogs/div.js | 2 +-
.../plugins/docprops/dialogs/docprops.js | 2 +-
.../ckeditor/plugins/docprops/plugin.js | 2 +-
.../ckeditor/plugins/find/dialogs/find.js | 15 +-
.../ckeditor/plugins/flash/dialogs/flash.js | 11 +-
.../ckeditor/plugins/forms/dialogs/button.js | 2 +-
.../plugins/forms/dialogs/checkbox.js | 2 +-
.../ckeditor/plugins/forms/dialogs/form.js | 2 +-
.../plugins/forms/dialogs/hiddenfield.js | 2 +-
.../ckeditor/plugins/forms/dialogs/radio.js | 2 +-
.../ckeditor/plugins/forms/dialogs/select.js | 2 +-
.../plugins/forms/dialogs/textarea.js | 2 +-
.../plugins/forms/dialogs/textfield.js | 2 +-
.../ckeditor/plugins/iframe/dialogs/iframe.js | 2 +-
.../ckeditor/plugins/iframedialog/plugin.js | 2 +-
.../ckeditor/plugins/image/dialogs/image.js | 13 +-
.../plugins/ipsbbcode/dialogs/ipsbbcode.js | 57 +-
.../plugins/ipscode/dialogs/ipscode.js | 89 +-
.../plugins/ipsimage/dialogs/ipsimage.js | 1865 ++
.../plugins/ipsimage/images/image.gif | Bin 0 -> 621 bytes
.../plugins/ipssourcearea/images/switch.png | Bin 0 -> 541 bytes
.../ckeditor/plugins/link/dialogs/anchor.js | 5 +-
.../ckeditor/plugins/link/dialogs/link.js | 19 +-
.../plugins/liststyle/dialogs/liststyle.js | 2 +-
.../plugins/pastefromword/filter/default.js | 2 +-
.../plugins/pastetext/dialogs/pastetext.js | 4 +-
.../placeholder/dialogs/placeholder.js | 2 +-
.../placeholder/lang/_translationstatus.txt | 30 +
.../ckeditor/plugins/placeholder/lang/bg.js | 16 +
.../ckeditor/plugins/placeholder/lang/cs.js | 16 +
.../ckeditor/plugins/placeholder/lang/cy.js | 16 +
.../ckeditor/plugins/placeholder/lang/da.js | 16 +
.../ckeditor/plugins/placeholder/lang/de.js | 16 +
.../ckeditor/plugins/placeholder/lang/el.js | 16 +
.../ckeditor/plugins/placeholder/lang/en.js | 2 +-
.../ckeditor/plugins/placeholder/lang/eo.js | 16 +
.../ckeditor/plugins/placeholder/lang/et.js | 16 +
.../ckeditor/plugins/placeholder/lang/fa.js | 16 +
.../ckeditor/plugins/placeholder/lang/fi.js | 16 +
.../ckeditor/plugins/placeholder/lang/fr.js | 16 +
.../ckeditor/plugins/placeholder/lang/he.js | 2 +-
.../ckeditor/plugins/placeholder/lang/hr.js | 16 +
.../ckeditor/plugins/placeholder/lang/it.js | 16 +
.../ckeditor/plugins/placeholder/lang/ku.js | 16 +
.../ckeditor/plugins/placeholder/lang/lv.js | 16 +
.../ckeditor/plugins/placeholder/lang/nb.js | 16 +
.../ckeditor/plugins/placeholder/lang/nl.js | 16 +
.../ckeditor/plugins/placeholder/lang/no.js | 16 +
.../ckeditor/plugins/placeholder/lang/pl.js | 16 +
.../plugins/placeholder/lang/pt-br.js | 16 +
.../ckeditor/plugins/placeholder/lang/sk.js | 16 +
.../ckeditor/plugins/placeholder/lang/tr.js | 16 +
.../ckeditor/plugins/placeholder/lang/ug.js | 16 +
.../ckeditor/plugins/placeholder/lang/uk.js | 16 +
.../ckeditor/plugins/placeholder/lang/vi.js | 16 +
.../plugins/placeholder/lang/zh-cn.js | 16 +
.../ckeditor/plugins/placeholder/plugin.js | 4 +-
.../ckeditor/plugins/preview/preview.html | 10 +
.../ckeditor/plugins/scayt/dialogs/options.js | 2 +-
.../ckeditor/plugins/smiley/dialogs/smiley.js | 10 +-
.../specialchar/dialogs/specialchar.js | 8 +-
.../specialchar/lang/_translationstatus.txt | 25 +
.../ckeditor/plugins/specialchar/lang/cs.js | 126 +
.../ckeditor/plugins/specialchar/lang/cy.js | 126 +
.../ckeditor/plugins/specialchar/lang/de.js | 126 +
.../ckeditor/plugins/specialchar/lang/el.js | 126 +
.../ckeditor/plugins/specialchar/lang/en.js | 242 +-
.../ckeditor/plugins/specialchar/lang/eo.js | 126 +
.../ckeditor/plugins/specialchar/lang/et.js | 126 +
.../ckeditor/plugins/specialchar/lang/fa.js | 126 +
.../ckeditor/plugins/specialchar/lang/fi.js | 126 +
.../ckeditor/plugins/specialchar/lang/fr.js | 126 +
.../ckeditor/plugins/specialchar/lang/he.js | 126 +
.../ckeditor/plugins/specialchar/lang/hr.js | 126 +
.../ckeditor/plugins/specialchar/lang/it.js | 126 +
.../ckeditor/plugins/specialchar/lang/ku.js | 126 +
.../ckeditor/plugins/specialchar/lang/lv.js | 126 +
.../ckeditor/plugins/specialchar/lang/nb.js | 126 +
.../ckeditor/plugins/specialchar/lang/nl.js | 126 +
.../ckeditor/plugins/specialchar/lang/no.js | 126 +
.../plugins/specialchar/lang/pt-br.js | 126 +
.../ckeditor/plugins/specialchar/lang/sk.js | 126 +
.../ckeditor/plugins/specialchar/lang/tr.js | 126 +
.../ckeditor/plugins/specialchar/lang/ug.js | 126 +
.../plugins/specialchar/lang/zh-cn.js | 126 +
.../ckeditor/plugins/styles/styles/default.js | 2 +-
.../plugins/stylesheetparser/plugin.js | 2 +-
.../ckeditor/plugins/table/dialogs/table.js | 51 +-
.../ckeditor/plugins/tableresize/plugin.js | 10 +-
.../plugins/tabletools/dialogs/tableCell.js | 15 +-
.../plugins/templates/dialogs/templates.js | 2 +-
.../plugins/templates/templates/default.js | 2 +-
.../plugins/uicolor/dialogs/uicolor.js | 2 +-
.../uicolor/lang/_translationstatus.txt | 31 +
.../ckeditor/plugins/uicolor/lang/bg.js | 15 +
.../ckeditor/plugins/uicolor/lang/cs.js | 15 +
.../ckeditor/plugins/uicolor/lang/cy.js | 15 +
.../ckeditor/plugins/uicolor/lang/da.js | 15 +
.../ckeditor/plugins/uicolor/lang/de.js | 15 +
.../ckeditor/plugins/uicolor/lang/el.js | 15 +
.../ckeditor/plugins/uicolor/lang/en.js | 2 +-
.../ckeditor/plugins/uicolor/lang/eo.js | 15 +
.../ckeditor/plugins/uicolor/lang/et.js | 15 +
.../ckeditor/plugins/uicolor/lang/fa.js | 15 +
.../ckeditor/plugins/uicolor/lang/fi.js | 15 +
.../ckeditor/plugins/uicolor/lang/fr.js | 15 +
.../ckeditor/plugins/uicolor/lang/he.js | 2 +-
.../ckeditor/plugins/uicolor/lang/hr.js | 15 +
.../ckeditor/plugins/uicolor/lang/it.js | 15 +
.../ckeditor/plugins/uicolor/lang/ku.js | 15 +
.../ckeditor/plugins/uicolor/lang/lv.js | 15 +
.../ckeditor/plugins/uicolor/lang/mk.js | 15 +
.../ckeditor/plugins/uicolor/lang/nb.js | 15 +
.../ckeditor/plugins/uicolor/lang/nl.js | 15 +
.../ckeditor/plugins/uicolor/lang/no.js | 15 +
.../ckeditor/plugins/uicolor/lang/pl.js | 15 +
.../ckeditor/plugins/uicolor/lang/pt-br.js | 15 +
.../ckeditor/plugins/uicolor/lang/sk.js | 15 +
.../ckeditor/plugins/uicolor/lang/tr.js | 15 +
.../ckeditor/plugins/uicolor/lang/ug.js | 15 +
.../ckeditor/plugins/uicolor/lang/uk.js | 15 +
.../ckeditor/plugins/uicolor/lang/vi.js | 15 +
.../ckeditor/plugins/uicolor/lang/zh-cn.js | 15 +
.../ckeditor/plugins/uicolor/plugin.js | 4 +-
.../ckeditor/plugins/wsc/dialogs/ciframe.html | 2 +-
.../plugins/wsc/dialogs/tmpFrameset.html | 2 +-
.../ckeditor/plugins/wsc/dialogs/wsc.css | 2 +-
.../ckeditor/plugins/wsc/dialogs/wsc.js | 2 +-
.../3rd_party/ckeditor/plugins/xml/plugin.js | 2 +-
.../3rd_party/ckeditor/skins/ips/dialog.css | 2 +-
upload/public/js/3rd_party/cropper/cropper.js | 4 +-
.../3rd_party/cropper/cropper.uncompressed.js | 57 +-
.../public/js/3rd_party/cropper/licence.txt | 2 +-
upload/public/js/3rd_party/iscroll/iscroll.js | 306 +-
upload/public/js/3rd_party/lightbox.js | 2 +-
.../public/js/3rd_party/prettify/lang-css.js | 3 +-
.../public/js/3rd_party/prettify/lang-sql.js | 3 +-
.../public/js/3rd_party/prettify/prettify.js | 76 +-
upload/public/js/3rd_party/prototype.js | 4316 ++-
upload/public/js/ipb.js | 327 +-
upload/public/js/ips.attach.js | 28 +-
upload/public/js/ips.board.js | 1 -
upload/public/js/ips.comments.js | 40 +-
upload/public/js/ips.editor.js | 8 +-
upload/public/js/ips.forums.js | 46 +-
upload/public/js/ips.gallery_patchwork.js | 438 +
upload/public/js/ips.gallery_slider.js | 23 +-
upload/public/js/ips.memberlist.js | 6 +-
upload/public/js/ips.misc.js | 2 +-
upload/public/js/ips.nexus.checkout.js | 60 +-
upload/public/js/ips.photoEditor.js | 9 +-
upload/public/js/ips.post.js | 4 +-
upload/public/js/ips.quickpm.js | 8 +-
upload/public/js/ips.register.js | 12 +-
upload/public/js/ips.search.js | 60 +-
upload/public/js/ips.sharelinks.js | 4 +-
upload/public/js/ips.skin_gen.js | 168 +-
upload/public/js/ips.status.js | 28 +-
upload/public/js/ips.tags.js | 15 +-
upload/public/js/ips.textEditor.bbcode.js | 1928 ++
upload/public/js/ips.textEditor.js | 1417 +-
upload/public/js/ips.topic.js | 177 +-
upload/public/js/ips.ucp.js | 3 +-
upload/public/js/mobile_touch.js | 191 +-
upload/public/min/README.txt | 150 +-
upload/public/min/builder/_index.js | 164 +-
upload/public/min/builder/index.php | 199 +-
upload/public/min/builder/ocCheck.php | 4 +-
upload/public/min/config.php | 2 +-
upload/public/min/index.php | 38 +-
upload/public/min/lib/FirePHP.php | 8 +-
upload/public/min/lib/HTTP/ConditionalGet.php | 52 +-
upload/public/min/lib/HTTP/Encoder.php | 93 +-
upload/public/min/lib/JSMin.php | 135 +-
upload/public/min/lib/Minify.php | 229 +-
upload/public/min/lib/Minify/Build.php | 2 +-
upload/public/min/lib/Minify/CSS.php | 50 +-
.../public/min/lib/Minify/CSS/Compressor.php | 33 +-
.../public/min/lib/Minify/CSS/UriRewriter.php | 220 +-
upload/public/min/lib/Minify/Cache/APC.php | 9 +-
upload/public/min/lib/Minify/Cache/File.php | 142 +-
.../public/min/lib/Minify/Cache/Memcache.php | 9 +-
.../min/lib/Minify/CommentPreserver.php | 7 +-
.../public/min/lib/Minify/Controller/Base.php | 66 +-
.../min/lib/Minify/Controller/Files.php | 2 +-
.../min/lib/Minify/Controller/Groups.php | 11 +-
.../min/lib/Minify/Controller/MinApp.php | 199 +-
.../public/min/lib/Minify/Controller/Page.php | 11 +-
.../min/lib/Minify/Controller/Version1.php | 4 +-
upload/public/min/lib/Minify/HTML.php | 491 +-
.../public/min/lib/Minify/ImportProcessor.php | 373 +-
upload/public/min/lib/Minify/Lines.php | 20 +-
upload/public/min/lib/Minify/Logger.php | 2 +
upload/public/min/lib/Minify/Packer.php | 2 +-
.../public/min/lib/Minify/YUICompressor.php | 23 +-
upload/public/min/utils.php | 128 +-
upload/public/style_css/ipb_rtl.css | 4255 +--
upload/public/style_css/prettify.css | 70 +-
.../style_extra/cprofile_icons/profile_vk.gif | Bin 0 -> 953 bytes
.../style_extra/cprofile_icons/profile_vk.png | Bin 0 -> 625 bytes
.../style_extra/sharelinks/bobrdobr.png | Bin 0 -> 884 bytes
.../public/style_extra/sharelinks/memori.png | Bin 0 -> 474 bytes
.../style_extra/sharelinks/vkontakte.png | Bin 0 -> 1487 bytes
.../public/style_extra/sharelinks/yandex.png | Bin 0 -> 802 bytes
.../public/style_images/master/cross_10px.png | Bin 0 -> 216 bytes
.../style_images/master/cross_white_10px.png | Bin 0 -> 210 bytes
.../master/icon_check_white_8px.png | Bin 0 -> 230 bytes
.../public/style_images/master/icon_share.png | Bin 0 -> 1201 bytes
.../master/loginmethods/vkontakte.png | Bin 0 -> 853 bytes
.../public/style_images/master/meta_image.png | Bin 7321 -> 14908 bytes
.../style_images/master/right_white_10px.png | Bin 0 -> 163 bytes
.../style_images/master/rte_icons/copy.png | Bin 0 -> 663 bytes
.../style_images/master/rte_icons/find.png | Bin 0 -> 569 bytes
.../master/rte_icons/ips_bbcode.png | Bin 0 -> 585 bytes
.../master/rte_icons/ips_options.png | Bin 0 -> 3639 bytes
.../style_images/master/rte_icons/paste.png | Bin 0 -> 654 bytes
.../master/rte_icons/paste_plain.png | Bin 0 -> 739 bytes
.../master/rte_icons/paste_word.png | Bin 0 -> 731 bytes
.../style_images/master/rte_icons/redo.png | Bin 610 -> 477 bytes
.../master/rte_icons/remove_formatting.png | Bin 859 -> 521 bytes
.../style_images/master/rte_icons/replace.png | Bin 0 -> 632 bytes
.../master/rte_icons/text_color.png | Bin 0 -> 264 bytes
.../style_images/master/rte_icons/toggle.png | Bin 0 -> 541 bytes
.../style_images/master/rte_icons/undo.png | Bin 608 -> 463 bytes
.../style_images/master/rte_icons/unlink.png | Bin 0 -> 535 bytes
.../style_images/master/subforum_stem_rtl.png | Bin 0 -> 188 bytes
.../public/style_images/master/tick_10px.png | Bin 0 -> 199 bytes
.../style_images/master/vkontakte_login.png | Bin 0 -> 4624 bytes
.../style_images/mobile/right_white_10px.png | Bin 0 -> 163 bytes
upload/public/style_status/vkontakte.png | Bin 0 -> 601 bytes
upload/robotstxt.txt | 27 +-
upload/uploads/index.html | 0
upload/uploads/profile/index.html | 0
1360 files changed, 228921 insertions(+), 179445 deletions(-)
delete mode 100644 upload/admin/Thumbs.db
create mode 100644 upload/admin/applications/core/extensions/enhancements/facebook.php
create mode 100644 upload/admin/applications/core/extensions/enhancements/googleanalytics.php
create mode 100644 upload/admin/applications/core/extensions/enhancements/ipsbackup.php
create mode 100644 upload/admin/applications/core/extensions/enhancements/ipscdn.php
create mode 100644 upload/admin/applications/core/extensions/enhancements/twitter.php
create mode 100644 upload/admin/applications/core/extensions/enhancements/viglink.php
create mode 100644 upload/admin/applications/core/extensions/enhancements/windowslive.php
create mode 100644 upload/admin/applications/core/extensions/furlTemplatesID.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/blog_entries.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/blogs.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/calendar.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/chat.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/content_database_categories.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/content_database_records.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/content_pages.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/core.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/downloads_categories.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/downloads_files.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/forums.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/gallery_albums.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/gallery_images.php
rename upload/admin/{sources/classes/nodes => applications/core/extensions/sitemapPlugins}/index.html (100%)
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/nexus_categories.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/nexus_products.php
create mode 100644 upload/admin/applications/core/extensions/sitemapPlugins/topics.php
create mode 100644 upload/admin/applications/core/modules_admin/ajax/bookmarks.php
create mode 100644 upload/admin/applications/core/modules_admin/ajax/editor.php
create mode 100644 upload/admin/applications/core/modules_admin/applications/enhancements.php
create mode 100644 upload/admin/applications/core/modules_admin/attach/attach.php
rename upload/admin/{sources/loginauth/ipconverge => applications/core/modules_admin/attach}/index.html (100%)
create mode 100644 upload/admin/applications/core/modules_admin/mycp/tabs.php
create mode 100644 upload/admin/applications/core/modules_admin/posts/acronyms.php
create mode 100644 upload/admin/applications/core/modules_admin/seo/activity.php
create mode 100644 upload/admin/applications/core/modules_admin/seo/advice.php
create mode 100644 upload/admin/applications/core/modules_admin/seo/defaultSection.php
create mode 100644 upload/admin/applications/core/modules_admin/seo/upgrade.php
create mode 100644 upload/admin/applications/core/modules_admin/seo/xml/menu.xml
create mode 100644 upload/admin/applications/core/modules_admin/seo/xml/permissions.xml
create mode 100644 upload/admin/applications/core/modules_admin/templates/meta.php
create mode 100644 upload/admin/applications/core/modules_admin/templates/systemTemplates.php
create mode 100644 upload/admin/applications/core/modules_public/global/meta.php
create mode 100644 upload/admin/applications/core/modules_public/global/sitemap.php
create mode 100644 upload/admin/applications/core/modules_public/global/unsubscribe.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_33016/index.html
create mode 100644 upload/admin/applications/core/setup/versions/upg_33016/mysql_updates.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34000/mysql_updates.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34000/version_class.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34000/version_upgrade.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34005/mysql_updates.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34007/mysql_updates.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34008/mysql_updates.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34009/mysql_updates.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34010/mysql_updates.php
create mode 100644 upload/admin/applications/core/setup/versions/upg_34011/mysql_updates.php
create mode 100644 upload/admin/applications/core/skin_cp/cp_skin_seo.php
create mode 100644 upload/admin/applications/core/skin_cp/images/bad.png
create mode 100644 upload/admin/applications/core/skin_cp/images/calendar-d.png
create mode 100644 upload/admin/applications/core/skin_cp/images/calendar-m.png
create mode 100644 upload/admin/applications/core/skin_cp/images/calendar-w.png
create mode 100644 upload/admin/applications/core/skin_cp/images/calendar.png
create mode 100644 upload/admin/applications/core/skin_cp/images/index.html
create mode 100644 upload/admin/applications/core/skin_cp/images/wand.png
create mode 100644 upload/admin/applications/core/skin_cp/images/warn.png
create mode 100644 upload/admin/applications/core/sources/classes/attach/controller.php
create mode 100644 upload/admin/applications/core/sql/mysql_seo_queries.php
create mode 100644 upload/admin/applications/core/tasks/backup.php
create mode 100644 upload/admin/applications/core/tasks/sitemapgenerator.php
create mode 100644 upload/admin/applications/core/xml/hooks/vkontakte.xml
create mode 100644 upload/admin/applications/forums/extensions/bulkMailFilters.php
create mode 100644 upload/admin/applications/forums/extensions/emailLists.php
create mode 100644 upload/admin/applications/forums/extensions/furlTemplatesID.php
create mode 100644 upload/admin/applications/forums/modules_public/extras/answer.php
create mode 100644 upload/admin/applications/members/extensions/bulkMailFilters.php
create mode 100644 upload/admin/applications/members/extensions/emailLists.php
create mode 100644 upload/admin/applications/members/extensions/enhancements/mandrill.php
create mode 100644 upload/admin/applications/members/extensions/enhancements/spammonitoring.php
create mode 100644 upload/admin/applications/members/extensions/furlTemplatesID.php
create mode 100644 upload/admin/applications/members/modules_admin/ajax/bulkmail.php
create mode 100644 upload/admin/applications/members/sources/classes/bulkMailFilter.php
create mode 100644 upload/admin/applications/members/sources/classes/mandrill.php
create mode 100644 upload/admin/applications/members/xml/hooks/mlist_alpharu.xml
create mode 100644 upload/admin/extensions/romanization.rename.php
create mode 100644 upload/admin/js/3rd_party/jquery-ui-core.min.js
create mode 100644 upload/admin/js/acp.jquery.tabprefs.js
create mode 100644 upload/admin/setup/applications/upgrade/sections/convert.php
create mode 100644 upload/admin/setup/xml/system_templates.xml
create mode 100644 upload/admin/skin_cp/images/icons/bookmark_grey_20.png
create mode 100644 upload/admin/skin_cp/images/icons/bookmark_white_20.png
create mode 100644 upload/admin/skin_cp/images/members/vkontakte.png
create mode 100644 upload/admin/sources/base/darkLAE.php
create mode 100644 upload/admin/sources/classes/admin/bookmarks.php
create mode 100644 upload/admin/sources/classes/backup.php
create mode 100644 upload/admin/sources/classes/backup/db.php
delete mode 100644 upload/admin/sources/classes/nodes/classNodes.php
create mode 100644 upload/admin/sources/classes/output/systemTemplates.php
delete mode 100644 upload/admin/sources/classes/session/convergeSessions.php
create mode 100644 upload/admin/sources/classes/share/plugins/bobrdobr.php
create mode 100644 upload/admin/sources/classes/share/plugins/memori.php
create mode 100644 upload/admin/sources/classes/share/plugins/vkontakte.php
create mode 100644 upload/admin/sources/classes/text/parser.php
create mode 100644 upload/admin/sources/classes/text/parser/bbcode.php
create mode 100644 upload/admin/sources/classes/text/parser/bbcode/ccs.php
create mode 100644 upload/admin/sources/classes/text/parser/bbcode/defaults.php
create mode 100644 upload/admin/sources/classes/text/parser/html.php
create mode 100644 upload/admin/sources/classes/text/parser/legacy.php
create mode 100644 upload/admin/sources/classes/vkontakte/connect.php
delete mode 100644 upload/admin/sources/handlers/han_editor.php
delete mode 100644 upload/admin/sources/loginauth/ipconverge/auth.php
delete mode 100644 upload/admin/sources/loginauth/ipconverge/loginauth_install.xml
create mode 100644 upload/admin/sources/loginauth/ipsconnect/acp.php
create mode 100644 upload/admin/sources/loginauth/ipsconnect/auth.php
rename upload/{converge_local/apis => admin/sources/loginauth/ipsconnect}/index.html (100%)
create mode 100644 upload/admin/sources/loginauth/ipsconnect/loginauth_install.xml
delete mode 100644 upload/cache/skin_cache/emailWrapper.php
delete mode 100644 upload/cache/skin_cache/ipsDriverError.php
delete mode 100644 upload/cache/skin_cache/ipsServerError.php
delete mode 100644 upload/converge_local/apis/allowed_methods.php
delete mode 100644 upload/converge_local/apis/server_functions.php
delete mode 100644 upload/converge_local/converge.php
delete mode 100644 upload/converge_local/converge_server.php
create mode 100644 upload/interface/ipsconnect/custom.rename.php
rename upload/{converge_local => interface/ipsconnect}/index.html (100%)
create mode 100644 upload/interface/ipsconnect/ipsconnect.php
create mode 100644 upload/interface/vkontakte/index.php
create mode 100644 upload/ips_kernel/PEAR/Net_IDNA2/Net/IDNA2.php
create mode 100644 upload/ips_kernel/PEAR/Net_IDNA2/Net/IDNA2/Exception.php
create mode 100644 upload/ips_kernel/PEAR/Net_IDNA2/Net/IDNA2/Exception/Nameprep.php
create mode 100644 upload/ips_kernel/PEAR/Net_IDNA2/docs/examples/example_web.php
create mode 100644 upload/ips_kernel/PEAR/Net_IDNA2/tests/AllTests.php
create mode 100644 upload/ips_kernel/PEAR/Net_IDNA2/tests/Net_IDNA2Test.php
create mode 100644 upload/ips_kernel/classCaptchaPlugin/keycaptcha.php
create mode 100644 upload/ips_kernel/vkontakte/OAuth2Client.php
create mode 100644 upload/ips_kernel/vkontakte/OAuth2ClientNOSSL.php
create mode 100644 upload/ips_kernel/vkontakte/oauth2.php
create mode 100644 upload/public/flowplayer/flowplayer-3.2.11.min.js
create mode 100644 upload/public/flowplayer/flowplayer-3.2.15.swf
delete mode 100644 upload/public/flowplayer/flowplayer-3.2.7.swf
create mode 100644 upload/public/flowplayer/flowplayer.controls-3.2.14.swf
delete mode 100644 upload/public/flowplayer/flowplayer.controls-3.2.5.swf
create mode 100644 upload/public/js/3rd_party/calendar_date_select/format_ipb.js
create mode 100644 upload/public/js/3rd_party/ckeditor/ckeditor_basic_source.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/_translationstatus.txt
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/cs.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/cy.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/da.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/de.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/el.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/eo.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/fa.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/fi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/fr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/gu.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/it.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/ku.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/lv.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/mk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/nb.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/nl.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/no.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/pt-br.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/ro.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/sk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/tr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/ug.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/vi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/a11yhelp/lang/zh-cn.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/_translationstatus.txt
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/bg.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/cs.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/cy.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/da.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/de.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/el.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/eo.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/et.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/fa.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/fi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/fr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/gu.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/he.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/hr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/it.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/ku.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/lv.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/nb.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/nl.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/no.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/pl.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/pt-br.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/sk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/tr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/ug.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/uk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/vi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/devtools/lang/zh-cn.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/ipsimage/dialogs/ipsimage.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/ipsimage/images/image.gif
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/ipssourcearea/images/switch.png
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/_translationstatus.txt
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/bg.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/cs.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/cy.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/da.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/de.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/el.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/eo.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/et.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/fa.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/fi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/fr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/hr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/it.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/ku.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/lv.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/nb.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/nl.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/no.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/pl.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/pt-br.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/sk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/tr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/ug.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/uk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/vi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/placeholder/lang/zh-cn.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/preview/preview.html
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/_translationstatus.txt
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/cs.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/cy.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/de.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/el.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/eo.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/et.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/fa.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/fi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/fr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/he.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/hr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/it.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/ku.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/lv.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/nb.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/nl.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/no.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/pt-br.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/sk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/tr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/ug.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/specialchar/lang/zh-cn.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/_translationstatus.txt
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/bg.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/cs.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/cy.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/da.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/de.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/el.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/eo.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/et.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/fa.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/fi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/fr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/hr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/it.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/ku.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/lv.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/mk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/nb.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/nl.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/no.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/pl.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/pt-br.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/sk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/tr.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/ug.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/uk.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/vi.js
create mode 100644 upload/public/js/3rd_party/ckeditor/plugins/uicolor/lang/zh-cn.js
create mode 100644 upload/public/js/ips.gallery_patchwork.js
create mode 100644 upload/public/js/ips.textEditor.bbcode.js
create mode 100644 upload/public/style_extra/cprofile_icons/profile_vk.gif
create mode 100644 upload/public/style_extra/cprofile_icons/profile_vk.png
create mode 100644 upload/public/style_extra/sharelinks/bobrdobr.png
create mode 100644 upload/public/style_extra/sharelinks/memori.png
create mode 100644 upload/public/style_extra/sharelinks/vkontakte.png
create mode 100644 upload/public/style_extra/sharelinks/yandex.png
create mode 100644 upload/public/style_images/master/cross_10px.png
create mode 100644 upload/public/style_images/master/cross_white_10px.png
create mode 100644 upload/public/style_images/master/icon_check_white_8px.png
create mode 100644 upload/public/style_images/master/icon_share.png
create mode 100644 upload/public/style_images/master/loginmethods/vkontakte.png
create mode 100644 upload/public/style_images/master/right_white_10px.png
create mode 100644 upload/public/style_images/master/rte_icons/copy.png
create mode 100644 upload/public/style_images/master/rte_icons/find.png
create mode 100644 upload/public/style_images/master/rte_icons/ips_bbcode.png
create mode 100644 upload/public/style_images/master/rte_icons/ips_options.png
create mode 100644 upload/public/style_images/master/rte_icons/paste.png
create mode 100644 upload/public/style_images/master/rte_icons/paste_plain.png
create mode 100644 upload/public/style_images/master/rte_icons/paste_word.png
create mode 100644 upload/public/style_images/master/rte_icons/replace.png
create mode 100644 upload/public/style_images/master/rte_icons/text_color.png
create mode 100644 upload/public/style_images/master/rte_icons/toggle.png
create mode 100644 upload/public/style_images/master/rte_icons/unlink.png
create mode 100644 upload/public/style_images/master/subforum_stem_rtl.png
create mode 100644 upload/public/style_images/master/tick_10px.png
create mode 100644 upload/public/style_images/master/vkontakte_login.png
create mode 100644 upload/public/style_images/mobile/right_white_10px.png
create mode 100644 upload/public/style_status/vkontakte.png
create mode 100644 upload/uploads/index.html
create mode 100644 upload/uploads/profile/index.html
diff --git a/upload/admin/Thumbs.db b/upload/admin/Thumbs.db
deleted file mode 100644
index 11610ee9b5817ade84256e3333104305b7eb89d3..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 2560
zcmca`Uhu)fjZzO8(10BSGsD0CoD6J8;*3Bx2!nwD0|OI~0pkDr|NlQkkbwcn90fxt
z1pWfu3W`4%9zsqZbt)A?Ac!F!2um0g7+e|hfOHWh3pnL;Vu@QqQgBe3SLmH4YU`S@LU@&GdVn}630^&rVSQ1#o43~)vS`18#$iaY9
zA(})kLC2zLz{4fSemusJEJca^pkM%%*?VV1f+pAK7#-Us6inA`F|piVk{1FcVbv~PUa<$!;&U>cv7h@-A}A64_jGX#vG7k$kjOZ|QS9((Q}+M&^*qZZFsrala%L~kKcM1pE?DHC36o0Oo02(k4W2A#t-k+1EYHC&QgHiHkHMa9
zA#QJf`~UrKY}9={Ev|ES@(Q_xaeqH_>-77;J=2r5PiANwJeZ)Ncz_{E*?XPse;MN`
zbC%8hJ%8^jsV?meM>RcoJ#^i48k*kznk~;``#WH7Qx1m*-x4;#Tu(W;o
q%zwX7O>Keregistry->getClass('output')->buildSEOUrl( "showforum={$row['forum_id']}", 'public', $row['name_seo'], 'showforum' );
$row['link-profile'] = $this->registry->getClass('output')->buildSEOUrl( "showuser={$row['member_id']}", 'public', $row['members_seo_name'], 'showuser' );
+ //-----------------------------------------
+ // Parse for display - http://community.invisionpower.com/resources/bugs.html/_/ip-board/xml-rpc-returning-bbcode-r41329
+ //-----------------------------------------
+
+ if ( $parse_display )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
+ $parser = new $classToLoad();
+
+ /* Set up some settings */
+ $parser->set( array( 'parseArea' => 'topics',
+ 'parseBBCode' => true,
+ 'parseHtml' => true,
+ 'parseEmoticons' => true ) );
+
+ $row['post'] = $parser->display( $row['post'] );
+ }
+
$topics[] = $row;
}
@@ -177,7 +195,7 @@ class apiTopicView extends apiCore
$this->DB->build( array( 'select' => '*',
'from' => 'attachments',
- 'where' => "attach_rel_module='post' AND attach_rel_id IN (" . implode( ",", $this->attach_pids ) . ")"
+ 'where' => "attach_rel_module='post' AND attach_rel_id IN (" . IPSText::cleanPermString( implode( ",", $this->attach_pids ) ) . ")"
) );
$this->DB->execute();
diff --git a/upload/admin/applications/core/extensions/admin/group_form.php b/upload/admin/applications/core/extensions/admin/group_form.php
index 357cc228..ec87ff8b 100644
--- a/upload/admin/applications/core/extensions/admin/group_form.php
+++ b/upload/admin/applications/core/extensions/admin/group_form.php
@@ -7,7 +7,7 @@
* $Author: bfarber $
* @since -
* $LastChangedDate: 2011-07-20 20:19:22 -0400 (Wed, 20 Jul 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 9296 $
*/
diff --git a/upload/admin/applications/core/extensions/admin/member_form.php b/upload/admin/applications/core/extensions/admin/member_form.php
index 00e0a175..dd6b9e4e 100644
--- a/upload/admin/applications/core/extensions/admin/member_form.php
+++ b/upload/admin/applications/core/extensions/admin/member_form.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Member property updater (AJAX)
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 1st march 2002
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/extensions/comments/reports.php b/upload/admin/applications/core/extensions/comments/reports.php
index 9c39ecb1..5b0e99e8 100644
--- a/upload/admin/applications/core/extensions/comments/reports.php
+++ b/upload/admin/applications/core/extensions/comments/reports.php
@@ -7,7 +7,7 @@
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Downloads
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11401 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -159,43 +159,53 @@ class comments_core_reports extends classes_comments_renderer
*/
public function postSave( $type, array $array, $commentId=0, $parentId=0 )
{
+
$_cnt = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'rc_comments', 'where' => 'rid=' . $parentId ) );
- $this->DB->update( 'rc_reports_index', array( 'num_comments' => intval($_cnt['total']), 'date_updated' => IPS_UNIX_TIME_NOW, 'updated_by' => $array['comment_author_id'] ), "id=" . $parentId );
+ $this->DB->update( 'rc_reports_index', array( 'num_comments' => intval($_cnt['total']), 'date_updated' => IPS_UNIX_TIME_NOW, 'updated_by' => $this->memberData['member_id'] ), "id=" . $parentId );
+
+ $report = $this->fetchParent( $parentId );
//-----------------------------------------
// Notify other moderators
- //-----------------------------------------
+ //-----------------------------------------
- $report = $this->fetchParent( $parentId );
-
- $this->registry->class_localization->loadLanguageFile( array( 'public_reports' ) );
-
- $this->DB->loadCacheFile( IPSLib::getAppDir('core') . '/sql/' . ips_DBRegistry::getDriverType() . '_report_queries.php', 'report_sql_queries' );
-
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('core') .'/sources/classes/reportLibrary.php', 'reportLibrary' );
- $this->registry->setClass( 'reportLibrary', new $classToLoad( $this->registry ) );
-
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('core') . '/sources/classes/reportNotifications.php', 'reportNotifications' );
- $notify = new $classToLoad( $this->registry );
-
- $this->registry->getClass('reportLibrary')->loadPlugin( $report['my_class'], $report['app'] );
-
- if( is_object($this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]) )
- {
- if( $report['extra_data'] && $report['extra_data'] != 'N;' )
- {
- $this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]->_extra = unserialize( $report['extra_data'] );
- }
- else
- {
- $this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]->_extra = array();
- }
+ if ( $type == 'add' )
+ {
+ $this->registry->class_localization->loadLanguageFile( array( 'public_reports' ) );
+
+ $this->DB->loadCacheFile( IPSLib::getAppDir('core') . '/sql/' . ips_DBRegistry::getDriverType() . '_report_queries.php', 'report_sql_queries' );
- $report_data = $this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]->formatReportData( $report );
-
- $notify->initNotify( $this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]->getNotificationList( IPSText::cleanPermString( $report['mod_group_perm'] ), $report_data ), $report_data );
- $notify->sendReplyNotifications( $array['comment_text'] );
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('core') .'/sources/classes/reportLibrary.php', 'reportLibrary' );
+ $this->registry->setClass( 'reportLibrary', new $classToLoad( $this->registry ) );
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('core') . '/sources/classes/reportNotifications.php', 'reportNotifications' );
+ $notify = new $classToLoad( $this->registry );
+
+ $this->registry->getClass('reportLibrary')->loadPlugin( $report['my_class'], $report['app'] );
+
+ if( is_object($this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]) )
+ {
+ if( $report['extra_data'] && $report['extra_data'] != 'N;' )
+ {
+ $this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]->_extra = unserialize( $report['extra_data'] );
+ }
+ else
+ {
+ $this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]->_extra = array();
+ }
+
+ $report_data = $this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]->formatReportData( $report );
+
+ $notify->initNotify( $this->registry->getClass('reportLibrary')->plugins[ $report['my_class'] ]->getNotificationList( IPSText::cleanPermString( $report['mod_group_perm'] ), $report_data ), $report_data );
+ $notify->sendReplyNotifications( $array['comment_text'] );
+ }
}
+
+ //-----------------------------------------
+ // Mark read
+ //-----------------------------------------
+
+ $this->registry->classItemMarking->markRead( array( 'forumID' => 0, 'itemID' => $report['id'] ), 'core' );
return $array;
}
diff --git a/upload/admin/applications/core/extensions/coreExtensions.php b/upload/admin/applications/core/extensions/coreExtensions.php
index 52d45964..f135e53c 100644
--- a/upload/admin/applications/core/extensions/coreExtensions.php
+++ b/upload/admin/applications/core/extensions/coreExtensions.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Core Sessions
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 20th February 2002
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*
*/
@@ -28,9 +28,9 @@ if ( ! defined( 'IN_IPB' ) )
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Item Marking
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -38,7 +38,7 @@ if ( ! defined( 'IN_IPB' ) )
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Downloads
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*
*/
diff --git a/upload/admin/applications/core/extensions/coreVariables.php b/upload/admin/applications/core/extensions/coreVariables.php
index ed882cbc..000ad488 100644
--- a/upload/admin/applications/core/extensions/coreVariables.php
+++ b/upload/admin/applications/core/extensions/coreVariables.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Core registered caches, redirect resets and bitwise settings
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 20th February 2002
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*
*/
diff --git a/upload/admin/applications/core/extensions/dashboardNotifications.php b/upload/admin/applications/core/extensions/dashboardNotifications.php
index 69f42f5e..9c4715e4 100644
--- a/upload/admin/applications/core/extensions/dashboardNotifications.php
+++ b/upload/admin/applications/core/extensions/dashboardNotifications.php
@@ -1,231 +1,335 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Dashboard Notifications
- * Last Updated: 11.07.2012
- *
- * @author $Author: ips_terabyte $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @version $Rev: 11026 $
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-/**
-* Main loader class
-* DO NOT MODIFY!
-*/
-class dashboardNotifications__core
-{
- /**
- * Registry Object Shortcuts
- *
- * @var object
- */
- public $settings;
- public $lang;
- public $cache;
- public $caches;
- public $DB;
-
- public function __construct()
- {
- $this->settings = ipsRegistry::fetchSettings();
- $this->lang = ipsRegistry::getClass('class_localization');
- $this->caches =& ipsRegistry::cache()->fetchCaches();
- $this->cache = ipsRegistry::cache();
- $this->DB = ipsRegistry::DB();
- }
-
- public function get()
- {
- /* INIT! */
- $entries = array();
-
- if( ! $this->settings['ipb_reg_number'] )
- {
- $entries[] = array( $this->lang->words['lc_title_nokey'], sprintf( $this->lang->words['lc_msg_nokey'], "{$this->settings['base_url']}module=tools§ion=licensekey" ) );
- }
-
- /* FURL cache OOD? */
- if ( is_file( IPS_CACHE_PATH . 'cache/furlCache.php' ) )
- {
- $mtime = intval( @filemtime( IPS_CACHE_PATH . 'cache/furlCache.php' ) );
-
- /* Check mtimes on extensions.. */
- foreach( ipsRegistry::$applications as $app_dir => $application )
- {
- if ( is_file( IPSLib::getAppDir( $app_dir ) . '/extensions/furlTemplates.php' ) )
- {
- $_mtime = intval( @filemtime( IPSLib::getAppDir( $app_dir ) . '/extensions/furlTemplates.php' ) );
-
- if ( $_mtime > $mtime )
- {
- $entries[] = array( $this->lang->words['furlcache_outofdate'], sprintf( $this->lang->words['furlcache_outofdate_desc'], $application['app_title'] ) . "{$this->lang->words['rebuild_furl_cache']} " );
- break;
- }
- }
- }
- }
-
- /* Sphinx cache OOD? */
- if ( $this->settings['search_method'] == 'sphinx' )
- {
- $mtime = intval( $this->cache->getCache('sphinx_config') );
-
- /* Check mtimes on extensions.. */
- foreach( ipsRegistry::$applications as $app_dir => $application )
- {
- if ( is_file( IPSLib::getAppDir( $app_dir ) . '/extensions/sphinxTemplate.php' ) )
- {
- $_mtime = intval( @filemtime( IPSLib::getAppDir( $app_dir ) . '/extensions/sphinxTemplate.php' ) );
-
- if ( !$mtime OR $_mtime > $mtime )
- {
- $entries[] = array( $this->lang->words['sphinxconfig_outofdate'], $this->lang->words['sphinxconfig_outofdate_desc'] . ' ' . "{$this->lang->words['rebuild_sphinx_config']} " );
- break;
- }
- }
- }
- }
-
- /* Minify on but /cache/tmp not writeable? */
- if ( !empty( $this->settings['_use_minify'] ) )
- {
- $entries[] = array( $this->lang->words['minifywrite_head'], $this->lang->words['minifynot_writeable'] );
- }
-
- /* Installer Check */
- if( @is_file( IPS_ROOT_PATH . 'install/index.php' ) )
- {
- if ( ! @is_file( DOC_IPS_ROOT_PATH . 'cache/installer_lock.php' ) )
- {
- $this->lang->words['cp_unlocked_warning'] = sprintf( $this->lang->words['cp_unlocked_warning'], CP_DIRECTORY );
- $entries[] = array( $this->lang->words['cp_unlockedinstaller'], $this->lang->words['cp_unlocked_warning'] );
- }
- }
-
- /* Unfinished Upgrade */
- require_once( IPS_ROOT_PATH . '/setup/sources/base/setup.php' );/*noLibHook*/
- $versions = IPSSetUp::fetchAppVersionNumbers( 'core' );
-
- if( $versions['current'][0] != $versions['latest'][0] )
- {
- $this->lang->words['cp_upgrade_warning'] = sprintf( $this->lang->words['cp_upgrade_warning'], $versions['current'][1], $versions['latest'][1], $this->settings['base_acp_url'] );
-
- $entries[] = array( $this->lang->words['cp_unfinishedupgrade'], $this->lang->words['cp_upgrade_warning'] );
- }
-
- /**
- * PHP Version Check
- *
- * @todo Remove this for 4.0? Installer/upgrader already do check for this anyway...
- */
- if( PHP_VERSION < '5.2.0' )
- {
- $entries[] = array( sprintf( $this->lang->words['cp_yourphpversion'], PHP_VERSION ), $this->lang->words['cp_php_warning'] );
- }
-
- /* Outgoing email address specified */
- if ( !$this->settings['email_out'] OR !$this->settings['email_in'] )
- {
- $entries[] = array( $this->lang->words['cp_missingemail'], "{$this->lang->words['cp_missingemail1']} {$this->lang->words['_raquo']} {$this->lang->words['cp_missingemail2']} " );
- }
-
- /* Board Offline Check */
- if ( $this->settings['board_offline'] )
- {
- $entries[] = array( $this->lang->words['cp_boardoffline'], "{$this->lang->words['cp_boardoffline1']} {$this->lang->words['_raquo']} {$this->lang->words['cp_boardoffline2']} " );
- }
-
- /* Fulltext Check */
- if( $this->settings['search_method'] == 'traditional' AND !$this->settings['use_fulltext'] AND !$this->settings['hide_ftext_note'] )
- {
- $entries[] = array( $this->lang->words['fulltext_off'], "{$this->lang->words['fulltext_turnon']} {$this->lang->words['_raquo']} {$this->lang->words['fulltext_find']} " );
- }
-
- /* Make sure the profile directory is writable */
- if( ! is_dir( $this->settings['upload_dir'] . '/profile/' ) || ! is_writable( $this->settings['upload_dir'] . '/profile/' ) )
- {
- $entries[] = array( $this->lang->words['cp_profilephotoerr_title'], sprintf( $this->lang->words['cp_profilephotoerr_msg'], $this->settings['upload_dir'] . '/profile/' ) );
- }
-
- /* Check for upgrade finish folder */
- if( is_dir( IPS_ROOT_PATH . 'upgradeFinish/' ) )
- {
- $entries[] = array( $this->lang->words['cp_upgradefinishfolder'], sprintf( $this->lang->words['cp_upgradefinishfolder_msg'], IPS_ROOT_PATH . 'upgradeFinish/' ) );
- }
-
- /* Check to see if GD is intalled */
- if(! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' ) )
- {
- $entries[] = array( $this->lang->words['cp_gdnotinstalled_title'], $this->lang->words['cp_gdnotinstalled_msg'] );
- }
-
- /* Performance mode check */
- $perfMode = $this->cache->getCache('performanceCache');
-
- if( is_array( $perfMode ) && count( $perfMode ) )
- {
- $entries[] = array( $this->lang->words['cp_perfmodeon_title'], $this->lang->words['cp_perfmodeon_msg'] );
- }
-
- /* Suhosin check */
- if( extension_loaded( 'suhosin' ) )
- {
- $_postMaxVars = @ini_get('suhosin.post.max_vars');
- $_reqMaxVars = @ini_get('suhosin.request.max_vars');
- $_postMaxLen = @ini_get('suhosin.post.max_value_length');
- $_reqMaxLen = @ini_get('suhosin.request.max_value_length');
-
- if( $_postMaxVars < 4096 )
- {
- $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue1'], $_postMaxVars ) );
- }
-
- if( $_reqMaxVars < 4096 )
- {
- $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue2'], $_reqMaxVars ) );
- }
-
- if( $_postMaxLen < 1000000 )
- {
- $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue3'], $_postMaxLen ) );
- }
-
- if( $_reqMaxLen < 1000000 )
- {
- $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue4'], $_reqMaxLen ) );
- }
- }
-
- /* SQL error check */
- /*if ( is_file( IPS_CACHE_PATH . 'cache/sql_error_latest.cgi' ) )
- {
- $unix = @filemtime( IPS_CACHE_PATH . 'cache/sql_error_latest.cgi' );
-
- if ( $unix )
- {
- $mtime = gmdate( 'd-j-Y', $unix );
- $now = gmdate( 'd-j-Y', time() );
-
- if ( $mtime == $now )
- {
- // Display a message
- }
- }
- }*/
-
- return $entries;
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Dashboard Notifications
+ * Last Updated: $Date
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @version $Rev: 12238 $
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+/**
+* Main loader class
+*/
+class dashboardNotifications__core
+{
+ /**
+ * Registry Object Shortcuts
+ *
+ * @var object
+ */
+ public $settings;
+ public $lang;
+ public $cache;
+ public $caches;
+ public $DB;
+
+ public function __construct()
+ {
+ $this->settings = ipsRegistry::fetchSettings();
+ $this->lang = ipsRegistry::getClass('class_localization');
+ $this->caches =& ipsRegistry::cache()->fetchCaches();
+ $this->cache = ipsRegistry::cache();
+ $this->DB = ipsRegistry::DB();
+ }
+
+ public function get()
+ {
+ /* INIT */
+ $entries = array();
+
+ if( ! $this->settings['ipb_reg_number'] )
+ {
+ $entries[] = array( $this->lang->words['lc_title_nokey'], sprintf( $this->lang->words['lc_msg_nokey'], "{$this->settings['base_url']}module=tools§ion=licensekey" ) );
+ }
+ else
+ {
+ /* Is the Spam Service Working? */
+ if ( $this->settings['spam_service_enabled'] )
+ {
+ $GOT_SPAM_ERROR = false;
+
+ /* Are we entitled to it? */
+ $licenseData = $this->cache->getCache( 'licenseData' );
+
+ if ( is_array( $licenseData['ipbMain'] ) && count( $licenseData['ipbMain'] ) )
+ {
+ foreach ( $licenseData['ipbMain'] as $data )
+ {
+ if ( $data['name'] == 'Spam Monitoring Service' && $data['status'] != 'Ok' )
+ {
+ $disableLink = $this->settings['base_url'] . "app=core&module=settings§ion=settings&do=findsetting&key=spamservice";
+
+ if ( is_numeric( $data['_expires'] ) && time() > $data['_expires'] )
+ {
+ $entries[] = array( $this->lang->words['spam_service_error'], sprintf( $this->lang->words['spam_service_expired'], $disableLink ) );
+ }
+ else
+ {
+ $entries[] = array( $this->lang->words['spam_service_error'], sprintf( $this->lang->words['spam_service_unavailable'], $disableLink ) );
+ }
+
+ $GOT_SPAM_ERROR = true;
+
+ break;
+ }
+ }
+ }
+
+ if ( ! $GOT_SPAM_ERROR )
+ {
+ /* Get last 5 logs, and if all 5 are errors, show message */
+ $_errors = 0;
+ $_entries = 0;
+ $_lastError = '';
+
+ $this->DB->build( array( 'select' => 'log_code, log_msg', 'from' => 'spam_service_log', 'order' => 'id DESC', 'limit' => 5 ) );
+ $this->DB->execute();
+
+ while( $_r = $this->DB->fetch() )
+ {
+ $_entries++;
+
+ if( $_r['log_code'] === '0' )
+ {
+ $_errors++;
+
+ if( !$_lastError )
+ {
+ $_lastError = $_r['log_msg'];
+ }
+ }
+ }
+
+ if( $_entries > 0 && $_errors == $_entries )
+ {
+ $entries[] = array( $this->lang->words['spam_service_error'], sprintf( $this->lang->words['spam_service_error_msg'], $_lastError ) );
+ }
+ }
+ }
+ /* If it's disabled, are we entitiled to it? */
+ else
+ {
+ $licenseData = $this->cache->getCache( 'licenseData' );
+
+ if ( is_array( $licenseData['ipbMain'] ) && count( $licenseData['ipbMain'] ) )
+ {
+ foreach ( $licenseData['ipbMain'] as $data )
+ {
+ if ( $data['name'] == 'Spam Monitoring Service' && $data['status'] == 'Ok' )
+ {
+ $entries[] = array( $this->lang->words['spam_service_disabled'], $this->lang->words['spam_service_disabled_msg'] );
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /* FURL cache OOD? */
+ if ( is_file( FURL_CACHE_PATH ) )
+ {
+ $mtime = intval( @filemtime( FURL_CACHE_PATH ) );
+
+ /* Check mtimes on extensions.. */
+ foreach( ipsRegistry::$applications as $app_dir => $application )
+ {
+ $furltemplatesfile = IPSLib::getAppDir( $app_dir );
+ if(IPB_USE_ONLY_ID_FURL && is_file( $furltemplatesfile.'/extensions/furlTemplatesID.php'))
+ {
+ $furltemplatesfile.='/extensions/furlTemplatesID.php';
+ }
+ else
+ {
+ $furltemplatesfile.='/extensions/furlTemplates.php';
+ }
+
+ if ( is_file( $furltemplatesfile ) )
+ {
+ $_mtime = intval( @filemtime( $furltemplatesfile ) );
+
+ if ( $_mtime > $mtime )
+ {
+ $entries[] = array( $this->lang->words['furlcache_outofdate'], sprintf( $this->lang->words['furlcache_outofdate_desc'], $application['app_title'] ) . "{$this->lang->words['rebuild_furl_cache']} " );
+ break;
+ }
+ }
+ }
+ }
+
+ /* Sphinx cache OOD? */
+ if ( $this->settings['search_method'] == 'sphinx' )
+ {
+ $mtime = intval( $this->cache->getCache('sphinx_config') );
+
+ /* Check mtimes on extensions.. */
+ foreach( ipsRegistry::$applications as $app_dir => $application )
+ {
+ if ( is_file( IPSLib::getAppDir( $app_dir ) . '/extensions/sphinxTemplate.php' ) )
+ {
+ $_mtime = intval( @filemtime( IPSLib::getAppDir( $app_dir ) . '/extensions/sphinxTemplate.php' ) );
+
+ if ( !$mtime OR $_mtime > $mtime )
+ {
+ $entries[] = array( $this->lang->words['sphinxconfig_outofdate'], $this->lang->words['sphinxconfig_outofdate_desc'] . ' ' . "{$this->lang->words['rebuild_sphinx_config']} " );
+ break;
+ }
+ }
+ }
+ }
+
+ /* Minify on but /cache/tmp not writeable? */
+ if ( !empty( $this->settings['_use_minify'] ) )
+ {
+ $entries[] = array( $this->lang->words['minifywrite_head'], $this->lang->words['minifynot_writeable'] );
+ }
+
+ /* Installer Check */
+ if( @is_file( IPS_ROOT_PATH . 'install/index.php' ) )
+ {
+ if ( ! @is_file( DOC_IPS_ROOT_PATH . 'cache/installer_lock.php' ) )
+ {
+ $this->lang->words['cp_unlocked_warning'] = sprintf( $this->lang->words['cp_unlocked_warning'], CP_DIRECTORY );
+ $entries[] = array( $this->lang->words['cp_unlockedinstaller'], $this->lang->words['cp_unlocked_warning'] );
+ }
+ }
+
+ /* Unfinished Upgrade */
+ require_once( IPS_ROOT_PATH . '/setup/sources/base/setup.php' );/*noLibHook*/
+ $versions = IPSSetUp::fetchAppVersionNumbers( 'core' );
+
+ if( $versions['current'][0] != $versions['latest'][0] )
+ {
+ $this->lang->words['cp_upgrade_warning'] = sprintf( $this->lang->words['cp_upgrade_warning'], $versions['current'][1], $versions['latest'][1], $this->settings['base_acp_url'] );
+
+ $entries[] = array( $this->lang->words['cp_unfinishedupgrade'], $this->lang->words['cp_upgrade_warning'] );
+ }
+
+ /**
+ * PHP Version Check
+ *
+ * @todo Remove this for 4.0? Installer/upgrader already do check for this anyway...
+ */
+ if( PHP_VERSION < '5.2.0' )
+ {
+ $entries[] = array( sprintf( $this->lang->words['cp_yourphpversion'], PHP_VERSION ), $this->lang->words['cp_php_warning'] );
+ }
+
+ /* Outgoing email address specified */
+ if ( !$this->settings['email_out'] OR !$this->settings['email_in'] )
+ {
+ $entries[] = array( $this->lang->words['cp_missingemail'], "{$this->lang->words['cp_missingemail1']} {$this->lang->words['_raquo']} {$this->lang->words['cp_missingemail2']} " );
+ }
+
+ /* Board Offline Check */
+ if ( $this->settings['board_offline'] )
+ {
+ $entries[] = array( $this->lang->words['cp_boardoffline'], "{$this->lang->words['cp_boardoffline1']} {$this->lang->words['_raquo']} {$this->lang->words['cp_boardoffline2']} " );
+ }
+
+ /* Fulltext Check */
+ if( $this->settings['search_method'] == 'traditional' AND !$this->settings['use_fulltext'] AND !$this->settings['hide_ftext_note'] )
+ {
+ $entries[] = array( $this->lang->words['fulltext_off'], "{$this->lang->words['fulltext_turnon']} {$this->lang->words['_raquo']} {$this->lang->words['fulltext_find']} " );
+ }
+
+ /* Make sure the profile directory is writable */
+ if( ! is_dir( $this->settings['upload_dir'] . '/profile/' ) || ! is_writable( $this->settings['upload_dir'] . '/profile/' ) )
+ {
+ $entries[] = array( $this->lang->words['cp_profilephotoerr_title'], sprintf( $this->lang->words['cp_profilephotoerr_msg'], $this->settings['upload_dir'] . '/profile/' ) );
+ }
+
+ /* Check for upgrade finish folder */
+ if( is_dir( IPS_ROOT_PATH . 'upgradeFinish/' ) )
+ {
+ $entries[] = array( $this->lang->words['cp_upgradefinishfolder'], sprintf( $this->lang->words['cp_upgradefinishfolder_msg'], IPS_ROOT_PATH . 'upgradeFinish/' ) );
+ }
+
+ /* Check to see if GD is intalled */
+ if(! extension_loaded( 'gd' ) || ! function_exists( 'gd_info' ) )
+ {
+ $entries[] = array( $this->lang->words['cp_gdnotinstalled_title'], $this->lang->words['cp_gdnotinstalled_msg'] );
+ }
+
+ /* Performance mode check */
+ $perfMode = $this->cache->getCache('performanceCache');
+
+ if( is_array( $perfMode ) && count( $perfMode ) )
+ {
+ $entries[] = array( $this->lang->words['cp_perfmodeon_title'], $this->lang->words['cp_perfmodeon_msg'] );
+ }
+
+ /* Suhosin check */
+ if( extension_loaded( 'suhosin' ) )
+ {
+ $_postMaxVars = @ini_get('suhosin.post.max_vars');
+ $_reqMaxVars = @ini_get('suhosin.request.max_vars');
+ $_getMaxLen = @ini_get('suhosin.get.max_value_length');
+ $_postMaxLen = @ini_get('suhosin.post.max_value_length');
+ $_reqMaxLen = @ini_get('suhosin.request.max_value_length');
+ $_reqMaxVar = @ini_get('suhosin.request.max_varname_length');
+
+ if( $_postMaxVars < 4096 )
+ {
+ $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue1'], $_postMaxVars ) );
+ }
+
+ if( $_reqMaxVars < 4096 )
+ {
+ $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue2'], $_reqMaxVars ) );
+ }
+
+ if( $_getMaxLen < 2000 )
+ {
+ $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue6'], $_getMaxLen ) );
+ }
+
+ if( $_postMaxLen < 1000000 )
+ {
+ $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue3'], $_postMaxLen ) );
+ }
+
+ if( $_reqMaxLen < 1000000 )
+ {
+ $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue4'], $_reqMaxLen ) );
+ }
+
+ if( $_reqMaxVar < 350 )
+ {
+ $entries[] = array( $this->lang->words['suhosin_notification'], sprintf( $this->lang->words['suhosin_badvalue5'], $_reqMaxVar ) );
+ }
+ }
+
+ /* SQL error check */
+ /*if ( is_file( IPS_CACHE_PATH . 'cache/sql_error_latest.cgi' ) )
+ {
+ $unix = @filemtime( IPS_CACHE_PATH . 'cache/sql_error_latest.cgi' );
+
+ if ( $unix )
+ {
+ $mtime = gmdate( 'd-j-Y', $unix );
+ $now = gmdate( 'd-j-Y', time() );
+
+ if ( $mtime == $now )
+ {
+ // Display a message
+ }
+ }
+ }*/
+
+ return $entries;
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/editorSections.php b/upload/admin/applications/core/extensions/editorSections.php
index 43f02d3a..1991e71d 100644
--- a/upload/admin/applications/core/extensions/editorSections.php
+++ b/upload/admin/applications/core/extensions/editorSections.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* BBCode Management : Determines if bbcode can be used in this section
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*
*/
diff --git a/upload/admin/applications/core/extensions/enhancements/facebook.php b/upload/admin/applications/core/extensions/enhancements/facebook.php
new file mode 100644
index 00000000..cb767213
--- /dev/null
+++ b/upload/admin/applications/core/extensions/enhancements/facebook.php
@@ -0,0 +1,38 @@
+title = $registry->getClass('class_localization')->words['enhancements_facebook'];
+ $this->description = $registry->getClass('class_localization')->words['enhancements_facebook_desc'];
+ $this->enabled = ipsRegistry::$settings['fbc_enable'];
+ $this->message = '' . ipsRegistry::getClass('class_localization')->words['enhancements_facebook_help'] . ' ';
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/enhancements/googleanalytics.php b/upload/admin/applications/core/extensions/enhancements/googleanalytics.php
new file mode 100644
index 00000000..98d453c4
--- /dev/null
+++ b/upload/admin/applications/core/extensions/enhancements/googleanalytics.php
@@ -0,0 +1,38 @@
+title = $registry->getClass('class_localization')->words['enhancements_googleanalytics'];
+ $this->description = $registry->getClass('class_localization')->words['enhancements_googleanalytics_desc'];
+ $this->message = "{$registry->getClass('class_localization')->words['enhancements_googleanalytics_help']} ";
+ $this->enabled = (bool) ipsRegistry::$settings['ipseo_ga'];
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/enhancements/ipsbackup.php b/upload/admin/applications/core/extensions/enhancements/ipsbackup.php
new file mode 100644
index 00000000..b1630a26
--- /dev/null
+++ b/upload/admin/applications/core/extensions/enhancements/ipsbackup.php
@@ -0,0 +1,42 @@
+title = 'IPS Backup Service';
+ $this->description = 'Automatically backup your community.';
+ $this->icon = '';
+ $this->enabled = FALSE;
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/enhancements/ipscdn.php b/upload/admin/applications/core/extensions/enhancements/ipscdn.php
new file mode 100644
index 00000000..b7adfa61
--- /dev/null
+++ b/upload/admin/applications/core/extensions/enhancements/ipscdn.php
@@ -0,0 +1,167 @@
+title = $registry->getClass('class_localization')->words['enhancements_ipscdn'];
+ $this->description = $registry->getClass('class_localization')->words['enhancements_ipscdn_desc'];
+ $this->icon = '';
+ $this->enabled = ipsRegistry::$settings['ips_cdn'];
+
+ $this->html = $registry->output->loadTemplate( 'cp_skin_applications' );
+ }
+
+ /**
+ * Edit Settings
+ */
+ public function editSettings()
+ {
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+
+ $skinFunctions = new skinCaching( ipsRegistry::instance() );
+
+ if ( ipsRegistry::$request['recache'] )
+ {
+ $skinFunctions->flushipscdn();
+
+ ipsRegistry::getClass('output')->redirect( ipsRegistry::$settings['_base_url'] . "app=core&module=applications§ion=enhancements&do=edit&service=enhancements_core_ipscdn", ipsRegistry::getClass('class_localization')->words['cdn_recached'] );
+ }
+
+ if ( ipsRegistry::$request['disable'] )
+ {
+ IPSLib::updateSettings( array( 'ips_cdn' => FALSE, 'ipb_img_url' => '', 'ipb_css_url' => '', 'ipb_js_url' => '', 'upload_url' => '' ) );
+
+ if ( IPSLib::appIsInstalled('gallery') )
+ {
+ $this_script = str_replace( '\\', '/', getenv( 'SCRIPT_FILENAME' ) );
+ $url = ipsRegistry::$settings['_original_base_url'];
+
+ if( $this_script )
+ {
+ $this_script = str_replace( '/'.CP_DIRECTORY.'/index.php', '', $this_script );
+ if ( substr( ipsRegistry::$settings['gallery_images_path'], 0, strlen( $this_script ) ) === $this_script )
+ {
+ $url = str_replace( '\\', '/', str_replace( $this_script, $url, ipsRegistry::$settings['gallery_images_path'] ) );
+ }
+ }
+ else
+ {
+ $url .= '/uploads';
+ }
+
+ IPSLib::updateSettings( array( 'gallery_images_path' => $url ) );
+ }
+
+ IPSContentCache::truncate( 'post' );
+ IPSContentCache::truncate( 'sig' );
+
+ /* Set skin sets to recache */
+ $skinFunctions->flagSetForRecache();
+
+ ipsRegistry::getClass('output')->redirect( ipsRegistry::$settings['_base_url'] . "app=core&module=applications§ion=enhancements", ipsRegistry::getClass('class_localization')->words['cdn_disabled'] );
+ return;
+ }
+
+ if ( !ipsRegistry::$settings['ipb_reg_number'] )
+ {
+ ipsRegistry::getClass('output')->showError( sprintf( ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_nokey'], ipsRegistry::getClass('output')->buildUrl('app=core&module=tools§ion=licensekey', 'admin') ) );
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
+ $file = new $classToLoad();
+ $return = NULL;
+
+ if ( $json = @json_decode( $ping, TRUE ) )
+ {
+ if ( $json['ENABLED'] and $json['BYTES'] > 0 )
+ {
+ if ( !ipsRegistry::$settings['ips_cdn'] and !ipsRegistry::$request['enable'] )
+ {
+ return $this->html->cdnInactive( $json );
+ }
+ else
+ {
+ $settings = array( 'ips_cdn' => TRUE, 'ipb_img_url' => $json['URL'], 'ipb_css_url' => rtrim( $json['URL'], '/' ) . '/', 'ipb_js_url' => rtrim( $json['URL'], '/' ) . '/', 'upload_url' => $json['URL'] . '/uploads' );
+ if ( IPSLib::appIsInstalled('downloads') )
+ {
+ if ( substr( ipsRegistry::$settings['idm_localsspath'], 0, 11 ) === '{root_path}' )
+ {
+ $settings['idm_screenshot_url'] = str_replace( '{root_path}', $json['URL'], ipsRegistry::$settings['idm_localsspath'] );
+ }
+ }
+ if ( IPSLib::appIsInstalled('gallery') )
+ {
+ $this_script = str_replace( '\\', '/', getenv( 'SCRIPT_FILENAME' ) );
+ if( $this_script )
+ {
+ $this_script = str_replace( '/'.CP_DIRECTORY.'/index.php', '', $this_script );
+ if ( substr( ipsRegistry::$settings['gallery_images_path'], 0, strlen( $this_script ) ) === $this_script )
+ {
+ $settings['gallery_images_url'] = str_replace( '\\', '/', str_replace( $this_script, $json['URL'], ipsRegistry::$settings['gallery_images_path'] ) );
+ }
+ }
+ }
+
+ $_settings = array();
+ foreach ( $settings as $k => $v )
+ {
+ if ( ipsRegistry::$settings[ $k ] != $v )
+ {
+ $_settings[ $k ] = $v;
+ }
+ }
+
+ if ( !empty( $_settings ) )
+ {
+ IPSLib::updateSettings( $settings );
+ }
+
+ /* Set skin sets to recache */
+ $skinFunctions->flagSetForRecache();
+ }
+ }
+ else
+ {
+ $licenseData = ipsRegistry::cache()->getCache('licenseData');
+ if ( $licenseData['key']['url'] != ipsRegistry::$settings['board_url'] )
+ {
+ ipsRegistry::getClass('output')->showError( ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_url'] );
+ }
+
+ /* Set skin sets to recache */
+ $skinFunctions->flagSetForRecache();
+
+ return $this->html->cdnNotEnabled( $json );
+ }
+ }
+ else
+ {
+ ipsRegistry::getClass('output')->showError( sprintf( ipsRegistry::getClass('class_localization')->words['enhancements_ipscdn_error_key'], ipsRegistry::getClass('output')->buildUrl('app=core&module=tools§ion=licensekey', 'admin') ) );
+ }
+
+ return $this->html->cdnOverview( $json );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/enhancements/twitter.php b/upload/admin/applications/core/extensions/enhancements/twitter.php
new file mode 100644
index 00000000..4087ca69
--- /dev/null
+++ b/upload/admin/applications/core/extensions/enhancements/twitter.php
@@ -0,0 +1,38 @@
+title = $registry->getClass('class_localization')->words['enhancements_twitter'];
+ $this->description = $registry->getClass('class_localization')->words['enhancements_twitter_desc'];
+ $this->enabled = ipsRegistry::$settings['tc_enabled'];
+ $this->message = '' . ipsRegistry::getClass('class_localization')->words['enhancements_twitter_help'] . ' ';
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/enhancements/viglink.php b/upload/admin/applications/core/extensions/enhancements/viglink.php
new file mode 100644
index 00000000..6a1c5a48
--- /dev/null
+++ b/upload/admin/applications/core/extensions/enhancements/viglink.php
@@ -0,0 +1,114 @@
+title = $registry->getClass('class_localization')->words['enhancements_viglink'];
+ $this->description = $registry->getClass('class_localization')->words['enhancements_viglink_desc'];
+ $this->enabled = ipsRegistry::$settings['viglink_enabled'];
+
+ if ( $this->enabled )
+ {
+ $this->message = sprintf( $registry->getClass('class_localization')->words['viglink_forums_notice'], $registry->output->buildUrl('app=forums', 'admin') );
+ $this->settings = array( 'viglink_enabled' );
+ if ( !ipsRegistry::$settings['viglink_subid'] )
+ {
+ $this->settings[] = 'viglink_api_key';
+ }
+ $this->settings[] = 'viglink_groups';
+ $this->settings[] = 'viglink_norewrite';
+ }
+ }
+
+ /**
+ * Edit Settings
+ */
+ public function editSettings()
+ {
+ $json = $this->_makeApiCall();
+ return ipsRegistry::getClass('output')->loadTemplate('cp_skin_applications')->viglinkConvert( $json['URL'] );
+ }
+
+ /**
+ * Save Settings
+ */
+ public function saveSettings()
+ {
+ if ( isset( ipsRegistry::$request['viglink_manual'] ) )
+ {
+ IPSLib::updateSettings( array( 'viglink_enabled' => '1', 'viglink_api_key' => ipsRegistry::$request['viglink_api_key'], 'viglink_subid' => '' ) );
+ }
+ else
+ {
+ $json = $this->_makeApiCall();
+ IPSLib::updateSettings( array( 'viglink_enabled' => '1', 'viglink_api_key' => $json['API_KEY'], 'viglink_subid' => $json['SUBID'] ) );
+ }
+
+ ipsRegistry::getClass('output')->silentRedirect( ipsRegistry::$settings['_base_url'] . "app=core&module=applications§ion=enhancements&do=edit&service=enhancements_core_viglink" );
+ return;
+ }
+
+ /**
+ * Make call to IPS to get API keys
+ *
+ * @return array
+ */
+ private function _makeApiCall()
+ {
+ $subId = NULL;
+ if ( ipsRegistry::$settings['ipb_reg_number'] )
+ {
+ $exploded = explode( '-', ipsRegistry::$settings['ipb_reg_number'] );
+ if ( isset( $exploded[3] ) )
+ {
+ $subId = $exploded[3];
+ }
+ }
+ if ( $subId === NULL )
+ {
+ $subId = ipsRegistry::$settings['board_url'];
+ if ( strlen( $subId ) > 32 )
+ {
+ $subId = str_replace( array( 'http://', 'https://' ), '', $subId );
+ }
+ if ( strlen( $subId ) > 32 )
+ {
+ $subId = md5( $subId );
+ }
+ }
+
+ require_once IPS_KERNEL_PATH . 'classFileManagement.php';
+ $cfm = new classFileManagement();
+ $return = NULL;
+ if ( $return and $json = @json_decode( $return, TRUE ) and $json['SUCCESS'] == TRUE )
+ {
+ return $json;
+ }
+ else
+ {
+ ipsRegistry::getClass('output')->showError( ipsRegistry::getClass('class_localization')->words['enhancements_viglink_error'] );
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/enhancements/windowslive.php b/upload/admin/applications/core/extensions/enhancements/windowslive.php
new file mode 100644
index 00000000..c8410aff
--- /dev/null
+++ b/upload/admin/applications/core/extensions/enhancements/windowslive.php
@@ -0,0 +1,140 @@
+title = $registry->getClass('class_localization')->words['enhancements_windowslive'];
+ $this->description = $registry->getClass('class_localization')->words['enhancements_windowslive_desc'];
+
+ $this->enabled = FALSE;
+ $loginMethods = ipsRegistry::cache()->getCache('login_methods');
+ foreach ( $loginMethods as $method )
+ {
+ if ( $method['login_folder_name'] == 'live' and $method['login_enabled'] )
+ {
+ $this->enabled = TRUE;
+ }
+ }
+
+ $this->html = $registry->output->loadTemplate( 'cp_skin_applications' );
+ }
+
+ /**
+ * Edit Settings
+ */
+ public function editSettings()
+ {
+ ipsRegistry::getClass('class_permissions')->checkPermissionAutoMsg( 'login_manage' );
+
+ $method = ipsRegistry::DB()->buildAndFetch( array( 'select' => '*', 'from' => 'login_methods', 'where' => "login_folder_name='live'" ) );
+ if ( !$method['login_id'] )
+ {
+ ipsRegistry::getClass('output')->showError( sprintf( ipsRegistry::getClass('class_localization')->words['enhancements_windowslive_error'], ipsRegistry::$settings['_base_url'] . 'app=core&module=tools§ion=login' ) );
+ }
+
+ if ( ipsRegistry::$request['downloadxml'] )
+ {
+ $clientId = ipsRegistry::$request['client_id'];
+ $clientSecret = ipsRegistry::$request['client_secret'];
+
+ header( "Content-Disposition: attachment; filename=\"Application-Key.xml\"" );
+ header( "Content-type: application/xml" );
+
+ echo <<
+ {$clientId}
+ {$clientSecret}
+ wsignin1.0
+
+XML;
+ exit;
+ }
+
+ $config = unserialize( $method['login_custom_config'] );
+ $settings = array( 'enabled' => $this->enabled );
+ if ( $config['key_file_location'] )
+ {
+ $settings['xml'] = $config['key_file_location'];
+
+ $xml = file_get_contents( $settings['xml'] );
+
+ preg_match( "/(.+?)<\/appid>/" , $xml, $matches );
+ $settings['client_id'] = $matches[1];
+
+ preg_match( "/(.+?)<\/secret>/" , $xml, $matches );
+ $settings['client_secret'] = $matches[1];
+
+ }
+ else
+ {
+ $exploded = explode( '/', rtrim( DOC_IPS_ROOT_PATH, '/' ) );
+ do
+ {
+ $popped = array_pop( $exploded );
+ }
+ while ( strstr( ipsRegistry::$settings['base_url'], $popped ) !== FALSE );
+ $exploded[] = $popped;
+
+ $settings['xml'] = implode( '/', $exploded ) . '/Application-Key.xml';
+ }
+
+ return $this->html->windowsLiveSetup( $settings );
+ }
+
+ /**
+ * Save Settings
+ */
+ public function saveSettings()
+ {
+ ipsRegistry::getClass('class_permissions')->checkPermissionAutoMsg( 'login_manage' );
+
+ $login = ipsRegistry::DB()->buildAndFetch( array( 'select' => '*', 'from' => 'login_methods', 'where' => "login_folder_name='live'" ) );
+ if ( !$login['login_id'] )
+ {
+ ipsRegistry::getClass('output')->showError( sprintf( ipsRegistry::getClass('class_localization')->words['enhancements_windowslive_error'], ipsRegistry::$settings['_base_url'] . 'app=core&module=tools§ion=login' ) );
+ }
+
+ if ( ipsRegistry::$request['disable'] )
+ {
+ ipsRegistry::DB()->update( 'login_methods', array( 'login_enabled' => 0 ), 'login_id=' . $login['login_id'] );
+ ipsRegistry::cache()->rebuildCache( 'login_methods' );
+ return;
+ }
+
+ if ( !is_file( ipsRegistry::$request['xml'] ) )
+ {
+ ipsRegistry::getClass('output')->showError( ipsRegistry::getClass('class_localization')->words['enhancements_windowslive_error2'] );
+ }
+
+ $config = unserialize( $login['login_custom_config'] );
+ $config['key_file_location'] = ipsRegistry::$request['xml'];
+ $toSave = array( 'login_custom_config' => serialize( $config ) );
+ $toSave['login_enabled'] = '1';
+
+ ipsRegistry::DB()->update( 'login_methods', $toSave, 'login_id=' . $login['login_id'] );
+
+ ipsRegistry::cache()->rebuildCache( 'login_methods' );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/furlTemplates.php b/upload/admin/applications/core/extensions/furlTemplates.php
index 78ae26f9..71575fdb 100644
--- a/upload/admin/applications/core/extensions/furlTemplates.php
+++ b/upload/admin/applications/core/extensions/furlTemplates.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Sets up SEO templates
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-03-12 09:54:04 -0400 (Tue, 12 Mar 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 20th February 2002
- * @version $Rev: 10914 $
+ * @version $Rev: 12072 $
*
*/
@@ -52,7 +52,20 @@ $_SEOTEMPLATES = array(
'in' => array( 'regex' => "#/register(/|$|\?)#i",
'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'register' ) ) ) ),
+'section=lostpass' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=lostpass(&|&|$)#i', 'lostpass/$3' ),
+ 'in' => array( 'regex' => "#/lostpass(/|$|\?)#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'lostpass' ) ) ) ),
+
+'section=login' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=login(&|&|$)#i', 'login/$3' ),
+ 'in' => array( 'regex' => "#/login(/|$|\?)#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'login' ) ) ) ),
+
'tags' => array( 'app' => 'core',
+ 'isPagesMode' => true,
'allowRedirect' => 0,
'out' => array( '#app=core(&|&)module=search(&|&)do=search(&|&)search_tags=(\S+?)(&|&)search_app=(\S+?)(&|&|$)#i', 'tags/$6/$4/$7' ),
'in' => array( 'regex' => "#/tags/(\S+?)/(\S+?)/#i",
@@ -83,7 +96,7 @@ $_SEOTEMPLATES = array(
'section=rss2' => array( 'app' => 'core',
'allowRedirect' => 0,
'out' => array( '#app=core(&|&)module=global(&|&)section=rss(&|&)type=(\w+?)(&|&)id=(\w+?)$#i', 'rss/$4/$6-#{__title__}/' ),
- 'in' => array( 'regex' => "#/rss/(\w+?)/(\w+?)-#i",
+ 'in' => array( 'regex' => "#/rss/(\w+?)/(\w+?)(?:-|/|$)#i",
'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'rss' ), array( 'type', '$1' ), array( 'id', '$2' ) ) ) ),
# Changed section=rss2 id matching to use \w for more flexibility
diff --git a/upload/admin/applications/core/extensions/furlTemplatesID.php b/upload/admin/applications/core/extensions/furlTemplatesID.php
new file mode 100644
index 00000000..d07a3289
--- /dev/null
+++ b/upload/admin/applications/core/extensions/furlTemplatesID.php
@@ -0,0 +1,106 @@
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Sets up SEO templates
+ * Last Updated: $Date: 2013-03-12 09:54:04 -0400 (Tue, 12 Mar 2013) $
+ *
+ *
+ * @author $Author: mmecham $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 20th February 2002
+ * @version $Rev: 12072 $
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+/**
+ * SEO templates
+ *
+ * 'allowRedirect' is a flag to tell IP.Board whether to check the incoming link and if not formatted correctly, redirect the correct one
+ *
+ * OUT FORMAT REGEX:
+ * First array element is a regex to run to see if we've a match for the URL
+ * The second array element is the template to use the results of the parenthesis capture
+ *
+ * Special variable #{__title__} is replaced with the $title data passed to output->formatUrl( $url, $title)
+ *
+ * IMPORTANT: Remember that when these regex are used, the output has not been fully parsed so you will get:
+ * showuser={$data['member_id']} NOT showuser=1 so do not try and match numerics only!
+ *
+ * IN FORMAT REGEX
+ *
+ * This allows the registry to piece back together a URL based on the template regex
+ * So, for example: "/user/(\d+?)/", 'matches' => array( array( 'showuser' => '$1' ) )tells IP.Board to populate 'showuser' with the result
+ * of the parenthesis capture #1
+ */
+$_SEOTEMPLATES = array(
+
+'section=register' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=register(&|&|$)#i', 'register/$3' ),
+ 'in' => array( 'regex' => "#/register(/|$|\?)#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'register' ) ) ) ),
+
+'section=lostpass' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=lostpass(&|&|$)#i', 'lostpass/$3' ),
+ 'in' => array( 'regex' => "#/lostpass(/|$|\?)#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'lostpass' ) ) ) ),
+
+'section=login' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=login(&|&|$)#i', 'login/$3' ),
+ 'in' => array( 'regex' => "#/login(/|$|\?)#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'login' ) ) ) ),
+
+'tags' => array( 'app' => 'core',
+ 'isPagesMode' => true,
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=search(&|&)do=search(&|&)search_tags=(\S+?)(&|&)search_app=(\S+?)(&|&|$)#i', 'tags/$6/$4/$7' ),
+ 'in' => array( 'regex' => "#/tags/(\S+?)/(\S+?)/#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'search' ), array( 'do', 'search' ), array( 'search_tags', '$2' ), array( 'search_app', '$1' ) ) ) ),
+
+'privacy' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=privacy(&|&|$)#i', 'privacypolicy/$4/' ),
+ 'in' => array( 'regex' => "#/privacypolicy/#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'privacy' ) ) ) ),
+
+'likeunsubscribe' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=like(&|&)do=unsubscribe(&|&)key=(\S+?)(&|&|$)#i', 'unsubscribe/$5/' ),
+ 'in' => array( 'regex' => "#/unsubscribe/(\S+?)/$#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'like' ), array( 'do', 'unsubscribe' ), array( 'key', '$1' ) ) ) ),
+'findcomment' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=comments(&|&)do=findComment(&|&)fromApp=(\S+?)(&|&)parentId=(\d+?)(&|&)commentId=(\d+?)(&|&|$)#i', 'findComment/$5/$7-$9' ),
+ 'in' => array( 'regex' => "#/findComment/(\S+?-\S+?)/(\d+?)-(\d+?)$#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'comments' ), array( 'do', 'findComment' ), array( 'fromApp', '$1' ), array( 'parentId', '$2' ), array( 'commentId', '$3' ) ) ) ),
+'section=rss' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=rss(&|&)type=(\w+?)$#i', 'rss/$4/' ),
+ 'in' => array( 'regex' => "#/rss/(\w+?)/$#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'rss' ), array( 'type', '$1' ) ) ) ),
+
+'section=rss2' => array( 'app' => 'core',
+ 'allowRedirect' => 0,
+ 'out' => array( '#app=core(&|&)module=global(&|&)section=rss(&|&)type=(\w+?)(&|&)id=(\w+?)$#i', 'rss/$4/$6/' ),
+ 'in' => array( 'regex' => "#/rss/(\w+?)/(\w+?)(?:-|/|$)#i",
+ 'matches' => array( array( 'app', 'core' ), array( 'module', 'global' ), array( 'section', 'rss' ), array( 'type', '$1' ), array( 'id', '$2' ) ) ) ),
+
+
+# Changed section=rss2 id matching to use \w for more flexibility
+
+);
+
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/like/default.php b/upload/admin/applications/core/extensions/like/default.php
index 1e29e725..9588a7e3 100644
--- a/upload/admin/applications/core/extensions/like/default.php
+++ b/upload/admin/applications/core/extensions/like/default.php
@@ -6,7 +6,7 @@
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: mark $
* $LastChangedDate: 2011-12-08 16:43:34 +0000 (Thu, 08 Dec 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 9971 $
*/
diff --git a/upload/admin/applications/core/extensions/navigation/generate.php b/upload/admin/applications/core/extensions/navigation/generate.php
index f735d09a..ba7e9d0c 100644
--- a/upload/admin/applications/core/extensions/navigation/generate.php
+++ b/upload/admin/applications/core/extensions/navigation/generate.php
@@ -4,11 +4,11 @@
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: bfarber $
+ * $Author: AndyMillne $
* @since 3/8/2011
- * $LastChangedDate: 2011-05-12 22:28:10 -0400 (Thu, 12 May 2011) $
- * @version v3.3.4
- * $Revision: 8754 $
+ * $LastChangedDate: 2013-03-12 15:04:05 -0400 (Tue, 12 Mar 2013) $
+ * @version v3.4.5
+ * $Revision: 12074 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -86,7 +86,12 @@ class navigation_core
$links = array();
$links[] = array( 'title' => $this->lang->words['view_new_posts'] , 'url' => $this->registry->output->buildUrl( 'app=core&module=search&do=viewNewContent&search_app=forums', 'public') );
- $links[] = array( 'title' => $this->lang->words['online_user_link'] , 'url' => $this->registry->output->buildUrl( 'app=members&module=online&sort_order=desc', 'public') );
+
+ if ( $this->settings['allow_online_list'] )
+ {
+ $links[] = array( 'title' => $this->lang->words['online_user_link'] , 'url' => $this->registry->output->buildUrl( 'app=members&module=online&sort_order=desc', 'public') );
+ }
+
$links[] = array( 'title' => $this->lang->words['registered_users_link'], 'url' => $this->registry->output->buildSEOUrl( 'app=members&module=list', 'public', 'false', 'members_list' ) );
$links[] = array( 'title' => $this->lang->words['status_updates_link'] , 'url' => $this->registry->output->buildSEOUrl( 'app=members&module=profile§ion=status', 'public', 'false', 'members_status_all' ) );
diff --git a/upload/admin/applications/core/extensions/notifications.php b/upload/admin/applications/core/extensions/notifications.php
index baf421c2..43d8cd68 100644
--- a/upload/admin/applications/core/extensions/notifications.php
+++ b/upload/admin/applications/core/extensions/notifications.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Define the core notification types
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-05-21 20:51:17 -0400 (Tue, 21 May 2013) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 20th February 2002
- * @version $Rev: 10914 $
+ * @version $Rev: 12263 $
*
*/
@@ -43,8 +43,8 @@ class core_notifications
return $_NOTIFY;
}
- public function report_center()
+ public function report_center( $member )
{
- return $this->memberData['access_report_center'];
+ return $member['access_report_center'];
}
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/reportPlugins/default.php b/upload/admin/applications/core/extensions/reportPlugins/default.php
index e57e54b5..f1b304bb 100644
--- a/upload/admin/applications/core/extensions/reportPlugins/default.php
+++ b/upload/admin/applications/core/extensions/reportPlugins/default.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Report Center :: Default plugin
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-12-10 11:06:25 -0500 (Mon, 10 Dec 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @author Based on original "Report Center" by Luke Scott
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11691 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -386,18 +386,18 @@ EOF;
$the_report = $this->DB->fetch();
$rid = $the_report['id'];
- $this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'] ), "id='{$rid}'" );
+ $this->DB->update( 'rc_reports_index', array( 'date_updated' => time(), 'status' => $status['new'], 'updated_by' => $this->memberData['member_id'] ), "id='{$rid}'" );
}
- IPSText::getTextClass('bbcode')->parse_bbcode = 1;
- IPSText::getTextClass('bbcode')->parse_html = 0;
- IPSText::getTextClass('bbcode')->parse_emoticons = 1;
- IPSText::getTextClass('bbcode')->parse_nl2br = 1;
- IPSText::getTextClass('bbcode')->parsing_section = 'reports';
+ /* Load editor stuff */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $editor = new $classToLoad();
+
+ $editor->setLegacyMode(false);
$build_report = array(
'rid' => $rid,
- 'report' => IPSText::getTextClass('bbcode')->preDbParse( $this->request['message'] ),
+ 'report' => $editor->process( $this->request['message'] ),
'report_by' => $this->memberData['member_id'],
'date_reported' => time(),
);
diff --git a/upload/admin/applications/core/extensions/rssOutput.php b/upload/admin/applications/core/extensions/rssOutput.php
index e5618957..f8af3f13 100644
--- a/upload/admin/applications/core/extensions/rssOutput.php
+++ b/upload/admin/applications/core/extensions/rssOutput.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* RSS output plugin :: report center
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 6/24/2008
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/extensions/search/config.php b/upload/admin/applications/core/extensions/search/config.php
index 1f44493b..a6d467c1 100644
--- a/upload/admin/applications/core/extensions/search/config.php
+++ b/upload/admin/applications/core/extensions/search/config.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Config file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $author$
@@ -14,7 +14,7 @@
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/extensions/search/engines/sql.php b/upload/admin/applications/core/extensions/search/engines/sql.php
index e69cd160..869738ea 100644
--- a/upload/admin/applications/core/extensions/search/engines/sql.php
+++ b/upload/admin/applications/core/extensions/search/engines/sql.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Basic Forum Search
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/extensions/search/form.php b/upload/admin/applications/core/extensions/search/form.php
index eca03973..b1b183ab 100644
--- a/upload/admin/applications/core/extensions/search/form.php
+++ b/upload/admin/applications/core/extensions/search/form.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Returns HTML for the form (optional class, not required)
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $author$
@@ -14,7 +14,7 @@
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/extensions/search/format.php b/upload/admin/applications/core/extensions/search/format.php
index e7f17670..7d938507 100644
--- a/upload/admin/applications/core/extensions/search/format.php
+++ b/upload/admin/applications/core/extensions/search/format.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Formats forum search results
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $author$
@@ -14,7 +14,7 @@
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/extensions/sharedmedia/plugin_attachments.php b/upload/admin/applications/core/extensions/sharedmedia/plugin_attachments.php
index 1e402d0f..ea67a277 100644
--- a/upload/admin/applications/core/extensions/sharedmedia/plugin_attachments.php
+++ b/upload/admin/applications/core/extensions/sharedmedia/plugin_attachments.php
@@ -3,11 +3,11 @@
* @file plugin_attachments.php Shared media plugin: attachments
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: rtissier $
+ * $Author: mmecham $
* @since 3/8/2011
- * $LastChangedDate: 2011-03-16 19:10:59 -0400 (Wed, 16 Mar 2011) $
- * @version v3.3.4
- * $Revision: 8108 $
+ * $LastChangedDate: 2013-04-03 08:07:11 -0400 (Wed, 03 Apr 2013) $
+ * @version v3.4.5
+ * $Revision: 12145 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -118,8 +118,9 @@ class plugin_core_attachments
{
$where = " AND attach_file LIKE '%{$string}%'";
}
-
- $count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'attachments', 'where' => "attach_member_id={$this->memberData['member_id']}" . $where ) );
+
+ /* Exclude PMs */
+ $count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'attachments', 'where' => "attach_rel_module != 'msg' AND attach_member_id={$this->memberData['member_id']}" . $where ) );
$rows = array();
$pages = $this->registry->output->generatePagination( array( 'totalItems' => $count['total'],
@@ -131,7 +132,7 @@ class plugin_core_attachments
'ajaxLoad' => 'mymedia_content',
'baseUrl' => "app=core&module=ajax§ion=media&do=loadtab&tabapp=core&tabplugin=attachments&search=" . urlencode($string) ) );
- $this->DB->build( array( 'select' => '*', 'from' => 'attachments', 'where' => "attach_member_id={$this->memberData['member_id']}" . $where, 'order' => 'attach_date DESC', 'limit' => array( $st, $each ) ) );
+ $this->DB->build( array( 'select' => '*', 'from' => 'attachments', 'where' => "attach_rel_module != 'msg' AND attach_member_id={$this->memberData['member_id']}" . $where, 'order' => 'attach_date DESC', 'limit' => array( $st, $each ) ) );
$outer = $this->DB->execute();
while( $r = $this->DB->fetch($outer) )
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/blog_entries.php b/upload/admin/applications/core/extensions/sitemapPlugins/blog_entries.php
new file mode 100644
index 00000000..c7a10876
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/blog_entries.php
@@ -0,0 +1,92 @@
+settings['sitemap_priority_blog_entries'] == 0)
+ {
+ return;
+ }
+
+ // Check whether groups can access blog at all:
+ $guestGroup = $this->DB->buildAndFetch(array( 'select' => 'g_blog_settings',
+ 'from' => 'groups',
+ 'where' => 'g_id = ' . $this->settings['guest_group']));
+
+ // Default is to not allow access unless explicitly given:
+ if(is_null($guestGroup['g_blog_settings']))
+ {
+ return;
+ }
+
+ $settings = unserialize($guestGroup['g_blog_settings']);
+
+ // Not allowed to access unless g_blog_allowview = 1
+ if(!is_array($settings) || intval($settings['g_blog_allowview']) != 1)
+ {
+ return;
+ }
+
+ $max = $this->settings['sitemap_count_blog_entries'];
+
+ if(!ipSeo_SitemapGenerator::isCronJob() && ($max > 10000 || $max == -1))
+ {
+ $max = 10000;
+ }
+ elseif(ipSeo_SitemapGenerator::isCronJob() && $max == -1)
+ {
+ $max = 50000000;
+ }
+
+ // Get blogs:
+ $addedCount = 0;
+ $limitCount = 0;
+
+ while($addedCount < $max)
+ {
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ sleep(0.25);
+ }
+
+ $query = $this->DB->build(array( 'select' => 'e.entry_id, b.blog_id, e.entry_name_seo, e.entry_last_update',
+ 'from' => array('blog_entries' => 'e'),
+ 'add_join' => array(array('type'=>'left', 'from' => array('blog_blogs' => 'b'),
+ 'where' => 'b.blog_id = e.blog_id')),
+ 'where' => 'b.blog_private = 0
+ AND b.blog_disabled = 0
+ AND b.blog_allowguests = 1
+ AND b.blog_view_level = \'public\'
+ AND e.entry_status = \'published\'',
+ 'order' => 'e.entry_id DESC',
+ 'limit' => array($limitCount, 100)));
+ $outer = $this->DB->execute();
+
+ // Add blogs to sitemap:
+ while($entry = $this->DB->fetch($outer))
+ {
+ $url = $this->settings['board_url'] . '/index.php?app=blog&module=display§ion=blog&blogid='.$entry['blog_id'].'&showentry=' . $entry['entry_id'];
+ $url = ipSeo_FURL::build($url, 'none', $entry['entry_name_seo'], 'showentry');
+ //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $entry['entry_name_seo'], 'showentry');
+ $addedCount = $this->sitemap->addURL($url, $entry['entry_last_update'], $this->settings['sitemap_priority_blog_entries']);
+
+ unset($url);
+ unset($entry);
+ }
+
+ $limitCount += 100;
+
+ // If we've got back less rows than expected, we've probably got no more to pull:
+ if($this->DB->getTotalRows($outer) < 100)
+ {
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/blogs.php b/upload/admin/applications/core/extensions/sitemapPlugins/blogs.php
new file mode 100644
index 00000000..3580ea07
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/blogs.php
@@ -0,0 +1,57 @@
+settings['sitemap_priority_blogs'] == 0)
+ {
+ return;
+ }
+
+ // Check whether groups can access blog at all:
+ $guestGroup = $this->DB->buildAndFetch(array( 'select' => 'g_blog_settings',
+ 'from' => 'groups',
+ 'where' => 'g_id = ' . $this->settings['guest_group']));
+
+ // Default is to not allow access unless explicitly given:
+ if(is_null($guestGroup['g_blog_settings']))
+ {
+ return;
+ }
+
+ $settings = unserialize($guestGroup['g_blog_settings']);
+
+ // Not allowed to access unless g_blog_allowview = 1
+ if(!is_array($settings) || intval($settings['g_blog_allowview']) != 1)
+ {
+ return;
+ }
+
+ // Get blogs:
+ $query = $this->DB->build(array( 'select' => 'blog_id, blog_seo_name, blog_last_udate',
+ 'from' => 'blog_blogs',
+ 'where' => 'blog_private = 0
+ AND blog_disabled = 0
+ AND blog_allowguests = 1
+ AND blog_view_level = \'public\''));
+ $this->DB->execute();
+
+ // Add blogs to sitemap:
+ while($blog = $this->DB->fetch())
+ {
+ $url = $this->settings['board_url'] . '/index.php?app=blog&blogid=' . $blog['blog_id'];
+ $url = ipSeo_FURL::build($url, 'none', $blog['blog_seo_name'], 'showblog');
+ //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $blog['blog_seo_name'], 'showblog');
+ $this->sitemap->addURL($url, $blog['blog_last_udate'], $this->settings['sitemap_priority_blogs']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/calendar.php b/upload/admin/applications/core/extensions/sitemapPlugins/calendar.php
new file mode 100644
index 00000000..08ac9314
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/calendar.php
@@ -0,0 +1,92 @@
+settings['sitemap_priority_calendar'] == 0)
+ {
+ return;
+ }
+
+ //-----------------------------------------
+ // Which calendars can we access?
+ //-----------------------------------------
+
+ $calendars = array();
+ $this->DB->build( array(
+ 'select' => 'c.cal_id',
+ 'from' => array( 'cal_calendars' => 'c' ),
+ 'add_join' => array( array(
+ 'from' => array('permission_index' => 'p'),
+ 'where' => "(p.app = 'calendar' AND p.perm_type = 'calendar' AND p.perm_type_id = c.cal_id)",
+ 'type' => 'left'
+ ) ),
+ 'where' => $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'p.perm_view' )
+ ) );
+ $this->DB->execute();
+ while ( $row = $this->DB->fetch() )
+ {
+ $calendars[] = $row['cal_id'];
+ }
+
+ if ( empty( $calendars ) )
+ {
+ return;
+ }
+
+ //-----------------------------------------
+ // Get past events
+ //-----------------------------------------
+
+ $time = time();
+
+ $this->DB->build( array(
+ 'select' => 'event_id, event_title_seo, event_start_date',
+ 'from' => 'cal_events',
+ 'where' => "event_end_date < {$time} AND " . $this->DB->buildWherePermission( $calendars, 'event_calendar_id', FALSE ) . ' AND ' . $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'event_perms' ),
+ 'limit' => $this->settings['sitemap_count_calendar_past']
+ ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $url = $this->settings['board_url'] . '/index.php?app=calendar&module=calendar§ion=view&do=showevent&event_id=' . $row['event_id'];
+ $url = ipSeo_FURL::build( $url, 'none', $row['event_title_seo'], 'cal_event' );
+
+ $this->sitemap->addURL( $url, strtotime( $row['event_start_date'] ), $this->settings['sitemap_priority_calendar'] );
+ }
+
+ //-----------------------------------------
+ // Get future events
+ //-----------------------------------------
+
+ $this->DB->build( array(
+ 'select' => 'event_id, event_title_seo, event_start_date',
+ 'from' => 'cal_events',
+ 'where' => "event_end_date > {$time} AND " . $this->DB->buildWherePermission( $calendars, 'event_calendar_id', FALSE ) . ' AND ' . $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'event_perms' ),
+ 'limit' => $this->settings['sitemap_count_calendar_future']
+ ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $url = $this->settings['board_url'] . '/index.php?app=calendar&module=calendar§ion=view&do=showevent&event_id=' . $row['event_id'];
+ $url = ipSeo_FURL::build( $url, 'none', $row['event_title_seo'], 'cal_event' );
+
+ $this->sitemap->addURL( $url, strtotime( $row['event_start_date'] ), $this->settings['sitemap_priority_calendar'] );
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/chat.php b/upload/admin/applications/core/extensions/sitemapPlugins/chat.php
new file mode 100644
index 00000000..e6f17c44
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/chat.php
@@ -0,0 +1,17 @@
+settings['sitemap_priority_chat'] > 0 )
+ {
+ $this->sitemap->addURL( $this->settings['board_url'] . '/index.php?app=chat', time(), $this->settings['sitemap_priority_chat'] );
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/content_database_categories.php b/upload/admin/applications/core/extensions/sitemapPlugins/content_database_categories.php
new file mode 100644
index 00000000..f9b72121
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/content_database_categories.php
@@ -0,0 +1,68 @@
+settings['sitemap_priority_content_categories'] == 0)
+ {
+ return;
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('ccs') . '/sources/functions.php', 'ccsFunctions', 'ccs' );
+ $ccsFunctions = new $classToLoad($this->registry);
+
+ $permCheck1 = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'perm1.perm_view', true);
+ $permCheck2 = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'perm2.perm_view', true);
+ $permCheck3 = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'p.page_view_perms', true);
+
+ $this->DB->build(array( 'select' => 'c.category_id, c.category_last_record_date, d.database_id, p.*',
+ 'from' => array('ccs_database_categories' => 'c'),
+ 'add_join' => array(
+ array(
+ 'from' => array('ccs_databases' => 'd'),
+ 'where' => "d.database_id = c.category_database_id",
+ 'type' => 'left'),
+ array(
+ 'from' => array('ccs_pages' => 'p'),
+ 'where' => "( d.database_is_articles = 0
+ AND p.page_content LIKE CONCAT('%parse database=\"', d.database_key, '\"%')
+ OR
+ ( d.database_is_articles = 1
+ AND p.page_content LIKE '%parse articles%'))",
+ 'type' => 'left'),
+ array(
+ 'from' => array('permission_index' => 'perm1'),
+ 'where' => "(perm1.app = 'ccs' AND
+ (perm1.perm_type = 'databases' OR perm1.perm_type = 'database') AND
+ perm1.perm_type_id = d.database_id)",
+ 'type' => 'left'),
+ array(
+ 'from' => array('permission_index' => 'perm2'),
+ 'where' => "(perm2.app = 'ccs' AND
+ (perm2.perm_type = 'categories' OR perm2.perm_type = 'cat') AND
+ perm2.perm_type_id = c.category_id)",
+ 'type' => 'left')
+ ),
+ 'where' => " {$permCheck1} AND
+ (perm2.perm_view IS NULL OR perm2.perm_view = '' OR perm2.perm_2=',,' OR {$permCheck2}) AND
+ ({$permCheck3})",
+ 'order' => 'category_id DESC',
+ ));
+
+ $result = $this->DB->execute();
+
+ while($category = $this->DB->fetch($result))
+ {
+ $pageUrl = $ccsFunctions->returnPageUrl($category) .'?';
+ $url = $ccsFunctions->getCategoriesClass($category['database_id'], false)->getCategoryUrl($pageUrl, $category['category_id']);
+
+ $this->sitemap->addURL($url, (int)$category['category_last_record_date'], $this->settings['sitemap_priority_content_categories']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/content_database_records.php b/upload/admin/applications/core/extensions/sitemapPlugins/content_database_records.php
new file mode 100644
index 00000000..2359e339
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/content_database_records.php
@@ -0,0 +1,169 @@
+settings['sitemap_priority_content_records'] == 0)
+ {
+ return;
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('ccs') . '/sources/functions.php', 'ccsFunctions', 'ccs' );
+ $databaseToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('ccs') . '/sources/databases.php', 'databaseBuilder', 'ccs' );
+ $ccsFunctions = new $classToLoad($this->registry);
+
+ $permCheck1 = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'perm1.perm_2', true);
+ $permCheck2 = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'perm2.perm_2', true);
+ $permCheck3 = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'p.page_view_perms', true);
+
+ $this->DB->build(array( 'select' => 'c.category_id, d.*, p.*',
+ 'from' => array('ccs_database_categories' => 'c'),
+ 'add_join' => array(
+ array(
+ 'from' => array('ccs_databases' => 'd'),
+ 'where' => "d.database_id = c.category_database_id",
+ 'type' => 'left'),
+ array(
+ 'from' => array('ccs_pages' => 'p'),
+ 'where' => "( d.database_is_articles = 0
+ AND p.page_content LIKE CONCAT('%parse database=\"', d.database_key, '\"%')
+ OR
+ ( d.database_is_articles = 1
+ AND p.page_content LIKE '%\{parse articles\}%'))",
+ 'type' => 'left'),
+ array(
+ 'from' => array('permission_index' => 'perm1'),
+ 'where' => "(perm1.app = 'ccs' AND
+ (perm1.perm_type = 'databases' OR perm1.perm_type = 'database') AND
+ perm1.perm_type_id = d.database_id)",
+ 'type' => 'left'),
+ array(
+ 'from' => array('permission_index' => 'perm2'),
+ 'where' => "(perm2.app = 'ccs' AND
+ (perm2.perm_type = 'categories' OR perm2.perm_type = 'cat') AND
+ perm2.perm_type_id = c.category_id)",
+ 'type' => 'left')
+ ),
+ 'where' => " {$permCheck1} AND
+ (perm2.perm_2 IS NULL OR perm2.perm_2 = '' OR perm2.perm_2=',,' OR {$permCheck2}) AND
+ ({$permCheck3})",
+ 'order' => 'category_id DESC',
+ ));
+
+ $result = $this->DB->execute();
+
+ $categories = array();
+ $databases = array();
+
+ while($category = $this->DB->fetch($result))
+ {
+ $categories[$category['category_id']] = $category['category_id'];
+ $databases[$category['database_id']] = $category;
+ $databases[$category['database_id']]['base_link'] = $ccsFunctions->returnPageUrl($category) .'?';
+ }
+
+ $_databases = $this->cache->getCache('ccs_databases');
+
+ foreach( $_databases as $_db )
+ {
+ if( isset($databases[ $_db['database_id'] ]) )
+ {
+ continue;
+ }
+
+ if ( ipsRegistry::getClass('permissions')->check( 'view', $_db, explode( ',', $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ) ) != TRUE )
+ {
+ $databases[ $_db['database_id'] ] = $_db;
+ $databases[ $_db['database_id'] ]['base_link'] = $ccsFunctions->returnDatabaseUrl( $_db['database_id'] );
+ }
+ }
+
+ /*if(!count($categories))
+ {
+ return;
+ }*/
+
+ $_cats = ( count($categories) ) ? implode( ',', $categories ) : 0;
+ $_hardLimit = !ipSeo_SitemapGenerator::isCronJob() ? 10000 : 500000000;
+ $addedCount = 0;
+
+ foreach($databases as $database)
+ {
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ sleep(1);
+ //print 'Processing database: ' . $database['database_name'] . PHP_EOL;
+ }
+
+ $db = new $databaseToLoad($this->registry);
+ $db->categories = $ccsFunctions->getCategoriesClass($database['database_id'], false);
+ $db->database = $database;
+
+ $db->fieldsClass = $this->registry->ccsFunctions->getFieldsClass();
+
+ $limitCount = 0;
+ while(1)
+ {
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ sleep(0.25);
+ }
+
+ if($addedCount >= $_hardLimit)
+ {
+ break;
+ }
+
+ $_published = null;
+
+ if( $database['database_is_articles'] )
+ {
+ $_cache = $this->cache->getCache('ccs_fields');
+
+ foreach( $_cache[ $database['database_id'] ] as $_field )
+ {
+ if( $_field['field_key'] == 'article_date' )
+ {
+ $_published = 'field_' . $_field['field_id'];
+ }
+ }
+ }
+
+ $this->DB->build(array( 'select' => '*',
+ 'from' => $database['database_database'],
+ 'where' => 'record_approved = 1 AND ( category_id IN ('.$_cats.') OR category_id=0)',
+ 'order' => 'record_updated DESC',
+ 'limit' => array($limitCount, 100)
+ ));
+ $result = $this->DB->execute();
+
+ while($record = $this->DB->fetch($result))
+ {
+ if( $database['database_is_articles'] AND $record[ $_published ] > time() )
+ {
+ continue;
+ }
+
+ $record['_skipUpdateDynamic'] = true;
+ $url = $db->getRecordUrl($record);
+
+ $addedCount = $this->sitemap->addUrl($url, (int)$record['record_updated'], $this->settings['sitemap_priority_content_records']);
+ }
+
+ $limitCount += 100;
+
+ // If we've got back less rows than expected, we've probably got no more to pull:
+ if($this->DB->getTotalRows($result) < 100)
+ {
+ break;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/content_pages.php b/upload/admin/applications/core/extensions/sitemapPlugins/content_pages.php
new file mode 100644
index 00000000..0c036034
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/content_pages.php
@@ -0,0 +1,61 @@
+DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'page_view_perms', true);
+
+ $this->DB->build(array(
+ 'select' => '*',
+ 'from' => 'ccs_pages',
+ 'where' => "({$permCheck}) AND page_content_type = 'page'",
+ 'order' => 'page_last_edited DESC',
+ 'limit' => array($curPages, 100)));
+
+ $result = $this->DB->execute();
+
+ if($result)
+ {
+ // Add the resulting rows to the sitemap:
+ while($row = $this->DB->fetch($result))
+ {
+ if(!$this->registry->isClassLoaded('ccsFunctions'))
+ {
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('ccs') . '/sources/functions.php', 'ccsFunctions', 'ccs' );
+ $this->registry->setClass('ccsFunctions', new $classToLoad($this->registry));
+ }
+ $url = $this->registry->ccsFunctions->returnPageUrl($row);
+
+ $priority = ($row['page_folder'] == '' && $row['page_seo_name'] == $this->settings['ccs_default_page']) ? $this->settings['sitemap_priority_ccs_index'] : $this->settings['sitemap_priority_ccs_page'];
+
+ $this->sitemap->addURL($url, $row['page_last_edited'], $priority);
+ }
+
+ // If we've got back less rows than expected, we've probably got no more to pull:
+ $pulledRows = $this->DB->getTotalRows($result);
+ $curPages += $pulledRows;
+ if($pulledRows < 100)
+ {
+ break;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/core.php b/upload/admin/applications/core/extensions/sitemapPlugins/core.php
new file mode 100644
index 00000000..46f98c5c
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/core.php
@@ -0,0 +1,17 @@
+settings['sitemap_priority_index'] > 0)
+ {
+ $this->sitemap->addURL($this->settings['board_url'] . '/', time(), $this->settings['sitemap_priority_index']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/downloads_categories.php b/upload/admin/applications/core/extensions/sitemapPlugins/downloads_categories.php
new file mode 100644
index 00000000..640af2b9
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/downloads_categories.php
@@ -0,0 +1,39 @@
+settings['sitemap_priority_downloads_categories'] == 0)
+ {
+ return;
+ }
+
+ // Get categories:
+ $permCheck = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'p.perm_view', true);
+
+ $this->DB->build(array( 'select' => 'c.cid, c.cname_furl',
+ 'from' => array('downloads_categories' => 'c'),
+ 'add_join' => array( array(
+ 'from' => array('permission_index' => 'p'),
+ 'where' => "(p.app = 'downloads' AND p.perm_type = 'cat' AND p.perm_type_id = c.cid)",
+ 'type' => 'left')),
+ 'where' => "c.copen = 1 AND ({$permCheck})"));
+ $this->DB->execute();
+
+ // Add to sitemap:
+ while($cat = $this->DB->fetch())
+ {
+
+ $url = $this->settings['board_url'] . '/index.php?app=downloads&showcat=' . $cat['cid'];
+ $url = ipSeo_FURL::build($url, 'none', $cat['cname_furl'], 'idmshowcat');
+ //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $cat['cname_furl'], 'idmshowcat');
+ $this->sitemap->addURL($url, null, $this->settings['sitemap_priority_downloads_categories']);
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/downloads_files.php b/upload/admin/applications/core/extensions/sitemapPlugins/downloads_files.php
new file mode 100644
index 00000000..e190e073
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/downloads_files.php
@@ -0,0 +1,69 @@
+settings['sitemap_priority_downloads_files'] == 0)
+ {
+ return;
+ }
+
+ $addedCount = 0;
+ $limitCount = 0;
+ while($addedCount < $this->settings['sitemap_count_downloads_files'])
+ {
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ sleep(0.5);
+ }
+
+ // Get files:
+ $permCheck = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'p.perm_2', true );
+
+ $this->DB->build(array( 'select' => 'f.file_id, f.file_name_furl, f.file_updated',
+ 'from' => array('downloads_files' => 'f'),
+ 'add_join' => array(
+ array(
+ 'from' => array('downloads_categories' => 'c'),
+ 'where' => "c.cid = f.file_cat",
+ 'type' => 'left'),
+ array(
+ 'from' => array('permission_index' => 'p'),
+ 'where' => "(p.app = 'downloads' AND p.perm_type = 'cat' AND p.perm_type_id = c.cid)",
+ 'type' => 'left'),
+ ),
+ 'where' => "f.file_broken = 0 AND file_open = 1 AND c.copen = 1 AND ({$permCheck})",
+ 'order' => 'f.file_updated DESC',
+ 'limit' => array($limitCount, 100)));
+ $result = $this->DB->execute();
+
+ // Add blogs to sitemap:
+ while($file = $this->DB->fetch($result))
+ {
+ if ( ! $file['file_updated'] )
+ {
+ $file['file_updated'] = $file['file_submitted'];
+ }
+
+ $url = $this->settings['board_url'] . '/index.php?app=downloads&showfile=' . $file['file_id'];
+ $url = ipSeo_FURL::build($url, 'none', $file['file_name_furl'], 'idmshowfile');
+ //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $file['file_name_furl'], 'idmshowfile');
+ $addedCount = $this->sitemap->addURL($url, $file['file_updated'], $this->settings['sitemap_priority_downloads_files']);
+ }
+
+ $limitCount += 100;
+
+ // If we've got back less rows than expected, we've probably got no more to pull:
+ if($this->DB->getTotalRows($result) < 100)
+ {
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/forums.php b/upload/admin/applications/core/extensions/sitemapPlugins/forums.php
new file mode 100644
index 00000000..6ba5918b
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/forums.php
@@ -0,0 +1,49 @@
+settings['sitemap_priority_forums'] == 0)
+ {
+ return;
+ }
+
+ // Get categories:
+ $permCheck = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'p.perm_view', true);
+
+ $this->DB->build(array( 'select' => 'f.*',
+ 'from' => array('forums' => 'f'),
+ 'add_join' => array( array(
+ 'from' => array('permission_index' => 'p'),
+ 'where' => "(p.perm_type = 'forum' AND p.perm_type_id = f.id)",
+ 'type' => 'left')),
+ 'where' => $permCheck));
+ $result = $this->DB->execute();
+
+ if($result)
+ {
+ // Add the resulting rows to the sitemap:
+ while($row = $this->DB->fetch( $result ))
+ {
+ if ( $row['ipseo_priority'] == '0' )
+ {
+ continue;
+ }
+ $priority = ( $row['ipseo_priority'] == '' ) ? $this->settings['sitemap_priority_forums'] : $row['ipseo_priority'];
+
+ $url = $this->settings['board_url'] . '/index.php?showforum=' . $row['id'];
+ $url = ipSeo_FURL::build($url, 'none', $row['name_seo'], 'showforum');
+ //$url = ipsRegistry::getClass('output')->buildSEOUrl( $url, 'none', $row['name_seo'], 'showforum' );
+
+ $mod = intval($row['last_post']) == 0 ? time() : $row['last_post'];
+ $this->sitemap->addURL( $url, $mod, $priority );
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/gallery_albums.php b/upload/admin/applications/core/extensions/sitemapPlugins/gallery_albums.php
new file mode 100644
index 00000000..f11dd097
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/gallery_albums.php
@@ -0,0 +1,57 @@
+settings['sitemap_priority_gallery_albums'] == 0 || !is_file($galleryClassFile))
+ {
+ return;
+ }
+
+ $classToLoad = IPSLib::loadLibrary( $galleryClassFile, 'ipsGallery', 'gallery' );
+ $this->registry->setClass( 'gallery', new $classToLoad( $this->registry ) );
+
+ $limitCount = 0;
+ while(1)
+ {
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ sleep(0.5);
+ }
+
+ $filters = array(
+ 'sortOrder' => 'desc',
+ 'sortKey' => 'date',
+ 'offset' => $limitCount,
+ 'limit' => 100,
+ 'isViewable' => true,
+ 'memberData' => array( 'member_id' => 0 )
+ );
+
+ $albums = $this->registry->gallery->helper('albums')->fetchAlbumsByFilters( $filters );
+
+ foreach($albums as $album)
+ {
+ $url = "{$this->settings['board_url']}/index.php?app=gallery&album={$album['album_id']}";
+ $url = ipSeo_FURL::build( $url, 'none', $album['album_name_seo'], 'viewalbum' );
+
+ $addedCount = $this->sitemap->addUrl( $url, $album['album_last_img_date'], $this->settings['sitemap_priority_gallery_albums'] );
+ }
+
+ $limitCount += 100;
+
+ if(count($albums) < 100)
+ {
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/gallery_images.php b/upload/admin/applications/core/extensions/sitemapPlugins/gallery_images.php
new file mode 100644
index 00000000..47766dfb
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/gallery_images.php
@@ -0,0 +1,69 @@
+settings['sitemap_priority_gallery_images'] == 0 || !is_file($galleryClassFile))
+ {
+ return;
+ }
+
+ $classToLoad = IPSLib::loadLibrary( $galleryClassFile, 'ipsGallery', 'gallery' );
+ $this->registry->setClass( 'gallery', new $classToLoad( $this->registry ) );
+
+ $max = $this->settings['sitemap_count_gallery_images'];
+
+ if(!ipSeo_SitemapGenerator::isCronJob() && ($max > 10000 || $max == -1))
+ {
+ $max = 10000;
+ }
+ elseif(ipSeo_SitemapGenerator::isCronJob() && $max == -1)
+ {
+ $max = 500000000;
+ }
+
+ $addedCount = 0;
+ $limitCount = 0;
+ while($addedCount < $max)
+ {
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ sleep(0.5);
+ }
+
+ $filters = array(
+ 'sortOrder' => 'desc',
+ 'sortKey' => 'date',
+ 'offset' => $limitCount,
+ 'limit' => 100,
+ 'getLatestComment' => 1,
+ );
+
+ $memberId = 0;
+ $images = $this->registry->gallery->helper('image')->fetchImages( $memberId, $filters );
+
+ foreach($images as $image)
+ {
+ $url = "{$this->settings['board_url']}/index.php?app=gallery&image={$image['image_id']}";
+ $url = ipSeo_FURL::build( $url, 'none', $image['image_caption_seo'], 'viewimage' );
+ $lastMod = is_null($image['comment_post_date']) ? $image['image_date'] : $image['comment_post_date'];
+ $addedCount = $this->sitemap->addUrl($url, $lastMod, $this->settings['sitemap_priority_gallery_images']);
+ }
+
+ $limitCount += 100;
+
+ if(count($images) < 100)
+ {
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/sources/classes/nodes/index.html b/upload/admin/applications/core/extensions/sitemapPlugins/index.html
similarity index 100%
rename from upload/admin/sources/classes/nodes/index.html
rename to upload/admin/applications/core/extensions/sitemapPlugins/index.html
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/nexus_categories.php b/upload/admin/applications/core/extensions/sitemapPlugins/nexus_categories.php
new file mode 100644
index 00000000..ef30060d
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/nexus_categories.php
@@ -0,0 +1,32 @@
+settings['sitemap_priority_nexus_categories'] == 0)
+ {
+ return;
+ }
+
+ // Get categories:
+ $this->DB->build(array( 'select' => 'pg_id, pg_name, pg_seo_name',
+ 'from' => 'nexus_package_groups',
+ ) );
+ $this->DB->execute();
+
+ // Add to sitemap:
+ while( $row = $this->DB->fetch() )
+ {
+ $url = $this->settings['board_url'] . '/index.php?app=nexus&module=payments&cat=' . $row['pg_id'];
+ $url = ipSeo_FURL::build( $url, 'none', $row['pg_seo_name'], 'storecat' );
+
+ $this->sitemap->addURL( $url, null, $this->settings['sitemap_priority_nexus_categories'] );
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/nexus_products.php b/upload/admin/applications/core/extensions/sitemapPlugins/nexus_products.php
new file mode 100644
index 00000000..868d9d47
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/nexus_products.php
@@ -0,0 +1,33 @@
+settings['sitemap_priority_nexus_products'] == 0)
+ {
+ return;
+ }
+
+ // Get categories:
+ $this->DB->build(array( 'select' => 'p_id, p_name, p_seo_name',
+ 'from' => 'nexus_packages',
+ 'where' => 'p_store=1 AND ' . $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'p_member_groups' ),
+ ) );
+ $this->DB->execute();
+
+ // Add to sitemap:
+ while( $row = $this->DB->fetch() )
+ {
+ $url = $this->settings['board_url'] . '/index.php?app=nexus&module=payments§ion=store&do=item&id=' . $row['p_id'];
+ $url = ipSeo_FURL::build( $url, 'none', $row['p_seo_name'], 'storeitem' );
+
+ $this->sitemap->addURL( $url, null, $this->settings['sitemap_priority_nexus_products'] );
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sitemapPlugins/topics.php b/upload/admin/applications/core/extensions/sitemapPlugins/topics.php
new file mode 100644
index 00000000..3d6c8c08
--- /dev/null
+++ b/upload/admin/applications/core/extensions/sitemapPlugins/topics.php
@@ -0,0 +1,194 @@
+settings['sitemap_priority_topics'] == 0)
+ {
+ return;
+ }
+
+ $maxTopics = (int)ipsRegistry::$settings['sitemap_recent_topics'];
+
+ if(!ipSeo_SitemapGenerator::isCronJob() && ($maxTopics > 10000 || $maxTopics == -1))
+ {
+ $maxTopics = 10000;
+ }
+ elseif(ipSeo_SitemapGenerator::isCronJob() && $maxTopics == -1)
+ {
+ $maxTopics = 50000000;
+ }
+
+ $curTopics = 0;
+ $limitTopics = 0;
+
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ //print 'Done: ';
+ }
+
+ while($curTopics < $maxTopics)
+ {
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ //print $curTopics . ', ';
+ sleep(0.5);
+ }
+
+ $permCheck = $this->DB->buildWherePermission( array( $this->caches['group_cache'][ $this->settings['guest_group'] ]['g_perm_id'] ), 'p.perm_2', true);
+
+ $this->DB->build( array(
+ 'select' => 't.*, f.ipseo_priority',
+ 'from' => array( 'topics' => 't' ),
+ 'add_join' => array(
+ array(
+ 'from' => array( 'permission_index' => 'p' ),
+ 'where' => "(p.perm_type = 'forum' AND p.perm_type_id = t.forum_id)",
+ 'type' => 'left'
+ ),
+ array(
+ 'from' => array( 'forums' => 'f' ),
+ 'where' => "f.id=t.forum_id",
+ 'type' => 'left'
+ ),
+ ),
+ 'where' => "{$permCheck} AND " . $this->registry->getClass('class_forums')->fetchTopicHiddenQuery( array( 'visible' ), '' ),
+ 'limit' => array( $limitTopics, 100 )
+ ) );
+ $result = $this->DB->execute();
+
+ if($result)
+ {
+ /*$_one = 0;
+ $_two = 0;
+ $_three = 0;*/
+
+ // Add the resulting rows to the sitemap:
+ while($row = $this->DB->fetch($result))
+ {
+ if ( $row['ipseo_priority'] == '0' )
+ {
+ continue;
+ }
+
+ if(!$this->settings['sitemap_topic_pages'] || $row['posts'] <= $this->settings['display_max_posts'])
+ {
+ $url = $this->settings['board_url'] . '/index.php?showtopic=' . $row['tid'];
+ $url = ipSeo_FURL::build($url, 'none', $row['title_seo'], 'showtopic');
+ //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $row['title_seo'], 'showtopic');
+
+ if($this->settings['sitemap_priority_topics'] == 100)
+ {
+ $priority = $this->calculatePriority($row);
+ }
+ else
+ {
+ $priority = $this->settings['sitemap_priority_topics'];
+ }
+
+ $curTopics = $this->sitemap->addURL($url, $row['last_post'], $priority);
+ }
+ else
+ {
+ $j = 1;
+
+ for($i = 0; $i <= $row['posts']; $i += $this->settings['display_max_posts'])
+ {
+ $url = $this->settings['board_url'] . '/index.php?showtopic=' . $row['tid'] . ( ( $j == 1 ) ? '' : '&page=' . $j );
+ $url = ipSeo_FURL::build($url, 'none', $row['title_seo'], 'showtopic');
+ //$url = ipsRegistry::getClass('output')->buildSEOUrl($url, 'none', $row['title_seo'], 'showtopic');
+
+ if($this->settings['sitemap_priority_topics'] == 100)
+ {
+ $priority = $this->calculatePriority($row, true);
+ }
+ else
+ {
+ $priority = $this->settings['sitemap_priority_topics'];
+ }
+
+ $curTopics = $this->sitemap->addURL($url, $row['last_post'], $priority);
+ $j++;
+ }
+ }
+
+ /*$_one += $one;
+ $_two += $two;
+ $_three += $three;*/
+ }
+
+ $limitTopics += 100;
+
+ // If we've got back less rows than expected, we've probably got no more to pull:
+ if($this->DB->getTotalRows($result) < 100)
+ {
+ break;
+ }
+ }
+
+ }
+
+ if(ipSeo_SitemapGenerator::isCronJob())
+ {
+ //print PHP_EOL;
+ }
+ }
+
+ protected function calculatePriority($topic, $subPage = false)
+ {
+ $priority = $subPage ? 0.4 : 0.6;
+
+ // Modify if forum has a special setting
+ if ( $topic['ipseo_priority'] != '' )
+ {
+ $priority += ( $topic['ipseo_priority'] - $priority );
+ }
+
+ // Boost topics where start date is today:
+ if($topic['start_date'] > (time() - 86400))
+ {
+ $priority = $priority + 0.1;
+ }
+
+ // Drop closed topics, but only if not pinned.
+ if(!$topic['pinned'] && $topic['state'] != 'open')
+ {
+ $priority = $priority - 0.2;
+ }
+
+ // Boost pinned topics:
+ if($topic['pinned'])
+ {
+ $priority = $priority + 0.1;
+ }
+
+ // Boost topics with more than one page of posts:
+ if($topic['posts'] > $this->settings['display_max_posts'])
+ {
+ $priority = $priority + 0.1;
+ }
+
+ // Extra boost for topics with more than ten pages of posts:
+ if($topic['posts'] > ($this->settings['display_max_posts'] * 10))
+ {
+ $priority = $priority + 0.2;
+ }
+
+ if($priority > 1)
+ {
+ $priority = 1.0;
+ }
+ elseif($priority < 0)
+ {
+ $priority = 0.0;
+ }
+
+ return $priority;
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/sphinxTemplate.php b/upload/admin/applications/core/extensions/sphinxTemplate.php
index 216440c1..3470877b 100644
--- a/upload/admin/applications/core/extensions/sphinxTemplate.php
+++ b/upload/admin/applications/core/extensions/sphinxTemplate.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Sphinx template file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @package IP.Board
* @subpackage Forums
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
* @since 3.0.0
*
*/
@@ -74,7 +74,7 @@ index core_tags_search_main
mlock = 0
morphology = none
min_word_len = 2
- charset_type = sbcs
+ charset_type = utf-8
html_strip = 0
#infix_fields = tag_text
#min_infix_len = 3
diff --git a/upload/admin/applications/core/extensions/usercpForms.php b/upload/admin/applications/core/extensions/usercpForms.php
index 7d092cb8..9f36c9cf 100644
--- a/upload/admin/applications/core/extensions/usercpForms.php
+++ b/upload/admin/applications/core/extensions/usercpForms.php
@@ -1,3164 +1,3332 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Core user control panel plugin
- * Last Updated: $Date: 2012-06-13 14:36:10 -0400 (Wed, 13 Jun 2012) $
- *
- *
- * @author $Author: AndyMillne $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since 20th February 2002
- * @version $Rev: 10917 $
- *
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class usercpForms_core extends public_core_usercp_manualResolver implements interface_usercp
-{
- /**
- * Tab name
- * This can be left blank and the application title will
- * be used
- *
- * @var string
- */
- public $tab_name = "Settings";
-
- /**
- * Default area code
- *
- * @var string
- */
- public $defaultAreaCode = 'profileinfo';
-
- /**
- * OK Message
- * This is an optional message to return back to the framework
- * to replace the standard 'Settings saved' message
- *
- * @var string
- */
- public $ok_message = '';
-
- /**
- * Hide 'save' button and form elements
- * Useful if you have custom output that doesn't
- * need to use it
- *
- * @var bool
- */
- public $hide_form_and_save_button = false;
-
- /**
- * If you wish to allow uploads, set a value for this
- *
- * @var integer
- */
- public $uploadFormMax = 0;
-
- /**
- * Flag to indicate that the user is a facebook logged in user doozer
- *
- * @var boolean
- */
- protected $_isFBUser = false;
-
- /**
- * Flag to indicate compatibility
- *
- * @var int
- */
- public $version = 32;
-
- /**
- * Initiate this module
- *
- * @return @e void
- */
- public function init( )
- {
- $this->tab_name = ipsRegistry::getClass('class_localization')->words['tab__core'];
-
- /* Facebook? */
- if ( IPSLib::fbc_enabled() === TRUE AND $this->memberData['fb_uid'] )
- {
- $this->_isFBUser = true;
- }
- }
-
- /**
- * Return links for this tab
- * You may return an empty array or FALSE to not have
- * any links show in the tab.
- *
- * The links must have 'area=xxxxx'. The rest of the URL
- * is added automatically.
- * 'area' can only be a-z A-Z 0-9 - _
- *
- * @author Matt Mecham
- * @return array Links
- */
- public function getLinks()
- {
- ipsRegistry::instance()->getClass('class_localization')->loadLanguageFile( array( 'public_usercp' ), 'core' );
-
- $array = array();
-
- $array[] = array( 'url' => 'area=profileinfo',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['change_settings'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'profileinfo' ? 1 : 0,
- 'area' => 'profileinfo'
- );
-
- if ( $this->memberData['gbw_allow_customization'] AND ! $this->memberData['bw_disable_customization'] )
- {
- $array[] = array( 'url' => 'area=customize',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_customize'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'customize' ? 1 : 0,
- 'area' => 'customize'
- );
- }
-
- $array[] = array( 'url' => 'area=email',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_email_pass_change'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'email' ? 1 : 0,
- 'area' => 'email'
- );
-
- if ( $this->settings['auth_allow_dnames'] == 1 AND $this->memberData['g_dname_changes'] != 0 )
- {
- $array[] = array( 'url' => 'area=displayname',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['ucp_change_name'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'displayname' ? 1 : 0,
- 'area' => 'displayname'
- );
- }
-
- $sig_restrictions = explode( ':', $this->memberData['g_signature_limits'] );
-
- if ( ! $sig_restrictions[0] OR ( $sig_restrictions[0] AND $this->memberData['g_sig_unit'] ) )
- {
- $array[] = array( 'url' => 'area=signature',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_sig_info'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'signature' ? 1 : 0,
- 'area' => 'signature'
- );
- }
-
- $array[] = array( 'url' => 'area=ignoredusers',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_ignore_users'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'ignoredusers' ? 1 : 0,
- 'area' => 'ignoredusers'
- );
-
- if ( IPSLib::fbc_enabled() === TRUE )
- {
- $array[] = array( 'url' => 'area=facebook',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_facebook'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'facebook' ? 1 : 0,
- 'area' => 'facebook'
- );
- }
-
- if ( IPSLib::twitter_enabled() === TRUE )
- {
- $array[] = array( 'url' => 'area=twitter',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_twitter'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'twitter' ? 1 : 0,
- 'area' => 'twitter'
- );
- }
-
- if ( $this->memberData['g_attach_max'] != -1 )
- {
- $array[] = array(
- 'url' => 'area=attachments',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_attach'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'attachments' ? 1 : 0,
- 'area' => 'attachments'
- );
- }
-
- $array[] = array( 'url' => 'area=notifications',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_notifications'],
- 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'notifications' ? 1 : 0,
- 'area' => 'notifications'
- );
-
- $array[] = array( 'url' => 'area=notificationlog',
- 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_arch_notify'],
- 'active' => ( in_array( $this->request['area'], array( 'notificationlog', 'viewNotification', 'removeNotifications' ) ) ) ? 1 : 0,
- 'area' => 'notificationlog'
- );
-
- return $array;
- }
-
-
- /**
- * Run custom event
- *
- * If you pass a 'do' in the URL / post form that is not either:
- * save / save_form or show / show_form then this function is loaded
- * instead. You can return a HTML chunk to be used in the UserCP (the
- * tabs and footer are auto loaded) or redirect to a link.
- *
- * If you are returning HTML, you can use $this->hide_form_and_save_button = 1;
- * to remove the form and save button that is automatically placed there.
- *
- * @author Matt Mecham
- * @param string Current area
- * @return mixed html or void
- */
- public function runCustomEvent( $currentArea )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $html = '';
-
- //-----------------------------------------
- // What to do?
- //-----------------------------------------
-
- switch( $currentArea )
- {
- case 'removeIgnoredUser':
- return $this->customEvent_removeIgnoredUser();
- break;
- case 'toggleIgnoredUser':
- return $this->customEvent_toggleIgnoredUser();
- break;
- case 'facebookSync':
- $html = $this->customEvent_facebookSync();
- break;
- case 'facebookRemove':
- $html = $this->customEvent_facebookRemove();
- break;
- case 'twitterRemove':
- $html = $this->customEvent_twitterRemove();
- break;
- case 'facebookLink':
- $html = $this->customEvent_facebookLink();
- break;
- case 'updateAttachments':
- return $this->customEvent_updateAttachments();
- break;
-
- case 'viewNotification':
- $html = $this->customEvent_viewNotification();
- break;
-
- case 'markNotification':
- return $this->customEvent_markNotification();
- break;
-
- case 'removeNotifications':
- return $this->customEvent_removeNotifications();
- break;
- }
-
- //-----------------------------------------
- // Turn off save button
- //-----------------------------------------
-
- $this->hide_form_and_save_button = 1;
-
- //-----------------------------------------
- // Return
- //-----------------------------------------
-
- return $html;
- }
-
- /**
- * Delete attachments
- *
- * @author Matt Mecham
- * @return string Processed HTML
- */
- public function customEvent_updateAttachments()
- {
- //-----------------------------------------
- // Get the ID's to delete
- //-----------------------------------------
-
- $finalIDs = array();
-
- //-----------------------------------------
- // Grab post IDs
- //-----------------------------------------
-
- if ( is_array( $_POST['attach'] ) and count( $_POST['attach'] ) )
- {
- foreach( $_POST['attach'] as $id => $value )
- {
- $finalIDs[ $id ] = intval( $id );
- }
- }
-
- if ( count($finalIDs) > 0 )
- {
- $this->DB->build( array( 'select' => 'a.*',
- 'from' => array( 'attachments' => 'a' ),
- 'where' => "a.attach_id IN (" . implode( ",", $finalIDs ) .") AND a.attach_rel_module IN( 'post', 'msg' ) AND attach_member_id=" . $this->memberData['member_id'],
- 'add_join' => array(
- array( 'select' => 'p.topic_id, p.pid',
- 'from' => array( 'posts' => 'p' ),
- 'where' => "p.pid=a.attach_rel_id AND a.attach_rel_module='post'",
- 'type' => 'left'
- ),
- array( 'select' => 'mt.msg_id, mt.msg_topic_id',
- 'from' => array( 'message_posts' => 'mt' ),
- 'where' => "mt.msg_id=a.attach_rel_id AND a.attach_rel_module='msg'",
- 'type' => 'left'
- ),
- )
- ) );
-
- $o = $this->DB->execute();
-
- while ( $killmeh = $this->DB->fetch( $o ) )
- {
- if ( $killmeh['attach_location'] )
- {
- @unlink( $this->settings['upload_dir']."/".$killmeh['attach_location'] );
- }
- if ( $killmeh['attach_thumb_location'] )
- {
- @unlink( $this->settings['upload_dir']."/".$killmeh['attach_thumb_location'] );
- }
-
- if ( $killmeh['topic_id'] )
- {
- $this->DB->update( 'topics', 'topic_hasattach=topic_hasattach-1', 'tid='.$killmeh['topic_id'], true, true );
- }
- else if( $killmeh['msg_id'] )
- {
- $this->DB->update( 'message_topics', 'mt_hasattach=mt_hasattach-1', 'mt_id='.$killmeh['msg_topic_id'], true, true );
- }
- }
-
- $this->DB->delete( 'attachments', 'attach_id IN ('.implode(",",$finalIDs).') and attach_member_id='.$this->memberData['member_id'] );
- }
-
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=attachments&do=show" );
- }
-
- /**
- * UserCP handle our notifications
- *
- * @return boolean Successful
- */
- public function customEvent_removeNotifications()
- {
- //-----------------------------------------
- // Check form hash
- //-----------------------------------------
-
- $this->request['secure_key'] = $this->request['secure_key'] ? $this->request['secure_key'] : $this->request['md5check'];
-
- if( $this->request['secure_key'] != $this->member->form_hash )
- {
- $this->registry->output->showError( 'usercp_forums_bad_key', 1021523 );
- }
-
- //-----------------------------------------
- // Notifications library
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
- $notifyLibrary = new $classToLoad( $this->registry );
- $notifyLibrary->setMember( $this->memberData );
-
- //-----------------------------------------
- // Delete the notifications
- //-----------------------------------------
-
- $_toDelete = IPSLib::cleanIntArray( $this->request['notifications'] );
-
- if( !count($_toDelete) )
- {
- return $this->showInlineNotifications( $this->lang->words['no_notify_del'] );
- }
-
- $this->DB->delete( 'inline_notifications', "notify_id IN(" . implode( ',', $_toDelete ) . ") AND notify_to_id=" . $this->memberData['member_id'] );
-
- //-----------------------------------------
- // If member has 'unread' count, rebuild count
- //-----------------------------------------
-
- if( $this->memberData['notification_cnt'] )
- {
- $notifyLibrary->rebuildUnreadCount();
- }
-
- //-----------------------------------------
- // Redirect
- //-----------------------------------------
-
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=notificationlog&confirm=1" );
- }
-
- /**
- * Mark a notification
- *
- * @return string HTML
- */
- public function customEvent_markNotification()
- {
- //-----------------------------------------
- // Notifications library
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
- $notifyLibrary = new $classToLoad( $this->registry );
- $notifyLibrary->setMember( $this->memberData );
-
- //-----------------------------------------
- // Get notification
- //-----------------------------------------
-
- /* Marking them all as read? */
- if ( $this->request['mark'] == 'all' )
- {
- $this->DB->update( 'inline_notifications', array( 'notify_read' => time() ), 'notify_to_id=' . $this->memberData['member_id'] );
- }
- else
- {
- $id = intval($this->request['mark']);
- $notification = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'inline_notifications', 'where' => 'notify_id=' . $id ) );
-
- //-----------------------------------------
- // Error checking
- //-----------------------------------------
-
- if( !$notification['notify_id'] )
- {
- if( $this->request['ajax'] )
- {
- print 'ok';
- exit;
- }
- else
- {
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . "app=core&module=usercp&tab=core&area=notificationlog" );
- }
- }
-
- if( $notification['notify_to_id'] != $this->memberData['member_id'] )
- {
- if( $this->request['ajax'] )
- {
- print 'ok';
- exit;
- }
- else
- {
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . "app=core&module=usercp&tab=core&area=notificationlog" );
- }
- }
-
- //-----------------------------------------
- // Update read timestamp
- //-----------------------------------------
-
- $this->DB->update( 'inline_notifications', array( 'notify_read' => time() ), 'notify_id=' . $id );
- }
-
- //-----------------------------------------
- // If member has 'unread' count, rebuild count
- //-----------------------------------------
-
- if( $this->memberData['notification_cnt'] )
- {
- $notifyLibrary->rebuildUnreadCount();
- }
-
- if( $this->request['ajax'] )
- {
- print 'ok';
- exit;
- }
- else
- {
- $this->registry->output->silentRedirect( $this->settings['base_url'] . "app=core&module=usercp&tab=core&area=notificationlog" );
- }
- }
-
- /**
- * View a notification
- *
- * @return string HTML
- */
- public function customEvent_viewNotification()
- {
- //-----------------------------------------
- // Notifications library
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
- $notifyLibrary = new $classToLoad( $this->registry );
- $notifyLibrary->setMember( $this->memberData );
-
- //-----------------------------------------
- // Get notification
- //-----------------------------------------
-
- $id = intval($this->request['view']);
- $notification = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'inline_notifications', 'where' => 'notify_id=' . $id ) );
-
- //-----------------------------------------
- // Error checking
- //-----------------------------------------
-
- if( !$notification['notify_id'] )
- {
- $this->registry->output->showError( 'bad_notify_id', 10191 );
- }
-
- if( $notification['notify_to_id'] != $this->memberData['member_id'] )
- {
- $this->registry->output->showError( 'bad_notify_id', 10192 );
- }
-
- //-----------------------------------------
- // Update read timestamp
- //-----------------------------------------
-
- $this->DB->update( 'inline_notifications', array( 'notify_read' => time() ), 'notify_id=' . $id );
-
- //-----------------------------------------
- // If member has 'unread' count, rebuild count
- //-----------------------------------------
-
- if( $this->memberData['notification_cnt'] )
- {
- $notifyLibrary->rebuildUnreadCount();
- }
-
- //-----------------------------------------
- // Parse for display
- //-----------------------------------------
-
- /* As the email template parser makes an attempt to reparse 'safe' HTML, we need to make it safe here */
- $notification['notify_text'] = IPSText::htmlspecialchars( $notification['notify_text'] );
-
- IPSText::getTextClass('bbcode')->parse_smilies = 1;
- IPSText::getTextClass('bbcode')->parse_nl2br = 1;
- IPSText::getTextClass('bbcode')->parse_html = 0;
- IPSText::getTextClass('bbcode')->parse_bbcode = 1;
- IPSText::getTextClass('bbcode')->parsing_section = 'global';
-
- $notification['notify_text'] = IPSText::getTextClass('bbcode')->preDisplayParse( nl2br( $notification['notify_text'] ) );
-
- //-----------------------------------------
- // Show notification
- //-----------------------------------------
-
- $this->_nav[] = array( $this->lang->words['m_arch_notify'], 'app=core&module=usercp&tab=core&area=notificationlog' );
- return $this->registry->getClass('output')->getTemplate('ucp')->showNotification( $notification );
- }
-
- /**
- * Custom Event: Remove Twitter link
- *
- * @return @e void
- */
- public function customEvent_twitterRemove()
- {
- //-----------------------------------------
- // Check secure hash...
- //-----------------------------------------
-
- if ( $this->request['secure_key'] != $this->member->form_hash )
- {
- $this->registry->output->showError( 'authorization_error', 100, true, null, 403 );
- }
-
- //-----------------------------------------
- // Okay...
- //-----------------------------------------
-
- if ( $this->memberData['twitter_id'] )
- {
- /* Remove the link */
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'twitter_id' => 0, 'twitter_token' => '', 'twitter_secret' => '' ) ) );
- }
-
- /* Log the user out */
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=global§ion=login&do=logout&k=" . $this->member->form_hash );
- }
-
- /**
- * Custom Event: Create facebook link
- *
- * @return @e void
- */
- public function customEvent_facebookLink()
- {
- //-----------------------------------------
- // Check secure hash...
- //-----------------------------------------
-
- if ( $this->request['secure_key'] != $this->member->form_hash )
- {
- $this->registry->output->showError( 'authorization_error', 100, true, null, 403 );
- }
-
- /* Load application */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
- $facebook = new $classToLoad( $this->registry );
-
- try
- {
- $facebook->linkMember( $this->memberData['member_id'] );
- }
- catch( Exception $error )
- {
- $msg = $error->getMessage();
-
- switch( $msg )
- {
- default:
- case 'NO_FACEBOOK_USER_LOGGED_IN':
- case 'ALREADY_LINKED':
- $this->registry->getClass('output')->showError( 'fbc_authorization_screwup', 1005.99, null, null, 403 );
- break;
- }
- }
-
- //-----------------------------------------
- // Return
- //-----------------------------------------
-
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=facebook&do=show" );
- }
-
- /**
- * Custom Event: Remove facebook link
- *
- * @return @e void
- */
- public function customEvent_facebookRemove()
- {
- //-----------------------------------------
- // Check secure hash...
- //-----------------------------------------
-
- if ( $this->request['secure_key'] != $this->member->form_hash )
- {
- $this->registry->output->showError( 'authorization_error', 100, true, null, 403 );
- }
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
- $facebook = new $classToLoad( $this->registry );
-
- //-----------------------------------------
- // Okay...
- //-----------------------------------------
-
- if ( $this->memberData['fb_uid'] )
- {
- /* Unauthorize application */
- $facebook->revokeAuthorization();
-
- /* Remove the link */
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'fb_uid' => 0, 'fb_emailhash' => '', 'fb_token' => '', 'fb_lastsync' => 0 ) ) );
- }
-
- /* Log the user out */
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=global§ion=login&do=logout&k=" . $this->member->form_hash );
- }
-
- /**
- * Custom Event: Sync up facebook
- * NO LONGER USED. LEFT FOR FIX CONFIRMATION
- *
- * @return @e void
- */
- public function customEvent_facebookSync()
- {
- if ( IPSLib::fbc_enabled() === TRUE )
- {
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
- $facebook = new $classToLoad( $this->registry );
-
- try
- {
- $facebook->syncMember( $this->memberData );
- }
- catch( Exception $error )
- {
- $msg = $error->getMessage();
-
- switch( $msg )
- {
- case 'NOT_LINKED':
- case 'NO_MEMBER':
- default:
- $this->registry->getClass('output')->showError( 'fbc_authorization_screwup', 1005, null, null, 403 );
- break;
- }
- }
-
- //-----------------------------------------
- // Return
- //-----------------------------------------
-
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=facebook&do=show" );
- }
- }
-
- /**
- * Custom Event: Run the find user tool
- *
- * @return @e void
- */
- public function customEvent_toggleIgnoredUser()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $member_id = intval( $this->request['id'] );
- $field = $this->request['field'];
- $update = array();
-
- //-----------------------------------------
- // Grab user
- //-----------------------------------------
-
- $ignoredUser = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'ignored_users',
- 'where' => 'ignore_ignore_id=' . $member_id . ' AND ignore_owner_id=' . $this->memberData['member_id'] ) );
-
- if ( $ignoredUser['ignore_id'] )
- {
- switch( $field )
- {
- default:
- case 'topics':
- $update = array( 'ignore_topics' => ( $ignoredUser['ignore_topics'] == 1 ) ? 0 : 1 );
- break;
- case 'messages':
- $update = array( 'ignore_messages' => ( $ignoredUser['ignore_messages'] == 1 ) ? 0 : 1 );
- break;
- case 'signatures':
- $update = array( 'ignore_signatures' => ( $ignoredUser['ignore_signatures'] == 1 ) ? 0 : 1 );
- break;
- case 'chats':
- $update = array( 'ignore_chats' => ( $ignoredUser['ignore_chats'] == 1 ) ? 0 : 1 );
- break;
- }
-
- //-----------------------------------------
- // Update
- //-----------------------------------------
-
- $this->DB->update( 'ignored_users', $update, 'ignore_id=' . $ignoredUser['ignore_id'] );
-
- /* Rebuild cache */
- IPSMember::rebuildIgnoredUsersCache( $this->memberData );
- }
-
- //-----------------------------------------
- // Return
- //-----------------------------------------
-
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=ignoredusers&do=show" );
- }
-
- /**
- * Custom event: Remove ignored user
- *
- * @author Matt Mecham
- * @return string Processed HTML
- */
- public function customEvent_removeIgnoredUser()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $removeID = intval( $this->request['id'] );
-
- $this->DB->delete( 'ignored_users', 'ignore_owner_id=' . $this->memberData['member_id'] . ' AND ignore_ignore_id=' . $removeID );
-
- /* Rebuild cache */
- IPSMember::rebuildIgnoredUsersCache( $this->memberData );
-
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=ignoredusers&do=show" );
- }
-
- /**
- * UserCP Form Show
- *
- * @author Matt Mecham
- * @param string Current area as defined by 'get_links'
- * @param array Array of errors
- * @return string Processed HTML
- */
- public function showForm( $current_area, $errors=array() )
- {
- //-----------------------------------------
- // Where to go, what to see?
- //-----------------------------------------
-
- switch( $current_area )
- {
- default:
- case 'profileinfo':
- return $this->formProfileInfo();
- break;
- case 'signature':
- return $this->formSignature();
- break;
- case 'photo':
- return $this->formPhoto();
- break;
- case 'ignoredusers':
- return $this->formIgnoredUsers();
- break;
- case 'facebook':
- return $this->formFacebook();
- break;
- case 'twitter':
- return $this->formTwitter();
- break;
- case 'customize':
- return $this->formCustomize();
- break;
- case 'email':
- return $this->showFormEmailPassword();
- break;
- case 'displayname':
- return $this->showFormDisplayname();
- break;
- case 'attachments':
- return $this->showFormAttachments();
- break;
- case 'notifications':
- return $this->showFormNotifications();
- break;
- case 'notificationlog':
- return $this->showInlineNotifications();
- break;
- }
- }
-
- /**
- * Show the customization form
- *
- * @author Matt Mecham
- * @param string Any inline message to show
- * @return string Processed HTML
- */
- public function formCustomize( $inlineMsg='' )
- {
- /* Allow uploads */
- $this->uploadFormMax = 10000 * 1024;
-
- if ( ! $this->memberData['gbw_allow_customization'] OR $this->memberData['bw_disable_customization'] )
- {
- $this->registry->getClass('output')->showError( 'no_permission', 1005.5 );
- }
-
- /* Grab current options */
- $options = unserialize( $this->memberData['pp_customization'] );
- $options = is_array( $options ) ? $options : array();
-
- /* Build input */
- foreach( $options as $k => $v )
- {
- $input[ $k ] = ( $this->request[ $k ] ) ? $this->request[ $k ] : $v;
- }
-
- /* Figure out preview URL */
- if ( $options['type'] == 'url' AND $options['bg_url'] )
- {
- $input['_preview'] = $options['bg_url'];
- }
- else if ( $options['type'] == 'upload' AND $options['bg_url'] )
- {
- $input['_preview'] = $this->settings['upload_url'] . '/' . $options['bg_url'];
- $input['bg_url'] = '';
- }
-
- /* Show form */
- return $this->registry->getClass('output')->getTemplate('ucp')->membersProfileCustomize( $options, $input, $inlineMsg );
- }
-
- /**
- * Show the twitter form
- *
- * @author Matt Mecham
- * @param string Any inline message to show
- * @return string Processed HTML
- */
- public function formTwitter( $inlineMsg='' )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- if( !IPSLib::twitter_enabled() )
- {
- $this->registry->getClass('output')->showError( 'twitter_disabled', 1005.1 );
- }
-
- //-----------------------------------------
- // Twitter user logged in?
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
- $twitter = new $classToLoad( $this->registry, $this->memberData['twitter_token'], $this->memberData['twitter_secret'] );
-
- //-----------------------------------------
- // Thaw bitfield options
- //-----------------------------------------
-
- $bwOptions = IPSBWOptions::thaw( $this->memberData['tc_bwoptions'], 'twitter' );
-
- //-----------------------------------------
- // Merge..
- //-----------------------------------------
-
- if ( is_array( $bwOptions ) )
- {
- foreach( $bwOptions as $k => $v )
- {
- $this->memberData[ $k ] = $v;
- }
- }
-
- if( ! $twitter->isConnected() )
- {
- $this->hide_form_and_save_button = 1;
- }
-
- $userData = $twitter->fetchUserData();
-
- if ( isset( $userData['status']['text'] ) )
- {
- if ( IPS_DOC_CHAR_SET != 'UTF-8' )
- {
- $userData['status']['text'] = IPSText::utf8ToEntities( $userData['status']['text'] );
- }
-
- /* Make safe */
- $userData['status']['text'] = str_replace( array( '<', '>' ), array( '<', '>' ), $userData['status']['text'] );
- }
-
- return $this->registry->getClass('output')->getTemplate('ucp')->membersTwitterConnect( $twitter->isConnected(), $userData );
- }
-
-
- /**
- * Show the member form
- *
- * @author Matt Mecham
- * @param string Any inline message to show
- * @return string Processed HTML
- */
- public function formFacebook( $inlineMsg='' )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- if( !IPSLib::fbc_enabled() )
- {
- $this->registry->getClass('output')->showError( 'fbc_disabled', 1005.2 );
- }
-
- //-----------------------------------------
- // Shut off save button if not associated yet
- //-----------------------------------------
-
- if( !$this->memberData['fb_uid'] )
- {
- $this->hide_form_and_save_button = true;
- $userData = array();
- $linkedMemberData = array();
- $perms = array();
- }
- else
- {
- //-----------------------------------------
- // FB user logged in?
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
- $facebook = new $classToLoad( $this->registry );
-
- /* Now get the linked user */
- $linkedMemberData = IPSMember::load( intval($this->memberData['fb_uid']), 'all', 'fb_uid' );
-
- $userData = $facebook->fetchUserData();
-
- /* Email */
- $perms['email'] = $facebook->fetchHasAppPermission( 'email' );
-
- /* Publish Stream */
- $perms['publish_stream'] = $facebook->fetchHasAppPermission( 'publish_stream' );
-
- /* Read stream */
- $perms['read_stream'] = $facebook->fetchHasAppPermission( 'read_stream' );
-
- /* Offline access */
- $perms['offline_access'] = $facebook->fetchHasAppPermission( 'offline_access' );
-
-
- //-----------------------------------------
- // Thaw bitfield options
- //-----------------------------------------
-
- $bwOptions = IPSBWOptions::thaw( $this->memberData['fb_bwoptions'], 'facebook' );
-
- //-----------------------------------------
- // Merge..
- //-----------------------------------------
-
- if ( is_array( $bwOptions ) )
- {
- foreach( $bwOptions as $k => $v )
- {
- $this->memberData[ $k ] = $v;
- }
- }
-
- //-----------------------------------------
- // Able to update status?
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus' );
- $this->registry->setClass( 'memberStatus', new $classToLoad( $this->registry ) );
-
- $this->registry->memberStatus->setAuthor( $this->memberData );
- $this->memberData['can_updated_status'] = $this->registry->memberStatus->canCreate();
-
- $_updates = $facebook->fetchUserTimeline( $userData['id'], 0, true );
-
- /* Got any? */
- if ( count( $_updates ) )
- {
- $update = array_shift( $_updates );
-
- if ( count( $update ) AND is_array( $update ) )
- {
- $userData['status'] = $update;
- }
- }
-
- if ( is_array( $userData ) AND $userData['status']['message'] AND IPS_DOC_CHAR_SET != 'UTF-8' )
- {
- $userData['status']['message'] = IPSText::utf8ToEntities( $userData['status']['message'] );
- }
-
- /* Make safe */
- $userData['status']['message'] = str_replace( array( '<', '>' ), array( '<', '>' ), $userData['status']['message'] );
- }
-
- return $this->registry->getClass('output')->getTemplate('ucp')->membersFacebookConnect( trim($this->memberData['fb_uid']), $userData, $linkedMemberData, $perms );
- }
-
- /**
- * Show the ignored users
- *
- * @author Matt Mecham
- * @return string Processed HTML
- */
- public function formIgnoredUsers()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $final_users = array();
- $temp_users = array();
- $uid = intval( $this->request['uid'] );
- $ignoredUsers = array();
-
- //-----------------------------------------
- // Do we have incoming?
- //-----------------------------------------
-
- if ( $uid )
- {
- $newmem = IPSMember::load( $uid );
-
- $this->request['newbox_1'] = $newmem['members_display_name'];
- }
-
- //-----------------------------------------
- // Get ignored users
- //-----------------------------------------
-
- $perPage = 25;
-
- /* Count */
- $count = $this->DB->buildAndFetch( array( 'select' => 'count(*) as dracula', 'from' => 'ignored_users', 'where' => 'ignore_owner_id=' . $this->memberData['member_id'] ) );
-
- /* Sort out pagination */
- $st = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $pagination = $this->registry->output->generatePagination( array(
- 'totalItems' => $count['dracula'],
- 'itemsPerPage' => $perPage,
- 'currentStartValue' => $st,
- 'baseUrl' => 'app=core&module=usercp&tab=core&area=ignoredusers',
- ) );
-
- /* Get em */
- $this->DB->build( array( 'select' => '*', 'from' => 'ignored_users', 'where' => 'ignore_owner_id=' . $this->memberData['member_id'], 'limit' => array( $st, $perPage ) ) );
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $ignoredUsers[ $row['ignore_ignore_id'] ] = $row;
- }
-
- //-----------------------------------------
- // Get members and check to see if they've
- // since been moved into a group that cannot
- // be ignored
- //-----------------------------------------
-
- foreach( $ignoredUsers as $_id => $data )
- {
- if ( intval($_id) )
- {
- $temp_users[] = $_id;
- }
- }
-
- if ( count($temp_users) )
- {
- $members = IPSMember::load( $temp_users, 'all' );
-
- foreach( $members as $m )
- {
- $m['g_title'] = IPSMember::makeNameFormatted( $this->caches['group_cache'][ $m['member_group_id'] ]['g_title'], $m['member_group_id'] );
-
- $final_users[ $m['member_id'] ] = IPSMember::buildDisplayData( $m );
- $final_users[ $m['member_id'] ]['ignoreData'] = $ignoredUsers[ $m['member_id'] ];
- }
- }
-
- $this->request['newbox_1'] = $this->request['newbox_1'] ? $this->request['newbox_1'] : '';
-
- return $this->registry->getClass('output')->getTemplate('ucp')->membersIgnoredUsersForm( $final_users, $pagination );
- }
-
-
- /**
- * Show the signature page
- *
- * @author Matt Mecham
- * @return string Processed HTML
- */
- public function formSignature()
- {
- /* Load editor stuff */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
- $this->editor = new $classToLoad();
-
- //-----------------------------------------
- // Check to make sure that we can edit profiles..
- //-----------------------------------------
-
- $sig_restrictions = explode( ':', $this->memberData['g_signature_limits'] );
-
- if ( ! $this->memberData['g_edit_profile'] OR ( $sig_restrictions[0] AND ! $this->memberData['g_sig_unit'] ) )
- {
- $this->registry->getClass('output')->showError( 'members_profile_disabled', 1024, null, null, 403 );
- }
-
- /* Signature Limits */
- if ( $sig_restrictions[0] AND $this->memberData['g_sig_unit'] )
- {
- if ( $this->memberData['gbw_sig_unit_type'] )
- {
- /* days */
- if ( $this->memberData['joined'] > ( time() - ( 86400 * $this->memberData['g_sig_unit'] ) ) )
- {
- $this->hide_form_and_save_button = 1;
- $form['_noPerm'] = sprintf( $this->lang->words['sig_group_restrict_date'], $this->lang->getDate( $this->memberData['joined'] + ( 86400 * $this->memberData['g_sig_unit'] ), 'long' ) );
- }
- }
- else
- {
- /* Posts */
- if ( $this->memberData['posts'] < $this->memberData['g_sig_unit'] )
- {
- $this->hide_form_and_save_button = 1;
- $form['_noPerm'] = sprintf( $this->lang->words['sig_group_restrict_posts'], $this->memberData['g_sig_unit'] - $this->memberData['posts'] );
- }
- }
-
- if( $form['_noPerm'] )
- {
- return $this->registry->getClass('output')->getTemplate('ucp')->membersSignatureFormError( $form );
- }
- }
-
- //-----------------------------------------
- // Set max length
- //-----------------------------------------
-
- $current_sig = '';
- $t_sig = '';
-
- /* Set content in editor */
- $this->editor->setAllowBbcode( true );
- $this->editor->setAllowSmilies( false );
- $this->editor->setAllowHtml( $this->memberData['g_dohtml'] );
- $this->editor->setContent( $this->memberData['signature'], 'signatures' );
-
- /* Current signature preview */
- IPSText::getTextClass('bbcode')->parse_bbcode = 1;
- IPSText::getTextClass('bbcode')->parse_smilies = 0;
- IPSText::getTextClass('bbcode')->parse_html = $this->memberData['g_dohtml'];
- IPSText::getTextClass('bbcode')->parse_nl2br = 1;
- IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
- IPSText::getTextClass('bbcode')->parsing_mgroup = $this->memberData['member_group_id'];
- IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->memberData['mgroup_others'];
-
- $signature = IPSText::getTextClass('bbcode')->preDisplayParse( $this->memberData['signature'] );
-
- return $this->registry->getClass('output')->getTemplate('ucp')->membersSignatureForm( $this->editor->show( 'Post', array( 'noSmilies' => true ) ), $sig_restrictions, $signature );
- }
-
-
- /**
- * Show the profile information
- *
- * @author Matt Mecham
- * @return string Processed HTML
- */
- public function formProfileInfo()
- {
- /* Load Lang File */
- $this->registry->class_localization->loadLanguageFile( array( 'public_profile' ), 'members' );
-
- /* Load editor stuff */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
- $this->editor = new $classToLoad();
-
- /* INIT */
- $required_output = "";
- $optional_output = "";
-
- /* Permission Check */
- if( ! $this->memberData['g_edit_profile'] )
- {
- $this->registry->getClass('output')->showError( 'members_profile_disabled', 1026, null, null, 403 );
- }
-
- /* Format the birthday drop boxes.. */
- $date = getdate();
-
- $day = array();
- $mon = array();
- $year = array();
- $times = array();
-
- /* Build the day options */
- $day[] = array( '0', '--' );
- for ( $i = 1 ; $i < 32 ; $i++ )
- {
- $day[] = array( $i, $i );
- }
-
- /* Build the month options */
- $mon[] = array( '0', '--' );
- for( $i = 1 ; $i < 13 ; $i++ )
- {
- $mon[] = array( $i, $this->lang->words['M_' . $i ] );
- }
-
- /* Build the years options */
- $i = $date['year'] - 1;
- $j = $date['year'] - 100;
-
- $year[] = array( '0', '--' );
- for( $i ; $j < $i ; $i-- )
- {
- $year[] = array( $i, $i );
- }
-
- /* Custom Fields */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
- $fields = new $classToLoad();
-
- $fields->member_data = $this->member->fetchMemberData();
- $fields->initData( 'edit' );
- $fields->parseToEdit();
-
- $field_output = array();
-
- if ( count( $fields->out_fields ) )
- {
- foreach( $fields->out_fields as $id => $element )
- {
- $data = $fields->cache_data[ $id ];
- $field_output[ $data['pf_group_key'] ][ $id ] = array(
- 'field' => $this->registry->getClass('output')->getTemplate('ucp')->field_entry( $fields->field_names[ $id ], $fields->field_desc[ $id ], $fields->out_fields[ $id ], $id ),
- 'required' => $data['pf_not_null']
- );
- }
-
- /*foreach( $fields->out_fields as $id => $data )
- {
- if ( $fields->cache_data[ $id ]['pf_not_null'] == 1 )
- {
- $ftype = 'required_output';
- }
- else
- {
- $ftype = 'optional_output';
- }
-
- ${$ftype} .= $this->registry->getClass('output')->getTemplate('ucp')->field_entry( $fields->field_names[ $id ], $fields->field_desc[ $id ], $data, $id );
- }*/
- }
-
- /* About me */
- $this->editor->setContent( $this->memberData['pp_about_me'] );
-
- $amEditor = $this->editor->show( 'Post', array( 'delayInit' => 1 ) );
-
- /* Times */
- foreach ( $this->lang->words as $k => $v )
- {
- if ( strpos( $k, "time_" ) === 0 )
- {
- $k = str_replace( "time_", '', $k );
-
- if( preg_match( '/^[\-\d\.]+$/', $k ) )
- {
- $times[ $k ] = $v;
- }
- }
- }
-
- ksort( $times );
-
- /* Build and return the form */
- $template = $this->registry->getClass('output')->getTemplate('ucp')->membersProfileForm( $field_output, $fields->fetchGroupTitles(), $day, $mon, $year, $amEditor, $times );
-
- return $template;
- }
-
- /**
- * Show the logged inline notifications
- *
- * @author Brandon Farber
- * @param string Error message
- * @return string Processed HTML
- */
- public function showInlineNotifications( $error='' )
- {
- /* Init */
- $start = intval( $this->request['st'] );
- $perPage = 50;
-
- //-----------------------------------------
- // Get class
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
- $notifyLibrary = new $classToLoad( $this->registry );
- $notifyLibrary->setMember( $this->memberData );
-
- /* Clear them? - used in mobile skin */
- if ( isset($this->request['clear']) && trim($this->request['clear']) == 'true' )
- {
- $this->DB->update( 'inline_notifications', array( 'notify_read' => 1 ), 'notify_to_id=' . $this->memberData['member_id'] );
-
- $notifyLibrary->rebuildUnreadCount();
- }
-
- //-----------------------------------------
- // Turn off normal form
- //-----------------------------------------
-
- $this->hide_form_and_save_button = 1;
-
- //-----------------------------------------
- // Get notifications
- //-----------------------------------------
-
- $_notifications = array();
- $mids = array();
-
- $count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as er',
- 'from' => 'inline_notifications',
- 'where' => 'notify_to_id=' . $this->memberData['member_id'] ) );
-
- if ( $count['er'] )
- {
- $this->DB->build( array( 'select' => '*',
- 'from' => 'inline_notifications',
- 'where' => 'notify_to_id=' . $this->memberData['member_id'],
- 'limit' => array( $start, $perPage ),
- 'order' => 'notify_sent DESC' ) );
- $outer = $this->DB->execute();
-
- while( $r = $this->DB->fetch($outer) )
- {
- $r['notify_icon'] = $notifyLibrary->getNotificationIcon( $r['notify_type_key'] );
-
- $_notifications[] = $r;
-
- $mids[ $r['notify_from_id'] ] = $r['notify_from_id'];
- }
-
- /* Get members */
- if ( count( $mids ) )
- {
- $members = IPSMember::load( array_keys( $mids ), 'all' );
-
- if ( count( $members ) )
- {
- foreach( $_notifications as $key => $data )
- {
- if ( isset($members[ $data['notify_from_id'] ]) )
- {
- $_notifications[ $key ]['member'] = IPSMember::buildProfilePhoto( $members[ $data['notify_from_id'] ] );
- }
- }
- }
- }
- }
-
- $pages = $this->registry->getClass('output')->generatePagination( array( 'totalItems' => $count['er'],
- 'itemsPerPage' => $perPage,
- 'currentStartValue' => $start,
- 'baseUrl' => "app=core&module=usercp&tab=core&area=notificationlog"
- ) );
-
- //-----------------------------------------
- // Send to template
- //-----------------------------------------
-
- return $this->registry->getClass('output')->getTemplate('ucp')->notificationsLog( $_notifications, $error, $pages );
- }
-
- /**
- * Show notification configuration form
- *
- * @author Brandon Farber
- * @return string Processed HTML
- *
- * @note Updating this function update also mobileApiRequest::_handleNotificationTypes()
- */
- public function showFormNotifications()
- {
- //-----------------------------------------
- // Notifications library
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
- $notifyLibrary = new $classToLoad( $this->registry );
- $notifyLibrary->setMember( $this->memberData );
-
- //-----------------------------------------
- // Show the form
- //-----------------------------------------
-
- $_basicOptions = array( array( 'email', $this->lang->words['notopt__email'] ), array( 'inline', $this->lang->words['notopt__inline'] ), array( 'mobile', $this->lang->words['notopt__mobile'] ) );
- $_configOptions = $notifyLibrary->getNotificationData( TRUE );
- $_notifyConfig = $notifyLibrary->getMemberNotificationConfig( $this->memberData );
- $_defaultConfig = $notifyLibrary->getDefaultNotificationConfig();
- $_formOptions = array();
-
- foreach( $_configOptions as $option )
- {
- $_thisConfig = isset($_notifyConfig[ $option['key'] ]) ? $_notifyConfig[ $option['key'] ] : $_defaultConfig[ $option['key'] ];
-
- //-----------------------------------------
- // Determine available options
- //-----------------------------------------
-
- $_available = array();
-
- foreach( $_basicOptions as $_bo ) // ewwww :P
- {
- if( !is_array($_defaultConfig[ $option['key'] ]['disabled']) OR !in_array( $_bo[0], $_defaultConfig[ $option['key'] ]['disabled'] ) )
- {
- $_available[] = $_bo;
- }
- }
-
- //-----------------------------------------
- // If none available, at least give inline
- //-----------------------------------------
-
- if( !count($_available) )
- {
- $_available[] = array( 'inline', $this->lang->words['notify__inline'] );
- }
-
- //-----------------------------------------
- // Start setting data to pass to form
- //-----------------------------------------
-
- $_formOptions[ $option['key'] ] = array();
- $_formOptions[ $option['key'] ]['key'] = $option['key'];
- $_formOptions[ $option['key'] ]['app'] = $option['app'];
-
- //-----------------------------------------
- // Rikki asked for this...
- //-----------------------------------------
-
- foreach( $_available as $_availOption )
- {
- $_formOptions[ $option['key'] ]['options'][ $_availOption[0] ] = $_availOption;
- }
-
- //$_formOptions[ $option['key'] ]['options'] = $_available;
-
- $_formOptions[ $option['key'] ]['defaults'] = is_array($_thisConfig['selected']) ? $_thisConfig['selected'] : array();
- $_formOptions[ $option['key'] ]['disabled'] = 0;
-
- //-----------------------------------------
- // Don't allow member to configure
- // Still show, but disable on form
- //-----------------------------------------
-
- if( $_defaultConfig[ $option['key'] ]['disable_override'] )
- {
- $_formOptions[ $option['key'] ]['disabled'] = 1;
- $_formOptions[ $option['key'] ]['defaults'] = is_array($_defaultConfig[ $option['key'] ]['selected']) ? $_defaultConfig[ $option['key'] ]['selected'] : array();
- }
- }
-
- //-----------------------------------------
- // Other settings
- //-----------------------------------------
-
- $_emailData = array();
-
- //-----------------------------------------
- // Email settings...
- //-----------------------------------------
-
- $_emailData['auto_track'] = $this->memberData['auto_track'] ? 'checked="checked"' : '';
-
- foreach( array( 'none', 'immediate', 'offline', 'daily', 'weekly' ) as $_opt )
- {
- $_emailData['trackOption'][ $_opt ] = ( $this->memberData['auto_track'] == $_opt ) ? 'selected="selected"' : '';
- }
-
- return $this->registry->getClass('output')->getTemplate('ucp')->notificationsForm( $_formOptions, $_emailData );
- }
-
- /**
- * Show the attachments form
- *
- * @author Matt Mecham
- * @return string Processed HTML
- */
- public function showFormAttachments()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $info = array();
- $start = intval( $this->request['st'] );
- $perpage = 15;
- $sort_key = "";
- $attachments = array();
-
- $this->hide_form_and_save_button = 1;
-
- //-----------------------------------------
- // Sort it
- //-----------------------------------------
-
- switch ( $this->request['sort'] )
- {
- case 'date':
- $sort_key = 'a.attach_date ASC';
- $info['date_order'] = 'rdate';
- $info['size_order'] = 'size';
- break;
- case 'rdate':
- $sort_key = 'a.attach_date DESC';
- $info['date_order'] = 'date';
- $info['size_order'] = 'size';
- break;
- case 'size':
- $sort_key = 'a.attach_filesize DESC';
- $info['date_order'] = 'date';
- $info['size_order'] = 'rsize';
- break;
- case 'rsize':
- $sort_key = 'a.attach_filesize ASC';
- $info['date_order'] = 'date';
- $info['size_order'] = 'size';
- break;
- default:
- $sort_key = 'a.attach_date DESC';
- $info['date_order'] = 'date';
- $info['size_order'] = 'size';
- break;
- }
-
- //-----------------------------------------
- // Get some stats...
- //-----------------------------------------
-
- $maxspace = intval($this->memberData['g_attach_max']);
-
- if ( $this->memberData['g_attach_max'] == -1 )
- {
- $this->registry->getClass('output')->showError( 'no_permission_to_attach', 1010 );
- }
-
- //-----------------------------------------
- // Limit by forums
- //-----------------------------------------
-
- $stats = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count, ' . $this->DB->buildCoalesce( array( 'sum(attach_filesize)', 0 ) ) . ' as sum',
- 'from' => 'attachments',
- 'where' => 'attach_member_id=' . $this->memberData['member_id'] . " AND attach_rel_module IN( 'post', 'msg' )" ) );
-
-
- if ( $maxspace > 0 )
- {
- //-----------------------------------------
- // Figure out percentage used
- //-----------------------------------------
-
- $info['has_limit'] = 1;
- $info['full_percent'] = $stats['sum'] ? sprintf( "%.0f", ( ( $stats['sum'] / ($maxspace * 1024) ) * 100) ) : 0;
-
- if ( $info['full_percent'] > 100 )
- {
- $info['full_percent'] = 100;
- }
- else if ( $info['full_percent'] < 1 AND $stats['count'] > 0 )
- {
- $info['full_percent'] = 1;
- }
-
- $info['attach_space_count'] = sprintf( $this->lang->words['attach_space_count'], intval($stats['count']), intval($info['full_percent']) );
- $info['attach_space_used'] = sprintf( $this->lang->words['attach_space_used'] , IPSLib::sizeFormat($stats['sum']), IPSLib::sizeFormat($maxspace * 1024) );
- }
- else
- {
- $info['has_limit'] = 0;
- $info['attach_space_used'] = sprintf( $this->lang->words['attach_space_unl'] , IPSLib::sizeFormat($stats['sum']) );
- }
-
- //-----------------------------------------
- // Pages
- //-----------------------------------------
-
- $pages = $this->registry->getClass('output')->generatePagination( array( 'totalItems' => $stats['count'],
- 'itemsPerPage' => $perpage,
- 'currentStartValue' => $start,
- 'baseUrl' => "app=core&module=usercp&tab=core&area=attachments&sort=" . $this->request['sort'] . "",
- ) );
-
- //-----------------------------------------
- // Get attachments...
- //-----------------------------------------
-
- if( $stats['count'] )
- {
- $this->DB->build( array( 'select' => 'a.*',
- 'from' => array( 'attachments' => 'a' ),
- 'where' => "a.attach_member_id=" . $this->memberData['member_id'] . " AND a.attach_rel_module IN( 'post', 'msg' )",
- 'order' => $sort_key,
- 'limit' => array( $start, $perpage ),
- 'add_join' => array(
- array( 'select' => 'p.topic_id',
- 'from' => array( 'posts' => 'p' ),
- 'where' => 'p.pid=a.attach_rel_id',
- 'type' => 'left'
- ),
- array( 'select' => 't.*',
- 'from' => array( 'topics' => 't' ),
- 'where' => 't.tid=p.topic_id',
- 'type' => 'left'
- ) )
- ) );
- $outer = $this->DB->execute();
-
- $this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'public_topic' ), 'forums' );
-
- $cache = $this->cache->getCache('attachtypes');
-
- while ( $row = $this->DB->fetch( $outer ) )
- {
- if ( IPSMember::checkPermissions('read', $row['forum_id'] ) != TRUE )
- {
- $row['title'] = $this->lang->words['attach_topicmoved'];
- }
-
- //-----------------------------------------
- // Full attachment thingy
- //-----------------------------------------
-
- if ( $row['attach_rel_module'] == 'post' )
- {
- $row['_type'] = 'post';
- }
- else if ( $row['attach_rel_module'] == 'msg' )
- {
- $row['_type'] = 'msg';
- $row['title'] = $this->lang->words['attach_inpm'];
- }
-
- /* IPB 2.x conversion */
- $row['image'] = str_replace( 'folder_mime_types', 'mime_types', $cache[ $row['attach_ext'] ]['atype_img'] );
- $row['short_name'] = IPSText::truncate( $row['attach_file'], 30 );
- $row['attach_date'] = $this->registry->getClass( 'class_localization')->getDate( $row['attach_date'], 'SHORT' );
- $row['real_size'] = IPSLib::sizeFormat( $row['attach_filesize'] );
-
- $attachments[] = $row;
- }
- }
-
- return $this->registry->getClass('output')->getTemplate('ucp')->coreAttachments( $info, $pages, $attachments );
- }
-
- /**
- * Show the Email & Password form
- *
- * @author Matt Mecham
- * @param string Returned error message (if any)
- * @return string Processed HTML
- */
- public function showFormEmailPassword( $_message='' )
- {
- //-----------------------------------------
- // Do not allow validating members to change
- // email when admin validation is on
- // @see http://community.invisionpower.com/tracker/issue-19964-loophole-in-registration-procedure/
- //-----------------------------------------
-
- if( $this->memberData['member_group_id'] == $this->settings['auth_group'] AND in_array( $this->settings['reg_auth_type'], array( 'admin', 'admin_user' ) ) )
- {
- $this->registry->output->showError( $this->lang->words['admin_val_no_email_chg'], 10189 );
- }
-
- //-----------------------------------------
- // Do we have another URL for email resets?
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
- $this->han_login->checkMaintenanceRedirect();
-
- //$txt = $this->lang->words['ce_current'] . $this->memberData['email'];
-
- if ( $this->settings['reg_auth_type'])
- {
- $txt .= $this->lang->words['ce_auth'];
- }
-
- $_message = $_message ? $this->lang->words[$_message] : '';
-
- if( $this->memberData['g_access_cp'] )
- {
- $this->hide_form_and_save_button = true;
- }
-
- return $this->registry->getClass('output')->getTemplate('ucp')->emailPasswordChangeForm( $txt, $_message, $this->_isFBUser );
- }
-
- /**
- * Show the display name form
- *
- * @author Matt Mecham
- * @param string Error message (if any)
- * @return string Processed HTML
- */
- public function showFormDisplayname( $error="" )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $form = array();
-
- //-----------------------------------------
- // CHECK (please)
- //-----------------------------------------
-
- if ( ! $this->settings['auth_allow_dnames'] OR $this->memberData['g_dname_changes'] == 0 OR $this->memberData['g_dname_date'] == 0 )
- {
- $this->registry->getClass('output')->showError( 'no_permission_for_display_names', 1011 );
- }
-
- $this->request['display_name'] = $this->request['display_name'] ? $this->request['display_name'] : '';
-
- $this->settings['username_errormsg'] = str_replace( '{chars}', $this->settings['username_characters'], $this->settings['username_errormsg'] );
-
- //-----------------------------------------
- // Grab # changes > 24 hours
- //-----------------------------------------
-
- $time_check = time() - 86400 * $this->memberData['g_dname_date'];
-
- if( $time_check < $this->memberData['joined'] )
- {
- $time_check = $this->memberData['joined'];
- }
-
- $name_count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count, MIN(dname_date) as min_date', 'from' => 'dnames_change', 'where' => "dname_member_id=" . $this->memberData['member_id'] . " AND dname_date > $time_check AND dname_discount=0" ) );
-
- $name_count['count'] = intval( $name_count['count'] );
- $name_count['min_date'] = intval( $name_count['min_date'] ) ? intval( $name_count['min_date'] ) : $time_check;
-
- //-----------------------------------------
- // Calculate # left
- //-----------------------------------------
-
- /* Check new permissions */
- $_g = $this->caches['group_cache'][ $this->memberData['member_group_id'] ];
-
- if ( $_g['g_displayname_unit'] )
- {
- if ( $_g['gbw_displayname_unit_type'] )
- {
- /* days */
- if ( $this->memberData['joined'] > ( time() - ( 86400 * $_g['g_displayname_unit'] ) ) )
- {
- $this->hide_form_and_save_button = 1;
- $form['_noPerm'] = sprintf( $this->lang->words['dname_group_restrict_date'], $this->lang->getDate( $this->memberData['joined'] + ( 86400 * $_g['g_displayname_unit'] ), 'long' ) );
- }
- }
- else
- {
- /* Posts */
- if ( $this->memberData['posts'] < $_g['g_displayname_unit'] )
- {
- $this->hide_form_and_save_button = 1;
- $form['_noPerm'] = sprintf( $this->lang->words['dname_group_restrict_posts'], $_g['g_displayname_unit'] - $this->memberData['posts'] );
- }
- }
- }
-
- if( !$form['_noPerm'] )
- {
- if ( $this->memberData['g_dname_changes'] == -1 )
- {
- $form['_lang_string'] = $this->lang->words['dname_string2'];
- }
- else
- {
- $form['_changes_left'] = $this->memberData['g_dname_changes'] - $name_count['count'];
- $form['_changes_done'] = $name_count['count'];
-
- # Make sure changes done isn't larger than allowed
- # This happens when changing via ACP
-
- if ( $form['_changes_done'] > $this->memberData['g_dname_changes'] )
- {
- $form['_changes_done'] = $this->memberData['g_dname_changes'];
- }
-
- $form['_first_change'] = $this->registry->getClass( 'class_localization')->getDate( $name_count['min_date'], 'date', 1 );
- $form['_lang_string'] = sprintf( $this->lang->words['dname_string'],
- $form['_changes_done'], $this->memberData['g_dname_changes'],
- $form['_first_change'], $this->memberData['g_dname_changes'],
- $this->memberData['g_dname_date'] ) . $this->lang->words['dname_string2'];
- }
- }
-
- //-----------------------------------------
- // Print
- //-----------------------------------------
-
- $this->_pageTitle = $this->lang->words['m_dname_change'];
-
- return $this->registry->getClass('output')->getTemplate('ucp')->displayNameForm( $form, $error, '', $this->_isFBUser );
- }
-
- /**
- * UserCP Form Check
- *
- * @author Matt Mecham
- * @param string Current area as defined by 'get_links'
- * @return string Processed HTML
- */
- public function saveForm( $current_area )
- {
- //-----------------------------------------
- // Where to go, what to see?
- //-----------------------------------------
-
- switch( $current_area )
- {
- default:
- case 'profileinfo':
- return $this->saveProfileInfo();
- break;
- case 'signature':
- return $this->saveSignature();
- break;
- case 'photo':
- return $this->savePhoto();
- break;
- case 'ignoredusers':
- return $this->saveIgnoredUsers();
- break;
- case 'facebook':
- return $this->saveFacebook();
- break;
- case 'twitter':
- return $this->saveTwitter();
- break;
- case 'customize':
- return $this->saveCustomize();
- break;
- case 'email':
- return $this->saveFormEmailPassword();
- break;
- case 'password':
- return $this->saveFormPassword();
- break;
- case 'displayname':
- return $this->saveFormDisplayname();
- break;
- case 'notifications':
- return $this->saveFormNotifications();
- break;
- }
- }
-
- /**
- * UserCP Save Form: Customize
- *
- * @return array Errors
- */
- public function saveCustomize()
- {
- /* Init */
- $errors = array();
- $custom = array();
- $bg_nix = trim( $this->request['bg_nix'] );
- $bg_url = trim( $this->request['bg_url'] );
- $bg_tile = intval( $this->request['bg_tile'] );
- $bg_color = trim( str_replace( '#', '', $this->request['bg_color'] ) );
-
- /* reset custom */
- $custom = unserialize( $this->memberData['pp_customization'] );
-
- /* Bug #21578 */
- if( ! $bg_color && $custom['bg_color'] )
- {
- $bg_color = $custom['bg_color'];
- }
-
- /* Delete all? */
- if ( $bg_nix )
- {
- /* reset array */
- $custom = array( 'bg_url' => '', 'type' => '', 'bg_color' => '', 'bg_tile' => '' );
-
- /* remove bg images */
- IPSMember::getFunction()->removeUploadedBackgroundImages( $this->memberData['member_id'] );
- }
- else
- {
- if ( $bg_url AND $this->memberData['gbw_allow_url_bgimage'] )
- {
- /* Check */
- if ( ! stristr( $bg_url, 'http://' ) OR preg_match( '#\(\*#', $bg_url ) )
- {
- return array( 0 => $this->lang->words['pp_bgimg_url_bad'] );
- }
-
- $image_extension = strtolower( pathinfo( $bg_url, PATHINFO_EXTENSION ) );
-
- if( ! in_array( $image_extension, array( 'png', 'jpg', 'gif', 'jpeg' ) ) )
- {
- return array( 0 => $this->lang->words['pp_bgimg_ext_bad'] );
- }
-
- $custom['bg_url'] = $bg_url;
- $custom['type'] = 'url';
- }
- else if ( $this->memberData['gbw_allow_upload_bgimage'] )
- {
- /* Load more lang strings */
- $this->registry->class_localization->loadLanguageFile( array( 'public_profile' ), 'members' );
-
- /* Upload img */
- $img = IPSMember::getFunction()->uploadBackgroundImage();
-
- if ( $img['status'] == 'fail' )
- {
- return array( 0 => $this->lang->words[ 'pp_' . $img['error'] ] );
- }
- else if ( $img['final_location'] )
- {
- $custom['bg_url'] = $img['final_location'];
- $custom['type'] = 'upload';
- }
- }
- }
-
- /* BG color */
- $custom['bg_color'] = $bg_nix ? '' : IPSText::alphanumericalClean( $bg_color );
-
- /* Tile */
- $custom['bg_tile'] = $bg_nix ? '' : $bg_tile;
-
- /* Save it */
- if ( ! $this->memberData['bw_disable_customization'] AND $this->memberData['gbw_allow_customization'] )
- {
- IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'pp_customization' => serialize( $custom ) ) ) );
- }
-
- return TRUE;
- }
-
- /**
- * UserCP Save Form: Twitter
- *
- * @return array Errors
- */
- public function saveTwitter()
- {
- if( !IPSLib::twitter_enabled() )
- {
- $this->registry->getClass('output')->showError( 'twitter_disabled', 1005.2 );
- }
-
- //-----------------------------------------
- // Data
- //-----------------------------------------
-
- $toSave = IPSBWOptions::thaw( $this->memberData['tc_bwoptions'], 'twitter' );
-
- //-----------------------------------------
- // Loop and save... simple
- //-----------------------------------------
-
- foreach( array( 'tc_s_pic', 'tc_s_status', 'tc_s_aboutme', 'tc_s_bgimg', 'tc_si_status' ) as $field )
- {
- $toSave[ $field ] = intval( $this->request[ $field ] );
- }
-
- $this->memberData['tc_bwoptions'] = IPSBWOptions::freeze( $toSave, 'twitter' );
- $return = IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'tc_bwoptions' => $this->memberData['tc_bwoptions'] ) ) );
-
- //-----------------------------------------
- // Now sync
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
- $twitter = new $classToLoad( $this->registry, $this->memberData['twitter_token'], $this->memberData['twitter_secret'] );
-
- try
- {
- $twitter->syncMember( $this->memberData );
- }
- catch( Exception $error )
- {
- $msg = $error->getMessage();
-
- switch( $msg )
- {
- case 'NOT_LINKED':
- case 'NO_MEMBER':
- break;
- }
- }
-
- return TRUE;
- }
-
- /**
- * UserCP Save Form: Facebook
- *
- * @return array Errors
- */
- public function saveFacebook()
- {
- if( !IPSLib::fbc_enabled() )
- {
- $this->registry->getClass('output')->showError( 'fbc_disabled', 1005 );
- }
-
- //-----------------------------------------
- // Data
- //-----------------------------------------
-
- $toSave = IPSBWOptions::thaw( $this->memberData['members_bitoptions'], 'members' );
-
- //-----------------------------------------
- // Loop and save... simple
- //-----------------------------------------
-
- foreach( array( 'fbc_s_pic', 'fbc_s_status', 'fbc_s_aboutme', 'fbc_si_status' ) as $field )
- {
- $toSave[ $field ] = intval( $this->request[ $field ] );
- }
-
- $this->memberData['fb_bwoptions'] = IPSBWOptions::freeze( $toSave, 'facebook' );
- IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'fb_bwoptions' => $this->memberData['fb_bwoptions'] ) ) );
-
- //-----------------------------------------
- // Now sync
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
- $facebook = new $classToLoad( $this->registry );
-
- try
- {
- $facebook->syncMember( $this->memberData );
- }
- catch( Exception $error )
- {
- $msg = $error->getMessage();
-
- switch( $msg )
- {
- case 'NOT_LINKED':
- case 'NO_MEMBER':
- break;
- }
- }
-
- return TRUE;
- }
-
- /**
- * UserCP Save Form: Ignore Users
- *
- * @return array Errors
- */
- public function saveIgnoredUsers()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $newName = $this->request['newbox_1'];
- $dnvs = intval( $this->request['donot_view_sigs'] );
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'view_sigs' => ( $dnvs ) ? 0 : 1 ) ) );
-
- if ( trim( $newName ) && $_POST['newbox_1'] != $this->lang->words['ucp_members_name'] )
- {
- //-----------------------------------------
- // Load
- //-----------------------------------------
-
- $member = IPSMember::load( $newName, 'core', 'displayname' );
-
- if ( ! $member['member_id'] )
- {
- return array( 0 => $this->lang->words['ignoreuser_nomem'] );
- }
-
- if ( $member['member_id'] == $this->memberData['member_id'] )
- {
- return array( 0 => $this->lang->words['ignoreuser_cannot'] );
- }
-
- //-----------------------------------------
- // Already ignoring?
- //-----------------------------------------
-
- $ignoreMe = $this->DB->buildAndFetch( array(
- 'select' => '*',
- 'from' => 'ignored_users',
- 'where' => 'ignore_owner_id=' . $this->memberData['member_id'] . ' AND ignore_ignore_id=' . $member['member_id']
- ) );
-
- if ( $ignoreMe['ignore_id'] )
- {
- return array( 0 => $this->lang->words['ignoreuser_already'] );
- }
-
- //-----------------------------------------
- // Can we ignore them?
- //-----------------------------------------
-
- if ( $member['_canBeIgnored'] !== TRUE )
- {
- return array( 0 => $this->lang->words['ignoreuser_cannot'] );
- }
-
- //-----------------------------------------
- // Add it
- //-----------------------------------------
-
- $this->DB->insert( 'ignored_users', array(
- 'ignore_owner_id' => $this->memberData['member_id'],
- 'ignore_ignore_id' => $member['member_id'],
- 'ignore_messages' => !empty( $this->request['ignore_messages'] ) ? 1 : 0,
- 'ignore_topics' => !empty( $this->request['ignore_topics'] ) ? 1 : 0,
- 'ignore_signatures' => !empty( $this->request['ignore_signatures'] ) ? 1 : 0,
- 'ignore_chats' => !empty( $this->request['ignore_chats'] ) ? 1 : 0,
- )
- );
-
- /* Rebuild cache */
- IPSMember::rebuildIgnoredUsersCache( $this->memberData );
- }
-
- return TRUE;
- }
-
-
- /**
- * UserCP Save Form: Signature
- *
- * @return array Errors
- */
- public function saveSignature()
- {
- /* Load editor stuff */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
- $this->editor = new $classToLoad();
-
- //-----------------------------------------
- // Check to make sure that we can edit profiles..
- //-----------------------------------------
-
- $sig_restrictions = explode( ':', $this->memberData['g_signature_limits'] );
-
- if ( ! $this->memberData['g_edit_profile'] OR ( $sig_restrictions[0] AND ! $this->memberData['g_sig_unit'] ) )
- {
- $this->registry->getClass('output')->showError( 'members_profile_disabled', 1028, null, null, 403 );
- }
-
- //-----------------------------------------
- // Post process the editor
- // Now we have safe HTML and bbcode
- //-----------------------------------------
-
- $signature = $this->editor->process( $_POST['Post'] );
-
- //-----------------------------------------
- // Parse post
- //-----------------------------------------
-
- IPSText::getTextClass( 'bbcode' )->parse_smilies = 0;
- IPSText::getTextClass( 'bbcode' )->parse_html = $this->memberData['g_dohtml'];
- IPSText::getTextClass( 'bbcode' )->parse_bbcode = 1;
- IPSText::getTextClass( 'bbcode' )->parsing_section = 'signatures';
-
- $signature = IPSText::getTextClass('bbcode')->preDbParse( $signature );
-
- $testSignature = IPSText::getTextClass('bbcode')->preDisplayParse( $signature );
-
- if ( IPSText::getTextClass( 'bbcode' )->error )
- {
- $this->lang->loadLanguageFile( array( 'public_post' ), 'forums' );
-
- $this->registry->getClass('output')->showError( IPSText::getTextClass( 'bbcode' )->error, 10210 );
- }
-
- //-----------------------------------------
- // Signature restrictions...
- //-----------------------------------------
-
- $sig_errors = array();
-
- //-----------------------------------------
- // Max number of images...
- //-----------------------------------------
-
- if( isset($sig_restrictions[1]) and $sig_restrictions[1] !== '' )
- {
- if( substr_count( strtolower($signature), "[img]" ) > $sig_restrictions[1] )
- {
- $sig_errors[] = sprintf( $this->lang->words['sig_toomanyimages'], $sig_restrictions[1] );
- }
- }
-
- //-----------------------------------------
- // Max number of urls...
- //-----------------------------------------
-
- if( isset($sig_restrictions[4]) and $sig_restrictions[4] !== '' )
- {
- if( substr_count( strtolower($signature), "[url" ) > $sig_restrictions[4] )
- {
- $sig_errors[] = sprintf( $this->lang->words['sig_toomanyurls'], $sig_restrictions[4] );
- }
- else
- {
- preg_match_all( '#(^|\s|>)((http|https|news|ftp)://\w+[^\s\[\]\<]+)#is', $signature, $matches );
-
- if( count($matches[1]) > $sig_restrictions[4] )
- {
- $sig_errors[] = sprintf( $this->lang->words['sig_toomanyurls'], $sig_restrictions[4] );
- }
- }
- }
-
- //-----------------------------------------
- // Max number of lines of text...
- //-----------------------------------------
-
- if( isset($sig_restrictions[5]) and $sig_restrictions[5] !== '' )
- {
- $this->settings['signature_line_length'] = $this->settings['signature_line_length'] > 0 ? $this->settings['signature_line_length'] : 200;
-
- $testSig = wordwrap( $signature, $this->settings['signature_line_length'], ' ' );
-
- // http://community.invisionpower.com/tracker/issue-35105-signature-restriction-minor-bug
- $testSig = preg_replace( '#^\s*( )+#i', '', $testSig );
- $testSig = preg_replace( '#( )+?\s*$#i', '', $testSig );
-
- if( substr_count( $testSig, " " ) >= $sig_restrictions[5] )
- {
- $sig_errors[] = sprintf( $this->lang->words['sig_toomanylines'], $sig_restrictions[5] );
- }
- }
-
- //-----------------------------------------
- // Now the crappy part..
- //-----------------------------------------
-
- if( isset($sig_restrictions[2]) and $sig_restrictions[2] !== '' AND isset($sig_restrictions[3]) and $sig_restrictions[3] !== '' )
- {
- preg_match_all( '/\[img\](.+?)\[\/img\]/i', $signature, $allImages );
-
- if( count($allImages[1]) )
- {
- foreach( $allImages[1] as $foundImage )
- {
- $imageProperties = @getimagesize( $foundImage );
-
- if( is_array($imageProperties) AND count($imageProperties) )
- {
- if( $imageProperties[0] > $sig_restrictions[2] OR $imageProperties[1] > $sig_restrictions[3] )
- {
- $sig_errors[] = sprintf( $this->lang->words['sig_imagetoobig'], $foundImage, $sig_restrictions[2], $sig_restrictions[3] );
- }
- }
- }
- }
- }
-
- if( count($sig_errors) )
- {
- $this->registry->getClass('output')->showError( implode( ' ', $sig_errors ), 10211 );
- }
-
- //-----------------------------------------
- // Write it to the DB.
- //-----------------------------------------
-
- IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'signature' => $signature ) ) );
-
- /* Update cache */
- IPSContentCache::update( $this->memberData['member_id'], 'sig', $testSignature );
-
- return TRUE;
- }
-
-
- /**
- * UserCP Save Form: Profile Info
- *
- * @return array Errors
- */
- public function saveProfileInfo()
- {
- /* Load editor stuff */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
- $this->editor = new $classToLoad();
-
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $pp_setting_moderate_comments = intval( $this->request['pp_setting_moderate_comments'] );
- $pp_setting_moderate_friends = intval( $this->request['pp_setting_moderate_friends'] );
- $pp_setting_count_visitors = intval( $this->request['pp_setting_count_visitors'] );
- $pp_setting_count_comments = intval( $this->request['pp_setting_count_comments'] );
- $pp_setting_count_friends = intval( $this->request['pp_setting_count_friends'] );
-
- //-----------------------------------------
- // Check to make sure that we can edit profiles..
- //-----------------------------------------
-
- if ( ! $this->memberData['g_edit_profile'] )
- {
- $this->registry->getClass('output')->showError( 'members_profile_disabled', 10214, null, null, 403 );
- }
-
- //-----------------------------------------
- // make sure that either we entered
- // all calendar fields, or we left them
- // all blank
- //-----------------------------------------
-
- $c_cnt = 0;
-
- foreach ( array('day','month','year') as $v )
- {
- if ( $this->request[ $v ] )
- {
- $c_cnt++;
- }
- }
-
- if( $c_cnt > 0 && $c_cnt < 2 )
- {
- $this->registry->getClass('output')->showError( 'member_bad_birthday', 10215 );
- }
- else if( $c_cnt > 0 )
- {
- //-----------------------------------------
- // Make sure it's a legal date
- //-----------------------------------------
-
- $_year = $this->request['year'] ? $this->request['year'] : 2000;
-
- if ( ! checkdate( $this->request['month'], $this->request['day'], $_year ) )
- {
- $this->registry->getClass('output')->showError( 'member_bad_birthday', 10216 );
- }
- }
-
- //-----------------------------------------
- // Start off our array
- //-----------------------------------------
-
- $core = array( 'bday_day' => $this->request['day'],
- 'bday_month' => $this->request['month'],
- 'bday_year' => $this->request['year'],
- );
-
- $extendedProfile = array( 'pp_setting_moderate_comments' => $pp_setting_moderate_comments,
- 'pp_setting_moderate_friends' => $pp_setting_moderate_friends,
- 'pp_setting_count_visitors' => $pp_setting_count_visitors,
- 'pp_setting_count_comments' => $pp_setting_count_comments,
- 'pp_setting_count_friends' => $pp_setting_count_friends );
-
- //-----------------------------------------
- // check to see if we can enter a member title
- // and if one is entered, update it.
- //-----------------------------------------
-
- if( isset( $this->request['member_title'] ) and ( $this->settings['post_titlechange'] ) and ( $this->memberData['posts'] >= $this->settings['post_titlechange']) )
- {
- $core['title'] = IPSText::getTextClass('bbcode')->stripBadWords( $this->request['member_title'] );
- }
-
- //-----------------------------------------
- // Custom profile field stuff
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
- $fields = new $classToLoad();
-
- $fields->member_data = $this->member->fetchMemberData();
- $fields->initData( 'edit' );
- /* Use $_POST and not ipsRegistry::$request as the custom profile field kernel class has its own cleaning routines for saving and showing
- which means we end up with double & -> & conversion (<, etc) */
- $fields->parseToSave( $_POST );
-
- if( $fields->error_messages )
- {
- return $fields->error_messages;
- }
-
- /* Check the website url field */
- $website_field = $fields->getFieldIDByKey( 'website' );
-
- if( $website_field && $fields->out_fields[ 'field_' . $website_field ] )
- {
- if( stristr( $fields->out_fields[ 'field_' . $website_field ], 'http://' ) === FALSE && stristr( $fields->out_fields[ 'field_' . $website_field ], 'https://' ) === FALSE )
- {
- $fields->out_fields[ 'field_' . $website_field ] = 'http://' . $fields->out_fields[ 'field_' . $website_field ];
- }
- }
-
- //-----------------------------------------
- // Check...
- //-----------------------------------------
-
- if ( count( $fields->error_fields['empty'] ) )
- {
- $this->registry->getClass('output')->showError( array( 'customfields_empty', $fields->error_fields['empty'][0]['pf_title'] ), 10217 );
- }
-
- if ( count( $fields->error_fields['invalid'] ) )
- {
- $this->registry->getClass('output')->showError( array( 'customfields_invalid', $fields->error_fields['invalid'][0]['pf_title'] ), 10218 );
- }
-
- if ( count( $fields->error_fields['toobig'] ) )
- {
- $this->registry->getClass('output')->showError( array( 'customfields_toobig', $fields->error_fields['toobig'][0]['pf_title'] ), 10219 );
- }
-
- /* About me */
- $extendedProfile['pp_about_me'] = $this->editor->process( $_POST['Post'] );
-
- /* Open ID & times*/
- $timeZone = IPSText::alphanumericalClean( $this->request['timeZone'], '+.' );
- $dst_correct = intval( $this->request['dst_correct'] );
-
- /* Add into array */
- $core['time_offset'] = $timeZone;
- $core['dst_in_use'] = $this->settings['time_dst_auto_correction'] ? ( ( $this->request['dstOption'] AND intval($this->request['dstCheck']) == 0 ) ? intval($this->request['dstOption']) : 0 ) : $this->memberData['dst_in_use'];
- $core['members_auto_dst'] = $this->settings['time_dst_auto_correction'] ? intval($this->request['dstCheck']) : $this->memberData['members_auto_dst'];
-
- //-----------------------------------------
- // Update the DB
- //-----------------------------------------
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => $core,
- 'customFields' => $fields->out_fields,
- 'extendedProfile' => $extendedProfile ) );
-
- //-----------------------------------------
- // Update birthdays cache if user set to today
- // or if birthday was today but isn't now
- //-----------------------------------------
-
- if( $core['bday_month'] == date('m') AND $core['bday_day'] == date('d') )
- {
- $this->cache->rebuildCache( 'birthdays', 'calendar' );
- }
- else if( $this->memberData['bday_month'] == date('m') AND $this->memberData['bday_day'] == date('d') AND ( $core['bday_month'] != date('m') OR $core['bday_day'] != date('d') ) )
- {
- $this->cache->rebuildCache( 'birthdays', 'calendar' );
- }
-
- return TRUE;
- }
-
- /**
- * UserCP Save Form: Notifications config
- *
- * @return boolean Successful
- */
- public function saveFormNotifications()
- {
- //-----------------------------------------
- // Notifications library
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
- $notifyLibrary = new $classToLoad( $this->registry );
- $notifyLibrary->setMember( $this->memberData );
-
- //-----------------------------------------
- // Show the form
- //-----------------------------------------
-
- $_basicOptions = array( array( 'email', $this->lang->words['notopt__email'] ), array( 'inline', $this->lang->words['notopt__inline'] ), array( 'mobile' => $this->lang->words['notopt__mobile'] ) );
- $_configOptions = $notifyLibrary->getNotificationData();
- $_notifyConfig = $notifyLibrary->getMemberNotificationConfig( $this->memberData );
- $_defaultConfig = $notifyLibrary->getDefaultNotificationConfig();
- $_saveConfig = array();
-
- foreach( $_configOptions as $option )
- {
- $_saveConfig[ $option['key'] ] = array();
- $_saveConfig[ $option['key'] ]['selected'] = array();
-
- //-----------------------------------------
- // Loop through and mark what we selected.
- // Do not allow changing of stuff from disable_override
- // and disabled, however
- //-----------------------------------------
-
- if( is_array($this->request['config_' . $option['key'] ]) AND count($this->request['config_' . $option['key'] ]) )
- {
- foreach( $this->request['config_' . $option['key'] ] as $_selected )
- {
- if( !is_array($_defaultConfig[ $option['key'] ]['disabled']) OR !in_array( $_selected, $_defaultConfig[ $option['key'] ]['disabled'] ) )
- {
- $_saveConfig[ $option['key'] ]['selected'][] = $_selected;
- }
- }
- }
-
- if( $_defaultConfig[ $option['key'] ]['disable_override'] )
- {
- $_saveConfig[ $option['key'] ]['selected'] = $_defaultConfig[ $option['key'] ]['selected'];
- }
- }
-
- //-----------------------------------------
- // Save
- //-----------------------------------------
-
- IPSMember::packMemberCache( $this->memberData['member_id'], array( 'notifications' => $_saveConfig, 'show_notification_popup' => intval($this->request['show_notification_popup']) ), $this->memberData['members_cache'] );
-
- //-----------------------------------------
- // Topic preferences
- //-----------------------------------------
-
- $_trackChoice = '';
-
- if ( $this->request['auto_track'] )
- {
- if ( in_array( $this->request['trackchoice'], array( 'none', 'immediate', 'offline', 'daily', 'weekly' ) ) )
- {
- $_trackChoice = $this->request['trackchoice'];
- }
- }
-
- //-----------------------------------------
- // Profile preferences
- //-----------------------------------------
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array(
- 'allow_admin_mails' => intval( $this->request['admin_send'] ),
- 'auto_track' => $_trackChoice
- ) ) );
-
- return TRUE;
- }
- /**
- * UserCP Save Form: Password
- *
- * @param array Array of member / core_sys_login information (if we're editing)
- * @return mixed Array of errors / boolean true
- */
- public function saveFormPassword( $member=array() )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $cur_pass = trim($this->request['current_pass']);
- $new_pass = trim($this->request['new_pass_1']);
- $chk_pass = trim($this->request['new_pass_2']);
- $isRemote = ( ! $this->memberData['bw_local_password_set'] AND $this->memberData['members_created_remote'] ) ? true : false;
-
- //-----------------------------------------
- // Checks...
- //-----------------------------------------
-
- if( $this->memberData['g_access_cp'] )
- {
- return array( 0 => $this->lang->words['admin_emailpassword'] );
- }
-
- if ( $isRemote === false AND ( ! $_POST['current_pass'] OR ( empty($new_pass) ) or ( empty($chk_pass) ) ) )
- {
- return array( 0 => $this->lang->words['complete_entire_form'] );
- }
-
- //-----------------------------------------
- // Do the passwords actually match?
- //-----------------------------------------
-
- if ( $new_pass != $chk_pass )
- {
- return array( 0 => $this->lang->words['passwords_not_matchy'] );
- }
-
- //-----------------------------------------
- // Check password...
- //-----------------------------------------
-
- if ( $isRemote === false )
- {
- if ( $this->_checkPassword( $cur_pass ) !== TRUE )
- {
- return array( 0 => $this->lang->words['current_pw_bad'] );
- }
- }
- else
- {
- /* This is INIT in _checkPassword */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
- }
-
- //-----------------------------------------
- // Create new password...
- //-----------------------------------------
-
- $md5_pass = md5($new_pass);
-
- //-----------------------------------------
- // han_login was loaded during check_password
- //-----------------------------------------
-
- $this->han_login->changePass( $this->memberData['email'], $md5_pass, $new_pass, $this->memberData );
-
- if ( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
- {
- return array( 0 => $this->lang->words['hanlogin_pw_failed'] );
- }
-
- //-----------------------------------------
- // Update the DB
- //-----------------------------------------
-
- IPSMember::updatePassword( $this->memberData['email'], $md5_pass );
-
- IPSLib::runMemberSync( 'onPassChange', $this->memberData['member_id'], $new_pass );
-
- //-----------------------------------------
- // Update members log in key...
- //-----------------------------------------
-
- $key = IPSMember::generateAutoLoginKey();
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'member_login_key' => $key, 'bw_local_password_set' => 1 ) ) );
-
- $this->ok_message = $this->lang->words['pw_change_successful'];
-
- return TRUE;
- }
-
- /**
- * UserCP Save Form: Display Name
- *
- * @return mixed Array of errors / boolean true
- */
- public function saveFormDisplayname()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $members_display_name = trim($this->request['displayName']);
- $password_check = trim( $this->request['displayPassword'] );
-
- //-----------------------------------------
- // Check for blanks...
- //-----------------------------------------
-
- if ( ! $members_display_name OR ( ! $this->_isFBUser AND ! $password_check ) )
- {
- return array( 0 => $this->lang->words['complete_entire_form'] );
- }
-
- //-----------------------------------------
- // Check password
- //-----------------------------------------
-
- if ( ! $this->_isFBUser )
- {
- if ( $this->_checkPassword( $password_check ) === FALSE )
- {
- return array( 0 => $this->lang->words['current_pw_bad'] );
- }
- }
-
- try
- {
- if ( IPSMember::getFunction()->updateName( $this->memberData['member_id'], $members_display_name, 'members_display_name' ) === TRUE )
- {
- $this->cache->rebuildCache( 'stats', 'global' );
-
- return $this->showFormDisplayname( '', $this->lang->words['dname_change_ok'] );
- }
- else
- {
- # We should absolutely never get here. So this is a fail-safe, really to
- # prevent a "false" positive outcome for the end-user
- return array( 0 => $this->lang->words['name_taken_change'] );
- }
- }
- catch( Exception $error )
- {
- switch( $error->getMessage() )
- {
- case 'NO_MORE_CHANGES':
- return array( 0 => $this->lang->words['name_change_no_more'] );
- break;
- case 'NO_USER':
- return array( 0 => $this->lang->words['name_change_noload'] );
- break;
- case 'NO_PERMISSION':
- return array( 0 => $this->lang->words['name_change_noperm'] );
- case 'NO_NAME':
- return array( 0 => sprintf( $this->lang->words['name_change_tooshort'], $this->settings['max_user_name_length'] ) );
- break;
- case 'TOO_LONG':
- return array( 0 => sprintf( $this->lang->words['name_change_tooshort'], $this->settings['max_user_name_length'] ) );
- break;
- case 'ILLEGAL_CHARS':
- return array( 0 => $this->lang->words['name_change_illegal'] );
- break;
- case 'USER_NAME_EXISTS':
- return array( 0 => $this->lang->words['name_change_taken'] );
- break;
- default:
- return array( 0 => $error->getMessage() );
- break;
- }
- }
-
- return TRUE;
- }
-
- /**
- * UserCP Save Form: Email Address
- *
- * @return mixed Array of errors / boolean true
- */
- public function saveFormEmailPassword()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $_emailOne = strtolower( trim($this->request['in_email_1']) );
- $_emailTwo = strtolower( trim($this->request['in_email_2']) );
- $cur_pass = trim($this->request['current_pass']);
- $new_pass = trim($this->request['new_pass_1']);
- $chk_pass = trim($this->request['new_pass_2']);
- $isRemote = ( ! $this->memberData['bw_local_password_set'] AND $this->memberData['members_created_remote'] ) ? true : false;
-
- if ( $_emailOne or $_emailTwo )
- {
- //-----------------------------------------
- // Do not allow validating members to change
- // email when admin validation is on
- // @see http://community.invisionpower.com/tracker/issue-19964-loophole-in-registration-procedure/
- //-----------------------------------------
-
- if( $this->memberData['member_group_id'] == $this->settings['auth_group'] AND in_array( $this->settings['reg_auth_type'], array( 'admin', 'admin_user' ) ) )
- {
- $this->registry->output->showError( $this->lang->words['admin_val_no_email_chg'], 10190 );
- }
-
- //-----------------------------------------
- // Check input
- //-----------------------------------------
-
- if( $this->memberData['g_access_cp'] )
- {
- return array( 0 => $this->lang->words['admin_emailpassword'] );
- }
-
- if ( ! $_POST['in_email_1'] OR ! $_POST['in_email_2'] )
- {
- return array( 0 => $this->lang->words['complete_entire_form'] );
- }
-
- //-----------------------------------------
- // Check password...
- //-----------------------------------------
-
- if ( ! $this->_isFBUser )
- {
- if ( $this->_checkPassword( $this->request['password'] ) === FALSE )
- {
- return array( 0 => $this->lang->words['current_pw_bad'] );
- }
- }
-
- //-----------------------------------------
- // Test email addresses
- //-----------------------------------------
-
- if ( $_emailOne != $_emailTwo )
- {
- return array( 0 => $this->lang->words['emails_no_matchy'] );
- }
-
- if ( IPSText::checkEmailAddress( $_emailOne ) !== TRUE )
- {
- return array( 0 => $this->lang->words['email_not_valid'] );
- }
-
- //-----------------------------------------
- // Is this email addy taken?
- //-----------------------------------------
-
- if ( IPSMember::checkByEmail( $_emailOne ) == TRUE )
- {
- return array( 0 => $this->lang->words['email_is_taken'] );
- }
-
- //-----------------------------------------
- // Load ban filters
- //-----------------------------------------
- $banfilters = array();
- $this->DB->build( array( 'select' => '*', 'from' => 'banfilters' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $banfilters[ $r['ban_type'] ][] = $r['ban_content'];
- }
-
- //-----------------------------------------
- // Check in banned list
- //-----------------------------------------
-
- if ( isset($banfilters['email']) AND is_array( $banfilters['email'] ) and count( $banfilters['email'] ) )
- {
- foreach ( $banfilters['email'] as $email )
- {
- $email = str_replace( '\*', '.*' , preg_quote($email, "/") );
-
- if ( preg_match( "/^{$email}$/i", $_emailOne ) )
- {
- return array( 0 => $this->lang->words['email_is_taken'] );
- }
- }
- }
-
- //-----------------------------------------
- // Load handler...
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
-
- if ( $this->han_login->emailExistsCheck( $_emailOne ) !== FALSE )
- {
- return array( 0 => $this->lang->words['email_is_taken'] );
- }
-
- $this->han_login->changeEmail( $this->memberData['email'], $_emailOne, $this->memberData );
-
- if ( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
- {
- return array( 0 => $this->lang->words['email_is_taken'] );
- }
-
- //-----------------------------------------
- // Want a new validation? NON ADMINS ONLY
- //-----------------------------------------
-
- if ( $this->settings['reg_auth_type'] AND !$this->memberData['g_access_cp'] )
- {
- //-----------------------------------------
- // Remove any existing entries
- //-----------------------------------------
-
- $_previous = $this->DB->buildAndFetch( array( 'select' => 'prev_email, real_group', 'from' => 'validating', 'where' => "member_id={$this->memberData['member_id']} AND email_chg=1" ) );
-
- if( $_previous['prev_email'] )
- {
- $this->DB->delete( 'validating', "member_id={$this->memberData['member_id']} AND email_chg=1" );
-
- $this->memberData['email'] = $_previous['prev_email'];
- $this->memberData['member_group_id'] = $_previous['real_group'];
- }
-
- $validate_key = md5( IPSMember::makePassword() . time() );
-
- //-----------------------------------------
- // Update the new email, but enter a validation key
- // and put the member in "awaiting authorisation"
- // and send an email..
- //-----------------------------------------
-
- $db_str = array(
- 'vid' => $validate_key,
- 'member_id' => $this->memberData['member_id'],
- 'temp_group' => $this->settings['auth_group'],
- 'entry_date' => time(),
- 'coppa_user' => 0,
- 'email_chg' => 1,
- 'ip_address' => $this->member->ip_address,
- 'prev_email' => $this->memberData['email'],
- );
-
- if ( $this->memberData['member_group_id'] != $this->settings['auth_group'] )
- {
- $db_str['real_group'] = $this->memberData['member_group_id'];
- }
-
- $this->DB->insert( 'validating', $db_str );
-
- IPSLib::runMemberSync( 'onEmailChange', $this->memberData['member_id'], strtolower( $_emailOne ), $this->memberData['email'] );
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'member_group_id' => $this->settings['auth_group'],
- 'email' => $_emailOne ) ) );
-
- //-----------------------------------------
- // Update their session with the new member group
- //-----------------------------------------
-
- if ( $this->member->session_id )
- {
- $this->member->sessionClass()->convertMemberToGuest();
- }
-
- //-----------------------------------------
- // Kill the cookies to stop auto log in
- //-----------------------------------------
-
- IPSCookie::set( 'pass_hash' , '-1', 0 );
- IPSCookie::set( 'member_id' , '-1', 0 );
- IPSCookie::set( 'session_id' , '-1', 0 );
-
- //-----------------------------------------
- // Dispatch the mail, and return to the activate form.
- //-----------------------------------------
-
- IPSText::getTextClass( 'email' )->getTemplate("newemail");
-
- IPSText::getTextClass( 'email' )->buildMessage( array(
- 'NAME' => $this->memberData['members_display_name'],
- 'THE_LINK' => $this->settings['base_url']."app=core&module=global§ion=register&do=auto_validate&type=newemail&uid=".$this->memberData['member_id']."&aid=".$validate_key,
- 'ID' => $this->memberData['member_id'],
- 'MAN_LINK' => $this->settings['base_url']."app=core&module=global§ion=register&do=07",
- 'CODE' => $validate_key,
- ) );
-
- IPSText::getTextClass( 'email' )->subject = $this->lang->words['lp_subject'].' '.$this->settings['board_name'];
- IPSText::getTextClass( 'email' )->to = $_emailOne;
-
- IPSText::getTextClass( 'email' )->sendMail();
-
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=global§ion=register&do=07' );
- }
- else
- {
- //-----------------------------------------
- // No authorisation needed, change email addy and return
- //-----------------------------------------
-
- IPSLib::runMemberSync( 'onEmailChange', $this->memberData['member_id'], strtolower( $_emailOne ), $this->memberData['email'] );
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'email' => $_emailOne ) ) );
-
- //-----------------------------------------
- // Add to OK message
- //-----------------------------------------
-
- $this->ok_message = $this->lang->words['ok_email_changed'];
- }
- }
- else if ( $cur_pass OR $new_pass )
- {
- if( $this->memberData['g_access_cp'] )
- {
- return array( 0 => $this->lang->words['admin_emailpassword'] );
- }
-
- if ( $isRemote === false AND ( ! $_POST['current_pass'] OR ( empty($new_pass) ) or ( empty($chk_pass) ) ) )
- {
- return array( 0 => $this->lang->words['complete_entire_form'] );
- }
-
- //-----------------------------------------
- // Do the passwords actually match?
- //-----------------------------------------
-
- if ( $new_pass != $chk_pass )
- {
- return array( 0 => $this->lang->words['passwords_not_matchy'] );
- }
-
- //-----------------------------------------
- // Check password...
- //-----------------------------------------
-
- if ( $isRemote === false )
- {
- if ( $this->_checkPassword( $cur_pass ) !== TRUE )
- {
- return array( 0 => $this->lang->words['current_pw_bad'] );
- }
- }
- else
- {
- /* This is INIT in _checkPassword */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
- }
-
- //-----------------------------------------
- // Create new password...
- //-----------------------------------------
-
- $md5_pass = md5($new_pass);
-
- //-----------------------------------------
- // han_login was loaded during check_password
- //-----------------------------------------
-
- $this->han_login->changePass( $this->memberData['email'], $md5_pass, $new_pass, $this->memberData );
-
- if ( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
- {
- return array( 0 => $this->lang->words['hanlogin_pw_failed'] );
- }
-
- //-----------------------------------------
- // Update the DB
- //-----------------------------------------
-
- IPSMember::updatePassword( $this->memberData['email'], $md5_pass );
-
- IPSLib::runMemberSync( 'onPassChange', $this->memberData['member_id'], $new_pass );
-
- //-----------------------------------------
- // Update members log in key...
- //-----------------------------------------
-
- $key = IPSMember::generateAutoLoginKey();
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'member_login_key' => $key, 'bw_local_password_set' => 1 ) ) );
-
- $this->ok_message = $this->lang->words['pw_change_successful'];
- }
-
- return TRUE;
- }
-
- /**
- * Password check
- *
- * @param string Plain Text Password
- * @return boolean Password matched or not
- */
- protected function _checkPassword( $password_check )
- {
- //-----------------------------------------
- // Ok, check password first
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
-
- //-----------------------------------------
- // Is this a username or email address?
- //-----------------------------------------
-
- $this->han_login->loginPasswordCheck( $this->memberData['name'], $this->memberData['email'], $password_check );
-
- if ( $this->han_login->return_code == 'SUCCESS' )
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Core user control panel plugin
+ * Last Updated: $Date: 2013-05-02 17:05:35 -0400 (Thu, 02 May 2013) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 20th February 2002
+ * @version $Rev: 12216 $
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class usercpForms_core extends public_core_usercp_manualResolver implements interface_usercp
+{
+ /**
+ * Tab name
+ * This can be left blank and the application title will
+ * be used
+ *
+ * @var string
+ */
+ public $tab_name = "Настройки";
+
+ /**
+ * Default area code
+ *
+ * @var string
+ */
+ public $defaultAreaCode = 'profileinfo';
+
+ /**
+ * OK Message
+ * This is an optional message to return back to the framework
+ * to replace the standard 'Settings saved' message
+ *
+ * @var string
+ */
+ public $ok_message = '';
+
+ /**
+ * Hide 'save' button and form elements
+ * Useful if you have custom output that doesn't
+ * need to use it
+ *
+ * @var bool
+ */
+ public $hide_form_and_save_button = false;
+
+ /**
+ * If you wish to allow uploads, set a value for this
+ *
+ * @var integer
+ */
+ public $uploadFormMax = 0;
+
+ /**
+ * Flag to indicate that the user is a facebook logged in user doozer
+ *
+ * @var boolean
+ */
+ protected $_isFBUser = false;
+
+ /**
+ * Flag to indicate compatibility
+ *
+ * @var int
+ */
+ public $version = 32;
+
+ /**
+ * Initiate this module
+ *
+ * @return @e void
+ */
+ public function init( )
+ {
+ $this->tab_name = ipsRegistry::getClass('class_localization')->words['tab__core'];
+
+ /* Facebook? */
+ if ( IPSLib::fbc_enabled() === TRUE AND $this->memberData['fb_uid'] )
+ {
+ $this->_isFBUser = true;
+ }
+
+ if( !$this->memberData['g_edit_profile'] )
+ {
+ $this->defaultAreaCode = 'email';
+ }
+ }
+
+ /**
+ * Return links for this tab
+ * You may return an empty array or FALSE to not have
+ * any links show in the tab.
+ *
+ * The links must have 'area=xxxxx'. The rest of the URL
+ * is added automatically.
+ * 'area' can only be a-z A-Z 0-9 - _
+ *
+ * @author Matt Mecham
+ * @return array Links
+ */
+ public function getLinks()
+ {
+ ipsRegistry::instance()->getClass('class_localization')->loadLanguageFile( array( 'public_usercp' ), 'core' );
+
+ $array = array();
+
+ if( $this->memberData['g_edit_profile'] )
+ {
+ $array[] = array( 'url' => 'area=profileinfo',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['change_settings'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'profileinfo' ? 1 : 0,
+ 'area' => 'profileinfo'
+ );
+ }
+
+ if ( $this->memberData['gbw_allow_customization'] AND ! $this->memberData['bw_disable_customization'] )
+ {
+ $array[] = array( 'url' => 'area=customize',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_customize'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'customize' ? 1 : 0,
+ 'area' => 'customize'
+ );
+ }
+
+ $array[] = array( 'url' => 'area=email',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_email_pass_change'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'email' ? 1 : 0,
+ 'area' => 'email'
+ );
+
+ if ( $this->settings['auth_allow_dnames'] == 1 AND $this->memberData['g_dname_changes'] != 0 )
+ {
+ $array[] = array( 'url' => 'area=displayname',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['ucp_change_name'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'displayname' ? 1 : 0,
+ 'area' => 'displayname'
+ );
+ }
+
+ $sig_restrictions = explode( ':', $this->memberData['g_signature_limits'] );
+
+ if ( ( ! $sig_restrictions[0] OR ( $sig_restrictions[0] AND $this->memberData['g_sig_unit'] ) ) AND $this->memberData['g_edit_profile'] )
+ {
+ $array[] = array( 'url' => 'area=signature',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_sig_info'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'signature' ? 1 : 0,
+ 'area' => 'signature'
+ );
+ }
+
+ $array[] = array( 'url' => 'area=ignoredusers',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_ignore_users'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'ignoredusers' ? 1 : 0,
+ 'area' => 'ignoredusers'
+ );
+
+ if ( IPSLib::fbc_enabled() === TRUE )
+ {
+ $array[] = array( 'url' => 'area=facebook',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_facebook'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'facebook' ? 1 : 0,
+ 'area' => 'facebook'
+ );
+ }
+
+ if ( IPSLib::twitter_enabled() === TRUE )
+ {
+ $array[] = array( 'url' => 'area=twitter',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_twitter'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'twitter' ? 1 : 0,
+ 'area' => 'twitter'
+ );
+ }
+
+ if ( IPSLib::vkontakte_enabled() === TRUE )
+ {
+ $array[] = array( 'url' => 'area=vkontakte',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_vkontakte'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'vkontakte' ? 1 : 0,
+ 'area' => 'vkontakte'
+ );
+ }
+
+ if ( $this->memberData['g_attach_max'] != -1 )
+ {
+ $array[] = array(
+ 'url' => 'area=attachments',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_attach'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'attachments' ? 1 : 0,
+ 'area' => 'attachments'
+ );
+ }
+
+ $array[] = array( 'url' => 'area=notifications',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_notifications'],
+ 'active' => $this->request['tab'] == 'core' && $this->request['area'] == 'notifications' ? 1 : 0,
+ 'area' => 'notifications'
+ );
+
+ $array[] = array( 'url' => 'area=notificationlog',
+ 'title' => ipsRegistry::instance()->getClass('class_localization')->words['m_arch_notify'],
+ 'active' => ( in_array( $this->request['area'], array( 'notificationlog', 'viewNotification', 'removeNotifications' ) ) ) ? 1 : 0,
+ 'area' => 'notificationlog'
+ );
+
+ return $array;
+ }
+
+
+ /**
+ * Run custom event
+ *
+ * If you pass a 'do' in the URL / post form that is not either:
+ * save / save_form or show / show_form then this function is loaded
+ * instead. You can return a HTML chunk to be used in the UserCP (the
+ * tabs and footer are auto loaded) or redirect to a link.
+ *
+ * If you are returning HTML, you can use $this->hide_form_and_save_button = 1;
+ * to remove the form and save button that is automatically placed there.
+ *
+ * @author Matt Mecham
+ * @param string Current area
+ * @return mixed html or void
+ */
+ public function runCustomEvent( $currentArea )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $html = '';
+
+ //-----------------------------------------
+ // What to do?
+ //-----------------------------------------
+
+ switch( $currentArea )
+ {
+ case 'removeIgnoredUser':
+ return $this->customEvent_removeIgnoredUser();
+ break;
+ case 'toggleIgnoredUser':
+ return $this->customEvent_toggleIgnoredUser();
+ break;
+ case 'facebookSync':
+ $html = $this->customEvent_facebookSync();
+ break;
+ case 'facebookRemove':
+ $html = $this->customEvent_facebookRemove();
+ break;
+ case 'vkontakteRemove':
+ $html = $this->customEvent_vkontakteRemove();
+ break;
+ case 'twitterRemove':
+ $html = $this->customEvent_twitterRemove();
+ break;
+ case 'facebookLink':
+ $html = $this->customEvent_facebookLink();
+ break;
+ case 'updateAttachments':
+ return $this->customEvent_updateAttachments();
+ break;
+
+ case 'viewNotification':
+ $html = $this->customEvent_viewNotification();
+ break;
+
+ case 'markNotification':
+ return $this->customEvent_markNotification();
+ break;
+
+ case 'removeNotifications':
+ return $this->customEvent_removeNotifications();
+ break;
+ }
+
+ //-----------------------------------------
+ // Turn off save button
+ //-----------------------------------------
+
+ $this->hide_form_and_save_button = 1;
+
+ //-----------------------------------------
+ // Return
+ //-----------------------------------------
+
+ return $html;
+ }
+
+ /**
+ * Delete attachments
+ *
+ * @author Matt Mecham
+ * @return string Processed HTML
+ */
+ public function customEvent_updateAttachments()
+ {
+ //-----------------------------------------
+ // Get the ID's to delete
+ //-----------------------------------------
+
+ $finalIDs = array();
+
+ //-----------------------------------------
+ // Grab post IDs
+ //-----------------------------------------
+
+ if ( is_array( $_POST['attach'] ) and count( $_POST['attach'] ) )
+ {
+ foreach( $_POST['attach'] as $id => $value )
+ {
+ $finalIDs[ $id ] = intval( $id );
+ }
+ }
+
+ if ( count($finalIDs) > 0 )
+ {
+ $this->DB->build( array( 'select' => 'a.*',
+ 'from' => array( 'attachments' => 'a' ),
+ 'where' => "a.attach_id IN (" . implode( ",", $finalIDs ) .") AND a.attach_rel_module IN( 'post', 'msg' ) AND attach_member_id=" . $this->memberData['member_id'],
+ 'add_join' => array(
+ array( 'select' => 'p.topic_id, p.pid',
+ 'from' => array( 'posts' => 'p' ),
+ 'where' => "p.pid=a.attach_rel_id AND a.attach_rel_module='post'",
+ 'type' => 'left'
+ ),
+ array( 'select' => 'mt.msg_id, mt.msg_topic_id',
+ 'from' => array( 'message_posts' => 'mt' ),
+ 'where' => "mt.msg_id=a.attach_rel_id AND a.attach_rel_module='msg'",
+ 'type' => 'left'
+ ),
+ )
+ ) );
+
+ $o = $this->DB->execute();
+
+ while ( $killmeh = $this->DB->fetch( $o ) )
+ {
+ if ( $killmeh['attach_location'] )
+ {
+ @unlink( $this->settings['upload_dir']."/".$killmeh['attach_location'] );
+ }
+ if ( $killmeh['attach_thumb_location'] )
+ {
+ @unlink( $this->settings['upload_dir']."/".$killmeh['attach_thumb_location'] );
+ }
+
+ if ( $killmeh['topic_id'] )
+ {
+ $this->DB->update( 'topics', 'topic_hasattach=topic_hasattach-1', 'tid='.$killmeh['topic_id'], true, true );
+ }
+ else if( $killmeh['msg_id'] )
+ {
+ $this->DB->update( 'message_topics', 'mt_hasattach=mt_hasattach-1', 'mt_id='.$killmeh['msg_topic_id'], true, true );
+ }
+ }
+
+ $this->DB->delete( 'attachments', 'attach_id IN ('.implode(",",$finalIDs).') and attach_member_id='.$this->memberData['member_id'] );
+ }
+
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=attachments&do=show" );
+ }
+
+ /**
+ * UserCP handle our notifications
+ *
+ * @return boolean Successful
+ */
+ public function customEvent_removeNotifications()
+ {
+ //-----------------------------------------
+ // Check form hash
+ //-----------------------------------------
+
+ $this->request['secure_key'] = $this->request['secure_key'] ? $this->request['secure_key'] : $this->request['md5check'];
+
+ if( $this->request['secure_key'] != $this->member->form_hash )
+ {
+ $this->registry->output->showError( 'usercp_forums_bad_key', 1021523 );
+ }
+
+ //-----------------------------------------
+ // Notifications library
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
+ $notifyLibrary = new $classToLoad( $this->registry );
+ $notifyLibrary->setMember( $this->memberData );
+
+ //-----------------------------------------
+ // Delete the notifications
+ //-----------------------------------------
+
+ $_toDelete = IPSLib::cleanIntArray( $this->request['notifications'] );
+
+ if( !count($_toDelete) )
+ {
+ return $this->showInlineNotifications( $this->lang->words['no_notify_del'] );
+ }
+
+ $this->DB->delete( 'inline_notifications', "notify_id IN(" . implode( ',', $_toDelete ) . ") AND notify_to_id=" . $this->memberData['member_id'] );
+
+ //-----------------------------------------
+ // If member has 'unread' count, rebuild count
+ //-----------------------------------------
+
+ if( $this->memberData['notification_cnt'] )
+ {
+ $notifyLibrary->rebuildUnreadCount();
+ }
+
+ //-----------------------------------------
+ // Redirect
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=notificationlog&confirm=1" );
+ }
+
+ /**
+ * Mark a notification
+ *
+ * @return string HTML
+ */
+ public function customEvent_markNotification()
+ {
+ //-----------------------------------------
+ // Notifications library
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
+ $notifyLibrary = new $classToLoad( $this->registry );
+ $notifyLibrary->setMember( $this->memberData );
+
+ //-----------------------------------------
+ // Get notification
+ //-----------------------------------------
+
+ /* Marking them all as read? */
+ if ( $this->request['mark'] == 'all' )
+ {
+ $this->DB->update( 'inline_notifications', array( 'notify_read' => time() ), 'notify_to_id=' . $this->memberData['member_id'] );
+ }
+ else
+ {
+ $id = intval($this->request['mark']);
+ $notification = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'inline_notifications', 'where' => 'notify_id=' . $id ) );
+
+ //-----------------------------------------
+ // Error checking
+ //-----------------------------------------
+
+ if( !$notification['notify_id'] )
+ {
+ if( $this->request['ajax'] )
+ {
+ print 'ok';
+ exit;
+ }
+ else
+ {
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . "app=core&module=usercp&tab=core&area=notificationlog" );
+ }
+ }
+
+ if( $notification['notify_to_id'] != $this->memberData['member_id'] )
+ {
+ if( $this->request['ajax'] )
+ {
+ print 'ok';
+ exit;
+ }
+ else
+ {
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . "app=core&module=usercp&tab=core&area=notificationlog" );
+ }
+ }
+
+ //-----------------------------------------
+ // Update read timestamp
+ //-----------------------------------------
+
+ $this->DB->update( 'inline_notifications', array( 'notify_read' => time() ), 'notify_id=' . $id );
+ }
+
+ //-----------------------------------------
+ // If member has 'unread' count, rebuild count
+ //-----------------------------------------
+
+ if( $this->memberData['notification_cnt'] )
+ {
+ $notifyLibrary->rebuildUnreadCount();
+ }
+
+ if( $this->request['ajax'] )
+ {
+ print 'ok';
+ exit;
+ }
+ else
+ {
+ $this->registry->output->silentRedirect( $this->settings['base_url'] . "app=core&module=usercp&tab=core&area=notificationlog" );
+ }
+ }
+
+ /**
+ * View a notification
+ *
+ * @return string HTML
+ */
+ public function customEvent_viewNotification()
+ {
+ //-----------------------------------------
+ // Notifications library
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
+ $notifyLibrary = new $classToLoad( $this->registry );
+ $notifyLibrary->setMember( $this->memberData );
+
+ //-----------------------------------------
+ // Get notification
+ //-----------------------------------------
+
+ $id = intval($this->request['view']);
+ $notification = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'inline_notifications', 'where' => 'notify_id=' . $id ) );
+
+ //-----------------------------------------
+ // Error checking
+ //-----------------------------------------
+
+ if( !$notification['notify_id'] )
+ {
+ $this->registry->output->showError( 'bad_notify_id', 10191 );
+ }
+
+ if( $notification['notify_to_id'] != $this->memberData['member_id'] )
+ {
+ $this->registry->output->showError( 'bad_notify_id', 10192 );
+ }
+
+ //-----------------------------------------
+ // Update read timestamp
+ //-----------------------------------------
+
+ $this->DB->update( 'inline_notifications', array( 'notify_read' => time() ), 'notify_id=' . $id );
+
+ //-----------------------------------------
+ // If member has 'unread' count, rebuild count
+ //-----------------------------------------
+
+ if( $this->memberData['notification_cnt'] )
+ {
+ $notifyLibrary->rebuildUnreadCount();
+ }
+
+ //-----------------------------------------
+ // Parse for display
+ //-----------------------------------------
+
+ /* As the email template parser makes an attempt to reparse 'safe' HTML, we need to make it safe here */
+ $notification['notify_text'] = IPSText::htmlspecialchars( $notification['notify_text'] );
+
+ IPSText::getTextClass('bbcode')->parse_smilies = 1;
+ IPSText::getTextClass('bbcode')->parse_nl2br = 1;
+ IPSText::getTextClass('bbcode')->parse_html = 0;
+ IPSText::getTextClass('bbcode')->parse_bbcode = 1;
+ IPSText::getTextClass('bbcode')->parsing_section = 'global';
+
+ $notification['notify_text'] = IPSText::getTextClass('bbcode')->preDisplayParse( nl2br( $notification['notify_text'] ) );
+
+ //-----------------------------------------
+ // Show notification
+ //-----------------------------------------
+
+ $this->_nav[] = array( $this->lang->words['m_arch_notify'], 'app=core&module=usercp&tab=core&area=notificationlog' );
+ return $this->registry->getClass('output')->getTemplate('ucp')->showNotification( $notification );
+ }
+
+ /**
+ * Custom Event: Remove Twitter link
+ *
+ * @return @e void
+ */
+ public function customEvent_twitterRemove()
+ {
+ //-----------------------------------------
+ // Check secure hash...
+ //-----------------------------------------
+
+ if ( $this->request['secure_key'] != $this->member->form_hash )
+ {
+ $this->registry->output->showError( 'authorization_error', 100, true, null, 403 );
+ }
+
+ //-----------------------------------------
+ // Okay...
+ //-----------------------------------------
+
+ if ( $this->memberData['twitter_id'] )
+ {
+ /* Remove the link */
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'twitter_id' => 0, 'twitter_token' => '', 'twitter_secret' => '' ) ) );
+ }
+
+ /* Log the user out */
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=global§ion=login&do=logout&k=" . $this->member->form_hash );
+ }
+
+ /**
+ * Custom Event: Remove vk link
+ *
+ * @return @e void
+ */
+ public function customEvent_vkontakteRemove()
+ {
+ //-----------------------------------------
+ // Check secure hash...
+ //-----------------------------------------
+
+ if ( $this->request['secure_key'] != $this->member->form_hash )
+ {
+ $this->registry->output->showError( 'authorization_error', 100, true, null, 403 );
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/vkontakte/connect.php', 'vkontakte_connect' );
+ $vkontakte = new $classToLoad( $this->registry );
+
+ //-----------------------------------------
+ // Okay...
+ //-----------------------------------------
+
+ if ( $this->memberData['vk_uid'] )
+ {
+ /* Remove the link */
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'vk_uid' => 0, 'vk_token' => '' ) ) );
+ }
+
+ /* Log the user out */
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=global§ion=login&do=logout&k=" . $this->member->form_hash );
+ }
+
+ /**
+ * Custom Event: Create facebook link
+ *
+ * @return @e void
+ */
+ public function customEvent_facebookLink()
+ {
+ //-----------------------------------------
+ // Check secure hash...
+ //-----------------------------------------
+
+ if ( $this->request['secure_key'] != $this->member->form_hash )
+ {
+ $this->registry->output->showError( 'authorization_error', 100, true, null, 403 );
+ }
+
+ /* Load application */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
+ $facebook = new $classToLoad( $this->registry );
+
+ try
+ {
+ $facebook->linkMember( $this->memberData['member_id'] );
+ }
+ catch( Exception $error )
+ {
+ $msg = $error->getMessage();
+
+ switch( $msg )
+ {
+ default:
+ case 'NO_FACEBOOK_USER_LOGGED_IN':
+ case 'ALREADY_LINKED':
+ $this->registry->getClass('output')->showError( 'fbc_authorization_screwup', 1005.99, null, null, 403 );
+ break;
+ }
+ }
+
+ //-----------------------------------------
+ // Return
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=facebook&do=show" );
+ }
+
+ /**
+ * Custom Event: Remove facebook link
+ *
+ * @return @e void
+ */
+ public function customEvent_facebookRemove()
+ {
+ //-----------------------------------------
+ // Check secure hash...
+ //-----------------------------------------
+
+ if ( $this->request['secure_key'] != $this->member->form_hash )
+ {
+ $this->registry->output->showError( 'authorization_error', 100, true, null, 403 );
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
+ $facebook = new $classToLoad( $this->registry );
+
+ //-----------------------------------------
+ // Okay...
+ //-----------------------------------------
+
+ if ( $this->memberData['fb_uid'] )
+ {
+ /* Unauthorize application */
+ $facebook->revokeAuthorization();
+
+ /* Remove the link */
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'fb_uid' => 0, 'fb_emailhash' => '', 'fb_token' => '', 'fb_lastsync' => 0 ) ) );
+ }
+
+ /* Log the user out */
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=global§ion=login&do=logout&k=" . $this->member->form_hash );
+ }
+
+ /**
+ * Custom Event: Sync up facebook
+ * NO LONGER USED. LEFT FOR FIX CONFIRMATION
+ *
+ * @return @e void
+ */
+ public function customEvent_facebookSync()
+ {
+ if ( IPSLib::fbc_enabled() === TRUE )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
+ $facebook = new $classToLoad( $this->registry );
+
+ try
+ {
+ $facebook->syncMember( $this->memberData );
+ }
+ catch( Exception $error )
+ {
+ $msg = $error->getMessage();
+
+ switch( $msg )
+ {
+ case 'NOT_LINKED':
+ case 'NO_MEMBER':
+ default:
+ $this->registry->getClass('output')->showError( 'fbc_authorization_screwup', 1005, null, null, 403 );
+ break;
+ }
+ }
+
+ //-----------------------------------------
+ // Return
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=facebook&do=show" );
+ }
+ }
+
+ /**
+ * Custom Event: Run the find user tool
+ *
+ * @return @e void
+ */
+ public function customEvent_toggleIgnoredUser()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $member_id = intval( $this->request['id'] );
+ $field = $this->request['field'];
+ $update = array();
+
+ //-----------------------------------------
+ // Grab user
+ //-----------------------------------------
+
+ $ignoredUser = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'ignored_users',
+ 'where' => 'ignore_ignore_id=' . $member_id . ' AND ignore_owner_id=' . $this->memberData['member_id'] ) );
+
+ if ( $ignoredUser['ignore_id'] )
+ {
+ switch( $field )
+ {
+ default:
+ case 'topics':
+ $update = array( 'ignore_topics' => ( $ignoredUser['ignore_topics'] == 1 ) ? 0 : 1 );
+ break;
+ case 'messages':
+ $update = array( 'ignore_messages' => ( $ignoredUser['ignore_messages'] == 1 ) ? 0 : 1 );
+ break;
+ case 'signatures':
+ $update = array( 'ignore_signatures' => ( $ignoredUser['ignore_signatures'] == 1 ) ? 0 : 1 );
+ break;
+ case 'chats':
+ $update = array( 'ignore_chats' => ( $ignoredUser['ignore_chats'] == 1 ) ? 0 : 1 );
+ break;
+ }
+
+ //-----------------------------------------
+ // Update
+ //-----------------------------------------
+
+ $this->DB->update( 'ignored_users', $update, 'ignore_id=' . $ignoredUser['ignore_id'] );
+
+ /* Rebuild cache */
+ IPSMember::rebuildIgnoredUsersCache( $this->memberData );
+ }
+
+ //-----------------------------------------
+ // Return
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=ignoredusers&do=show&st={$this->request['st']}" );
+ }
+
+ /**
+ * Custom event: Remove ignored user
+ *
+ * @author Matt Mecham
+ * @return string Processed HTML
+ */
+ public function customEvent_removeIgnoredUser()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $removeID = intval( $this->request['id'] );
+
+ $this->DB->delete( 'ignored_users', 'ignore_owner_id=' . $this->memberData['member_id'] . ' AND ignore_ignore_id=' . $removeID );
+
+ /* Rebuild cache */
+ IPSMember::rebuildIgnoredUsersCache( $this->memberData );
+
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=usercp&tab=core&area=ignoredusers&do=show" );
+ }
+
+ /**
+ * UserCP Form Show
+ *
+ * @author Matt Mecham
+ * @param string Current area as defined by 'get_links'
+ * @param array Array of errors
+ * @return string Processed HTML
+ */
+ public function showForm( $current_area, $errors=array() )
+ {
+ //-----------------------------------------
+ // Where to go, what to see?
+ //-----------------------------------------
+
+ if( !$current_area AND !$this->memberData['g_edit_profile'] )
+ {
+ $current_area = 'email';
+ }
+
+ switch( $current_area )
+ {
+ default:
+ case 'profileinfo':
+ return $this->formProfileInfo();
+ break;
+ case 'signature':
+ return $this->formSignature();
+ break;
+ case 'photo':
+ return $this->formPhoto();
+ break;
+ case 'ignoredusers':
+ return $this->formIgnoredUsers();
+ break;
+ case 'facebook':
+ return $this->formFacebook();
+ break;
+ case 'twitter':
+ return $this->formTwitter();
+ break;
+ case 'vkontakte':
+ return $this->formVkontakte();
+ break;
+ case 'customize':
+ return $this->formCustomize();
+ break;
+ case 'email':
+ return $this->showFormEmailPassword();
+ break;
+ case 'displayname':
+ return $this->showFormDisplayname();
+ break;
+ case 'attachments':
+ return $this->showFormAttachments();
+ break;
+ case 'notifications':
+ return $this->showFormNotifications();
+ break;
+ case 'notificationlog':
+ return $this->showInlineNotifications();
+ break;
+ }
+ }
+
+ /**
+ * Show the customization form
+ *
+ * @author Matt Mecham
+ * @param string Any inline message to show
+ * @return string Processed HTML
+ */
+ public function formCustomize( $inlineMsg='' )
+ {
+ /* Allow uploads */
+ $this->uploadFormMax = 10000 * 1024;
+
+ if ( ! $this->memberData['gbw_allow_customization'] OR $this->memberData['bw_disable_customization'] )
+ {
+ $this->registry->getClass('output')->showError( 'no_permission', 1005.5 );
+ }
+
+ /* Grab current options */
+ $options = IPSLib::safeUnserialize( $this->memberData['pp_customization'] );
+ $options = is_array( $options ) ? $options : array();
+
+ /* Build input */
+ foreach( $options as $k => $v )
+ {
+ $input[ $k ] = ( $this->request[ $k ] ) ? $this->request[ $k ] : $v;
+ }
+
+ /* Figure out preview URL */
+ if ( $options['type'] == 'url' AND $options['bg_url'] )
+ {
+ $input['_preview'] = $options['bg_url'];
+ }
+ else if ( $options['type'] == 'upload' AND $options['bg_url'] )
+ {
+ $input['_preview'] = $this->settings['upload_url'] . '/' . $options['bg_url'];
+ $input['bg_url'] = '';
+ }
+
+ /* Show form */
+ return $this->registry->getClass('output')->getTemplate('ucp')->membersProfileCustomize( $options, $input, $inlineMsg );
+ }
+
+ /**
+ * Show the vkontakte form
+ *
+ * @author Matt Mecham
+ * @param string Any inline message to show
+ * @return string Processed HTML
+ */
+ public function formVkontakte( $inlineMsg='' )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ if( !IPSLib::vkontakte_enabled() )
+ {
+ $this->registry->getClass('output')->showError( 'twitter_disabled', 1005.1 );
+ }
+
+ //-----------------------------------------
+ // Twitter user logged in?
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/vkontakte/connect.php', 'vkontakte_connect' );
+ $vkontakte = new $classToLoad( $this->registry, $this->memberData['vk_token'], $this->memberData['vk_uid'] );
+
+ //-----------------------------------------
+ // Thaw bitfield options
+ //-----------------------------------------
+
+ $bwOptions = IPSBWOptions::thaw( $this->memberData['vk_bwoptions'], 'vkontakte' );
+
+ //-----------------------------------------
+ // Merge..
+ //-----------------------------------------
+
+ if ( is_array( $bwOptions ) )
+ {
+ foreach( $bwOptions as $k => $v )
+ {
+ $this->memberData[ $k ] = $v;
+ }
+ }
+
+ $this->hide_form_and_save_button = 1;
+
+ $userData = $vkontakte->fetchUserData();
+
+ if ( isset( $userData['status']['text'] ) )
+ {
+ if ( IPS_DOC_CHAR_SET != 'UTF-8' )
+ {
+ $userData['status']['text'] = IPSText::utf8ToEntities( $userData['status']['text'] );
+ }
+ }
+
+ return $this->registry->getClass('output')->getTemplate('vkontakte')->membersVkontakteConnect( $this->memberData['vk_uid'], $userData );
+ }
+
+ /**
+ * Show the twitter form
+ *
+ * @author Matt Mecham
+ * @param string Any inline message to show
+ * @return string Processed HTML
+ */
+ public function formTwitter( $inlineMsg='' )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ if( !IPSLib::twitter_enabled() )
+ {
+ $this->registry->getClass('output')->showError( 'twitter_disabled', 1005.1 );
+ }
+
+ //-----------------------------------------
+ // Twitter user logged in?
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
+ $twitter = new $classToLoad( $this->registry, $this->memberData['twitter_token'], $this->memberData['twitter_secret'] );
+
+ //-----------------------------------------
+ // Thaw bitfield options
+ //-----------------------------------------
+
+ $bwOptions = IPSBWOptions::thaw( $this->memberData['tc_bwoptions'], 'twitter' );
+
+ //-----------------------------------------
+ // Merge..
+ //-----------------------------------------
+
+ if ( is_array( $bwOptions ) )
+ {
+ foreach( $bwOptions as $k => $v )
+ {
+ $this->memberData[ $k ] = $v;
+ }
+ }
+
+ if( ! $twitter->isConnected() )
+ {
+ $this->hide_form_and_save_button = 1;
+ }
+
+ $userData = $twitter->fetchUserData();
+
+ if ( isset( $userData['status']['text'] ) )
+ {
+ if ( IPS_DOC_CHAR_SET != 'UTF-8' )
+ {
+ $userData['status']['text'] = IPSText::utf8ToEntities( $userData['status']['text'] );
+ }
+
+ /* Make safe */
+ $userData['status']['text'] = str_replace( array( '<', '>' ), array( '<', '>' ), $userData['status']['text'] );
+ }
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->membersTwitterConnect( $twitter->isConnected(), $userData );
+ }
+
+
+ /**
+ * Show the member form
+ *
+ * @author Matt Mecham
+ * @param string Any inline message to show
+ * @return string Processed HTML
+ */
+ public function formFacebook( $inlineMsg='' )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ if( !IPSLib::fbc_enabled() )
+ {
+ $this->registry->getClass('output')->showError( 'fbc_disabled', 1005.2 );
+ }
+
+ //-----------------------------------------
+ // Shut off save button if not associated yet
+ //-----------------------------------------
+
+ if( !$this->memberData['fb_uid'] )
+ {
+ $this->hide_form_and_save_button = true;
+ $userData = array();
+ $linkedMemberData = array();
+ $perms = array();
+ }
+ else
+ {
+ //-----------------------------------------
+ // FB user logged in?
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
+ $facebook = new $classToLoad( $this->registry );
+
+ /* Now get the linked user */
+ $linkedMemberData = IPSMember::load( intval($this->memberData['fb_uid']), 'all', 'fb_uid' );
+
+ $userData = $facebook->fetchUserData();
+
+ /* Email */
+ $perms['email'] = $facebook->fetchHasAppPermission( 'email' );
+
+ /* Publish Stream */
+ $perms['publish_stream'] = $facebook->fetchHasAppPermission( 'publish_stream' );
+
+ /* Read stream */
+ $perms['read_stream'] = $facebook->fetchHasAppPermission( 'read_stream' );
+
+ /* Offline access */
+ $perms['offline_access'] = $facebook->fetchHasAppPermission( 'offline_access' );
+
+
+ //-----------------------------------------
+ // Thaw bitfield options
+ //-----------------------------------------
+
+ $bwOptions = IPSBWOptions::thaw( $this->memberData['fb_bwoptions'], 'facebook' );
+
+ //-----------------------------------------
+ // Merge..
+ //-----------------------------------------
+
+ if ( is_array( $bwOptions ) )
+ {
+ foreach( $bwOptions as $k => $v )
+ {
+ $this->memberData[ $k ] = $v;
+ }
+ }
+
+ //-----------------------------------------
+ // Able to update status?
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/status.php', 'memberStatus' );
+ $this->registry->setClass( 'memberStatus', new $classToLoad( $this->registry ) );
+
+ $this->registry->memberStatus->setAuthor( $this->memberData );
+ $this->memberData['can_updated_status'] = $this->registry->memberStatus->canCreate();
+
+ $_updates = $facebook->fetchUserTimeline( $userData['id'], 0, true );
+
+ /* Got any? */
+ if ( count( $_updates ) )
+ {
+ $update = array_shift( $_updates );
+
+ if ( count( $update ) AND is_array( $update ) )
+ {
+ $userData['status'] = $update;
+ }
+ }
+
+ if ( is_array( $userData ) AND $userData['status']['message'] AND IPS_DOC_CHAR_SET != 'UTF-8' )
+ {
+ $userData['status']['message'] = IPSText::utf8ToEntities( $userData['status']['message'] );
+ }
+
+ /* Make safe */
+ $userData['status']['message'] = str_replace( array( '<', '>' ), array( '<', '>' ), $userData['status']['message'] );
+ }
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->membersFacebookConnect( trim($this->memberData['fb_uid']), $userData, $linkedMemberData, $perms );
+ }
+
+ /**
+ * Show the ignored users
+ *
+ * @author Matt Mecham
+ * @return string Processed HTML
+ */
+ public function formIgnoredUsers()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $final_users = array();
+ $temp_users = array();
+ $uid = intval( $this->request['uid'] );
+ $ignoredUsers = array();
+
+ //-----------------------------------------
+ // Do we have incoming?
+ //-----------------------------------------
+
+ if ( $uid )
+ {
+ $newmem = IPSMember::load( $uid );
+
+ $this->request['newbox_1'] = $newmem['members_display_name'];
+ }
+
+ //-----------------------------------------
+ // Get ignored users
+ //-----------------------------------------
+
+ $perPage = 25;
+
+ /* Count */
+ $count = $this->DB->buildAndFetch( array( 'select' => 'count(*) as dracula', 'from' => 'ignored_users', 'where' => 'ignore_owner_id=' . $this->memberData['member_id'] ) );
+
+ /* Sort out pagination */
+ $st = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $pagination = $this->registry->output->generatePagination( array(
+ 'totalItems' => $count['dracula'],
+ 'itemsPerPage' => $perPage,
+ 'currentStartValue' => $st,
+ 'baseUrl' => 'app=core&module=usercp&tab=core&area=ignoredusers',
+ ) );
+
+ /* Get em */
+ $this->DB->build( array( 'select' => '*', 'from' => 'ignored_users', 'where' => 'ignore_owner_id=' . $this->memberData['member_id'], 'limit' => array( $st, $perPage ) ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $ignoredUsers[ $row['ignore_ignore_id'] ] = $row;
+ }
+
+ //-----------------------------------------
+ // Get members and check to see if they've
+ // since been moved into a group that cannot
+ // be ignored
+ //-----------------------------------------
+
+ foreach( $ignoredUsers as $_id => $data )
+ {
+ if ( intval($_id) )
+ {
+ $temp_users[] = $_id;
+ }
+ }
+
+ if ( count($temp_users) )
+ {
+ $members = IPSMember::load( $temp_users, 'all' );
+
+ foreach( $members as $m )
+ {
+ $m['g_title'] = IPSMember::makeNameFormatted( $this->caches['group_cache'][ $m['member_group_id'] ]['g_title'], $m['member_group_id'] );
+
+ $final_users[ $m['member_id'] ] = IPSMember::buildDisplayData( $m );
+ $final_users[ $m['member_id'] ]['ignoreData'] = $ignoredUsers[ $m['member_id'] ];
+ }
+ }
+
+ $this->request['newbox_1'] = $this->request['newbox_1'] ? $this->request['newbox_1'] : '';
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->membersIgnoredUsersForm( $final_users, $pagination );
+ }
+
+
+ /**
+ * Show the signature page
+ *
+ * @author Matt Mecham
+ * @return string Processed HTML
+ */
+ public function formSignature()
+ {
+ /* Load editor stuff */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $this->editor = new $classToLoad();
+
+ /* HTML checkbox language strings */
+ $this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_post' ), 'forums' );
+
+ //-----------------------------------------
+ // Check to make sure that we can edit profiles..
+ //-----------------------------------------
+
+ $sig_restrictions = explode( ':', $this->memberData['g_signature_limits'] );
+
+ if ( ! $this->memberData['g_edit_profile'] OR ( $sig_restrictions[0] AND ! $this->memberData['g_sig_unit'] ) )
+ {
+ $this->registry->getClass('output')->showError( 'members_profile_disabled', 1024, null, null, 403 );
+ }
+
+ /* Signature Limits */
+ if ( $sig_restrictions[0] AND $this->memberData['g_sig_unit'] )
+ {
+ if ( $this->memberData['gbw_sig_unit_type'] )
+ {
+ /* days */
+ if ( $this->memberData['joined'] > ( time() - ( 86400 * $this->memberData['g_sig_unit'] ) ) )
+ {
+ $this->hide_form_and_save_button = 1;
+ $form['_noPerm'] = sprintf( $this->lang->words['sig_group_restrict_date'], $this->lang->getDate( $this->memberData['joined'] + ( 86400 * $this->memberData['g_sig_unit'] ), 'long' ) );
+ }
+ }
+ else
+ {
+ /* Posts */
+ if ( $this->memberData['posts'] < $this->memberData['g_sig_unit'] )
+ {
+ $this->hide_form_and_save_button = 1;
+ $form['_noPerm'] = sprintf( $this->lang->words['sig_group_restrict_posts'], $this->memberData['g_sig_unit'] - $this->memberData['posts'] );
+ }
+ }
+
+ if( $form['_noPerm'] )
+ {
+ return $this->registry->getClass('output')->getTemplate('ucp')->membersSignatureFormError( $form );
+ }
+ }
+
+ //-----------------------------------------
+ // Set max length
+ //-----------------------------------------
+
+ $current_sig = '';
+ $t_sig = '';
+
+ /* Set content in editor */
+ $this->editor->setLegacyMode(false);
+ $this->editor->setAllowBbcode( true );
+ $this->editor->setAllowSmilies( true );
+ $this->editor->setAllowHtml( $this->memberData['g_dohtml'] );
+ $this->editor->setIsHtml( $this->memberData['bw_html_sig'] );
+ $this->editor->setBbcodeSection('signatures');
+ $this->editor->setContent( $this->memberData['signature'] );
+
+ /* Load parser */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
+ $parser = new $classToLoad();
+
+ $parser->set( array( 'memberData' => $this->memberData,
+ 'parseBBCode' => 1,
+ 'parseHtml' => ( $this->memberData['g_dohtml'] && $this->memberData['bw_html_sig'] ),
+ 'parseArea' => 'signatures',
+ 'parseEmoticons' => 1 ) );
+
+ $signature = $parser->display( $this->memberData['signature'] );
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->membersSignatureForm( $this->editor->show( 'Post', array( 'noSmilies' => false ) ), $sig_restrictions, $signature );
+ }
+
+
+ /**
+ * Show the profile information
+ *
+ * @author Matt Mecham
+ * @return string Processed HTML
+ */
+ public function formProfileInfo()
+ {
+ /* Load Lang File */
+ $this->registry->class_localization->loadLanguageFile( array( 'public_profile' ), 'members' );
+
+ /* Load editor stuff */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $this->editor = new $classToLoad();
+
+ /* INIT */
+ $required_output = "";
+ $optional_output = "";
+
+ /* Permission Check */
+ if( ! $this->memberData['g_edit_profile'] )
+ {
+ $this->registry->getClass('output')->showError( 'members_profile_disabled', 1026, null, null, 403 );
+ }
+
+ /* Format the birthday drop boxes.. */
+ $date = getdate();
+
+ $day = array();
+ $mon = array();
+ $year = array();
+ $times = array();
+
+ /* Build the day options */
+ $day[] = array( '0', '--' );
+ for ( $i = 1 ; $i < 32 ; $i++ )
+ {
+ $day[] = array( $i, $i );
+ }
+
+ /* Build the month options */
+ $mon[] = array( '0', '--' );
+ for( $i = 1 ; $i < 13 ; $i++ )
+ {
+ $mon[] = array( $i, $this->lang->words['M_' . $i ] );
+ }
+
+ /* Build the years options */
+ $i = $date['year'] - 1;
+ $j = $date['year'] - 100;
+
+ $year[] = array( '0', '--' );
+ for( $i ; $j < $i ; $i-- )
+ {
+ $year[] = array( $i, $i );
+ }
+
+ /* Custom Fields */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
+ $fields = new $classToLoad();
+
+ $fields->member_data = $this->member->fetchMemberData();
+ $fields->initData( 'edit' );
+ $fields->parseToEdit();
+
+ $field_output = array();
+
+ if ( count( $fields->out_fields ) )
+ {
+ foreach( $fields->out_fields as $id => $element )
+ {
+ $data = $fields->cache_data[ $id ];
+ $field_output[ $data['pf_group_key'] ][ $id ] = array(
+ 'field' => $this->registry->getClass('output')->getTemplate('ucp')->field_entry( $fields->field_names[ $id ], $fields->field_desc[ $id ], $fields->out_fields[ $id ], $id ),
+ 'required' => $data['pf_not_null']
+ );
+ }
+
+ /*foreach( $fields->out_fields as $id => $data )
+ {
+ if ( $fields->cache_data[ $id ]['pf_not_null'] == 1 )
+ {
+ $ftype = 'required_output';
+ }
+ else
+ {
+ $ftype = 'optional_output';
+ }
+
+ ${$ftype} .= $this->registry->getClass('output')->getTemplate('ucp')->field_entry( $fields->field_names[ $id ], $fields->field_desc[ $id ], $data, $id );
+ }*/
+ }
+
+ /* About me */
+ $this->editor->setContent( $this->memberData['pp_about_me'] );
+
+ $amEditor = $this->editor->show( 'Post', array( 'delayInit' => 1 ) );
+
+ /* Times */
+ foreach ( $this->lang->words as $k => $v )
+ {
+ if ( strpos( $k, "time_" ) === 0 )
+ {
+ $k = str_replace( "time_", '', $k );
+
+ if( preg_match( '/^[\-\d\.]+$/', $k ) )
+ {
+ $times[ $k ] = $v;
+ }
+ }
+ }
+
+ ksort( $times );
+
+ /* Build and return the form */
+ $template = $this->registry->getClass('output')->getTemplate('ucp')->membersProfileForm( $field_output, $fields->fetchGroupTitles(), $day, $mon, $year, $amEditor, $times );
+
+ return $template;
+ }
+
+ /**
+ * Show the logged inline notifications
+ *
+ * @author Brandon Farber
+ * @param string Error message
+ * @return string Processed HTML
+ */
+ public function showInlineNotifications( $error='' )
+ {
+ /* Init */
+ $start = intval( $this->request['st'] );
+ $perPage = 50;
+
+ //-----------------------------------------
+ // Get class
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
+ $notifyLibrary = new $classToLoad( $this->registry );
+ $notifyLibrary->setMember( $this->memberData );
+
+ /* Clear them? - used in mobile skin */
+ if ( isset($this->request['clear']) && trim($this->request['clear']) == 'true' )
+ {
+ $this->DB->update( 'inline_notifications', array( 'notify_read' => 1 ), 'notify_to_id=' . $this->memberData['member_id'] );
+
+ $notifyLibrary->rebuildUnreadCount();
+ }
+
+ //-----------------------------------------
+ // Turn off normal form
+ //-----------------------------------------
+
+ $this->hide_form_and_save_button = 1;
+
+ //-----------------------------------------
+ // Get notifications
+ //-----------------------------------------
+
+ $_notifications = array();
+ $mids = array();
+
+ $count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as er',
+ 'from' => 'inline_notifications',
+ 'where' => 'notify_to_id=' . $this->memberData['member_id'] ) );
+
+ if ( $count['er'] )
+ {
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'inline_notifications',
+ 'where' => 'notify_to_id=' . $this->memberData['member_id'],
+ 'limit' => array( $start, $perPage ),
+ 'order' => 'notify_sent DESC' ) );
+ $outer = $this->DB->execute();
+
+ while( $r = $this->DB->fetch($outer) )
+ {
+ $r['notify_icon'] = $notifyLibrary->getNotificationIcon( $r['notify_type_key'] );
+
+ $_notifications[] = $r;
+
+ $mids[ $r['notify_from_id'] ] = $r['notify_from_id'];
+ }
+
+ /* Get members */
+ if ( count( $mids ) )
+ {
+ $members = IPSMember::load( array_keys( $mids ), 'all' );
+
+ if ( count( $members ) )
+ {
+ foreach( $_notifications as $key => $data )
+ {
+ if ( isset($members[ $data['notify_from_id'] ]) )
+ {
+ $_notifications[ $key ]['member'] = IPSMember::buildProfilePhoto( $members[ $data['notify_from_id'] ] );
+ }
+ }
+ }
+ }
+ }
+
+ $pages = $this->registry->getClass('output')->generatePagination( array( 'totalItems' => $count['er'],
+ 'itemsPerPage' => $perPage,
+ 'currentStartValue' => $start,
+ 'baseUrl' => "app=core&module=usercp&tab=core&area=notificationlog"
+ ) );
+
+ //-----------------------------------------
+ // Send to template
+ //-----------------------------------------
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->notificationsLog( $_notifications, $error, $pages );
+ }
+
+ /**
+ * Show notification configuration form
+ *
+ * @author Brandon Farber
+ * @return string Processed HTML
+ *
+ * @note Updating this function update also mobileApiRequest::_handleNotificationTypes()
+ */
+ public function showFormNotifications()
+ {
+ //-----------------------------------------
+ // Notifications library
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
+ $notifyLibrary = new $classToLoad( $this->registry );
+ $notifyLibrary->setMember( $this->memberData );
+
+ //-----------------------------------------
+ // Show the form
+ //-----------------------------------------
+
+ $_basicOptions = array( array( 'email', $this->lang->words['notopt__email'] ), array( 'inline', $this->lang->words['notopt__inline'] ), array( 'mobile', $this->lang->words['notopt__mobile'] ) );
+ $_configOptions = $notifyLibrary->getNotificationData( TRUE );
+ $_notifyConfig = $notifyLibrary->getMemberNotificationConfig( $this->memberData );
+ $_defaultConfig = $notifyLibrary->getDefaultNotificationConfig();
+ $_formOptions = array();
+
+ foreach( $_configOptions as $option )
+ {
+ $_thisConfig = isset($_notifyConfig[ $option['key'] ]) ? $_notifyConfig[ $option['key'] ] : $_defaultConfig[ $option['key'] ];
+
+ //-----------------------------------------
+ // Determine available options
+ //-----------------------------------------
+
+ $_available = array();
+
+ foreach( $_basicOptions as $_bo ) // ewwww :P
+ {
+ if( !is_array($_defaultConfig[ $option['key'] ]['disabled']) OR !in_array( $_bo[0], $_defaultConfig[ $option['key'] ]['disabled'] ) )
+ {
+ $_available[] = $_bo;
+ }
+ }
+
+ //-----------------------------------------
+ // If none available, at least give inline
+ //-----------------------------------------
+
+ if( !count($_available) )
+ {
+ $_available[] = array( 'inline', $this->lang->words['notify__inline'] );
+ }
+
+ //-----------------------------------------
+ // Start setting data to pass to form
+ //-----------------------------------------
+
+ $_formOptions[ $option['key'] ] = array();
+ $_formOptions[ $option['key'] ]['key'] = $option['key'];
+ $_formOptions[ $option['key'] ]['app'] = $option['app'];
+
+ //-----------------------------------------
+ // Rikki asked for this...
+ //-----------------------------------------
+
+ foreach( $_available as $_availOption )
+ {
+ $_formOptions[ $option['key'] ]['options'][ $_availOption[0] ] = $_availOption;
+ }
+
+ //$_formOptions[ $option['key'] ]['options'] = $_available;
+
+ $_formOptions[ $option['key'] ]['defaults'] = is_array($_thisConfig['selected']) ? $_thisConfig['selected'] : array();
+ $_formOptions[ $option['key'] ]['disabled'] = 0;
+
+ //-----------------------------------------
+ // Don't allow member to configure
+ // Still show, but disable on form
+ //-----------------------------------------
+
+ if( $_defaultConfig[ $option['key'] ]['disable_override'] )
+ {
+ $_formOptions[ $option['key'] ]['disabled'] = 1;
+ $_formOptions[ $option['key'] ]['defaults'] = is_array($_defaultConfig[ $option['key'] ]['selected']) ? $_defaultConfig[ $option['key'] ]['selected'] : array();
+ }
+ }
+
+ //-----------------------------------------
+ // Other settings
+ //-----------------------------------------
+
+ $_emailData = array();
+
+ //-----------------------------------------
+ // Email settings...
+ //-----------------------------------------
+
+ $_emailData['auto_track'] = $this->memberData['auto_track'] ? 'checked="checked"' : '';
+
+ foreach( array( 'none', 'immediate', 'offline', 'daily', 'weekly' ) as $_opt )
+ {
+ $_emailData['trackOption'][ $_opt ] = ( $this->memberData['auto_track'] == $_opt ) ? 'selected="selected"' : '';
+ }
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->notificationsForm( $_formOptions, $_emailData );
+ }
+
+ /**
+ * Show the attachments form
+ *
+ * @author Matt Mecham
+ * @return string Processed HTML
+ */
+ public function showFormAttachments()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $info = array();
+ $start = intval( $this->request['st'] );
+ $perpage = 15;
+ $sort_key = "";
+ $attachments = array();
+
+ $this->hide_form_and_save_button = 1;
+
+ //-----------------------------------------
+ // Sort it
+ //-----------------------------------------
+
+ switch ( $this->request['sort'] )
+ {
+ case 'date':
+ $sort_key = 'a.attach_date ASC';
+ $info['date_order'] = 'rdate';
+ $info['size_order'] = 'size';
+ break;
+ case 'rdate':
+ $sort_key = 'a.attach_date DESC';
+ $info['date_order'] = 'date';
+ $info['size_order'] = 'size';
+ break;
+ case 'size':
+ $sort_key = 'a.attach_filesize DESC';
+ $info['date_order'] = 'date';
+ $info['size_order'] = 'rsize';
+ break;
+ case 'rsize':
+ $sort_key = 'a.attach_filesize ASC';
+ $info['date_order'] = 'date';
+ $info['size_order'] = 'size';
+ break;
+ default:
+ $sort_key = 'a.attach_date DESC';
+ $info['date_order'] = 'date';
+ $info['size_order'] = 'size';
+ break;
+ }
+
+ //-----------------------------------------
+ // Get some stats...
+ //-----------------------------------------
+
+ $maxspace = intval($this->memberData['g_attach_max']);
+
+ if ( $this->memberData['g_attach_max'] == -1 )
+ {
+ $this->registry->getClass('output')->showError( 'no_permission_to_attach', 1010 );
+ }
+
+ //-----------------------------------------
+ // Limit by forums
+ //-----------------------------------------
+
+ $stats = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count, ' . $this->DB->buildCoalesce( array( 'sum(attach_filesize)', 0 ) ) . ' as sum',
+ 'from' => 'attachments',
+ 'where' => 'attach_member_id=' . $this->memberData['member_id'] . " AND attach_rel_module IN( 'post', 'msg' )" ) );
+
+
+ if ( $maxspace > 0 )
+ {
+ //-----------------------------------------
+ // Figure out percentage used
+ //-----------------------------------------
+
+ $info['has_limit'] = 1;
+ $info['full_percent'] = $stats['sum'] ? sprintf( "%.0f", ( ( $stats['sum'] / ($maxspace * 1024) ) * 100) ) : 0;
+
+ if ( $info['full_percent'] > 100 )
+ {
+ $info['full_percent'] = 100;
+ }
+ else if ( $info['full_percent'] < 1 AND $stats['count'] > 0 )
+ {
+ $info['full_percent'] = 1;
+ }
+
+ $info['attach_space_count'] = sprintf( $this->lang->words['attach_space_count'], intval($stats['count']), intval($info['full_percent']) );
+ $info['attach_space_used'] = sprintf( $this->lang->words['attach_space_used'] , IPSLib::sizeFormat($stats['sum']), IPSLib::sizeFormat($maxspace * 1024) );
+ }
+ else
+ {
+ $info['has_limit'] = 0;
+ $info['attach_space_used'] = sprintf( $this->lang->words['attach_space_unl'] , IPSLib::sizeFormat($stats['sum']) );
+ }
+
+ //-----------------------------------------
+ // Pages
+ //-----------------------------------------
+
+ $pages = $this->registry->getClass('output')->generatePagination( array( 'totalItems' => $stats['count'],
+ 'itemsPerPage' => $perpage,
+ 'currentStartValue' => $start,
+ 'baseUrl' => "app=core&module=usercp&tab=core&area=attachments&sort=" . $this->request['sort'] . "",
+ ) );
+
+ //-----------------------------------------
+ // Get attachments...
+ //-----------------------------------------
+
+ if( $stats['count'] )
+ {
+ $this->DB->build( array( 'select' => 'a.*',
+ 'from' => array( 'attachments' => 'a' ),
+ 'where' => "a.attach_member_id=" . $this->memberData['member_id'] . " AND a.attach_rel_module IN( 'post', 'msg' )",
+ 'order' => $sort_key,
+ 'limit' => array( $start, $perpage ),
+ 'add_join' => array(
+ array( 'select' => 'p.topic_id',
+ 'from' => array( 'posts' => 'p' ),
+ 'where' => 'p.pid=a.attach_rel_id',
+ 'type' => 'left'
+ ),
+ array( 'select' => 't.*',
+ 'from' => array( 'topics' => 't' ),
+ 'where' => 't.tid=p.topic_id',
+ 'type' => 'left'
+ ) )
+ ) );
+ $outer = $this->DB->execute();
+
+ $this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'public_topic' ), 'forums' );
+
+ $cache = $this->cache->getCache('attachtypes');
+
+ /* Load topic class */
+ if ( ! $this->registry->isClassLoaded('topics') )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums' );
+ $this->registry->setClass( 'topics', new $classToLoad( $this->registry ) );
+ }
+
+ while ( $row = $this->DB->fetch( $outer ) )
+ {
+ $row['_link'] = true;
+
+ if ( ! $this->registry->topics->canView( $row ) )
+ {
+ $row['title'] = $this->lang->words['attach_topicmoved'];
+ $row['_link'] = false;
+ }
+
+ //-----------------------------------------
+ // Full attachment thingy
+ //-----------------------------------------
+
+ if ( $row['attach_rel_module'] == 'post' )
+ {
+ $row['_type'] = 'post';
+ }
+ else if ( $row['attach_rel_module'] == 'msg' )
+ {
+ $row['_type'] = 'msg';
+ $row['title'] = $this->lang->words['attach_inpm'];
+ }
+
+ /* IPB 2.x conversion */
+ $row['image'] = str_replace( 'folder_mime_types', 'mime_types', $cache[ $row['attach_ext'] ]['atype_img'] );
+ $row['short_name'] = IPSText::truncate( $row['attach_file'], 30 );
+ $row['attach_date'] = $this->registry->getClass( 'class_localization')->getDate( $row['attach_date'], 'SHORT' );
+ $row['real_size'] = IPSLib::sizeFormat( $row['attach_filesize'] );
+
+ $attachments[] = $row;
+ }
+ }
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->coreAttachments( $info, $pages, $attachments );
+ }
+
+ /**
+ * Show the Email & Password form
+ *
+ * @author Matt Mecham
+ * @param string Returned error message (if any)
+ * @return string Processed HTML
+ */
+ public function showFormEmailPassword( $_message='' )
+ {
+ //-----------------------------------------
+ // Do not allow validating members to change
+ // email when admin validation is on
+ // @see http://community.invisionpower.com/tracker/issue-19964-loophole-in-registration-procedure/
+ //-----------------------------------------
+
+ if( $this->memberData['member_group_id'] == $this->settings['auth_group'] AND in_array( $this->settings['reg_auth_type'], array( 'admin', 'admin_user' ) ) )
+ {
+ $this->registry->output->showError( $this->lang->words['admin_val_no_email_chg'], 10189 );
+ }
+
+ //-----------------------------------------
+ // Do we have another URL for email resets?
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+ $this->han_login->checkMaintenanceRedirect();
+
+ //$txt = $this->lang->words['ce_current'] . $this->memberData['email'];
+
+ if ( $this->settings['reg_auth_type'])
+ {
+ $txt .= $this->lang->words['ce_auth'];
+ }
+
+ $_message = $_message ? $this->lang->words[$_message] : '';
+
+ if( $this->memberData['g_access_cp'] )
+ {
+ $this->hide_form_and_save_button = true;
+ }
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->emailPasswordChangeForm( $txt, $_message, $this->_isFBUser );
+ }
+
+ /**
+ * Show the display name form
+ *
+ * @author Matt Mecham
+ * @param string Error message (if any)
+ * @return string Processed HTML
+ */
+ public function showFormDisplayname( $error="" )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $form = array();
+
+ //-----------------------------------------
+ // CHECK (please)
+ //-----------------------------------------
+
+ if ( ! $this->settings['auth_allow_dnames'] OR $this->memberData['g_dname_changes'] == 0 OR $this->memberData['g_dname_date'] == 0 )
+ {
+ $this->registry->getClass('output')->showError( 'no_permission_for_display_names', 1011 );
+ }
+
+ $this->request['display_name'] = $this->request['display_name'] ? $this->request['display_name'] : '';
+
+ $this->settings['username_errormsg'] = str_replace( '{chars}', $this->settings['username_characters'], $this->settings['username_errormsg'] );
+
+ //-----------------------------------------
+ // Grab # changes > 24 hours
+ //-----------------------------------------
+
+ $time_check = time() - 86400 * $this->memberData['g_dname_date'];
+
+ if( $time_check < $this->memberData['joined'] )
+ {
+ $time_check = $this->memberData['joined'];
+ }
+
+ $name_count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count, MIN(dname_date) as min_date', 'from' => 'dnames_change', 'where' => "dname_member_id=" . $this->memberData['member_id'] . " AND dname_date > $time_check AND dname_discount=0" ) );
+
+ $name_count['count'] = intval( $name_count['count'] );
+ $name_count['min_date'] = intval( $name_count['min_date'] ) ? intval( $name_count['min_date'] ) : $time_check;
+
+ //-----------------------------------------
+ // Calculate # left
+ //-----------------------------------------
+
+ /* Check new permissions */
+ $_g = $this->caches['group_cache'][ $this->memberData['member_group_id'] ];
+
+ if ( $_g['g_displayname_unit'] )
+ {
+ if ( $_g['gbw_displayname_unit_type'] )
+ {
+ /* days */
+ if ( $this->memberData['joined'] > ( time() - ( 86400 * $_g['g_displayname_unit'] ) ) )
+ {
+ $this->hide_form_and_save_button = 1;
+ $form['_noPerm'] = sprintf( $this->lang->words['dname_group_restrict_date'], $this->lang->getDate( $this->memberData['joined'] + ( 86400 * $_g['g_displayname_unit'] ), 'long' ) );
+ }
+ }
+ else
+ {
+ /* Posts */
+ if ( $this->memberData['posts'] < $_g['g_displayname_unit'] )
+ {
+ $this->hide_form_and_save_button = 1;
+ $form['_noPerm'] = sprintf( $this->lang->words['dname_group_restrict_posts'], $_g['g_displayname_unit'] - $this->memberData['posts'] );
+ }
+ }
+ }
+
+ if( !$form['_noPerm'] )
+ {
+ if ( $this->memberData['g_dname_changes'] == -1 )
+ {
+ $form['_lang_string'] = $this->lang->words['dname_string2'];
+ }
+ else
+ {
+ $form['_changes_left'] = $this->memberData['g_dname_changes'] - $name_count['count'];
+ $form['_changes_done'] = $name_count['count'];
+
+ # Make sure changes done isn't larger than allowed
+ # This happens when changing via ACP
+
+ if ( $form['_changes_done'] > $this->memberData['g_dname_changes'] )
+ {
+ $form['_changes_done'] = $this->memberData['g_dname_changes'];
+ }
+
+ $form['_first_change'] = $this->registry->getClass( 'class_localization')->getDate( $name_count['min_date'], 'date', 1 );
+ $form['_lang_string'] = sprintf( $this->lang->words['dname_string'],
+ $form['_changes_done'], $this->memberData['g_dname_changes'],
+ $form['_first_change'], $this->memberData['g_dname_changes'],
+ $this->memberData['g_dname_date'] ) . $this->lang->words['dname_string2'];
+ }
+ }
+
+ //-----------------------------------------
+ // Print
+ //-----------------------------------------
+
+ $this->_pageTitle = $this->lang->words['m_dname_change'];
+
+ return $this->registry->getClass('output')->getTemplate('ucp')->displayNameForm( $form, $error, '', $this->_isFBUser );
+ }
+
+ /**
+ * UserCP Form Check
+ *
+ * @author Matt Mecham
+ * @param string Current area as defined by 'get_links'
+ * @return string Processed HTML
+ */
+ public function saveForm( $current_area )
+ {
+ //-----------------------------------------
+ // Where to go, what to see?
+ //-----------------------------------------
+
+ switch( $current_area )
+ {
+ default:
+ case 'profileinfo':
+ return $this->saveProfileInfo();
+ break;
+ case 'signature':
+ return $this->saveSignature();
+ break;
+ case 'photo':
+ return $this->savePhoto();
+ break;
+ case 'ignoredusers':
+ return $this->saveIgnoredUsers();
+ break;
+ case 'facebook':
+ return $this->saveFacebook();
+ break;
+ case 'twitter':
+ return $this->saveTwitter();
+ break;
+ case 'customize':
+ return $this->saveCustomize();
+ break;
+ case 'email':
+ return $this->saveFormEmailPassword();
+ break;
+ case 'password':
+ return $this->saveFormPassword();
+ break;
+ case 'displayname':
+ return $this->saveFormDisplayname();
+ break;
+ case 'notifications':
+ return $this->saveFormNotifications();
+ break;
+ }
+ }
+
+ /**
+ * UserCP Save Form: Customize
+ *
+ * @return array Errors
+ */
+ public function saveCustomize()
+ {
+ /* Init */
+ $errors = array();
+ $custom = array();
+ $bg_nix = trim( $this->request['bg_nix'] );
+ $bg_url = trim( $this->request['bg_url'] );
+ $bg_tile = intval( $this->request['bg_tile'] );
+ $bg_color = trim( str_replace( '#', '', $this->request['bg_color'] ) );
+
+ /* reset custom */
+ $custom = IPSLib::safeUnserialize( $this->memberData['pp_customization'] );
+
+ /* Bug #21578 */
+ if( ! $bg_color && $custom['bg_color'] )
+ {
+ $bg_color = $custom['bg_color'];
+ }
+
+ /* Delete all? */
+ if ( $bg_nix )
+ {
+ /* reset array */
+ $custom = array( 'bg_url' => '', 'type' => '', 'bg_color' => '', 'bg_tile' => '' );
+
+ /* remove bg images */
+ IPSMember::getFunction()->removeUploadedBackgroundImages( $this->memberData['member_id'] );
+ }
+ else
+ {
+ if ( $bg_url AND $this->memberData['gbw_allow_url_bgimage'] )
+ {
+ /* Check */
+ if ( ! stristr( $bg_url, 'http://' ) OR preg_match( '#\(\*#', $bg_url ) )
+ {
+ return array( 0 => $this->lang->words['pp_bgimg_url_bad'] );
+ }
+
+ $image_extension = strtolower( pathinfo( $bg_url, PATHINFO_EXTENSION ) );
+
+ if( ! in_array( $image_extension, array( 'png', 'jpg', 'gif', 'jpeg' ) ) )
+ {
+ return array( 0 => $this->lang->words['pp_bgimg_ext_bad'] );
+ }
+
+ $custom['bg_url'] = $bg_url;
+ $custom['type'] = 'url';
+ }
+ else if ( $this->memberData['gbw_allow_upload_bgimage'] )
+ {
+ /* Load more lang strings */
+ $this->registry->class_localization->loadLanguageFile( array( 'public_profile' ), 'members' );
+
+ /* Upload img */
+ $img = IPSMember::getFunction()->uploadBackgroundImage();
+
+ if ( $img['status'] == 'fail' )
+ {
+ return array( 0 => sprintf( $this->lang->words[ 'pp_' . $img['error'] ], $img['maxSize'] ) );
+ }
+ else if ( $img['final_location'] )
+ {
+ $custom['bg_url'] = $img['final_location'];
+ $custom['type'] = 'upload';
+ }
+ }
+ }
+
+ /* BG color */
+ $custom['bg_color'] = $bg_nix ? '' : IPSText::alphanumericalClean( $bg_color );
+
+ /* Tile */
+ $custom['bg_tile'] = $bg_nix ? '' : $bg_tile;
+
+ /* Save it */
+ if ( ! $this->memberData['bw_disable_customization'] AND $this->memberData['gbw_allow_customization'] )
+ {
+ IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'pp_profile_update' => IPS_UNIX_TIME_NOW, 'pp_customization' => serialize( $custom ) ) ) );
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * UserCP Save Form: Twitter
+ *
+ * @return array Errors
+ */
+ public function saveTwitter()
+ {
+ if( !IPSLib::twitter_enabled() )
+ {
+ $this->registry->getClass('output')->showError( 'twitter_disabled', 1005.2 );
+ }
+
+ //-----------------------------------------
+ // Data
+ //-----------------------------------------
+
+ $toSave = IPSBWOptions::thaw( $this->memberData['tc_bwoptions'], 'twitter' );
+
+ //-----------------------------------------
+ // Loop and save... simple
+ //-----------------------------------------
+
+ foreach( array( 'tc_s_pic', 'tc_s_status', 'tc_s_aboutme', 'tc_s_bgimg', 'tc_si_status' ) as $field )
+ {
+ $toSave[ $field ] = intval( $this->request[ $field ] );
+ }
+
+ $this->memberData['tc_bwoptions'] = IPSBWOptions::freeze( $toSave, 'twitter' );
+ $return = IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'tc_bwoptions' => $this->memberData['tc_bwoptions'] ) ) );
+
+ //-----------------------------------------
+ // Now sync
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
+ $twitter = new $classToLoad( $this->registry, $this->memberData['twitter_token'], $this->memberData['twitter_secret'] );
+
+ try
+ {
+ $twitter->syncMember( $this->memberData );
+ }
+ catch( Exception $error )
+ {
+ $msg = $error->getMessage();
+
+ switch( $msg )
+ {
+ case 'NOT_LINKED':
+ case 'NO_MEMBER':
+ break;
+ }
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * UserCP Save Form: Facebook
+ *
+ * @return array Errors
+ */
+ public function saveFacebook()
+ {
+ if( !IPSLib::fbc_enabled() )
+ {
+ $this->registry->getClass('output')->showError( 'fbc_disabled', 1005 );
+ }
+
+ //-----------------------------------------
+ // Data
+ //-----------------------------------------
+
+ $toSave = IPSBWOptions::thaw( $this->memberData['members_bitoptions'], 'members' );
+
+ //-----------------------------------------
+ // Loop and save... simple
+ //-----------------------------------------
+
+ foreach( array( 'fbc_s_pic', 'fbc_s_status', 'fbc_s_aboutme', 'fbc_si_status' ) as $field )
+ {
+ $toSave[ $field ] = intval( $this->request[ $field ] );
+ }
+
+ $this->memberData['fb_bwoptions'] = IPSBWOptions::freeze( $toSave, 'facebook' );
+ IPSMember::save( $this->memberData['member_id'], array( 'extendedProfile' => array( 'fb_bwoptions' => $this->memberData['fb_bwoptions'] ) ) );
+
+ //-----------------------------------------
+ // Now sync
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
+ $facebook = new $classToLoad( $this->registry );
+
+ try
+ {
+ $facebook->syncMember( $this->memberData );
+ }
+ catch( Exception $error )
+ {
+ $msg = $error->getMessage();
+
+ switch( $msg )
+ {
+ case 'NOT_LINKED':
+ case 'NO_MEMBER':
+ break;
+ }
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * UserCP Save Form: Ignore Users
+ *
+ * @return array Errors
+ */
+ public function saveIgnoredUsers()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $newName = $this->request['newbox_1'];
+ $dnvs = intval( $this->request['donot_view_sigs'] );
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'view_sigs' => ( $dnvs ) ? 0 : 1 ) ) );
+
+ if ( trim( $newName ) && $_POST['newbox_1'] != $this->lang->words['ucp_members_name'] )
+ {
+ //-----------------------------------------
+ // Load
+ //-----------------------------------------
+
+ $member = IPSMember::load( $newName, 'core', 'displayname' );
+
+ if ( ! $member['member_id'] )
+ {
+ return array( 0 => $this->lang->words['ignoreuser_nomem'] );
+ }
+
+ if ( $member['member_id'] == $this->memberData['member_id'] )
+ {
+ return array( 0 => $this->lang->words['ignoreuser_cannot'] );
+ }
+
+ //-----------------------------------------
+ // Already ignoring?
+ //-----------------------------------------
+
+ $ignoreMe = $this->DB->buildAndFetch( array(
+ 'select' => '*',
+ 'from' => 'ignored_users',
+ 'where' => 'ignore_owner_id=' . $this->memberData['member_id'] . ' AND ignore_ignore_id=' . $member['member_id']
+ ) );
+
+ if ( $ignoreMe['ignore_id'] )
+ {
+ return array( 0 => $this->lang->words['ignoreuser_already'] );
+ }
+
+ //-----------------------------------------
+ // Can we ignore them?
+ //-----------------------------------------
+
+ if ( $member['_canBeIgnored'] !== TRUE )
+ {
+ return array( 0 => $this->lang->words['ignoreuser_cannot'] );
+ }
+
+ //-----------------------------------------
+ // Add it
+ //-----------------------------------------
+
+ $this->DB->insert( 'ignored_users', array(
+ 'ignore_owner_id' => $this->memberData['member_id'],
+ 'ignore_ignore_id' => $member['member_id'],
+ 'ignore_messages' => !empty( $this->request['ignore_messages'] ) ? 1 : 0,
+ 'ignore_topics' => !empty( $this->request['ignore_topics'] ) ? 1 : 0,
+ 'ignore_signatures' => !empty( $this->request['ignore_signatures'] ) ? 1 : 0,
+ 'ignore_chats' => !empty( $this->request['ignore_chats'] ) ? 1 : 0,
+ )
+ );
+
+ /* Rebuild cache */
+ IPSMember::rebuildIgnoredUsersCache( $this->memberData );
+ }
+
+ return TRUE;
+ }
+
+
+ /**
+ * UserCP Save Form: Signature
+ *
+ * @return array Errors
+ */
+ public function saveSignature()
+ {
+ /* Load editor stuff */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $this->editor = new $classToLoad();
+ $this->editor->setLegacyMode(false);
+
+ $isHtml = intval( $this->request['sig_htmlstatus'] );
+
+ //-----------------------------------------
+ // Check to make sure that we can edit profiles..
+ //-----------------------------------------
+
+ $sig_restrictions = explode( ':', $this->memberData['g_signature_limits'] );
+
+ if ( ! $this->memberData['g_edit_profile'] OR ( $sig_restrictions[0] AND ! $this->memberData['g_sig_unit'] ) )
+ {
+ $this->registry->getClass('output')->showError( 'members_profile_disabled', 1028, null, null, 403 );
+ }
+
+ //-----------------------------------------
+ // Post process the editor
+ // Now we have safe HTML and bbcode
+ //-----------------------------------------
+
+ /* Set content in editor */
+ $this->editor->setAllowBbcode( true );
+ $this->editor->setAllowSmilies( true );
+ $this->editor->setIsHtml( $this->memberData['g_dohtml'] && $isHtml );
+ $this->editor->setBbcodeSection('signatures');
+ $this->editor->setContent( $this->memberData['signature'] );
+
+ $signature = $this->editor->process( $_POST['Post'] );
+
+ //-----------------------------------------
+ // Parse post
+ //-----------------------------------------
+
+ /* Load parser */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
+ $parser = new $classToLoad();
+
+ $parser->testForParsingLimits( $signature, array( 'quote', 'emoticons', 'urls' ) );
+
+ if ( is_array( $parser->getErrors() ) && count( $parser->getErrors() ) )
+ {
+ $this->lang->loadLanguageFile( array( 'public_post' ), 'forums' );
+
+ $_error = array_pop( $parser->getErrors() );
+ $this->registry->getClass('output')->showError( $_error, 10210 );
+ }
+
+ //-----------------------------------------
+ // Signature restrictions...
+ //-----------------------------------------
+
+ $sig_errors = array();
+
+ //-----------------------------------------
+ // Max number of images...
+ //-----------------------------------------
+
+ if( isset($sig_restrictions[1]) and $sig_restrictions[1] !== '' )
+ {
+ if( $parser->getImageCount( $signature ) > $sig_restrictions[1] )
+ {
+ $sig_errors[] = sprintf( $this->lang->words['sig_toomanyimages'], $sig_restrictions[1] );
+ }
+ }
+
+ //-----------------------------------------
+ // Max number of urls...
+ //-----------------------------------------
+
+ if( isset($sig_restrictions[4]) and $sig_restrictions[4] !== '' )
+ {
+ if( $parser->getUrlCount( $signature ) > $sig_restrictions[4] )
+ {
+ $sig_errors[] = sprintf( $this->lang->words['sig_toomanyurls'], $sig_restrictions[4] );
+ }
+ else
+ {
+ preg_match_all( '#(^|\s|>)((http|https|news|ftp)://\w+[^\s\[\]\<]+)#is', $signature, $matches );
+
+ if( count($matches[1]) > $sig_restrictions[4] )
+ {
+ $sig_errors[] = sprintf( $this->lang->words['sig_toomanyurls'], $sig_restrictions[4] );
+ }
+ }
+ }
+
+ $this->settings['signature_line_length'] = $this->settings['signature_line_length'] > 0 ? $this->settings['signature_line_length'] : 200;
+
+ /* You can't wordwrap on HTML http://community.invisionpower.com/resources/bugs.html/_/ip-board/signature-url-bbcode-r41254 */
+ //$signature = wordwrap( $signature, $this->settings['signature_line_length'], '
', true );
+
+ // http://community.invisionpower.com/tracker/issue-35105-signature-restriction-minor-bug
+ $signature = preg_replace( '#^\s*()+#i', '', $signature );
+ $signature = preg_replace( '#()+?\s*$#i', '', $signature );
+
+ //-----------------------------------------
+ // Max number of lines of text...
+ //-----------------------------------------
+
+ if( isset($sig_restrictions[5]) and $sig_restrictions[5] !== '' )
+ {
+ $lineCount = substr_count( $signature, "" ) + substr_count( $signature, "br>" );
+
+ if( $lineCount >= $sig_restrictions[5] )
+ {
+ $sig_errors[] = sprintf( $this->lang->words['sig_toomanylines'], $sig_restrictions[5] );
+ }
+ }
+
+ //-----------------------------------------
+ // Now the crappy part..
+ //-----------------------------------------
+
+ if( isset($sig_restrictions[2]) and $sig_restrictions[2] !== '' AND isset($sig_restrictions[3]) and $sig_restrictions[3] !== '' )
+ {
+ preg_match_all( '/\ ]+?)>/i', $signature, $allImages );
+
+ if( count($allImages[1]) )
+ {
+ foreach( $allImages[1] as $foundImage )
+ {
+ preg_match( '#src=[\'"]([^\'"]+?)[\'"]#i', $foundImage, $url );
+ $imageProperties = @getimagesize( $url[1] );
+
+ if( is_array($imageProperties) AND count($imageProperties) )
+ {
+ if( $imageProperties[0] > $sig_restrictions[2] OR $imageProperties[1] > $sig_restrictions[3] )
+ {
+ $sig_errors[] = sprintf( $this->lang->words['sig_imagetoobig'], $url[1], $sig_restrictions[2], $sig_restrictions[3] );
+ }
+ }
+ else
+ {
+ $sig_errors[] = $this->lang->words['sig_imagenotretrievable'];
+ }
+ }
+ }
+ }
+
+ if( count($sig_errors) )
+ {
+ $this->registry->getClass('output')->showError( implode( ' ', $sig_errors ), 10211 );
+ }
+
+ /* Save HTML status */
+ $members_bitoptions = IPSBWOptions::thaw( $this->memberData['members_bitoptions'], 'members', 'global' );
+ $members_bitoptions['bw_html_sig'] = $isHtml;
+
+ //-----------------------------------------
+ // Write it to the DB.
+ //-----------------------------------------
+
+ IPSMember::save( $this->memberData['member_id'], array( 'members' => $members_bitoptions, 'extendedProfile' => array( 'signature' => $signature ) ) );
+
+ /* Update cache */
+ IPSContentCache::update( $this->memberData['member_id'], 'sig', $parser->display( $signature ) );
+
+ return TRUE;
+ }
+
+
+ /**
+ * UserCP Save Form: Profile Info
+ *
+ * @return array Errors
+ */
+ public function saveProfileInfo()
+ {
+ /* Load editor stuff */
+ if( $this->request['updateAboutMe'] )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $this->editor = new $classToLoad();
+ $this->editor->setLegacyMode(false);
+ }
+
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $pp_setting_moderate_comments = intval( $this->request['pp_setting_moderate_comments'] );
+ $pp_setting_moderate_friends = intval( $this->request['pp_setting_moderate_friends'] );
+ $pp_setting_count_visitors = intval( $this->request['pp_setting_count_visitors'] );
+ $pp_setting_count_comments = intval( $this->request['pp_setting_count_comments'] );
+ $pp_setting_count_friends = intval( $this->request['pp_setting_count_friends'] );
+
+ //-----------------------------------------
+ // Check to make sure that we can edit profiles..
+ //-----------------------------------------
+
+ if ( ! $this->memberData['g_edit_profile'] )
+ {
+ $this->registry->getClass('output')->showError( 'members_profile_disabled', 10214, null, null, 403 );
+ }
+
+ //-----------------------------------------
+ // make sure that either we entered
+ // all calendar fields, or we left them
+ // all blank
+ //-----------------------------------------
+
+ $c_cnt = 0;
+
+ foreach ( array('day','month','year') as $v )
+ {
+ if ( $this->request[ $v ] )
+ {
+ $c_cnt++;
+ }
+ }
+
+ if( $c_cnt > 0 && $c_cnt < 2 )
+ {
+ $this->registry->getClass('output')->showError( 'member_bad_birthday', 10215 );
+ }
+ else if( $c_cnt > 0 )
+ {
+ //-----------------------------------------
+ // Make sure it's a legal date
+ //-----------------------------------------
+
+ $_year = $this->request['year'] ? $this->request['year'] : 2000;
+
+ if ( ! checkdate( $this->request['month'], $this->request['day'], $_year ) )
+ {
+ $this->registry->getClass('output')->showError( 'member_bad_birthday', 10216 );
+ }
+ }
+
+ //-----------------------------------------
+ // Start off our array
+ //-----------------------------------------
+
+ $core = array( 'bday_day' => $this->request['day'],
+ 'bday_month' => $this->request['month'],
+ 'bday_year' => $this->request['year'],
+ );
+
+ $extendedProfile = array( 'pp_setting_moderate_comments' => $pp_setting_moderate_comments,
+ 'pp_setting_moderate_friends' => $pp_setting_moderate_friends,
+ 'pp_setting_count_visitors' => $pp_setting_count_visitors,
+ 'pp_setting_count_comments' => $pp_setting_count_comments,
+ 'pp_setting_count_friends' => $pp_setting_count_friends );
+
+ //-----------------------------------------
+ // check to see if we can enter a member title
+ // and if one is entered, update it.
+ //-----------------------------------------
+
+ if( isset( $this->request['member_title'] ) and ( $this->settings['post_titlechange'] == -1 or ( $this->settings['post_titlechange'] and $this->memberData['posts'] >= $this->settings['post_titlechange'] ) ) )
+ {
+ $core['title'] = IPSText::getTextClass('bbcode')->stripBadWords( $this->request['member_title'] );
+ }
+
+ //-----------------------------------------
+ // Custom profile field stuff
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
+ $fields = new $classToLoad();
+
+ $fields->member_data = $this->member->fetchMemberData();
+ $fields->initData( 'edit' );
+ /* Use $_POST and not ipsRegistry::$request as the custom profile field kernel class has its own cleaning routines for saving and showing
+ which means we end up with double & -> & conversion (<, etc) */
+ $fields->parseToSave( $_POST );
+
+ if( $fields->error_messages )
+ {
+ return $fields->error_messages;
+ }
+
+ /* Check the website url field */
+ $website_field = $fields->getFieldIDByKey( 'website' );
+
+ if( $website_field && $fields->out_fields[ 'field_' . $website_field ] )
+ {
+ if( stristr( $fields->out_fields[ 'field_' . $website_field ], 'http://' ) === FALSE && stristr( $fields->out_fields[ 'field_' . $website_field ], 'https://' ) === FALSE )
+ {
+ $fields->out_fields[ 'field_' . $website_field ] = 'http://' . $fields->out_fields[ 'field_' . $website_field ];
+ }
+ }
+
+ //-----------------------------------------
+ // Check...
+ //-----------------------------------------
+
+ if ( count( $fields->error_fields['empty'] ) )
+ {
+ $this->registry->getClass('output')->showError( array( 'customfields_empty', $fields->error_fields['empty'][0]['pf_title'] ), 10217 );
+ }
+
+ if ( count( $fields->error_fields['invalid'] ) )
+ {
+ $this->registry->getClass('output')->showError( array( 'customfields_invalid', $fields->error_fields['invalid'][0]['pf_title'] ), 10218 );
+ }
+
+ if ( count( $fields->error_fields['toobig'] ) )
+ {
+ $this->registry->getClass('output')->showError( array( 'customfields_toobig', $fields->error_fields['toobig'][0]['pf_title'] ), 10219 );
+ }
+
+ /* About me */
+ if( $this->request['updateAboutMe'] )
+ {
+ $extendedProfile['pp_about_me'] = $this->editor->process( $_POST['Post'] );
+ }
+
+ /* Open ID & times*/
+ $timeZone = IPSText::alphanumericalClean( $this->request['timeZone'], '+.' );
+ $dst_correct = intval( $this->request['dst_correct'] );
+
+ /* Add into array */
+ $core['time_offset'] = $timeZone;
+
+ /* http://community.invisionpower.com/resources/bugs.html/_/ip-board/cannot-uncheck-my-timezone-is-currently-in-dst-checkbox-in-profile-r41510 */
+ //$core['dst_in_use'] = $this->settings['time_dst_auto_correction'] ? ( ( $this->request['dstOption'] AND intval($this->request['dstCheck']) == 0 ) ? intval($this->request['dstOption']) : 0 ) : $this->memberData['dst_in_use'];
+ $core['dst_in_use'] = $this->settings['time_dst_auto_correction'] ? ( ( $this->request['dstOption'] AND intval($this->request['dstCheck']) == 0 ) ? intval($this->request['dstOption']) : 0 ) : intval($this->request['dstOption']);
+
+ $core['members_auto_dst'] = $this->settings['time_dst_auto_correction'] ? intval($this->request['dstCheck']) : $this->memberData['members_auto_dst'];
+
+ //-----------------------------------------
+ // Update the DB
+ //-----------------------------------------
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => $core,
+ 'customFields' => $fields->out_fields,
+ 'extendedProfile' => $extendedProfile ) );
+
+ //-----------------------------------------
+ // Update birthdays cache if user set to today
+ // or if birthday was today but isn't now
+ //-----------------------------------------
+
+ if( $core['bday_month'] == date('m') AND $core['bday_day'] == date('d') )
+ {
+ $this->cache->rebuildCache( 'birthdays', 'calendar' );
+ }
+ else if( $this->memberData['bday_month'] == date('m') AND $this->memberData['bday_day'] == date('d') AND ( $core['bday_month'] != date('m') OR $core['bday_day'] != date('d') ) )
+ {
+ $this->cache->rebuildCache( 'birthdays', 'calendar' );
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * UserCP Save Form: Notifications config
+ *
+ * @return boolean Successful
+ */
+ public function saveFormNotifications()
+ {
+ //-----------------------------------------
+ // Notifications library
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . '/sources/classes/member/notifications.php', 'notifications' );
+ $notifyLibrary = new $classToLoad( $this->registry );
+ $notifyLibrary->setMember( $this->memberData );
+
+ //-----------------------------------------
+ // Show the form
+ //-----------------------------------------
+
+ $_basicOptions = array( array( 'email', $this->lang->words['notopt__email'] ), array( 'inline', $this->lang->words['notopt__inline'] ), array( 'mobile' => $this->lang->words['notopt__mobile'] ) );
+ $_configOptions = $notifyLibrary->getNotificationData();
+ $_notifyConfig = $notifyLibrary->getMemberNotificationConfig( $this->memberData );
+ $_defaultConfig = $notifyLibrary->getDefaultNotificationConfig();
+ $_saveConfig = array();
+
+ foreach( $_configOptions as $option )
+ {
+ $_saveConfig[ $option['key'] ] = array();
+ $_saveConfig[ $option['key'] ]['selected'] = array();
+
+ //-----------------------------------------
+ // Loop through and mark what we selected.
+ // Do not allow changing of stuff from disable_override
+ // and disabled, however
+ //-----------------------------------------
+
+ if( is_array($this->request['config_' . $option['key'] ]) AND count($this->request['config_' . $option['key'] ]) )
+ {
+ foreach( $this->request['config_' . $option['key'] ] as $_selected )
+ {
+ if( !is_array($_defaultConfig[ $option['key'] ]['disabled']) OR !in_array( $_selected, $_defaultConfig[ $option['key'] ]['disabled'] ) )
+ {
+ $_saveConfig[ $option['key'] ]['selected'][] = $_selected;
+ }
+ }
+ }
+
+ if( $_defaultConfig[ $option['key'] ]['disable_override'] )
+ {
+ $_saveConfig[ $option['key'] ]['selected'] = $_defaultConfig[ $option['key'] ]['selected'];
+ }
+ }
+
+ //-----------------------------------------
+ // Save
+ //-----------------------------------------
+
+ IPSMember::packMemberCache( $this->memberData['member_id'], array( 'notifications' => $_saveConfig, 'show_notification_popup' => intval($this->request['show_notification_popup']) ), $this->memberData['members_cache'] );
+
+ //-----------------------------------------
+ // Topic preferences
+ //-----------------------------------------
+
+ $_trackChoice = '';
+
+ if ( $this->request['auto_track'] )
+ {
+ if ( in_array( $this->request['trackchoice'], array( 'none', 'immediate', 'offline', 'daily', 'weekly' ) ) )
+ {
+ $_trackChoice = $this->request['trackchoice'];
+ }
+ }
+
+ //-----------------------------------------
+ // Profile preferences
+ //-----------------------------------------
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array(
+ 'allow_admin_mails' => intval( $this->request['admin_send'] ),
+ 'auto_track' => $_trackChoice
+ ) ) );
+
+ return TRUE;
+ }
+ /**
+ * UserCP Save Form: Password
+ *
+ * @param array Array of member / core_sys_login information (if we're editing)
+ * @return mixed Array of errors / boolean true
+ */
+ public function saveFormPassword( $member=array() )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $cur_pass = trim($this->request['current_pass']);
+ $new_pass = trim($this->request['new_pass_1']);
+ $chk_pass = trim($this->request['new_pass_2']);
+ $isRemote = ( ! $this->memberData['bw_local_password_set'] AND $this->memberData['members_created_remote'] ) ? true : false;
+
+ //-----------------------------------------
+ // Checks...
+ //-----------------------------------------
+
+ if( $this->memberData['g_access_cp'] )
+ {
+ return array( 0 => $this->lang->words['admin_emailpassword'] );
+ }
+
+ if ( $isRemote === false AND ( ! $_POST['current_pass'] OR ( empty($new_pass) ) or ( empty($chk_pass) ) ) )
+ {
+ return array( 0 => $this->lang->words['complete_entire_form'] );
+ }
+
+ //-----------------------------------------
+ // Do the passwords actually match?
+ //-----------------------------------------
+
+ if ( $new_pass != $chk_pass )
+ {
+ return array( 0 => $this->lang->words['passwords_not_matchy'] );
+ }
+
+ //-----------------------------------------
+ // Check password...
+ //-----------------------------------------
+
+ if ( $isRemote === false )
+ {
+ if ( $this->_checkPassword( $cur_pass ) !== TRUE )
+ {
+ return array( 0 => $this->lang->words['current_pw_bad'] );
+ }
+ }
+ else
+ {
+ /* This is INIT in _checkPassword */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+ }
+
+ //-----------------------------------------
+ // Create new password...
+ //-----------------------------------------
+
+ $md5_pass = md5($new_pass);
+
+ //-----------------------------------------
+ // han_login was loaded during check_password
+ //-----------------------------------------
+
+ $this->han_login->changePass( $this->memberData['email'], $md5_pass, $new_pass, $this->memberData );
+
+ if ( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
+ {
+ return array( 0 => $this->lang->words['hanlogin_pw_failed'] );
+ }
+
+ //-----------------------------------------
+ // Update the DB
+ //-----------------------------------------
+
+ IPSMember::updatePassword( $this->memberData['member_id'], $md5_pass );
+
+ IPSLib::runMemberSync( 'onPassChange', $this->memberData['member_id'], $new_pass );
+
+ //-----------------------------------------
+ // Update members log in key...
+ //-----------------------------------------
+
+ $key = IPSMember::generateAutoLoginKey();
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'member_login_key' => $key, 'bw_local_password_set' => 1 ) ) );
+
+ $this->ok_message = $this->lang->words['pw_change_successful'];
+
+ return TRUE;
+ }
+
+ /**
+ * UserCP Save Form: Display Name
+ *
+ * @return mixed Array of errors / boolean true
+ */
+ public function saveFormDisplayname()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $members_display_name = trim($this->request['displayName']);
+ $password_check = trim( $this->request['displayPassword'] );
+
+ //-----------------------------------------
+ // Check for blanks...
+ //-----------------------------------------
+
+ if ( ! $members_display_name OR ( ! $this->_isFBUser AND ! $password_check ) )
+ {
+ return array( 0 => $this->lang->words['complete_entire_form'] );
+ }
+
+ //-----------------------------------------
+ // Check password
+ //-----------------------------------------
+
+ if ( ! $this->_isFBUser )
+ {
+ if ( $this->_checkPassword( $password_check ) === FALSE )
+ {
+ return array( 0 => $this->lang->words['current_pw_bad'] );
+ }
+ }
+
+ try
+ {
+ if ( IPSMember::getFunction()->updateName( $this->memberData['member_id'], $members_display_name, 'members_display_name' ) === TRUE )
+ {
+ $this->cache->rebuildCache( 'stats', 'global' );
+
+ return $this->showFormDisplayname( '', $this->lang->words['dname_change_ok'] );
+ }
+ else
+ {
+ # We should absolutely never get here. So this is a fail-safe, really to
+ # prevent a "false" positive outcome for the end-user
+ return array( 0 => $this->lang->words['name_taken_change'] );
+ }
+ }
+ catch( Exception $error )
+ {
+ switch( $error->getMessage() )
+ {
+ case 'NO_MORE_CHANGES':
+ return array( 0 => $this->lang->words['name_change_no_more'] );
+ break;
+ case 'NO_USER':
+ return array( 0 => $this->lang->words['name_change_noload'] );
+ break;
+ case 'NO_PERMISSION':
+ return array( 0 => $this->lang->words['name_change_noperm'] );
+ case 'NO_NAME':
+ return array( 0 => sprintf( $this->lang->words['name_change_tooshort'], $this->settings['max_user_name_length'] ) );
+ break;
+ case 'TOO_LONG':
+ return array( 0 => sprintf( $this->lang->words['name_change_tooshort'], $this->settings['max_user_name_length'] ) );
+ break;
+ case 'ILLEGAL_CHARS':
+ return array( 0 => $this->lang->words['name_change_illegal'] );
+ break;
+ case 'USER_NAME_EXISTS':
+ return array( 0 => $this->lang->words['name_change_taken'] );
+ break;
+ default:
+ return array( 0 => $error->getMessage() );
+ break;
+ }
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * UserCP Save Form: Email Address
+ *
+ * @return mixed Array of errors / boolean true
+ */
+ public function saveFormEmailPassword()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $_emailOne = strtolower( trim($this->request['in_email_1']) );
+ $_emailTwo = strtolower( trim($this->request['in_email_2']) );
+ $cur_pass = trim($this->request['current_pass']);
+ $new_pass = trim($this->request['new_pass_1']);
+ $chk_pass = trim($this->request['new_pass_2']);
+ $isRemote = ( ! $this->memberData['bw_local_password_set'] AND $this->memberData['members_created_remote'] ) ? true : false;
+
+ if ( $cur_pass OR $new_pass )
+ {
+ if( $this->memberData['g_access_cp'] )
+ {
+ return array( 0 => $this->lang->words['admin_emailpassword'] );
+ }
+
+ if ( $isRemote === false AND ( ! $_POST['current_pass'] OR ( empty($new_pass) ) or ( empty($chk_pass) ) ) )
+ {
+ return array( 0 => $this->lang->words['complete_entire_form'] );
+ }
+
+ //-----------------------------------------
+ // Do the passwords actually match?
+ //-----------------------------------------
+
+ if ( $new_pass != $chk_pass )
+ {
+ return array( 0 => $this->lang->words['passwords_not_matchy'] );
+ }
+
+ //-----------------------------------------
+ // Check password...
+ //-----------------------------------------
+
+ if ( $isRemote === false )
+ {
+ if ( $this->_checkPassword( $cur_pass ) !== TRUE )
+ {
+ return array( 0 => $this->lang->words['current_pw_bad'] );
+ }
+ }
+ else
+ {
+ /* This is INIT in _checkPassword */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+ }
+
+ //-----------------------------------------
+ // Create new password...
+ //-----------------------------------------
+
+ $md5_pass = md5($new_pass);
+
+ //-----------------------------------------
+ // han_login was loaded during check_password
+ //-----------------------------------------
+
+ $this->han_login->changePass( $this->memberData['email'], $md5_pass, $new_pass, $this->memberData );
+
+ if ( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
+ {
+ return array( 0 => $this->lang->words['hanlogin_pw_failed'] );
+ }
+
+ //-----------------------------------------
+ // Update the DB
+ //-----------------------------------------
+
+ IPSMember::updatePassword( $this->memberData['email'], $md5_pass );
+
+ IPSLib::runMemberSync( 'onPassChange', $this->memberData['member_id'], $new_pass );
+
+ //-----------------------------------------
+ // Update members log in key...
+ //-----------------------------------------
+
+ $key = IPSMember::generateAutoLoginKey();
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'member_login_key' => $key, 'bw_local_password_set' => 1 ) ) );
+
+ $this->ok_message = $this->lang->words['pw_change_successful'];
+ }
+
+ if ( $_emailOne or $_emailTwo )
+ {
+ //-----------------------------------------
+ // Do not allow validating members to change
+ // email when admin validation is on
+ // @see http://community.invisionpower.com/tracker/issue-19964-loophole-in-registration-procedure/
+ //-----------------------------------------
+
+ if( $this->memberData['member_group_id'] == $this->settings['auth_group'] AND in_array( $this->settings['reg_auth_type'], array( 'admin', 'admin_user' ) ) )
+ {
+ $this->registry->output->showError( $this->lang->words['admin_val_no_email_chg'], 10190 );
+ }
+
+ //-----------------------------------------
+ // Check input
+ //-----------------------------------------
+
+ if( $this->memberData['g_access_cp'] )
+ {
+ return array( 0 => $this->lang->words['admin_emailpassword'] );
+ }
+
+ if ( ! $_POST['in_email_1'] OR ! $_POST['in_email_2'] )
+ {
+ return array( 0 => $this->lang->words['complete_entire_form'] );
+ }
+
+ //-----------------------------------------
+ // Check password...
+ //-----------------------------------------
+
+ if ( ! $this->_isFBUser )
+ {
+ if ( $this->_checkPassword( $this->request['password'] ) === FALSE )
+ {
+ return array( 0 => $this->lang->words['current_pw_bad'] );
+ }
+ }
+
+ //-----------------------------------------
+ // Test email addresses
+ //-----------------------------------------
+
+ if ( $_emailOne != $_emailTwo )
+ {
+ return array( 0 => $this->lang->words['emails_no_matchy'] );
+ }
+
+ if ( IPSText::checkEmailAddress( $_emailOne ) !== TRUE )
+ {
+ return array( 0 => $this->lang->words['email_not_valid'] );
+ }
+
+ //-----------------------------------------
+ // Is this email addy taken?
+ //-----------------------------------------
+
+ if ( IPSMember::checkByEmail( $_emailOne ) == TRUE )
+ {
+ return array( 0 => $this->lang->words['email_is_taken'] );
+ }
+
+ //-----------------------------------------
+ // Load ban filters
+ //-----------------------------------------
+ $banfilters = array();
+ $this->DB->build( array( 'select' => '*', 'from' => 'banfilters' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $banfilters[ $r['ban_type'] ][] = $r['ban_content'];
+ }
+
+ //-----------------------------------------
+ // Check in banned list
+ //-----------------------------------------
+
+ if ( isset($banfilters['email']) AND is_array( $banfilters['email'] ) and count( $banfilters['email'] ) )
+ {
+ foreach ( $banfilters['email'] as $email )
+ {
+ $email = str_replace( '\*', '.*' , preg_quote($email, "/") );
+
+ if ( preg_match( "/^{$email}$/i", $_emailOne ) )
+ {
+ return array( 0 => $this->lang->words['email_is_taken'] );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Load handler...
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+
+ if ( $this->han_login->emailExistsCheck( $_emailOne ) !== FALSE )
+ {
+ return array( 0 => $this->lang->words['email_is_taken'] );
+ }
+
+ $this->han_login->changeEmail( $this->memberData['email'], $_emailOne, $this->memberData );
+
+ if ( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
+ {
+ return array( 0 => $this->lang->words['email_is_taken'] );
+ }
+
+ //-----------------------------------------
+ // Want a new validation? NON ADMINS ONLY
+ //-----------------------------------------
+
+ if ( $this->settings['reg_auth_type'] AND !$this->memberData['g_access_cp'] )
+ {
+ //-----------------------------------------
+ // Remove any existing entries
+ //-----------------------------------------
+
+ $_previous = $this->DB->buildAndFetch( array( 'select' => 'prev_email, real_group', 'from' => 'validating', 'where' => "member_id={$this->memberData['member_id']} AND email_chg=1" ) );
+
+ if( $_previous['prev_email'] )
+ {
+ $this->DB->delete( 'validating', "member_id={$this->memberData['member_id']} AND email_chg=1" );
+
+ $this->memberData['email'] = $_previous['prev_email'];
+ $this->memberData['member_group_id'] = $_previous['real_group'];
+ }
+
+ $validate_key = md5( IPSMember::makePassword() . time() );
+
+ //-----------------------------------------
+ // Update the new email, but enter a validation key
+ // and put the member in "awaiting authorisation"
+ // and send an email..
+ //-----------------------------------------
+
+ $db_str = array(
+ 'vid' => $validate_key,
+ 'member_id' => $this->memberData['member_id'],
+ 'temp_group' => $this->settings['auth_group'],
+ 'entry_date' => time(),
+ 'coppa_user' => 0,
+ 'email_chg' => 1,
+ 'ip_address' => $this->member->ip_address,
+ 'prev_email' => $this->memberData['email'],
+ );
+
+ if ( $this->memberData['member_group_id'] != $this->settings['auth_group'] )
+ {
+ $db_str['real_group'] = $this->memberData['member_group_id'];
+ }
+
+ $this->DB->insert( 'validating', $db_str );
+
+ IPSLib::runMemberSync( 'onEmailChange', $this->memberData['member_id'], strtolower( $_emailOne ), $this->memberData['email'] );
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'member_group_id' => $this->settings['auth_group'],
+ 'email' => $_emailOne ) ) );
+
+ //-----------------------------------------
+ // Update their session with the new member group
+ //-----------------------------------------
+
+ if ( $this->member->session_id )
+ {
+ $this->member->sessionClass()->convertMemberToGuest();
+ }
+
+ //-----------------------------------------
+ // Kill the cookies to stop auto log in
+ //-----------------------------------------
+
+ IPSCookie::set( 'pass_hash' , '-1', 0 );
+ IPSCookie::set( 'member_id' , '-1', 0 );
+ IPSCookie::set( 'session_id' , '-1', 0 );
+
+ //-----------------------------------------
+ // Dispatch the mail, and return to the activate form.
+ //-----------------------------------------
+
+ IPSText::getTextClass( 'email' )->getTemplate("newemail");
+
+ IPSText::getTextClass( 'email' )->buildMessage( array(
+ 'NAME' => $this->memberData['members_display_name'],
+ 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=auto_validate&type=newemail&uid=".$this->memberData['member_id']."&aid=".$validate_key, 'publicNoSession', 'false' ),
+ 'ID' => $this->memberData['member_id'],
+ 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=07", 'publicNoSession', 'false'),
+ 'CODE' => $validate_key,
+ ) );
+
+ IPSText::getTextClass( 'email' )->subject = $this->lang->words['lp_subject'].' '.$this->settings['board_name'];
+ IPSText::getTextClass( 'email' )->to = $_emailOne;
+
+ IPSText::getTextClass( 'email' )->sendMail();
+
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=global§ion=register&do=07' );
+ }
+ else
+ {
+ //-----------------------------------------
+ // No authorisation needed, change email addy and return
+ //-----------------------------------------
+
+ IPSLib::runMemberSync( 'onEmailChange', $this->memberData['member_id'], strtolower( $_emailOne ), $this->memberData['email'] );
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'email' => $_emailOne ) ) );
+
+ //-----------------------------------------
+ // Add to OK message
+ //-----------------------------------------
+
+ $this->ok_message = $this->lang->words['ok_email_changed'];
+ }
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * Password check
+ *
+ * @param string Plain Text Password
+ * @return boolean Password matched or not
+ */
+ protected function _checkPassword( $password_check )
+ {
+ //-----------------------------------------
+ // Ok, check password first
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+
+ //-----------------------------------------
+ // Is this a username or email address?
+ //-----------------------------------------
+
+ $this->han_login->loginPasswordCheck( $this->memberData['name'], $this->memberData['email'], $password_check );
+
+ if ( $this->han_login->return_code == 'SUCCESS' )
+ {
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/extensions/warnings.php b/upload/admin/applications/core/extensions/warnings.php
index 0b941065..0d2a016d 100644
--- a/upload/admin/applications/core/extensions/warnings.php
+++ b/upload/admin/applications/core/extensions/warnings.php
@@ -6,9 +6,9 @@
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: bfarber $ (Original: Mark)
* @since -
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $LastChangedDate: 2013-05-01 17:35:09 -0400 (Wed, 01 May 2013) $
+ * @version v3.4.5
+ * $Revision: 12211 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -49,10 +49,12 @@ class warnings_core
require_once( IPS_ROOT_PATH . 'sources/classes/comments/bootstrap.php' );/*noLibHook*/
$comments = classes_comments_bootstrap::controller( $warning['wl_content_id1'] );
- $parent = $comments->remapFromLocal( $comments->fetchParent( $exploded[0] ), 'parent' );
+ $parent = $comments->fetchParent( $exploded[0] );
- if ( ! empty($parent['parent_id']) )
+ if ( ! is_null($parent) )
{
+ $parent = $comments->remapFromLocal( $parent, 'parent' );
+
return array( 'url' => ipsRegistry::getClass('output')->buildUrl( "app=core&module=global§ion=comments&fromApp={$warning['wl_content_id1']}&do=findComment&parentId={$exploded[0]}&comment_id={$exploded[1]}" ), 'title' => $parent['parent_title'] );
}
}
diff --git a/upload/admin/applications/core/js/IPB3TemplateDiffResults.js b/upload/admin/applications/core/js/IPB3TemplateDiffResults.js
index c8aab7df..4717652c 100644
--- a/upload/admin/applications/core/js/IPB3TemplateDiffResults.js
+++ b/upload/admin/applications/core/js/IPB3TemplateDiffResults.js
@@ -335,11 +335,11 @@ function IPB3TemplateDiffResults()
if ( json['change_data_type'] == 'css' )
{
- content = ''+ _text + ': ' + json['change_data_title'] + '.css ' + json['change_data_content'] + ' ' + _qb + "
";
+ content = ''+ _text + ': ' + json['change_data_title'] + '.css ' + json['change_data_content'] + ' ' + _qb + "
";
}
else
{
- content = ''+ _text + ': ' + json['change_data_group'] + ' > ' + json['change_data_title'] + ' ' + json['change_data_content'] + ' ' + _qb + "
";
+ content = ''+ _text + ': ' + json['change_data_group'] + ' > ' + json['change_data_title'] + ' ' + json['change_data_content'] + ' ' + _qb + "
";
}
max = document.viewport.getHeight();
diff --git a/upload/admin/applications/core/js/acp.homepage.js b/upload/admin/applications/core/js/acp.homepage.js
index 5dec5455..137bab32 100644
--- a/upload/admin/applications/core/js/acp.homepage.js
+++ b/upload/admin/applications/core/js/acp.homepage.js
@@ -20,7 +20,7 @@ ACPHomepage = {
{
if ( $('members_display_name').value == "" )
{
- alert("You must enter a username!");
+ alert("Нужно ввести имя пользователя!");
return false;
}
diff --git a/upload/admin/applications/core/js/ipb3CSS.js b/upload/admin/applications/core/js/ipb3CSS.js
index 3a495205..1ed6490f 100644
--- a/upload/admin/applications/core/js/ipb3CSS.js
+++ b/upload/admin/applications/core/js/ipb3CSS.js
@@ -85,11 +85,11 @@ function IPBCSS()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Похоже у нас проблемы: " + t.responseText );
}
},
- onException: function( f,e ){ alert( "Exception: " + e ); },
- onFailure: function( t ){ alert( "Failure: " + t.responseText ); }
+ onException: function( f,e ){ alert( "Исключение: " + e ); },
+ onFailure: function( t ){ alert( "Ошибка: " + t.responseText ); }
} );
};
@@ -143,7 +143,7 @@ function IPBCSS()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Похоже у нас проблемы: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ); },
@@ -159,14 +159,14 @@ function IPBCSS()
/* Make sure we're mean it... */
if ( $('tplate_cssRow_' + css_id ).hasClassName( 'tplateRow_new') )
{
- if ( ! confirm( "REMOVE CSS file?\n This will remove this template bit in ALL skins!" ) )
+ if ( ! confirm( "Удалить CSS файл ?\nФайл будет удален из ВСЕХ стилей!" ) )
{
return false;
}
}
else
{
- if ( ! confirm( "Revert CSS file?\n All changes WILL be lost!" ) )
+ if ( ! confirm( "Отменить изменения в CSS файле ?\nВсе изменения будут утеряны!" ) )
{
return false;
}
@@ -202,7 +202,7 @@ function IPBCSS()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Похоже у нас проблемы: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ); },
@@ -239,7 +239,7 @@ function IPBCSS()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Похоже у нас проблемы: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ); },
diff --git a/upload/admin/applications/core/js/ipb3TemplateDiff.js b/upload/admin/applications/core/js/ipb3TemplateDiff.js
index 763895f8..a075ddbe 100644
--- a/upload/admin/applications/core/js/ipb3TemplateDiff.js
+++ b/upload/admin/applications/core/js/ipb3TemplateDiff.js
@@ -217,14 +217,14 @@ function IPBTemplateDiff()
*/
this.timeOutAjax = function( t )
{
- if ( confirm( "No response from the webserver.\nDo you wish to continue waiting?" ) )
+ if ( confirm( "Нет ответа от сервера.\nХотите подождать?" ) )
{
return true;
}
else
{
t.transport.abort();
- alert( "Request Cancelled" );
+ alert( "Запрос отменен" );
}
};
@@ -265,7 +265,7 @@ function IPBTemplateDiff()
if ( json['error'] )
{
- alert( "An error occurred: " . json['error'] );
+ alert( "Ошибка: " . json['error'] );
return false;
}
diff --git a/upload/admin/applications/core/js/ipb3TemplateSandR.js b/upload/admin/applications/core/js/ipb3TemplateSandR.js
index db5fd81b..734ad4a4 100644
--- a/upload/admin/applications/core/js/ipb3TemplateSandR.js
+++ b/upload/admin/applications/core/js/ipb3TemplateSandR.js
@@ -166,7 +166,7 @@ function IPBTemplateSandR()
else
{
$('replaceButton').disabled = false;
- $('replaceButton').value = "Replace Selected";
+ $('replaceButton').value = "Заменить выбранные";
}
}
}
diff --git a/upload/admin/applications/core/js/ipb3Templates.js b/upload/admin/applications/core/js/ipb3Templates.js
index 0ebda002..1ae5c716 100644
--- a/upload/admin/applications/core/js/ipb3Templates.js
+++ b/upload/admin/applications/core/js/ipb3Templates.js
@@ -103,7 +103,7 @@ function IPBTemplates()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Ошибка: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ); },
@@ -169,7 +169,7 @@ function IPBTemplates()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Ошибка: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ); },
@@ -222,7 +222,7 @@ function IPBTemplates()
if ( json['errors'] )
{
/* Something inline would be very nice here.. rather than this ugly alert */
- alert("Error:: " + json['errors'] );
+ alert("Ошибка: " + json['errors'] );
}
else
{
@@ -232,7 +232,7 @@ function IPBTemplates()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Ошибка: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ); },
@@ -248,14 +248,14 @@ function IPBTemplates()
/* Make sure we're mean it... */
if ( $('tplate_templaterow_' + template_id ).hasClassName( 'tplateRow_new') )
{
- if ( ! confirm( "REMOVE template bit?\n This will remove this template bit in ALL skins!" ) )
+ if ( ! confirm( "Удалить шаблон?\n Произойдет удаление шаблона из ВСЕХ стилей!" ) )
{
return false;
}
}
else
{
- if ( ! confirm( "Revert template bit?\n All changes WILL be lost!" ) )
+ if ( ! confirm( "Откатить изменения?\n Все изменения БУДУТ УТРАЧЕНЫ!" ) )
{
return false;
}
@@ -301,7 +301,7 @@ function IPBTemplates()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Ошибка: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ); },
@@ -338,7 +338,7 @@ function IPBTemplates()
}
else
{
- alert( "Ooops. Something went wrong. Does this help?: " + t.responseText );
+ alert( "Ошибка: " + t.responseText );
}
},
onException: function( f,e ){ alert( "Exception: " + e ); },
diff --git a/upload/admin/applications/core/modules_admin/ajax/bookmarks.php b/upload/admin/applications/core/modules_admin/ajax/bookmarks.php
new file mode 100644
index 00000000..c545e7e4
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/ajax/bookmarks.php
@@ -0,0 +1,138 @@
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+/**
+ *
+ * @class AJAX storage of bookmarks
+ * @brief AJAX storage of tab order preference
+ *
+ */
+class admin_core_ajax_bookmarks extends ipsAjaxCommand
+{
+ private $_classBookmark;
+
+ /**
+ * Main function executed automatically by the controller
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ $registry->getClass('class_localization')->loadLanguageFile( array( 'admin_global' ), 'core' );
+
+ require_once( IPS_ROOT_PATH . 'sources/classes/admin/bookmarks.php' );
+ $this->_classBookmark = new classes_admin_bookmarks();
+
+ //-----------------------------------------
+ // What shall we do?
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ default:
+ case 'add':
+ $this->_add();
+ break;
+ case 'managePane':
+ $this->_managePane();
+ break;
+ case 'delete':
+ $this->_delete();
+ break;
+ case 'save':
+ $this->_save();
+ break;
+ }
+ }
+
+ /**
+ * Save all from manage screen
+ */
+ protected function _save()
+ {
+ $home = intval( $this->request['home'] );
+ $names = $_POST['names'];
+ $position = array();
+
+ if ( is_array( $_GET['bookmark'] ) )
+ {
+ foreach( $_GET['bookmark'] as $id )
+ {
+ $position[ $id ] = count( $position ) + 1;
+ }
+ }
+
+ if ( is_array( $names ) )
+ {
+ foreach( $names as $id => $name )
+ {
+ $this->_classBookmark->update( $id, array( 'title' => $name, 'position' => intval( $position[ $id ] ) ) );
+ }
+ }
+
+ $this->_classBookmark->setAsHome( $home );
+
+ $this->returnJsonArray( array( 'status' => 'ok', 'json' => json_decode( $this->_classBookmark->asJson(), true ) ) );
+ }
+
+ /**
+ * Remove a book mark
+ */
+ protected function _delete()
+ {
+ $id = intval( $this->request['id'] );
+
+ $this->_classBookmark->removeBookmark( $id );
+
+ $this->returnJsonArray( array( 'status' => 'ok', 'json' => json_decode( $this->_classBookmark->asJson(), true ) ) );
+ }
+
+ /**
+ * Manage panel
+ */
+ protected function _managePane()
+ {
+ $bookmarks = $this->_classBookmark->getBookmarks();
+
+ /* Return it then */
+ $this->returnHtml( $this->registry->output->global_template->manageBookmarks( $bookmarks ) );
+ }
+
+ /**
+ * Add a book mark
+ */
+ protected function _add()
+ {
+ $title = $this->request['title'];
+ $url = $this->request['url'];
+ $home = intval( $this->request['home'] );
+
+ try
+ {
+ $this->_classBookmark->addBookmark( $url, $title, $home );
+
+ $this->returnJsonArray( array( 'status' => 'ok', 'json' => json_decode( $this->_classBookmark->asJson(), true ) ) );
+ }
+ catch( Exception $err )
+ {
+ $this->returnJsonArray( array( 'status' => 'fail', 'msg' => $err->getMessage() ) );
+ }
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/ajax/compare.php b/upload/admin/applications/core/modules_admin/ajax/compare.php
index 2bdb5544..b4635ffc 100644
--- a/upload/admin/applications/core/modules_admin/ajax/compare.php
+++ b/upload/admin/applications/core/modules_admin/ajax/compare.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Template comparison
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
diff --git a/upload/admin/applications/core/modules_admin/ajax/css.php b/upload/admin/applications/core/modules_admin/ajax/css.php
index 23232e51..078e7399 100644
--- a/upload/admin/applications/core/modules_admin/ajax/css.php
+++ b/upload/admin/applications/core/modules_admin/ajax/css.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* AJAX Functions For applications/core/js/ipb3CSS.js file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
diff --git a/upload/admin/applications/core/modules_admin/ajax/editor.php b/upload/admin/applications/core/modules_admin/ajax/editor.php
new file mode 100644
index 00000000..9b3bbbd2
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/ajax/editor.php
@@ -0,0 +1,31 @@
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Handles Admin ajax functions for IP.Board Text Editor
+ * Author: Matt "Matt Mecham" Mecham
+ * Last Updated: $LastChangedDate: 2012-05-29 14:05:10 +0100 (Tue, 29 May 2012) $
+ *
+ *
+ * @author $Author: AndyMillne $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Gallery
+ * @link http://www.invisionpower.com
+ * @version $Rev: 10807 $
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+require_once( IPSLib::getAppDir('core') . '/modules_public/ajax/editor.php' );
+
+class admin_core_ajax_editor extends public_core_ajax_editor
+{
+
+}
diff --git a/upload/admin/applications/core/modules_admin/ajax/findnames.php b/upload/admin/applications/core/modules_admin/ajax/findnames.php
index b0456dd0..93d59988 100644
--- a/upload/admin/applications/core/modules_admin/ajax/findnames.php
+++ b/upload/admin/applications/core/modules_admin/ajax/findnames.php
@@ -1,115 +1,115 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Login handler abstraction : AJAX Find Names functions
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since Tuesday 1st March 2005 (11:52)
- * @version $Revision: 10914 $
- * @see public_core_ajax_findnames
- *
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class admin_core_ajax_findnames extends ipsAjaxCommand
-{
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- switch( $this->request['do'] )
- {
- case 'get-member-names':
- $this->_getMemberNames();
- break;
- }
- }
-
- /**
- * Returns possible matches for the string input
- *
- * @return @e void Outputs to screen
- */
- protected function _getMemberNames()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $name = IPSText::convertUnicode( $this->convertAndMakeSafe( $this->request['name'], 0 ), true );
- $name = IPSText::convertCharsets( $name, 'utf-8', IPS_DOC_CHAR_SET );
-
- //-----------------------------------------
- // Check length
- //-----------------------------------------
-
- if ( IPSText::mbstrlen( $name ) < 3 )
- {
- $this->returnJsonError( 'requestTooShort' );
- }
-
- //-----------------------------------------
- // Try query...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'm.members_display_name, m.name, m.member_id, m.member_group_id',
- 'from' => array( 'members' => 'm' ),
- 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes( strtolower( $name ) ) . "%'",
- 'order' => $this->DB->buildLength( 'm.members_display_name' ) . ' ASC',
- 'limit' => array( 0, 15 ),
- 'add_join' => array( array( 'select' => 'p.*',
- 'from' => array( 'profile_portal' => 'p' ),
- 'where' => 'p.pp_member_id=m.member_id',
- 'type' => 'left' ) ) ) );
- $this->DB->execute();
-
- //-----------------------------------------
- // Got any results?
- //-----------------------------------------
-
- if ( ! $this->DB->getTotalRows() )
- {
- $this->returnJsonArray( array( ) );
- }
-
- $return = array();
-
- while( $r = $this->DB->fetch() )
- {
- if( !$r['members_display_name'] )
- {
- continue;
- }
-
- $photo = IPSMember::buildProfilePhoto( $r );
- $group = IPSMember::makeNameFormatted( '' , $r['member_group_id'] );
- $return[ $r['member_id'] ] = array( 'name' => $r['members_display_name'],
- 'showas'=> '' . $r['members_display_name'] . ' (' . $group . ')',
- 'img' => $photo['pp_mini_photo'],
- 'img_w' => $photo['pp_mini_width'],
- 'img_h' => $photo['pp_mini_height']
- );
- }
-
- $this->returnJsonArray( $return );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Login handler abstraction : AJAX Find Names functions
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since Tuesday 1st March 2005 (11:52)
+ * @version $Revision: 10721 $
+ * @see public_core_ajax_findnames
+ *
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class admin_core_ajax_findnames extends ipsAjaxCommand
+{
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ switch( $this->request['do'] )
+ {
+ case 'get-member-names':
+ $this->_getMemberNames();
+ break;
+ }
+ }
+
+ /**
+ * Returns possible matches for the string input
+ *
+ * @return @e void Outputs to screen
+ */
+ protected function _getMemberNames()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $name = IPSText::convertUnicode( $this->convertAndMakeSafe( $this->request['name'], 0 ), true );
+ $name = IPSText::convertCharsets( $name, 'utf-8', IPS_DOC_CHAR_SET );
+
+ //-----------------------------------------
+ // Check length
+ //-----------------------------------------
+
+ if ( IPSText::mbstrlen( $name ) < 3 )
+ {
+ $this->returnJsonError( 'requestTooShort' );
+ }
+
+ //-----------------------------------------
+ // Try query...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'm.members_display_name, m.name, m.member_id, m.member_group_id',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes( mb_strtolower( $name ) ) . "%'",
+ 'order' => $this->DB->buildLength( 'm.members_display_name' ) . ' ASC',
+ 'limit' => array( 0, 15 ),
+ 'add_join' => array( array( 'select' => 'p.*',
+ 'from' => array( 'profile_portal' => 'p' ),
+ 'where' => 'p.pp_member_id=m.member_id',
+ 'type' => 'left' ) ) ) );
+ $this->DB->execute();
+
+ //-----------------------------------------
+ // Got any results?
+ //-----------------------------------------
+
+ if ( ! $this->DB->getTotalRows() )
+ {
+ $this->returnJsonArray( array( ) );
+ }
+
+ $return = array();
+
+ while( $r = $this->DB->fetch() )
+ {
+ if( !$r['members_display_name'] )
+ {
+ continue;
+ }
+
+ $photo = IPSMember::buildProfilePhoto( $r );
+ $group = IPSMember::makeNameFormatted( '' , $r['member_group_id'] );
+ $return[ $r['member_id'] ] = array( 'name' => $r['members_display_name'],
+ 'showas'=> '' . $r['members_display_name'] . ' (' . $group . ')',
+ 'img' => $photo['pp_mini_photo'],
+ 'img_w' => $photo['pp_mini_width'],
+ 'img_h' => $photo['pp_mini_height']
+ );
+ }
+
+ $this->returnJsonArray( $return );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/ajax/hooks.php b/upload/admin/applications/core/modules_admin/ajax/hooks.php
index d0e88803..e84e48b2 100644
--- a/upload/admin/applications/core/modules_admin/ajax/hooks.php
+++ b/upload/admin/applications/core/modules_admin/ajax/hooks.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Hooks (AJAX)
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-02-15 17:36:04 -0500 (Fri, 15 Feb 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 1st march 2002
- * @version $Revision: 10914 $
+ * @version $Revision: 11998 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -208,7 +208,7 @@ class admin_core_ajax_hooks extends ipsAjaxCommand
/* Return data ;o */
$minVersions = $this->registry->output->formDropdown( "minVersion[{$i}]", $versions );
- $maxVersions = $this->registry->output->formDropdown( "minVersion[{$i}]", $versions );
+ $maxVersions = $this->registry->output->formDropdown( "maxVersion[{$i}]", $versions );
$this->returnHtml( "{$this->lang->words['a_min']}: {$minVersions} {$this->lang->words['a_max']}: {$maxVersions}" );
}
diff --git a/upload/admin/applications/core/modules_admin/ajax/livesearch.php b/upload/admin/applications/core/modules_admin/ajax/livesearch.php
index 4f84c922..205186a8 100644
--- a/upload/admin/applications/core/modules_admin/ajax/livesearch.php
+++ b/upload/admin/applications/core/modules_admin/ajax/livesearch.php
@@ -1,566 +1,566 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Live Search
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @version $Rev: 10914 $
- *
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class admin_core_ajax_livesearch extends ipsAjaxCommand
-{
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- //-----------------------------------------
- // Load skin
- //-----------------------------------------
- $this->registry->class_localization->loadLanguageFile( array( 'admin_ajax' ) );
-
- /* What to do */
- switch( $this->request['do'] )
- {
- default:
- case 'search':
- $this->doSearchRequest();
- break;
- }
- }
-
- /**
- * Handles the live search
- *
- * @return @e void
- */
- public function doSearchRequest()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $search_term = IPSText::convertCharsets( $this->request['search_term'], 'utf-8', IPS_DOC_CHAR_SET );
- $results = array();
- $results = array( 'members' => array(), 'groups' => array(), 'groupLangs' => false, 'settings' => array(), 'forums' => array(), 'location' => array() );
-
- if ( IPSLib::appIsInstalled('nexus') )
- {
- $results['nexus'] = array();
- }
-
- //-----------------------------------------
- // Search
- //-----------------------------------------
-
- $results = $this->_getSettings( $search_term, $results );
- $results = $this->_getFromXML( $search_term, $results );
- $results = $this->_getMembers( $search_term, $results );
- $results = $this->_checkGroups( $search_term, $results );
- $results = $this->_checkForums( $search_term, $results );
-
- if ( IPSLib::appIsInstalled('nexus') )
- {
- $results = $this->_checkNexus( $search_term, $results );
- }
-
- //-----------------------------------------
- // Output
- //-----------------------------------------
-
- $this->returnJsonArray( $results );
- }
-
- /**
- * Searches for matching members
- *
- * @param string Search term
- * @param array Existing search results
- * @return array New search results
- */
- protected function _getMembers( $term, $results )
- {
- if ( !$this->registry->getClass('class_permissions')->checkPermission( 'member_edit', 'members', 'members' ) )
- {
- $results['members'] = array();
- return $results;
- }
-
- $term = strtolower($term);
-
- $this->DB->build( array('select' => 'm.*, pp.*, g.g_title',
- 'from' => array('members' => 'm'),
- 'where' => "members_l_username LIKE '%{$term}%' OR members_l_display_name LIKE '%{$term}%' OR " . $this->DB->buildLower('email') . " LIKE '%{$term}%'",
- 'limit' => array(0, 250 ),
- 'add_join' => array( array( 'from' => array( 'groups' => 'g' ),
- 'where' => 'g.g_id=m.member_group_id',
- 'type' => 'left' ),
- array( 'from' => array( 'profile_portal' => 'pp' ),
- 'where' => 'pp.pp_member_id=m.member_id',
- 'type' => 'left' ) )
- ) );
-
- $this->DB->execute();
-
- while( $member = $this->DB->fetch() )
- {
- $_matched = '';
- $member = $r = IPSMember::buildProfilePhoto( $member );
- $r = array();
-
- if( $member['members_l_display_name'] AND strpos( $term, $member['members_l_display_name'] ) !== false )
- {
- $r['_matched'] = 'members_display_name';
- }
- else if( $member['members_l_username'] AND strpos( $term, $member['members_l_username'] ) !== false )
- {
- $r['_matched'] = 'name';
- }
- else
- {
- $r['_matched'] = 'email';
- }
-
- $r['name'] = $member['members_display_name'];
- $r['extra'] = $member['g_title'];
- $r['img'] = $member['pp_mini_photo'];
- $r['url'] = $this->settings['_base_url']."&app=members&module=members§ion=members&do=viewmember&member_id=".$member['member_id'];
-
- /* Trim out what we don't need */
-
- $results['members'][] = $r;
- }
-
- return $results;
- }
-
- /**
- * Check if search term is found in groups language file or in the group_cache.g_title
- *
- * @param string Search term
- * @param array Existing search results
- * @return array New search results
- */
- protected function _checkGroups( $term, $results )
- {
- if ( !$this->registry->getClass('class_permissions')->checkPermission( 'groups_edit', 'members', 'groups' ) )
- {
- $results['groups'] = array();
- return $results;
- }
-
- $term = strtolower($term);
-
- $this->registry->class_localization->loadLanguageFile( array( 'admin_groups' ), 'members' );
- $this->registry->class_localization->loadLanguageFile( array( 'admin_forums' ), 'forums' );
- $this->registry->class_localization->loadLanguageFile( array( 'admin_gallery' ), 'gallery' );
- $this->registry->class_localization->loadLanguageFile( array( 'admin_blog' ), 'blog' );
- $this->registry->class_localization->loadLanguageFile( array( 'admin_downloads' ), 'downloads' );
-
- foreach( $this->lang->words as $k => $v )
- {
- if( strpos( $k, 'gf_' ) !== false AND strpos( $v, $term ) !== false )
- {
- IPSDebug::fireBug( 'info', array( 'Group key found: ' . $k . ': ' . $v ) );
-
- $results['groupLangs'] = true;
- break;
- }
- }
-
- /* Now check group names */
- $groups = $this->cache->getCache('group_cache');
-
- if ( is_array( $groups ) AND count( $groups ) )
- {
- foreach( $groups as $id => $data )
- {
- $_term = preg_quote( $term, '#' );
-
- if ( preg_match( "#" . $_term . "#i", $data['g_title'] ) )
- {
- $results['groups'][] = array(
- 'name' => IPSMember::makeNameFormatted( $data['g_title'], $data['g_id'] ),
- 'url' => $this->settings['_base_url'] . "&app=members&module=groups§ion=groups&do=edit&id=" . $data['g_id'],
- );
- }
- }
- }
-
- return $results;
- }
-
- /**
- * Check if search term is found in groups language file
- *
- * @param string Search term
- * @param array Existing search results
- * @return array New search results
- */
- protected function _checkForums( $term, $results )
- {
- if ( !$this->registry->getClass('class_permissions')->checkPermission( 'forums_edit', 'forums', 'forums' ) )
- {
- $results['forums'] = array();
- return $results;
- }
-
- $term = strtolower($term);
- $results['forums'] = false;
-
- /* Fetch forums lib */
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums' );
- $forums = new $classToLoad( $this->registry );
- $forums->strip_invisible = 1;
- $forums->forumsInit();
-
- /* Now check forum titles names */
- foreach( $forums->forum_by_id as $id => $data )
- {
- $_term = preg_quote( $term, '#' );
-
- if ( preg_match( "#" . $_term . "#i", $data['name'] ) )
- {
- $data['extra'] = ( ( $data['posts'] == null ) ? 0 : $data['posts'] ) . " posts";
- $data['url'] = $this->settings['_base_url']."&app=forums&module=forums§ion=forums&do=edit&f=".$data['id'];
- $results['forums'][] = $data;
- }
- }
-
- return $results;
- }
-
- /**
- * Searches the settings table
- *
- * @param string Search term
- * @param array Existing search results
- * @return array New search results
- */
- protected function _getSettings( $term, $results )
- {
- if ( !$this->registry->getClass('class_permissions')->checkPermission( 'settings_manage', 'core', 'settings' ) )
- {
- $results['settings'] = array();
- return $results;
- }
-
- $term = strtolower($term);
-
- if( !IN_DEV )
- {
- $this->DB->build( array( 'select' => 'c.conf_group, c.conf_title, c.conf_description, c.conf_keywords',
- 'from' => array( 'core_sys_conf_settings' => 'c' ),
- 'where' => 't.conf_title_noshow=0 AND (' . $this->DB->buildLower('c.conf_title') . " LIKE '%{$term}%' OR ". $this->DB->buildLower('c.conf_description') . " LIKE '%{$term}%' OR " . $this->DB->buildLower('c.conf_keywords') . " LIKE '%{$term}%')",
- 'add_join' => array( array( 'from' => array( 'core_sys_settings_titles' => 't' ),
- 'where' => 't.conf_title_id=c.conf_group',
- 'type' => 'left' ) )
- ) );
- }
- else
- {
- $this->DB->build( array( 'select' => 'conf_group, conf_title, conf_description, conf_keywords',
- 'from' => 'core_sys_conf_settings',
- 'where' => $this->DB->buildLower('conf_title') . " LIKE '%{$term}%' OR ". $this->DB->buildLower('conf_description') . " LIKE '%{$term}%' OR " . $this->DB->buildLower('conf_keywords') . " LIKE '%{$term}%'",
- ) );
- }
-
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $r['name'] = $r['conf_title'];
- $r['url'] = $this->settings['_base_url']."&app=core&module=settings§ion=settings&do=setting_view&conf_group=" . $r['conf_group'] . "&search=" . $this->request['search_term'];
-
- $results['settings'][] = $r;
- }
-
- return $results;
- }
-
- /**
- * Searches Nexus
- *
- * @param string Search term
- * @param array Existing search results
- * @return array New search results
- */
- protected function _checkNexus( $term, $results )
- {
- if ( !$this->registry->getClass('class_permissions')->checkForAppAccess('nexus') )
- {
- $results['nexus'] = array();
- return $results;
- }
-
- $textTerm = $this->DB->addSlashes( strtolower( $term ) );
- $intTerm = intval( $term );
- $encodedTerm = urlencode( $encodedTerm );
-
- $tempResults = array();
-
- require_once( IPSLib::getAppDir('nexus') . '/sources/customer.php' );/*noLibHook*/
-
- //-----------------------------------------
- // Is it a number?
- //-----------------------------------------
-
- if ( (string) $term == (string) $intTerm )
- {
- /* Invoice? */
- if ( $this->registry->getClass('class_permissions')->checkPermission( 'invoices_manage', 'nexus', 'payments' ) )
- {
- $invoice = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_invoices', 'where' => "i_id={$intTerm}" ) );
- if ( $invoice['i_id'] )
- {
- $tempResults['invoice'] = array( 'name' => $invoice['i_title'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=invoices&do=view_invoice&id={$invoice['i_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/invoice.png' );
- }
- }
-
- /* Purchase? */
- if ( $this->registry->getClass('class_permissions')->checkPermission( 'purchases_view', 'nexus', 'payments' ) )
- {
- $purchase = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_purchases', 'where' => "ps_id={$intTerm}" ) );
- if ( $purchase['ps_id'] )
- {
- $tempResults['purchase'] = array( 'name' => $purchase['ps_name'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=purchases&id={$purchase['ps_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/purchase.png' );
- }
- }
-
- /* Support */
- if ( $this->registry->getClass('class_permissions')->checkPermission( 'sr_view', 'nexus', 'tickets' ) )
- {
- $support = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_support_requests', 'where' => "r_id={$intTerm}" ) );
- if ( $support['r_id'] )
- {
- $tempResults['support'] = array( 'name' => $support['r_title'], 'url' => $this->settings['_base_url']."&app=nexus&module=tickets§ion=view&id={$support['r_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/support.png' );
- }
- }
-
- /* Customer */
- if ( $this->registry->getClass('class_permissions')->checkForModuleAccess( 'nexus', 'customers' ) )
- {
- $customer = $this->DB->buildAndFetch( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'where' => "member_id={$intTerm}" ) );
- if ( $customer['member_id'] )
- {
- if ( !preg_replace( '/\s/', '', $customer['members_display_name'] ) )
- {
- $customer['members_display_name'] = '?????';
- }
-
- $tempResults['member'] = array( 'name' => $customer['members_display_name'], 'url' => $this->settings['_base_url']."&app=nexus&module=customers§ion=view&id={$customer['member_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
- }
- }
-
- /* Transaction? */
- if ( $this->registry->getClass('class_permissions')->checkPermission( 'transactions_manage', 'nexus', 'payments' ) )
- {
- $transaction = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_transactions', 'where' => "t_id={$intTerm}" ) );
- if ( $transaction['t_id'] )
- {
- $tempResults['transactions'] = array( 'name' => $transaction['t_id'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=transactions&do=view&id={$transaction['i_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/transaction.png' );
- }
- }
-
- }
-
- //-----------------------------------------
- // Nope - text
- //-----------------------------------------
-
- else
- {
- /* License Key */
- if ( $this->registry->getClass('class_permissions')->checkPermission( 'purchases_view', 'nexus', 'payments' ) )
- {
- $lkey = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_licensekeys', 'where' => $this->DB->buildLower('lkey_key') ."='{$textTerm}'" ) );
- if ( $lkey['lkey_key'] )
- {
- $tempResults['lkey'] = array( 'name' => $lkey['lkey_key'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=purchases&id={$lkey['lkey_purchase']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/lkey.png' );
- }
- }
-
- /* Customers */
- if ( $this->registry->getClass('class_permissions')->checkForModuleAccess( 'nexus', 'customers' ) )
- {
- $customer = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'members', 'where' => $this->DB->buildLower('email') ." LIKE '%{$textTerm}%'" ) );
- if ( $customer['count'] )
- {
- if ( $customer['count'] > 50 )
- {
- $tempResults['member'] = array( 'name' => sprintf( $this->lang->words['livesearch_more'], $customer['count'] ), 'url' => "{$this->settings['base_url']}app=nexus&module=customers§ion=search&searchpag=1&option=email&criteria=contains&value={$encodedTerm}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
-
- }
- else
- {
- $this->DB->build( array( 'select' => 'member_id, email', 'from' => 'members', 'where' => $this->DB->buildLower('email') ." LIKE '%{$textTerm}%'" ) );
- $this->DB->execute();
- while ( $row = $this->DB->fetch() )
- {
- $tempResults['member'][] = array( 'name' => $row['email'], 'url' => $this->settings['_base_url']."&app=nexus&module=customers§ion=view&id={$row['member_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
- }
- }
- }
-
- $customer = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'members', 'where' => "members_l_display_name LIKE '%{$textTerm}%'" ) );
- if ( $customer['count'] )
- {
- if ( $customer['count'] > 50 )
- {
- $tempResults['member'] = array( 'name' => sprintf( $this->lang->words['livesearch_more'], $customer['count'] ), 'url' => "{$this->settings['base_url']}app=nexus&module=customers§ion=search&searchpag=1&option=email&criteria=contains&value={$encodedTerm}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
-
- }
- else
- {
- $this->DB->build( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'where' => "members_l_display_name LIKE '%{$textTerm}%'" ) );
- $this->DB->execute();
- while ( $row = $this->DB->fetch() )
- {
- $tempResults['member'][] = array( 'name' => $row['members_display_name'], 'url' => $this->settings['_base_url']."&app=nexus&module=customers§ion=view&id={$row['member_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
- }
- }
- }
- }
-
- /* Hosting Accounts */
- if ( $this->registry->getClass('class_permissions')->checkPermission( 'purchases_view', 'nexus', 'payments' ) )
- {
- if ( strpos( $textTerm, '.' ) === FALSE )
- {
- $hosting = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'nexus_hosting_accounts', 'where' => $this->DB->buildLower('account_username') . " LIKE '%{$textTerm}%'" ) );
- if ( $hosting['count'] )
- {
- if ( $hosting['count'] > 50 )
- {
- $tempResults['hosting'] = array( 'name' => sprintf( $this->lang->words['livesearch_more'], $customer['count'] ), 'url' => "&app=nexus&module=search§ion=search&nexus_search={$encodedTerm}&nexus_searchby=username", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/nexus_icons/hosting.png' );
-
- }
- else
- {
- $this->DB->build( array( 'select' => 'ps_id, account_username', 'from' => 'nexus_hosting_accounts', 'where' => $this->DB->buildLower('account_username') . " LIKE '%{$textTerm}%'" ) );
- $this->DB->execute();
- while ( $row = $this->DB->fetch() )
- {
- $tempResults['hosting'][] = array( 'name' => $row['account_username'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=purchases&id={$row['ps_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/nexus_icons/hosting.png' );
- }
- }
- }
- }
- if ( empty( $tempResults['hosting'] ) )
- {
- $hosting = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'nexus_hosting_accounts', 'where' => $this->DB->buildLower('account_domain') . " LIKE '%{$textTerm}%'" ) );
- if ( $hosting['count'] )
- {
- if ( $hosting['count'] > 50 )
- {
- $tempResults['hosting'] = array( 'name' => sprintf( $this->lang->words['livesearch_more'], $customer['count'] ), 'url' => "&app=nexus&module=search§ion=search&nexus_search={$encodedTerm}&nexus_searchby=domain", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
-
- }
- else
- {
- $this->DB->build( array( 'select' => 'ps_id, account_domain', 'from' => 'nexus_hosting_accounts', 'where' => $this->DB->buildLower('account_domain') . " LIKE '%{$textTerm}%'" ) );
- $this->DB->execute();
- while ( $row = $this->DB->fetch() )
- {
- $tempResults['hosting'][] = array( 'name' => $row['account_domain'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=purchases&id={$row['ps_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/nexus_icons/hosting.png' );
- }
- }
- }
- }
- }
- }
-
- //-----------------------------------------
- // Return results
- //-----------------------------------------
-
-
- foreach ( array( 'invoice', 'purchase', 'transactions', 'lkey', 'support', 'member', 'hosting' ) as $k )
- {
- if ( isset( $tempResults[ $k ] ) )
- {
- if ( isset( $tempResults[ $k ][0] ) )
- {
- foreach ( $tempResults[ $k ] as $l )
- {
- $results['nexus'][] = $l;
- }
- }
- else
- {
- $results['nexus'][] = $tempResults[ $k ];
- }
- }
- }
-
- return $results;
- }
-
- /**
- * Searches the XML Files
- *
- * @param string Search term
- * @param array Existing search results
- * @return array New search results
- */
- protected function _getFromXML( $term, $results )
- {
- foreach( $this->cache->getCache('app_menu_cache') as $app => $cache )
- {
- if( IPSLib::appIsInstalled( $app ) and $this->registry->getClass('class_permissions')->checkForAppAccess( $app ) )
- {
- foreach( $cache as $entry )
- {
- if( count($entry['items']) )
- {
- foreach( $entry['items'] as $item )
- {
- if ( $this->registry->getClass('class_permissions')->checkForModuleAccess( $app, $item['module'] ) and ( !$item['rolekey'] or $this->registry->getClass('class_permissions')->checkPermission( $item['rolekey'], $app, $item['module'] ) ) )
- {
- if( $item['section'] )
- {
- $item['url'] = "section={$item['section']}&" . $item['url'];
- }
-
- if( isset($item['keywords']) AND stripos( $item['keywords'], $term ) !== false )
- {
- $item['name'] = $item['title'];
- $item['url'] = $this->settings['_base_url']."&app={$app}&module={$item['module']}&{$item['url']}";
- $results['location'][] = $item;
- }
- else if( stripos( $item['title'], $term ) !== false )
- {
- $item['name'] = $item['title'];
- $item['url'] = $this->settings['_base_url']."&app={$app}&module={$item['module']}&{$item['url']}";
- $results['location'][] = $item;
- }
- }
- }
- }
- }
- }
- }
-
- return $results;
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Live Search
+ * Last Updated: $Date: 2012-12-06 10:19:49 -0500 (Thu, 06 Dec 2012) $
+ *
+ *
+ * @author $Author: mark $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @version $Rev: 11685 $
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class admin_core_ajax_livesearch extends ipsAjaxCommand
+{
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ //-----------------------------------------
+ // Load skin
+ //-----------------------------------------
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_ajax' ) );
+
+ /* What to do */
+ switch( $this->request['do'] )
+ {
+ default:
+ case 'search':
+ $this->doSearchRequest();
+ break;
+ }
+ }
+
+ /**
+ * Handles the live search
+ *
+ * @return @e void
+ */
+ public function doSearchRequest()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $search_term = IPSText::convertCharsets( $this->request['search_term'], 'utf-8', IPS_DOC_CHAR_SET );
+ $results = array();
+ $results = array( 'members' => array(), 'groups' => array(), 'groupLangs' => false, 'settings' => array(), 'forums' => array(), 'location' => array() );
+
+ if ( IPSLib::appIsInstalled('nexus') )
+ {
+ $results['nexus'] = array();
+ }
+
+ //-----------------------------------------
+ // Search
+ //-----------------------------------------
+
+ $results = $this->_getSettings( $search_term, $results );
+ $results = $this->_getFromXML( $search_term, $results );
+ $results = $this->_getMembers( $search_term, $results );
+ $results = $this->_checkGroups( $search_term, $results );
+ $results = $this->_checkForums( $search_term, $results );
+
+ if ( IPSLib::appIsInstalled('nexus') )
+ {
+ $results = $this->_checkNexus( $search_term, $results );
+ }
+
+ //-----------------------------------------
+ // Output
+ //-----------------------------------------
+
+ $this->returnJsonArray( $results );
+ }
+
+ /**
+ * Searches for matching members
+ *
+ * @param string Search term
+ * @param array Existing search results
+ * @return array New search results
+ */
+ protected function _getMembers( $term, $results )
+ {
+ if ( !$this->registry->getClass('class_permissions')->checkPermission( 'member_edit', 'members', 'members' ) )
+ {
+ $results['members'] = array();
+ return $results;
+ }
+
+ $term = mb_strtolower($term);
+
+ $this->DB->build( array('select' => 'm.*, pp.*, g.g_title',
+ 'from' => array('members' => 'm'),
+ 'where' => "members_l_username LIKE '%{$term}%' OR members_l_display_name LIKE '%{$term}%' OR " . $this->DB->buildLower('email') . " LIKE '%{$term}%'",
+ 'limit' => array(0, 250 ),
+ 'add_join' => array( array( 'from' => array( 'groups' => 'g' ),
+ 'where' => 'g.g_id=m.member_group_id',
+ 'type' => 'left' ),
+ array( 'from' => array( 'profile_portal' => 'pp' ),
+ 'where' => 'pp.pp_member_id=m.member_id',
+ 'type' => 'left' ) )
+ ) );
+
+ $this->DB->execute();
+
+ while( $member = $this->DB->fetch() )
+ {
+ $_matched = '';
+ $member = $r = IPSMember::buildProfilePhoto( $member );
+ $r = array();
+
+ if( $member['members_l_display_name'] AND mb_strpos( $term, $member['members_l_display_name'] ) !== false )
+ {
+ $r['_matched'] = 'members_display_name';
+ }
+ else if( $member['members_l_username'] AND mb_strpos( $term, $member['members_l_username'] ) !== false )
+ {
+ $r['_matched'] = 'name';
+ }
+ else
+ {
+ $r['_matched'] = 'email';
+ }
+
+ $r['name'] = $member['members_display_name'];
+ $r['extra'] = $member['g_title'];
+ $r['img'] = $member['pp_mini_photo'];
+ $r['url'] = $this->settings['_base_url']."&app=members&module=members§ion=members&do=viewmember&member_id=".$member['member_id'];
+
+ /* Trim out what we don't need */
+
+ $results['members'][] = $r;
+ }
+
+ return $results;
+ }
+
+ /**
+ * Check if search term is found in groups language file or in the group_cache.g_title
+ *
+ * @param string Search term
+ * @param array Existing search results
+ * @return array New search results
+ */
+ protected function _checkGroups( $term, $results )
+ {
+ if ( !$this->registry->getClass('class_permissions')->checkPermission( 'groups_edit', 'members', 'groups' ) )
+ {
+ $results['groups'] = array();
+ return $results;
+ }
+
+ $term = mb_strtolower($term);
+
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_groups' ), 'members' );
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_forums' ), 'forums' );
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_gallery' ), 'gallery' );
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_blog' ), 'blog' );
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_downloads' ), 'downloads' );
+
+ foreach( $this->lang->words as $k => $v )
+ {
+ if( strpos( $k, 'gf_' ) !== false AND mb_strpos( $v, $term ) !== false )
+ {
+ IPSDebug::fireBug( 'info', array( 'Group key found: ' . $k . ': ' . $v ) );
+
+ $results['groupLangs'] = true;
+ break;
+ }
+ }
+
+ /* Now check group names */
+ $groups = $this->cache->getCache('group_cache');
+
+ if ( is_array( $groups ) AND count( $groups ) )
+ {
+ foreach( $groups as $id => $data )
+ {
+ $_term = preg_quote( $term, '#' );
+
+ if ( preg_match( "#" . $_term . "#iu", $data['g_title'] ) )
+ {
+ $results['groups'][] = array(
+ 'name' => IPSMember::makeNameFormatted( $data['g_title'], $data['g_id'] ),
+ 'url' => $this->settings['_base_url'] . "&app=members&module=groups§ion=groups&do=edit&id=" . $data['g_id'],
+ );
+ }
+ }
+ }
+
+ return $results;
+ }
+
+ /**
+ * Check if search term is found in groups language file
+ *
+ * @param string Search term
+ * @param array Existing search results
+ * @return array New search results
+ */
+ protected function _checkForums( $term, $results )
+ {
+ if ( !$this->registry->getClass('class_permissions')->checkPermission( 'forums_edit', 'forums', 'forums' ) )
+ {
+ $results['forums'] = array();
+ return $results;
+ }
+
+ $term = mb_strtolower($term);
+ $results['forums'] = false;
+
+ /* Fetch forums lib */
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/forums/class_forums.php", 'class_forums', 'forums' );
+ $forums = new $classToLoad( $this->registry );
+ $forums->strip_invisible = 1;
+ $forums->forumsInit();
+
+ /* Now check forum titles names */
+ foreach( $forums->forum_by_id as $id => $data )
+ {
+ $_term = preg_quote( $term, '#' );
+
+ if ( preg_match( "#" . $_term . "#iu", $data['name'] ) )
+ {
+ $data['extra'] = ( ( $data['posts'] == null ) ? 0 : $data['posts'] ) . " сообщений";
+ $data['url'] = $this->settings['_base_url']."&app=forums&module=forums§ion=forums&do=edit&f=".$data['id'];
+ $results['forums'][] = $data;
+ }
+ }
+
+ return $results;
+ }
+
+ /**
+ * Searches the settings table
+ *
+ * @param string Search term
+ * @param array Existing search results
+ * @return array New search results
+ */
+ protected function _getSettings( $term, $results )
+ {
+ if ( !$this->registry->getClass('class_permissions')->checkPermission( 'settings_manage', 'core', 'settings' ) )
+ {
+ $results['settings'] = array();
+ return $results;
+ }
+
+ $term = mb_strtolower($term);
+
+ if( !IN_DEV )
+ {
+ $this->DB->build( array( 'select' => 'c.conf_group, c.conf_title, c.conf_description, c.conf_keywords',
+ 'from' => array( 'core_sys_conf_settings' => 'c' ),
+ 'where' => 't.conf_title_noshow=0 AND (' . $this->DB->buildLower('c.conf_title') . " LIKE '%{$term}%' OR ". $this->DB->buildLower('c.conf_description') . " LIKE '%{$term}%' OR " . $this->DB->buildLower('c.conf_keywords') . " LIKE '%{$term}%')",
+ 'add_join' => array( array( 'from' => array( 'core_sys_settings_titles' => 't' ),
+ 'where' => 't.conf_title_id=c.conf_group',
+ 'type' => 'left' ) )
+ ) );
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => 'conf_group, conf_title, conf_description, conf_keywords',
+ 'from' => 'core_sys_conf_settings',
+ 'where' => $this->DB->buildLower('conf_title') . " LIKE '%{$term}%' OR ". $this->DB->buildLower('conf_description') . " LIKE '%{$term}%' OR " . $this->DB->buildLower('conf_keywords') . " LIKE '%{$term}%'",
+ ) );
+ }
+
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $r['name'] = $r['conf_title'];
+ $r['url'] = $this->settings['_base_url']."&app=core&module=settings§ion=settings&do=setting_view&conf_group=" . $r['conf_group'] . "&search=" . $this->request['search_term'];
+
+ $results['settings'][] = $r;
+ }
+
+ return $results;
+ }
+
+ /**
+ * Searches Nexus
+ *
+ * @param string Search term
+ * @param array Existing search results
+ * @return array New search results
+ */
+ protected function _checkNexus( $term, $results )
+ {
+ if ( !$this->registry->getClass('class_permissions')->checkForAppAccess('nexus') )
+ {
+ $results['nexus'] = array();
+ return $results;
+ }
+
+ $textTerm = $this->DB->addSlashes( mb_strtolower( $term ) );
+ $intTerm = intval( $term );
+ $encodedTerm = urlencode( $encodedTerm );
+
+ $tempResults = array();
+
+ require_once( IPSLib::getAppDir('nexus') . '/sources/customer.php' );/*noLibHook*/
+
+ //-----------------------------------------
+ // Is it a number?
+ //-----------------------------------------
+
+ if ( (string) $term == (string) $intTerm )
+ {
+ /* Invoice? */
+ if ( $this->registry->getClass('class_permissions')->checkPermission( 'invoices_manage', 'nexus', 'payments' ) )
+ {
+ $invoice = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_invoices', 'where' => "i_id={$intTerm}" ) );
+ if ( $invoice['i_id'] )
+ {
+ $tempResults['invoice'] = array( 'name' => $invoice['i_title'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=invoices&do=view_invoice&id={$invoice['i_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/invoice.png' );
+ }
+ }
+
+ /* Purchase? */
+ if ( $this->registry->getClass('class_permissions')->checkPermission( 'purchases_view', 'nexus', 'payments' ) )
+ {
+ $purchase = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_purchases', 'where' => "ps_id={$intTerm}" ) );
+ if ( $purchase['ps_id'] )
+ {
+ $tempResults['purchase'] = array( 'name' => $purchase['ps_name'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=purchases&id={$purchase['ps_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/purchase.png' );
+ }
+ }
+
+ /* Support */
+ if ( $this->registry->getClass('class_permissions')->checkPermission( 'sr_view', 'nexus', 'tickets' ) )
+ {
+ $support = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_support_requests', 'where' => "r_id={$intTerm}" ) );
+ if ( $support['r_id'] )
+ {
+ $tempResults['support'] = array( 'name' => $support['r_title'], 'url' => $this->settings['_base_url']."&app=nexus&module=tickets§ion=view&id={$support['r_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/support.png' );
+ }
+ }
+
+ /* Customer */
+ if ( $this->registry->getClass('class_permissions')->checkForModuleAccess( 'nexus', 'customers' ) )
+ {
+ $customer = $this->DB->buildAndFetch( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'where' => "member_id={$intTerm}" ) );
+ if ( $customer['member_id'] )
+ {
+ if ( !preg_replace( '/\s/', '', $customer['members_display_name'] ) )
+ {
+ $customer['members_display_name'] = '?????';
+ }
+
+ $tempResults['member'] = array( 'name' => $customer['members_display_name'], 'url' => $this->settings['_base_url']."&app=nexus&module=customers§ion=view&id={$customer['member_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
+ }
+ }
+
+ /* Transaction? */
+ if ( $this->registry->getClass('class_permissions')->checkPermission( 'transactions_manage', 'nexus', 'payments' ) )
+ {
+ $transaction = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_transactions', 'where' => "t_id={$intTerm}" ) );
+ if ( $transaction['t_id'] )
+ {
+ $tempResults['transactions'] = array( 'name' => $transaction['t_id'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=transactions&do=view&id={$transaction['t_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/transaction.png' );
+ }
+ }
+
+ }
+
+ //-----------------------------------------
+ // Nope - text
+ //-----------------------------------------
+
+ else
+ {
+ /* License Key */
+ if ( $this->registry->getClass('class_permissions')->checkPermission( 'purchases_view', 'nexus', 'payments' ) )
+ {
+ $lkey = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'nexus_licensekeys', 'where' => $this->DB->buildLower('lkey_key') ."='{$textTerm}'" ) );
+ if ( $lkey['lkey_key'] )
+ {
+ $tempResults['lkey'] = array( 'name' => $lkey['lkey_key'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=purchases&id={$lkey['lkey_purchase']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/lkey.png' );
+ }
+ }
+
+ /* Customers */
+ if ( $this->registry->getClass('class_permissions')->checkForModuleAccess( 'nexus', 'customers' ) )
+ {
+ $customer = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'members', 'where' => $this->DB->buildLower('email') ." LIKE '%{$textTerm}%'" ) );
+ if ( $customer['count'] )
+ {
+ if ( $customer['count'] > 50 )
+ {
+ $tempResults['member'] = array( 'name' => sprintf( $this->lang->words['livesearch_more'], $customer['count'] ), 'url' => "{$this->settings['base_url']}app=nexus&module=customers§ion=search&searchpag=1&option=email&criteria=contains&value={$encodedTerm}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
+
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => 'member_id, email', 'from' => 'members', 'where' => $this->DB->buildLower('email') ." LIKE '%{$textTerm}%'" ) );
+ $this->DB->execute();
+ while ( $row = $this->DB->fetch() )
+ {
+ $tempResults['member'][] = array( 'name' => $row['email'], 'url' => $this->settings['_base_url']."&app=nexus&module=customers§ion=view&id={$row['member_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
+ }
+ }
+ }
+
+ $customer = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'members', 'where' => "members_l_display_name LIKE '%{$textTerm}%'" ) );
+ if ( $customer['count'] )
+ {
+ if ( $customer['count'] > 50 )
+ {
+ $tempResults['member'] = array( 'name' => sprintf( $this->lang->words['livesearch_more'], $customer['count'] ), 'url' => "{$this->settings['base_url']}app=nexus&module=customers§ion=search&searchpag=1&option=email&criteria=contains&value={$encodedTerm}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
+
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'where' => "members_l_display_name LIKE '%{$textTerm}%'" ) );
+ $this->DB->execute();
+ while ( $row = $this->DB->fetch() )
+ {
+ $tempResults['member'][] = array( 'name' => $row['members_display_name'], 'url' => $this->settings['_base_url']."&app=nexus&module=customers§ion=view&id={$row['member_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
+ }
+ }
+ }
+ }
+
+ /* Hosting Accounts */
+ if ( $this->registry->getClass('class_permissions')->checkPermission( 'purchases_view', 'nexus', 'payments' ) )
+ {
+ if ( strpos( $textTerm, '.' ) === FALSE )
+ {
+ $hosting = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'nexus_hosting_accounts', 'where' => $this->DB->buildLower('account_username') . " LIKE '%{$textTerm}%'" ) );
+ if ( $hosting['count'] )
+ {
+ if ( $hosting['count'] > 50 )
+ {
+ $tempResults['hosting'] = array( 'name' => sprintf( $this->lang->words['livesearch_more'], $customer['count'] ), 'url' => "&app=nexus&module=search§ion=search&nexus_search={$encodedTerm}&nexus_searchby=username", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/nexus_icons/hosting.png' );
+
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => 'ps_id, account_username', 'from' => 'nexus_hosting_accounts', 'where' => $this->DB->buildLower('account_username') . " LIKE '%{$textTerm}%'" ) );
+ $this->DB->execute();
+ while ( $row = $this->DB->fetch() )
+ {
+ $tempResults['hosting'][] = array( 'name' => $row['account_username'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=purchases&id={$row['ps_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/nexus_icons/hosting.png' );
+ }
+ }
+ }
+ }
+ if ( empty( $tempResults['hosting'] ) )
+ {
+ $hosting = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'nexus_hosting_accounts', 'where' => $this->DB->buildLower('account_domain') . " LIKE '%{$textTerm}%'" ) );
+ if ( $hosting['count'] )
+ {
+ if ( $hosting['count'] > 50 )
+ {
+ $tempResults['hosting'] = array( 'name' => sprintf( $this->lang->words['livesearch_more'], $customer['count'] ), 'url' => "&app=nexus&module=search§ion=search&nexus_search={$encodedTerm}&nexus_searchby=domain", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/customers/info.png' );
+
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => 'ps_id, account_domain', 'from' => 'nexus_hosting_accounts', 'where' => $this->DB->buildLower('account_domain') . " LIKE '%{$textTerm}%'" ) );
+ $this->DB->execute();
+ while ( $row = $this->DB->fetch() )
+ {
+ $tempResults['hosting'][] = array( 'name' => $row['account_domain'], 'url' => $this->settings['_base_url']."&app=nexus&module=payments§ion=purchases&id={$row['ps_id']}", 'img' => $this->settings['base_acp_url'] . '/applications_addon/ips/nexus/skin_cp/images/nexus_icons/hosting.png' );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Return results
+ //-----------------------------------------
+
+
+ foreach ( array( 'invoice', 'purchase', 'transactions', 'lkey', 'support', 'member', 'hosting' ) as $k )
+ {
+ if ( isset( $tempResults[ $k ] ) )
+ {
+ if ( isset( $tempResults[ $k ][0] ) )
+ {
+ foreach ( $tempResults[ $k ] as $l )
+ {
+ $results['nexus'][] = $l;
+ }
+ }
+ else
+ {
+ $results['nexus'][] = $tempResults[ $k ];
+ }
+ }
+ }
+
+ return $results;
+ }
+
+ /**
+ * Searches the XML Files
+ *
+ * @param string Search term
+ * @param array Existing search results
+ * @return array New search results
+ */
+ protected function _getFromXML( $term, $results )
+ {
+ foreach( $this->cache->getCache('app_menu_cache') as $app => $cache )
+ {
+ if( IPSLib::appIsInstalled( $app ) and $this->registry->getClass('class_permissions')->checkForAppAccess( $app ) )
+ {
+ foreach( $cache as $entry )
+ {
+ if( count($entry['items']) )
+ {
+ foreach( $entry['items'] as $item )
+ {
+ if ( $this->registry->getClass('class_permissions')->checkForModuleAccess( $app, $item['module'] ) and ( !$item['rolekey'] or $this->registry->getClass('class_permissions')->checkPermission( $item['rolekey'], $app, $item['module'] ) ) )
+ {
+ if( $item['section'] )
+ {
+ $item['url'] = "section={$item['section']}&" . $item['url'];
+ }
+
+ if( isset($item['keywords']) AND mb_stripos( $item['keywords'], $term ) !== false )
+ {
+ $item['name'] = $item['title'];
+ $item['url'] = $this->settings['_base_url']."&app={$app}&module={$item['module']}&{$item['url']}";
+ $results['location'][] = $item;
+ }
+ else if( mb_stripos( $item['title'], $term ) !== false )
+ {
+ $item['name'] = $item['title'];
+ $item['url'] = $this->settings['_base_url']."&app={$app}&module={$item['module']}&{$item['url']}";
+ $results['location'][] = $item;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return $results;
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/ajax/replacements.php b/upload/admin/applications/core/modules_admin/ajax/replacements.php
index d5d57dfd..f8ca67ae 100644
--- a/upload/admin/applications/core/modules_admin/ajax/replacements.php
+++ b/upload/admin/applications/core/modules_admin/ajax/replacements.php
@@ -3,21 +3,21 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* AJAX Functions For applications/core/js/ipb3CSS.js file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-24 16:20:59 -0400 (Thu, 24 May 2012) $
*
*
* Author: Matt Mecham
*
- * @author $Author: bfarber $
+ * @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 10792 $
*/
diff --git a/upload/admin/applications/core/modules_admin/ajax/skinsets.php b/upload/admin/applications/core/modules_admin/ajax/skinsets.php
index 87f98f99..668d3a62 100644
--- a/upload/admin/applications/core/modules_admin/ajax/skinsets.php
+++ b/upload/admin/applications/core/modules_admin/ajax/skinsets.php
@@ -3,7 +3,7 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* AJAX Functions For applications/core/js/ipb3CSS.js file
* Last Updated: $Date: 2011-05-05 12:03:47 +0100 (Thu, 05 May 2011) $
*
diff --git a/upload/admin/applications/core/modules_admin/ajax/tabs.php b/upload/admin/applications/core/modules_admin/ajax/tabs.php
index a95dea3c..1b4f1fe4 100644
--- a/upload/admin/applications/core/modules_admin/ajax/tabs.php
+++ b/upload/admin/applications/core/modules_admin/ajax/tabs.php
@@ -7,7 +7,7 @@
* $Author: bfarber $
* @since 8th Feb 2011
* $LastChangedDate: 2011-03-10 16:00:38 -0500 (Thu, 10 Mar 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8021 $
*/
diff --git a/upload/admin/applications/core/modules_admin/ajax/templatediff.php b/upload/admin/applications/core/modules_admin/ajax/templatediff.php
index e2edd111..c59f7048 100644
--- a/upload/admin/applications/core/modules_admin/ajax/templatediff.php
+++ b/upload/admin/applications/core/modules_admin/ajax/templatediff.php
@@ -3,21 +3,21 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* AJAX Functions For applications/core/js/ipb3Templates.js file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-11-30 10:02:12 -0500 (Fri, 30 Nov 2012) $
*
*
* Author: Matt Mecham
*
- * @author $Author: bfarber $
+ * @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 11668 $
*/
@@ -137,6 +137,7 @@ class admin_core_ajax_templatediff extends ipsAjaxCommand
$return['data_content'] = $this->skinFunctions->fetchOriginalItem( $return );
break;
case 'custom':
+ $return['data_set_id'] = $session['merge_set_id'];
$return['data_content'] = $this->skinFunctions->fetchCustomItem( $return );
break;
case 'new':
diff --git a/upload/admin/applications/core/modules_admin/ajax/templates.php b/upload/admin/applications/core/modules_admin/ajax/templates.php
index 44df4304..bf3f9083 100644
--- a/upload/admin/applications/core/modules_admin/ajax/templates.php
+++ b/upload/admin/applications/core/modules_admin/ajax/templates.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* AJAX Functions For applications/core/js/ipb3Templates.js file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* Author: Matt Mecham
@@ -17,7 +17,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
diff --git a/upload/admin/applications/core/modules_admin/ajax/templatesandr.php b/upload/admin/applications/core/modules_admin/ajax/templatesandr.php
index d083f4ff..e75a4125 100644
--- a/upload/admin/applications/core/modules_admin/ajax/templatesandr.php
+++ b/upload/admin/applications/core/modules_admin/ajax/templatesandr.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* AJAX Functions For applications/core/js/ipb3Templates.js file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* Author: Matt Mecham
@@ -17,7 +17,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
diff --git a/upload/admin/applications/core/modules_admin/ajax/uagents.php b/upload/admin/applications/core/modules_admin/ajax/uagents.php
index c835282e..e484a782 100644
--- a/upload/admin/applications/core/modules_admin/ajax/uagents.php
+++ b/upload/admin/applications/core/modules_admin/ajax/uagents.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* AJAX Functions For applications/core/js/ipb3CSS.js file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* Author: Matt Mecham
@@ -17,7 +17,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
diff --git a/upload/admin/applications/core/modules_admin/applications/applications.php b/upload/admin/applications/core/modules_admin/applications/applications.php
index b92f5dde..c33a4bcc 100644
--- a/upload/admin/applications/core/modules_admin/applications/applications.php
+++ b/upload/admin/applications/core/modules_admin/applications/applications.php
@@ -6,9 +6,9 @@
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: bfarber $
* @since 15 January 2007
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $LastChangedDate: 2013-05-07 22:02:49 -0400 (Tue, 07 May 2013) $
+ * @version v3.4.5
+ * $Revision: 12236 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -1085,6 +1085,7 @@ class admin_core_applications_applications extends ipsCommand
$this->moduleRecache();
+ $this->applicationsMenuDataRecache();
//-----------------------------------------
// List...
@@ -1163,8 +1164,8 @@ class admin_core_applications_applications extends ipsCommand
//-----------------------------------------
- $form['sys_module_title'] = $this->registry->output->formInput( 'sys_module_title', $_POST['sys_module_title'] ? $_POST['sys_module_title'] : $module['sys_module_title'] );
- $form['sys_module_description'] = $this->registry->output->formInput( 'sys_module_description', $_POST['sys_module_description'] ? $_POST['sys_module_description'] : $module['sys_module_description'] );
+ $form['sys_module_title'] = $this->registry->output->formInput( 'sys_module_title', $_POST['sys_module_title'] ? $_POST['sys_module_title'] : $module['sys_module_title'], '', 30, 'text', '', '', 32 );
+ $form['sys_module_description'] = $this->registry->output->formInput( 'sys_module_description', $_POST['sys_module_description'] ? $_POST['sys_module_description'] : $module['sys_module_description'], '', 30, 'text', '', '', 100 );
$form['sys_module_key'] = $this->registry->output->formInput( 'sys_module_key', $_POST['sys_module_key'] ? $_POST['sys_module_key'] : $module['sys_module_key'] );
$form['sys_module_version'] = $this->registry->output->formInput( 'sys_module_version', $_POST['sys_module_version'] ? $_POST['sys_module_version'] : $module['sys_module_version'] );
$form['sys_module_protected'] = $this->registry->output->formYesNo( 'sys_module_protected', $_POST['sys_module_protected'] ? $_POST['sys_module_protected'] : $module['sys_module_protected'] );
@@ -1534,7 +1535,9 @@ class admin_core_applications_applications extends ipsCommand
if ( $match[1] )
{
- $this->DB->dropTable( preg_replace( '#^' . ipsRegistry::dbFunctions()->getPrefix() . "(\S+)#", "\\1", $match[1] ) );
+ $_table = preg_replace( '#^' . ipsRegistry::dbFunctions()->getPrefix() . "(\S+)#", "\\1", $match[1] );
+
+ $this->DB->dropTable( $_table );
}
else
{
@@ -1546,7 +1549,14 @@ class admin_core_applications_applications extends ipsCommand
if ( $match[1] and $match[2] )
{
- $this->DB->dropField( preg_replace( '#^' . ipsRegistry::dbFunctions()->getPrefix() . "(\S+)#", "\\1", $match[1] ), $match[2] );
+ $_table = preg_replace( '#^' . ipsRegistry::dbFunctions()->getPrefix() . "(\S+)#", "\\1", $match[1] );
+ $_field = $match[2];
+
+ /* check for field */
+ if ( $this->DB->checkForField( $_field, $_table ) )
+ {
+ $this->DB->dropField( $_table, $_field );
+ }
}
}
}
@@ -1621,6 +1631,7 @@ class admin_core_applications_applications extends ipsCommand
}
$this->DB->delete( 'rc_reports_index', 'rc_class=' . $plugin['com_id'] );
+ $this->DB->delete( 'rc_classes', 'com_id=' . $plugin['com_id'] );
}
//-----------------------------------------
@@ -1786,11 +1797,11 @@ class admin_core_applications_applications extends ipsCommand
/* Loop through skin directories */
try
{
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . 'cache/skin_cache/' ) as $dir )
+ foreach( new DirectoryIterator( IPS_CACHE_PATH . 'cache/skin_cache/' ) as $dir )
{
if ( preg_match( "/^(cacheid_)/", $dir->getFileName() ) )
{
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . 'cache/skin_cache/' . $dir->getFileName() . '/' ) as $file )
+ foreach( new DirectoryIterator( IPS_CACHE_PATH . 'cache/skin_cache/' . $dir->getFileName() . '/' ) as $file )
{
if ( ! $file->isDot() )
{
@@ -1823,10 +1834,14 @@ class admin_core_applications_applications extends ipsCommand
if ( $match == 'contains' )
{
$this->DB->delete( 'skin_templates', "template_group LIKE '%{$name}%'" );
+ $this->DB->delete( 'skin_templates_previous', "p_template_group LIKE '%{$name}%'" );
+ $this->DB->delete( 'skin_cache', "cache_type='phptemplate' AND cache_value_1 LIKE '%{$name}%'" );
}
else
{
$this->DB->delete( 'skin_templates', "template_group='{$name}'" );
+ $this->DB->delete( 'skin_templates_previous', "p_template_group='{$name}'" );
+ $this->DB->delete( 'skin_cache', "cache_type='phptemplate' AND cache_value_1='{$name}'" );
}
}
}
@@ -2314,8 +2329,6 @@ XML;
$_groups[] = array( $gid, $gdata['g_title'] );
}
- sort( $_groups );
-
$form['app_tab_groups'] = $this->registry->output->formMultiDropdown( 'app_tab_groups[]', $_groups, isset( $_POST['app_tab_groups'] ) ? $_POST['app_tab_groups'] : explode( ',', $application['app_tab_groups'] ), 7 );
/* Setup the global caches MDD */
@@ -2434,7 +2447,7 @@ XML;
{
/* Got updates? */
if ( $row['app_update_check'] && $checkUpdates === true )
- {
+ {
$row['app_update_available'] = $hooksClass->_updateAvailable( $row['app_update_check'], $row['app_long_version'] );
if ( $row['app_update_available'][0] )
@@ -2554,8 +2567,8 @@ XML;
$okToGo = 1;
}
}
-
- if ( $info['name'] )
+
+ if ( $info['name'] && $info['key'] != "ipseo" )
{
$uninstalled[$_file] = array( 'title' => $info['name'], 'author' => $info['author'], 'path' => $filepath, 'okToGo' => $okToGo, 'directory' => $_file );
}
@@ -2981,7 +2994,7 @@ XML;
{
$app_dir = $row['app_directory'];
$main_items = $modules_cache[$app_dir];
-
+
//-----------------------------------------
// Continue...
//-----------------------------------------
diff --git a/upload/admin/applications/core/modules_admin/applications/blog.php b/upload/admin/applications/core/modules_admin/applications/blog.php
index 9b831d06..e5e71283 100644
--- a/upload/admin/applications/core/modules_admin/applications/blog.php
+++ b/upload/admin/applications/core/modules_admin/applications/blog.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Blog Application
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th Aug 2004
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/applications/ccs.php b/upload/admin/applications/core/modules_admin/applications/ccs.php
index ab0f503a..49bced6d 100644
--- a/upload/admin/applications/core/modules_admin/applications/ccs.php
+++ b/upload/admin/applications/core/modules_admin/applications/ccs.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Blog Application
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/applications/copyright.php b/upload/admin/applications/core/modules_admin/applications/copyright.php
index ad67c25d..2466ae7e 100644
--- a/upload/admin/applications/core/modules_admin/applications/copyright.php
+++ b/upload/admin/applications/core/modules_admin/applications/copyright.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Download Manager Application
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 17 February 2003
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/applications/defaultSection.php b/upload/admin/applications/core/modules_admin/applications/defaultSection.php
index 2092b4bf..456754a1 100644
--- a/upload/admin/applications/core/modules_admin/applications/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/applications/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/applications/downloads.php b/upload/admin/applications/core/modules_admin/applications/downloads.php
index 3b305fc3..dccb1261 100644
--- a/upload/admin/applications/core/modules_admin/applications/downloads.php
+++ b/upload/admin/applications/core/modules_admin/applications/downloads.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Download Manager Application
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/applications/enhancements.php b/upload/admin/applications/core/modules_admin/applications/enhancements.php
new file mode 100644
index 00000000..f3154c6d
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/applications/enhancements.php
@@ -0,0 +1,178 @@
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+/**
+ *
+ * @class admin_core_applications_enhancements
+ * @brief Community Enhancements
+ */
+class admin_core_applications_enhancements extends ipsCommand
+{
+ /**
+ * Main function executed automatically by the controller
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_applications' );
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_applications' ) );
+
+ switch( $this->request['do'] )
+ {
+ case 'edit':
+ $this->edit();
+ break;
+
+ case 'save':
+ $this->save();
+ break;
+
+ default:
+ $this->manage();
+ break;
+ }
+
+ $this->registry->getClass( 'output' )->html_main .= $this->registry->getClass( 'output' )->global_template->global_frame_wrapper();
+ $this->registry->getClass( 'output' )->sendOutput();
+ }
+
+ /**
+ * Manage
+ */
+ public function manage()
+ {
+ $enhancements = array();
+
+ foreach ( IPSLib::getEnabledApplications() as $app )
+ {
+ if ( is_dir( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/enhancements' ) )
+ {
+ $dir = new DirectoryIterator( IPSLib::getAppDir( $app['app_directory'] ) . '/extensions/enhancements' );
+ foreach ( $dir as $file )
+ {
+ if ( $file->isFile() and !$file->isDot() and substr( $file, 0, 1 ) !== '.' and substr( $file, -4 ) === '.php' )
+ {
+ $className = "enhancements_{$app['app_directory']}_" . str_replace( '.php', '', $file->getFilename() );
+
+ /* Backup system isn't ready */
+ if ( $className == 'enhancements_core_ipsbackup' )
+ {
+ continue;
+ }
+
+ $classToLoad = IPSLib::loadLibrary( $file->getPathName(), $className );
+ $enhancements[ $className ] = new $classToLoad( $this->registry );
+ }
+ }
+ }
+ }
+
+ uasort( $enhancements, create_function( '$a, $b', 'return $a->title > $b->title;' ) );
+
+ $this->registry->output->html .= $this->html->communityEnhancements( $enhancements );
+ }
+
+ /**
+ * Edit
+ */
+ public function edit()
+ {
+ $exploded = explode( '_', $this->request['service'] );
+ if ( !IPSLib::appIsInstalled( $exploded[1] ) or !is_file( IPSLib::getAppDir( $exploded[1] ) . '/extensions/enhancements/' . $exploded[2] . '.php' ) )
+ {
+ $this->registry->output->showError( $this->lang->words['err_no_enhancement'], 111800 );
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $exploded[1] ) . '/extensions/enhancements/' . $exploded[2] . '.php', $this->request['service'] );
+ $class = new $classToLoad( $this->registry );
+
+ if ( method_exists( $class, 'check' ) )
+ {
+ $class->check();
+ }
+
+ if ( isset( $class->settings ) and !empty( $class->settings ) )
+ {
+ $settingsClass = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/settings/settings.php', 'admin_core_settings_settings' );
+ $settingsClass = new $settingsClass();
+ $settingsClass->makeRegistryShortcuts( $this->registry );
+ $settingsClass->html = $this->registry->output->loadTemplate('cp_skin_settings');
+
+ $html = '';
+
+ $imploded = implode( ', ', array_map( create_function( '$v', 'return "\'{$v}\'";' ), $class->settings ) );
+ $settings = array();
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN( {$imploded} )", 'order' => 'conf_position' ) );
+ $e = $this->DB->execute();
+ while ( $row = $this->DB->fetch( $e ) )
+ {
+ $html .= $settingsClass->_processSettingEntry( $row );
+ }
+
+ $this->registry->output->html .= $this->html->communityEnhancementsSettings( $class, $html );
+ }
+ else
+ {
+ $this->registry->output->html .= $class->editSettings();
+ }
+ }
+
+ /**
+ * Save
+ */
+ public function save()
+ {
+ $exploded = explode( '_', $this->request['service'] );
+ if ( !IPSLib::appIsInstalled( $exploded[1] ) or !is_file( IPSLib::getAppDir( $exploded[1] ) . '/extensions/enhancements/' . $exploded[2] . '.php' ) )
+ {
+ $this->registry->output->showError( $this->lang->words['err_no_enhancement'], 111801 );
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $exploded[1] ) . '/extensions/enhancements/' . $exploded[2] . '.php', $this->request['service'] );
+ $class = new $classToLoad( $this->registry );
+
+ if ( method_exists( $class, 'check' ) )
+ {
+ $class->check();
+ }
+
+ if ( isset( $class->settings ) and !empty( $class->settings ) )
+ {
+ $toSave = array();
+ foreach ( $class->settings as $key )
+ {
+ $toSave[ $key ] = $_POST[ $key ];
+ }
+ IPSLib::updateSettings( $toSave, TRUE );
+ }
+ else
+ {
+ $output = $class->saveSettings();
+ if ( $output and is_string( $output ) )
+ {
+ $this->registry->output->html .= $output;
+ return;
+ }
+ }
+
+ $this->registry->output->redirect( "{$this->settings['base_url']}app=core&module=applications§ion=enhancements", $this->lang->words['enhancements_saved'] );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/applications/gallery.php b/upload/admin/applications/core/modules_admin/applications/gallery.php
index 90046f35..c31dd9f0 100644
--- a/upload/admin/applications/core/modules_admin/applications/gallery.php
+++ b/upload/admin/applications/core/modules_admin/applications/gallery.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Gallery Application
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/applications/hooks.php b/upload/admin/applications/core/modules_admin/applications/hooks.php
index e5063278..7f2237e8 100644
--- a/upload/admin/applications/core/modules_admin/applications/hooks.php
+++ b/upload/admin/applications/core/modules_admin/applications/hooks.php
@@ -1,3511 +1,3543 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Hooks Management
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since 3.0.0
- * @version $Revision: 10914 $
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-class admin_core_applications_hooks extends ipsCommand
-{
- /**
- * Skin object
- *
- * @var object Skin templates
- */
- protected $html;
-
- /**
- * Hooks library
- *
- * @var object Hooks library
- */
- protected $hooksFunctions;
-
- /**
- * Existing hooks
- *
- * @var array Existing hooks
- */
- protected $hooks;
-
- /**
- * Array of all the cache versions
- * for the required applications
- *
- * @var $cachedVersions
- */
- protected $cachedVersions = array();
-
- /**
- * Main class entry point
- *
- * @param object ipsRegistry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- //-----------------------------------------
- // Load skin
- //-----------------------------------------
-
- $this->html = $this->registry->output->loadTemplate('cp_skin_applications');
-
- //-----------------------------------------
- // Load hooks library
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('core') . '/sources/classes/hooksFunctions.php', 'hooksFunctions' );
- $this->hooksFunctions = new $classToLoad( $registry );
-
- // lang already loaded by hookFunctions
- //$this->registry->class_localization->loadLanguageFile( array( 'admin_applications' ), 'core' );
-
- //-----------------------------------------
- // Set up stuff
- //-----------------------------------------
-
- $this->form_code = $this->html->form_code = 'module=applications§ion=hooks&';
- $this->form_code_js = $this->html->form_code_js = 'module=applications§ion=hooks&';
-
- //-----------------------------------------
- // What to do...
- //-----------------------------------------
-
- switch( $this->request['do'] )
- {
- case 'reenable_all_hooks':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_reenableAllHooks();
- break;
- case 'disable_all_hooks':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_disableAllHooks();
- break;
-
- break;
- case 'disable_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_disableHook();
- break;
- case 'enable_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_enableHook();
- break;
-
- case 'uninstall_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_delete' );
- $this->_uninstallHook();
- break;
- case 'install_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_installHook();
- break;
-
- case 'reorder':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_reorder();
- break;
-
- case 'view_details':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_viewDetails();
- break;
-
- case 'check_requirements':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_checkRequirements();
- break;
-
- case 'export_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_exportHook();
- break;
-
- case 'do_export_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_doExportHook();
- break;
-
- case 'create_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_hookForm( 'add' );
- break;
-
- case 'edit_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_hookForm( 'edit' );
- break;
-
- case 'do_create_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_hookSave( 'add' );
- break;
-
- case 'do_edit_hook':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->_hookSave( 'edit' );
- break;
-
- case 'removeDeadCaches':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->removeDeadCaches();
- break;
-
- case 'reimport_apps':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->reimportAppHooks();
- break;
-
- case 'hooks_overview':
- default:
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
- $this->request['do'] = 'hooks_overview';
- $this->_hooksOverview();
- break;
- }
-
- //-----------------------------------------
- // Pass to CP output hander
- //-----------------------------------------
-
- $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
- $this->registry->getClass('output')->sendOutput();
- }
-
- /**
- * Reimport all hooks for all installed applications
- *
- * @return @e void
- */
- protected function reimportAppHooks()
- {
- $stats = array( 'inserted' => 0, 'updated' => 0, 'skipped' => 0 );
-
- foreach( ipsRegistry::$applications as $app )
- {
- $_stats = $this->installAppHooks( $app['app_directory'] );
-
- $stats['inserted'] = $stats['inserted'] + $_stats['inserted'];
- $stats['updated'] = $stats['updated'] + $_stats['updated'];
- $stats['skipped'] = $stats['skipped'] + $_stats['skipped'];
- }
-
- /* Rebuild cache */
- $this->rebuildHooksCache();
-
- /* Rebuild global caches */
- try
- {
- IPSLib::cacheGlobalCaches();
- }
- catch( Exception $e ){}
-
- /* Flag skins for recache */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
- $skinCaching->flagSetForRecache();
-
- /* Redirect */
- $this->registry->output->global_message = sprintf( $this->lang->words['app_hooks_rebuilt'], $stats['inserted'], $stats['updated'], $stats['skipped'] );
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /**
- * Rebuild skins following hook import that included a template
- *
- * @return @e void
- */
- protected function removeDeadCaches()
- {
- $messages = array();
- $keep = array();
- $unlink = array();
-
- /* Grab all current hooks caches */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'core_hooks_files' ) );
-
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $keep[] = $row['hook_file_stored'];
- }
-
- try
- {
- foreach( new DirectoryIterator( IPS_HOOKS_PATH ) as $file )
- {
- if ( ! $file->isDot() )
- {
- $_name = $file->getFileName();
-
- if ( preg_match( "#_[a-z0-9]{32}\.php$#", $_name ) )
- {
- if ( ! in_array( $_name, $keep ) )
- {
- $unlink[] = $_name;
- }
- }
- }
- }
- } catch ( Exception $e ) { print $e->getMessage(); }
-
- /* Anything to unlink? */
- if ( count( $unlink ) )
- {
- foreach( $unlink as $file )
- {
- @unlink( IPS_HOOKS_PATH . $file );
- }
- }
-
- /* Print message */
- $this->registry->output->global_message = sprintf( $this->lang->words['hook_removed_files'], count( $unlink ) ) . ' ' . implode( ' ', $unlink );
- $this->_hooksOverview();
- }
-
- /**
- * Reorder hooks
- *
- * @return @e void [Outputs to screen]
- */
- protected function _reorder()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
- $ajax = new $classToLoad();
-
- //-----------------------------------------
- // Checks...
- //-----------------------------------------
-
- if( $this->registry->adminFunctions->checkSecurityKey( $this->request['md5check'], true ) === false )
- {
- $ajax->returnString( $this->lang->words['postform_badmd5'] );
- }
-
- //-----------------------------------------
- // Save new position
- //-----------------------------------------
-
- $position = 1;
-
- if( is_array($this->request['hooks']) AND count($this->request['hooks']) )
- {
- /* Reset all hooks to 0 temporarily */
- $this->DB->update( 'core_hooks', array( 'hook_position' => 0 ) );
-
- foreach( $this->request['hooks'] as $this_id )
- {
- $this->DB->update( 'core_hooks', array( 'hook_position' => $position ), 'hook_id=' . $this_id );
-
- $position++;
- }
- }
-
- $this->rebuildHooksCache();
-
- $ajax->returnString('OK');
- }
-
- /**
- * Install a new hook
- *
- * @return void
- */
- protected function _installHook()
- {
- //-----------------------------------------
- // Get uploaded schtuff
- //-----------------------------------------
-
- $tmp_name = $_FILES['FILE_UPLOAD']['name'];
- $tmp_name = preg_replace( "#\.gz$#", "", $tmp_name );
-
- $content = ipsRegistry::getClass('adminFunctions')->importXml( $tmp_name );
-
- if( ! $content )
- {
- $this->registry->output->showError( $this->lang->words['h_noxml'], 1110 );
- }
-
- $this->installHook( $content, TRUE, FALSE );
-
- /* Rebuild cache */
- $this->rebuildHooksCache();
-
- /* Rebuild global caches */
- try
- {
- IPSLib::cacheGlobalCaches();
- }
- catch( Exception $e ){}
-
- /* Flag skins for recache */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
- $skinCaching->flagSetForRecache();
-
- /* Redirect */
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /**
- * Function mostly used in installer/upgrader
- * Inserts new hooks
- *
- * @param string Application to install hooks for
- */
- public function installAppHooks( $app )
- {
- static $hooks = array();
-
- $msgs = array( 'inserted' => 0, 'updated' => 0, 'skipped' => 0 );
- $xmlData = array();
- $path = IPSLib::getAppDir( $app ) . '/xml';
-
- if ( is_file( $path . '/hooks.xml' ) AND is_dir( $path . '/hooks' ) )
- {
- if( !count($hooks) )
- {
- /* Fetch current hooks */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'core_hooks' ) );
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- if ( $row['hook_key'] )
- {
- $hooks[ $row['hook_key'] ] = $row;
- }
- }
- }
-
- /* Alright. We're in. Read the XML file */
- require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
- $xml = new classXML( IPS_DOC_CHAR_SET );
-
- /* Grab wrapper file */
- $xml->load( $path . '/hooks.xml' );
-
- foreach( $xml->fetchElements('hook') as $data )
- {
- $xmlData[] = $xml->fetchElementsFromRecord( $data );
- }
-
- /* Examine XML */
- if ( is_array( $xmlData ) AND count( $xmlData ) )
- {
- foreach( $xmlData as $x )
- {
- if ( is_file( $path . '/hooks/' . $x['file'] ) )
- {
- $xml->load( $path . '/hooks/' . $x['file'] );
-
- foreach( $xml->fetchElements('config') as $data )
- {
- $config = $xml->fetchElementsFromRecord( $data );
- }
-
- if ( ! isset( $hooks[ $config['hook_key'] ] ) )
- {
- /* Add it */
- $msgs['inserted']++;
- $this->installHook( file_get_contents( $path . '/hooks/' . $x['file'] ), FALSE, FALSE, $x['enabled'] );
- }
- else
- {
- $this->installHook( file_get_contents( $path . '/hooks/' . $x['file'] ), FALSE, FALSE, $x['enabled'] );
- $msgs['updated']++;
- }
- }
- }
- }
- }
-
- return $msgs;
- }
-
- /**
- * Public install hook so we can use it in the installer and elsewhere
- *
- * @param string XML data
- * @param boolean Add message to output->global_message
- * @param boolean Allow skins to recache
- * @param int Install enabled
- * @return @e void
- */
- public function installHook( $content, $addMessage=FALSE, $allowSkinRecache=TRUE, $enabled=1 )
- {
- //-----------------------------------------
- // Hooks directory writable?
- //-----------------------------------------
-
- if( !is_writable( IPS_HOOKS_PATH ) )
- {
- if( !$addMessage )
- {
- return false;
- }
-
- $this->registry->output->showError( $this->lang->words['h_dir_notwritable'], 111159 );
- }
-
- //-----------------------------------------
- // Got our hooks?
- //-----------------------------------------
-
- if( !is_array($this->hooks) OR !count($this->hooks) )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $this->hooks[ $r['hook_key'] ] = $r;
- }
- }
-
- //-----------------------------------------
- // Get xml mah-do-dah
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
- $xml = new classXML( IPS_DOC_CHAR_SET );
-
- //-----------------------------------------
- // Unpack the datafile
- //-----------------------------------------
-
- $xml->loadXML( $content );
-
- foreach( $xml->fetchElements('config') as $data )
- {
- $config = $xml->fetchElementsFromRecord( $data );
-
- if( !count($config) )
- {
- $this->registry->output->showError( $this->lang->words['h_xmlwrong'], 1111 );
- }
- }
-
- //-----------------------------------------
- // Temp
- //-----------------------------------------
-
- $tempExtraData = unserialize( $config['hook_extra_data'] );
-
- //-----------------------------------------
- // Set config
- //-----------------------------------------
-
- $config = array('hook_name' => $config['hook_name'],
- 'hook_desc' => $config['hook_desc'],
- 'hook_author' => $config['hook_author'],
- 'hook_email' => $config['hook_email'],
- 'hook_website' => $config['hook_website'],
- 'hook_update_check' => $config['hook_update_check'],
- 'hook_requirements' => $config['hook_requirements'],
- 'hook_version_human' => $config['hook_version_human'],
- 'hook_version_long' => $config['hook_version_long'],
- 'hook_key' => $config['hook_key'],
- 'hook_global_caches' => $config['hook_global_caches'],
- 'hook_enabled' => $enabled,
- 'hook_updated' => IPS_UNIX_TIME_NOW,
- );
-
- $extra_data = array();
-
- //-----------------------------------------
- // Set files
- //-----------------------------------------
-
- $files = array();
-
- foreach( $xml->fetchElements('hookfiles') as $node )
- {
- foreach( $xml->fetchElements('file', $node) as $_file )
- {
- $file = $xml->fetchElementsFromRecord( $_file );
-
- if( $file['hook_type'] )
- {
- $files[] = array(
- 'hook_file_real' => $file['hook_file_real'],
- 'hook_type' => $file['hook_type'],
- 'hook_classname' => $file['hook_classname'],
- 'hook_data' => $file['hook_data'],
- 'hooks_source' => $file['hooks_source'],
- );
- }
- }
- }
-
- //-----------------------------------------
- // Set the custom script
- //-----------------------------------------
-
- $custom = array();
- $customClass = null;
-
- foreach( $xml->fetchElements('hookextras_custom') as $node )
- {
- foreach( $xml->fetchElements('file', $node) as $_file )
- {
- $file = $xml->fetchElementsFromRecord( $_file );
-
- if( count($file) )
- {
- $custom = array( 'filename' => $file['filename'],
- 'source' => $file['source'],
- );
- }
- }
- }
-
- /* Got any custom file to initialize? */
- if ( $custom['filename'] && $custom['source'] )
- {
- # Our dirty trick to avoid saving the file on disk just yet...
- $_custom = preg_replace( '#^(\s*)<\?(php)+#i', '', $custom['source'] );
- eval($_custom);
-
- $classname = str_replace( '.php', '', $custom['filename'] );
-
- if( class_exists( $classname ) )
- {
- $customClass = new $classname( $this->registry );
-
- if( method_exists( $customClass, 'pre_install' ) )
- {
- $customClass->pre_install();
- }
- }
- }
-
- //-----------------------------------------
- // Set the settings
- //-----------------------------------------
-
- $settings = array();
- $settingGroups = array();
-
- foreach( $xml->fetchElements('hookextras_settings') as $node )
- {
- foreach( $xml->fetchElements('setting', $node) as $_setting )
- {
- $setting = $xml->fetchElementsFromRecord( $_setting );
-
- if( $setting['conf_is_title'] == 1)
- {
- $settingGroups[] = array(
- 'conf_title_title' => $setting['conf_title_title'],
- 'conf_title_desc' => $setting['conf_title_desc'],
- 'conf_title_noshow' => $setting['conf_title_noshow'],
- 'conf_title_keyword' => $setting['conf_title_keyword'],
- 'conf_title_app' => $setting['conf_title_app'],
- 'conf_title_tab' => $setting['conf_title_tab'],
- );
- }
- else
- {
- $settings[] = array(
- 'conf_title' => $setting['conf_title'],
- 'conf_description' => $setting['conf_description'],
- 'conf_group' => $setting['conf_group'],
- 'conf_type' => $setting['conf_type'],
- 'conf_key' => $setting['conf_key'],
- 'conf_default' => $setting['conf_default'],
- 'conf_extra' => $setting['conf_extra'],
- 'conf_evalphp' => $setting['conf_evalphp'],
- 'conf_protected' => $setting['conf_protected'],
- 'conf_position' => $setting['conf_position'],
- 'conf_start_group' => $setting['conf_start_group'],
- 'conf_add_cache' => $setting['conf_add_cache'],
- 'conf_title_keyword' => $setting['conf_title_keyword'],
- );
- }
- }
- }
-
- //-----------------------------------------
- // Set the lang bits
- //-----------------------------------------
-
- $language = array();
-
- foreach( $xml->fetchElements('hookextras_language') as $node )
- {
- foreach( $xml->fetchElements('language', $node) as $_langbit )
- {
- $langbit = $xml->fetchElementsFromRecord( $_langbit );
-
- $language[] = array(
- 'word_app' => $langbit['word_app'],
- 'word_pack' => $langbit['word_pack'],
- 'word_key' => $langbit['word_key'],
- 'word_default' => $langbit['word_default'],
- 'word_custom' => $langbit['word_custom'],
- 'word_js' => intval($langbit['word_js']),
- );
- }
- }
-
- //-----------------------------------------
- // Set the modules
- //-----------------------------------------
-
- $modules = array();
-
- foreach( $xml->fetchElements('hookextras_modules') as $node )
- {
- foreach( $xml->fetchElements('module', $node) as $_module )
- {
- $module = $xml->fetchElementsFromRecord( $_module );
- $modules[] = array(
- 'sys_module_title' => $module['sys_module_title'],
- 'sys_module_application' => $module['sys_module_application'],
- 'sys_module_key' => $module['sys_module_key'],
- 'sys_module_description' => $module['sys_module_description'],
- 'sys_module_version' => $module['sys_module_version'],
- 'sys_module_protected' => $module['sys_module_protected'],
- 'sys_module_visible' => $module['sys_module_visible'],
- 'sys_module_position' => $module['sys_module_position'],
- 'sys_module_admin' => $module['sys_module_admin'],
- );
- }
- }
-
- //-----------------------------------------
- // Set the help files
- //-----------------------------------------
-
- $help = array();
-
- foreach( $xml->fetchElements('hookextras_help') as $node )
- {
- foreach( $xml->fetchElements('help', $node) as $_helpfile )
- {
- $helpfile = $xml->fetchElementsFromRecord( $_helpfile );
- $help[] = array(
- 'title' => $helpfile['title'],
- 'text' => $helpfile['text'],
- 'description' => $helpfile['description'],
- 'position' => $helpfile['position'],
- );
- }
- }
-
- //-----------------------------------------
- // Set the templates
- //-----------------------------------------
-
- $templates = array();
-
- foreach( $xml->fetchElements('hookextras_templates') as $node )
- {
- foreach( $xml->fetchElements('templates', $node) as $_template )
- {
- $template = $xml->fetchElementsFromRecord( $_template );
- $templates[] = array(
- 'template_set_id' => 0,
- 'template_group' => $template['template_group'],
- 'template_content' => $template['template_content'],
- 'template_name' => $template['template_name'],
- 'template_data' => $template['template_data'],
- 'template_updated' => $template['template_updated'],
- 'template_removable' => $template['template_removable'],
- 'template_added_to' => intval($template['template_added_to']),
- 'template_user_added' => 1,
- 'template_user_edited' => 0,
- 'template_master_key' => $template['template_master_key'] ? $template['template_master_key'] : 'root',
- );
- }
- }
-
- //-----------------------------------------
- // Set the CSS
- //-----------------------------------------
-
- $css = array();
-
- foreach( $xml->fetchElements('hookextras_css') as $node )
- {
- foreach( $xml->fetchElements('css', $node) as $_css )
- {
- $_css = $xml->fetchElementsFromRecord( $_css );
- $css[] = array(
- 'css_set_id' => 0,
- 'css_group' => $_css['css_group'],
- 'css_content' => $_css['css_content'],
- 'css_position' => $_css['css_position'],
- 'css_added_to' => 1,
- 'css_app' => $_css['css_app'],
- 'css_app_hide' => $_css['css_app_hide'],
- 'css_attributes' => $_css['css_attributes'],
- 'css_removed' => $_css['css_removed'],
- 'css_modules' => $_css['css_modules'],
- 'css_master_key' => $_css['css_master_key'],
- );
- }
- }
-
- //-----------------------------------------
- // Set the Replacements
- //-----------------------------------------
-
- $replacements = array();
-
- foreach( $xml->fetchElements('hookextras_replacements') as $node )
- {
- foreach( $xml->fetchElements('replacements', $node) as $_r )
- {
- $_r = $xml->fetchElementsFromRecord( $_r );
- $replacements[] = array(
- 'replacement_key' => $_r['replacement_key'],
- 'replacement_content' => $_r['replacement_content'],
- );
- }
- }
-
- //-----------------------------------------
- // Set the tasks
- //-----------------------------------------
-
- $tasks = array();
-
- foreach( $xml->fetchElements('hookextras_tasks') as $node )
- {
- foreach( $xml->fetchElements('tasks', $node) as $_task )
- {
- $task = $xml->fetchElementsFromRecord( $_task );
- $tasks[] = array(
- 'task_title' => $task['task_title'],
- 'task_file' => $task['task_file'],
- 'task_week_day' => $task['task_week_day'],
- 'task_month_day' => $task['task_month_day'],
- 'task_hour' => $task['task_hour'],
- 'task_minute' => $task['task_minute'],
- 'task_cronkey' => $task['task_cronkey'],
- 'task_log' => $task['task_log'],
- 'task_description' => $task['task_description'],
- 'task_enabled' => $task['task_enabled'],
- 'task_key' => $task['task_key'],
- 'task_safemode' => $task['task_safemode'],
- 'task_locked' => $task['task_locked'],
- 'task_application' => $task['task_application'],
- );
- }
- }
-
- //-----------------------------------------
- // Set the database changes
- //-----------------------------------------
-
- $database = array(
- 'create' => array(),
- 'alter' => array(),
- 'update' => array(),
- 'insert' => array(),
- );
-
- foreach( $xml->fetchElements('hookextras_database_create') as $node )
- {
- foreach( $xml->fetchElements('create', $node) as $_table )
- {
- $table = $xml->fetchElementsFromRecord( $_table );
- $database['create'][] = array(
- 'name' => $table['name'],
- 'fields' => $table['fields'],
- 'tabletype' => $table['tabletype'],
- );
- }
- }
-
- foreach( $xml->fetchElements('hookextras_database_alter') as $node )
- {
- foreach( $xml->fetchElements('alter', $node) as $_table )
- {
- $table = $xml->fetchElementsFromRecord( $_table );
- $database['alter'][] = array(
- 'altertype' => $table['altertype'],
- 'table' => $table['table'],
- 'field' => $table['field'],
- 'newfield' => $table['newfield'],
- 'fieldtype' => $table['fieldtype'],
- 'default' => $table['default'],
- );
- }
- }
-
- foreach( $xml->fetchElements('hookextras_database_update') as $node )
- {
- foreach( $xml->fetchElements('update', $node) as $_table )
- {
- $table = $xml->fetchElementsFromRecord( $_table );
- $database['update'][] = array(
- 'table' => $table['table'],
- 'field' => $table['field'],
- 'newvalue' => $table['newvalue'],
- 'oldvalue' => $table['oldvalue'],
- 'where' => $table['where'],
- );
- }
- }
-
- foreach( $xml->fetchElements('hookextras_database_insert') as $node )
- {
- foreach( $xml->fetchElements('insert', $node) as $_table )
- {
- $table = $xml->fetchElementsFromRecord( $_table );
- $database['insert'][] = array(
- 'table' => $table['table'],
- 'updates' => $table['updates'],
- 'fordelete' => $table['fordelete'],
- );
- }
- }
-
- //-----------------------------------------
- // Set some vars for display tallies
- //-----------------------------------------
-
- $filesInserted = 0;
- $settingGroupsInserted = 0;
- $settingsInserted = 0;
- $settingsUpdated = 0;
- $languageInserted = 0;
- $languageUpdated = 0;
- $modulesInserted = 0;
- $modulesUpdated = 0;
- $helpInserted = 0;
- $helpUpdated = 0;
- $templatesInserted = 0;
- $templatesUpdated = 0;
- $templateHooks = false;
- $tasksInserted = 0;
- $tasksUpdated = 0;
- $createQueries = 0;
- $alterQueries = 0;
- $updateQueries = 0;
- $insertQueries = 0;
- $cssInserted = 0;
- $cssUpdated = 0;
- $replacementsInserted = 0;
- $replacementsUpdated = 0;
-
- //-----------------------------------------
- // Insert/update DB records
- //-----------------------------------------
-
- if( $this->hooks[ $config['hook_key'] ]['hook_id'] )
- {
- //-----------------------------------------
- // Don't change enabled/disabled status
- //-----------------------------------------
-
- unset( $config['hook_enabled'] );
-
- $this->DB->update( 'core_hooks', $config, 'hook_id=' . $this->hooks[ $config['hook_key'] ]['hook_id'] );
-
- $hook_id = $this->hooks[ $config['hook_key'] ]['hook_id'];
-
- $extra_data = unserialize( $this->hooks[ $config['hook_key'] ]['hook_extra_data'] );
-
- /* Reset DB */
- $extra_data['database'] = array();
- }
- else
- {
- $config['hook_installed'] = IPS_UNIX_TIME_NOW;
- $this->hook[ $config['hook_key'] ] = $config;
-
- $this->DB->insert( 'core_hooks', $config );
-
- $hook_id = $this->DB->getInsertId();
-
- $this->hook[ $config['hook_key'] ]['hook_id'] = $hook_id;
-
- $extra_data['display'] = $tempExtraData['display'];
- }
-
- if( count($files) )
- {
- //-----------------------------------------
- // If we are updating, remove old files
- //-----------------------------------------
-
- if( $this->hooks[ $config['hook_key'] ]['hook_id'] )
- {
- $this->DB->build( array( 'select' => 'hook_file_id, hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $this->hooks[ $config['hook_key'] ]['hook_id'] ) );
- $outer = $this->DB->execute();
-
- while( $r = $this->DB->fetch($outer) )
- {
- @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
- $this->DB->delete( 'core_hooks_files', 'hook_file_id=' . $r['hook_file_id'] );
- }
- }
-
- foreach( $files as $file )
- {
- //-----------------------------------------
- // Store new files
- //-----------------------------------------
-
- $filename = $file['hook_classname'] . '_' . md5( uniqid( microtime(), true ) ) . '.php';
-
- file_put_contents( IPS_HOOKS_PATH . $filename, $file['hooks_source'] );
- chmod( IPS_HOOKS_PATH . $filename, IPS_FILE_PERMISSION );
-
- $file['hook_file_stored'] = $filename;
- $file['hook_hook_id'] = $hook_id;
-
- $this->DB->insert( 'core_hooks_files', $file );
- $filesInserted++;
-
- /* Need to recache skins? */
- if ( $file['hook_type'] == 'templateHooks' )
- {
- $templateHooks = true;
- }
- }
- }
-
- //-----------------------------------------
- // Put custom install/uninstall file
- //-----------------------------------------
-
- if( is_object($customClass) )
- {
- $extra_data['display']['custom'] = $custom['filename'];
-
- file_put_contents( IPS_HOOKS_PATH . 'install_' . $custom['filename'], $custom['source'] );
- chmod( IPS_HOOKS_PATH . 'install_' . $custom['filename'], IPS_FILE_PERMISSION );
- }
-
- //-----------------------------------------
- // (1) Settings
- //-----------------------------------------
-
- if( count($settingGroups) OR count($settings) )
- {
- $setting_groups = array();
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $setting_groups[ $r['conf_title_id'] ] = $r;
- $setting_groups_by_key[ $r['conf_title_keyword'] ] = $r;
- }
-
- //-----------------------------------------
- // Get current settings.
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'conf_id, conf_key', 'from' => 'core_sys_conf_settings' ) );
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- $cur_settings[ $r['conf_key'] ] = $r['conf_id'];
- }
- }
-
- if( count($settingGroups) )
- {
- $need_to_update = array();
-
- foreach( $settingGroups as $data )
- {
- if ( $data['conf_title_title'] AND $data['conf_title_keyword'] )
- {
- //-----------------------------------------
- // Get ID based on key
- //-----------------------------------------
-
- $conf_id = $setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
-
- $save = array( 'conf_title_title' => $data['conf_title_title'],
- 'conf_title_desc' => $data['conf_title_desc'],
- 'conf_title_keyword' => $data['conf_title_keyword'],
- 'conf_title_app' => $data['conf_title_app'],
- 'conf_title_tab' => $data['conf_title_tab'],
- 'conf_title_noshow' => $data['conf_title_noshow'] );
-
- //-----------------------------------------
- // Not got a row, insert first!
- //-----------------------------------------
-
- if ( ! $conf_id )
- {
- $this->DB->insert( 'core_sys_settings_titles', $save );
- $conf_id = $this->DB->getInsertId();
- $settingGroupsInserted++;
- $extra_data['settingGroups'][] = $save['conf_title_keyword'];
- }
- else
- {
- //-----------------------------------------
- // Update...
- //-----------------------------------------
-
- $this->DB->update( 'core_sys_settings_titles', $save, 'conf_title_id='.$conf_id );
- }
-
- //-----------------------------------------
- // Update settings cache
- //-----------------------------------------
-
- $save['conf_title_id'] = $conf_id;
- $setting_groups_by_key[ $save['conf_title_keyword'] ] = $save;
- $setting_groups[ $save['conf_title_id'] ] = $save;
-
- //-----------------------------------------
- // Set need update...
- //-----------------------------------------
-
- $need_update[] = $conf_id;
- }
- }
- }
-
- if( count($settings) )
- {
- foreach( $settings as $idx => $data )
- {
- $data['conf_group'] = $setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
-
- //-----------------------------------------
- // Remove from array
- //-----------------------------------------
-
- unset( $data['conf_title_keyword'] );
-
- if ( $cur_settings[ $data['conf_key'] ] )
- {
- $this->DB->update( 'core_sys_conf_settings', $data, 'conf_id='.$cur_settings[ $data['conf_key'] ] );
- $settingsUpdated++;
- }
- else
- {
- $this->DB->insert( 'core_sys_conf_settings', $data );
- $settingsInserted++;
- $extra_data['settings'][] = $data['conf_key'];
- }
- }
- }
-
- //-----------------------------------------
- // Update group counts...
- //-----------------------------------------
-
- if ( count( $need_update ) )
- {
- foreach( $need_update as $i => $idx )
- {
- $conf = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group=' . $idx ) );
-
- $count = intval($conf['count']);
-
- $this->DB->update( 'core_sys_settings_titles', array( 'conf_title_count' => $count ), 'conf_title_id='.$idx );
- }
- }
-
- if( count($settingGroups) OR count($settings) )
- {
- $this->cache->rebuildCache( 'settings', 'global' );
- }
-
- //-----------------------------------------
- // (2) Languages
- //-----------------------------------------
-
- if( count($language) )
- {
- $langPacks = array();
-
- $this->DB->build( array( 'select' => 'lang_id', 'from' => 'core_sys_lang' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $langPacks[] = $r['lang_id'];
- }
-
- foreach( $language as $langbit )
- {
- foreach( $langPacks as $lang_id )
- {
- $langbit['lang_id'] = $lang_id;
-
- // See if it exists
- $cnt = $this->DB->buildAndFetch( array( 'select' => 'word_id', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id} AND word_app='{$langbit['word_app']}' AND word_key='{$langbit['word_key']}' AND word_pack='{$langbit['word_pack']}'" ) );
-
- if( $cnt['word_id'] )
- {
- $this->DB->update( 'core_sys_lang_words', $langbit, 'word_id=' . $cnt['word_id'] );
- $languageUpdated++;
- }
- else
- {
- $this->DB->insert( 'core_sys_lang_words', $langbit );
- $languageInserted++;
- $word_id = $this->DB->getInsertId();
- $extra_data['language'][ $langbit['word_pack'] ][] = $langbit['word_key'];
- }
- }
- }
-
- $classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages' );
- $langLib = new $classToLoad();
- $langLib->makeRegistryShortcuts( $this->registry );
-
- foreach( $langPacks as $langId )
- {
- $langLib->cacheToDisk( $langId );
- }
- }
-
- //-----------------------------------------
- // (3) Modules
- //-----------------------------------------
-
- if( count($modules) )
- {
- //-----------------------------------------
- // Get current modules
- //-----------------------------------------
- $cur_modules = array();
- $this->DB->build( array( 'select' => '*',
- 'from' => 'core_sys_module',
- 'order' => 'sys_module_id' ) );
-
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- $cur_modules[ $r['sys_module_application'] ][ $r['sys_module_key'] ] = $r['sys_module_id'];
- }
-
- foreach( $modules as $module )
- {
- //-----------------------------------------
- // Insert or update?
- //-----------------------------------------
-
- if ( $cur_modules[ $module['sys_module_application'] ][ $module['sys_module_key'] ] )
- {
- $this->DB->update( 'core_sys_module', $module, "sys_module_id=" . $cur_modules[ $module['sys_module_application'] ][ $module['sys_module_key'] ] );
- $modulesUpdated++;
- }
- else
- {
- $this->DB->insert( 'core_sys_module', $module );
- $modulesInserted++;
-
- $extra_data['modules'][] = ( $module['sys_module_admin'] ? 'admin' : 'public' ) . '-' . $module['sys_module_application'] . '-' . $module['sys_module_key'];
- }
- }
-
- $classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/applications/applications.php', 'admin_core_applications_applications' );
- $moduleLib = new $classToLoad();
- $moduleLib->makeRegistryShortcuts( $this->registry );
- $moduleLib->moduleRecache();
- $moduleLib->applicationsMenuDataRecache();
- }
-
- //-----------------------------------------
- // (4) Help Files
- //-----------------------------------------
-
- if( count($help) )
- {
- $keys = array();
-
- $this->DB->build( array( 'select' => 'title', 'from' => 'faq' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $keys[] = $r['title'];
- }
-
- foreach( $help as $entry )
- {
- if( in_array( $entry['title'], $keys ) )
- {
- $this->DB->update( 'faq', $entry, "title='{$entry['title']}'" );
- $helpUpdated++;
- }
- else
- {
- $this->DB->insert( 'faq', $entry );
- $helpInserted++;
- $help_id = $this->DB->getInsertId();
- $extra_data['help'][] = $entry['title'];
- }
- }
- }
-
- //-----------------------------------------
- // (6) Templates
- //-----------------------------------------
-
- if( count($templates) )
- {
- $bits = array();
-
- /* Root will always be updated */
- $this->DB->build( array( 'select' => 'template_name,template_group,template_master_key', 'from' => 'skin_templates' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $bits[ $r['template_master_key'] ][ $r['template_group'] ][] = $r['template_name'];
- }
-
- foreach( $templates as $template )
- {
- //-----------------------------------------
- // If template is not in root set, add it to
- // prevent fatal error selecting other skins
- //-----------------------------------------
-
- if ( $template['template_master_key'] != 'root' && ( !isset($bits['root'][ $template['template_group'] ]) OR !in_array( $template['template_name'], $bits['root'][ $template['template_group'] ] ) ) )
- {
- $this->DB->insert( 'skin_templates', array_merge( $template, array( 'template_set_id' => 0, 'template_master_key' => 'root', 'template_content' => '' ) ) );
-
- $extra_data['templates'][ $template['template_group'] ][ $template['template_name'] ] = $template['template_name'];
- $bits['root'][ $template['template_group'] ][] = $template['template_name'];
- }
-
- //-----------------------------------------
- // Ignore unknown skin sets
- //-----------------------------------------
-
- if ( !isset($bits[ $template['template_master_key'] ]) )
- {
- continue;
- }
-
- if( isset($bits[ $template['template_master_key'] ][ $template['template_group'] ]) AND in_array( $template['template_name'], $bits[ $template['template_master_key'] ][ $template['template_group'] ] ) )
- {
- $template['template_updated'] = IPS_UNIX_TIME_NOW;
-
- $this->DB->update( 'skin_templates', $template, "template_master_key='{$template['template_master_key']}' AND template_group='{$template['template_group']}' AND template_name='{$template['template_name']}'" );
- $templatesUpdated++;
- }
- else
- {
- $this->DB->insert( 'skin_templates', $template );
- $templatesInserted++;
-
- $extra_data['templates'][ $template['template_group'] ][ $template['template_name'] ] = $template['template_name'];
- $bits[ $template['template_master_key'] ][ $template['template_group'] ][] = $template['template_name'];
- }
- }
- }
-
- //-----------------------------------------
- // CSS
- //-----------------------------------------
-
- if( count( $css ) )
- {
- $bits = array();
-
- $this->DB->build( array( 'select' => 'css_master_key, css_group', 'from' => 'skin_css' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $bits[ $r['css_master_key'] ][ $r['css_group'] ] = $r['css_group'];
- }
-
- foreach( $css as $entry )
- {
- //-----------------------------------------
- // Ignore unknown skin sets
- //-----------------------------------------
-
- if ( !isset( $bits[ $entry['css_master_key'] ] ) )
- {
- continue;
- }
-
- if( in_array( $entry['css_group'], $bits[ $entry['css_master_key'] ] ) )
- {
- $entry['css_updated'] = IPS_UNIX_TIME_NOW;
-
- $this->DB->update( 'skin_css', $entry, "css_master_key='{$entry['css_master_key']}' AND css_group='{$entry['css_group']}'" );
- $cssUpdated++;
- }
- else
- {
- $this->DB->insert( 'skin_css', $entry );
- $cssInserted++;
-
- $extra_data['css'][ $entry['css_group'] ] = $entry['css_group'];
- $bits[ $entry['css_master_key'] ][ $entry['css_group'] ] = $entry['css_group'];
- }
- }
- }
-
- //-----------------------------------------
- // Skin Replacements
- //-----------------------------------------
-
- if( count( $replacements ) )
- {
- $bits = array();
-
- $this->DB->build( array( 'select' => 'replacement_master_key, replacement_key', 'from' => 'skin_replacements' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $bits[ $r['replacement_master_key'] ][ $r['replacement_key'] ] = $r['replacement_key'];
- }
-
- foreach( $replacements as $entry )
- {
- if ( !isset( $bits[ $entry['replacement_master_key'] ] ) )
- {
- $entry['replacement_master_key'] = 'root';
- }
-
- if( in_array( $entry['replacement_key'], $bits[ $entry['replacement_master_key'] ] ) )
- {
- $this->DB->update( 'skin_replacements', $entry, "replacement_master_key='{$entry['replacement_master_key']}' AND replacement_key='{$entry['replacement_key']}'" );
- $replacementsUpdated++;
- }
- else
- {
- $this->DB->insert( 'skin_replacements', $entry );
- $replacementsInserted++;
-
- $extra_data['replacements'][ $entry['replacement_key'] ] = $entry['replacement_key'];
- }
- }
- }
-
- //-----------------------------------------
- // (7) Tasks
- //-----------------------------------------
-
- if( count($tasks) )
- {
- $keys = array();
-
- $this->DB->build( array( 'select' => 'task_key', 'from' => 'task_manager' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $keys[] = $r['task_key'];
- }
-
- foreach( $tasks as $entry )
- {
- if( in_array( $entry['task_key'], $keys ) )
- {
- $this->DB->update( 'task_manager', $entry, "task_key='{$entry['task_key']}'" );
- $tasksUpdated++;
- }
- else
- {
- $this->DB->insert( 'task_manager', $entry );
- $tasksInserted++;
- $task_id = $this->DB->getInsertId();
- $extra_data['tasks'][] = $entry['task_key'];
- }
- }
- }
-
- //-----------------------------------------
- // (8) Create new tables
- //-----------------------------------------
-
- if( count($database['create']) )
- {
- foreach($database['create'] as $create )
- {
- $query = "CREATE TABLE {$this->settings['sql_tbl_prefix']}{$create['name']} (
- {$create['fields']}
- )";
-
- if( $create['tabletype'] )
- {
- $query .= " ENGINE=" . $create['tabletype'];
- }
- else if( $this->settings['sql_driver'] == 'mysql' AND $this->settings['mysql_tbl_type'] )
- {
- $query .= " ENGINE=" . $this->settings['mysql_tbl_type'];
- }
-
- //-----------------------------------------
- // Fix prefix
- //-----------------------------------------
-
- $this->DB->return_die = true;
- $this->DB->query( $query );
- $this->DB->return_die = false;
- $createQueries++;
-
- $extra_data['database']['create'][] = $create;
- }
- }
-
- //-----------------------------------------
- // (9) Alter tables
- //-----------------------------------------
-
- if( count($database['alter']) )
- {
- foreach( $database['alter'] as $alter )
- {
- $this->DB->return_die = true;
-
- switch( $alter['altertype'] )
- {
- case 'remove':
- $this->DB->dropField( $alter['table'], $alter['field'] );
- break;
-
- case 'add':
- $this->DB->addField( $alter['table'], $alter['field'], $alter['fieldtype'], $alter['default'] );
- break;
-
- case 'change':
- $this->DB->changeField( $alter['table'], $alter['field'], $alter['newfield'], $alter['fieldtype'], $alter['default'] );
- break;
- }
-
- $this->DB->return_die = false;
- $alterQueries++;
- $extra_data['database']['alter'][] = $alter;
- }
- }
-
- //-----------------------------------------
- // (10) Run update queries
- //-----------------------------------------
-
- if( count($database['update']) )
- {
- foreach( $database['update'] as $update )
- {
- $this->DB->return_die = true;
- $this->DB->update( $update['table'], array( $update['field'] => $update['newvalue'] ), html_entity_decode( $update['where'], ENT_QUOTES ) );
- $this->DB->return_die = false;
- $updateQueries++;
- $extra_data['database']['update'][] = $update;
- }
- }
-
- //-----------------------------------------
- // (11) Run insert queries
- //-----------------------------------------
-
- // if( !$this->hooks[ $config['hook_key'] ]['hook_id'] )
- // {
- if( count($database['insert']) )
- {
- foreach( $database['insert'] as $insert )
- {
- $fields = array();
- $content = explode( ',', $insert['updates'] );
-
- foreach( $content as $value )
- {
- list( $field, $toInsert ) = explode( '=', $value );
-
- $fields[ trim($field) ] = str_replace( '~C~', ',', $toInsert );
- }
-
- $this->DB->return_die = true;
- $this->DB->insert( $insert['table'], $fields );
- $this->DB->return_die = false;
- $insertQueries++;
- $extra_data['database']['insert'][] = $insert;
- }
- }
- // }
-
- /* Got an install function to run too? */
- if( is_object($customClass) )
- {
- if( method_exists( $customClass, 'install' ) )
- {
- $customClass->install();
- }
- }
-
- if( count($extra_data) )
- {
- $this->DB->update( 'core_hooks', array( 'hook_extra_data' => serialize( $extra_data ) ), 'hook_id=' . $hook_id );
- }
-
- //print_r($config);
- //print_r($files);
- //print_r($custom);
- //print_r($settingGroups);
- //print_r($settings);
- //print_r($language);
- //print_r($modules);
- //print_r($templates);
- //print_r($tasks);
- //print_r($help);
- //print_r($database);
-
- if ( $addMessage )
- {
- $_tempMsg = <<{$this->lang->words['h_newhookin']}
-
- {$filesInserted} {$this->lang->words['h_filesin']}
- {$settingGroupsInserted} {$this->lang->words['h_settinggin']}
- {$settingsInserted} {$this->lang->words['h_settingin']}
- {$settingsUpdated} {$this->lang->words['h_settingup']}
- {$languageInserted} {$this->lang->words['h_langbitin']}
- {$languageUpdated} {$this->lang->words['h_langbitup']}
- {$modulesInserted} {$this->lang->words['h_modin']}
- {$modulesUpdated} {$this->lang->words['h_modup']}
- {$helpInserted} {$this->lang->words['h_helpin']}
- {$helpUpdated} {$this->lang->words['h_helpup']}
- {$templatesInserted} {$this->lang->words['h_tempin']}
- {$templatesUpdated} {$this->lang->words['h_tempup']}
- {$cssInserted} {$this->lang->words['h_cssin']}
- {$cssUpdated} {$this->lang->words['h_cssup']}
- {$replacementsInserted} {$this->lang->words['h_replacementsin']}
- {$replacementsUpdated} {$this->lang->words['h_replacementsup']}
- {$tasksInserted} {$this->lang->words['h_taskin']}
- {$tasksUpdated} {$this->lang->words['h_taskup']}
- {$createQueries} {$this->lang->words['h_dbcreated']}
- {$alterQueries} {$this->lang->words['h_dbaltered']}
- {$updateQueries} {$this->lang->words['h_updateran']}
- {$insertQueries} {$this->lang->words['h_insertran']}
-
-EOF;
-
- $this->registry->output->setMessage( $_tempMsg, 1 );
- }
-
- //-----------------------------------------
- // Got some skin recaching to do...
- //-----------------------------------------
-
- if( $allowSkinRecache === TRUE AND ( $templatesInserted OR $templatesUpdated OR $templateHooks OR $cssUpdated OR $cssInserted ) )
- {
- /* Rebuild cache */
- $this->rebuildHooksCache();
-
- /* Flag skins for recache */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
- $skinCaching->flagSetForRecache();
- }
- }
-
- /**
- * Show the form to export a hook
- *
- * @return void
- */
- protected function _exportHook()
- {
- /* Get the hook */
- $id = intval($this->request['id']);
-
- if( !$id )
- {
- $this->registry->output->showError( $this->lang->words['h_noexport'], 1112 );
- }
-
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
-
- if( !$hookData['hook_id'] )
- {
- $this->registry->output->showError( $this->lang->words['h_noexport'], 1113 );
- }
-
- /* Set defaults */
- $hookData['hook_extra_data'] = unserialize( $hookData['hook_extra_data'] );
-
- /* Output */
- $this->registry->output->html .= $this->html->hooksExport( $hookData );
- }
-
- /**
- * Actually export the damn hook already
- * Sorry, it has been a long day...
- *
- * @return @e void
- */
- protected function _doExportHook()
- {
- //-----------------------------------------
- // Get hook
- //-----------------------------------------
-
- $id = intval($this->request['id']);
-
- if( !$id )
- {
- $this->registry->output->showError( $this->lang->words['h_noexport'], 1114 );
- }
-
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
-
- if( !$hookData['hook_id'] )
- {
- $this->registry->output->showError( $this->lang->words['h_noexport'], 1115 );
- }
-
- $extra_data = unserialize( $hookData['hook_extra_data'] );
-
- //-----------------------------------------
- // Get hook files
- //-----------------------------------------
-
- $files = array();
- $index = 1;
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id, 'order' => 'hook_file_id ASC' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $files[ $index ] = $r;
- $index++;
- }
-
- //-----------------------------------------
- // Get XML class
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
-
- $xml = new classXML( IPS_DOC_CHAR_SET );
-
- $xml->newXMLDocument();
- $xml->addElement( 'hookexport' );
-
- //-----------------------------------------
- // Put hook data in export
- //-----------------------------------------
-
- $xml->addElement( 'hookdata', 'hookexport' );
- $content = array();
-
- foreach( $hookData as $k => $v )
- {
- if( in_array( $k, array( 'hook_id', 'hook_enabled', 'hook_installed', 'hook_updated', 'hook_position' ) ) )
- {
- continue;
- }
-
- $content[ $k ] = $v;
- }
-
- $xml->addElementAsRecord( 'hookdata', 'config', $content );
-
- //-----------------------------------------
- // Put hook files in export
- //-----------------------------------------
-
- $xml->addElement( 'hookfiles', 'hookexport' );
-
- foreach( $files as $index => $r )
- {
- $content = array();
-
- foreach( $r as $k => $v )
- {
- if( in_array( $k, array( 'hook_file_id', 'hook_hook_id', 'hook_file_stored', 'hooks_source' ) ) )
- {
- continue;
- }
-
- $content[ $k ] = $v;
- }
-
- $source = is_file( IPS_HOOKS_PATH . $r['hook_file_stored'] ) ? file_get_contents( IPS_HOOKS_PATH . $r['hook_file_stored'] ) : '';
-
- if ( !empty($source) && in_array( $r['hook_type'], array( 'skinHooks', 'commandHooks', 'libraryHooks' ) ) )
- {
- $source = $this->_cleanSource( $source );
- }
-
- $content['hooks_source'] = $source;
-
- $xml->addElementAsRecord( 'hookfiles', 'file', $content );
- }
-
- //-----------------------------------------
- // Custom install/uninstall script?
- //-----------------------------------------
-
- if( $extra_data['custom'] )
- {
- $content = array();
- $xml->addElement( 'hookextras_custom', 'hookexport' );
-
- $content['filename'] = $extra_data['custom'];
- $content['source'] = is_file( IPS_HOOKS_PATH . 'install_' . $extra_data['custom'] ) ? file_get_contents( IPS_HOOKS_PATH . 'install_' . $extra_data['custom'] ) : '';
-
- $xml->addElementAsRecord( 'hookextras_custom', 'file', $content );
- }
-
- //-----------------------------------------
- // Settings or setting groups?
- //-----------------------------------------
-
- $entry = array();
- $_groups = array();
- $_settings = array();
- $titles = array();
- $content = array();
-
- $xml->addElement( 'hookextras_settings', 'hookexport' );
-
- # Store group ids and setting ids for entire setting groups
- if( is_array($extra_data['settingGroups']) AND count($extra_data['settingGroups']) )
- {
- $_groups = $extra_data['settingGroups'];
- $_groupIds = array();
-
- $this->DB->build( array( 'select' => 'conf_title_id', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN('" . implode( "','", $_groups ) . "')" ) );
- $this->DB->execute();
-
- while( $rr = $this->DB->fetch() )
- {
- $_groupIds[] = $rr['conf_title_id'];
- }
-
- if( count($_groupIds) )
- {
- $this->DB->build( array( 'select' => 'conf_key', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group IN(' . implode( ',', $_groupIds ) . ')' ) );
- $this->DB->execute();
-
- while( $setting = $this->DB->fetch() )
- {
- $_settings[] = $setting['conf_key'];
- }
- }
- }
-
- # Store group ids and setting ids for indvidual settings
- if( is_array($extra_data['settings']) AND count($extra_data['settings']) )
- {
- foreach( $extra_data['settings'] as $_aSetting )
- {
- $_settings[] = $_aSetting;
- }
-
- $this->DB->build( array( 'select' => 't.conf_title_keyword',
- 'from' => array( 'core_sys_settings_titles' => 't' ),
- 'where' => "c.conf_key IN('" . implode( "','", $extra_data['settings'] ) . "')",
- 'add_join' => array(
- array(
- 'from' => array( 'core_sys_conf_settings' => 'c' ),
- 'where' => 'c.conf_group=t.conf_title_id',
- 'type' => 'left',
- )
- )
- ) );
- $this->DB->execute();
-
- while( $group = $this->DB->fetch() )
- {
- $_groups[] = $group['conf_title_keyword'];
- }
- }
-
- if( count($_groups) )
- {
- # Now get the group data for the XML file
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN('" . implode( "','", $_groups ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $content = array();
-
- $titles[ $r['conf_title_id'] ] = $r['conf_title_keyword'];
-
- $content['conf_is_title'] = 1;
-
- foreach( $r as $k => $v )
- {
- if( in_array( $k, array( 'conf_title_tab', 'conf_title_keyword', 'conf_title_title', 'conf_title_desc', 'conf_title_app', 'conf_title_noshow' ) ) )
- {
- $content[ $k ] = $v;
- }
- }
-
- $xml->addElementAsRecord( 'hookextras_settings', 'setting', $content );
- }
- }
-
- if( count($_settings) )
- {
- # Now get the group data for the XML file
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN('" . implode( "','", $_settings ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $r['conf_value'] = '';
- $r['conf_title_keyword'] = $titles[ $r['conf_group'] ];
- $r['conf_is_title'] = 0;
-
- $xml->addElementAsRecord( 'hookextras_settings', 'setting', $r );
- }
- }
-
- //-----------------------------------------
- // Language strings/files
- //-----------------------------------------
-
- $entry = array();
-
- $xml->addElement( 'hookextras_language', 'hookexport' );
-
- if( is_array($extra_data['language']) AND count($extra_data['language']) )
- {
- foreach( $extra_data['language'] as $file => $strings )
- {
- $bits = explode( '_', $file );
- $app = $bits[0];
- $pack = str_replace( $app.'_', '', $file );
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "word_app='{$app}' AND word_pack='{$pack}' AND word_key IN('" . implode( "','", $strings ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $content = array();
-
- foreach( $r as $k => $v )
- {
- if( !in_array( $k, array( 'word_app', 'word_pack', 'word_key', 'word_default' ) ) )
- {
- continue;
- }
-
- $content[ $k ] = $v;
- }
-
- $xml->addElementAsRecord( 'hookextras_language', 'language', $content );
- }
- }
- }
-
- //-----------------------------------------
- // Modules
- //-----------------------------------------
-
- $xml->addElement( 'hookextras_modules', 'hookexport' );
-
- if( is_array($extra_data['modules']) AND count($extra_data['modules']) )
- {
- foreach ( $extra_data['modules'] as $module )
- {
- list( $_side, $_app, $_module ) = explode( '-', $module );
- $_is_admin = ( $_side == 'admin' ) ? 1 : 0;
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_module', 'where' => "sys_module_application='{$_app}' AND sys_module_key='{$_module}' AND sys_module_admin={$_is_admin}" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- unset($r['sys_module_id']);
-
- $xml->addElementAsRecord( 'hookextras_modules', 'module', $r );
- }
- }
- }
-
- //-----------------------------------------
- // Help files
- //-----------------------------------------
-
- $xml->addElement( 'hookextras_help', 'hookexport' );
-
- if( is_array($extra_data['help']) AND count($extra_data['help']) )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'faq', 'where' => "title IN('" . implode( "','", $extra_data['help'] ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- unset($r['id']);
-
- $xml->addElementAsRecord( 'hookextras_help', 'help', $r );
- }
- }
-
- //-----------------------------------------
- // Skin templates
- //-----------------------------------------
-
- $remapData = $this->registry->output->buildRemapData( true );
-
- $xml->addElement( 'hookextras_templates', 'hookexport' );
-
- if( is_array($extra_data['templates']) AND count($extra_data['templates']) )
- {
- foreach( $extra_data['templates'] as $file => $templates )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'skin_templates', 'where' => "template_set_id IN ('" . implode( "','", $remapData['export'] ) . "') AND template_master_key != '' AND template_group='{$file}' AND template_name IN('" . implode( "','", $templates ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- unset($r['template_id']);
- unset($r['template_set_id']);
-
- $xml->addElementAsRecord( 'hookextras_templates', 'templates', $r );
- }
- }
- }
-
- //-----------------------------------------
- // CSS
- //-----------------------------------------
-
- $xml->addElement( 'hookextras_css', 'hookexport' );
-
- if( is_array( $extra_data['css'] ) AND count ( $extra_data['css'] ) )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'skin_css', 'where' => "css_set_id IN ('" . implode( "','", $remapData['export'] ) . "') AND css_master_key != '' AND css_group IN('" . implode( "','", $extra_data['css'] ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- unset($r['css_id']);
- unset($r['css_set_id']);
-
- $xml->addElementAsRecord( 'hookextras_css', 'css', $r );
- }
- }
-
- //-----------------------------------------
- // Replacements
- //-----------------------------------------
-
- $xml->addElement( 'hookextras_replacements', 'hookexport' );
-
- if( is_array( $extra_data['replacements'] ) AND count ( $extra_data['replacements'] ) )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'skin_replacements', 'where' => "replacement_key IN('" . implode( "','", $extra_data['replacements'] ) . "')", 'group' => 'replacement_key' ) );
-
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- unset($r['replacement_id']);
- unset($r['replacement_set_id']);
-
- $xml->addElementAsRecord( 'hookextras_replacements', 'replacements', $r );
- }
- }
-
- //-----------------------------------------
- // Tasks
- //-----------------------------------------
-
- $xml->addElement( 'hookextras_tasks', 'hookexport' );
-
- if( is_array($extra_data['tasks']) AND count($extra_data['tasks']) )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'task_manager', 'where' => "task_key IN('" . implode( "','", $extra_data['tasks'] ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- unset($r['task_id']);
- unset($r['task_next_run']);
-
- $xml->addElementAsRecord( 'hookextras_tasks', 'tasks', $r );
- }
- }
-
- //-----------------------------------------
- // Database changes
- //-----------------------------------------
-
- $xml->addElement( 'hookextras_database_create', 'hookexport' );
-
- if( is_array($extra_data['database']['create']) AND count($extra_data['database']['create']) )
- {
- foreach( $extra_data['database']['create'] as $create_query )
- {
- $xml->addElementAsRecord( 'hookextras_database_create', 'create', $create_query );
- }
- }
-
- $xml->addElement( 'hookextras_database_alter', 'hookexport' );
-
- if( is_array($extra_data['database']['alter']) AND count($extra_data['database']['alter']) )
- {
- foreach( $extra_data['database']['alter'] as $alter_query )
- {
- $xml->addElementAsRecord( 'hookextras_database_alter', 'alter', $alter_query );
- }
- }
-
- $xml->addElement( 'hookextras_database_update', 'hookexport' );
-
- if( is_array($extra_data['database']['update']) AND count($extra_data['database']['update']) )
- {
- foreach( $extra_data['database']['update'] as $update_query )
- {
- $xml->addElementAsRecord( 'hookextras_database_update', 'update', $update_query );
- }
- }
-
- $xml->addElement( 'hookextras_database_insert', 'hookexport' );
-
- if( is_array($extra_data['database']['insert']) AND count($extra_data['database']['insert']) )
- {
- foreach( $extra_data['database']['insert'] as $insert_query )
- {
- $xml->addElementAsRecord( 'hookextras_database_insert', 'insert', $insert_query );
- }
- }
-
- //-----------------------------------------
- // Print to browser
- //-----------------------------------------
-
- $this->registry->output->showDownload( $xml->fetchDocument(), $hookData['hook_key'] . '.xml', '', 0 );
- }
-
- /**
- * Clean source code for export..
- *
- * @param string Hook source code
- * @return string "Cleaned" source code
- */
- protected function _cleanSource( $source )
- {
- $source = preg_replace( "/class\s+(\S+)\s+extends\s+(\S+)/i", "class \\1 extends (~extends~)", $source );
-
- return $source;
- }
-
- /**
- * Fix hook positions
- *
- * @return @e void
- */
- protected function _fixPositions()
- {
- /* Init vars */
- $new_order = 0;
- $usedActions = array();
-
- $this->DB->build( array( 'select' => 'hook_id, hook_position', 'from' => 'core_hooks', 'where' => 'hook_enabled=1', 'order' => 'hook_position ASC' ) );
- $qid = $this->DB->execute();
-
- while ( $hook = $this->DB->fetch( $qid ) )
- {
- $new_order++;
- $this->DB->update( 'core_hooks', array ( 'hook_position' => $new_order ), "hook_id={$hook['hook_id']}" );
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => "hook_type IN ('commandHooks', 'skinHooks', 'libraryHooks' ) AND hook_hook_id=" . $hook['hook_id'] ) );
- $this->DB->execute();
-
- while( $file = $this->DB->fetch() )
- {
- if( $file['hooks_source'] )
- {
- $source = $this->_cleanSource( $file['hooks_source'] );
- }
- else
- {
- $source = is_file( IPS_HOOKS_PATH . $file['hook_file_stored'] ) ? file_get_contents( IPS_HOOKS_PATH . $file['hook_file_stored'] ) : '';
-
- if( $source )
- {
- $source = $this->_cleanSource( $source );
- }
- }
-
- if( $source )
- {
- $hook_data = unserialize( $file['hook_data'] );
- $overload = $hook_data['classToOverload'];
- $newClass = $overload;
-
- $app = ( $file['hook_type'] == 'libraryHooks' ) ? trim($hook_data['libApplication']) : '~_NO_APP_~';
-
- if( isset( $usedActions[ $app ][ $overload ] ) )
- {
- $newClass = $usedActions[ $app ][ $overload ];
- }
- else if( $file['hook_type'] == 'skinHooks' )
- {
- $newClass .= "(~id~)";
- }
-
- $source = str_replace( "(~extends~)", $newClass, $source );
-
- file_put_contents( IPS_HOOKS_PATH . $file['hook_file_stored'], $source );
-
- $usedActions[ $app ][ $hook_data['classToOverload'] ] = $file['hook_classname'];
- }
- }
- }
- }
-
- /**
- * Check if there is an update for a hook
- *
- * @param string URL to check
- * @param string Long version number
- * @return bool
- */
- public function _updateAvailable( $url, $version )
- {
- if( empty($url) || $version === '' )
- {
- return false;
- }
-
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . '/classFileManagement.php', 'classFileManagement' );
- $checker = new $classToLoad();
-
- /* Timeout to prevent page from taking too long */
- $checker->timeout = 5;
-
- /* Setup url and check */
- $url = str_replace( 'php&', 'php?', $url );
- $url .= '&boardVersion=' . IPB_LONG_VERSION . '&version=' . $version;
-
- $return = $checker->getFileContents( $url );
-
- /* Return the content (if valid) or return 'no update' */
- return ( strpos( $return, '0' ) === 0 || strpos( $return, '1' ) === 0 ) ? explode( '|', $return ) : array( 0 );
- }
-
- /**
- * Sorts hooks by their position
- * (this is used to avoid a mysql filesort)
- *
- * @param array $a First hook data
- * @param array $b Second hook data
- * @return @e integer
- */
- protected function sortHooksByPosition( $a, $b )
- {
- if ( $a['hook_position'] == $b['hook_position'] )
- {
- return 0;
- }
-
- return ( $a['hook_position'] < $b['hook_position'] ) ? -1 : 1;
- }
-
- /**
- * Hooks overview
- *
- * @return @e void [Outputs to screen]
- */
- public function _hooksOverview()
- {
- /* INI */
- $hooksFound = array( 'installed' => array(), 'uninstalled' => array() );
- $hookwarnings = 0;
- $hookUpdates = 0;
- $checkUpdates = !empty( $this->request['checkUpdates'] ) ? true : false;
- $message = '';
- $confGroupIdsToLoad = array();
- $confGroupKeysToLoad= array();
-
- /* Get current hooks */
- $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks' ) );
- $outer = $this->DB->execute();
-
- while( $r = $this->DB->fetch($outer) )
- {
- /* Format some dates */
- $r['_updated'] = $this->registry->getClass('class_localization')->formatTime( $r['hook_updated'] );
- $r['_installed'] = $this->registry->getClass('class_localization')->formatTime( $r['hook_installed'] );
-
- /* Got updates? */
- if ( $r['hook_update_check'] && $checkUpdates === true )
- {
- $r['hook_update_available'] = $this->_updateAvailable( $r['hook_update_check'], $r['hook_version_long'] );
-
- if ( $r['hook_update_available'][0] )
- {
- $hookUpdates++;
- }
- }
- else
- {
- $r['hook_update_available'] = array( 0 );
- }
-
- /* Got some setting groups to take care of? */
- $r['_has_setting_links'] = null;
- $r['_hook_extra_data'] = IPSLib::isSerialized($r['hook_extra_data']) ? unserialize($r['hook_extra_data']) : array();
-
- if ( is_array($r['_hook_extra_data']['settingGroups']) && count($r['_hook_extra_data']['settingGroups']) )
- {
- $r['_has_setting_links'] = array();
-
- foreach( $r['_hook_extra_data']['settingGroups'] as $_group )
- {
- $confGroupKeysToLoad[ $_group ] = $_group;
- }
- }
-
- if ( is_array($r['_hook_extra_data']['settings']) && count($r['_hook_extra_data']['settings']) )
- {
- $r['_has_setting_links'] = array();
-
- $this->DB->build( array( 'select' => 'conf_group, conf_key', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN ('" . implode( "','", $r['_hook_extra_data']['settings'] ) . "')" ) );
- $this->DB->execute();
-
- while( $hsg = $this->DB->fetch() )
- {
- $confGroupIdsToLoad[ $hsg['conf_key'] ] = $hsg['conf_group'];
- }
- }
-
- /* Check requirements */
- $r['_require_errors'] = $this->checkHookRequirements( $r );
-
- /* Store */
- if( $r['hook_enabled'] )
- {
- if ( count($r['_require_errors']) )
- {
- $hookwarnings++;
- }
-
- $hooksFound['installed'][ $r['hook_id'] ] = $r;
- }
- else
- {
- $hooksFound['uninstalled'][ $r['hook_id'] ] = $r;
- }
- }
-
- /* Got groups to load? */
- $where = array();
-
- if ( count($confGroupKeysToLoad) )
- {
- $where[] = "conf_title_keyword IN ('" . implode( "','", $confGroupKeysToLoad ) . "')";
- }
-
- if ( count($confGroupIdsToLoad) )
- {
- $where[] = "conf_title_id IN (" . implode( ",", $confGroupIdsToLoad ) . ")";
- }
-
- if ( count($where) )
- {
- $confGroupsLoaded = array();
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'where' => implode( ' OR ', $where ) ) );
- $this->DB->execute();
-
- while( $gr = $this->DB->fetch() )
- {
- if ( empty($gr['conf_title_noshow']) )
- {
- $confGroupsLoaded['ids'][ $gr['conf_title_id'] ] = $gr;
- $confGroupsLoaded['keys'][ $gr['conf_title_keyword'] ] = & $confGroupsLoaded['ids'][ $gr['conf_title_id'] ];
- }
- }
-
- /* Merge back the data */
- foreach( $hooksFound as $rk => $rt )
- {
- foreach( $rt as $sk => $st )
- {
- if ( is_array($st['_has_setting_links']) )
- {
- if ( is_array($st['_hook_extra_data']['settingGroups']) && count($st['_hook_extra_data']['settingGroups']) )
- {
- foreach( $st['_hook_extra_data']['settingGroups'] as $_group )
- {
- if ( isset($confGroupsLoaded['keys'][ $_group ]) )
- {
- $hooksFound[ $rk ][ $sk ]['_has_setting_links'][ $confGroupsLoaded['keys'][ $_group ]['conf_title_id'] ] = $confGroupsLoaded['keys'][ $_group ]['conf_title_title'];
- }
- }
- }
-
- if ( is_array($st['_hook_extra_data']['settings']) && count($st['_hook_extra_data']['settings']) )
- {
- foreach( $st['_hook_extra_data']['settings'] as $_id )
- {
- if ( isset($confGroupsLoaded['ids'][ $confGroupIdsToLoad[ $_id ] ]) )
- {
- $hooksFound[ $rk ][ $sk ]['_has_setting_links'][ $confGroupIdsToLoad[ $_id ] ] = $confGroupsLoaded['ids'][ $confGroupIdsToLoad[ $_id ] ]['conf_title_title'];
- }
- }
- }
- }
- }
- }
- }
-
- /* Got updates to show? */
- if ( $checkUpdates === true )
- {
- $message = ( $hookUpdates == 1 ) ? $this->lang->words['updates_string_single'] : sprintf( $this->lang->words['updates_string_more'], $hookUpdates );
- }
-
- if ( count($hooksFound['installed']) )
- {
- uasort( $hooksFound['installed'], array( $this, 'sortHooksByPosition' ) );
- }
-
- /* Output */
- $this->registry->output->html .= $this->html->hooksOverview( $hooksFound, $hookwarnings, $message );
- }
-
- /**
- * Disables all hook
- *
- * @return @e void [Outputs to screen]
- */
- protected function _disableAllHooks()
- {
- /* INIT */
- $activeHookIds = array();
-
- /* Query Enabled Hooks */
- $this->DB->build( array( 'select' => 'hook_id', 'from' => 'core_hooks', 'where' => "hook_enabled=1" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $activeHookIds[] = $r['hook_id'];
- }
-
- /* Make sure there were active hooks */
- if( ! count( $activeHookIds ) )
- {
- $this->registry->output->global_message = $this->lang->words['hook_disable_all_none'];
- $this->_hooksOverview();
- return;
- }
-
- /* Disable hooks */
- $this->DB->update( 'core_hooks', array( 'hook_enabled' => 0 ), 'hook_id IN( ' . implode( ',', $activeHookIds ) . ' ) ' );
-
- /* Save to cache */
- $this->cache->setCache( 'disabledHooksCache', $activeHookIds, array( 'array' => 1 ) );
-
- /* Rebuild cache */
- $this->rebuildHooksCache();
-
- /* All Done */
- $this->registry->output->global_message = $this->lang->words['hook_disabled_all'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /**
- * Re-enable all hook
- *
- * @return @e void [Outputs to screen]
- */
- protected function _reenableAllHooks()
- {
- /* INIT */
- $activeHookIds = $this->cache->getCache( 'disabledHooksCache' );
-
- /* Make sure there were active hooks */
- if( ! count( $activeHookIds ) )
- {
- $this->registry->output->global_message = $this->lang->words['hook_enable_all_none'];
- $this->_hooksOverview();
- return;
- }
-
- /* Disable hooks */
- $this->DB->update( 'core_hooks', array( 'hook_enabled' => 1 ), 'hook_id IN( ' . implode( ',', $activeHookIds ) . ' ) ' );
-
- /* Save to cache */
- $this->cache->setCache( 'disabledHooksCache', array(), array( 'array' => 1 ) );
-
- /* Rebuild cache */
- $this->rebuildHooksCache();
-
- /* Flag skins for recache */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
-
- /* Flag all for recache */
- $skinCaching->flagSetForRecache();
-
- /* All Done */
- $this->registry->output->global_message = $this->lang->words['hook_reenable_all'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /**
- * Disables a hook
- *
- * @return @e void [Outputs to screen]
- */
- protected function _disableHook()
- {
- /* INI */
- $hook_id = intval( $this->request['id'] );
-
- if( !$hook_id )
- {
- $this->registry->output->showError( $this->lang->words['h_noedit'], '1118.D' );
- }
-
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id ) );
-
- if( !$hookData['hook_id'] )
- {
- $this->registry->output->showError( $this->lang->words['h_noedit'], '1119.D' );
- }
-
- /* Do update */
- $this->DB->update( 'core_hooks', array( 'hook_enabled' => 0, 'hook_position' => 0 ), "hook_id={$hookData['hook_id']}" );
-
- /* Rebuild cache */
- $this->rebuildHooksCache();
-
- /* Rebuild global caches */
- try
- {
- IPSLib::cacheGlobalCaches();
- }
- catch( Exception $e ){}
-
- /* Flag skins for recache */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
- $skinCaching->flagSetForRecache();
-
- /* Redirect */
- $this->registry->output->setMessage( $this->lang->words['h_hasbeendisabled'] );
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /**
- * Enables a hook
- *
- * @return @e void [Outputs to screen]
- */
- protected function _enableHook()
- {
- /* INI */
- $hook_id = intval($this->request['id']);
-
- if( !$hook_id )
- {
- $this->registry->output->showError( $this->lang->words['h_noedit'], '1118.E' );
- }
-
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id ) );
-
- if( !$hookData['hook_id'] )
- {
- $this->registry->output->showError( $this->lang->words['h_noedit'], '1119.E' );
- }
-
- /* Check for requirements */
- if ( empty($this->request['skipRequirements']) )
- {
- $errors = $this->checkHookRequirements( $hookData );
-
- if ( count($errors) )
- {
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=check_requirements&fromInstall=1&id='.$hook_id );
- }
- }
-
- /* Do update */
- $this->DB->update( 'core_hooks', array( 'hook_enabled' => 1 ), "hook_id={$hookData['hook_id']}" );
-
- /* Rebuild cache */
- $this->rebuildHooksCache();
-
- /* Rebuild global caches */
- try
- {
- IPSLib::cacheGlobalCaches();
- }
- catch( Exception $e ){}
-
- /* Flag skins for recache */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
- $skinCaching->flagSetForRecache();
-
- /* Redirect */
- $this->registry->output->global_message = $this->lang->words['h_hasbeenenabled'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /**
- * Uninstall a hook
- *
- * @return @e void [Outputs to screen]
- */
- protected function _uninstallHook()
- {
- /* Init vars */
- $hook_id = intval( $this->request['id'] );
-
- $hook = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id ) );
- $extra_data = unserialize( $hook['hook_extra_data'] );
-
- if ( ! $hook['hook_id'] )
- {
- $this->registry->output->global_message = $this->lang->words['h_hasbeenun'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /* Got any custom file to initialize? */
- $_customFile = '';
- $customClass = null;
-
- if ( $extra_data['display']['custom'] )
- {
- $_customFile = IPS_HOOKS_PATH . 'install_' . $extra_data['display']['custom'];
-
- if( is_file( $_customFile ) )
- {
- require_once( $_customFile );/*noLibHook*/
-
- $classname = str_replace( '.php', '', $extra_data['display']['custom'] );
-
- if( class_exists( $classname ) )
- {
- $customClass = new $classname( $this->registry );
-
- if( method_exists( $customClass, 'pre_uninstall' ) )
- {
- $customClass->pre_uninstall();
- }
- }
- }
- }
-
- /* Get associated files */
- $this->DB->build( array( 'select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $hook_id ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
- }
-
- /* Delete hook file entries */
- $this->DB->delete( 'core_hooks_files', "hook_hook_id={$hook_id}" );
-
- //-----------------------------------------
- // Settings or setting groups?
- //-----------------------------------------
-
- if( count($extra_data['settingGroups']) )
- {
- $this->DB->delete( 'core_sys_settings_titles', "conf_title_keyword IN('" . implode( "','", $extra_data['settingGroups'] ) . "')" );
- }
-
- if( count($extra_data['settings']) )
- {
- $this->DB->delete( 'core_sys_conf_settings', "conf_key IN('" . implode( "','", $extra_data['settings'] ) . "')" );
- }
-
- $this->cache->rebuildCache( 'settings', 'global' );
-
- //-----------------------------------------
- // Language strings/files
- //-----------------------------------------
-
- if( count($extra_data['language']) )
- {
- foreach( $extra_data['language'] as $file => $bit )
- {
- $this->DB->delete( 'core_sys_lang_words', "word_pack='{$file}' AND word_key IN('" . implode( "','", $bit ) . "')" );
- }
-
- $langPacks = array();
-
- $this->DB->build( array( 'select' => 'lang_id', 'from' => 'core_sys_lang' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $langPacks[] = $r['lang_id'];
- }
-
- $classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages' );
- $langLib = new $classToLoad();
- $langLib->makeRegistryShortcuts( $this->registry );
-
- foreach( $langPacks as $langId )
- {
- $langLib->cacheToDisk( $langId );
- }
- }
-
- //-----------------------------------------
- // Modules
- //-----------------------------------------
-
- if( count($extra_data['modules']) )
- {
- foreach( $extra_data['modules'] as $module )
- {
- list( $_side, $_app, $_module ) = explode( '-', $module );
- $_is_admin = ( $_side == 'admin' ) ? 1 : 0;
-
- $this->DB->delete( 'core_sys_module', "sys_module_application='{$_app}' AND sys_module_key='{$_module}' AND sys_module_admin={$_is_admin}" );
- }
-
- $this->cache->rebuildCache( 'module_cache', 'global' );
- $this->cache->rebuildCache( 'app_menu_cache', 'global' );
- }
-
- //-----------------------------------------
- // Help files
- //-----------------------------------------
-
- if( count($extra_data['help']) )
- {
- $this->DB->delete( 'faq', "title IN('" . implode( "','", $extra_data['help'] ) . "')" );
- }
-
- //-----------------------------------------
- // Skin templates
- //-----------------------------------------
-
- if( count($extra_data['templates']) )
- {
- foreach( $extra_data['templates'] as $group => $bits )
- {
- $this->DB->delete( 'skin_templates', "template_group='{$group}' AND template_name IN('" . implode( "','", $bits ) . "')" );
- }
-
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
- $skinCaching->rebuildPHPTemplates( 0 );
- }
-
- //-----------------------------------------
- // CSS
- //-----------------------------------------
-
- if( count( $extra_data['css'] ) )
- {
- $this->DB->delete( 'skin_css', "css_group IN('" . implode( "','", $extra_data['css'] ) . "')" );
-
- if( ! $skinCaching )
- {
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
- }
-
- $skinCaching->rebuildCSSCache( 0 );
- }
-
- //-----------------------------------------
- // Tasks
- //-----------------------------------------
-
- if( count($extra_data['tasks']) )
- {
- $this->DB->delete( 'task_manager', "task_key IN('" . implode( "','", $extra_data['tasks'] ) . "')" );
- }
-
- //-----------------------------------------
- // Database changes
- //-----------------------------------------
-
- if( is_array($extra_data['database']['create']) AND count($extra_data['database']['create']) )
- {
- foreach( $extra_data['database']['create'] as $create_query )
- {
- $this->DB->return_die = true;
- $this->DB->dropTable( $create_query['name'] );
- $this->DB->return_die = false;
- }
- }
-
- if( is_array($extra_data['database']['alter']) AND count($extra_data['database']['alter']) )
- {
- foreach( $extra_data['database']['alter'] as $alter_query )
- {
- $this->DB->return_die = true;
-
- if( $alter_query['altertype'] == 'add' )
- {
- if( $this->DB->checkForField( $alter_query['field'], $alter_query['table'] ) )
- {
- $this->DB->dropField( $alter_query['table'], $alter_query['field'] );
- }
- }
- else if( $alter_query['altertype'] == 'change' )
- {
- if( $this->DB->checkForField( $alter_query['newfield'], $alter_query['table'] ) )
- {
- $this->DB->changeField( $alter_query['table'] , $alter_query['newfield'], $alter_query['field'], $alter_query['fieldtype'], $alter_query['default'] );
- }
- }
-
- $this->DB->return_die = false;
- }
- }
-
- if( is_array($extra_data['database']['update']) AND count($extra_data['database']['update']) )
- {
- foreach( $extra_data['database']['update'] as $update_query )
- {
- $this->DB->return_die = true;
- $this->DB->update( $update_query['table'], array( $update_query['field'] => $update_query['oldvalue'] ), $update_query['where'] );
- $this->DB->return_die = false;
- }
- }
-
- if( is_array($extra_data['database']['insert']) AND count($extra_data['database']['insert']) )
- {
- foreach( $extra_data['database']['insert'] as $insert_query )
- {
- if( $insert_query['fordelete'] )
- {
- $this->DB->return_die = true;
- $this->DB->delete( $insert_query['table'], $insert_query['fordelete'] );
- $this->DB->return_die = false;
- }
- }
- }
-
- //-----------------------------------------
- // Custom install/uninstall script?
- //-----------------------------------------
-
- if ( $_customFile )
- {
- if( is_object($customClass) && method_exists( $customClass, 'uninstall' ) )
- {
- $customClass->uninstall();
- }
-
- @unlink( $_customFile );
- }
-
- /* Delete main hook entry */
- $this->DB->delete( 'core_hooks', "hook_id={$hook_id}" );
-
- $this->rebuildHooksCache();
-
- /* Done */
- $this->registry->output->global_message = $this->lang->words['h_hasbeenun'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /**
- * Hook add/edit form
- * This dynamic form allows users to associate multiple files with a single hook.
- *
- * @param string [add|edit]
- * @return @e void [Outputs to screen]
- */
- protected function _hookForm( $type='add' )
- {
- /* Init vars */
- $form = array();
- $files = array();
- $hookData = array();
- $requirements = array();
- $entryPoints = array( 'foreach' => array( array( 'outer.pre', $this->lang->words['h_outerpre'] ),
- array( 'inner.pre', $this->lang->words['h_innerpre'] ),
- array( 'inner.post', $this->lang->words['h_innerpost'] ),
- array( 'outer.post', $this->lang->words['h_outerpost'] )
- ),
- 'if' => array( array( 'pre.startif', $this->lang->words['h_prestartif'] ),
- array( 'post.startif', $this->lang->words['h_poststartif'] ),
- array( 'pre.else', $this->lang->words['h_preelse']),
- array( 'post.else', $this->lang->words['h_postelse'] ),
- array( 'pre.endif', $this->lang->words['h_preendif'] ),
- array( 'post.endif', $this->lang->words['h_postendif'] )
- )
- );
-
- /* Edit time? */
- if( $type == 'edit' )
- {
- $id = intval($this->request['id']);
-
- if( !$id )
- {
- $this->registry->output->showError( $this->lang->words['h_noedit'], 1116 );
- }
-
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
-
- if( !$hookData['hook_id'] )
- {
- $this->registry->output->showError( $this->lang->words['h_noedit'], 1117 );
- }
-
- /* Sort out extra stuff and requirements */
- $hookData['hook_extra_data'] = unserialize( $hookData['hook_extra_data'] );
- $hookData['hook_requirements'] = unserialize( $hookData['hook_requirements'] );
-
- /* Old data? - @todo: we should remove that around 3.3(4?) */
- if ( ! isset($hookData['hook_requirements']['required_applications']['core']) && isset($hookData['hook_requirements']['hook_ipb_version_min']) && ( $hookData['hook_requirements']['hook_ipb_version_min'] > 0 || $hookData['hook_requirements']['hook_ipb_version_max'] > 0 ) )
- {
- $requirements['core'] = array( 'min_version' => intval($hookData['hook_requirements']['hook_ipb_version_min']), 'max_version' => intval($hookData['hook_requirements']['hook_ipb_version_max']) );
- }
-
- if ( is_array($hookData['hook_requirements']['required_applications']) && count($hookData['hook_requirements']['required_applications']) )
- {
- /* Get the setup class */
- require_once( IPS_ROOT_PATH . 'setup/sources/base/setup.php' );/*noLibHook*/
-
- foreach( $hookData['hook_requirements']['required_applications'] as $appKey => $versionData )
- {
- /* Fetch and check versions */
- if ( !isset($this->cachedVersions[ $appKey ]) )
- {
- $this->cachedVersions[ $appKey ] = IPSSetUp::fetchXmlAppVersions( $appKey );
- }
-
- $_versions = $this->cachedVersions[ $appKey ];
-
- krsort($_versions);
-
- /* Setup our default 'no version' value */
- $versions = array( array( 0, $this->lang->words['h_any_version'] ) );
-
- foreach( $_versions as $long => $human )
- {
- if ( $long < 30000 && in_array( $appKey, array( 'core', 'forums', 'members' ) ) )
- {
- continue;
- }
-
- $versions[] = array( $long, $human );
- }
-
- $versionData['_versions'] = $versions;
- $requirements[ $appKey ] = $versionData;
- }
- }
-
- /* Sort out hook files */
- $index = 1;
- $skinGroups = $this->hooksFunctions->getSkinGroups();
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id ) );
- $outer = $this->DB->execute();
-
- /* Get them outside the while cycle to prevent warnings */
- $_dataHooks = IPSLib::getDataHookLocations();
-
- while( $r = $this->DB->fetch($outer) )
- {
- $r['hook_data'] = unserialize( $r['hook_data'] );
-
- if( $r['hook_type'] == 'templateHooks' )
- {
- $templates = $this->hooksFunctions->getSkinMethods( $r['hook_data']['skinGroup'] );
- $hookIds = $this->hooksFunctions->getHookIds( $r['hook_data']['skinFunction'], $r['hook_data']['type'] );
-
- $r['_skinDropdown'] = $this->registry->output->formDropdown( "skinGroup[{$index}]", $skinGroups, $r['hook_data']['skinGroup'], "skinGroup[{$index}]", "onchange='getTemplatesForAdd({$index});'" );
- $r['_templateDropdown'] = $this->registry->output->formDropdown( "skinFunction[{$index}]", $templates, $r['hook_data']['skinFunction'], "skinFunction[{$index}]", "onchange='getTypeOfHook({$index});'" );
- $r['_hookTypeDropdown'] = $this->registry->output->formDropdown( "type[{$index}]", array( array( 0, $this->lang->words['a_selectone'] ), array( 'foreach', $this->lang->words['hook_foreach_loop'] ), array( 'if', $this->lang->words['hook_if_statement'] ) ), $r['hook_data']['type'], "type[{$index}]", "onchange='getHookIds({$index});'" );
- $r['_hookIdsDropdown'] = $this->registry->output->formDropdown( "id[{$index}]", $hookIds, $r['hook_data']['id'], "id[{$index}]", "onchange='getHookEntryPoints({$index});'" );
- $r['_hookEPDropdown'] = $this->registry->output->formDropdown( "position[{$index}]", $r['hook_data']['type'] == 'foreach' ? $entryPoints['foreach'] : $entryPoints['if'], $r['hook_data']['position'] );
- }
-
- if( $r['hook_type'] == 'dataHooks' )
- {
- $r['_dataLocationDropdown'] = $this->registry->output->formDropdown( "dataLocation[{$index}]", $_dataHooks, $r['hook_data']['dataLocation'] );
- }
-
- $files[ $index ] = $r;
- $index++;
- }
-
- $action = 'do_edit_hook';
- }
- else
- {
- $action = 'do_create_hook';
- }
-
- /* Info */
- foreach( array( 'hook_name', 'hook_desc', 'hook_key', 'hook_version_human', 'hook_version_long', 'hook_author', 'hook_email', 'hook_website', 'hook_update_check' ) as $_hook_key )
- {
- $form[ $_hook_key ] = $this->registry->output->formSimpleInput( $_hook_key , isset($this->request[ $_hook_key ]) ? $this->request[ $_hook_key ] : $hookData[ $_hook_key ], 60 );
- }
-
- /* Requirements */
- foreach( array( 'hook_php_version_min', 'hook_php_version_max' ) as $_version_key )
- {
- $form[ $_version_key ] = $this->registry->output->formSimpleInput( $_version_key , isset($this->request[ $_version_key ]) ? $this->request[ $_version_key ] : $hookData['hook_requirements'][ $_version_key ], 20 );
- }
-
- /* Setup the global caches DD */
- $_caches = array();
-
- $this->DB->build( array( 'select' => 'cs_key',
- 'from' => 'cache_store',
- 'order' => 'cs_key ASC'
- ) );
- $this->DB->execute();
-
- while( $gc = $this->DB->fetch() )
- {
- $_caches[] = array( $gc['cs_key'], $gc['cs_key'] );
- }
-
- sort( $_caches );
-
- $form['hook_global_caches'] = $this->registry->output->formMultiDropdown( 'hook_global_caches[]', $_caches, isset($_POST['hook_global_caches']) ? $_POST['hook_global_caches'] : explode(',',$hookData['hook_global_caches']), 15 );
-
- /* Get some data for the javascript */
- $form['jsDataTypes'] = IPSText::br2nl( $this->registry->output->formDropdown( "type[#{index}]", array( array( 0, $this->lang->words['a_selectone'] ), array( 'foreach', $this->lang->words['hook_foreach_loop'] ), array( 'if', $this->lang->words['hook_if_statement'] ) ), '', "type[#{index}]", "onchange='getHookIds(#{index});'" ) );
- $form['jsDataPoints'] = IPSText::br2nl( $this->registry->output->formDropdown( "position[#{index}]", $r['hook_data']['type'] == 'foreach' ? $entryPoints['foreach'] : $entryPoints['if'] ) );
-
- /* Output */
- $this->registry->output->html .= $this->html->hookForm( $form, $action, $hookData, $files, $requirements );
- }
-
- /**
- * Hook add/edit save
- * Save the new (or updated) hook record
- *
- * @param string [add|edit]
- * @return @e void [Outputs to screen]
- */
- protected function _hookSave( $type='add' )
- {
- /* Init vars */
- $hookData = array();
- $newFiles = array();
- $requireApp = array();
- $_hookFiles = array();
- $extraKey = '';
-
- /* Get data if we are editing */
- if( $type == 'edit' )
- {
- $id = intval($this->request['hook_id']);
-
- if( !$id )
- {
- $this->registry->output->showError( $this->lang->words['h_noedit'], 1118 );
- }
-
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
-
- if( !$hookData['hook_id'] )
- {
- $this->registry->output->showError( $this->lang->words['h_noedit'], 1119 );
- }
-
- $extraKey = ' AND hook_id != ' . $hookData['hook_id'];
- }
-
- /* Error Checking */
- if( ! $this->request['hook_name'] )
- {
- $errors[] = $this->lang->words['hook_form_no_title'];
- }
-
- if( empty( $this->request['hook_key'] ) )
- {
- $errors[] = $this->lang->words['hook_form_no_key'];
- }
- else
- {
- $keyCheck = $this->DB->buildAndFetch( array( 'select' => 'count(*) as found', 'from' => 'core_hooks', 'where' => "hook_key='" . $this->DB->addSlashes( $this->request['hook_key'] ) . "'" . $extraKey ) );
-
- if ( $keyCheck['found'] > 0 )
- {
- $errors[] = $this->lang->words['hook_form_dupe_key'];
- }
- }
-
- /* Got any errors? */
- if ( is_array( $errors ) && count( $errors ) )
- {
- $this->registry->output->global_error = implode( ' ', $errors );
- $this->_hookForm();
- return;
- }
-
- /* Not IN_DEV? */
- if ( ! IN_DEV )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . intval($this->request['hook_id']) ) );
- $this->DB->execute();
-
- while( $_r = $this->DB->fetch() )
- {
- $_hookFiles[ $_r['hook_classname'] ] = $_r['hook_file_stored'];
- }
- }
-
- /* Check for requirements */
- if ( is_array( $this->request['requireApp'] ) AND count( $this->request['requireApp'] ) )
- {
- foreach( $this->request['requireApp'] as $_index => $app_key )
- {
- if ( $app_key )
- {
- $minVersion = intval($this->request['minVersion'][ $_index ]);
- $maxVersion = intval($this->request['maxVersion'][ $_index ]);
-
- $requireApp[ $app_key ] = array( 'app_name' => ipsRegistry::$applications[ $app_key ]['app_title'],
- 'min_version' => $minVersion,
- 'max_version' => $maxVersion
- );
- }
- }
- }
-
- /* Check for files */
- if ( is_array( $this->request['file'] ) AND count( $this->request['file'] ) )
- {
- foreach( $this->request['file'] as $index => $file )
- {
- if ( $file )
- {
- $newFiles[ $index ] = array('hook_file_real' => $file,
- 'hook_type' => $this->request['hook_type'][ $index ],
- 'hook_classname' => $this->request['hook_classname'][ $index ],
- 'hook_data' => serialize( array('dataLocation' => trim( $this->request['dataLocation'][ $index ] ),
- 'libApplication' => trim( $this->request['libApplication'][ $index ] ),
- 'classToOverload' => trim($this->request['classToOverload'][ $index ]),
- 'skinGroup' => $this->request['skinGroup'][ $index ],
- 'skinFunction' => $this->request['skinFunction'][ $index ],
- 'type' => $this->request['type'][ $index ],
- 'id' => $this->request['id'][ $index ],
- 'position' => $this->request['position'][ $index ],
- )
- )
- );
-
- /**
- * @link http://community.invisionpower.com/tracker/issue-22084-hook-edit-does-not-preserve-correct-name/
- * We don't want to reset the stored name if you are not in developer mode
- */
- if ( IN_DEV )
- {
- $newFiles[ $index ]['hook_file_stored'] = $file; // During import this is a random name, but for devs it's actual file
- }
- else
- {
- $newFiles[ $index ]['hook_file_stored'] = $_hookFiles[ $this->request['hook_classname'][ $index ] ] ? $_hookFiles[ $this->request['hook_classname'][ $index ] ] : $file;
- }
- }
- }
- }
-
- /* Get position */
- if ( $type == 'add' )
- {
- $position = $this->DB->buildAndFetch( array( 'select' => 'MAX(hook_position) as newPos', 'from' => 'core_hooks' ) );
-
- $position['newPos'] = intval($position['newPos']) + 1;
- }
- else
- {
- $position['newPos'] = $hookData['hook_position'];
- }
-
- $mainHookRecord = array('hook_name' => trim($this->request['hook_name']),
- 'hook_key' => substr( trim($this->request['hook_key']), 0, 32 ),
- 'hook_global_caches' => ( is_array($this->request['hook_global_caches']) && count($this->request['hook_global_caches']) ) ? implode(',', $this->request['hook_global_caches']) : '',
- 'hook_desc' => trim($this->request['hook_desc']),
- 'hook_version_human' => trim($this->request['hook_version_human']),
- 'hook_version_long' => trim($this->request['hook_version_long']),
- 'hook_author' => trim($this->request['hook_author']),
- 'hook_email' => trim($this->request['hook_email']),
- 'hook_website' => trim($this->request['hook_website']),
- 'hook_update_check' => trim($this->request['hook_update_check']),
- 'hook_enabled' => $type == 'add' ? 1 : $hookData['hook_enabled'],
- 'hook_installed' => $type == 'add' ? IPS_UNIX_TIME_NOW : $hookData['hook_installed'],
- 'hook_updated' => $type == 'add' ? 0 : IPS_UNIX_TIME_NOW,
- 'hook_position' => $position['newPos'],
- 'hook_requirements' => serialize( array('required_applications' => $requireApp,
- 'hook_php_version_min' => trim($this->request['hook_php_version_min']),
- 'hook_php_version_max' => trim($this->request['hook_php_version_max'])
- )
- )
- );
-
- if( $type == 'edit' )
- {
- $this->DB->update( 'core_hooks', $mainHookRecord, 'hook_id=' . $hookData['hook_id'] );
-
- $this->DB->delete( 'core_hooks_files', 'hook_hook_id=' . $hookData['hook_id'] );
- }
- else
- {
- $this->DB->insert( 'core_hooks', $mainHookRecord );
-
- $hookData['hook_id'] = $this->DB->getInsertId();
- }
-
- foreach( $newFiles as $index => $toInsert )
- {
- $toInsert['hook_hook_id'] = $hookData['hook_id'];
-
- $this->DB->insert( 'core_hooks_files', $toInsert );
- }
-
- /* Rebuild cache */
- $this->rebuildHooksCache();
-
- /* Rebuild global caches */
- try
- {
- IPSLib::cacheGlobalCaches();
- }
- catch( Exception $e ){}
-
- /* Flag skins for recache */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
- $skinCaching->flagSetForRecache();
-
- /* Redirect */
- $this->registry->output->setMessage( $this->lang->words['h_saved'] );
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
- }
-
- /**
- * View details about a hook
- *
- * @return @e void [Outputs to screen]
- */
- protected function _viewDetails()
- {
- $id = intval($this->request['id']);
-
- if( !$id )
- {
- $this->registry->output->showError( $this->lang->words['h_nodetails'], 11110 );
- }
-
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
-
- if( !$hookData['hook_id'] )
- {
- $this->registry->output->showError( $this->lang->words['h_nodetails'], 11111 );
- }
-
- /* Extra data */
- $hookData['_updated'] = $this->registry->getClass('class_localization')->formatTime( $hookData['hook_updated'] );
- $hookData['hook_extra_data'] = unserialize( $hookData['hook_extra_data'] );
-
- /* Meets requirements? */
- $hookData['_require_errors'] = $this->checkHookRequirements( $hookData );
-
- /* Got updates? */
- if ( $hookData['hook_update_check'] )
- {
- $hookData['hook_update_available'] = $this->_updateAvailable( $hookData['hook_update_check'], $hookData['hook_version_long'] );
- }
- else
- {
- $hookData['hook_update_available'] = array( 0 );
- }
-
- /* Get files */
- $files = array();
- $index = 1;
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $r['hook_data'] = unserialize( $r['hook_data'] );
- $files[ $index ] = $r;
- $index++;
- }
-
- /* Output */
- $this->registry->output->html .= $this->html->hookDetails( $hookData, $files );
- }
-
- /**
- * Check if the hook meets all the requirements
- *
- * @param mixed $hook Can be an hook ID or an array of the hook data
- * @return @e array Errors found
- */
- public function checkHookRequirements( $hook )
- {
- /* Init vars */
- $hookData = array();
- $reqsData = array();
- $errors = array();
-
- /* We already have some data? */
- if ( is_array($hook) && count($hook) )
- {
- $hookData = $hook;
- }
- elseif ( is_int($hook) )
- {
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook ) );
- }
-
- /* Requirements are still serialized? */
- if ( IPSLib::isSerialized($hookData['hook_requirements']) )
- {
- $hookData['hook_requirements'] = unserialize($hookData['hook_requirements']);
- }
-
- /* Make our var shorter... */
- $reqsData = &$hookData['hook_requirements'];
-
- /* Old data? - @todo: remove this check around 3.3(4?) */
- if ( ! isset($reqsData['required_applications']['core']) && isset($reqsData['hook_ipb_version_min']) && ( $reqsData['hook_ipb_version_min'] > 0 || $reqsData['hook_ipb_version_max'] > 0 ) )
- {
- $reqsData['hook_ipb_version_min'] = ( $reqsData['hook_ipb_version_min'] < 30000 ) ? 30000 : $reqsData['hook_ipb_version_min'];
-
- $reqsData['required_applications']['core'] = array( 'min_version' => intval($reqsData['hook_ipb_version_min']), 'max_version' => intval($reqsData['hook_ipb_version_max']) );
- }
-
- //-----------------------------------------
- // Let's start checking requirements
- //-----------------------------------------
-
- /* PHP */
- if( $reqsData['hook_php_version_min'] OR $reqsData['hook_php_version_max'] )
- {
- if( $reqsData['hook_php_version_min'] AND version_compare( PHP_VERSION, $reqsData['hook_php_version_min'], '<' ) == true )
- {
- $errors['php_min'] = sprintf( $this->lang->words['h_phpold'],$reqsData['hook_php_version_min'] );
- }
-
- if( $reqsData['hook_php_version_max'] AND version_compare( PHP_VERSION, $reqsData['hook_php_version_max'], '>' ) == true )
- {
- $errors['php_max'] = sprintf( $this->lang->words['h_phpnew'], $reqsData['hook_php_version_max'] );
- }
- }
-
- /* Additional applications */
- if ( is_array($reqsData['required_applications']) && count($reqsData['required_applications']) )
- {
- /* Get the setup class */
- require_once( IPS_ROOT_PATH . 'setup/sources/base/setup.php' );/*noLibHook*/
-
- /* Loop through all apps */
- foreach( $reqsData['required_applications'] as $appKey => $appData )
- {
- /* Versions file doesn't exist? */
- if ( !is_file( IPSLib::getAppDir( $appKey ) . '/xml/versions.xml' ) )
- {
- $errors[ $appKey.'_app' ] = sprintf( $this->lang->words['hook_require_appnotfound'], $appData['app_name'] );
- }
- /* App not installed/enabled? */
- elseif ( !IPSLib::appIsInstalled( $appKey ) )
- {
- $errors[ $appKey.'_app' ] = sprintf( $this->lang->words['hook_require_appdisabled'], ipsRegistry::$applications[ $appKey ]['app_title'] );
- }
- elseif ( $appData['min_version'] OR $appData['max_version'] )
- {
- /* Fetch and check versions */
- if ( !isset($this->cachedVersions[ $appKey ]) )
- {
- $this->cachedVersions[ $appKey ] = IPSSetUp::fetchXmlAppVersions( $appKey );
- }
-
- $versions = $this->cachedVersions[ $appKey ];
-
- if ( is_array($versions) && count($versions) )
- {
- if ( !isset($this->cachedUpgradeInfo[ $appKey ]) )
- {
- $_key = in_array( $appKey, array( 'forums', 'members' ) ) ? 'core' : $appKey;
- $this->cachedUpgradeInfo[ $_key ] = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'upgrade_history', 'where' => "upgrade_app='{$_key}'", 'order' => 'upgrade_version_id DESC', 'limit' => array( 1 ) ) );
-
- /* Extra caching for the three core apps */
- if( in_array( $appKey, array( 'core', 'forums', 'members' ) ) )
- {
- $this->cachedUpgradeInfo['core'] = $this->cachedUpgradeInfo[ $_key ];
- $this->cachedUpgradeInfo['forums'] = $this->cachedUpgradeInfo[ $_key ];
- $this->cachedUpgradeInfo['members'] = $this->cachedUpgradeInfo[ $_key ];
- }
- }
-
- /* Do we meet tha requirements? */
- if ( $appData['min_version'] AND $this->cachedUpgradeInfo[ $appKey ]['upgrade_version_id'] < $appData['min_version'] )
- {
- $errors[ $appKey.'_min' ] = sprintf( $this->lang->words['hook_require_tooold'], isset($versions[ $appData['min_version'] ]) ? $versions[ $appData['min_version'] ] : $appData['min_version'] );
- }
-
- if ( $appData['max_version'] AND $this->cachedUpgradeInfo[ $appKey ]['upgrade_version_id'] > $appData['max_version'] )
- {
- $errors[ $appKey.'_max' ] = sprintf( $this->lang->words['hook_require_toonew'], isset($versions[ $appData['max_version'] ]) ? $versions[ $appData['max_version'] ] : $appData['max_version'] );
- }
- }
- }
- }
- }
-
- return $errors;
- }
-
- /**
- * Check if you meet hook requirements
- *
- * @return @e void [Outputs to screen]
- */
- protected function _checkRequirements()
- {
- $id = intval($this->request['id']);
-
- if( !$id )
- {
- $this->registry->output->showError( $this->lang->words['h_norequirements'], 11112 );
- }
-
- $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
-
- if( !$hookData['hook_id'] )
- {
- $this->registry->output->showError( $this->lang->words['h_norequirements'], 11113 );
- }
-
- /* Get requirements */
- $hookData['hook_requirements'] = unserialize($hookData['hook_requirements']);
-
- /* Check requirements */
- $errors = $this->checkHookRequirements( $hookData );
-
- /* Output */
- $this->registry->output->html .= $this->html->hookRequirements( $hookData, $errors, $this->cachedVersions );
- }
-
- /**
- * Rebuild hooks cache
- *
- * @return @e void
- */
- public function rebuildHooksCache()
- {
- /* INI */
- $cache = array( 'commandHooks' => array(), 'skinHooks' => array(), 'templateHooks' => array(), 'dataHooks' => array(), 'libraryHooks' => array() );
-
- /* First fix positions */
- $this->_fixPositions();
-
- /* Get current hooks */
- $this->DB->build( array( 'select' => 'f.*',
- 'from' => array( 'core_hooks_files' => 'f' ),
- 'where' => 'c.hook_enabled=1',
- 'order' => 'c.hook_position ASC',
- 'add_join' => array( array( 'select' => 'c.hook_id',
- 'from' => array( 'core_hooks' => 'c' ),
- 'where' => 'c.hook_id=f.hook_hook_id',
- 'type' => 'left' ) )
- ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- /* Got no main hook id? Weird but skip.. */
- if ( empty($r['hook_id']) )
- {
- continue;
- }
-
- /* INIT */
- $_cache = array();
- $data = unserialize( $r['hook_data'] );
-
- /* General Stuff */
- $_cache = array( 'filename' => $r['hook_file_stored'],
- 'className' => $r['hook_classname']
- );
-
- /* Hook type specific stuff */
- if( $r['hook_type'] == 'templateHooks' )
- {
- $_cache['type'] = $data['type'];
- $_cache['skinFunction'] = $data['skinFunction'];
- $_cache['id'] = $data['id'];
- $_cache['position'] = $data['position'];
- }
- else if( /*$r['hook_type'] == 'dataHooks' OR*/ $r['hook_type'] == 'libraryHooks' )
- {
- $_cache['classToOverload'] = $data['classToOverload'];
- }
-
- /* Add to array */
- if( $r['hook_type'] == 'templateHooks' )
- {
- $cache[ $r['hook_type'] ][ $data['skinGroup'] ][] = $_cache;
- }
- else if( $r['hook_type'] == 'dataHooks' )
- {
- $cache[ $r['hook_type'] ][ $data['dataLocation'] ][] = $_cache;
- }
- else if( $r['hook_type'] == 'libraryHooks' )
- {
- $cache[ $r['hook_type'] ][ $data['libApplication'] ][ $data['classToOverload'] ][] = $_cache;
- }
- else
- {
- $cache[ $r['hook_type'] ][ $data['classToOverload'] ][] = $_cache;
- }
- }
-
- /* Update the cache */
- $this->cache->setCache( 'hooks', $cache, array( 'array' => 1 ) );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Hooks Management
+ * Last Updated: $Date: 2013-05-20 16:38:23 -0400 (Mon, 20 May 2013) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 3.0.0
+ * @version $Revision: 12261 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+class admin_core_applications_hooks extends ipsCommand
+{
+ /**
+ * Skin object
+ *
+ * @var object Skin templates
+ */
+ protected $html;
+
+ /**
+ * Hooks library
+ *
+ * @var object Hooks library
+ */
+ protected $hooksFunctions;
+
+ /**
+ * Existing hooks
+ *
+ * @var array Existing hooks
+ */
+ protected $hooks;
+
+ /**
+ * Array of all the cache versions
+ * for the required applications
+ *
+ * @var $cachedVersions
+ */
+ protected $cachedVersions = array();
+
+ /**
+ * Main class entry point
+ *
+ * @param object ipsRegistry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ //-----------------------------------------
+ // Load skin
+ //-----------------------------------------
+
+ $this->html = $this->registry->output->loadTemplate('cp_skin_applications');
+
+ //-----------------------------------------
+ // Load hooks library
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('core') . '/sources/classes/hooksFunctions.php', 'hooksFunctions' );
+ $this->hooksFunctions = new $classToLoad( $registry );
+
+ // lang already loaded by hookFunctions
+ //$this->registry->class_localization->loadLanguageFile( array( 'admin_applications' ), 'core' );
+
+ if( defined('NO_WRITE_HOOKS') )
+ {
+ $this->registry->output->showError( $this->lang->words['no_write_hooks'] );
+ }
+
+ //-----------------------------------------
+ // Set up stuff
+ //-----------------------------------------
+
+ $this->form_code = $this->html->form_code = 'module=applications§ion=hooks&';
+ $this->form_code_js = $this->html->form_code_js = 'module=applications§ion=hooks&';
+
+ //-----------------------------------------
+ // What to do...
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ case 'reenable_all_hooks':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_reenableAllHooks();
+ break;
+ case 'disable_all_hooks':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_disableAllHooks();
+ break;
+
+ break;
+ case 'disable_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_disableHook();
+ break;
+ case 'enable_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_enableHook();
+ break;
+
+ case 'uninstall_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_delete' );
+ $this->_uninstallHook();
+ break;
+ case 'install_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_installHook();
+ break;
+
+ case 'reorder':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_reorder();
+ break;
+
+ case 'view_details':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_viewDetails();
+ break;
+
+ case 'check_requirements':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_checkRequirements();
+ break;
+
+ case 'export_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_exportHook();
+ break;
+
+ case 'do_export_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_doExportHook();
+ break;
+
+ case 'create_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_hookForm( 'add' );
+ break;
+
+ case 'edit_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_hookForm( 'edit' );
+ break;
+
+ case 'do_create_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_hookSave( 'add' );
+ break;
+
+ case 'do_edit_hook':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->_hookSave( 'edit' );
+ break;
+
+ case 'removeDeadCaches':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->removeDeadCaches();
+ break;
+
+ case 'reimport_apps':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->reimportAppHooks();
+ break;
+
+ case 'hooks_overview':
+ default:
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'hooks_manage' );
+ $this->request['do'] = 'hooks_overview';
+ $this->_hooksOverview();
+ break;
+ }
+
+ //-----------------------------------------
+ // Pass to CP output hander
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
+ $this->registry->getClass('output')->sendOutput();
+ }
+
+ /**
+ * Reimport all hooks for all installed applications
+ *
+ * @return @e void
+ */
+ protected function reimportAppHooks()
+ {
+ $stats = array( 'inserted' => 0, 'updated' => 0, 'skipped' => 0 );
+
+ foreach( ipsRegistry::$applications as $app )
+ {
+ $_stats = $this->installAppHooks( $app['app_directory'] );
+
+ $stats['inserted'] = $stats['inserted'] + $_stats['inserted'];
+ $stats['updated'] = $stats['updated'] + $_stats['updated'];
+ $stats['skipped'] = $stats['skipped'] + $_stats['skipped'];
+ }
+
+ /* Rebuild cache */
+ $this->rebuildHooksCache();
+
+ /* Rebuild global caches */
+ try
+ {
+ IPSLib::cacheGlobalCaches();
+ }
+ catch( Exception $e ){}
+
+ /* Flag skins for recache */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+ $skinCaching->flagSetForRecache();
+
+ /* Redirect */
+ $this->registry->output->global_message = sprintf( $this->lang->words['app_hooks_rebuilt'], $stats['inserted'], $stats['updated'], $stats['skipped'] );
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /**
+ * Rebuild skins following hook import that included a template
+ *
+ * @return @e void
+ */
+ protected function removeDeadCaches()
+ {
+ $messages = array();
+ $keep = array();
+ $unlink = array();
+
+ /* Grab all current hooks caches */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'core_hooks_files' ) );
+
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $keep[] = $row['hook_file_stored'];
+ }
+
+ try
+ {
+ foreach( new DirectoryIterator( IPS_HOOKS_PATH ) as $file )
+ {
+ if ( ! $file->isDot() )
+ {
+ $_name = $file->getFileName();
+
+ if ( preg_match( "#_[a-z0-9]{32}\.php$#", $_name ) )
+ {
+ if ( ! in_array( $_name, $keep ) )
+ {
+ $unlink[] = $_name;
+ }
+ }
+ }
+ }
+ } catch ( Exception $e ) { print $e->getMessage(); }
+
+ /* Anything to unlink? */
+ if ( count( $unlink ) )
+ {
+ foreach( $unlink as $file )
+ {
+ @unlink( IPS_HOOKS_PATH . $file );
+ }
+ }
+
+ /* Print message */
+ $this->registry->output->global_message = sprintf( $this->lang->words['hook_removed_files'], count( $unlink ) ) . ' ' . implode( ' ', $unlink );
+ $this->_hooksOverview();
+ }
+
+ /**
+ * Reorder hooks
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _reorder()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
+ $ajax = new $classToLoad();
+
+ //-----------------------------------------
+ // Checks...
+ //-----------------------------------------
+
+ if( $this->registry->adminFunctions->checkSecurityKey( $this->request['md5check'], true ) === false )
+ {
+ $ajax->returnString( $this->lang->words['postform_badmd5'] );
+ }
+
+ //-----------------------------------------
+ // Save new position
+ //-----------------------------------------
+
+ $position = 1;
+
+ if( is_array($this->request['hooks']) AND count($this->request['hooks']) )
+ {
+ /* Reset all hooks to 0 temporarily */
+ $this->DB->update( 'core_hooks', array( 'hook_position' => 0 ) );
+
+ foreach( $this->request['hooks'] as $this_id )
+ {
+ $this->DB->update( 'core_hooks', array( 'hook_position' => $position ), 'hook_id=' . $this_id );
+
+ $position++;
+ }
+ }
+
+ $this->rebuildHooksCache();
+
+ $ajax->returnString('OK');
+ }
+
+ /**
+ * Install a new hook
+ *
+ * @return void
+ */
+ protected function _installHook()
+ {
+ //-----------------------------------------
+ // Get uploaded schtuff
+ //-----------------------------------------
+
+ $tmp_name = $_FILES['FILE_UPLOAD']['name'];
+ $tmp_name = preg_replace( "#\.gz$#", "", $tmp_name );
+
+ $content = ipsRegistry::getClass('adminFunctions')->importXml( $tmp_name );
+
+ if( ! $content )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noxml'], 1110 );
+ }
+
+ $this->installHook( $content, TRUE, FALSE );
+
+ /* Rebuild cache */
+ $this->rebuildHooksCache();
+
+ /* Rebuild global caches */
+ try
+ {
+ IPSLib::cacheGlobalCaches();
+ }
+ catch( Exception $e ){}
+
+ /* Flag skins for recache */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+ $skinCaching->flagSetForRecache();
+
+ /* Redirect */
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /**
+ * Function mostly used in installer/upgrader
+ * Inserts new hooks
+ *
+ * @param string Application to install hooks for
+ */
+ public function installAppHooks( $app )
+ {
+ static $hooks = array();
+
+ $msgs = array( 'inserted' => 0, 'updated' => 0, 'skipped' => 0 );
+ $xmlData = array();
+ $path = IPSLib::getAppDir( $app ) . '/xml';
+
+ if ( is_file( $path . '/hooks.xml' ) AND is_dir( $path . '/hooks' ) )
+ {
+ if( !count($hooks) )
+ {
+ /* Fetch current hooks */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'core_hooks' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ if ( $row['hook_key'] )
+ {
+ $hooks[ $row['hook_key'] ] = $row;
+ }
+ }
+ }
+
+ /* Alright. We're in. Read the XML file */
+ require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+
+ /* Grab wrapper file */
+ $xml->load( $path . '/hooks.xml' );
+
+ foreach( $xml->fetchElements('hook') as $data )
+ {
+ $xmlData[] = $xml->fetchElementsFromRecord( $data );
+ }
+
+ /* Examine XML */
+ if ( is_array( $xmlData ) AND count( $xmlData ) )
+ {
+ foreach( $xmlData as $x )
+ {
+ if ( is_file( $path . '/hooks/' . $x['file'] ) )
+ {
+ $xml->load( $path . '/hooks/' . $x['file'] );
+
+ foreach( $xml->fetchElements('config') as $data )
+ {
+ $config = $xml->fetchElementsFromRecord( $data );
+ }
+
+ if ( ! isset( $hooks[ $config['hook_key'] ] ) )
+ {
+ /* Add it */
+ $msgs['inserted']++;
+ $this->installHook( file_get_contents( $path . '/hooks/' . $x['file'] ), FALSE, FALSE, $x['enabled'] );
+ }
+ else
+ {
+ $this->installHook( file_get_contents( $path . '/hooks/' . $x['file'] ), FALSE, FALSE, $x['enabled'] );
+ $msgs['updated']++;
+ }
+ }
+ }
+ }
+ }
+
+ return $msgs;
+ }
+
+ /**
+ * Public install hook so we can use it in the installer and elsewhere
+ *
+ * @param string XML data
+ * @param boolean Add message to output->global_message
+ * @param boolean Allow skins to recache
+ * @param int Install enabled
+ * @return @e void
+ */
+ public function installHook( $content, $addMessage=FALSE, $allowSkinRecache=TRUE, $enabled=1 )
+ {
+ //-----------------------------------------
+ // Hooks directory writable?
+ //-----------------------------------------
+
+ if( !is_writable( IPS_HOOKS_PATH ) )
+ {
+ if( !$addMessage )
+ {
+ return false;
+ }
+
+ $this->registry->output->showError( $this->lang->words['h_dir_notwritable'], 111159 );
+ }
+
+ //-----------------------------------------
+ // Got our hooks?
+ //-----------------------------------------
+
+ if( !is_array($this->hooks) OR !count($this->hooks) )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $this->hooks[ $r['hook_key'] ] = $r;
+ }
+ }
+
+ //-----------------------------------------
+ // Get xml mah-do-dah
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+
+ //-----------------------------------------
+ // Unpack the datafile
+ //-----------------------------------------
+
+ $xml->loadXML( $content );
+
+ foreach( $xml->fetchElements('config') as $data )
+ {
+ $config = $xml->fetchElementsFromRecord( $data );
+
+ if( !count($config) )
+ {
+ $this->registry->output->showError( $this->lang->words['h_xmlwrong'], 1111 );
+ }
+ }
+
+ //-----------------------------------------
+ // Temp
+ //-----------------------------------------
+
+ $tempExtraData = unserialize( $config['hook_extra_data'] );
+
+ //-----------------------------------------
+ // Set config
+ //-----------------------------------------
+
+ $config = array('hook_name' => $config['hook_name'],
+ 'hook_desc' => $config['hook_desc'],
+ 'hook_author' => $config['hook_author'],
+ 'hook_email' => $config['hook_email'],
+ 'hook_website' => $config['hook_website'],
+ 'hook_update_check' => $config['hook_update_check'],
+ 'hook_requirements' => $config['hook_requirements'],
+ 'hook_version_human' => $config['hook_version_human'],
+ 'hook_version_long' => $config['hook_version_long'],
+ 'hook_key' => $config['hook_key'],
+ 'hook_global_caches' => $config['hook_global_caches'],
+ 'hook_enabled' => $enabled,
+ 'hook_updated' => IPS_UNIX_TIME_NOW,
+ );
+
+ $extra_data = array();
+
+ //-----------------------------------------
+ // Set files
+ //-----------------------------------------
+
+ $files = array();
+
+ foreach( $xml->fetchElements('hookfiles') as $node )
+ {
+ foreach( $xml->fetchElements('file', $node) as $_file )
+ {
+ $file = $xml->fetchElementsFromRecord( $_file );
+
+ if( $file['hook_type'] )
+ {
+ $files[] = array(
+ 'hook_file_real' => $file['hook_file_real'],
+ 'hook_type' => $file['hook_type'],
+ 'hook_classname' => $file['hook_classname'],
+ 'hook_data' => $file['hook_data'],
+ 'hooks_source' => $file['hooks_source'],
+ );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Set the custom script
+ //-----------------------------------------
+
+ $custom = array();
+ $customClass = null;
+
+ foreach( $xml->fetchElements('hookextras_custom') as $node )
+ {
+ foreach( $xml->fetchElements('file', $node) as $_file )
+ {
+ $file = $xml->fetchElementsFromRecord( $_file );
+
+ if( count($file) )
+ {
+ $custom = array( 'filename' => $file['filename'],
+ 'source' => $file['source'],
+ );
+ }
+ }
+ }
+
+ /* Got any custom file to initialize? */
+ if ( $custom['filename'] && $custom['source'] )
+ {
+ # Our dirty trick to avoid saving the file on disk just yet...
+ $_custom = preg_replace( '#^(\s*)<\?(php)+#i', '', $custom['source'] );
+ eval($_custom);
+
+ $classname = str_replace( '.php', '', $custom['filename'] );
+
+ if( class_exists( $classname ) )
+ {
+ $customClass = new $classname( $this->registry );
+
+ if( method_exists( $customClass, 'pre_install' ) )
+ {
+ $customClass->pre_install();
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Set the settings
+ //-----------------------------------------
+
+ $settings = array();
+ $settingGroups = array();
+
+ foreach( $xml->fetchElements('hookextras_settings') as $node )
+ {
+ foreach( $xml->fetchElements('setting', $node) as $_setting )
+ {
+ $setting = $xml->fetchElementsFromRecord( $_setting );
+
+ if( $setting['conf_is_title'] == 1)
+ {
+ $settingGroups[] = array(
+ 'conf_title_title' => $setting['conf_title_title'],
+ 'conf_title_desc' => $setting['conf_title_desc'],
+ 'conf_title_noshow' => $setting['conf_title_noshow'],
+ 'conf_title_keyword' => $setting['conf_title_keyword'],
+ 'conf_title_app' => $setting['conf_title_app'],
+ 'conf_title_tab' => $setting['conf_title_tab'],
+ );
+ }
+ else
+ {
+ $settings[] = array(
+ 'conf_title' => $setting['conf_title'],
+ 'conf_description' => $setting['conf_description'],
+ 'conf_group' => $setting['conf_group'],
+ 'conf_type' => $setting['conf_type'],
+ 'conf_key' => $setting['conf_key'],
+ 'conf_default' => $setting['conf_default'],
+ 'conf_extra' => $setting['conf_extra'],
+ 'conf_evalphp' => $setting['conf_evalphp'],
+ 'conf_protected' => $setting['conf_protected'],
+ 'conf_position' => $setting['conf_position'],
+ 'conf_start_group' => $setting['conf_start_group'],
+ 'conf_add_cache' => $setting['conf_add_cache'],
+ 'conf_title_keyword' => $setting['conf_title_keyword'],
+ );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Set the lang bits
+ //-----------------------------------------
+
+ $language = array();
+
+ foreach( $xml->fetchElements('hookextras_language') as $node )
+ {
+ foreach( $xml->fetchElements('language', $node) as $_langbit )
+ {
+ $langbit = $xml->fetchElementsFromRecord( $_langbit );
+
+ $language[] = array(
+ 'word_app' => $langbit['word_app'],
+ 'word_pack' => $langbit['word_pack'],
+ 'word_key' => $langbit['word_key'],
+ 'word_default' => $langbit['word_default'],
+ 'word_custom' => $langbit['word_custom'],
+ 'word_js' => intval($langbit['word_js']),
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Set the modules
+ //-----------------------------------------
+
+ $modules = array();
+
+ foreach( $xml->fetchElements('hookextras_modules') as $node )
+ {
+ foreach( $xml->fetchElements('module', $node) as $_module )
+ {
+ $module = $xml->fetchElementsFromRecord( $_module );
+ $modules[] = array(
+ 'sys_module_title' => $module['sys_module_title'],
+ 'sys_module_application' => $module['sys_module_application'],
+ 'sys_module_key' => $module['sys_module_key'],
+ 'sys_module_description' => $module['sys_module_description'],
+ 'sys_module_version' => $module['sys_module_version'],
+ 'sys_module_protected' => $module['sys_module_protected'],
+ 'sys_module_visible' => $module['sys_module_visible'],
+ 'sys_module_position' => $module['sys_module_position'],
+ 'sys_module_admin' => $module['sys_module_admin'],
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Set the help files
+ //-----------------------------------------
+
+ $help = array();
+
+ foreach( $xml->fetchElements('hookextras_help') as $node )
+ {
+ foreach( $xml->fetchElements('help', $node) as $_helpfile )
+ {
+ $helpfile = $xml->fetchElementsFromRecord( $_helpfile );
+ $help[] = array(
+ 'title' => $helpfile['title'],
+ 'text' => $helpfile['text'],
+ 'description' => $helpfile['description'],
+ 'position' => $helpfile['position'],
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Set the templates
+ //-----------------------------------------
+
+ $templates = array();
+
+ foreach( $xml->fetchElements('hookextras_templates') as $node )
+ {
+ foreach( $xml->fetchElements('templates', $node) as $_template )
+ {
+ $template = $xml->fetchElementsFromRecord( $_template );
+ $templates[] = array(
+ 'template_set_id' => 0,
+ 'template_group' => $template['template_group'],
+ 'template_content' => $template['template_content'],
+ 'template_name' => $template['template_name'],
+ 'template_data' => $template['template_data'],
+ 'template_updated' => $template['template_updated'],
+ 'template_removable' => $template['template_removable'],
+ 'template_added_to' => intval($template['template_added_to']),
+ 'template_user_added' => 1,
+ 'template_user_edited' => 0,
+ 'template_master_key' => $template['template_master_key'] ? $template['template_master_key'] : 'root',
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Set the CSS
+ //-----------------------------------------
+
+ $css = array();
+
+ foreach( $xml->fetchElements('hookextras_css') as $node )
+ {
+ foreach( $xml->fetchElements('css', $node) as $_css )
+ {
+ $_css = $xml->fetchElementsFromRecord( $_css );
+ $css[] = array(
+ 'css_set_id' => 0,
+ 'css_group' => $_css['css_group'],
+ 'css_content' => $_css['css_content'],
+ 'css_position' => $_css['css_position'],
+ 'css_added_to' => 1,
+ 'css_app' => $_css['css_app'],
+ 'css_app_hide' => $_css['css_app_hide'],
+ 'css_attributes' => $_css['css_attributes'],
+ 'css_removed' => $_css['css_removed'],
+ 'css_modules' => $_css['css_modules'],
+ 'css_master_key' => $_css['css_master_key'],
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Set the Replacements
+ //-----------------------------------------
+
+ $replacements = array();
+
+ foreach( $xml->fetchElements('hookextras_replacements') as $node )
+ {
+ foreach( $xml->fetchElements('replacements', $node) as $_r )
+ {
+ $_r = $xml->fetchElementsFromRecord( $_r );
+ $replacements[] = array(
+ 'replacement_key' => $_r['replacement_key'],
+ 'replacement_content' => $_r['replacement_content'],
+ 'replacement_master_key' => $_r['replacement_master_key'],
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Set the tasks
+ //-----------------------------------------
+
+ $tasks = array();
+
+ foreach( $xml->fetchElements('hookextras_tasks') as $node )
+ {
+ foreach( $xml->fetchElements('tasks', $node) as $_task )
+ {
+ $task = $xml->fetchElementsFromRecord( $_task );
+ $tasks[] = array(
+ 'task_title' => $task['task_title'],
+ 'task_file' => $task['task_file'],
+ 'task_week_day' => $task['task_week_day'],
+ 'task_month_day' => $task['task_month_day'],
+ 'task_hour' => $task['task_hour'],
+ 'task_minute' => $task['task_minute'],
+ 'task_cronkey' => $task['task_cronkey'],
+ 'task_log' => $task['task_log'],
+ 'task_description' => $task['task_description'],
+ 'task_enabled' => $task['task_enabled'],
+ 'task_key' => $task['task_key'],
+ 'task_safemode' => $task['task_safemode'],
+ 'task_locked' => $task['task_locked'],
+ 'task_application' => $task['task_application'],
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Set the database changes
+ //-----------------------------------------
+
+ $database = array(
+ 'create' => array(),
+ 'alter' => array(),
+ 'update' => array(),
+ 'insert' => array(),
+ );
+
+ foreach( $xml->fetchElements('hookextras_database_create') as $node )
+ {
+ foreach( $xml->fetchElements('create', $node) as $_table )
+ {
+ $table = $xml->fetchElementsFromRecord( $_table );
+ $database['create'][] = array(
+ 'name' => $table['name'],
+ 'fields' => $table['fields'],
+ 'tabletype' => $table['tabletype'],
+ );
+ }
+ }
+
+ foreach( $xml->fetchElements('hookextras_database_alter') as $node )
+ {
+ foreach( $xml->fetchElements('alter', $node) as $_table )
+ {
+ $table = $xml->fetchElementsFromRecord( $_table );
+ $database['alter'][] = array(
+ 'altertype' => $table['altertype'],
+ 'table' => $table['table'],
+ 'field' => $table['field'],
+ 'newfield' => $table['newfield'],
+ 'fieldtype' => $table['fieldtype'],
+ 'default' => $table['default'],
+ );
+ }
+ }
+
+ foreach( $xml->fetchElements('hookextras_database_update') as $node )
+ {
+ foreach( $xml->fetchElements('update', $node) as $_table )
+ {
+ $table = $xml->fetchElementsFromRecord( $_table );
+ $database['update'][] = array(
+ 'table' => $table['table'],
+ 'field' => $table['field'],
+ 'newvalue' => $table['newvalue'],
+ 'oldvalue' => $table['oldvalue'],
+ 'where' => $table['where'],
+ );
+ }
+ }
+
+ foreach( $xml->fetchElements('hookextras_database_insert') as $node )
+ {
+ foreach( $xml->fetchElements('insert', $node) as $_table )
+ {
+ $table = $xml->fetchElementsFromRecord( $_table );
+ $database['insert'][] = array(
+ 'table' => $table['table'],
+ 'updates' => $table['updates'],
+ 'fordelete' => $table['fordelete'],
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Set some vars for display tallies
+ //-----------------------------------------
+
+ $filesInserted = 0;
+ $settingGroupsInserted = 0;
+ $settingsInserted = 0;
+ $settingsUpdated = 0;
+ $languageInserted = 0;
+ $languageUpdated = 0;
+ $modulesInserted = 0;
+ $modulesUpdated = 0;
+ $helpInserted = 0;
+ $helpUpdated = 0;
+ $templatesInserted = 0;
+ $templatesUpdated = 0;
+ $templateHooks = false;
+ $tasksInserted = 0;
+ $tasksUpdated = 0;
+ $createQueries = 0;
+ $alterQueries = 0;
+ $updateQueries = 0;
+ $insertQueries = 0;
+ $cssInserted = 0;
+ $cssUpdated = 0;
+ $replacementsInserted = 0;
+ $replacementsUpdated = 0;
+
+ //-----------------------------------------
+ // Insert/update DB records
+ //-----------------------------------------
+
+ if( $this->hooks[ $config['hook_key'] ]['hook_id'] )
+ {
+ //-----------------------------------------
+ // Don't change enabled/disabled status
+ //-----------------------------------------
+
+ unset( $config['hook_enabled'] );
+
+ $this->DB->update( 'core_hooks', $config, 'hook_id=' . $this->hooks[ $config['hook_key'] ]['hook_id'] );
+
+ $hook_id = $this->hooks[ $config['hook_key'] ]['hook_id'];
+
+ $extra_data = unserialize( $this->hooks[ $config['hook_key'] ]['hook_extra_data'] );
+
+ /* Reset DB */
+ $extra_data['database'] = array();
+ }
+ else
+ {
+ $config['hook_installed'] = IPS_UNIX_TIME_NOW;
+ $this->hook[ $config['hook_key'] ] = $config;
+
+ $this->DB->insert( 'core_hooks', $config );
+
+ $hook_id = $this->DB->getInsertId();
+
+ $this->hook[ $config['hook_key'] ]['hook_id'] = $hook_id;
+
+ $extra_data['display'] = $tempExtraData['display'];
+ }
+
+ if( count($files) )
+ {
+ //-----------------------------------------
+ // If we are updating, remove old files
+ //-----------------------------------------
+
+ if( $this->hooks[ $config['hook_key'] ]['hook_id'] )
+ {
+ $this->DB->build( array( 'select' => 'hook_file_id, hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $this->hooks[ $config['hook_key'] ]['hook_id'] ) );
+ $outer = $this->DB->execute();
+
+ while( $r = $this->DB->fetch($outer) )
+ {
+ @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
+ $this->DB->delete( 'core_hooks_files', 'hook_file_id=' . $r['hook_file_id'] );
+ }
+ }
+
+ foreach( $files as $file )
+ {
+ //-----------------------------------------
+ // Store new files
+ //-----------------------------------------
+
+ $filename = $file['hook_classname'] . '_' . md5( uniqid( microtime(), true ) ) . '.php';
+
+ file_put_contents( IPS_HOOKS_PATH . $filename, $file['hooks_source'] );
+ chmod( IPS_HOOKS_PATH . $filename, IPS_FILE_PERMISSION );
+
+ $file['hook_file_stored'] = $filename;
+ $file['hook_hook_id'] = $hook_id;
+
+ $this->DB->insert( 'core_hooks_files', $file );
+ $filesInserted++;
+
+ /* Need to recache skins? */
+ if ( $file['hook_type'] == 'templateHooks' )
+ {
+ $templateHooks = true;
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Put custom install/uninstall file
+ //-----------------------------------------
+
+ if( is_object($customClass) )
+ {
+ $extra_data['display']['custom'] = $custom['filename'];
+
+ file_put_contents( IPS_HOOKS_PATH . 'install_' . $custom['filename'], $custom['source'] );
+ chmod( IPS_HOOKS_PATH . 'install_' . $custom['filename'], IPS_FILE_PERMISSION );
+ }
+
+ //-----------------------------------------
+ // (1) Settings
+ //-----------------------------------------
+
+ if( count($settingGroups) OR count($settings) )
+ {
+ $setting_groups = array();
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $setting_groups[ $r['conf_title_id'] ] = $r;
+ $setting_groups_by_key[ $r['conf_title_keyword'] ] = $r;
+ }
+
+ //-----------------------------------------
+ // Get current settings.
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'conf_id, conf_key', 'from' => 'core_sys_conf_settings' ) );
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ $cur_settings[ $r['conf_key'] ] = $r['conf_id'];
+ }
+ }
+
+ if( count($settingGroups) )
+ {
+ $need_to_update = array();
+
+ foreach( $settingGroups as $data )
+ {
+ if ( $data['conf_title_title'] AND $data['conf_title_keyword'] )
+ {
+ //-----------------------------------------
+ // Get ID based on key
+ //-----------------------------------------
+
+ $conf_id = $setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
+
+ $save = array( 'conf_title_title' => $data['conf_title_title'],
+ 'conf_title_desc' => $data['conf_title_desc'],
+ 'conf_title_keyword' => $data['conf_title_keyword'],
+ 'conf_title_app' => $data['conf_title_app'],
+ 'conf_title_tab' => $data['conf_title_tab'],
+ 'conf_title_noshow' => $data['conf_title_noshow'] );
+
+ //-----------------------------------------
+ // Not got a row, insert first!
+ //-----------------------------------------
+
+ if ( ! $conf_id )
+ {
+ $this->DB->insert( 'core_sys_settings_titles', $save );
+ $conf_id = $this->DB->getInsertId();
+ $settingGroupsInserted++;
+ $extra_data['settingGroups'][] = $save['conf_title_keyword'];
+ }
+ else
+ {
+ //-----------------------------------------
+ // Update...
+ //-----------------------------------------
+
+ $this->DB->update( 'core_sys_settings_titles', $save, 'conf_title_id='.$conf_id );
+ }
+
+ //-----------------------------------------
+ // Update settings cache
+ //-----------------------------------------
+
+ $save['conf_title_id'] = $conf_id;
+ $setting_groups_by_key[ $save['conf_title_keyword'] ] = $save;
+ $setting_groups[ $save['conf_title_id'] ] = $save;
+
+ //-----------------------------------------
+ // Set need update...
+ //-----------------------------------------
+
+ $need_update[] = $conf_id;
+ }
+ }
+ }
+
+ if( count($settings) )
+ {
+ foreach( $settings as $idx => $data )
+ {
+ $data['conf_group'] = $setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
+
+ //-----------------------------------------
+ // Remove from array
+ //-----------------------------------------
+
+ unset( $data['conf_title_keyword'] );
+
+ if ( $cur_settings[ $data['conf_key'] ] )
+ {
+ $this->DB->update( 'core_sys_conf_settings', $data, 'conf_id='.$cur_settings[ $data['conf_key'] ] );
+ $settingsUpdated++;
+ }
+ else
+ {
+ $this->DB->insert( 'core_sys_conf_settings', $data );
+ $settingsInserted++;
+ $extra_data['settings'][] = $data['conf_key'];
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Update group counts...
+ //-----------------------------------------
+
+ if ( count( $need_update ) )
+ {
+ foreach( $need_update as $i => $idx )
+ {
+ $conf = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group=' . $idx ) );
+
+ $count = intval($conf['count']);
+
+ $this->DB->update( 'core_sys_settings_titles', array( 'conf_title_count' => $count ), 'conf_title_id='.$idx );
+ }
+ }
+
+ if( count($settingGroups) OR count($settings) )
+ {
+ $this->cache->rebuildCache( 'settings', 'global' );
+ }
+
+ //-----------------------------------------
+ // (2) Languages
+ //-----------------------------------------
+
+ if( count($language) )
+ {
+ $langPacks = array();
+
+ $this->DB->build( array( 'select' => 'lang_id', 'from' => 'core_sys_lang' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $langPacks[] = $r['lang_id'];
+ }
+
+ foreach( $language as $langbit )
+ {
+ foreach( $langPacks as $lang_id )
+ {
+
+ $langbit['lang_id'] = $lang_id;
+
+ // See if it exists
+ $cnt = $this->DB->buildAndFetch( array( 'select' => 'word_id', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id} AND word_app='{$langbit['word_app']}' AND word_key='{$langbit['word_key']}' AND word_pack='{$langbit['word_pack']}'" ) );
+
+ if( $cnt['word_id'] )
+ {
+ $this->DB->update( 'core_sys_lang_words', $langbit, 'word_id=' . $cnt['word_id'] );
+ $languageUpdated++;
+ }
+ else
+ {
+ $this->DB->insert( 'core_sys_lang_words', $langbit );
+ $languageInserted++;
+ $word_id = $this->DB->getInsertId();
+ }
+
+ $extra_data['language'][ $langbit['word_app'] . "_" . $langbit['word_pack'] ][] = $langbit['word_key'];
+ }
+
+ }
+
+ $classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages' );
+ $langLib = new $classToLoad();
+ $langLib->makeRegistryShortcuts( $this->registry );
+
+ foreach( $langPacks as $langId )
+ {
+ $langLib->cacheToDisk( $langId );
+ }
+
+ }
+
+ //-----------------------------------------
+ // (3) Modules
+ //-----------------------------------------
+
+ if( count($modules) )
+ {
+ //-----------------------------------------
+ // Get current modules
+ //-----------------------------------------
+ $cur_modules = array();
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'core_sys_module',
+ 'order' => 'sys_module_id' ) );
+
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ $cur_modules[ $r['sys_module_application'] ][ $r['sys_module_key'] ] = $r['sys_module_id'];
+ }
+
+ foreach( $modules as $module )
+ {
+ //-----------------------------------------
+ // Insert or update?
+ //-----------------------------------------
+
+ if ( $cur_modules[ $module['sys_module_application'] ][ $module['sys_module_key'] ] )
+ {
+ $this->DB->update( 'core_sys_module', $module, "sys_module_id=" . $cur_modules[ $module['sys_module_application'] ][ $module['sys_module_key'] ] );
+ $modulesUpdated++;
+ }
+ else
+ {
+ $this->DB->insert( 'core_sys_module', $module );
+ $modulesInserted++;
+
+ $extra_data['modules'][] = ( $module['sys_module_admin'] ? 'admin' : 'public' ) . '-' . $module['sys_module_application'] . '-' . $module['sys_module_key'];
+ }
+ }
+
+ $classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/applications/applications.php', 'admin_core_applications_applications' );
+ $moduleLib = new $classToLoad();
+ $moduleLib->makeRegistryShortcuts( $this->registry );
+ $moduleLib->moduleRecache();
+ $moduleLib->applicationsMenuDataRecache();
+ }
+
+ //-----------------------------------------
+ // (4) Help Files
+ //-----------------------------------------
+
+ if( count($help) )
+ {
+ $keys = array();
+
+ $this->DB->build( array( 'select' => 'title', 'from' => 'faq' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $keys[] = $r['title'];
+ }
+
+ foreach( $help as $entry )
+ {
+ if( in_array( $entry['title'], $keys ) )
+ {
+ $this->DB->update( 'faq', $entry, "title='{$entry['title']}'" );
+ $helpUpdated++;
+ }
+ else
+ {
+ $this->DB->insert( 'faq', $entry );
+ $helpInserted++;
+ $help_id = $this->DB->getInsertId();
+ $extra_data['help'][] = $entry['title'];
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // (6) Templates
+ //-----------------------------------------
+
+ if( count($templates) )
+ {
+ $bits = array();
+
+ /* Root will always be updated */
+ $this->DB->build( array( 'select' => 'template_name,template_group,template_master_key', 'from' => 'skin_templates' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $bits[ $r['template_master_key'] ][ $r['template_group'] ][] = $r['template_name'];
+ }
+
+ foreach( $templates as $template )
+ {
+ //-----------------------------------------
+ // If template is not in root set, add it to
+ // prevent fatal error selecting other skins
+ //-----------------------------------------
+
+ if ( $template['template_master_key'] != 'root' && ( !isset($bits['root'][ $template['template_group'] ]) OR !in_array( $template['template_name'], $bits['root'][ $template['template_group'] ] ) ) )
+ {
+ $this->DB->insert( 'skin_templates', array_merge( $template, array( 'template_set_id' => 0, 'template_master_key' => 'root', 'template_content' => '' ) ) );
+
+ $extra_data['templates'][ $template['template_group'] ][ $template['template_name'] ] = $template['template_name'];
+ $bits['root'][ $template['template_group'] ][] = $template['template_name'];
+ }
+
+ //-----------------------------------------
+ // Ignore unknown skin sets
+ //-----------------------------------------
+
+ if ( !isset($bits[ $template['template_master_key'] ]) )
+ {
+ continue;
+ }
+
+ if( isset($bits[ $template['template_master_key'] ][ $template['template_group'] ]) AND in_array( $template['template_name'], $bits[ $template['template_master_key'] ][ $template['template_group'] ] ) )
+ {
+ $template['template_updated'] = IPS_UNIX_TIME_NOW;
+
+ $this->DB->update( 'skin_templates', $template, "template_master_key='{$template['template_master_key']}' AND template_group='{$template['template_group']}' AND template_name='{$template['template_name']}'" );
+ $templatesUpdated++;
+ }
+ else
+ {
+ $this->DB->insert( 'skin_templates', $template );
+ $templatesInserted++;
+
+ $extra_data['templates'][ $template['template_group'] ][ $template['template_name'] ] = $template['template_name'];
+ $bits[ $template['template_master_key'] ][ $template['template_group'] ][] = $template['template_name'];
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // CSS
+ //-----------------------------------------
+
+ if( count( $css ) )
+ {
+ $bits = array();
+
+ $this->DB->build( array( 'select' => 'css_master_key, css_group', 'from' => 'skin_css' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $bits[ $r['css_master_key'] ][ $r['css_group'] ] = $r['css_group'];
+ }
+
+ foreach( $css as $entry )
+ {
+ //-----------------------------------------
+ // Ignore unknown skin sets
+ //-----------------------------------------
+
+ if ( !isset( $bits[ $entry['css_master_key'] ] ) )
+ {
+ continue;
+ }
+
+ if( in_array( $entry['css_group'], $bits[ $entry['css_master_key'] ] ) )
+ {
+ $entry['css_updated'] = IPS_UNIX_TIME_NOW;
+
+ $this->DB->update( 'skin_css', $entry, "css_master_key='{$entry['css_master_key']}' AND css_group='{$entry['css_group']}'" );
+ $cssUpdated++;
+ }
+ else
+ {
+ $this->DB->insert( 'skin_css', $entry );
+ $cssInserted++;
+
+ $extra_data['css'][ $entry['css_group'] ] = $entry['css_group'];
+ $bits[ $entry['css_master_key'] ][ $entry['css_group'] ] = $entry['css_group'];
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Skin Replacements
+ //-----------------------------------------
+
+ if( count( $replacements ) )
+ {
+ $bits = array();
+
+ $this->DB->build( array( 'select' => 'replacement_master_key, replacement_key', 'from' => 'skin_replacements' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $bits[ $r['replacement_master_key'] ][ $r['replacement_key'] ] = $r['replacement_key'];
+ }
+
+ foreach( $replacements as $entry )
+ {
+ if ( !isset( $entry['replacement_master_key'] ) or !isset( $bits[ $entry['replacement_master_key'] ] ) )
+ {
+ $entry['replacement_master_key'] = 'root';
+ }
+
+ if( in_array( $entry['replacement_key'], $bits[ $entry['replacement_master_key'] ] ) )
+ {
+ $this->DB->update( 'skin_replacements', $entry, "replacement_master_key='{$entry['replacement_master_key']}' AND replacement_key='{$entry['replacement_key']}'" );
+ $replacementsUpdated++;
+ }
+ else
+ {
+ $this->DB->insert( 'skin_replacements', $entry );
+ $replacementsInserted++;
+
+ $extra_data['replacements'][ $entry['replacement_key'] ] = $entry['replacement_key'];
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // (7) Tasks
+ //-----------------------------------------
+
+ if( count($tasks) )
+ {
+ $keys = array();
+
+ $this->DB->build( array( 'select' => 'task_key', 'from' => 'task_manager' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $keys[] = $r['task_key'];
+ }
+
+ foreach( $tasks as $entry )
+ {
+ if( in_array( $entry['task_key'], $keys ) )
+ {
+ $this->DB->update( 'task_manager', $entry, "task_key='{$entry['task_key']}'" );
+ $tasksUpdated++;
+ }
+ else
+ {
+ $this->DB->insert( 'task_manager', $entry );
+ $tasksInserted++;
+ $task_id = $this->DB->getInsertId();
+ $extra_data['tasks'][] = $entry['task_key'];
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // (8) Create new tables
+ //-----------------------------------------
+
+ if( count($database['create']) )
+ {
+ foreach($database['create'] as $create )
+ {
+ $query = "CREATE TABLE {$this->settings['sql_tbl_prefix']}{$create['name']} (
+ {$create['fields']}
+ )";
+
+ if( $create['tabletype'] )
+ {
+ $query .= " ENGINE=" . $create['tabletype'];
+ }
+ else if( $this->settings['sql_driver'] == 'mysql' AND $this->settings['mysql_tbl_type'] )
+ {
+ $query .= " ENGINE=" . $this->settings['mysql_tbl_type'];
+ }
+
+ //-----------------------------------------
+ // Fix prefix
+ //-----------------------------------------
+
+ $this->DB->return_die = true;
+ $this->DB->query( $query );
+ $this->DB->return_die = false;
+ $createQueries++;
+
+ $extra_data['database']['create'][] = $create;
+ }
+ }
+
+ //-----------------------------------------
+ // (9) Alter tables
+ //-----------------------------------------
+
+ if( count($database['alter']) )
+ {
+ foreach( $database['alter'] as $alter )
+ {
+ $this->DB->return_die = true;
+
+ $alter['default'] = ( !isset($alter['default']) || $alter['default'] === "" ) ? NULL : $alter['default'];
+
+ switch( $alter['altertype'] )
+ {
+ case 'remove':
+ $this->DB->dropField( $alter['table'], $alter['field'] );
+ break;
+
+ case 'add':
+ $this->DB->addField( $alter['table'], $alter['field'], $alter['fieldtype'], $alter['default'] );
+ break;
+
+ case 'change':
+ $this->DB->changeField( $alter['table'], $alter['field'], $alter['newfield'], $alter['fieldtype'], $alter['default'] );
+ break;
+ }
+
+ $this->DB->return_die = false;
+ $alterQueries++;
+ $extra_data['database']['alter'][] = $alter;
+ }
+ }
+
+ //-----------------------------------------
+ // (10) Run update queries
+ //-----------------------------------------
+
+ if( count($database['update']) )
+ {
+ foreach( $database['update'] as $update )
+ {
+ $this->DB->return_die = true;
+ $this->DB->update( $update['table'], array( $update['field'] => $update['newvalue'] ), html_entity_decode( $update['where'], ENT_QUOTES ) );
+ $this->DB->return_die = false;
+ $updateQueries++;
+ $extra_data['database']['update'][] = $update;
+ }
+ }
+
+ //-----------------------------------------
+ // (11) Run insert queries
+ //-----------------------------------------
+
+ // if( !$this->hooks[ $config['hook_key'] ]['hook_id'] )
+ // {
+ if( count($database['insert']) )
+ {
+ foreach( $database['insert'] as $insert )
+ {
+ $fields = array();
+ $content = explode( ',', $insert['updates'] );
+
+ foreach( $content as $value )
+ {
+ list( $field, $toInsert ) = explode( '=', $value );
+
+ $fields[ trim($field) ] = str_replace( '~C~', ',', $toInsert );
+ }
+
+ $this->DB->return_die = true;
+ $this->DB->insert( $insert['table'], $fields );
+ $this->DB->return_die = false;
+ $insertQueries++;
+ $extra_data['database']['insert'][] = $insert;
+ }
+ }
+ // }
+
+ /* Got an install function to run too? */
+ if( is_object($customClass) )
+ {
+ if( method_exists( $customClass, 'install' ) )
+ {
+ $customClass->install();
+ }
+ }
+
+ if( count($extra_data) )
+ {
+ $this->DB->update( 'core_hooks', array( 'hook_extra_data' => serialize( $extra_data ) ), 'hook_id=' . $hook_id );
+ }
+
+ //print_r($config);
+ //print_r($files);
+ //print_r($custom);
+ //print_r($settingGroups);
+ //print_r($settings);
+ //print_r($language);
+ //print_r($modules);
+ //print_r($templates);
+ //print_r($tasks);
+ //print_r($help);
+ //print_r($database);
+
+ if ( $addMessage )
+ {
+ $_tempMsg = <<{$this->lang->words['h_newhookin']}
+
+ {$filesInserted} {$this->lang->words['h_filesin']}
+ {$settingGroupsInserted} {$this->lang->words['h_settinggin']}
+ {$settingsInserted} {$this->lang->words['h_settingin']}
+ {$settingsUpdated} {$this->lang->words['h_settingup']}
+ {$languageInserted} {$this->lang->words['h_langbitin']}
+ {$languageUpdated} {$this->lang->words['h_langbitup']}
+ {$modulesInserted} {$this->lang->words['h_modin']}
+ {$modulesUpdated} {$this->lang->words['h_modup']}
+ {$helpInserted} {$this->lang->words['h_helpin']}
+ {$helpUpdated} {$this->lang->words['h_helpup']}
+ {$templatesInserted} {$this->lang->words['h_tempin']}
+ {$templatesUpdated} {$this->lang->words['h_tempup']}
+ {$cssInserted} {$this->lang->words['h_cssin']}
+ {$cssUpdated} {$this->lang->words['h_cssup']}
+ {$replacementsInserted} {$this->lang->words['h_replacementsin']}
+ {$replacementsUpdated} {$this->lang->words['h_replacementsup']}
+ {$tasksInserted} {$this->lang->words['h_taskin']}
+ {$tasksUpdated} {$this->lang->words['h_taskup']}
+ {$createQueries} {$this->lang->words['h_dbcreated']}
+ {$alterQueries} {$this->lang->words['h_dbaltered']}
+ {$updateQueries} {$this->lang->words['h_updateran']}
+ {$insertQueries} {$this->lang->words['h_insertran']}
+
+EOF;
+
+ $this->registry->output->setMessage( $_tempMsg, 1 );
+ }
+
+ //-----------------------------------------
+ // Got some skin recaching to do...
+ //-----------------------------------------
+
+ if( $allowSkinRecache === TRUE AND ( $templatesInserted OR $templatesUpdated OR $templateHooks OR $cssUpdated OR $cssInserted ) )
+ {
+ /* Rebuild cache */
+ $this->rebuildHooksCache();
+
+ /* Flag skins for recache */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+ $skinCaching->flagSetForRecache();
+ }
+ }
+
+ /**
+ * Show the form to export a hook
+ *
+ * @return void
+ */
+ protected function _exportHook()
+ {
+ /* Get the hook */
+ $id = intval($this->request['id']);
+
+ if( !$id )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noexport'], 1112 );
+ }
+
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
+
+ if( !$hookData['hook_id'] )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noexport'], 1113 );
+ }
+
+ /* Set defaults */
+ $hookData['hook_extra_data'] = unserialize( $hookData['hook_extra_data'] );
+
+ /* Output */
+ $this->registry->output->extra_nav[] = array( $this->settings['base_url'] . $this->form_code . 'do=hooks_overview', $this->lang->words['menu__manage_hooks'] );
+ $this->registry->output->html .= $this->html->hooksExport( $hookData );
+ }
+
+ /**
+ * Actually export the damn hook already
+ * Sorry, it has been a long day...
+ *
+ * @return @e void
+ */
+ protected function _doExportHook()
+ {
+ //-----------------------------------------
+ // Get hook
+ //-----------------------------------------
+
+ $id = intval($this->request['id']);
+
+ if( !$id )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noexport'], 1114 );
+ }
+
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
+
+ if( !$hookData['hook_id'] )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noexport'], 1115 );
+ }
+
+ $extra_data = unserialize( $hookData['hook_extra_data'] );
+
+ //-----------------------------------------
+ // Get hook files
+ //-----------------------------------------
+
+ $files = array();
+ $index = 1;
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id, 'order' => 'hook_file_id ASC' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $files[ $index ] = $r;
+ $index++;
+ }
+
+ //-----------------------------------------
+ // Get XML class
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
+
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+
+ $xml->newXMLDocument();
+ $xml->addElement( 'hookexport' );
+
+ //-----------------------------------------
+ // Put hook data in export
+ //-----------------------------------------
+
+ $xml->addElement( 'hookdata', 'hookexport' );
+ $content = array();
+
+ foreach( $hookData as $k => $v )
+ {
+ if( in_array( $k, array( 'hook_id', 'hook_enabled', 'hook_installed', 'hook_updated', 'hook_position' ) ) )
+ {
+ continue;
+ }
+
+ $content[ $k ] = $v;
+ }
+
+ $xml->addElementAsRecord( 'hookdata', 'config', $content );
+
+ //-----------------------------------------
+ // Put hook files in export
+ //-----------------------------------------
+
+ $xml->addElement( 'hookfiles', 'hookexport' );
+
+ foreach( $files as $index => $r )
+ {
+ $content = array();
+
+ foreach( $r as $k => $v )
+ {
+ if( in_array( $k, array( 'hook_file_id', 'hook_hook_id', 'hook_file_stored', 'hooks_source' ) ) )
+ {
+ continue;
+ }
+
+ $content[ $k ] = $v;
+ }
+
+ $source = is_file( IPS_HOOKS_PATH . $r['hook_file_stored'] ) ? file_get_contents( IPS_HOOKS_PATH . $r['hook_file_stored'] ) : '';
+
+ if ( !empty($source) && in_array( $r['hook_type'], array( 'skinHooks', 'commandHooks', 'libraryHooks' ) ) )
+ {
+ $source = $this->_cleanSource( $source );
+ }
+
+ $content['hooks_source'] = $source;
+
+ $xml->addElementAsRecord( 'hookfiles', 'file', $content );
+ }
+
+ //-----------------------------------------
+ // Custom install/uninstall script?
+ //-----------------------------------------
+
+ if( $extra_data['custom'] )
+ {
+ $content = array();
+ $xml->addElement( 'hookextras_custom', 'hookexport' );
+
+ $content['filename'] = $extra_data['custom'];
+ $content['source'] = is_file( IPS_HOOKS_PATH . 'install_' . $extra_data['custom'] ) ? file_get_contents( IPS_HOOKS_PATH . 'install_' . $extra_data['custom'] ) : '';
+
+ $xml->addElementAsRecord( 'hookextras_custom', 'file', $content );
+ }
+
+ //-----------------------------------------
+ // Settings or setting groups?
+ //-----------------------------------------
+
+ $entry = array();
+ $_groups = array();
+ $_settings = array();
+ $titles = array();
+ $content = array();
+
+ $xml->addElement( 'hookextras_settings', 'hookexport' );
+
+ # Store group ids and setting ids for entire setting groups
+ if( is_array($extra_data['settingGroups']) AND count($extra_data['settingGroups']) )
+ {
+ $_groups = $extra_data['settingGroups'];
+ $_groupIds = array();
+
+ $this->DB->build( array( 'select' => 'conf_title_id', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN('" . implode( "','", $_groups ) . "')" ) );
+ $this->DB->execute();
+
+ while( $rr = $this->DB->fetch() )
+ {
+ $_groupIds[] = $rr['conf_title_id'];
+ }
+
+ if( count($_groupIds) )
+ {
+ $this->DB->build( array( 'select' => 'conf_key', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group IN(' . implode( ',', $_groupIds ) . ')' ) );
+ $this->DB->execute();
+
+ while( $setting = $this->DB->fetch() )
+ {
+ $_settings[] = $setting['conf_key'];
+ }
+ }
+ }
+
+ # Store group ids and setting ids for indvidual settings
+ if( is_array($extra_data['settings']) AND count($extra_data['settings']) )
+ {
+ foreach( $extra_data['settings'] as $_aSetting )
+ {
+ $_settings[] = $_aSetting;
+ }
+
+ $this->DB->build( array( 'select' => 't.conf_title_keyword',
+ 'from' => array( 'core_sys_settings_titles' => 't' ),
+ 'where' => "c.conf_key IN('" . implode( "','", $extra_data['settings'] ) . "')",
+ 'add_join' => array(
+ array(
+ 'from' => array( 'core_sys_conf_settings' => 'c' ),
+ 'where' => 'c.conf_group=t.conf_title_id',
+ 'type' => 'left',
+ )
+ )
+ ) );
+ $this->DB->execute();
+
+ while( $group = $this->DB->fetch() )
+ {
+ $_groups[] = $group['conf_title_keyword'];
+ }
+ }
+
+ if( count($_groups) )
+ {
+ # Now get the group data for the XML file
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN('" . implode( "','", $_groups ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $content = array();
+
+ $titles[ $r['conf_title_id'] ] = $r['conf_title_keyword'];
+
+ $content['conf_is_title'] = 1;
+
+ foreach( $r as $k => $v )
+ {
+ if( in_array( $k, array( 'conf_title_tab', 'conf_title_keyword', 'conf_title_title', 'conf_title_desc', 'conf_title_app', 'conf_title_noshow' ) ) )
+ {
+ $content[ $k ] = $v;
+ }
+ }
+
+ $xml->addElementAsRecord( 'hookextras_settings', 'setting', $content );
+ }
+ }
+
+ if( count($_settings) )
+ {
+ # Now get the group data for the XML file
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN('" . implode( "','", $_settings ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $r['conf_value'] = '';
+ $r['conf_title_keyword'] = $titles[ $r['conf_group'] ];
+ $r['conf_is_title'] = 0;
+
+ $xml->addElementAsRecord( 'hookextras_settings', 'setting', $r );
+ }
+ }
+
+ //-----------------------------------------
+ // Language strings/files
+ //-----------------------------------------
+
+ $entry = array();
+
+ $xml->addElement( 'hookextras_language', 'hookexport' );
+
+ if( is_array($extra_data['language']) AND count($extra_data['language']) )
+ {
+ foreach( $extra_data['language'] as $file => $strings )
+ {
+ $bits = explode( '_', $file );
+ $app = $bits[0];
+ $pack = str_replace( $app.'_', '', $file );
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "word_app='{$app}' AND word_pack='{$pack}' AND word_key IN('" . implode( "','", $strings ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $content = array();
+
+ foreach( $r as $k => $v )
+ {
+ if( !in_array( $k, array( 'word_app', 'word_pack', 'word_key', 'word_default' ) ) )
+ {
+ continue;
+ }
+
+ $content[ $k ] = $v;
+ }
+
+ $xml->addElementAsRecord( 'hookextras_language', 'language', $content );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Modules
+ //-----------------------------------------
+
+ $xml->addElement( 'hookextras_modules', 'hookexport' );
+
+ if( is_array($extra_data['modules']) AND count($extra_data['modules']) )
+ {
+ foreach ( $extra_data['modules'] as $module )
+ {
+ list( $_side, $_app, $_module ) = explode( '-', $module );
+ $_is_admin = ( $_side == 'admin' ) ? 1 : 0;
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_module', 'where' => "sys_module_application='{$_app}' AND sys_module_key='{$_module}' AND sys_module_admin={$_is_admin}" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ unset($r['sys_module_id']);
+
+ $xml->addElementAsRecord( 'hookextras_modules', 'module', $r );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Help files
+ //-----------------------------------------
+
+ $xml->addElement( 'hookextras_help', 'hookexport' );
+
+ if( is_array($extra_data['help']) AND count($extra_data['help']) )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'faq', 'where' => "title IN('" . implode( "','", $extra_data['help'] ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ unset($r['id']);
+
+ $xml->addElementAsRecord( 'hookextras_help', 'help', $r );
+ }
+ }
+
+ //-----------------------------------------
+ // Skin templates
+ //-----------------------------------------
+
+ $remapData = $this->registry->output->buildRemapData( true );
+
+ $xml->addElement( 'hookextras_templates', 'hookexport' );
+
+ if( is_array($extra_data['templates']) AND count($extra_data['templates']) )
+ {
+ foreach( $extra_data['templates'] as $file => $templates )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'skin_templates', 'where' => "template_set_id IN ('" . implode( "','", $remapData['export'] ) . "') AND template_master_key != '' AND template_group='{$file}' AND template_name IN('" . implode( "','", $templates ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ unset($r['template_id']);
+ unset($r['template_set_id']);
+
+ $xml->addElementAsRecord( 'hookextras_templates', 'templates', $r );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // CSS
+ //-----------------------------------------
+
+ $xml->addElement( 'hookextras_css', 'hookexport' );
+
+ if( is_array( $extra_data['css'] ) AND count ( $extra_data['css'] ) )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'skin_css', 'where' => "css_set_id IN ('" . implode( "','", $remapData['export'] ) . "') AND css_master_key != '' AND css_group IN('" . implode( "','", $extra_data['css'] ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ unset($r['css_id']);
+ unset($r['css_set_id']);
+
+ $xml->addElementAsRecord( 'hookextras_css', 'css', $r );
+ }
+ }
+
+ //-----------------------------------------
+ // Replacements
+ //-----------------------------------------
+
+ $xml->addElement( 'hookextras_replacements', 'hookexport' );
+
+ if( is_array( $extra_data['replacements'] ) AND count ( $extra_data['replacements'] ) )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'skin_replacements', 'where' => "replacement_key IN('" . implode( "','", $extra_data['replacements'] ) . "')", 'group' => 'replacement_key' ) );
+
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ unset($r['replacement_id']);
+ unset($r['replacement_set_id']);
+
+ $xml->addElementAsRecord( 'hookextras_replacements', 'replacements', $r );
+ }
+ }
+
+ //-----------------------------------------
+ // Tasks
+ //-----------------------------------------
+
+ $xml->addElement( 'hookextras_tasks', 'hookexport' );
+
+ if( is_array($extra_data['tasks']) AND count($extra_data['tasks']) )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'task_manager', 'where' => "task_key IN('" . implode( "','", $extra_data['tasks'] ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ unset($r['task_id']);
+ unset($r['task_next_run']);
+
+ $xml->addElementAsRecord( 'hookextras_tasks', 'tasks', $r );
+ }
+ }
+
+ //-----------------------------------------
+ // Database changes
+ //-----------------------------------------
+
+ $xml->addElement( 'hookextras_database_create', 'hookexport' );
+
+ if( is_array($extra_data['database']['create']) AND count($extra_data['database']['create']) )
+ {
+ foreach( $extra_data['database']['create'] as $create_query )
+ {
+ $xml->addElementAsRecord( 'hookextras_database_create', 'create', $create_query );
+ }
+ }
+
+ $xml->addElement( 'hookextras_database_alter', 'hookexport' );
+
+ if( is_array($extra_data['database']['alter']) AND count($extra_data['database']['alter']) )
+ {
+ foreach( $extra_data['database']['alter'] as $alter_query )
+ {
+ $xml->addElementAsRecord( 'hookextras_database_alter', 'alter', $alter_query );
+ }
+ }
+
+ $xml->addElement( 'hookextras_database_update', 'hookexport' );
+
+ if( is_array($extra_data['database']['update']) AND count($extra_data['database']['update']) )
+ {
+ foreach( $extra_data['database']['update'] as $update_query )
+ {
+ $xml->addElementAsRecord( 'hookextras_database_update', 'update', $update_query );
+ }
+ }
+
+ $xml->addElement( 'hookextras_database_insert', 'hookexport' );
+
+ if( is_array($extra_data['database']['insert']) AND count($extra_data['database']['insert']) )
+ {
+ foreach( $extra_data['database']['insert'] as $insert_query )
+ {
+ $xml->addElementAsRecord( 'hookextras_database_insert', 'insert', $insert_query );
+ }
+ }
+
+ //-----------------------------------------
+ // Print to browser
+ //-----------------------------------------
+
+ $this->registry->output->showDownload( $xml->fetchDocument(), $hookData['hook_key'] . '.xml', '', 0 );
+ }
+
+ /**
+ * Clean source code for export..
+ *
+ * @param string Hook source code
+ * @return string "Cleaned" source code
+ */
+ protected function _cleanSource( $source )
+ {
+ $source = preg_replace( "/class\s+(\S+)\s+extends\s+(\S+)/i", "class \\1 extends (~extends~)", $source );
+
+ return $source;
+ }
+
+ /**
+ * Fix hook positions
+ *
+ * @return @e void
+ */
+ protected function _fixPositions()
+ {
+ /* Init vars */
+ $new_order = 0;
+ $usedActions = array();
+
+ $this->DB->build( array( 'select' => 'hook_id, hook_position', 'from' => 'core_hooks', 'where' => 'hook_enabled=1', 'order' => 'hook_position ASC' ) );
+ $qid = $this->DB->execute();
+
+ while ( $hook = $this->DB->fetch( $qid ) )
+ {
+ $new_order++;
+ $this->DB->update( 'core_hooks', array ( 'hook_position' => $new_order ), "hook_id={$hook['hook_id']}" );
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => "hook_type IN ('commandHooks', 'skinHooks', 'libraryHooks' ) AND hook_hook_id=" . $hook['hook_id'] ) );
+ $this->DB->execute();
+
+ while( $file = $this->DB->fetch() )
+ {
+ if( $file['hooks_source'] )
+ {
+ $source = $this->_cleanSource( $file['hooks_source'] );
+ }
+ else
+ {
+ $source = is_file( IPS_HOOKS_PATH . $file['hook_file_stored'] ) ? file_get_contents( IPS_HOOKS_PATH . $file['hook_file_stored'] ) : '';
+
+ if( $source )
+ {
+ $source = $this->_cleanSource( $source );
+ }
+ }
+
+ if( $source )
+ {
+ $hook_data = unserialize( $file['hook_data'] );
+ $overload = $hook_data['classToOverload'];
+ $newClass = $overload;
+
+ $app = ( $file['hook_type'] == 'libraryHooks' ) ? trim($hook_data['libApplication']) : '~_NO_APP_~';
+
+ if( isset( $usedActions[ $app ][ $overload ] ) )
+ {
+ $newClass = $usedActions[ $app ][ $overload ];
+ }
+ else if( $file['hook_type'] == 'skinHooks' )
+ {
+ $newClass .= "(~id~)";
+ }
+
+ $source = str_replace( "(~extends~)", $newClass, $source );
+
+ file_put_contents( IPS_HOOKS_PATH . $file['hook_file_stored'], $source );
+
+ $usedActions[ $app ][ $hook_data['classToOverload'] ] = $file['hook_classname'];
+ }
+ }
+ }
+ }
+
+ /**
+ * Check if there is an update for a hook
+ *
+ * @param string URL to check
+ * @param string Long version number
+ * @return bool
+ */
+ public function _updateAvailable( $url, $version )
+ {
+ if( empty($url) || $version === '' )
+ {
+ return false;
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . '/classFileManagement.php', 'classFileManagement' );
+ $checker = new $classToLoad();
+
+ /* Timeout to prevent page from taking too long */
+ $checker->timeout = 5;
+
+ /* Setup url and check */
+ $url = str_replace( 'php&', 'php?', $url );
+ $url .= '&boardVersion=' . IPB_LONG_VERSION . '&version=' . $version;
+
+ $return = $checker->getFileContents( $url );
+
+ /* Return the content (if valid) or return 'no update' */
+ $return = ( strpos( $return, '0' ) === 0 || strpos( $return, '1' ) === 0 ) ? explode( '|', $return ) : array( 0 );
+
+ /* Replace {IPSID} id necessary */
+ if ( strpos( $return[1], '{IPSID}' ) )
+ {
+ if ( ipsRegistry::$settings['ipb_reg_number'] )
+ {
+ $exploded = explode( '-', ipsRegistry::$settings['ipb_reg_number'] );
+ $return[1] = str_replace( '{IPSID}', $exploded[3], $return[1] );
+ }
+ else
+ {
+ $return[1] = "https://www.invisionpower.com/clients";
+ }
+ }
+
+ return $return;
+ }
+
+ /**
+ * Sorts hooks by their position
+ * (this is used to avoid a mysql filesort)
+ *
+ * @param array $a First hook data
+ * @param array $b Second hook data
+ * @return @e integer
+ */
+ protected function sortHooksByPosition( $a, $b )
+ {
+ if ( $a['hook_position'] == $b['hook_position'] )
+ {
+ return 0;
+ }
+
+ return ( $a['hook_position'] < $b['hook_position'] ) ? -1 : 1;
+ }
+
+ /**
+ * Hooks overview
+ *
+ * @return @e void [Outputs to screen]
+ */
+ public function _hooksOverview()
+ {
+ /* INI */
+ $hooksFound = array( 'installed' => array(), 'uninstalled' => array() );
+ $hookwarnings = 0;
+ $hookUpdates = 0;
+ $checkUpdates = !empty( $this->request['checkUpdates'] ) ? true : false;
+ $message = '';
+ $confGroupIdsToLoad = array();
+ $confGroupKeysToLoad= array();
+
+ /* Get current hooks */
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks' ) );
+ $outer = $this->DB->execute();
+
+ while( $r = $this->DB->fetch($outer) )
+ {
+ /* Format some dates */
+ $r['_updated'] = $this->registry->getClass('class_localization')->formatTime( $r['hook_updated'] );
+ $r['_installed'] = $this->registry->getClass('class_localization')->formatTime( $r['hook_installed'] );
+
+ /* Got updates? */
+ if ( $r['hook_update_check'] && $checkUpdates === true )
+ {
+ $r['hook_update_available'] = $this->_updateAvailable( $r['hook_update_check'], $r['hook_version_long'] );
+
+ if ( $r['hook_update_available'][0] )
+ {
+ $hookUpdates++;
+ }
+ }
+ else
+ {
+ $r['hook_update_available'] = array( 0 );
+ }
+
+ /* Got some setting groups to take care of? */
+ $r['_has_setting_links'] = null;
+ $r['_hook_extra_data'] = IPSLib::isSerialized($r['hook_extra_data']) ? unserialize($r['hook_extra_data']) : array();
+
+ if ( is_array($r['_hook_extra_data']['settingGroups']) && count($r['_hook_extra_data']['settingGroups']) )
+ {
+ $r['_has_setting_links'] = array();
+
+ foreach( $r['_hook_extra_data']['settingGroups'] as $_group )
+ {
+ $confGroupKeysToLoad[ $_group ] = $_group;
+ }
+ }
+
+ if ( is_array($r['_hook_extra_data']['settings']) && count($r['_hook_extra_data']['settings']) )
+ {
+ $r['_has_setting_links'] = array();
+
+ $this->DB->build( array( 'select' => 'conf_group, conf_key', 'from' => 'core_sys_conf_settings', 'where' => "conf_key IN ('" . implode( "','", $r['_hook_extra_data']['settings'] ) . "')" ) );
+ $this->DB->execute();
+
+ while( $hsg = $this->DB->fetch() )
+ {
+ $confGroupIdsToLoad[ $hsg['conf_key'] ] = $hsg['conf_group'];
+ }
+ }
+
+ /* Check requirements */
+ $r['_require_errors'] = $this->checkHookRequirements( $r );
+
+ /* Store */
+ if( $r['hook_enabled'] )
+ {
+ if ( count($r['_require_errors']) )
+ {
+ $hookwarnings++;
+ }
+
+ $hooksFound['installed'][ $r['hook_id'] ] = $r;
+ }
+ else
+ {
+ $hooksFound['uninstalled'][ $r['hook_id'] ] = $r;
+ }
+ }
+
+ /* Got groups to load? */
+ $where = array();
+
+ if ( count($confGroupKeysToLoad) )
+ {
+ $where[] = "conf_title_keyword IN ('" . implode( "','", $confGroupKeysToLoad ) . "')";
+ }
+
+ if ( count($confGroupIdsToLoad) )
+ {
+ $where[] = "conf_title_id IN (" . implode( ",", $confGroupIdsToLoad ) . ")";
+ }
+
+ if ( count($where) )
+ {
+ $confGroupsLoaded = array();
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'where' => implode( ' OR ', $where ) ) );
+ $this->DB->execute();
+
+ while( $gr = $this->DB->fetch() )
+ {
+ if ( empty($gr['conf_title_noshow']) )
+ {
+ $confGroupsLoaded['ids'][ $gr['conf_title_id'] ] = $gr;
+ $confGroupsLoaded['keys'][ $gr['conf_title_keyword'] ] = & $confGroupsLoaded['ids'][ $gr['conf_title_id'] ];
+ }
+ }
+
+ /* Merge back the data */
+ foreach( $hooksFound as $rk => $rt )
+ {
+ foreach( $rt as $sk => $st )
+ {
+ if ( is_array($st['_has_setting_links']) )
+ {
+ if ( is_array($st['_hook_extra_data']['settingGroups']) && count($st['_hook_extra_data']['settingGroups']) )
+ {
+ foreach( $st['_hook_extra_data']['settingGroups'] as $_group )
+ {
+ if ( isset($confGroupsLoaded['keys'][ $_group ]) )
+ {
+ $hooksFound[ $rk ][ $sk ]['_has_setting_links'][ $confGroupsLoaded['keys'][ $_group ]['conf_title_id'] ] = $confGroupsLoaded['keys'][ $_group ]['conf_title_title'];
+ }
+ }
+ }
+
+ if ( is_array($st['_hook_extra_data']['settings']) && count($st['_hook_extra_data']['settings']) )
+ {
+ foreach( $st['_hook_extra_data']['settings'] as $_id )
+ {
+ if ( isset($confGroupsLoaded['ids'][ $confGroupIdsToLoad[ $_id ] ]) )
+ {
+ $hooksFound[ $rk ][ $sk ]['_has_setting_links'][ $confGroupIdsToLoad[ $_id ] ] = $confGroupsLoaded['ids'][ $confGroupIdsToLoad[ $_id ] ]['conf_title_title'];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* Got updates to show? */
+ if ( $checkUpdates === true )
+ {
+ $message = ( $hookUpdates == 1 ) ? $this->lang->words['updates_string_single'] : sprintf( $this->lang->words['updates_string_more'], $hookUpdates );
+ }
+
+ if ( count($hooksFound['installed']) )
+ {
+ uasort( $hooksFound['installed'], array( $this, 'sortHooksByPosition' ) );
+ }
+
+ /* Output */
+ $this->registry->output->html .= $this->html->hooksOverview( $hooksFound, $hookwarnings, $message );
+ }
+
+ /**
+ * Disables all hook
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _disableAllHooks()
+ {
+ /* INIT */
+ $activeHookIds = array();
+
+ /* Query Enabled Hooks */
+ $this->DB->build( array( 'select' => 'hook_id', 'from' => 'core_hooks', 'where' => "hook_enabled=1" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $activeHookIds[] = $r['hook_id'];
+ }
+
+ /* Make sure there were active hooks */
+ if( ! count( $activeHookIds ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['hook_disable_all_none'];
+ $this->_hooksOverview();
+ return;
+ }
+
+ /* Disable hooks */
+ $this->DB->update( 'core_hooks', array( 'hook_enabled' => 0 ), 'hook_id IN( ' . implode( ',', $activeHookIds ) . ' ) ' );
+
+ /* Save to cache */
+ $this->cache->setCache( 'disabledHooksCache', $activeHookIds, array( 'array' => 1 ) );
+
+ /* Rebuild cache */
+ $this->rebuildHooksCache();
+
+ /* All Done */
+ $this->registry->output->global_message = $this->lang->words['hook_disabled_all'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /**
+ * Re-enable all hook
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _reenableAllHooks()
+ {
+ /* INIT */
+ $activeHookIds = $this->cache->getCache( 'disabledHooksCache' );
+
+ /* Make sure there were active hooks */
+ if( ! count( $activeHookIds ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['hook_enable_all_none'];
+ $this->_hooksOverview();
+ return;
+ }
+
+ /* Disable hooks */
+ $this->DB->update( 'core_hooks', array( 'hook_enabled' => 1 ), 'hook_id IN( ' . implode( ',', $activeHookIds ) . ' ) ' );
+
+ /* Save to cache */
+ $this->cache->setCache( 'disabledHooksCache', array(), array( 'array' => 1 ) );
+
+ /* Rebuild cache */
+ $this->rebuildHooksCache();
+
+ /* Flag skins for recache */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+
+ /* Flag all for recache */
+ $skinCaching->flagSetForRecache();
+
+ /* All Done */
+ $this->registry->output->global_message = $this->lang->words['hook_reenable_all'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /**
+ * Disables a hook
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _disableHook()
+ {
+ /* INI */
+ $hook_id = intval( $this->request['id'] );
+
+ if( !$hook_id )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noedit'], '1118.D' );
+ }
+
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id ) );
+
+ if( !$hookData['hook_id'] )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noedit'], '1119.D' );
+ }
+
+ /* Do update */
+ $this->DB->update( 'core_hooks', array( 'hook_enabled' => 0, 'hook_position' => 0 ), "hook_id={$hookData['hook_id']}" );
+
+ /* Rebuild cache */
+ $this->rebuildHooksCache();
+
+ /* Rebuild global caches */
+ try
+ {
+ IPSLib::cacheGlobalCaches();
+ }
+ catch( Exception $e ){}
+
+ /* Flag skins for recache */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+ $skinCaching->flagSetForRecache();
+
+ /* Redirect */
+ $this->registry->output->setMessage( $this->lang->words['h_hasbeendisabled'] );
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /**
+ * Enables a hook
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _enableHook()
+ {
+ /* INI */
+ $hook_id = intval($this->request['id']);
+
+ if( !$hook_id )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noedit'], '1118.E' );
+ }
+
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id ) );
+
+ if( !$hookData['hook_id'] )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noedit'], '1119.E' );
+ }
+
+ /* Check for requirements */
+ if ( empty($this->request['skipRequirements']) )
+ {
+ $errors = $this->checkHookRequirements( $hookData );
+
+ if ( count($errors) )
+ {
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=check_requirements&fromInstall=1&id='.$hook_id );
+ }
+ }
+
+ /* Do update */
+ $this->DB->update( 'core_hooks', array( 'hook_enabled' => 1 ), "hook_id={$hookData['hook_id']}" );
+
+ /* Rebuild cache */
+ $this->rebuildHooksCache();
+
+ /* Rebuild global caches */
+ try
+ {
+ IPSLib::cacheGlobalCaches();
+ }
+ catch( Exception $e ){}
+
+ /* Flag skins for recache */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+ $skinCaching->flagSetForRecache();
+
+ /* Redirect */
+ $this->registry->output->global_message = $this->lang->words['h_hasbeenenabled'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /**
+ * Uninstall a hook
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _uninstallHook()
+ {
+ /* Init vars */
+ $hook_id = intval( $this->request['id'] );
+
+ $hook = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook_id ) );
+ $extra_data = unserialize( $hook['hook_extra_data'] );
+
+ if ( ! $hook['hook_id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['h_hasbeenun'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /* Got any custom file to initialize? */
+ $_customFile = '';
+ $customClass = null;
+
+ if ( $extra_data['display']['custom'] )
+ {
+ $_customFile = IPS_HOOKS_PATH . 'install_' . $extra_data['display']['custom'];
+
+ if( is_file( $_customFile ) )
+ {
+ require_once( $_customFile );/*noLibHook*/
+
+ $classname = str_replace( '.php', '', $extra_data['display']['custom'] );
+
+ if( class_exists( $classname ) )
+ {
+ $customClass = new $classname( $this->registry );
+
+ if( method_exists( $customClass, 'pre_uninstall' ) )
+ {
+ $customClass->pre_uninstall();
+ }
+ }
+ }
+ }
+
+ /* Get associated files */
+ $this->DB->build( array( 'select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $hook_id ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
+ }
+
+ /* Delete hook file entries */
+ $this->DB->delete( 'core_hooks_files', "hook_hook_id={$hook_id}" );
+
+ //-----------------------------------------
+ // Settings or setting groups?
+ //-----------------------------------------
+
+ if( count($extra_data['settingGroups']) )
+ {
+ $this->DB->delete( 'core_sys_settings_titles', "conf_title_keyword IN('" . implode( "','", $extra_data['settingGroups'] ) . "')" );
+ }
+
+ if( count($extra_data['settings']) )
+ {
+ $this->DB->delete( 'core_sys_conf_settings', "conf_key IN('" . implode( "','", $extra_data['settings'] ) . "')" );
+ }
+
+ $this->cache->rebuildCache( 'settings', 'global' );
+
+ //-----------------------------------------
+ // Language strings/files
+ //-----------------------------------------
+
+ if( count($extra_data['language']) )
+ {
+ foreach( $extra_data['language'] as $file => $bit )
+ {
+ $this->DB->delete( 'core_sys_lang_words', "word_pack='{$file}' AND word_key IN('" . implode( "','", $bit ) . "')" );
+ }
+
+ $langPacks = array();
+
+ $this->DB->build( array( 'select' => 'lang_id', 'from' => 'core_sys_lang' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $langPacks[] = $r['lang_id'];
+ }
+
+ $classToLoad = IPSLib::loadActionOverloader( IPSLib::getAppDir('core') . '/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages' );
+ $langLib = new $classToLoad();
+ $langLib->makeRegistryShortcuts( $this->registry );
+
+ foreach( $langPacks as $langId )
+ {
+ $langLib->cacheToDisk( $langId );
+ }
+ }
+
+ //-----------------------------------------
+ // Modules
+ //-----------------------------------------
+
+ if( count($extra_data['modules']) )
+ {
+ foreach( $extra_data['modules'] as $module )
+ {
+ list( $_side, $_app, $_module ) = explode( '-', $module );
+ $_is_admin = ( $_side == 'admin' ) ? 1 : 0;
+
+ $this->DB->delete( 'core_sys_module', "sys_module_application='{$_app}' AND sys_module_key='{$_module}' AND sys_module_admin={$_is_admin}" );
+ }
+
+ $this->cache->rebuildCache( 'module_cache', 'global' );
+ $this->cache->rebuildCache( 'app_menu_cache', 'global' );
+ }
+
+ //-----------------------------------------
+ // Help files
+ //-----------------------------------------
+
+ if( count($extra_data['help']) )
+ {
+ $this->DB->delete( 'faq', "title IN('" . implode( "','", $extra_data['help'] ) . "')" );
+ }
+
+ //-----------------------------------------
+ // Skin templates
+ //-----------------------------------------
+
+ if( count($extra_data['templates']) )
+ {
+ foreach( $extra_data['templates'] as $group => $bits )
+ {
+ $this->DB->delete( 'skin_templates', "template_group='{$group}' AND template_name IN('" . implode( "','", $bits ) . "')" );
+ }
+
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+ $skinCaching->rebuildPHPTemplates( 0 );
+ }
+
+ //-----------------------------------------
+ // CSS
+ //-----------------------------------------
+
+ if( count( $extra_data['css'] ) )
+ {
+ $this->DB->delete( 'skin_css', "css_group IN('" . implode( "','", $extra_data['css'] ) . "')" );
+
+ if( ! $skinCaching )
+ {
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+ }
+
+ $skinCaching->rebuildCSSCache( 0 );
+ }
+
+ //-----------------------------------------
+ // Tasks
+ //-----------------------------------------
+
+ if( count($extra_data['tasks']) )
+ {
+ $this->DB->delete( 'task_manager', "task_key IN('" . implode( "','", $extra_data['tasks'] ) . "')" );
+ }
+
+ //-----------------------------------------
+ // Database changes
+ //-----------------------------------------
+
+ if( is_array($extra_data['database']['create']) AND count($extra_data['database']['create']) )
+ {
+ foreach( $extra_data['database']['create'] as $create_query )
+ {
+ $this->DB->return_die = true;
+ $this->DB->dropTable( $create_query['name'] );
+ $this->DB->return_die = false;
+ }
+ }
+
+ if( is_array($extra_data['database']['alter']) AND count($extra_data['database']['alter']) )
+ {
+ foreach( $extra_data['database']['alter'] as $alter_query )
+ {
+ $this->DB->return_die = true;
+
+ if( $alter_query['altertype'] == 'add' )
+ {
+ if( $this->DB->checkForField( $alter_query['field'], $alter_query['table'] ) )
+ {
+ $this->DB->dropField( $alter_query['table'], $alter_query['field'] );
+ }
+ }
+ else if( $alter_query['altertype'] == 'change' )
+ {
+ if( $this->DB->checkForField( $alter_query['newfield'], $alter_query['table'] ) )
+ {
+ $this->DB->changeField( $alter_query['table'] , $alter_query['newfield'], $alter_query['field'], $alter_query['fieldtype'], $alter_query['default'] );
+ }
+ }
+
+ $this->DB->return_die = false;
+ }
+ }
+
+ if( is_array($extra_data['database']['update']) AND count($extra_data['database']['update']) )
+ {
+ foreach( $extra_data['database']['update'] as $update_query )
+ {
+ $this->DB->return_die = true;
+ $this->DB->update( $update_query['table'], array( $update_query['field'] => $update_query['oldvalue'] ), $update_query['where'] );
+ $this->DB->return_die = false;
+ }
+ }
+
+ if( is_array($extra_data['database']['insert']) AND count($extra_data['database']['insert']) )
+ {
+ foreach( $extra_data['database']['insert'] as $insert_query )
+ {
+ if( $insert_query['fordelete'] )
+ {
+ $this->DB->return_die = true;
+ $this->DB->delete( $insert_query['table'], $insert_query['fordelete'] );
+ $this->DB->return_die = false;
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Custom install/uninstall script?
+ //-----------------------------------------
+
+ if ( $_customFile )
+ {
+ if( is_object($customClass) && method_exists( $customClass, 'uninstall' ) )
+ {
+ $customClass->uninstall();
+ }
+
+ @unlink( $_customFile );
+ }
+
+ /* Delete main hook entry */
+ $this->DB->delete( 'core_hooks', "hook_id={$hook_id}" );
+
+ $this->rebuildHooksCache();
+
+ /* Done */
+ $this->registry->output->global_message = $this->lang->words['h_hasbeenun'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /**
+ * Hook add/edit form
+ * This dynamic form allows users to associate multiple files with a single hook.
+ *
+ * @param string [add|edit]
+ * @return @e void [Outputs to screen]
+ */
+ protected function _hookForm( $type='add' )
+ {
+ /* Init vars */
+ $form = array();
+ $files = array();
+ $hookData = array();
+ $requirements = array();
+ $entryPoints = array( 'foreach' => array( array( 'outer.pre', $this->lang->words['h_outerpre'] ),
+ array( 'inner.pre', $this->lang->words['h_innerpre'] ),
+ array( 'inner.post', $this->lang->words['h_innerpost'] ),
+ array( 'outer.post', $this->lang->words['h_outerpost'] )
+ ),
+ 'if' => array( array( 'pre.startif', $this->lang->words['h_prestartif'] ),
+ array( 'post.startif', $this->lang->words['h_poststartif'] ),
+ array( 'pre.else', $this->lang->words['h_preelse']),
+ array( 'post.else', $this->lang->words['h_postelse'] ),
+ array( 'pre.endif', $this->lang->words['h_preendif'] ),
+ array( 'post.endif', $this->lang->words['h_postendif'] )
+ )
+ );
+
+ /* Edit time? */
+ if( $type == 'edit' )
+ {
+ $id = intval($this->request['id']);
+
+ if( !$id )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noedit'], 1116 );
+ }
+
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
+
+ if( !$hookData['hook_id'] )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noedit'], 1117 );
+ }
+
+ /* Sort out extra stuff and requirements */
+ $hookData['hook_extra_data'] = unserialize( $hookData['hook_extra_data'] );
+ $hookData['hook_requirements'] = unserialize( $hookData['hook_requirements'] );
+
+ /* Old data? - @todo: we should remove that around 3.3(4?) */
+ if ( ! isset($hookData['hook_requirements']['required_applications']['core']) && isset($hookData['hook_requirements']['hook_ipb_version_min']) && ( $hookData['hook_requirements']['hook_ipb_version_min'] > 0 || $hookData['hook_requirements']['hook_ipb_version_max'] > 0 ) )
+ {
+ $requirements['core'] = array( 'min_version' => intval($hookData['hook_requirements']['hook_ipb_version_min']), 'max_version' => intval($hookData['hook_requirements']['hook_ipb_version_max']) );
+ }
+
+ if ( is_array($hookData['hook_requirements']['required_applications']) && count($hookData['hook_requirements']['required_applications']) )
+ {
+ /* Get the setup class */
+ require_once( IPS_ROOT_PATH . 'setup/sources/base/setup.php' );/*noLibHook*/
+
+ foreach( $hookData['hook_requirements']['required_applications'] as $appKey => $versionData )
+ {
+ /* Fetch and check versions */
+ if ( !isset($this->cachedVersions[ $appKey ]) )
+ {
+ $this->cachedVersions[ $appKey ] = IPSSetUp::fetchXmlAppVersions( $appKey );
+ }
+
+ $_versions = $this->cachedVersions[ $appKey ];
+
+ krsort($_versions);
+
+ /* Setup our default 'no version' value */
+ $versions = array( array( 0, $this->lang->words['h_any_version'] ) );
+
+ foreach( $_versions as $long => $human )
+ {
+ if ( $long < 30000 && in_array( $appKey, array( 'core', 'forums', 'members' ) ) )
+ {
+ continue;
+ }
+
+ $versions[] = array( $long, $human );
+ }
+
+ $versionData['_versions'] = $versions;
+ $requirements[ $appKey ] = $versionData;
+ }
+ }
+
+ /* Sort out hook files */
+ $index = 1;
+ $skinGroups = $this->hooksFunctions->getSkinGroups();
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id ) );
+ $outer = $this->DB->execute();
+
+ /* Get them outside the while cycle to prevent warnings */
+ $_dataHooks = IPSLib::getDataHookLocations();
+
+ while( $r = $this->DB->fetch($outer) )
+ {
+ $r['hook_data'] = unserialize( $r['hook_data'] );
+
+ if( $r['hook_type'] == 'templateHooks' )
+ {
+ $templates = $this->hooksFunctions->getSkinMethods( $r['hook_data']['skinGroup'] );
+ $hookIds = $this->hooksFunctions->getHookIds( $r['hook_data']['skinFunction'], $r['hook_data']['type'] );
+
+ $r['_skinDropdown'] = $this->registry->output->formDropdown( "skinGroup[{$index}]", $skinGroups, $r['hook_data']['skinGroup'], "skinGroup[{$index}]", "onchange='getTemplatesForAdd({$index});'" );
+ $r['_templateDropdown'] = $this->registry->output->formDropdown( "skinFunction[{$index}]", $templates, $r['hook_data']['skinFunction'], "skinFunction[{$index}]", "onchange='getTypeOfHook({$index});'" );
+ $r['_hookTypeDropdown'] = $this->registry->output->formDropdown( "type[{$index}]", array( array( 0, $this->lang->words['a_selectone'] ), array( 'foreach', $this->lang->words['hook_foreach_loop'] ), array( 'if', $this->lang->words['hook_if_statement'] ) ), $r['hook_data']['type'], "type[{$index}]", "onchange='getHookIds({$index});'" );
+ $r['_hookIdsDropdown'] = $this->registry->output->formDropdown( "id[{$index}]", $hookIds, $r['hook_data']['id'], "id[{$index}]", "onchange='getHookEntryPoints({$index});'" );
+ $r['_hookEPDropdown'] = $this->registry->output->formDropdown( "position[{$index}]", $r['hook_data']['type'] == 'foreach' ? $entryPoints['foreach'] : $entryPoints['if'], $r['hook_data']['position'] );
+ }
+
+ if( $r['hook_type'] == 'dataHooks' )
+ {
+ $r['_dataLocationDropdown'] = $this->registry->output->formDropdown( "dataLocation[{$index}]", $_dataHooks, $r['hook_data']['dataLocation'] );
+ }
+
+ $files[ $index ] = $r;
+ $index++;
+ }
+
+ $action = 'do_edit_hook';
+ }
+ else
+ {
+ $action = 'do_create_hook';
+ }
+
+ /* Info */
+ foreach( array( 'hook_name', 'hook_desc', 'hook_key', 'hook_version_human', 'hook_version_long', 'hook_author', 'hook_email', 'hook_website', 'hook_update_check' ) as $_hook_key )
+ {
+ $form[ $_hook_key ] = $this->registry->output->formSimpleInput( $_hook_key , isset($this->request[ $_hook_key ]) ? $this->request[ $_hook_key ] : $hookData[ $_hook_key ], 60 );
+ }
+
+ /* Requirements */
+ foreach( array( 'hook_php_version_min', 'hook_php_version_max' ) as $_version_key )
+ {
+ $form[ $_version_key ] = $this->registry->output->formSimpleInput( $_version_key , isset($this->request[ $_version_key ]) ? $this->request[ $_version_key ] : $hookData['hook_requirements'][ $_version_key ], 20 );
+ }
+
+ /* Setup the global caches DD */
+ $_caches = array();
+
+ $this->DB->build( array( 'select' => 'cs_key',
+ 'from' => 'cache_store',
+ 'order' => 'cs_key ASC'
+ ) );
+ $this->DB->execute();
+
+ while( $gc = $this->DB->fetch() )
+ {
+ $_caches[] = array( $gc['cs_key'], $gc['cs_key'] );
+ }
+
+ sort( $_caches );
+
+ $form['hook_global_caches'] = $this->registry->output->formMultiDropdown( 'hook_global_caches[]', $_caches, isset($_POST['hook_global_caches']) ? $_POST['hook_global_caches'] : explode(',',$hookData['hook_global_caches']), 15 );
+
+ /* Get some data for the javascript */
+ $form['jsDataTypes'] = IPSText::br2nl( $this->registry->output->formDropdown( "type[#{index}]", array( array( 0, $this->lang->words['a_selectone'] ), array( 'foreach', $this->lang->words['hook_foreach_loop'] ), array( 'if', $this->lang->words['hook_if_statement'] ) ), '', "type[#{index}]", "onchange='getHookIds(#{index});'" ) );
+ $form['jsDataPoints'] = IPSText::br2nl( $this->registry->output->formDropdown( "position[#{index}]", $r['hook_data']['type'] == 'foreach' ? $entryPoints['foreach'] : $entryPoints['if'] ) );
+
+ /* Output */
+ $this->registry->output->extra_nav[] = array( $this->settings['base_url'] . $this->form_code . 'do=hooks_overview', $this->lang->words['menu__manage_hooks'] );
+ $this->registry->output->html .= $this->html->hookForm( $form, $action, $hookData, $files, $requirements );
+ }
+
+ /**
+ * Hook add/edit save
+ * Save the new (or updated) hook record
+ *
+ * @param string [add|edit]
+ * @return @e void [Outputs to screen]
+ */
+ protected function _hookSave( $type='add' )
+ {
+ /* Init vars */
+ $hookData = array();
+ $newFiles = array();
+ $requireApp = array();
+ $_hookFiles = array();
+ $extraKey = '';
+
+ /* Get data if we are editing */
+ if( $type == 'edit' )
+ {
+ $id = intval($this->request['hook_id']);
+
+ if( !$id )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noedit'], 1118 );
+ }
+
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
+
+ if( !$hookData['hook_id'] )
+ {
+ $this->registry->output->showError( $this->lang->words['h_noedit'], 1119 );
+ }
+
+ $extraKey = ' AND hook_id != ' . $hookData['hook_id'];
+ }
+
+ /* Error Checking */
+ if( ! $this->request['hook_name'] )
+ {
+ $errors[] = $this->lang->words['hook_form_no_title'];
+ }
+
+ if( empty( $this->request['hook_key'] ) )
+ {
+ $errors[] = $this->lang->words['hook_form_no_key'];
+ }
+ else
+ {
+ $keyCheck = $this->DB->buildAndFetch( array( 'select' => 'count(*) as found', 'from' => 'core_hooks', 'where' => "hook_key='" . $this->DB->addSlashes( $this->request['hook_key'] ) . "'" . $extraKey ) );
+
+ if ( $keyCheck['found'] > 0 )
+ {
+ $errors[] = $this->lang->words['hook_form_dupe_key'];
+ }
+ }
+
+ /* Got any errors? */
+ if ( is_array( $errors ) && count( $errors ) )
+ {
+ $this->registry->output->global_error = implode( ' ', $errors );
+ $this->_hookForm();
+ return;
+ }
+
+ /* Not IN_DEV? */
+ if ( ! IN_DEV )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . intval($this->request['hook_id']) ) );
+ $this->DB->execute();
+
+ while( $_r = $this->DB->fetch() )
+ {
+ $_hookFiles[ $_r['hook_classname'] ] = $_r['hook_file_stored'];
+ }
+ }
+
+ /* Check for requirements */
+ if ( is_array( $this->request['requireApp'] ) AND count( $this->request['requireApp'] ) )
+ {
+ foreach( $this->request['requireApp'] as $_index => $app_key )
+ {
+ if ( $app_key )
+ {
+ $minVersion = intval($this->request['minVersion'][ $_index ]);
+ $maxVersion = intval($this->request['maxVersion'][ $_index ]);
+
+ $requireApp[ $app_key ] = array( 'app_name' => ipsRegistry::$applications[ $app_key ]['app_title'],
+ 'min_version' => $minVersion,
+ 'max_version' => $maxVersion
+ );
+ }
+ }
+ }
+
+ /* Check for files */
+ if ( is_array( $this->request['file'] ) AND count( $this->request['file'] ) )
+ {
+ foreach( $this->request['file'] as $index => $file )
+ {
+ if ( $file )
+ {
+ $newFiles[ $index ] = array('hook_file_real' => $file,
+ 'hook_type' => $this->request['hook_type'][ $index ],
+ 'hook_classname' => $this->request['hook_classname'][ $index ],
+ 'hook_data' => serialize( array('dataLocation' => trim( $this->request['dataLocation'][ $index ] ),
+ 'libApplication' => trim( $this->request['libApplication'][ $index ] ),
+ 'classToOverload' => trim($this->request['classToOverload'][ $index ]),
+ 'skinGroup' => $this->request['skinGroup'][ $index ],
+ 'skinFunction' => $this->request['skinFunction'][ $index ],
+ 'type' => $this->request['type'][ $index ],
+ 'id' => $this->request['id'][ $index ],
+ 'position' => $this->request['position'][ $index ],
+ )
+ )
+ );
+
+ /**
+ * @link http://community.invisionpower.com/tracker/issue-22084-hook-edit-does-not-preserve-correct-name/
+ * We don't want to reset the stored name if you are not in developer mode
+ */
+ if ( IN_DEV )
+ {
+ $newFiles[ $index ]['hook_file_stored'] = $file; // During import this is a random name, but for devs it's actual file
+ }
+ else
+ {
+ $newFiles[ $index ]['hook_file_stored'] = $_hookFiles[ $this->request['hook_classname'][ $index ] ] ? $_hookFiles[ $this->request['hook_classname'][ $index ] ] : $file;
+ }
+ }
+ }
+ }
+
+ /* Get position */
+ if ( $type == 'add' )
+ {
+ $position = $this->DB->buildAndFetch( array( 'select' => 'MAX(hook_position) as newPos', 'from' => 'core_hooks' ) );
+
+ $position['newPos'] = intval($position['newPos']) + 1;
+ }
+ else
+ {
+ $position['newPos'] = $hookData['hook_position'];
+ }
+
+ $mainHookRecord = array('hook_name' => trim($this->request['hook_name']),
+ 'hook_key' => substr( trim($this->request['hook_key']), 0, 32 ),
+ 'hook_global_caches' => ( is_array($this->request['hook_global_caches']) && count($this->request['hook_global_caches']) ) ? implode(',', $this->request['hook_global_caches']) : '',
+ 'hook_desc' => trim($this->request['hook_desc']),
+ 'hook_version_human' => trim($this->request['hook_version_human']),
+ 'hook_version_long' => trim($this->request['hook_version_long']),
+ 'hook_author' => trim($this->request['hook_author']),
+ 'hook_email' => trim($this->request['hook_email']),
+ 'hook_website' => trim($this->request['hook_website']),
+ 'hook_update_check' => trim($this->request['hook_update_check']),
+ 'hook_enabled' => $type == 'add' ? 1 : $hookData['hook_enabled'],
+ 'hook_installed' => $type == 'add' ? IPS_UNIX_TIME_NOW : $hookData['hook_installed'],
+ 'hook_updated' => $type == 'add' ? 0 : IPS_UNIX_TIME_NOW,
+ 'hook_position' => $position['newPos'],
+ 'hook_requirements' => serialize( array('required_applications' => $requireApp,
+ 'hook_php_version_min' => trim($this->request['hook_php_version_min']),
+ 'hook_php_version_max' => trim($this->request['hook_php_version_max'])
+ )
+ )
+ );
+
+ if( $type == 'edit' )
+ {
+ $this->DB->update( 'core_hooks', $mainHookRecord, 'hook_id=' . $hookData['hook_id'] );
+
+ $this->DB->delete( 'core_hooks_files', 'hook_hook_id=' . $hookData['hook_id'] );
+ }
+ else
+ {
+ $this->DB->insert( 'core_hooks', $mainHookRecord );
+
+ $hookData['hook_id'] = $this->DB->getInsertId();
+ }
+
+ foreach( $newFiles as $index => $toInsert )
+ {
+ $toInsert['hook_hook_id'] = $hookData['hook_id'];
+
+ $this->DB->insert( 'core_hooks_files', $toInsert );
+ }
+
+ /* Rebuild cache */
+ $this->rebuildHooksCache();
+
+ /* Rebuild global caches */
+ try
+ {
+ IPSLib::cacheGlobalCaches();
+ }
+ catch( Exception $e ){}
+
+ /* Flag skins for recache */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+ $skinCaching->flagSetForRecache();
+
+ /* Redirect */
+ $this->registry->output->setMessage( $this->lang->words['h_saved'] );
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=hooks_overview' );
+ }
+
+ /**
+ * View details about a hook
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _viewDetails()
+ {
+ $id = intval($this->request['id']);
+
+ if( !$id )
+ {
+ $this->registry->output->showError( $this->lang->words['h_nodetails'], 11110 );
+ }
+
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
+
+ if( !$hookData['hook_id'] )
+ {
+ $this->registry->output->showError( $this->lang->words['h_nodetails'], 11111 );
+ }
+
+ /* Extra data */
+ $hookData['_updated'] = $this->registry->getClass('class_localization')->formatTime( $hookData['hook_updated'] );
+ $hookData['hook_extra_data'] = unserialize( $hookData['hook_extra_data'] );
+
+ /* Meets requirements? */
+ $hookData['_require_errors'] = $this->checkHookRequirements( $hookData );
+
+ /* Got updates? */
+ if ( $hookData['hook_update_check'] )
+ {
+ $hookData['hook_update_available'] = $this->_updateAvailable( $hookData['hook_update_check'], $hookData['hook_version_long'] );
+ }
+ else
+ {
+ $hookData['hook_update_available'] = array( 0 );
+ }
+
+ /* Get files */
+ $files = array();
+ $index = 1;
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id=' . $id ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $r['hook_data'] = unserialize( $r['hook_data'] );
+ $files[ $index ] = $r;
+ $index++;
+ }
+
+ /* Output */
+ $this->registry->output->extra_nav[] = array( $this->settings['base_url'] . $this->form_code . 'do=hooks_overview', $this->lang->words['menu__manage_hooks'] );
+ $this->registry->output->html .= $this->html->hookDetails( $hookData, $files );
+ }
+
+ /**
+ * Check if the hook meets all the requirements
+ *
+ * @param mixed $hook Can be an hook ID or an array of the hook data
+ * @return @e array Errors found
+ */
+ public function checkHookRequirements( $hook )
+ {
+ /* Init vars */
+ $hookData = array();
+ $reqsData = array();
+ $errors = array();
+
+ /* We already have some data? */
+ if ( is_array($hook) && count($hook) )
+ {
+ $hookData = $hook;
+ }
+ elseif ( is_int($hook) )
+ {
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $hook ) );
+ }
+
+ /* Requirements are still serialized? */
+ if ( IPSLib::isSerialized($hookData['hook_requirements']) )
+ {
+ $hookData['hook_requirements'] = unserialize($hookData['hook_requirements']);
+ }
+
+ /* Make our var shorter... */
+ $reqsData = &$hookData['hook_requirements'];
+
+ /* Old data? - @todo: remove this check around 3.3(4?) */
+ if ( ! isset($reqsData['required_applications']['core']) && isset($reqsData['hook_ipb_version_min']) && ( $reqsData['hook_ipb_version_min'] > 0 || $reqsData['hook_ipb_version_max'] > 0 ) )
+ {
+ $reqsData['hook_ipb_version_min'] = ( $reqsData['hook_ipb_version_min'] < 30000 ) ? 30000 : $reqsData['hook_ipb_version_min'];
+
+ $reqsData['required_applications']['core'] = array( 'min_version' => intval($reqsData['hook_ipb_version_min']), 'max_version' => intval($reqsData['hook_ipb_version_max']) );
+ }
+
+ //-----------------------------------------
+ // Let's start checking requirements
+ //-----------------------------------------
+
+ /* PHP */
+ if( $reqsData['hook_php_version_min'] OR $reqsData['hook_php_version_max'] )
+ {
+ if( $reqsData['hook_php_version_min'] AND version_compare( PHP_VERSION, $reqsData['hook_php_version_min'], '<' ) == true )
+ {
+ $errors['php_min'] = sprintf( $this->lang->words['h_phpold'],$reqsData['hook_php_version_min'] );
+ }
+
+ if( $reqsData['hook_php_version_max'] AND version_compare( PHP_VERSION, $reqsData['hook_php_version_max'], '>' ) == true )
+ {
+ $errors['php_max'] = sprintf( $this->lang->words['h_phpnew'], $reqsData['hook_php_version_max'] );
+ }
+ }
+
+ /* Additional applications */
+ if ( is_array($reqsData['required_applications']) && count($reqsData['required_applications']) )
+ {
+ /* Get the setup class */
+ require_once( IPS_ROOT_PATH . 'setup/sources/base/setup.php' );/*noLibHook*/
+
+ /* Loop through all apps */
+ foreach( $reqsData['required_applications'] as $appKey => $appData )
+ {
+ /* Versions file doesn't exist? */
+ if ( !is_file( IPSLib::getAppDir( $appKey ) . '/xml/versions.xml' ) )
+ {
+ $errors[ $appKey.'_app' ] = sprintf( $this->lang->words['hook_require_appnotfound'], $appData['app_name'] );
+ }
+ /* App not installed/enabled? */
+ elseif ( !IPSLib::appIsInstalled( $appKey ) )
+ {
+ $errors[ $appKey.'_app' ] = sprintf( $this->lang->words['hook_require_appdisabled'], ipsRegistry::$applications[ $appKey ]['app_title'] );
+ }
+ elseif ( $appData['min_version'] OR $appData['max_version'] )
+ {
+ /* Fetch and check versions */
+ if ( !isset($this->cachedVersions[ $appKey ]) )
+ {
+ $this->cachedVersions[ $appKey ] = IPSSetUp::fetchXmlAppVersions( $appKey );
+ }
+
+ $versions = $this->cachedVersions[ $appKey ];
+
+ if ( is_array($versions) && count($versions) )
+ {
+ if ( !isset($this->cachedUpgradeInfo[ $appKey ]) )
+ {
+ $_key = in_array( $appKey, array( 'forums', 'members' ) ) ? 'core' : $appKey;
+ $this->cachedUpgradeInfo[ $_key ] = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'upgrade_history', 'where' => "upgrade_app='{$_key}'", 'order' => 'upgrade_version_id DESC', 'limit' => array( 1 ) ) );
+
+ /* Extra caching for the three core apps */
+ if( in_array( $appKey, array( 'core', 'forums', 'members' ) ) )
+ {
+ $this->cachedUpgradeInfo['core'] = $this->cachedUpgradeInfo[ $_key ];
+ $this->cachedUpgradeInfo['forums'] = $this->cachedUpgradeInfo[ $_key ];
+ $this->cachedUpgradeInfo['members'] = $this->cachedUpgradeInfo[ $_key ];
+ }
+ }
+
+ /* Do we meet tha requirements? */
+ if ( $appData['min_version'] AND $this->cachedUpgradeInfo[ $appKey ]['upgrade_version_id'] < $appData['min_version'] )
+ {
+ $errors[ $appKey.'_min' ] = sprintf( $this->lang->words['hook_require_tooold'], isset($versions[ $appData['min_version'] ]) ? $versions[ $appData['min_version'] ] : $appData['min_version'] );
+ }
+
+ if ( $appData['max_version'] AND $this->cachedUpgradeInfo[ $appKey ]['upgrade_version_id'] > $appData['max_version'] )
+ {
+ $errors[ $appKey.'_max' ] = sprintf( $this->lang->words['hook_require_toonew'], isset($versions[ $appData['max_version'] ]) ? $versions[ $appData['max_version'] ] : $appData['max_version'] );
+ }
+ }
+ }
+ }
+ }
+
+ return $errors;
+ }
+
+ /**
+ * Check if you meet hook requirements
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _checkRequirements()
+ {
+ $id = intval($this->request['id']);
+
+ if( !$id )
+ {
+ $this->registry->output->showError( $this->lang->words['h_norequirements'], 11112 );
+ }
+
+ $hookData = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where' => 'hook_id=' . $id ) );
+
+ if( !$hookData['hook_id'] )
+ {
+ $this->registry->output->showError( $this->lang->words['h_norequirements'], 11113 );
+ }
+
+ /* Get requirements */
+ $hookData['hook_requirements'] = unserialize($hookData['hook_requirements']);
+
+ /* Check requirements */
+ $errors = $this->checkHookRequirements( $hookData );
+
+ /* Output */
+ $this->registry->output->extra_nav[] = array( $this->settings['base_url'] . $this->form_code . 'do=hooks_overview', $this->lang->words['menu__manage_hooks'] );
+ $this->registry->output->html .= $this->html->hookRequirements( $hookData, $errors, $this->cachedVersions );
+ }
+
+ /**
+ * Rebuild hooks cache
+ *
+ * @return @e void
+ */
+ public function rebuildHooksCache()
+ {
+ /* INI */
+ $cache = array( 'commandHooks' => array(), 'skinHooks' => array(), 'templateHooks' => array(), 'dataHooks' => array(), 'libraryHooks' => array() );
+
+ /* First fix positions */
+ $this->_fixPositions();
+
+ /* Get current hooks */
+ $this->DB->build( array( 'select' => 'f.*',
+ 'from' => array( 'core_hooks_files' => 'f' ),
+ 'where' => 'c.hook_enabled=1',
+ 'order' => 'c.hook_position ASC',
+ 'add_join' => array( array( 'select' => 'c.hook_id',
+ 'from' => array( 'core_hooks' => 'c' ),
+ 'where' => 'c.hook_id=f.hook_hook_id',
+ 'type' => 'left' ) )
+ ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ /* Got no main hook id? Weird but skip.. */
+ if ( empty($r['hook_id']) )
+ {
+ continue;
+ }
+
+ /* INIT */
+ $_cache = array();
+ $data = unserialize( $r['hook_data'] );
+
+ /* General Stuff */
+ $_cache = array( 'filename' => $r['hook_file_stored'],
+ 'className' => $r['hook_classname']
+ );
+
+ /* Hook type specific stuff */
+ if( $r['hook_type'] == 'templateHooks' )
+ {
+ $_cache['type'] = $data['type'];
+ $_cache['skinFunction'] = $data['skinFunction'];
+ $_cache['id'] = $data['id'];
+ $_cache['position'] = $data['position'];
+ }
+ else if( /*$r['hook_type'] == 'dataHooks' OR*/ $r['hook_type'] == 'libraryHooks' )
+ {
+ $_cache['classToOverload'] = $data['classToOverload'];
+ }
+
+ /* Add to array */
+ if( $r['hook_type'] == 'templateHooks' )
+ {
+ $cache[ $r['hook_type'] ][ $data['skinGroup'] ][] = $_cache;
+ }
+ else if( $r['hook_type'] == 'dataHooks' )
+ {
+ $cache[ $r['hook_type'] ][ $data['dataLocation'] ][] = $_cache;
+ }
+ else if( $r['hook_type'] == 'libraryHooks' )
+ {
+ $cache[ $r['hook_type'] ][ $data['libApplication'] ][ $data['classToOverload'] ][] = $_cache;
+ }
+ else
+ {
+ $cache[ $r['hook_type'] ][ $data['classToOverload'] ][] = $_cache;
+ }
+ }
+
+ /* Update the cache */
+ $this->cache->setCache( 'hooks', $cache, array( 'array' => 1 ) );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/applications/nexus.php b/upload/admin/applications/core/modules_admin/applications/nexus.php
index c9c60c4a..504353b2 100644
--- a/upload/admin/applications/core/modules_admin/applications/nexus.php
+++ b/upload/admin/applications/core/modules_admin/applications/nexus.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Nexus Application
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/applications/setup.php b/upload/admin/applications/core/modules_admin/applications/setup.php
index f6a4fad0..639b2caf 100644
--- a/upload/admin/applications/core/modules_admin/applications/setup.php
+++ b/upload/admin/applications/core/modules_admin/applications/setup.php
@@ -1,1164 +1,1173 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Application Installation
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @version $Rev: 10914 $
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-
-class admin_core_applications_setup extends ipsCommand
-{
- /**
- * Skin object
- *
- * @var object Skin templates
- */
- protected $html;
-
- /**
- * Shortcut for url
- *
- * @var string URL shortcut
- */
- protected $form_code;
-
- /**
- * Shortcut for url (javascript)
- *
- * @var string JS URL shortcut
- */
- protected $form_code_js;
-
- /**
- * Current app path
- *
- * @var object
- */
- protected $app_full_path;
-
- /**
- * Product information
- *
- * @var array
- */
- protected $product_information;
-
- /**
- * Main class entry point
- *
- * @param object ipsRegistry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'app_install' );
-
- /* Get Template and Language */
- $this->html = $this->registry->output->loadTemplate( 'cp_skin_setup' );
-
- $this->lang->loadLanguageFile( array( 'admin_setup', 'admin_system', 'admin_tools', 'admin_templates' ), 'core' );
-
- /* URL Bits */
- $this->form_code = $this->html->form_code = 'module=applications§ion=setup';
- $this->form_code_js = $this->html->form_code_js = 'module=applications§ion=setup';
-
- /* Get the setup class */
- require( IPS_ROOT_PATH . "setup/sources/base/setup.php" );/*noLibHook*/
-
- /* Set the path */
- $this->app_full_path = IPSLib::getAppDir( $this->request['app_directory'] ) . '/';
-
- /* Set up product info from XML file */
- $this->product_information = IPSSetUp::fetchXmlAppInformation( $this->request['app_directory'], $this->settings['gb_char_set'] );
-
- if( ! $this->app_full_path OR ! $this->product_information['title'] )
- {
- $this->registry->output->global_message = $this->lang->words['error__cannot_init'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] );
- return;
- }
-
- /* Sequence of Events:
- # SQL
- # App Module
- # Check for more modules
- # Templates
- # Languages
- # Tasks
- # Settings
- # Template Cache
- # Caches / Done
- */
- switch( $this->request['do'] )
- {
- default:
- case 'start':
- $this->start();
- break;
- case 'sql':
- $this->sqlBasics();
- break;
- case 'sql_steps':
- $this->sqlSteps();
- break;
- case 'next_check':
- $this->nextCheck();
- break;
-
- case 'templates':
- $this->templates();
- break;
- case 'languages':
- $this->languages();
- break;
- case 'tasks':
- $this->tasks();
- break;
- case 'bbcode':
- $this->bbcode();
- break;
- case 'help':
- $this->help();
- break;
- case 'settings':
- $this->settings();
- break;
- case 'hooks':
- $this->hooks();
- break;
- case 'tplcache':
- $this->recacheTemplates();
- break;
- case 'finish':
- $this->finish();
- break;
- }
-
- $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
- $this->registry->getClass('output')->sendOutput();
- }
-
- /**
- * Rebuild PHP Templates Cache
- *
- * @return @e void
- */
- public function recacheTemplates()
- {
- /* Flag skins for recache */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- $skinCaching = new skinCaching( $this->registry );
-
- /* Flag all for recache */
- $skinCaching->flagSetForRecache();
-
- $data = $this->getVars();
-
- $this->showRedirectScreen( $data['app_directory'], array( $this->lang->words['install_skins_flag_recache'] ), '', $this->getNextURL( 'finish', $data ) );
- }
-
- /**
- * Finalizes installation and rebuilds caches
- *
- * @return @e void
- */
- public function finish()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
-
- /* Init Data */
- $data = IPSSetUp::fetchXmlAppInformation( $vars['app_directory'], $this->settings['gb_char_set'] );
- $_numbers = IPSSetUp::fetchAppVersionNumbers( $vars['app_directory'] );
-
- /* Grab Data */
- $data['app_directory'] = $vars['app_directory'];
- $data['current_version'] = ( $_numbers['current'][0] ) ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
- $data['latest_version'] = $_numbers['latest'][1];
- $data['next_version'] = $_numbers['next'][0];
-
- /* Rebuild applications and modules cache */
- $this->cache->rebuildCache( 'app_cache', 'global' );
- $this->cache->rebuildCache( 'module_cache', 'global' );
- $this->cache->rebuildCache( 'app_menu_cache', 'global' );
- $this->cache->rebuildCache( 'group_cache', 'global' );
- $this->cache->rebuildCache( 'notifications', 'global' );
- $this->cache->rebuildCache( 'report_plugins', 'global' );
-
- /* Rebuild application specific caches */
- $_file = $this->app_full_path . 'extensions/coreVariables.php';
-
- if( is_file( $_file ) )
- {
- $CACHE = array();
- require( $_file );/*noLibHook*/
-
- if( is_array( $CACHE ) AND count( $CACHE ) )
- {
- foreach( $CACHE as $key => $cdata )
- {
- $this->cache->rebuildCache( $key, $vars['app_directory'] );
- }
- }
- }
-
- /* Rebuild GLOBAL CACHES! */
- try
- {
- IPSLib::cacheGlobalCaches();
- }
- catch( Exception $e )
- {
- // Show an error?
- }
-
- /* Rebuild FURLs */
- if( is_file( $this->app_full_path . 'extensions/furlTemplates.php' ) )
- {
- try
- {
- IPSLib::cacheFurlTemplates();
- }
- catch( Exception $e )
- {
- // Show an error?
- }
- }
-
- /* Show completed screen... */
- $this->registry->output->html .= $this->html->setup_completed_screen( $data, $vars['type'] );
- }
-
- /**
- * Next Check
- *
- * @return @e void
- */
- public function nextCheck()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
-
- /* Init Data */
- $data = IPSSetUp::fetchXmlAppInformation( $vars['app_directory'], $this->settings['gb_char_set'] );
- $_numbers = IPSSetUp::fetchAppVersionNumbers( $vars['app_directory'] );
- $modules = IPSSetUp::fetchXmlAppModules( $vars['app_directory'], $this->settings['gb_char_set'] );
-
- /* Grab Data */
- $data['app_directory'] = $vars['app_directory'];
- $data['current_version'] = ( $_numbers['current'][0] ) ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
- $data['latest_version'] = $_numbers['latest'][1];
- $data['next_version'] = $_numbers['next'][0];
-
- /* Update the app DB */
- if( $vars['type'] == 'install' )
- {
- /* Get current max position */
- $pos = $this->DB->buildAndFetch( array( 'select' => 'MAX(app_position) as pos', 'from' => 'core_applications' ) );
- $new_pos = intval( $pos['pos'] ) + 1;
-
- /* Insert details into the DB */
- $this->DB->insert( 'core_applications', array( 'app_title' => $this->product_information['name'],
- 'app_public_title' => $this->product_information['public_name'],
- 'app_author' => $this->product_information['author'],
- 'app_description' => $this->product_information['description'],
- 'app_hide_tab' => intval($this->product_information['hide_tab']),
- 'app_version' => $_numbers['latest'][1],
- 'app_long_version' => $_numbers['latest'][0],
- 'app_directory' => $vars['app_directory'],
- 'app_location' => $vars['app_location'],
- 'app_added' => time(),
- 'app_position' => $new_pos,
- 'app_protected' => 0,
- 'app_enabled' => $this->product_information['disabledatinstall'] ? 0 : 1,
- 'app_website' => trim($this->product_information['website']),
- 'app_update_check' => trim($this->product_information['update_check']),
- 'app_global_caches' => trim($this->product_information['global_caches']),
- )
- );
-
- $this->DB->insert( 'upgrade_history', array(
- 'upgrade_version_id' => $_numbers['latest'][0],
- 'upgrade_version_human' => $_numbers['latest'][1],
- 'upgrade_date' => time(),
- 'upgrade_notes' => '',
- 'upgrade_mid' => $this->memberData['member_id'],
- 'upgrade_app' => $vars['app_directory'],
- ) );
-
- /* Insert the modules */
- foreach( $modules as $key => $module )
- {
- $this->DB->insert( 'core_sys_module', $module );
- }
- }
- else
- {
- $this->DB->update( 'core_applications', array( 'app_title' => $this->product_information['name'],
- 'app_public_title' => $this->product_information['public_name'],
- 'app_author' => $this->product_information['author'],
- 'app_description' => $this->product_information['description'],
- 'app_hide_tab' => intval($this->product_information['hide_tab']),
- 'app_version' => $_numbers['current'][1],
- 'app_long_version' => $_numbers['current'][0],
- 'app_website' => trim($this->product_information['website']),
- 'app_update_check' => trim($this->product_information['update_check']),
- 'app_global_caches' => trim($this->product_information['global_caches']),
- ), "app_directory='" . $vars['app_directory'] . "'" );
-
- /* Update the modules */
- foreach( $modules as $key => $module )
- {
- $this->DB->update( 'core_sys_module', $module, "sys_module_application='{$module['sys_module_application']}' AND sys_module_key='{$module['sys_module_key']}'" );
- }
- }
-
- /* Finish? */
- if( $vars['type'] == 'install' OR $vars['version'] == $_numbers['latest'][0] )
- {
- /* Go back and start over with the new version */
- $output[] = $this->lang->words['redir__nomore_modules'];
-
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'templates', $vars ) );
- }
- else
- {
- /* Go back and start over with the new version */
- $output[] = sprintf( $this->lang->words['redir__upgraded_to'], $_numbers['current'][1] );
-
- /* Work out the next step */
- $vars['version'] = $_numbers['next'][0];
-
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'sql', $vars ) );
- }
- }
-
- /**
- * Import Hooks
- *
- * @return @e void
- */
- public function hooks()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
- $knownSettings = array();
-
- $this->registry->class_localization->loadLanguageFile( array( 'admin_tools' ) );
-
- if( is_file( $this->app_full_path . 'xml/hooks.xml' ) )
- {
- /* Get the hooks class */
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/applications/hooks.php', 'admin_core_applications_hooks' );
- $hooks = new $classToLoad();
- $hooks->makeRegistryShortcuts( $this->registry );
-
- $return = $hooks->installAppHooks( $vars['app_directory'] );
- $this->cache->rebuildCache( 'hooks', 'global' );
-
- $output[] = sprintf( $this->lang->words['redir__hooks'], $return['inserted'], $return['updated'] );
- }
- else
- {
- $this->registry->output->global_message = $this->lang->words['hooks_nofile'];
-
- $output[] = $this->registry->output->global_message;
- }
-
- /* Clear main messaage */
- $this->registry->output->global_message = '';
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'tplcache', $vars ) );
- }
-
- /**
- * Import Settings
- *
- * @return @e void
- */
- public function settings()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
- $knownSettings = array();
-
- $this->registry->class_localization->loadLanguageFile( array( 'admin_tools' ), 'core' );
-
- if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_settings.xml' ) )
- {
- /* Get the settings class */
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/settings/settings.php', 'admin_core_settings_settings' );
- $settings = new $classToLoad();
- $settings->makeRegistryShortcuts( $this->registry );
-
- $this->request['app_dir'] = $vars['app_directory'];
-
- //-----------------------------------------
- // Known settings
- //-----------------------------------------
-
- if ( substr( $this->settings['_original_base_url'], -1 ) == '/' )
- {
- IPSSetUp::setSavedData('install_url', substr( $this->settings['_original_base_url'], 0, -1 ) );
- }
-
- if ( substr( $this->settings['base_dir'], -1 ) == '/' )
- {
- IPSSetUp::setSavedData('install_dir', substr( $this->settings['base_dir'], 0, -1 ) );
- }
-
- /* Fetch known settings */
- if ( is_file( IPSLib::getAppDir( $vars['app_directory'] ) . '/setup/versions/install/knownSettings.php' ) )
- {
- require( IPSLib::getAppDir( $vars['app_directory'] ) . '/setup/versions/install/knownSettings.php' );/*noLibHook*/
- }
-
- $settings->importAllSettings( 1, 1, $knownSettings );
- $settings->settingsRebuildCache();
- }
- else
- {
- $this->registry->output->global_message = $this->lang->words['settings_nofile'];
- }
-
- $output[] = $this->registry->output->global_message;
-
- /* Clear main messaage */
- $this->registry->output->global_message = '';
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'hooks', $vars ) );
- }
-
- /**
- * Import tasks
- *
- * @return @e void
- */
- public function tasks()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
-
- if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_tasks.xml' ) )
- {
- /* Get the language class */
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/system/taskmanager.php', 'admin_core_system_taskmanager' );
- $task_obj = new $classToLoad();
- $task_obj->makeRegistryShortcuts( $this->registry );
-
- $task_obj->tasksImportFromXML( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_tasks.xml', true );
- }
-
- $output[] = $this->registry->output->global_message ? $this->registry->output->global_message : $this->lang->words['no_tasks_for_import'];
-
- /* Clear main msg */
- $this->registry->output->global_message = '';
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'bbcode', $vars ) );
- }
-
- /**
- * Import bbcode
- *
- * @return @e void
- */
- public function bbcode()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
-
- if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_bbcode.xml' ) )
- {
- /* Get the language class */
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/posts/bbcode.php', 'admin_core_posts_bbcode' );
- $bbcode = new $classToLoad();
- $bbcode->makeRegistryShortcuts( $this->registry );
-
- $bbcode->bbcodeImportDo( file_get_contents( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_bbcode.xml' ) );
-
- $output[] = $this->lang->words['bbcode_and_media'];
- }
-
- if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_mediatag.xml' ) )
- {
- /* Get the language class */
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/posts/media.php', 'admin_core_posts_media' );
- $bbcode = new $classToLoad();
- $bbcode->makeRegistryShortcuts( $this->registry );
-
- $bbcode->doMediaImport( file_get_contents( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_mediatag.xml' ) );
-
- if( !count($output) )
- {
- $output[] = $this->lang->words['bbcode_and_media'];
- }
- }
-
- if( !count($output) )
- {
- $output[] = $this->lang->words['no_bbcode_media'];
- }
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'help', $vars ) );
- }
-
- /**
- * Import help
- *
- * @return @e void
- */
- public function help()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
-
- if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_help.xml' ) )
- {
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/tools/help.php', 'admin_core_tools_help' );
- $help = new $classToLoad();
- $help->makeRegistryShortcuts( $this->registry );
-
- $done = $help->helpFilesXMLImport_app( $vars['app_directory'] );
-
- $output[] = sprintf( $this->lang->words['imported_x_help'], ($done['added'] + $done['updated']) );
- }
- else
- {
- $output[] = $this->lang->words['imported_no_help'];
- }
-
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'settings', $vars ) );
- }
-
- /**
- * Language Import
- *
- * @return @e void
- */
- public function languages()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
-
- /* Load the language file */
- $this->registry->class_localization->loadLanguageFile( array( 'admin_system' ) );
-
- /* Get the language stuff */
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages' );
- $lang = new $classToLoad();
- $lang->makeRegistryShortcuts( $this->registry );
-
- /* Loop through the xml directory and look for lang packs */
- $_PATH = $this->app_full_path . '/xml/';
-
- try
- {
- foreach( new DirectoryIterator( $_PATH ) as $f )
- {
- if( preg_match( "#(.+?)_language_pack.xml#", $f->getFileName() ) )
- {
- $this->request['file_location'] = $_PATH . $f->getFileName();
- $lang->imprtFromXML( true, true, true, $vars['app_directory'] );
- }
- }
- } catch ( Exception $e ) {}
-
- $output[] = $this->registry->output->global_message ? $this->registry->output->global_message : $this->lang->words['redir__nolanguages'];
-
- /* Clear main msg */
- $this->registry->output->global_message = '';
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'tasks', $vars ) );
- }
-
- /**
- * Install templates
- *
- * @return @e void
- */
- public function templates()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
-
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinImportExport.php' );/*noLibHook*/
- $skinFunctions = new skinImportExport( $this->registry );
- $skinCaching = new skinCaching( $this->registry );
-
- /* Grab skin data */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'skin_collections' ) );
-
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- /* Bit of jiggery pokery... */
- if ( $row['set_key'] == 'default' )
- {
- $row['set_key'] = 'root';
- $row['set_id'] = 0;
- }
-
- $skinSets[ $row['set_key'] ] = $row;
- }
-
- foreach( $skinSets as $skinKey => $skinData )
- {
- /* Skin files first */
- if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_' . $skinKey . '_templates.xml' ) )
- {
- $return = $skinFunctions->importTemplateAppXML( $vars['app_directory'], $skinKey, $skinData['set_id'], TRUE );
-
- $output[] = sprintf( $this->lang->words['redir__templates'], $return['insertCount'], $return['updateCount'], $skinData['set_name'] );
- }
-
- /* Then CSS files */
- if ( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_' . $skinKey . '_css.xml' ) )
- {
- //-----------------------------------------
- // Install
- //-----------------------------------------
-
- $return = $skinFunctions->importCSSAppXML( $vars['app_directory'], $skinKey, $skinData['set_id'] );
-
- $output[] = sprintf( $this->lang->words['redir__cssfiles'], $return['insertCount'], $return['updateCount'], $skinData['set_name'] );
- }
-
- /* And we can support replacements for good measure */
- if ( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_replacements.xml' ) )
- {
- //-----------------------------------------
- // Install
- //-----------------------------------------
-
- $return = $skinFunctions->importReplacementsXMLArchive( file_get_contents( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_replacements.xml' ), $skinKey );
-
- $output[] = $this->lang->words['redir__replacements'];
- }
- }
-
- /* Recache */
- //$skinCaching->rebuildPHPTemplates( 0 );
- //$skinCaching->rebuildCSS( 0 );
- //$skinCaching->rebuildReplacementsCache( 0 );
-
- /* No templates? Give some sort of feedback */
- if ( !count( $output ) )
- {
- $output[] = $this->lang->words['redir__no_templates'];
- }
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'languages', $vars ) );
- }
-
- /**
- * Runs any additional sql files
- *
- * @return @e void
- */
- public function sqlSteps()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
- $id = intval( $this->request['id'] );
- $id = ( $id < 1 ) ? 1 : $id;
- $sql_files = array();
-
- /* Any "extra" configs required for this driver? */
- if( is_file( IPS_ROOT_PATH . 'setup/sql/' . strtolower( $this->settings['sql_driver'] ) . '_install.php' ) )
- {
- require_once( IPS_ROOT_PATH . 'setup/sql/' . strtolower( $this->settings['sql_driver'] ) . '_install.php' );/*noLibHook*/
-
- $extra_install = new install_extra( $this->registry );
- }
-
-
- /* Run any sql files we found */
- if( is_file( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ips_DBRegistry::getDriverType() ) . '_sql_' . $id .'.php' ) )
- {
- /* INIT */
- $new_id = $id + 1;
- $count = 0;
- $SQL = array();
-
- /* Get the sql file */
- require_once( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ips_DBRegistry::getDriverType() ) . '_sql_' . $id .'.php' );/*noLibHook*/
-
- $this->DB->return_die = 1;
-
- /* Run the queries */
- foreach( $SQL as $query )
- {
- $this->DB->allow_sub_select = 1;
- $this->DB->error = '';
-
- $query = str_replace( "<%time%>", time(), $query );
-
- if( $extra_install AND method_exists( $extra_install, 'process_query_insert' ) )
- {
- $query = $extra_install->process_query_insert( $query );
- }
-
- $this->DB->query( $query );
-
- if ( $this->DB->error )
- {
- $errors[] = $query." ".$this->DB->error;
- }
- else
- {
- $count++;
- }
- }
-
- $output[] = sprintf( $this->lang->words['redir__sql_run'], $count );
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'sql_steps', $vars ) . '&id=' . $new_id );
- }
- else
- {
- $output[] = $this->lang->words['redir__nomore_sql'];
-
- /* Show redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'next_check', $vars ) );
- }
- }
-
- /**
- * Creates Tables, Runs Inserts, and Indexes
- *
- * @return @e void
- */
- public function sqlBasics()
- {
- /* INIT */
- $vars = $this->getVars();
- $output = array();
- $errors = array();
- $skipped = 0;
- $count = 0;
-
- /* Any "extra" configs required for this driver? */
- if( is_file( IPS_ROOT_PATH . 'setup/sql/' . strtolower( $this->settings['sql_driver'] ) . '_install.php' ) )
- {
- require_once( IPS_ROOT_PATH . 'setup/sql/' . strtolower( $this->settings['sql_driver'] ) . '_install.php' );/*noLibHook*/
-
- $extra_install = new install_extra( $this->registry );
- }
-
- //-----------------------------------------
- // Tables
- //-----------------------------------------
-
- $this->DB->return_die = 1;
-
- if ( is_file( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_tables.php' ) )
- {
- $TABLE = array();
- include( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_tables.php' );/*noLibHook*/
-
- if ( is_array( $TABLE ) and count( $TABLE ) )
- {
- foreach( $TABLE as $q )
- {
- //-----------------------------------------
- // Is this a create?
- //-----------------------------------------
-
- preg_match("/CREATE TABLE\s+(\S+)(\s)?\(/", str_ireplace( 'if not exists', '', $q ), $match);
-
- if( $match[1] AND $vars['dupe_tables'] == 'drop' )
- {
- $this->DB->dropTable( str_replace( $this->settings['sql_tbl_prefix'], '', $match[1] ) );
- }
- else if( $match[1] )
- {
- if( $this->DB->getTableSchematic( $match[1] ) )
- {
- $skipped++;
- continue;
- }
- }
-
- //-----------------------------------------
- // Is this an alter?
- //-----------------------------------------
-
- preg_match("/ALTER\s+TABLE\s+(\S+)\s+ADD\s+(\S+)\s+/i", $q, $match);
-
- if( $match[1] AND $match[2] AND $vars['dupe_tables'] == 'drop' )
- {
- $this->DB->dropField( str_replace( $this->settings['sql_tbl_prefix'], '', $match[1] ), $match[2] );
- }
- else if( $match[1] AND $match[2] )
- {
- if( $this->DB->checkForField( $match[2], $match[1] ) )
- {
- $skipped++;
- continue;
- }
- }
-
- if ( $extra_install AND method_exists( $extra_install, 'process_query_create' ) )
- {
- $q = $extra_install->process_query_create( $q );
- }
- $this->DB->error = '';
-
- $this->DB->query( $q );
-
- if ( $this->DB->error )
- {
- $errors[] = $q." ".$this->DB->error;
- }
- else
- {
- $count++;
- }
- }
- }
-
- $output[] = sprintf( $this->lang->words['redir__sql_tables'], $count, $skipped );
- }
-
- //---------------------------------------------
- // Create the fulltext index...
- //---------------------------------------------
-
- if ( $this->DB->checkFulltextSupport() )
- {
- if ( is_file( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_fulltext.php' ) )
- {
- $INDEX = array();
- include( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_fulltext.php' );/*noLibHook*/
-
- $count = 0;
-
- foreach( $INDEX as $q )
- {
- //---------------------------------------------
- // Pass to handler
- //---------------------------------------------
-
- if ( $extra_install AND method_exists( $extra_install, 'process_query_index' ) )
- {
- $q = $extra_install->process_query_index( $q );
- }
-
- //---------------------------------------------
- // Pass query
- //---------------------------------------------
- $this->DB->error = '';
- $this->DB->query( $q );
-
- if ( $this->DB->error )
- {
- $errors[] = $q." ".$this->DB->error;
- }
- else
- {
- $count++;
- }
- }
-
- $output[] = sprintf( $this->lang->words['redir__sql_indexes'], $count );
- }
- }
-
- /* INSERTS */
- if ( is_file( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_inserts.php' ) )
- {
- $INSERT = array();
- $count = 0;
-
- /* Get the SQL File */
- include( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_inserts.php' );/*noLibHook*/
-
- foreach( $INSERT as $q )
- {
- /* Extra Handler */
- if( $extra_install AND method_exists( $extra_install, 'process_query_insert' ) )
- {
- $q = $extra_install->process_query_insert( $q );
- }
-
- $q = str_replace( "<%time%>", time(), $q );
- $this->DB->error = '';
- $this->DB->query( $q );
-
- if ( $this->DB->error )
- {
- $errors[] = $q." ".$this->DB->error;
- }
- else
- {
- $count++;
- }
- }
-
- $output[] = sprintf( $this->lang->words['redir__sql_inserts'], $count );
- }
-
- /* If we did no queries, show something here */
- if ( !count( $output ) )
- {
- $output[] = sprintf( $this->lang->words['redir__sql_run'], 0 );
- }
-
- /* Show Redirect... */
- $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'sql_steps', $vars ) );
- }
-
- /**
- * Begin installation
- *
- * @return @e void
- */
- public function start()
- {
- /* INIT */
- $app_directory = IPSText::alphanumericalClean( $this->request['app_directory'] );
- $type = 'upgrade';
- $data = array();
- $ok = 1;
- $errors = array();
- $localfiles = array( DOC_IPS_ROOT_PATH . 'cache/skin_cache' );
- $info = array();
-
- /* Init Data */
- $data = IPSSetUp::fetchXmlAppInformation( $app_directory, $this->settings['gb_char_set'] );
- $_numbers = IPSSetUp::fetchAppVersionNumbers( $app_directory );
- $_files = IPSSetUp::fetchXmlAppWriteableFiles( $app_directory );
-
- /* Grab Data */
- $data['app_directory'] = $app_directory;
- $data['current_version'] = ( $_numbers['current'][0] ) ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
- $data['latest_version'] = $_numbers['latest'][1];
- $data['next_version'] = $_numbers['next'][0];
-
- /* Install, or upgrade? */
- if ( ! $_numbers['current'][0] )
- {
- $type = 'install';
- }
-
- //-----------------------------------------
- // For upgrade, redirect
- //-----------------------------------------
-
- else
- {
- @header( "Location: {$this->settings['board_url']}/" . CP_DIRECTORY . "/upgrade/" );
- exit;
- }
-
- /* Version Check */
- if( $data['current_version'] > 0 AND $data['current_version'] == $data['latest_version'] )
- {
- $this->registry->output->global_message = $this->lang->words['error__up_to_date'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] );
- return;
- }
-
- /* Check local files */
- foreach( $localfiles as $_path )
- {
- if ( ! file_exists( $_path ) )
- {
- if ( $data['dir'] )
- {
- if ( ! @mkdir( $_path, IPS_FOLDER_PERMISSION, TRUE ) )
- {
- $info['notexist'][] = $_path;
- }
- }
- else
- {
- $info['notexist'][] = $_path;
- }
- }
- else if ( ! is_writeable( $_path ) )
- {
- if ( ! @chmod( $_path, is_dir( $_path ) ? IPS_FOLDER_PERMISSION : IPS_FILE_PERMISSION ) )
- {
- $info['notwrite'][] = $_path;
- }
- }
- }
-
- /* Check files... */
- if( is_array( $_files ) AND count( $_files ) )
- {
- $info = array_merge( $info, $_files );
- }
-
- if ( count( $info['notexist'] ) )
- {
- foreach( $info['notexist'] as $path )
- {
- $errors[] = sprintf( $this->lang->words['error__file_missing'], $path );
- }
- }
-
- if ( count( $info['notwrite'] ) )
- {
- foreach( $info['notwrite'] as $path )
- {
- $errors[] = sprintf( $this->lang->words['error__file_chmod'], $path );
- }
- }
-
- /**
- * Custom errors
- */
- if ( count( $info['other'] ) )
- {
- foreach( $info['other'] as $error )
- {
- $errors[] = $error;
- }
- }
-
- /* Check for xml files */
- $required_xml = array(
- "information",
- //"{$app_directory}_modules",
- //"{$app_directory}_settings",
- //"{$app_directory}_tasks",
- //"{$app_directory}_templates",
- );
-
- foreach( $required_xml as $r )
- {
- if( ! is_file( $this->app_full_path . "xml/{$r}.xml" ) )
- {
- $errors[] = sprintf( $this->lang->words['error__file_needed'], $this->app_full_path . "xml/{$r}.xml" );
- }
- }
-
- /* Show splash */
- $this->registry->output->html .= $this->html->setup_splash_screen( $data, $errors, $type );
- }
-
- /**
- * Get environment vars
- *
- * @return array
- */
- protected function getVars()
- {
- /* INIT */
- $env = array();
-
- /* Get the infos */
- $env['type'] = strtolower( $this->request['type'] );
- $env['version'] = $this->request['version'];
- $env['dupe_tables'] = $this->request['dupe_tables'];
- $env['app_directory'] = $this->request['app_directory'];
-
- $env['app_location'] = 'other';
-
- if( $this->product_information['ipskey'] )
- {
- if ( strstr( $this->app_full_path, 'applications_addon/ips' ) or strstr( $this->app_full_path, 'applications/' ) )
- {
- if ( md5( 'ips_' . basename($this->app_full_path) ) == $this->product_information['ipskey'] )
- {
- $env['app_location'] = 'ips';
- }
- }
- }
-
- $env['path'] = ( $env['type'] == 'install' ) ? $this->app_full_path . 'setup/versions/install'
- : $this->app_full_path . 'setup/versions/' . $env['version'];
-
- return $env;
- }
-
- /**
- * Get next action URL
- *
- * @param string $next_action
- * @param array $env
- * @return string
- */
- protected function getNextURL( $next_action, $env )
- {
- return $this->settings['base_url'] . $this->form_code . '&do=' . $next_action . '&app_directory=' . $env['app_directory'] . '&type=' . $env['type'] . '&version=' . $env['version'];
- }
-
- /**
- * Show the redirect screen
- *
- * @param string $app_directory
- * @param string $output
- * @param string $errors
- * @param string $next_url
- * @return @e void
- */
- protected function showRedirectScreen( $app_directory, $output, $errors, $next_url )
- {
- /* Init Data */
- $data = IPSSetUp::fetchXmlAppInformation( $app_directory, $this->settings['gb_char_set'] );
- $_numbers = IPSSetUp::fetchAppVersionNumbers( $app_directory );
-
- /* Grab Data */
- $data['app_directory'] = $app_directory;
- $data['current_version'] = ( $_numbers['current'][0] ) ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
- $data['latest_version'] = $_numbers['latest'][1];
- $data['next_version'] = $_numbers['next'][0];
-
- /* Setup Redirect */
- $this->registry->output->html .= $this->html->setup_redirectScreen( $output, $errors, $next_url );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Application Installation
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @version $Rev: 10721 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+
+class admin_core_applications_setup extends ipsCommand
+{
+ /**
+ * Skin object
+ *
+ * @var object Skin templates
+ */
+ protected $html;
+
+ /**
+ * Shortcut for url
+ *
+ * @var string URL shortcut
+ */
+ protected $form_code;
+
+ /**
+ * Shortcut for url (javascript)
+ *
+ * @var string JS URL shortcut
+ */
+ protected $form_code_js;
+
+ /**
+ * Current app path
+ *
+ * @var object
+ */
+ protected $app_full_path;
+
+ /**
+ * Product information
+ *
+ * @var array
+ */
+ protected $product_information;
+
+ /**
+ * Main class entry point
+ *
+ * @param object ipsRegistry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'app_install' );
+
+ /* Get Template and Language */
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_setup' );
+
+ $this->lang->loadLanguageFile( array( 'admin_setup', 'admin_system', 'admin_tools', 'admin_templates' ), 'core' );
+
+ /* URL Bits */
+ $this->form_code = $this->html->form_code = 'module=applications§ion=setup';
+ $this->form_code_js = $this->html->form_code_js = 'module=applications§ion=setup';
+
+ /* Get the setup class */
+ require( IPS_ROOT_PATH . "setup/sources/base/setup.php" );/*noLibHook*/
+
+ /* Set the path */
+ $this->app_full_path = IPSLib::getAppDir( $this->request['app_directory'] ) . '/';
+
+ /* Set up product info from XML file */
+ $this->product_information = IPSSetUp::fetchXmlAppInformation( $this->request['app_directory'], $this->settings['gb_char_set'] );
+
+ if( ! $this->app_full_path OR ! $this->product_information['title'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['error__cannot_init'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] );
+ return;
+ }
+
+ /* Sequence of Events:
+ # SQL
+ # App Module
+ # Check for more modules
+ # Templates
+ # Languages
+ # Tasks
+ # Settings
+ # Template Cache
+ # Caches / Done
+ */
+ switch( $this->request['do'] )
+ {
+ default:
+ case 'start':
+ $this->start();
+ break;
+ case 'sql':
+ $this->sqlBasics();
+ break;
+ case 'sql_steps':
+ $this->sqlSteps();
+ break;
+ case 'next_check':
+ $this->nextCheck();
+ break;
+
+ case 'templates':
+ $this->templates();
+ break;
+ case 'languages':
+ $this->languages();
+ break;
+ case 'tasks':
+ $this->tasks();
+ break;
+ case 'bbcode':
+ $this->bbcode();
+ break;
+ case 'help':
+ $this->help();
+ break;
+ case 'settings':
+ $this->settings();
+ break;
+ case 'hooks':
+ $this->hooks();
+ break;
+ case 'tplcache':
+ $this->recacheTemplates();
+ break;
+ case 'finish':
+ $this->finish();
+ break;
+ }
+
+ $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
+ $this->registry->getClass('output')->sendOutput();
+ }
+
+ /**
+ * Rebuild PHP Templates Cache
+ *
+ * @return @e void
+ */
+ public function recacheTemplates()
+ {
+ /* Flag skins for recache */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ $skinCaching = new skinCaching( $this->registry );
+
+ /* Flag all for recache */
+ $skinCaching->flagSetForRecache();
+
+ $data = $this->getVars();
+
+ $this->showRedirectScreen( $data['app_directory'], array( $this->lang->words['install_skins_flag_recache'] ), '', $this->getNextURL( 'finish', $data ) );
+ }
+
+ /**
+ * Finalizes installation and rebuilds caches
+ *
+ * @return @e void
+ */
+ public function finish()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+
+ /* Init Data */
+ $data = IPSSetUp::fetchXmlAppInformation( $vars['app_directory'], $this->settings['gb_char_set'] );
+ $_numbers = IPSSetUp::fetchAppVersionNumbers( $vars['app_directory'] );
+
+ /* Grab Data */
+ $data['app_directory'] = $vars['app_directory'];
+ $data['current_version'] = ( $_numbers['current'][0] ) ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
+ $data['latest_version'] = $_numbers['latest'][1];
+ $data['next_version'] = $_numbers['next'][0];
+
+ /* Rebuild applications and modules cache */
+ $this->cache->rebuildCache( 'app_cache', 'global' );
+ $this->cache->rebuildCache( 'module_cache', 'global' );
+ $this->cache->rebuildCache( 'app_menu_cache', 'global' );
+ $this->cache->rebuildCache( 'group_cache', 'global' );
+ $this->cache->rebuildCache( 'notifications', 'global' );
+ $this->cache->rebuildCache( 'report_plugins', 'global' );
+
+ /* Rebuild application specific caches */
+ $_file = $this->app_full_path . 'extensions/coreVariables.php';
+
+ if( is_file( $_file ) )
+ {
+ $CACHE = array();
+ require( $_file );/*noLibHook*/
+
+ if( is_array( $CACHE ) AND count( $CACHE ) )
+ {
+ foreach( $CACHE as $key => $cdata )
+ {
+ $this->cache->rebuildCache( $key, $vars['app_directory'] );
+ }
+ }
+ }
+
+ /* Rebuild GLOBAL CACHES! */
+ try
+ {
+ IPSLib::cacheGlobalCaches();
+ }
+ catch( Exception $e )
+ {
+ // Show an error?
+ }
+
+ /* Rebuild FURLs */
+ $furltemplatesfile = $this->app_full_path;
+ if(IPB_USE_ONLY_ID_FURL && is_file( $furltemplatesfile.'/extensions/furlTemplatesID.php'))
+ {
+ $furltemplatesfile.='/extensions/furlTemplatesID.php';
+ }
+ else
+ {
+ $furltemplatesfile.='/extensions/furlTemplates.php';
+ }
+ if( is_file( $furltemplatesfile ) )
+ {
+ try
+ {
+ IPSLib::cacheFurlTemplates();
+ }
+ catch( Exception $e )
+ {
+ // Show an error?
+ }
+ }
+
+ /* Show completed screen... */
+ $this->registry->output->html .= $this->html->setup_completed_screen( $data, $vars['type'] );
+ }
+
+ /**
+ * Next Check
+ *
+ * @return @e void
+ */
+ public function nextCheck()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+
+ /* Init Data */
+ $data = IPSSetUp::fetchXmlAppInformation( $vars['app_directory'], $this->settings['gb_char_set'] );
+ $_numbers = IPSSetUp::fetchAppVersionNumbers( $vars['app_directory'] );
+ $modules = IPSSetUp::fetchXmlAppModules( $vars['app_directory'], $this->settings['gb_char_set'] );
+
+ /* Grab Data */
+ $data['app_directory'] = $vars['app_directory'];
+ $data['current_version'] = ( $_numbers['current'][0] ) ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
+ $data['latest_version'] = $_numbers['latest'][1];
+ $data['next_version'] = $_numbers['next'][0];
+
+ /* Update the app DB */
+ if( $vars['type'] == 'install' )
+ {
+ /* Get current max position */
+ $pos = $this->DB->buildAndFetch( array( 'select' => 'MAX(app_position) as pos', 'from' => 'core_applications' ) );
+ $new_pos = intval( $pos['pos'] ) + 1;
+
+ /* Insert details into the DB */
+ $this->DB->insert( 'core_applications', array( 'app_title' => $this->product_information['name'],
+ 'app_public_title' => $this->product_information['public_name'],
+ 'app_author' => $this->product_information['author'],
+ 'app_description' => $this->product_information['description'],
+ 'app_hide_tab' => intval($this->product_information['hide_tab']),
+ 'app_version' => $_numbers['latest'][1],
+ 'app_long_version' => $_numbers['latest'][0],
+ 'app_directory' => $vars['app_directory'],
+ 'app_location' => $vars['app_location'],
+ 'app_added' => time(),
+ 'app_position' => $new_pos,
+ 'app_protected' => 0,
+ 'app_enabled' => $this->product_information['disabledatinstall'] ? 0 : 1,
+ 'app_website' => trim($this->product_information['website']),
+ 'app_update_check' => trim($this->product_information['update_check']),
+ 'app_global_caches' => trim($this->product_information['global_caches']),
+ )
+ );
+
+ $this->DB->insert( 'upgrade_history', array(
+ 'upgrade_version_id' => $_numbers['latest'][0],
+ 'upgrade_version_human' => $_numbers['latest'][1],
+ 'upgrade_date' => time(),
+ 'upgrade_notes' => '',
+ 'upgrade_mid' => $this->memberData['member_id'],
+ 'upgrade_app' => $vars['app_directory'],
+ ) );
+
+ /* Insert the modules */
+ foreach( $modules as $key => $module )
+ {
+ $this->DB->insert( 'core_sys_module', $module );
+ }
+ }
+ else
+ {
+ $this->DB->update( 'core_applications', array( 'app_title' => $this->product_information['name'],
+ 'app_public_title' => $this->product_information['public_name'],
+ 'app_author' => $this->product_information['author'],
+ 'app_description' => $this->product_information['description'],
+ 'app_hide_tab' => intval($this->product_information['hide_tab']),
+ 'app_version' => $_numbers['current'][1],
+ 'app_long_version' => $_numbers['current'][0],
+ 'app_website' => trim($this->product_information['website']),
+ 'app_update_check' => trim($this->product_information['update_check']),
+ 'app_global_caches' => trim($this->product_information['global_caches']),
+ ), "app_directory='" . $vars['app_directory'] . "'" );
+
+ /* Update the modules */
+ foreach( $modules as $key => $module )
+ {
+ $this->DB->update( 'core_sys_module', $module, "sys_module_application='{$module['sys_module_application']}' AND sys_module_key='{$module['sys_module_key']}'" );
+ }
+ }
+
+ /* Finish? */
+ if( $vars['type'] == 'install' OR $vars['version'] == $_numbers['latest'][0] )
+ {
+ /* Go back and start over with the new version */
+ $output[] = $this->lang->words['redir__nomore_modules'];
+
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'templates', $vars ) );
+ }
+ else
+ {
+ /* Go back and start over with the new version */
+ $output[] = sprintf( $this->lang->words['redir__upgraded_to'], $_numbers['current'][1] );
+
+ /* Work out the next step */
+ $vars['version'] = $_numbers['next'][0];
+
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'sql', $vars ) );
+ }
+ }
+
+ /**
+ * Import Hooks
+ *
+ * @return @e void
+ */
+ public function hooks()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+ $knownSettings = array();
+
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_tools' ) );
+
+ if( is_file( $this->app_full_path . 'xml/hooks.xml' ) )
+ {
+ /* Get the hooks class */
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/applications/hooks.php', 'admin_core_applications_hooks' );
+ $hooks = new $classToLoad();
+ $hooks->makeRegistryShortcuts( $this->registry );
+
+ $return = $hooks->installAppHooks( $vars['app_directory'] );
+ $this->cache->rebuildCache( 'hooks', 'global' );
+
+ $output[] = sprintf( $this->lang->words['redir__hooks'], $return['inserted'], $return['updated'] );
+ }
+ else
+ {
+ $this->registry->output->global_message = $this->lang->words['hooks_nofile'];
+
+ $output[] = $this->registry->output->global_message;
+ }
+
+ /* Clear main messaage */
+ $this->registry->output->global_message = '';
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'tplcache', $vars ) );
+ }
+
+ /**
+ * Import Settings
+ *
+ * @return @e void
+ */
+ public function settings()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+ $knownSettings = array();
+
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_tools' ), 'core' );
+
+ if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_settings.xml' ) )
+ {
+ /* Get the settings class */
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/settings/settings.php', 'admin_core_settings_settings' );
+ $settings = new $classToLoad();
+ $settings->makeRegistryShortcuts( $this->registry );
+
+ $this->request['app_dir'] = $vars['app_directory'];
+
+ //-----------------------------------------
+ // Known settings
+ //-----------------------------------------
+
+ if ( substr( $this->settings['_original_base_url'], -1 ) == '/' )
+ {
+ IPSSetUp::setSavedData('install_url', substr( $this->settings['_original_base_url'], 0, -1 ) );
+ }
+
+ if ( substr( $this->settings['base_dir'], -1 ) == '/' )
+ {
+ IPSSetUp::setSavedData('install_dir', substr( $this->settings['base_dir'], 0, -1 ) );
+ }
+
+ /* Fetch known settings */
+ if ( is_file( IPSLib::getAppDir( $vars['app_directory'] ) . '/setup/versions/install/knownSettings.php' ) )
+ {
+ require( IPSLib::getAppDir( $vars['app_directory'] ) . '/setup/versions/install/knownSettings.php' );/*noLibHook*/
+ }
+
+ $settings->importAllSettings( 1, 1, $knownSettings );
+ $settings->settingsRebuildCache();
+ }
+ else
+ {
+ $this->registry->output->global_message = $this->lang->words['settings_nofile'];
+ }
+
+ $output[] = $this->registry->output->global_message;
+
+ /* Clear main messaage */
+ $this->registry->output->global_message = '';
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'hooks', $vars ) );
+ }
+
+ /**
+ * Import tasks
+ *
+ * @return @e void
+ */
+ public function tasks()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+
+ if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_tasks.xml' ) )
+ {
+ /* Get the language class */
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/system/taskmanager.php', 'admin_core_system_taskmanager' );
+ $task_obj = new $classToLoad();
+ $task_obj->makeRegistryShortcuts( $this->registry );
+
+ $task_obj->tasksImportFromXML( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_tasks.xml', true );
+ }
+
+ $output[] = $this->registry->output->global_message ? $this->registry->output->global_message : $this->lang->words['no_tasks_for_import'];
+
+ /* Clear main msg */
+ $this->registry->output->global_message = '';
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'bbcode', $vars ) );
+ }
+
+ /**
+ * Import bbcode
+ *
+ * @return @e void
+ */
+ public function bbcode()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+
+ if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_bbcode.xml' ) )
+ {
+ /* Get the language class */
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/posts/bbcode.php', 'admin_core_posts_bbcode' );
+ $bbcode = new $classToLoad();
+ $bbcode->makeRegistryShortcuts( $this->registry );
+
+ $bbcode->bbcodeImportDo( file_get_contents( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_bbcode.xml' ) );
+
+ $output[] = $this->lang->words['bbcode_and_media'];
+ }
+
+ if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_mediatag.xml' ) )
+ {
+ /* Get the language class */
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/posts/media.php', 'admin_core_posts_media' );
+ $bbcode = new $classToLoad();
+ $bbcode->makeRegistryShortcuts( $this->registry );
+
+ $bbcode->doMediaImport( file_get_contents( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_mediatag.xml' ) );
+
+ if( !count($output) )
+ {
+ $output[] = $this->lang->words['bbcode_and_media'];
+ }
+ }
+
+ if( !count($output) )
+ {
+ $output[] = $this->lang->words['no_bbcode_media'];
+ }
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'help', $vars ) );
+ }
+
+ /**
+ * Import help
+ *
+ * @return @e void
+ */
+ public function help()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+
+ if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_help.xml' ) )
+ {
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/tools/help.php', 'admin_core_tools_help' );
+ $help = new $classToLoad();
+ $help->makeRegistryShortcuts( $this->registry );
+
+ $done = $help->helpFilesXMLImport_app( $vars['app_directory'] );
+
+ $output[] = sprintf( $this->lang->words['imported_x_help'], ($done['added'] + $done['updated']) );
+ }
+ else
+ {
+ $output[] = $this->lang->words['imported_no_help'];
+ }
+
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'settings', $vars ) );
+ }
+
+ /**
+ * Language Import
+ *
+ * @return @e void
+ */
+ public function languages()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+
+ /* Load the language file */
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_system' ) );
+
+ /* Get the language stuff */
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/languages/manage_languages.php', 'admin_core_languages_manage_languages' );
+ $lang = new $classToLoad();
+ $lang->makeRegistryShortcuts( $this->registry );
+
+ /* Loop through the xml directory and look for lang packs */
+ $_PATH = $this->app_full_path . '/xml/';
+
+ try
+ {
+ foreach( new DirectoryIterator( $_PATH ) as $f )
+ {
+ if( preg_match( "#(.+?)_language_pack.xml#", $f->getFileName() ) )
+ {
+ $this->request['file_location'] = $_PATH . $f->getFileName();
+ $lang->imprtFromXML( true, true, true, $vars['app_directory'], false, 1 );
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ $output[] = $this->registry->output->global_message ? $this->registry->output->global_message : $this->lang->words['redir__nolanguages'];
+
+ /* Clear main msg */
+ $this->registry->output->global_message = '';
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'tasks', $vars ) );
+ }
+
+ /**
+ * Install templates
+ *
+ * @return @e void
+ */
+ public function templates()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinImportExport.php' );/*noLibHook*/
+ $skinFunctions = new skinImportExport( $this->registry );
+ $skinCaching = new skinCaching( $this->registry );
+
+ /* Grab skin data */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'skin_collections' ) );
+
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ /* Bit of jiggery pokery... */
+ if ( $row['set_key'] == 'default' )
+ {
+ $row['set_key'] = 'root';
+ $row['set_id'] = 0;
+ }
+
+ $skinSets[ $row['set_key'] ] = $row;
+ }
+
+ foreach( $skinSets as $skinKey => $skinData )
+ {
+ /* Skin files first */
+ if( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_' . $skinKey . '_templates.xml' ) )
+ {
+ $return = $skinFunctions->importTemplateAppXML( $vars['app_directory'], $skinKey, $skinData['set_id'], TRUE );
+
+ $output[] = sprintf( $this->lang->words['redir__templates'], $return['insertCount'], $return['updateCount'], $skinData['set_name'] );
+ }
+
+ /* Then CSS files */
+ if ( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_' . $skinKey . '_css.xml' ) )
+ {
+ //-----------------------------------------
+ // Install
+ //-----------------------------------------
+
+ $return = $skinFunctions->importCSSAppXML( $vars['app_directory'], $skinKey, $skinData['set_id'] );
+
+ $output[] = sprintf( $this->lang->words['redir__cssfiles'], $return['insertCount'], $return['updateCount'], $skinData['set_name'] );
+ }
+
+ /* And we can support replacements for good measure */
+ if ( is_file( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_replacements.xml' ) )
+ {
+ //-----------------------------------------
+ // Install
+ //-----------------------------------------
+
+ $return = $skinFunctions->importReplacementsXMLArchive( file_get_contents( $this->app_full_path . 'xml/' . $vars['app_directory'] . '_replacements.xml' ), $skinKey );
+
+ $output[] = $this->lang->words['redir__replacements'];
+ }
+ }
+
+ /* Recache */
+ //$skinCaching->rebuildPHPTemplates( 0 );
+ //$skinCaching->rebuildCSS( 0 );
+ //$skinCaching->rebuildReplacementsCache( 0 );
+
+ /* No templates? Give some sort of feedback */
+ if ( !count( $output ) )
+ {
+ $output[] = $this->lang->words['redir__no_templates'];
+ }
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'languages', $vars ) );
+ }
+
+ /**
+ * Runs any additional sql files
+ *
+ * @return @e void
+ */
+ public function sqlSteps()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+ $id = intval( $this->request['id'] );
+ $id = ( $id < 1 ) ? 1 : $id;
+ $sql_files = array();
+
+ /* Any "extra" configs required for this driver? */
+ if( is_file( IPS_ROOT_PATH . 'setup/sql/' . strtolower( $this->settings['sql_driver'] ) . '_install.php' ) )
+ {
+ require_once( IPS_ROOT_PATH . 'setup/sql/' . strtolower( $this->settings['sql_driver'] ) . '_install.php' );/*noLibHook*/
+
+ $extra_install = new install_extra( $this->registry );
+ }
+
+
+ /* Run any sql files we found */
+ if( is_file( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ips_DBRegistry::getDriverType() ) . '_sql_' . $id .'.php' ) )
+ {
+ /* INIT */
+ $new_id = $id + 1;
+ $count = 0;
+ $SQL = array();
+
+ /* Get the sql file */
+ require_once( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ips_DBRegistry::getDriverType() ) . '_sql_' . $id .'.php' );/*noLibHook*/
+
+ $this->DB->return_die = 1;
+
+ /* Run the queries */
+ foreach( $SQL as $query )
+ {
+ $this->DB->allow_sub_select = 1;
+ $this->DB->error = '';
+
+ $query = str_replace( "<%time%>", time(), $query );
+
+ if( $extra_install AND method_exists( $extra_install, 'process_query_insert' ) )
+ {
+ $query = $extra_install->process_query_insert( $query );
+ }
+
+ $this->DB->query( $query );
+
+ if ( $this->DB->error )
+ {
+ $errors[] = $query." ".$this->DB->error;
+ }
+ else
+ {
+ $count++;
+ }
+ }
+
+ $output[] = sprintf( $this->lang->words['redir__sql_run'], $count );
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'sql_steps', $vars ) . '&id=' . $new_id );
+ }
+ else
+ {
+ $output[] = $this->lang->words['redir__nomore_sql'];
+
+ /* Show redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'next_check', $vars ) );
+ }
+ }
+
+ /**
+ * Creates Tables, Runs Inserts, and Indexes
+ *
+ * @return @e void
+ */
+ public function sqlBasics()
+ {
+ /* INIT */
+ $vars = $this->getVars();
+ $output = array();
+ $errors = array();
+ $skipped = 0;
+ $count = 0;
+
+ /* Any "extra" configs required for this driver? */
+ if( is_file( IPS_ROOT_PATH . 'setup/sql/' . strtolower( $this->settings['sql_driver'] ) . '_install.php' ) )
+ {
+ require_once( IPS_ROOT_PATH . 'setup/sql/' . strtolower( $this->settings['sql_driver'] ) . '_install.php' );/*noLibHook*/
+
+ $extra_install = new install_extra( $this->registry );
+ }
+
+ //-----------------------------------------
+ // Tables
+ //-----------------------------------------
+
+ $this->DB->return_die = 1;
+
+ if ( is_file( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_tables.php' ) )
+ {
+ $TABLE = array();
+ include( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_tables.php' );/*noLibHook*/
+
+ if ( is_array( $TABLE ) and count( $TABLE ) )
+ {
+ foreach( $TABLE as $q )
+ {
+ //-----------------------------------------
+ // Is this a create?
+ //-----------------------------------------
+
+ preg_match("/CREATE TABLE\s+(\S+)(\s)?\(/", str_ireplace( 'if not exists', '', $q ), $match);
+
+ if( $match[1] AND $vars['dupe_tables'] == 'drop' )
+ {
+ $this->DB->dropTable( str_replace( $this->settings['sql_tbl_prefix'], '', $match[1] ) );
+ }
+ else if( $match[1] )
+ {
+ if( $this->DB->getTableSchematic( $match[1] ) )
+ {
+ $skipped++;
+ continue;
+ }
+ }
+
+ //-----------------------------------------
+ // Is this an alter?
+ //-----------------------------------------
+
+ preg_match("/ALTER\s+TABLE\s+(\S+)\s+ADD\s+(\S+)\s+/i", $q, $match);
+
+ if( $match[1] AND $match[2] AND $vars['dupe_tables'] == 'drop' )
+ {
+ $this->DB->dropField( str_replace( $this->settings['sql_tbl_prefix'], '', $match[1] ), $match[2] );
+ }
+ else if( $match[1] AND $match[2] )
+ {
+ if( $this->DB->checkForField( $match[2], $match[1] ) )
+ {
+ $skipped++;
+ continue;
+ }
+ }
+
+ if ( $extra_install AND method_exists( $extra_install, 'process_query_create' ) )
+ {
+ $q = $extra_install->process_query_create( $q );
+ }
+ $this->DB->error = '';
+
+ $this->DB->query( $q );
+
+ if ( $this->DB->error )
+ {
+ $errors[] = $q." ".$this->DB->error;
+ }
+ else
+ {
+ $count++;
+ }
+ }
+ }
+
+ $output[] = sprintf( $this->lang->words['redir__sql_tables'], $count, $skipped );
+ }
+
+ //---------------------------------------------
+ // Create the fulltext index...
+ //---------------------------------------------
+
+ if ( $this->DB->checkFulltextSupport() )
+ {
+ if ( is_file( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_fulltext.php' ) )
+ {
+ $INDEX = array();
+ include( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_fulltext.php' );/*noLibHook*/
+
+ $count = 0;
+
+ foreach( $INDEX as $q )
+ {
+ //---------------------------------------------
+ // Pass to handler
+ //---------------------------------------------
+
+ if ( $extra_install AND method_exists( $extra_install, 'process_query_index' ) )
+ {
+ $q = $extra_install->process_query_index( $q );
+ }
+
+ //---------------------------------------------
+ // Pass query
+ //---------------------------------------------
+ $this->DB->error = '';
+ $this->DB->query( $q );
+
+ if ( $this->DB->error )
+ {
+ $errors[] = $q." ".$this->DB->error;
+ }
+ else
+ {
+ $count++;
+ }
+ }
+
+ $output[] = sprintf( $this->lang->words['redir__sql_indexes'], $count );
+ }
+ }
+
+ /* INSERTS */
+ if ( is_file( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_inserts.php' ) )
+ {
+ $INSERT = array();
+ $count = 0;
+
+ /* Get the SQL File */
+ include( $this->app_full_path . 'setup/versions/install/sql/' . $vars['app_directory']. '_' . strtolower( ipsRegistry::dbFunctions()->getDriverType() ) . '_inserts.php' );/*noLibHook*/
+
+ foreach( $INSERT as $q )
+ {
+ /* Extra Handler */
+ if( $extra_install AND method_exists( $extra_install, 'process_query_insert' ) )
+ {
+ $q = $extra_install->process_query_insert( $q );
+ }
+
+ $q = str_replace( "<%time%>", time(), $q );
+ $this->DB->error = '';
+ $this->DB->query( $q );
+
+ if ( $this->DB->error )
+ {
+ $errors[] = $q." ".$this->DB->error;
+ }
+ else
+ {
+ $count++;
+ }
+ }
+
+ $output[] = sprintf( $this->lang->words['redir__sql_inserts'], $count );
+ }
+
+ /* If we did no queries, show something here */
+ if ( !count( $output ) )
+ {
+ $output[] = sprintf( $this->lang->words['redir__sql_run'], 0 );
+ }
+
+ /* Show Redirect... */
+ $this->showRedirectScreen( $vars['app_directory'], $output, $errors, $this->getNextURL( 'sql_steps', $vars ) );
+ }
+
+ /**
+ * Begin installation
+ *
+ * @return @e void
+ */
+ public function start()
+ {
+ /* INIT */
+ $app_directory = IPSText::alphanumericalClean( $this->request['app_directory'] );
+ $type = 'upgrade';
+ $data = array();
+ $ok = 1;
+ $errors = array();
+ $localfiles = array( DOC_IPS_ROOT_PATH . 'cache/skin_cache' );
+ $info = array();
+
+ /* Init Data */
+ $data = IPSSetUp::fetchXmlAppInformation( $app_directory, $this->settings['gb_char_set'] );
+ $_numbers = IPSSetUp::fetchAppVersionNumbers( $app_directory );
+ $_files = IPSSetUp::fetchXmlAppWriteableFiles( $app_directory );
+
+ /* Grab Data */
+ $data['app_directory'] = $app_directory;
+ $data['current_version'] = ( $_numbers['current'][0] ) ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
+ $data['latest_version'] = $_numbers['latest'][1];
+ $data['next_version'] = $_numbers['next'][0];
+
+ /* Install, or upgrade? */
+ if ( ! $_numbers['current'][0] )
+ {
+ $type = 'install';
+ }
+
+ //-----------------------------------------
+ // For upgrade, redirect
+ //-----------------------------------------
+
+ else
+ {
+ @header( "Location: {$this->settings['board_url']}/" . CP_DIRECTORY . "/upgrade/" );
+ exit;
+ }
+
+ /* Version Check */
+ if( $data['current_version'] > 0 AND $data['current_version'] == $data['latest_version'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['error__up_to_date'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] );
+ return;
+ }
+
+ /* Check local files */
+ foreach( $localfiles as $_path )
+ {
+ if ( ! file_exists( $_path ) )
+ {
+ if ( $data['dir'] )
+ {
+ if ( ! @mkdir( $_path, IPS_FOLDER_PERMISSION, TRUE ) )
+ {
+ $info['notexist'][] = $_path;
+ }
+ }
+ else
+ {
+ $info['notexist'][] = $_path;
+ }
+ }
+ else if ( ! is_writeable( $_path ) )
+ {
+ if ( ! @chmod( $_path, is_dir( $_path ) ? IPS_FOLDER_PERMISSION : IPS_FILE_PERMISSION ) )
+ {
+ $info['notwrite'][] = $_path;
+ }
+ }
+ }
+
+ /* Check files... */
+ if( is_array( $_files ) AND count( $_files ) )
+ {
+ $info = array_merge( $info, $_files );
+ }
+
+ if ( count( $info['notexist'] ) )
+ {
+ foreach( $info['notexist'] as $path )
+ {
+ $errors[] = sprintf( $this->lang->words['error__file_missing'], $path );
+ }
+ }
+
+ if ( count( $info['notwrite'] ) )
+ {
+ foreach( $info['notwrite'] as $path )
+ {
+ $errors[] = sprintf( $this->lang->words['error__file_chmod'], $path );
+ }
+ }
+
+ /**
+ * Custom errors
+ */
+ if ( count( $info['other'] ) )
+ {
+ foreach( $info['other'] as $error )
+ {
+ $errors[] = $error;
+ }
+ }
+
+ /* Check for xml files */
+ $required_xml = array(
+ "information",
+ //"{$app_directory}_modules",
+ //"{$app_directory}_settings",
+ //"{$app_directory}_tasks",
+ //"{$app_directory}_templates",
+ );
+
+ foreach( $required_xml as $r )
+ {
+ if( ! is_file( $this->app_full_path . "xml/{$r}.xml" ) )
+ {
+ $errors[] = sprintf( $this->lang->words['error__file_needed'], $this->app_full_path . "xml/{$r}.xml" );
+ }
+ }
+
+ /* Show splash */
+ $this->registry->output->html .= $this->html->setup_splash_screen( $data, $errors, $type );
+ }
+
+ /**
+ * Get environment vars
+ *
+ * @return array
+ */
+ protected function getVars()
+ {
+ /* INIT */
+ $env = array();
+
+ /* Get the infos */
+ $env['type'] = strtolower( $this->request['type'] );
+ $env['version'] = $this->request['version'];
+ $env['dupe_tables'] = $this->request['dupe_tables'];
+ $env['app_directory'] = $this->request['app_directory'];
+
+ $env['app_location'] = 'other';
+
+ if( $this->product_information['ipskey'] )
+ {
+ if ( strstr( $this->app_full_path, 'applications_addon/ips' ) or strstr( $this->app_full_path, 'applications/' ) )
+ {
+ if ( md5( 'ips_' . basename($this->app_full_path) ) == $this->product_information['ipskey'] )
+ {
+ $env['app_location'] = 'ips';
+ }
+ }
+ }
+
+ $env['path'] = ( $env['type'] == 'install' ) ? $this->app_full_path . 'setup/versions/install'
+ : $this->app_full_path . 'setup/versions/' . $env['version'];
+
+ return $env;
+ }
+
+ /**
+ * Get next action URL
+ *
+ * @param string $next_action
+ * @param array $env
+ * @return string
+ */
+ protected function getNextURL( $next_action, $env )
+ {
+ return $this->settings['base_url'] . $this->form_code . '&do=' . $next_action . '&app_directory=' . $env['app_directory'] . '&type=' . $env['type'] . '&version=' . $env['version'];
+ }
+
+ /**
+ * Show the redirect screen
+ *
+ * @param string $app_directory
+ * @param string $output
+ * @param string $errors
+ * @param string $next_url
+ * @return @e void
+ */
+ protected function showRedirectScreen( $app_directory, $output, $errors, $next_url )
+ {
+ /* Init Data */
+ $data = IPSSetUp::fetchXmlAppInformation( $app_directory, $this->settings['gb_char_set'] );
+ $_numbers = IPSSetUp::fetchAppVersionNumbers( $app_directory );
+
+ /* Grab Data */
+ $data['app_directory'] = $app_directory;
+ $data['current_version'] = ( $_numbers['current'][0] ) ? $_numbers['current'][0] : $this->lang->words['cur_version_none'];
+ $data['latest_version'] = $_numbers['latest'][1];
+ $data['next_version'] = $_numbers['next'][0];
+
+ /* Setup Redirect */
+ $this->registry->output->html .= $this->html->setup_redirectScreen( $output, $errors, $next_url );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/applications/xml/menu.xml b/upload/admin/applications/core/modules_admin/applications/xml/menu.xml
index 3600a9de..fe80ab4c 100644
--- a/upload/admin/applications/core/modules_admin/applications/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/applications/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Manage Applications & Modules
+ Управление Приложениями
- Manage Applications & Modules
+ Управление Приложениями
manage_apps_modules
applications
do=applications_overview
@@ -15,10 +15,10 @@
-
-
Manage Hooks
+ Управление Хуками
- Manage Hooks
+ Управление Хуками
manage_hooks
hooks
do=hooks_overview
@@ -27,5 +27,18 @@
+ -
+
Расширения
+
+
+ Расширения
+ community_enhancements
+ enhancements
+
+ enhancements_manage
+ 0
+
+
+
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/applications/xml/permissions.xml b/upload/admin/applications/core/modules_admin/applications/xml/permissions.xml
index 25d1d502..4e775053 100644
--- a/upload/admin/applications/core/modules_admin/applications/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/applications/xml/permissions.xml
@@ -1,62 +1,72 @@
- Manage Applications
+ Управление приложениями
core_manage_apps
-
app_manage
- Can manage applications?
+ Может изменять/добавлять приложения?
-
app_delete
- Can delete applications?
+ Может удалять приложения?
-
app_install
- Can install new applications?
+ Может устанавливать новые приложения?
-
build_sphinx
- Can build sphinx.conf? WARNING: Exposes database login details
+ Может создавать sphinx.conf? ВНИМАНИЕ: будут доступны данные для соединения с базой данных
- Manage Modules
+ Управление модулями
core_manage_modules
-
module_manage
- Can edit/add application modules?
+ Может изменять/добавлять модули?
-
module_delete
- Can delete application modules?
+ Может удалять модули приложений?
- Purchase Applications
+ Покупка приложений
core_purchase_app
-
purchase_app
- Can view pages to purchase additional applications?
+ Может просматривать страницу с платными приложениями?
- Manage Hooks
+ Управление хуками
core_manage_hooks
-
hooks_manage
- Can manage hooks?
+ Может добавлять/изменять хуки?
-
hooks_delete
- Can remove hooks?
+ Может удалять хуки?
+
+
+
+
+ Расширения для Сообщества
+ core_community_enhancements
+
+ -
+
enhancements_manage
+ Может управлять расширениями?
diff --git a/upload/admin/applications/core/modules_admin/attach/attach.php b/upload/admin/applications/core/modules_admin/attach/attach.php
new file mode 100644
index 00000000..f226751a
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/attach/attach.php
@@ -0,0 +1,41 @@
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Attachment Poster
+ * Last Updated: $Date: 2012-05-21 21:37:50 +0100 (Mon, 21 May 2012) $
+ *
+ *
+ * @author $Author: ips_terabyte $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @version $Rev: 10777 $
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class admin_core_attach_attach extends ipsCommand
+{
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen/redirects]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Attachment Controller Class */
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/controller.php', 'classes_attach_controller' );
+ $controller = new $classToLoad( $registry );
+
+ $controller->run( $this->request['do'] );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/sources/loginauth/ipconverge/index.html b/upload/admin/applications/core/modules_admin/attach/index.html
similarity index 100%
rename from upload/admin/sources/loginauth/ipconverge/index.html
rename to upload/admin/applications/core/modules_admin/attach/index.html
diff --git a/upload/admin/applications/core/modules_admin/diagnostics/defaultSection.php b/upload/admin/applications/core/modules_admin/diagnostics/defaultSection.php
index 5871c6ad..e17551f1 100644
--- a/upload/admin/applications/core/modules_admin/diagnostics/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/diagnostics/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/diagnostics/diagnostics.php b/upload/admin/applications/core/modules_admin/diagnostics/diagnostics.php
index 46fe93cb..14dc0650 100644
--- a/upload/admin/applications/core/modules_admin/diagnostics/diagnostics.php
+++ b/upload/admin/applications/core/modules_admin/diagnostics/diagnostics.php
@@ -1,811 +1,824 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Diagnostic tools
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since 1st march 2002
- * @version $Revision: 10914 $
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-
-class admin_core_diagnostics_diagnostics extends ipsCommand
-{
- /**
- * Skin object
- *
- * @var object Skin templates
- */
- protected $html;
-
- /**
- * Shortcut for url
- *
- * @var string URL shortcut
- */
- protected $form_code;
-
- /**
- * Shortcut for url (javascript)
- *
- * @var string JS URL shortcut
- */
- protected $form_code_js;
-
- /**
- * Db tools
- *
- * @var object
- */
- protected $dbTools;
-
- /**
- * Main class entry point
- *
- * @param object ipsRegistry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Load skin and setup stuff */
- $this->html = $this->registry->output->loadTemplate('cp_skin_diagnostics');
- $this->form_code = $this->html->form_code = 'module=diagnostics§ion=diagnostics';
- $this->form_code_js = $this->html->form_code_js = 'module=diagnostics§ion=diagnostics';
-
- //-----------------------------------------
- // Some of these functions can take a while..
- //-----------------------------------------
-
- @set_time_limit(0);
-
- //-----------------------------------------
- // Load lang
- //-----------------------------------------
-
- ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_system' ), 'core' );
-
- ///----------------------------------------
- // What to do...
- //-----------------------------------------
-
- switch( $this->request['do'] )
- {
- case 'dbindex':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'index_checker' );
- $this->_indexCheck();
- break;
-
- case 'dbchecker':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'database_checker' );
- $this->_dbCheck();
- break;
-
- case 'whitespace':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'whitespace_checker' );
- $this->_whitespaceCheck();
- break;
-
- case 'connections':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'connection_checker' );
- $this->_checkConnections();
- break;
-
- case 'filepermissions':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'permission_checker' );
- $this->_permissionsCheck();
- break;
-
- case 'email':
- $this->_emailCheckerForm();
- break;
- case 'doemail':
- $this->_emailCheckerGo();
- break;
-
- default:
- $this->_listFunctions();
- break;
- }
-
- //-----------------------------------------
- // Pass to CP output hander
- //-----------------------------------------
-
- $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
- $this->registry->getClass('output')->sendOutput();
- }
-
- /**
- * Test outbound connections
- *
- * @return @e void [Outputs to screen]
- */
- public function _checkConnections()
- {
- //-----------------------------------------
- // Turn errors on so we can view them
- //-----------------------------------------
-
- @ini_set( 'display_errors', 1 );
- error_reporting( E_ALL ^ E_NOTICE );
-
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
- $_files = new $classToLoad();
-
- $_test = $_files->getFileContents( "http://www.invisionpower.com/connection-checker.html" );
- $_headers = $_files->raw_headers;
-
- $_test1 = $_files->getFileContents( "https://www.invisionpower.com/connection-checker.html" );
- $_headers1 = $_files->raw_headers;
-
- $this->registry->output->html .= $this->html->connectionCheckerResult( $_headers, $_test, $_headers1, $_test1 );
- }
-
- /**
- * Check file permissions
- *
- * @return @e void [Outputs to screen]
- */
- public function _permissionsCheck()
- {
- $checkdirs = array( PUBLIC_DIRECTORY . '/style_images',
- PUBLIC_DIRECTORY . '/style_css',
- PUBLIC_DIRECTORY . '/style_emoticons',
- 'cache',
- 'cache/skin_cache',
- 'cache/lang_cache',
- 'cache/tmp',
- 'uploads',
- 'uploads/profile',
- rtrim( str_replace( DOC_IPS_ROOT_PATH, '', IPS_HOOKS_PATH ), '/\\' ),
- );
-
- //-----------------------------------------
- // Get language directories
- //-----------------------------------------
-
- if( is_array( $this->cache->getCache('lang_data') ) && count( $this->cache->getCache('lang_data') ) )
- {
- foreach( $this->cache->getCache('lang_data') as $v )
- {
- $this_lang = 'cache/lang_cache/' . $v['lang_id'];
- $checkdirs[] = $this_lang;
-
- try
- {
- foreach( new DirectoryIterator( rtrim( DOC_IPS_ROOT_PATH, '/\\' ) . '/' . $this_lang ) as $file )
- {
- if( $file->isFile() )
- {
- $checkdirs[] = $this_lang . '/' . $file->getFilename();
- }
- }
- } catch ( Exception $e ) {}
- }
- }
- else
- {
- $this->DB->build( array( 'select' => 'lang_id', 'from' => 'core_sys_lang' ) );
- $this->DB->execute();
-
- while( $v = $this->DB->fetch() )
- {
- $this_lang = 'cache/lang_cache/' . $v['lang_id'];
- $checkdirs[] = $this_lang;
-
- try
- {
- foreach( new DirectoryIterator( rtrim( DOC_IPS_ROOT_PATH, '/\\' ) . '/' . $this_lang ) as $file )
- {
- if( $file->isFile() )
- {
- $checkdirs[] = $this_lang . '/' . $file->getFilename();
- }
- }
- } catch ( Exception $e ) {}
- }
- }
-
- //-----------------------------------------
- // Get emoticon directories
- //-----------------------------------------
-
- if( is_array( $this->cache->getCache('emoticons') ) && count( $this->cache->getCache('emoticons') ) )
- {
- foreach( $this->cache->getCache('emoticons') as $v )
- {
- $checkdirs[] = PUBLIC_DIRECTORY . '/style_emoticons/' . $v['emo_set'];
- }
- }
- else
- {
- $this->DB->build( array( 'select' => 'emo_set', 'from' => 'emoticons' ) );
- $this->DB->execute();
-
- while( $v = $this->DB->fetch() )
- {
- $checkdirs[] = PUBLIC_DIRECTORY . '/style_emoticons/' . $v['emo_set'];
- }
- }
-
- //-----------------------------------------
- // Get skin directories
- //-----------------------------------------
-
- $skin_dirs = array();
-
- if( is_array( $this->cache->getCache('skin_id_cache') ) && count( $this->cache->getCache('skin_id_cache') ) )
- {
- foreach( $this->cache->getCache('skin_id_cache') as $k => $v )
- {
- if( $k == 1 && !IN_DEV )
- {
- continue;
- }
-
- $checkdirs[] = 'cache/skin_cache/cacheid_' . $v['set_id'];
- $skin_dirs[] = $v['set_skin_set_id'];
- }
- }
- else
- {
- $this->DB->build( array( 'select' => 'set_id', 'from' => 'skin_collections' ) );
- $this->DB->execute();
-
- while( $v = $this->DB->fetch() )
- {
- $checkdirs[] = 'cache/skin_cache/cacheid_' . $v['set_id'];
- $skin_dirs[] = $v['set_skin_set_id'];
- }
- }
-
- //-----------------------------------------
- // Get skin files
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => $this->DB->buildDistinct( 'template_group' ),
- 'from' => 'skin_templates',
- 'group' => 'template_group',
- ) );
- $this->DB->execute();
-
- while( $v = $this->DB->fetch() )
- {
- foreach( $skin_dirs as $dir )
- {
- $checkdirs[] = 'cache/skin_cache/cacheid_' . $dir . '/' . $v['group_name'] . '.php';
- }
- }
-
- $checkdirs = array_unique($checkdirs);
- $output = array();
-
- foreach( $checkdirs as $dir_to_check )
- {
- if( !file_exists( rtrim( DOC_IPS_ROOT_PATH, '/\\' ) . '/' . $dir_to_check ) )
- {
- # Could be skin files from custom skins for components they don't own
- # or they could be using safe_mode skins
- # Make sure skin_cache still shows up though...
-
- if( !strpos( $dir_to_check, 'skin_' ) OR !strpos( $dir_to_check, '.php' ) )
- {
- $output[] = "{$this->lang->words['d_p404']} ". rtrim( DOC_IPS_ROOT_PATH, '/\\' ) . "/{$dir_to_check} ";
- }
- }
- else
- {
- $output[] = ( is_writable( DOC_IPS_ROOT_PATH . '/' . $dir_to_check ) ) ? "" . rtrim( DOC_IPS_ROOT_PATH, '/\\' ) . "/{$dir_to_check} {$this->lang->words['d_pyes']} " : "{$this->lang->words['d_pno']} ". rtrim( DOC_IPS_ROOT_PATH, '/\\' ) . "/{$dir_to_check} ";
- }
- }
-
- $this->registry->output->html .= $this->html->permissionsResults( $output );
- }
-
- /**
- * Whitespace checking
- *
- * @return @e void [Outputs to screen]
- */
- public function _whitespaceCheck()
- {
- $files_with_junk = $this->_whitespaceDirRecurse( rtrim( DOC_IPS_ROOT_PATH, '/\\' ) );
-
- $this->registry->output->html .= $this->html->whitespaceResults( $files_with_junk );
- }
-
- /**
- * Recurse over a directory
- *
- * @param string Directory to check
- * @return array Array of files with whitespace in them
- */
- public function _whitespaceDirRecurse( $dir )
- {
- $skip_dirs = array( 'uploads',
- PUBLIC_DIRECTORY,
- 'js',
- 'images',
- );
-
- $files = array();
-
- try
- {
- foreach( new DirectoryIterator( $dir ) as $directory )
- {
- if( $directory->isDot() )
- {
- continue;
- }
-
- if ( strpos( $directory->getFilename(), '_' ) === 0 OR strpos( $directory->getFilename(), '.' ) === 0 )
- {
- continue;
- }
-
- $newpath = $dir . '/' . $directory->getFilename();
- $level = explode( '/', $newpath );
-
- if ( is_dir($newpath) && !in_array( $directory->getFilename(), $skip_dirs ) )
- {
- $files = array_merge( $files, $this->_whitespaceDirRecurse($newpath) );
- }
- else
- {
- if ( strpos( $directory->getFilename(), ".php" ) !== false && !is_dir( $newpath ) )
- {
- $file = file_get_contents($newpath);
- $has_whitespace = false;
-
- if( substr( ltrim($file), 0, 3 ) == '' AND substr( $file, -2 ) != '?>' )
- {
- //-----------------------------------------
- // PHP explicitly allows one newline after closing tag
- //-----------------------------------------
-
- if( substr( rtrim($file), -2 ) == '?>' AND substr( $file, -3 ) != "?>\n" )
- {
- $has_whitespace = true;
- }
- }
-
- if( $has_whitespace )
- {
- $files[] = $newpath;
- }
- }
- }
- }
- } catch ( Exception $e ) {}
-
- return $files;
- }
-
- /**
- * Table and index checker basic stuff
- *
- * @param void
- * @return array Table files
- */
- public function _getDbTools()
- {
- //-----------------------------------------
- // First we get the SQL definitions for each app
- //-----------------------------------------
-
- $sql_table_files = array();
-
- foreach( $this->registry->getApplications() as $app )
- {
- $_file = IPSLib::getAppDir( $app['app_directory'] ) . '/setup/versions/install/sql/' . $app['app_directory'] . '_' . strtolower( ipsRegistry::$settings['sql_driver'] ) . '_tables.php';
-
- if( is_file( $_file ) )
- {
- $sql_table_files[ $app['app_title'] ] = $_file;
- }
- }
-
- //-----------------------------------------
- // Get the library to run the checks
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'db_lib/' . strtolower( ipsRegistry::$settings['sql_driver'] ) . '_tools.php', 'db_tools' );
- $this->dbTools = new $classToLoad();
-
- return $sql_table_files;
- }
-
- /**
- * Check the database for missing indexes
- *
- * @return @e void [Outputs to screen]
- */
- public function _indexCheck()
- {
- //-----------------------------------------
- // First we get the SQL definitions for each app
- //-----------------------------------------
-
- $sql_table_files = $this->_getDbTools();
-
- //-----------------------------------------
- // Now let's loop
- //-----------------------------------------
-
- $errors_array = array();
- $tables_array = array();
- $queriesRan = array();
-
- foreach( $sql_table_files as $app_title => $sql_file )
- {
- $TABLE = array();
- require_once( $sql_file );/*noLibHook*/
-
- if ( is_array( $TABLE ) AND count( $TABLE ) )
- {
- $output = $this->dbTools->dbIndexDiag( $TABLE, $this->request['fix'] );
-
- if( !$output )
- {
- continue;
- }
-
- if ( isset( $output['results']['ran'] ) )
- {
- $queriesRan = array_merge( $queriesRan, $output['results']['ran'] );
- unset( $output['results']['ran'] );
- }
-
- if( $output['error_count'] > 0 )
- {
- $errors_array[] = $app_title;
- }
-
- $tables_array[$app_title] = $output['results'];
- }
- }
-
- /* Output */
- $this->registry->output->html .= $this->html->indexChecker( $errors_array, $tables_array, $queriesRan );
- }
-
- /**
- * Check the database for missing tables/columns
- *
- * @return @e void [Outputs to screen]
- * @todo [Future] Functionality to show EXTRA columns/tables?
- */
- public function _dbCheck()
- {
- //-----------------------------------------
- // First we get the SQL definitions for each app
- //-----------------------------------------
-
- $sql_table_files = $this->_getDbTools();
-
- //-----------------------------------------
- // Now let's loop
- //-----------------------------------------
-
- $errors_array = array();
- $tables_array = array();
- $queriesRan = array();
-
- foreach( $sql_table_files as $app_title => $sql_file )
- {
- $TABLE = array();
- require_once( $sql_file );/*noLibHook*/
-
- $output = $this->dbTools->dbTableDiag( $TABLE, $this->request['fix'] );
-
- if( !$output )
- {
- continue;
- }
-
- if ( isset( $output['results']['ran'] ) )
- {
- $queriesRan = array_merge( $queriesRan, $output['results']['ran'] );
- unset( $output['results']['ran'] );
- }
-
- if( $output['error_count'] > 0 )
- {
- $errors_array[] = $app_title;
- }
-
- $tables_array[$app_title] = $output['results'];
- }
-
- //-----------------------------------------
- // And output
- //-----------------------------------------
-
- $this->registry->output->html .= $this->html->dbChecker( $errors_array, $tables_array, $queriesRan );
- }
-
- /**
- * Show the overview page
- *
- * @return @e void [Outputs to screen]
- */
- public function _listFunctions()
- {
- //-----------------------------------------
- // PHP INFO?
- //-----------------------------------------
-
- if ( $this->request['phpinfo'] AND $this->request['phpinfo'] )
- {
- @ob_start();
- phpinfo();
- $parsed = @ob_get_contents();
- @ob_end_clean();
-
- preg_match( "#(.*)#is" , $parsed, $match1 );
-
- $php_body = $match1[1];
-
- # PREVENT WRAP: Most cookies
- $php_body = str_replace( "; " , "; " , $php_body );
- # PREVENT WRAP: Very long string cookies
- $php_body = str_replace( "%3B", " " , $php_body );
- # PREVENT WRAP: Serialized array string cookies
- $php_body = str_replace( ";i:", "; i:" , $php_body );
- # PREVENT WRAP: LS_COLORS env
- $php_body = str_replace( ":*.", " :*." , $php_body );
- # PREVENT WRAP: PATH env
- $php_body = str_replace( "bin:/", "bin :/" , $php_body );
- # PREVENT WRAP: Cookie %2C split
- $php_body = str_replace( "%2C", "%2C " , $php_body );
- #PREVENT WRAP: Cookie , split
- $php_body = preg_replace( "#,(\d+),#", ", \\1," , $php_body );
-
- $this->registry->output->html .= $this->html->phpInfo( $php_body );
- return;
- }
-
- //-----------------------------------------
- // Stats
- //-----------------------------------------
-
- $reg = $this->DB->buildAndFetch( array(
- 'select' => 'COUNT(*) as reg' ,
- 'from' => array( 'validating' => 'v' ),
- 'where' => 'v.lost_pass <> 1 AND m.member_group_id=' . $this->settings['auth_group'],
- 'add_join' => array( array(
- 'from' => array( 'members' => 'm' ),
- 'where' => 'm.member_id=v.member_id',
- 'type' => 'left'
- ) ) ) );
-
- if( $this->settings['ipb_bruteforce_attempts'] )
- {
- $lock = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as mems' , 'from' => 'members', 'where' => 'failed_login_count >= ' . $this->settings['ipb_bruteforce_attempts'] ) );
- }
-
- $my_timestamp = time() - $this->settings['au_cutoff'] * 60;
-
- $online = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as sessions', 'from' => 'sessions', 'where' => 'running_time>' . $my_timestamp ) );
-
- $pending = $this->DB->buildAndFetch( array( 'select' => 'SUM(queued_topics) as topics, SUM(queued_posts) as posts', 'from' => 'forums' ) );
-
- $spammers = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count',
- 'from' => 'members',
- 'where' => "members_bitoptions = '1'" ) );
-
- $statsbox = $this->html->acp_stats_wrapper( array( 'topics' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['total_topics']),
- 'replies' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['total_replies']),
- 'topics_mod' => ipsRegistry::getClass('class_localization')->formatNumber($pending['topics']),
- 'posts_mod' => ipsRegistry::getClass('class_localization')->formatNumber($pending['posts']),
- 'members' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['mem_count']),
- 'validate' => ipsRegistry::getClass('class_localization')->formatNumber( $reg['reg'] ),
- 'spammer' => ipsRegistry::getClass('class_localization')->formatNumber( $spammers['count'] ),
- 'locked' => ipsRegistry::getClass('class_localization')->formatNumber( $lock['mems'] ),
- 'sql_driver' => strtoupper(SQL_DRIVER),
- 'sql_version' => $this->DB->true_version,
- 'php_version' => phpversion(),
- 'sessions' => ipsRegistry::getClass('class_localization')->formatNumber($online['sessions']),
- 'php_sapi' => @php_sapi_name(),
- 'ipb_version' => ipsRegistry::$version,
- 'ipb_id' => ipsRegistry::$vn_full ) );
-
- //-----------------------------------------
- // Server stuff
- //-----------------------------------------
-
- $this->DB->getSqlVersion();
-
- $sql_version = strtoupper($this->settings['sql_driver']) . " " . $this->DB->true_version;
-
- $php_version = phpversion() . " (" . @php_sapi_name() . ") ( form_code}&phpinfo=1'>{$this->lang->words['d_aphpinfo']} )";
- $server_software = @php_uname();
-
- $load_limit = IPSDebug::getServerLoad();
- $server_load_found = 0;
- $total_memory = "--";
- $avail_memory = "--";
- $_disabled = @ini_get('disable_functions') ? explode( ',', @ini_get('disable_functions') ) : array();
- $_shellExecAvail = in_array( 'shell_exec', $_disabled ) ? false : true;
-
- //-----------------------------------------
- // Check memory
- //-----------------------------------------
-
- if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
- {
- $mem = $_shellExecAvail ? @shell_exec('systeminfo') : null;
-
- if( $mem )
- {
- $server_reply = explode( "\n", str_replace( "\r", "", $mem ) );
-
- if( count($server_reply) )
- {
- foreach( $server_reply as $info )
- {
- if( strstr( $info, $this->lang->words['d_atotal'] ) )
- {
- $total_memory = trim( str_replace( ":", "", strrchr( $info, ":" ) ) );
- }
-
- if( strstr( $info, $this->lang->words['d_aavail']) )
- {
- $avail_memory = trim( str_replace( ":", "", strrchr( $info, ":" ) ) );
- }
- }
- }
- }
- }
- else
- {
- $mem = $_shellExecAvail ? @shell_exec("free -m") : null;
-
- if( $mem )
- {
- $server_reply = explode( "\n", str_replace( "\r", "", $mem ) );
- $mem = array_slice( $server_reply, 1, 1 );
- $mem = preg_split( "#\s+#", $mem[0] );
-
- $total_memory = ( $mem[1] ) ? $mem[1] . ' MB' : '--';
- $avail_memory = ( $mem[3] ) ? $mem[3] . ' MB' : '--';
- }
- else
- {
- $total_memory = '--';
- $avail_memory = '--';
- }
- }
-
- $disabled_functions = ( is_array($_disabled) && count($_disabled) ) ? implode( ', ', $_disabled ) : $this->lang->words['d_anoinfo'];
- $extensions = get_loaded_extensions();
- $extensions = array_combine( $extensions, $extensions );
- sort( $extensions, SORT_STRING );
-
- //-----------------------------------------
- // Set variables and pass to skin
- //-----------------------------------------
-
- $data = array(
- 'version' => 'v' . IPB_VERSION,
- 'version_full' => IPB_LONG_VERSION,
- 'version_sql' => $sql_version,
- 'driver_type' => strtoupper($this->settings['sql_driver']),
- 'version_php' => $php_version,
- 'disabled' => $disabled_functions,
- 'extensions' => str_replace( "suhosin", "suhosin ", implode( ", ", $extensions ) ),
- 'safe_mode' => SAFE_MODE_ON == 1 ? "{$this->lang->words['d_aon']} " : "{$this->lang->words['d_aoff']} ",
- 'server' => $server_software,
- 'load' => $load_limit,
- 'total_memory' => $total_memory,
- 'avail_memory' => $avail_memory,
- );
-
- if( $_shellExecAvail )
- {
- if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
- {
- $tasks = @shell_exec( "tasklist" );
- $tasks = str_replace( " ", " ", $tasks );
- }
- else if( strtolower( PHP_OS ) == 'darwin' )
- {
- $tasks = @shell_exec( "top -l 1" );
- $tasks = str_replace( " ", " ", $tasks );
- }
- else
- {
- $tasks = @shell_exec( "top -b -n 1" );
- $tasks = str_replace( " ", " ", $tasks );
- }
- }
- else
- {
- $tasks = '';
- }
-
- if( !$tasks )
- {
- $tasks = $this->lang->words['d_aunable'];
- }
- else
- {
- $tasks = "".$tasks." ";
- }
-
- $data['tasks'] = $tasks;
-
- $this->registry->output->html .= $this->html->diagnosticsOverview( $data, $statsbox );
- }
-
- /**
- * Show the email tester page
- *
- * @param sring Error message
- * @return @e void [Outputs to screen]
- */
- public function _emailCheckerForm( $error='' )
- {
- $this->registry->output->html .= $this->html->emailChecker( $error );
- }
-
- /**
- * Send a test email
- *
- * @return @e void [Outputs to screen]
- */
- public function _emailCheckerGo()
- {
- //-----------------------------------------
- // Send it
- //-----------------------------------------
-
- IPSText::getTextClass('email')->to = $this->request['to'];
- IPSText::getTextClass('email')->from = $this->request['from'];
- IPSText::getTextClass('email')->subject = $this->request['subject'];
- IPSText::getTextClass('email')->message = $this->request['message'];
- IPSText::getTextClass('email')->sendMail();
-
- //-----------------------------------------
- // Check the error log
- //-----------------------------------------
-
- $error = '';
-
- $lastLog = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'mail_error_logs', 'order' => 'mlog_date DESC', 'limit' => 1 ) );
- if ( $lastLog['mlog_date'] >= ( time() - 2 ) and $lastLog['mlog_subject'] == $this->request['subject'] )
- {
- $error = $lastLog['mlog_msg'];
- }
- else
- {
- $this->registry->output->global_message = $this->lang->words['email_tester_ok'];
- }
-
- //-----------------------------------------
- // Show
- //-----------------------------------------
-
- $this->_emailCheckerForm( $error );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Diagnostic tools
+ * Last Updated: $Date: 2013-04-15 17:26:30 -0400 (Mon, 15 Apr 2013) $
+ *
+ *
+ * @author $Author: AndyMillne $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 1st march 2002
+ * @version $Revision: 12179 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+
+class admin_core_diagnostics_diagnostics extends ipsCommand
+{
+ /**
+ * Skin object
+ *
+ * @var object Skin templates
+ */
+ public $html;
+
+ /**
+ * Shortcut for url
+ *
+ * @var string URL shortcut
+ */
+ public $form_code;
+
+ /**
+ * Shortcut for url (javascript)
+ *
+ * @var string JS URL shortcut
+ */
+ public $form_code_js;
+
+ /**
+ * Db tools
+ *
+ * @var object
+ */
+ protected $dbTools;
+
+ /**
+ * Main class entry point
+ *
+ * @param object ipsRegistry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Load skin and setup stuff */
+ $this->html = $this->registry->output->loadTemplate('cp_skin_diagnostics');
+ $this->form_code = $this->html->form_code = 'module=diagnostics§ion=diagnostics';
+ $this->form_code_js = $this->html->form_code_js = 'module=diagnostics§ion=diagnostics';
+
+ //-----------------------------------------
+ // Some of these functions can take a while..
+ //-----------------------------------------
+
+ @set_time_limit(0);
+
+ //-----------------------------------------
+ // Load lang
+ //-----------------------------------------
+
+ ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_system' ), 'core' );
+
+ ///----------------------------------------
+ // What to do...
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ case 'dbindex':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'index_checker' );
+ $this->_indexCheck();
+ break;
+
+ case 'dbchecker':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'database_checker' );
+ $this->_dbCheck();
+ break;
+
+ case 'whitespace':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'whitespace_checker' );
+ $this->_whitespaceCheck();
+ break;
+
+ case 'connections':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'connection_checker' );
+ $this->_checkConnections();
+ break;
+
+ case 'filepermissions':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'permission_checker' );
+ $this->_permissionsCheck();
+ break;
+
+ case 'email':
+ $this->_emailCheckerForm();
+ break;
+ case 'doemail':
+ $this->_emailCheckerGo();
+ break;
+
+ default:
+ $this->_listFunctions();
+ break;
+ }
+
+ //-----------------------------------------
+ // Pass to CP output hander
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
+ $this->registry->getClass('output')->sendOutput();
+ }
+
+ /**
+ * Test outbound connections
+ *
+ * @return @e void [Outputs to screen]
+ */
+ public function _checkConnections()
+ {
+ //-----------------------------------------
+ // Turn errors on so we can view them
+ //-----------------------------------------
+
+ @ini_set( 'display_errors', 1 );
+ error_reporting( E_ALL ^ E_NOTICE );
+
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
+ $_files = new $classToLoad();
+
+ $_test = $_files->getFileContents( "http://www.invisionpower.com/connection-checker.html" );
+ $_headers = $_files->raw_headers;
+
+ $_test1 = $_files->getFileContents( "https://www.invisionpower.com/connection-checker.html" );
+ $_headers1 = $_files->raw_headers;
+
+ $this->registry->output->html .= $this->html->connectionCheckerResult( $_headers, $_test, $_headers1, $_test1 );
+ }
+
+ /**
+ * Check file permissions
+ *
+ * @return @e void [Outputs to screen]
+ */
+ public function _permissionsCheck()
+ {
+ $checkdirs = array( IPS_PUBLIC_PATH . 'style_images',
+ IPS_PUBLIC_PATH . 'style_css',
+ IPS_PUBLIC_PATH . 'style_emoticons',
+ IPS_CACHE_PATH . 'cache',
+ IPS_CACHE_PATH . 'cache/skin_cache',
+ IPS_CACHE_PATH . 'cache/lang_cache',
+ IPS_CACHE_PATH . 'cache/tmp',
+ IPS_CACHE_PATH . 'cache/tmp/HTML',
+ IPS_CACHE_PATH . 'cache/tmp/URI',
+ IPS_CACHE_PATH . 'cache/tmp/CSS',
+ $this->settings['upload_dir'],
+ $this->settings['upload_dir'] . '/profile',
+ IPS_HOOKS_PATH,
+ );
+
+ //-----------------------------------------
+ // Get language directories
+ //-----------------------------------------
+
+ if( is_array( $this->cache->getCache('lang_data') ) && count( $this->cache->getCache('lang_data') ) )
+ {
+ foreach( $this->cache->getCache('lang_data') as $v )
+ {
+ $this_lang = IPS_CACHE_PATH . 'cache/lang_cache/' . $v['lang_id'];
+ $checkdirs[] = $this_lang;
+
+ try
+ {
+ foreach( new DirectoryIterator( $this_lang ) as $file )
+ {
+ if( $file->isFile() )
+ {
+ $checkdirs[] = $this_lang . '/' . $file->getFilename();
+ }
+ }
+ } catch ( Exception $e ) {}
+ }
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => 'lang_id', 'from' => 'core_sys_lang' ) );
+ $this->DB->execute();
+
+ while( $v = $this->DB->fetch() )
+ {
+ $this_lang = IPS_CACHE_PATH . 'cache/lang_cache/' . $v['lang_id'];
+ $checkdirs[] = $this_lang;
+
+ try
+ {
+ foreach( new DirectoryIterator( $this_lang ) as $file )
+ {
+ if( $file->isFile() )
+ {
+ $checkdirs[] = $this_lang . '/' . $file->getFilename();
+ }
+ }
+ } catch ( Exception $e ) {}
+ }
+ }
+
+ //-----------------------------------------
+ // Get emoticon directories
+ //-----------------------------------------
+
+ if( is_array( $this->cache->getCache('emoticons') ) && count( $this->cache->getCache('emoticons') ) )
+ {
+ foreach( $this->cache->getCache('emoticons') as $v )
+ {
+ $checkdirs[] = IPS_PUBLIC_PATH . 'style_emoticons/' . $v['emo_set'];
+ }
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => 'emo_set', 'from' => 'emoticons' ) );
+ $this->DB->execute();
+
+ while( $v = $this->DB->fetch() )
+ {
+ $checkdirs[] = IPS_PUBLIC_PATH . 'style_emoticons/' . $v['emo_set'];
+ }
+ }
+
+ //-----------------------------------------
+ // Get skin directories
+ //-----------------------------------------
+
+ $skin_dirs = array();
+
+ if( is_array( $this->cache->getCache('skin_id_cache') ) && count( $this->cache->getCache('skin_id_cache') ) )
+ {
+ foreach( $this->cache->getCache('skin_id_cache') as $k => $v )
+ {
+ if( $k == 1 && !IN_DEV )
+ {
+ continue;
+ }
+
+ $checkdirs[] = IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $v['set_id'];
+ $skin_dirs[] = $v['set_skin_set_id'];
+ }
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => 'set_id', 'from' => 'skin_collections' ) );
+ $this->DB->execute();
+
+ while( $v = $this->DB->fetch() )
+ {
+ $checkdirs[] = IPS_CACHE_PATH . 'cache/skin_cache/cacheid_' . $v['set_id'];
+ $skin_dirs[] = $v['set_skin_set_id'];
+ }
+ }
+
+ //-----------------------------------------
+ // Get skin files
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => $this->DB->buildDistinct( 'template_group' ),
+ 'from' => 'skin_templates',
+ 'group' => 'template_group',
+ ) );
+ $this->DB->execute();
+
+ while( $v = $this->DB->fetch() )
+ {
+ foreach( $skin_dirs as $dir )
+ {
+ $checkdirs[] = 'cache/skin_cache/cacheid_' . $dir . '/' . $v['group_name'] . '.php';
+ }
+ }
+
+ $checkdirs = array_unique($checkdirs);
+ $output = array();
+
+
+
+
+ foreach( $checkdirs as $dir_to_check )
+ {
+ if( !file_exists( $dir_to_check ) )
+ {
+ # Could be skin files from custom skins for components they don't own
+ # or they could be using safe_mode skins
+ # Make sure skin_cache still shows up though...
+
+ /* tmp/ folders are created automatically. We don't need to make sure they exist but if they do they should still be writable */
+ if( strpos( $dir_to_check, 'tmp/' ) )
+ {
+ continue;
+ }
+
+ if( !strpos( $dir_to_check, 'skin_' ) OR !strpos( $dir_to_check, '.php' ) )
+ {
+ $output[] = "{$this->lang->words['d_p404']} {$dir_to_check} ";
+ }
+ }
+ else
+ {
+ $output[] = ( is_writable( $dir_to_check ) ) ? "{$dir_to_check} {$this->lang->words['d_pyes']} " : "{$this->lang->words['d_pno']} {$dir_to_check} ";
+ }
+ }
+
+ $this->registry->output->html .= $this->html->permissionsResults( $output );
+ }
+
+ /**
+ * Whitespace checking
+ *
+ * @return @e void [Outputs to screen]
+ */
+ public function _whitespaceCheck()
+ {
+ $files_with_junk = $this->_whitespaceDirRecurse( rtrim( DOC_IPS_ROOT_PATH, '/\\' ) );
+
+ $this->registry->output->html .= $this->html->whitespaceResults( $files_with_junk );
+ }
+
+ /**
+ * Recurse over a directory
+ *
+ * @param string Directory to check
+ * @return array Array of files with whitespace in them
+ */
+ public function _whitespaceDirRecurse( $dir )
+ {
+ $skip_dirs = array( 'uploads',
+ PUBLIC_DIRECTORY,
+ 'js',
+ 'images',
+ );
+
+ $files = array();
+
+ try
+ {
+ foreach( new DirectoryIterator( $dir ) as $directory )
+ {
+ if( $directory->isDot() )
+ {
+ continue;
+ }
+
+ if ( strpos( $directory->getFilename(), '_' ) === 0 OR strpos( $directory->getFilename(), '.' ) === 0 )
+ {
+ continue;
+ }
+
+ $newpath = $dir . '/' . $directory->getFilename();
+ $level = explode( '/', $newpath );
+
+ if ( is_dir($newpath) && !in_array( $directory->getFilename(), $skip_dirs ) )
+ {
+ $files = array_merge( $files, $this->_whitespaceDirRecurse($newpath) );
+ }
+ else
+ {
+ if ( strpos( $directory->getFilename(), ".php" ) !== false && !is_dir( $newpath ) )
+ {
+ $file = file_get_contents($newpath);
+ $has_whitespace = false;
+
+ if( substr( ltrim($file), 0, 3 ) == '' AND substr( $file, -2 ) != '?>' )
+ {
+ //-----------------------------------------
+ // PHP explicitly allows one newline after closing tag
+ //-----------------------------------------
+
+ if( substr( rtrim($file), -2 ) == '?>' AND substr( $file, -3 ) != "?>\n" )
+ {
+ $has_whitespace = true;
+ }
+ }
+
+ if( $has_whitespace )
+ {
+ $files[] = $newpath;
+ }
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ return $files;
+ }
+
+ /**
+ * Table and index checker basic stuff
+ *
+ * @param void
+ * @return array Table files
+ */
+ public function _getDbTools()
+ {
+ //-----------------------------------------
+ // First we get the SQL definitions for each app
+ //-----------------------------------------
+
+ $sql_table_files = array();
+
+ foreach( $this->registry->getApplications() as $app )
+ {
+ $_file = IPSLib::getAppDir( $app['app_directory'] ) . '/setup/versions/install/sql/' . $app['app_directory'] . '_' . strtolower( ipsRegistry::$settings['sql_driver'] ) . '_tables.php';
+
+ if( is_file( $_file ) )
+ {
+ $sql_table_files[ $app['app_title'] ] = $_file;
+ }
+ }
+
+ //-----------------------------------------
+ // Get the library to run the checks
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'db_lib/' . strtolower( ipsRegistry::$settings['sql_driver'] ) . '_tools.php', 'db_tools' );
+ $this->dbTools = new $classToLoad();
+
+ return $sql_table_files;
+ }
+
+ /**
+ * Check the database for missing indexes
+ *
+ * @return @e void [Outputs to screen]
+ */
+ public function _indexCheck()
+ {
+ //-----------------------------------------
+ // First we get the SQL definitions for each app
+ //-----------------------------------------
+
+ $sql_table_files = $this->_getDbTools();
+
+ //-----------------------------------------
+ // Now let's loop
+ //-----------------------------------------
+
+ $errors_array = array();
+ $tables_array = array();
+ $queriesRan = array();
+
+ foreach( $sql_table_files as $app_title => $sql_file )
+ {
+ $TABLE = array();
+ require_once( $sql_file );/*noLibHook*/
+
+ if ( is_array( $TABLE ) AND count( $TABLE ) )
+ {
+ $output = $this->dbTools->dbIndexDiag( $TABLE, $this->request['fix'] );
+
+ if( !$output )
+ {
+ continue;
+ }
+
+ if ( isset( $output['results']['ran'] ) )
+ {
+ $queriesRan = array_merge( $queriesRan, $output['results']['ran'] );
+ unset( $output['results']['ran'] );
+ }
+
+ if( $output['error_count'] > 0 )
+ {
+ $errors_array[] = $app_title;
+ }
+
+ $tables_array[$app_title] = $output['results'];
+ }
+ }
+
+ /* Output */
+ $this->registry->output->html .= $this->html->indexChecker( $errors_array, $tables_array, $queriesRan );
+ }
+
+ /**
+ * Check the database for missing tables/columns
+ *
+ * @return @e void [Outputs to screen]
+ * @todo [Future] Functionality to show EXTRA columns/tables?
+ */
+ public function _dbCheck()
+ {
+ //-----------------------------------------
+ // First we get the SQL definitions for each app
+ //-----------------------------------------
+
+ $sql_table_files = $this->_getDbTools();
+
+ //-----------------------------------------
+ // Now let's loop
+ //-----------------------------------------
+
+ $errors_array = array();
+ $tables_array = array();
+ $queriesRan = array();
+
+ foreach( $sql_table_files as $app_title => $sql_file )
+ {
+ $TABLE = array();
+ require_once( $sql_file );/*noLibHook*/
+
+ $output = $this->dbTools->dbTableDiag( $TABLE, $this->request['fix'] );
+
+ if( !$output )
+ {
+ continue;
+ }
+
+ if ( isset( $output['results']['ran'] ) )
+ {
+ $queriesRan = array_merge( $queriesRan, $output['results']['ran'] );
+ unset( $output['results']['ran'] );
+ }
+
+ if( $output['error_count'] > 0 )
+ {
+ $errors_array[] = $app_title;
+ }
+
+ $tables_array[$app_title] = $output['results'];
+ }
+
+ //-----------------------------------------
+ // And output
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->html->dbChecker( $errors_array, $tables_array, $queriesRan );
+ }
+
+ /**
+ * Show the overview page
+ *
+ * @return @e void [Outputs to screen]
+ */
+ public function _listFunctions()
+ {
+ //-----------------------------------------
+ // PHP INFO?
+ //-----------------------------------------
+
+ if ( $this->request['phpinfo'] AND $this->request['phpinfo'] )
+ {
+ @ob_start();
+ phpinfo();
+ $parsed = @ob_get_contents();
+ @ob_end_clean();
+
+ preg_match( "#(.*)#is" , $parsed, $match1 );
+
+ $php_body = $match1[1];
+
+ # PREVENT WRAP: Most cookies
+ $php_body = str_replace( "; " , "; " , $php_body );
+ # PREVENT WRAP: Very long string cookies
+ $php_body = str_replace( "%3B", " " , $php_body );
+ # PREVENT WRAP: Serialized array string cookies
+ $php_body = str_replace( ";i:", "; i:" , $php_body );
+ # PREVENT WRAP: LS_COLORS env
+ $php_body = str_replace( ":*.", " :*." , $php_body );
+ # PREVENT WRAP: PATH env
+ $php_body = str_replace( "bin:/", "bin :/" , $php_body );
+ # PREVENT WRAP: Cookie %2C split
+ $php_body = str_replace( "%2C", "%2C " , $php_body );
+ #PREVENT WRAP: Cookie , split
+ $php_body = preg_replace( "#,(\d+),#", ", \\1," , $php_body );
+
+ $this->registry->output->html .= $this->html->phpInfo( $php_body );
+ return;
+ }
+
+ //-----------------------------------------
+ // Stats
+ //-----------------------------------------
+
+ $reg = $this->DB->buildAndFetch( array(
+ 'select' => 'COUNT(*) as reg' ,
+ 'from' => array( 'validating' => 'v' ),
+ 'where' => 'v.lost_pass <> 1 AND m.member_group_id=' . $this->settings['auth_group'],
+ 'add_join' => array( array(
+ 'from' => array( 'members' => 'm' ),
+ 'where' => 'm.member_id=v.member_id',
+ 'type' => 'left'
+ ) ) ) );
+
+ if( $this->settings['ipb_bruteforce_attempts'] )
+ {
+ $lock = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as mems' , 'from' => 'members', 'where' => 'failed_login_count >= ' . $this->settings['ipb_bruteforce_attempts'] ) );
+ }
+
+ $my_timestamp = time() - $this->settings['au_cutoff'] * 60;
+
+ $online = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as sessions', 'from' => 'sessions', 'where' => 'running_time>' . $my_timestamp ) );
+
+ $pending = $this->DB->buildAndFetch( array( 'select' => 'SUM(queued_topics) as topics, SUM(queued_posts) as posts', 'from' => 'forums' ) );
+
+ $spammers = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count',
+ 'from' => 'members',
+ 'where' => "members_bitoptions = '1'" ) );
+
+ $statsbox = $this->html->acp_stats_wrapper( array( 'topics' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['total_topics']),
+ 'replies' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['total_replies']),
+ 'topics_mod' => ipsRegistry::getClass('class_localization')->formatNumber($pending['topics']),
+ 'posts_mod' => ipsRegistry::getClass('class_localization')->formatNumber($pending['posts']),
+ 'members' => ipsRegistry::getClass('class_localization')->formatNumber($this->caches['stats']['mem_count']),
+ 'validate' => ipsRegistry::getClass('class_localization')->formatNumber( $reg['reg'] ),
+ 'spammer' => ipsRegistry::getClass('class_localization')->formatNumber( $spammers['count'] ),
+ 'locked' => ipsRegistry::getClass('class_localization')->formatNumber( $lock['mems'] ),
+ 'sql_driver' => strtoupper(SQL_DRIVER),
+ 'sql_version' => $this->DB->true_version,
+ 'php_version' => phpversion(),
+ 'sessions' => ipsRegistry::getClass('class_localization')->formatNumber($online['sessions']),
+ 'php_sapi' => @php_sapi_name(),
+ 'ipb_version' => ipsRegistry::$version,
+ 'ipb_id' => ipsRegistry::$vn_full ) );
+
+ //-----------------------------------------
+ // Server stuff
+ //-----------------------------------------
+
+ $this->DB->getSqlVersion();
+
+ $sql_version = strtoupper($this->settings['sql_driver']) . " " . $this->DB->true_version;
+
+ $php_version = phpversion() . " (" . @php_sapi_name() . ") ( form_code}&phpinfo=1'>{$this->lang->words['d_aphpinfo']} )";
+ $server_software = @php_uname();
+
+ $load_limit = IPSDebug::getServerLoad();
+ $server_load_found = 0;
+ $total_memory = "--";
+ $avail_memory = "--";
+ $_disabled = @ini_get('disable_functions') ? explode( ',', @ini_get('disable_functions') ) : array();
+ $_shellExecAvail = in_array( 'shell_exec', $_disabled ) ? false : true;
+
+ //-----------------------------------------
+ // Check memory
+ //-----------------------------------------
+
+ if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
+ {
+ $mem = $_shellExecAvail ? @shell_exec('systeminfo') : null;
+
+ if( $mem )
+ {
+ $server_reply = explode( "\n", str_replace( "\r", "", $mem ) );
+
+ if( count($server_reply) )
+ {
+ foreach( $server_reply as $info )
+ {
+ if( strstr( $info, $this->lang->words['d_atotal'] ) )
+ {
+ $total_memory = trim( str_replace( ":", "", strrchr( $info, ":" ) ) );
+ }
+
+ if( strstr( $info, $this->lang->words['d_aavail']) )
+ {
+ $avail_memory = trim( str_replace( ":", "", strrchr( $info, ":" ) ) );
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ $mem = $_shellExecAvail ? @shell_exec("free -m") : null;
+
+ if( $mem )
+ {
+ $server_reply = explode( "\n", str_replace( "\r", "", $mem ) );
+ $mem = array_slice( $server_reply, 1, 1 );
+ $mem = preg_split( "#\s+#", $mem[0] );
+
+ $total_memory = ( $mem[1] ) ? $mem[1] . ' MB' : '--';
+ $avail_memory = ( $mem[3] ) ? $mem[3] . ' MB' : '--';
+ }
+ else
+ {
+ $total_memory = '--';
+ $avail_memory = '--';
+ }
+ }
+
+ $disabled_functions = ( is_array($_disabled) && count($_disabled) ) ? implode( ', ', $_disabled ) : $this->lang->words['d_anoinfo'];
+ $extensions = get_loaded_extensions();
+ $extensions = array_combine( $extensions, $extensions );
+ sort( $extensions, SORT_STRING );
+
+ //-----------------------------------------
+ // Set variables and pass to skin
+ //-----------------------------------------
+
+ $data = array(
+ 'version' => 'v' . IPB_VERSION,
+ 'version_full' => IPB_LONG_VERSION,
+ 'version_sql' => $sql_version,
+ 'driver_type' => strtoupper($this->settings['sql_driver']),
+ 'version_php' => $php_version,
+ 'disabled' => $disabled_functions,
+ 'extensions' => str_replace( "suhosin", "suhosin ", implode( ", ", $extensions ) ),
+ 'safe_mode' => SAFE_MODE_ON == 1 ? "{$this->lang->words['d_aon']} " : "{$this->lang->words['d_aoff']} ",
+ 'server' => $server_software,
+ 'load' => $load_limit,
+ 'total_memory' => $total_memory,
+ 'avail_memory' => $avail_memory,
+ );
+
+ if( $_shellExecAvail )
+ {
+ if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
+ {
+ $tasks = @shell_exec( "tasklist" );
+ $tasks = str_replace( " ", " ", $tasks );
+ $tasks = mb_convert_encoding($tasks, IPS_DOC_CHAR_SET, 'CP866');
+ }
+ else if( strtolower( PHP_OS ) == 'darwin' )
+ {
+ $tasks = @shell_exec( "top -l 1" );
+ $tasks = str_replace( " ", " ", $tasks );
+ }
+ else
+ {
+ $tasks = @shell_exec( "top -b -n 1" );
+ $tasks = str_replace( " ", " ", $tasks );
+ }
+ }
+ else
+ {
+ $tasks = '';
+ }
+
+ if( !$tasks )
+ {
+ $tasks = $this->lang->words['d_aunable'];
+ }
+ else
+ {
+ $tasks = "".$tasks." ";
+ }
+
+ $data['tasks'] = $tasks;
+
+ $this->registry->output->html .= $this->html->diagnosticsOverview( $data, $statsbox );
+ }
+
+ /**
+ * Show the email tester page
+ *
+ * @param sring Error message
+ * @return @e void [Outputs to screen]
+ */
+ public function _emailCheckerForm( $error='' )
+ {
+ $this->registry->output->html .= $this->html->emailChecker( $error );
+ }
+
+ /**
+ * Send a test email
+ *
+ * @return @e void [Outputs to screen]
+ */
+ public function _emailCheckerGo()
+ {
+ //-----------------------------------------
+ // Send it
+ //-----------------------------------------
+
+ IPSText::getTextClass('email')->to = $this->request['to'];
+ IPSText::getTextClass('email')->from = $this->request['from'];
+ IPSText::getTextClass('email')->subject = $this->request['subject'];
+ IPSText::getTextClass('email')->message = $this->request['message'];
+ IPSText::getTextClass('email')->sendMail();
+
+ //-----------------------------------------
+ // Check the error log
+ //-----------------------------------------
+
+ $error = '';
+
+ $lastLog = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'mail_error_logs', 'order' => 'mlog_date DESC', 'limit' => 1 ) );
+ if ( $lastLog['mlog_date'] >= ( time() - 2 ) and $lastLog['mlog_subject'] == $this->request['subject'] )
+ {
+ $error = $lastLog['mlog_msg'];
+ }
+ else
+ {
+ $this->registry->output->global_message = $this->lang->words['email_tester_ok'];
+ }
+
+ //-----------------------------------------
+ // Show
+ //-----------------------------------------
+
+ $this->_emailCheckerForm( $error );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/diagnostics/xml/menu.xml b/upload/admin/applications/core/modules_admin/diagnostics/xml/menu.xml
index 4a3ceb43..183fd43d 100644
--- a/upload/admin/applications/core/modules_admin/diagnostics/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/diagnostics/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Overview
+ Обзор Системы
- Overview
+ Обзор Системы
diag_overview
diagnostics
@@ -15,10 +15,10 @@
-
-
Whitespace Checker
+ Проверка Пробелов
- Whitespace Checker
+ Проверка Пробелов
whitespace_checker
diagnostics
do=whitespace
@@ -28,10 +28,10 @@
-
-
Permissions Checker
+ Проверка Ограничений ФС
- Permissions Checker
+ Проверка Ограничений ФС
permissions_checker
diagnostics
do=filepermissions
@@ -41,10 +41,10 @@
-
-
Connection Checker
+ Проверка Соединений
- Connection Checker
+ Проверка Соединений
connection_checker
diagnostics
do=connections
@@ -54,10 +54,10 @@
-
-
Database Checker
+ Прверка БД
- Database Checker
+ Проверка БД
db_checker
diagnostics
do=dbchecker
@@ -67,10 +67,10 @@
-
-
Database Index Checker
+ Проверка Индексов БД
- Database Index Checker
+ Проверка Индексов БД
dbi_checker
diagnostics
do=dbindex
@@ -80,10 +80,10 @@
-
-
Email Tester
+ Тест Email
- Email Tester
+ Тест Email
email_checker
diagnostics
do=email
diff --git a/upload/admin/applications/core/modules_admin/diagnostics/xml/permissions.xml b/upload/admin/applications/core/modules_admin/diagnostics/xml/permissions.xml
index dc27ada0..ebd700af 100644
--- a/upload/admin/applications/core/modules_admin/diagnostics/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/diagnostics/xml/permissions.xml
@@ -1,32 +1,32 @@
- Diagnostic Tools
+ Инструменты диагностики
core_diag_tools
-
index_checker
- Can use the database index checker? Warning: Allows ability to run database queries indirectly.
+ Может проверять индексы таблиц базы? Внимание: позволяет выполнять запросы к базе.
-
database_checker
- Can use the database checker? Warning: Allows ability to run database queries indirectly.
+ Может использовать проверку базы данных? Внимание: позволяет выполнять запросы к базе.
-
whitespace_checker
- Can use the whitespace checker?
+ Может проверять файлы на лишние пробелы?
-
connection_checker
- Can use the connection checker?
+ Может использовать проверку сетевых соединений?
-
permission_checker
- Can use the permissions checker?
+ Может проверять файлы и директории на правильность расстановки прав доступа?
-
email_checker
- Can use the email tester?
+ Может проверять работу почты?
diff --git a/upload/admin/applications/core/modules_admin/help/defaultSection.php b/upload/admin/applications/core/modules_admin/help/defaultSection.php
index 84bd77a1..d2249488 100644
--- a/upload/admin/applications/core/modules_admin/help/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/help/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/help/quickhelp.php b/upload/admin/applications/core/modules_admin/help/quickhelp.php
index 3690bd9a..b2e246f5 100644
--- a/upload/admin/applications/core/modules_admin/help/quickhelp.php
+++ b/upload/admin/applications/core/modules_admin/help/quickhelp.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Quick help - shows popups with help information
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 1st march 2002
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/help/xml/menu.xml b/upload/admin/applications/core/modules_admin/help/xml/menu.xml
index f17f3fa3..0e620ef0 100644
--- a/upload/admin/applications/core/modules_admin/help/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/help/xml/menu.xml
@@ -1,77 +1,77 @@
-
-
-
- -
-
Documentation
-
-
- Documentation
- help_documentation
- quickhelp
- do=redirect&id=docs
- 1
-
-
-
- -
-
Technical Support
-
-
- Technical Support
- help_support
- quickhelp
- do=redirect&id=support
- 1
-
-
-
- -
-
Additional Resources
-
-
- Additional Resources
- help_resources
- quickhelp
- do=redirect&id=resources
- 1
-
-
-
- -
-
IPS Contact Information
-
-
- IPS Contact Information
- help_contact
- quickhelp
- do=redirect&id=contact
- 1
-
-
-
- -
-
Feature Requests
-
-
- Feature Requests
- help_features
- quickhelp
- do=redirect&id=features
- 1
-
-
-
- -
-
Report a Bug
-
-
- Report a Bug
- help_bugs
- quickhelp
- do=redirect&id=bugs
- 1
-
-
-
-
+
+
+
+ -
+
Документация
+
+
+ Документация
+ help_documentation
+ quickhelp
+ do=redirect&id=docs
+ 1
+
+
+
+ -
+
Техническая поддержка
+
+
+ Техническая поддержка
+ help_support
+ quickhelp
+ do=redirect&id=support
+ 1
+
+
+
+ -
+
Дополнительные Ресурсы
+
+
+ Дополнительные Ресурсы
+ help_resources
+ quickhelp
+ do=redirect&id=resources
+ 1
+
+
+
+ -
+
Контактная Информация
+
+
+ Контактная Информация
+ help_contact
+ quickhelp
+ do=redirect&id=contact
+ 1
+
+
+
+ -
+
Запрос Функций
+
+
+ Запрос Функций
+ help_features
+ quickhelp
+ do=redirect&id=features
+ 1
+
+
+
+ -
+
Сообщить об Ошибке
+
+
+ Сообщить об Ошибке
+ help_bugs
+ quickhelp
+ do=redirect&id=bugs
+ 1
+
+
+
+
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/languages/defaultSection.php b/upload/admin/applications/core/modules_admin/languages/defaultSection.php
index d371d559..ef475502 100644
--- a/upload/admin/applications/core/modules_admin/languages/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/languages/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/languages/manage_languages.php b/upload/admin/applications/core/modules_admin/languages/manage_languages.php
index 99b92000..35b984ba 100644
--- a/upload/admin/applications/core/modules_admin/languages/manage_languages.php
+++ b/upload/admin/applications/core/modules_admin/languages/manage_languages.php
@@ -1,3026 +1,3061 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Language Pack Management
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @version $Rev: 10914 $
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-class admin_core_languages_manage_languages extends ipsCommand
-{
- /**
- * Daily flag
- *
- * @var bool
- */
- private $__daily = false;
-
- /**
- * Tab buttons
- *
- * @var array
- */
- public $tab_buttons = array();
-
- /**
- * Tabs
- *
- * @var array
- */
- public $tab_tabs = array();
-
- /**
- * Javascript action to execute on tab click
- *
- * @var string
- */
- public $tab_js_action = '';
-
- /**
- * Default tab
- *
- * @var string
- */
- public $default_tab = '';
-
- /**
- * Main class entry point
- *
- * @param object ipsRegistry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- //-----------------------------------------
- // Get skin and language file
- //-----------------------------------------
-
- $this->html = $this->registry->output->loadTemplate( 'cp_skin_system', 'core' );
- $this->registry->class_localization->loadLanguageFile( array( 'admin_system' ), 'core' );
-
- //-----------------------------------------
- // Set urls
- //-----------------------------------------
-
- $this->form_code = $this->html->form_code = 'module=languages§ion=manage_languages&';
- $this->form_code_js = $this->html->form_code_js = 'module=languages§ion=manage_languages&';
-
- //-----------------------------------------
- // Go
- //-----------------------------------------
-
- switch( $this->request['do'] )
- {
- case 'copy_lang_pack':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
- $this->languageCopy();
- break;
-
- case 'edit_word_entry':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
- $this->languageWordEntryForm( 'edit' );
- break;
-
- case 'do_edit_word_entry':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
- $this->handleWordEntryForm( 'edit' );
- break;
-
- case 'add_word_entry':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
- $this->languageWordEntryForm( 'add' );
- break;
-
- case 'do_add_word_entry':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
- $this->handleWordEntryForm( 'add' );
- break;
-
- case 'list_word_packs':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
- $this->languageListWordPacks();
- break;
-
- case 'edit_word_pack':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_packs' );
- $this->languageEditWordPack();
- break;
-
- case 'do_edit_word_pack':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_packs' );
- $this->languageEditWordPackValues();
- break;
-
- case 'edit_lang_info':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_pack_info' );
- $this->languageInformationForm( 'edit' );
- break;
-
- case 'do_edit_lang_info':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_pack_info' );
- $this->handleLanguageInformationForm( 'edit' );
- break;
-
- case 'new_language':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_packs' );
- $this->languageInformationForm( 'new' );
- break;
-
- case 'do_new_language':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_packs' );
- $this->handleLanguageInformationForm( 'new' );
- break;
-
- case 'language_swap':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_pack_info' );
- $this->swapLanguages();
- break;
-
- case 'revert':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
- $this->languageDoRevertWord();
- break;
-
- case 'export':
- $this->languageExportToXML( intval( $this->request['id'] ) );
- break;
-
- case 'language_do_import':
- $this->imprtFromXML( intval( $this->request['id'] ) );
- break;
-
- case 'language_do_indev_export':
- foreach( ipsRegistry::$applications as $app_dir => $app_data )
- {
- $this->request['app_dir'] = $app_dir;
-
- $this->request['type'] = 'admin';
- $this->languageExportToXML( 1, 1 );
-
- $this->request['type'] = 'public';
- $this->languageExportToXML( 1, 1 );
- }
-
- $this->registry->output->setMessage( $this->lang->words['indev_lang_export_done'], 1 );
- $this->languagesList();
- break;
-
- case 'language_do_indev_import':
- $this->importFromCacheFiles();
- break;
-
- case 'remove_language':
- $this->languageRemove();
- break;
-
- case 'remove_word_entry':
- $this->removeWordEntry();
- break;
-
- case 'remove_word_pack':
- $this->removeWordPack();
- break;
-
- case 'rebuildFromXml':
- $this->rebuildFromXml();
- break;
-
- case 'recache_lang_pack':
- $this->recacheLangPack();
- break;
-
- case 'translateExtSplash':
- $this->translateExtSplash();
- break;
-
- case 'translateImport':
- $this->translateImport();
- break;
-
- case 'translateKill':
- $this->translateKill();
- break;
-
- default:
- $this->languagesList();
- break;
- }
-
- //-----------------------------------------
- // Pass to CP output hander
- //-----------------------------------------
-
- $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
- $this->registry->output->sendOutput();
- }
-
- /**
- * Swap member language choice globally
- *
- * @return @e void
- */
- public function swapLanguages()
- {
- /* INIT */
- $langFrom = intval( $this->request['lang_from'] );
- $langTo = intval( $this->request['lang_to'] );
-
- /* Run query... */
- if( !$langFrom )
- {
- $this->DB->update( 'members', array( 'language' => $langTo > 0 ? $langTo : '' ), "language='' OR language " . $this->DB->buildIsNull( true ) );
- }
- else
- {
- $this->DB->update( 'members', array( 'language' => $langTo > 0 ? $langTo : '' ), "language='{$langFrom}'" );
- }
-
- /* Done */
- $this->registry->output->global_message = $this->lang->words['mem_lang_choice_swapped'];
- $this->languagesList();
- return;
- }
-
- /**
- * Finish a session and remove data
- *
- * @return @e void
- */
- public function translateKill()
- {
- /* INIT */
- $langId = intval( $this->request['id'] );
- $mainDir = DOC_IPS_ROOT_PATH . 'translate';
- $words_by_file = array();
- $errors = array();
- $filesToImport = array();
-
- /* Start top message */
- if ( ! is_dir( $mainDir ) )
- {
- /* Just bounce back asking them to create translate */
- $this->registry->output->global_error = $this->lang->words['ext_no_translate_dir'];
- $this->languagesList();
- return;
- }
-
- if ( ! is_writeable( $mainDir ) )
- {
- /* Just bounce back asking them to chmod translate */
- $this->registry->output->global_error = $this->lang->words['ext_chmod_translate_dir'];
- $this->languagesList();
- return;
- }
-
- /* Load kernel class for file management */
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
- $classFileManagement = new $classToLoad();
-
- /* Remove files */
- $classFileManagement->emptyDirectory( $mainDir );
-
- /* Delete session */
- $session = $this->DB->delete( 'cache_store', "cs_key='translate_session'" );
-
- /* Done */
- $this->registry->output->global_message = $this->lang->words['ext_all_killed'];
- $this->languagesList();
- return;
- }
-
- /**
- * Translate externally import changed files
- *
- * @return @e void
- */
- public function translateImport()
- {
- /* INIT */
- $langId = intval( $this->request['id'] );
- $mainDir = DOC_IPS_ROOT_PATH . 'translate';
- $words_by_file = array();
- $errors = array();
- $filesToImport = array();
- $fileCount = 0;
-
- /* Start top message */
- if ( ! is_dir( $mainDir ) )
- {
- /* Just bounce back asking them to create translate */
- $this->registry->output->global_error = $this->lang->words['ext_no_translate_dir'];
- $this->languagesList();
- return;
- }
-
- if ( ! is_writeable( $mainDir ) )
- {
- /* Just bounce back asking them to chmod translate */
- $this->registry->output->global_error = $this->lang->words['ext_chmod_translate_dir'];
- $this->languagesList();
- return;
- }
-
- /* Get file count */
- try
- {
- foreach( new DirectoryIterator( $mainDir ) as $f )
- {
- if ( !$f->isDir() )
- {
- $fileCount++;
- }
- }
- }
- catch ( Exception $e )
- {
- $fileCount = 0;
- }
-
- /* Get lang */
- $lang = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => 'lang_id=' . $langId ) );
-
- /* Get current session if one */
- $sessionData = $this->cache->getCache('translate_session');
-
- /* Check */
- if ( empty( $sessionData['lang_id'] ) OR ! count( $sessionData['files'] ) OR !$fileCount )
- {
- /* Just bounce back asking them to create translate */
- $this->registry->output->global_error = $this->lang->words['ext_no_translate_files'];
- $this->languagesList();
- return;
- }
-
- /* Still here? Okay */
- if ( is_array( $_POST['cb'] ) AND count( $_POST['cb'] ) )
- {
- /* Gather a list of files to import */
- foreach( $_POST['cb'] as $file => $value )
- {
- if ( $_POST['cb'][ $file ] )
- {
- $filesToImport[ $file ] = $file;
- }
- }
-
- /* Assume nothing */
- if ( count( $filesToImport ) )
- {
- $counts = $this->_importFromDisk( $mainDir, $sessionData['lang_id'], array_keys( $filesToImport ), true );
-
- foreach( $counts as $file => $data )
- {
- /* Update session data */
- $sessionData['files'][ $file ]['dbtime'] = time();
-
- $this->registry->output->global_message = sprintf( $this->lang->words['ext_file_written'], $file, intval( $data['inserts'] ), intval( $data['updates'] ) );
- }
-
- $this->registry->output->global_message .= ' ' . sprintf( $this->lang->words['ext_recache'], "{$this->settings['base_url']}&{$this->form_code}&do=recache_lang_pack&id={$sessionData['lang_id']}" );
-
- /* Update session */
- $this->cache->setCache( 'translate_session', $sessionData, array( 'array' => 1, 'donow' => 1 ) );
-
- $this->translateExtSplash();
- return;
- }
- }
- else
- {
- /* Just bounce back asking them to create translate */
- $this->registry->output->global_error = $this->lang->words['ext_no_selected_files'];
- $this->translateExtSplash();
- return;
- }
- }
-
- /**
- * Translate externally splash
- *
- * @return @e void
- */
- public function translateExtSplash()
- {
- /* INIT */
- $langId = intval( $this->request['id'] );
- $mainDir = DOC_IPS_ROOT_PATH . 'translate';
- $words_by_file = array();
- $errors = array();
-
- /* Start top message */
- if ( ! is_dir( $mainDir ) )
- {
- /* Just bounce back asking them to create translate */
- $this->registry->output->global_error = $this->lang->words['ext_no_translate_dir'];
- $this->languagesList();
- return;
- }
-
- if ( ! is_writeable( $mainDir ) )
- {
- /* Just bounce back asking them to chmod translate */
- $this->registry->output->global_error = $this->lang->words['ext_chmod_translate_dir'];
- $this->languagesList();
- return;
- }
-
- /* Load kernel class for file management */
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
- $classFileManagement = new $classToLoad();
-
- /* Get lang */
- $lang = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => 'lang_id=' . $langId ) );
-
- /* Get current session if one */
- $session = $this->DB->buildandFetch( array( 'select' => '*', 'from' => 'cache_store', 'where' => "cs_key='translate_session'" ) );
- $sessionData = ( strstr( $session['cs_value'], 'a:' ) ) ? unserialize( $session['cs_value'] ) : array();
-
- /* No current session? */
- if ( empty( $sessionData['lang_id'] ) OR ! count( $sessionData['files'] ) )
- {
- /* Ensure directory is empty */
- $classFileManagement->emptyDirectory( $mainDir );
-
- /* Ensure it's gone, gone */
- $this->DB->delete( 'cache_store', "cs_key='translate_session'" );
- $sessionData = $lang;
- $sessionData['files'] = array();
- $header = "/*******************************************************\nNOTE: This is a translatable file generated by IP.Board " . IPB_VERSION . " (" . IPB_LONG_VERSION . ") on " . date( "r" ) . " by " . $this->memberData['members_display_name'] . "\nPLEASE set your text editor to save this document as UTF-8 regardless of your board's character-set\n*******************************************************/\n\n";
-
- /* Export all the languages into flat files */
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => 'lang_id=' . $langId, 'order' => 'word_custom_version DESC, word_default_version DESC' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $_text = ( $r['word_custom'] ) ? $r['word_custom'] : $r['word_default'];
- $_version = ( $r['word_custom_version'] ) ? $r['word_custom_version'] : $r['word_default_version'];
- $words_by_file[$r['word_app']][$r['word_pack']][] = array( $r['word_key'], $_text );
- }
-
- //-----------------------------------------
- // Now loop and write to file
- //-----------------------------------------
-
- foreach( $words_by_file as $app => $word_packs )
- {
- foreach( $word_packs as $pack => $words )
- {
- if( $pack == 'public_js' )
- {
- $to_write = '';
- $_file = 'ipb.lang.js';
-
- foreach( $words as $word )
- {
- $word[1] = str_replace( '"', '\\"', $word[1] );
- $to_write .= "ipb.lang['{$word[0]}'] = \"{$word[1]}\";\n";
- }
- }
- else if( $pack == 'admin_js' )
- {
- $to_write = '';
- $_file = 'acp.lang.js';
-
- foreach( $words as $word )
- {
- $word[1] = str_replace( '"', '\\"', $word[1] );
- $to_write .= "ipb.lang['{$word[0]}'] = \"{$word[1]}\";\n";
- }
- }
- else
- {
- //-----------------------------------------
- // Build cache file contents
- //-----------------------------------------
-
- $to_write = " \"{$word[1]}\",\n";
- }
-
- $to_write .= " ); \n";
- }
-
- //-----------------------------------------
- // Convert data
- //-----------------------------------------
-
- $to_write = IPSText::convertCharsets( $to_write, IPS_DOC_CHAR_SET, 'UTF-8' );
-
- //-----------------------------------------
- // Write the file
- //-----------------------------------------
-
- @unlink( $mainDir . '/' . $_file );
-
- if ( $fh = @fopen( $mainDir . '/' . $_file, 'wb' ) )
- {
- fwrite( $fh, $to_write, strlen( $to_write ) );
- fclose( $fh );
- @chmod( $mainDir . '/' . $_file, IPS_FILE_PERMISSION );
-
- $mtime = @filemtime( $mainDir . '/' . $_file );
-
- $sessionData['files'][ $_file ] = array( 'mtime' => $mtime, 'dbtime' => $mtime );
- }
- else
- {
- $errors[] = $this->lang->words['l_nowrite'] . $mainDir . '/' . $_file;
- }
- }
- }
-
- /* Sort files */
- ksort( $sessionData['files'] );
-
- /* Save session */
- $this->DB->insert( 'cache_store', array( 'cs_key' => 'translate_session',
- 'cs_value' => serialize( $sessionData ),
- 'cs_array' => 1,
- 'cs_updated' => time() ) );
-
- }
- else
- {
- /* Update mtime */
- foreach( $sessionData['files'] as $file => $data )
- {
- $sessionData['files'][ $file ]['mtime'] = @filemtime( $mainDir . '/' . $file );
- }
- }
-
- //-----------------------------------------
- // Output
- //-----------------------------------------
-
- $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}&{$this->form_code}&do=translateExtSplash&id={$sessionData['lang_id']}", "{$this->lang->words['ext_title_for']} {$sessionData['lang_title']}" );
-
- $this->registry->output->html .= $this->html->languages_translateExt( $sessionData, $lang );
- }
-
- /**
- * Import files from disk
- *
- * @param string Directory to look in
- * @param int Language ID to import into
- * @param array [Only import these files]
- * @param boolean [Perform character set translation from UTF-8]
- * @return array List of files successfully imported
- */
- private function _importFromDisk( $mainDir, $langId, $onlyTheseFiles=array(), $convertCharSet=false )
- {
- /* INIT */
- $imported = array();
- $lang_entries = array();
- $js_entries = array();
- $counts = array();
-
- /* Start looping */
- if ( is_dir( $mainDir ) )
- {
- $dh = opendir( $mainDir );
-
- /* Ensure it has a trailing slash */
- if ( substr( $mainDir, -1 ) != '/' )
- {
- $mainDir .= '/';
- }
-
- while( $f = readdir( $dh ) )
- {
- if ( $f[0] == '.' || $f == 'index.html' )
- {
- continue;
- }
-
- /* Skipping? */
- if ( is_array( $onlyTheseFiles ) AND count( $onlyTheseFiles ) AND ! in_array( $f, $onlyTheseFiles ) )
- {
- continue;
- }
-
- if ( preg_match( '#^\S+?_\S+?\.php$#', $f ) )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $updated = 0;
- $inserted = 0;
- $app = preg_replace( '#^([^_]+?)_(\S+?)\.php$#', "\\1", $f );
- $word_pack = preg_replace( '#^([^_]+?)_(\S+?)\.php$#', "\\2", $f );
- $lang = array();
- $db_lang = array();
-
- $counts[ $f ] = array();
-
- if ( ! is_file( $mainDir . $f ) )
- {
- continue;
- }
-
- /* Require the file */
- require( $mainDir . $f );/*noLibHook*/
-
- //-----------------------------------------
- // Loop
- //-----------------------------------------
-
- foreach( $lang as $k => $v )
- {
- //-----------------------------------------
- // Build db array
- //-----------------------------------------
-
- $db_array = array(
- 'lang_id' => $langId,
- 'word_app' => $app,
- 'word_pack' => $word_pack,
- 'word_key' => $k,
- 'word_custom' => IPSText::convertCharsets($v, 'UTF-8', IPS_DOC_CHAR_SET ),
- 'word_js' => 0
- );
-
- //-----------------------------------------
- // If cached, get from cache
- //-----------------------------------------
-
- if( $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ] )
- {
- $lang_entry = $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ];
- }
-
- //-----------------------------------------
- // Otherwise get all langs from this entry and
- // put in cache
- //-----------------------------------------
-
- else
- {
- $this->DB->build( array(
- 'select' => '*',
- 'from' => 'core_sys_lang_words',
- 'where' => "lang_id={$langId} AND word_app='{$db_array['word_app']}' AND word_pack='{$db_array['word_pack']}'"
- ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $lang_entries[ $r['lang_id'] ][ $r['word_app'] ][ $r['word_pack'] ][ $r['word_key'] ] = $r;
- }
-
- if( $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ] )
- {
- $lang_entry = $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ];
- }
- }
-
- /* Finish off */
- $db_array['word_default'] = $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ]['word_default'];
- $db_array['word_default_version'] = $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ]['word_default_version'];
- $db_array['word_custom_version'] = IPB_LONG_VERSION;
-
- //-----------------------------------------
- // If there is no new custom lang bit to insert
- // don't delete what is already there.
- //-----------------------------------------
-
- if( ! $db_array['word_custom'] )
- {
- unset($db_array['word_custom']);
- }
-
- //-----------------------------------------
- // Lang bit already exists, update
- //-----------------------------------------
-
- if( $lang_entry['word_id'] )
- {
- //-----------------------------------------
- // Don't update default version
- //-----------------------------------------
-
- unset( $db_array['word_default_version'] );
-
- $counts[ $f ]['updates']++;
- $this->DB->update( 'core_sys_lang_words', $db_array, "word_id={$lang_entry['word_id']}" );
- }
-
- //-----------------------------------------
- // Lang bit doesn't exist, so insert
- //-----------------------------------------
-
- else if( !$lang_entry['word_id'] )
- {
- $counts[ $f ]['inserts']++;
- $this->DB->insert( 'core_sys_lang_words', $db_array );
- }
- }
- }
- else if( preg_match( '/(\.js)$/', $f ) )
- {
- $_js_word_pack = '';
-
- if( $f == 'ipb.lang.js' )
- {
- $_js_word_pack = 'public_js';
- }
- else if( $f == 'acp.lang.js' )
- {
- $_js_word_pack = 'admin_js';
- }
-
- //-----------------------------------------
- // If not cached, get it
- //-----------------------------------------
-
- if( !$js_entries[ $langId ][ $_js_word_pack ] )
- {
- $this->DB->build( array(
- 'select' => '*',
- 'from' => 'core_sys_lang_words',
- 'where' => "lang_id={$langId} AND word_pack='{$_js_word_pack}'"
- ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $js_entries[ $r['word_pack'] ][ $r['word_key'] ] = $r;
- }
- }
-
- //-----------------------------------------
- // Delete current words for this app and word pack
- //-----------------------------------------
-
- $this->DB->delete( 'core_sys_lang_words', 'lang_id=' . $langId . " AND word_app='core' AND word_pack='" . $_js_word_pack . "'" );
-
- //-----------------------------------------
- // Get each line
- //-----------------------------------------
-
- $js_file = file( $mainDir . $f );
-
- //-----------------------------------------
- // Loop through lines and import
- //-----------------------------------------
-
- foreach( $js_file as $r )
- {
- //-----------------------------------------
- // preg_match what we want
- //-----------------------------------------
-
- preg_match( '#ipb\.lang\[\'(.+?)\'\](.+?)= ["\'](.+?)["\'];#', $r, $matches );
-
- //-----------------------------------------
- // Valid?
- //-----------------------------------------
-
- if( $matches[1] && $matches[3] )
- {
- $counts[ $f ]['inserts']++;
- $insert = array(
- 'lang_id' => $langId,
- 'word_app' => 'core',
- 'word_pack' => $_js_word_pack,
- 'word_key' => $matches[1],
- 'word_custom' => IPSText::convertCharsets($matches[3], 'UTF-8', IPS_DOC_CHAR_SET ),
- 'word_js' => 1,
- 'word_default' => $js_entries[ $_js_word_pack ][ $matches[1] ]['word_default'],
- 'word_default_version' => $js_entries[ $_js_word_pack ][ $matches[1] ]['word_default_version'],
- 'word_custom_version' => IPB_LONG_VERSION,
- );
-
- $this->DB->insert( 'core_sys_lang_words', $insert );
- }
- }
- }
- }
-
- closedir( $dh );
- }
-
- return $counts;
- }
-
-
- /**
- * Recaches a language pack
- *
- * @return @e void
- */
- public function recacheLangPack()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $this->cache_errors = array();
-
- $lang_id = intval( $this->request['id'] );
-
- $this->cacheToDisk( $lang_id );
-
- $this->registry->output->global_message = $this->lang->words['language_recache_done'] . ( !empty( $this->cache_errors ) ? ( " " . implode( " ", $this->cache_errors ) ) : '' );
- $this->languagesList();
- }
-
- /**
- * Remove a word entry
- *
- * @return @e void
- */
- public function removeWordEntry()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $word_id = intval($this->request['word_id']);
- $lang_id = intval( $this->request['id'] );
-
- //-----------------------------------------
- // Delete lang bit
- //-----------------------------------------
-
- $this->DB->delete( 'core_sys_lang_words', 'word_id=' . $word_id );
-
- //-----------------------------------------
- // Recache to disk
- //-----------------------------------------
-
- $this->cacheToDisk( $lang_id );
-
- //-----------------------------------------
- // Bounce to new URL
- //-----------------------------------------
-
- $this->request['secure_key'] = $this->registry->adminFunctions->generated_acp_hash;
- $this->registry->output->global_message = $this->lang->words['language_word_removed'];
- $this->languageEditWordPack();
- }
-
- /**
- * Remove a word pack
- *
- * @return @e void
- */
- public function removeWordPack()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $pack = explode( '/', $this->request['word_pack'] );
- $lang_id = intval( $this->request['id'] );
-
- if( $lang_id )
- {
- //-----------------------------------------
- // Delete from DB
- //-----------------------------------------
-
- $this->DB->delete( 'core_sys_lang_words', "lang_id='{$lang_id}' AND word_pack='" . $pack[1] . "' AND word_app='" . $pack[0] . "'" );
-
- //-----------------------------------------
- // Delete from disk
- //-----------------------------------------
-
- $_file = IPS_CACHE_PATH . 'cache/lang_cache/' . $lang_id . '/' . $pack[0] . '_' . $pack[1] . '.php';
-
- if( is_file( $_file ) )
- {
- @unlink( $_file );
- }
-
- //-----------------------------------------
- // And recache
- //-----------------------------------------
-
- $this->cacheToDisk( $lang_id );
- }
-
- //-----------------------------------------
- // Bounce back
- //-----------------------------------------
-
- $this->request['secure_key'] = $this->registry->adminFunctions->generated_acp_hash;
- $this->registry->output->global_message = $this->lang->words['language_wordpack_removed'];
- $this->languageListWordPacks();
- }
-
- /**
- * Rebuilds language from XML files
- *
- * @return @e void
- */
- public function rebuildFromXml()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $apps = array();
- $previous = trim( $this->request['previous'] );
- $type = trim( $this->request['type'] );
- $id = intval($this->request['id']);
- $_word = ( $type == 'admin' ) ? 'admin' : 'public';
-
- //-----------------------------------------
- // Verify writable
- //-----------------------------------------
-
- if ( ! is_writeable( IPS_CACHE_PATH . 'cache/lang_cache/' . $id ) )
- {
- $this->registry->output->global_error = $this->lang->words['cannot_write_to_cache'] ? sprintf( $this->lang->words['cannot_write_to_cache'], $id ) : "Cannot write to cache/lang_cache/" . $id;
- $this->languagesList();
- return;
- }
-
- //-----------------------------------------
- // Get setup class
- //-----------------------------------------
-
- require_once( IPS_ROOT_PATH . "setup/sources/base/setup.php" );/*noLibHook*/
-
- //-----------------------------------------
- // Get apps
- //-----------------------------------------
-
- foreach( ipsRegistry::$applications as $appDir => $appData )
- {
- $apps[] = $appDir;
- }
-
- //-----------------------------------------
- // Klude for setup class
- //-----------------------------------------
-
- IPSSetUp::setSavedData( 'install_apps', implode( ',', $apps ) );
-
- //-----------------------------------------
- // Get next app
- //-----------------------------------------
-
- $next = IPSSetUp::fetchNextApplication( $previous, '', $this->settings['gb_char_set'] );
-
- if ( $next['key'] )
- {
- $msg = $next['title'] . sprintf( $this->lang->words['importing_x_langs'], $_word );
- $_PATH = IPSLib::getAppDir( $next['key'] ) . '/xml/';
-
- //-----------------------------------------
- // Try to import all the lang packs
- //-----------------------------------------
-
- try
- {
- foreach( new DirectoryIterator( $_PATH ) as $f )
- {
- if ( preg_match( "#" . $_word . "_(.+?)_language_pack.xml#", $f->getFileName() ) )
- {
- $this->request['file_location'] = $_PATH . $f->getFileName();
- $this->imprtFromXML( 1, true, true, $next['key'] );
- }
- }
- } catch ( Exception $e ) {}
-
- //-----------------------------------------
- // Off to next setp
- //-----------------------------------------
-
- $this->registry->output->html .= $this->registry->output->global_template->temporaryRedirect( $this->settings['base_url'] . $this->form_code . "do=rebuildFromXml&id={$id}&type={$type}&previous=" . $next['key'], $msg . ' ' . $this->registry->output->global_message );
- $this->registry->output->global_message = '';
- return;
- }
- else
- {
- if ( $type == 'public' )
- {
- //-----------------------------------------
- // Onto admin languages
- //-----------------------------------------
-
- $this->registry->output->html .= $this->registry->output->global_template->temporaryRedirect( $this->settings['base_url'] . $this->form_code . "do=rebuildFromXml&id={$id}&type=admin", $this->lang->words['starting_admin_import'] );
- return;
- }
- else
- {
- //-----------------------------------------
- // And we're done
- //-----------------------------------------
-
- $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code, $this->lang->words['lang_reimport_done'] );
- }
- }
- }
-
- /**
- * Copies a language pack
- *
- * @return void
- */
- public function languageCopy()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $id = intval( $this->request['id'] );
-
- //-----------------------------------------
- // Get lang pack
- //-----------------------------------------
-
- $lang_info = $this->DB->buildAndFetch( array( 'select' => 'lang_short, lang_title, lang_isrtl', 'from' => 'core_sys_lang', 'where' => "lang_id={$id}" ) );
-
- $lang_info['lang_title'] .= " (COPY)";
-
- //-----------------------------------------
- // Insert language pack
- //-----------------------------------------
-
- $this->DB->insert( 'core_sys_lang', $lang_info );
- $new_id = $this->DB->getInsertID();
-
- //-----------------------------------------
- // Copy the language bits now
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$id}" ) );
- $q = $this->DB->execute();
-
- while( $r = $this->DB->fetch( $q ) )
- {
- unset( $r['word_id'] );
- $r['lang_id'] = $new_id;
-
- $this->DB->insert( 'core_sys_lang_words', $r );
- }
-
- //-----------------------------------------
- // Recache and redirect
- //-----------------------------------------
-
- $this->cacheToDisk( $new_id );
- $this->registry->class_localization->rebuildLanguagesCache();
-
- $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code, $this->lang->words['l_copied'] );
- }
-
- /**
- * Removes a language pack and cleans up files
- *
- * @return void
- */
- public function languageRemove()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $id = intval( $this->request['id'] );
-
- //-----------------------------------------
- // Make sure this isn't default pack
- //-----------------------------------------
-
- $langCheck = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => 'lang_id=' . $id ) );
-
- if( $langCheck['lang_default'] )
- {
- $this->registry->output->showError( $this->lang->words['cannot_delete_default_lang'] );
- }
-
- if( $langCheck['lang_protected'] AND !IN_DEV )
- {
- $this->registry->output->showError( $this->lang->words['cannot_delete_protected_lang'] );
- }
-
- //-----------------------------------------
- // Delete from database
- //-----------------------------------------
-
- $this->DB->delete( 'core_sys_lang' , "lang_id={$id}" );
- $this->DB->delete( 'core_sys_lang_words', "lang_id={$id}" );
-
- //-----------------------------------------
- // Delete from disk
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . '/classFileManagement.php', 'classFileManagement' );
- $fileManagement = new $classToLoad();
- $fileManagement->removeDirectory( IPS_CACHE_PATH . 'cache/lang_cache/' . $id . '/' );
-
- //-----------------------------------------
- // Update member default choice
- //-----------------------------------------
- $default = $this->DB->buildAndFetch( array( 'select' => 'lang_id', 'from' => 'core_sys_lang', 'where' => "lang_default=1" ) );
- $this->DB->update( 'members', array( 'language' => intval($default['lang_id']) ), "language={$id}" );
-
- //-----------------------------------------
- // Update cache and redirect
- //-----------------------------------------
-
- $this->registry->class_localization->rebuildLanguagesCache();
- $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code, $this->lang->words['l_removed'] );
- }
-
- /**
- * Revert a word pack entry to the default value
- *
- * @return @e void
- */
- public function languageDoRevertWord()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $word_id = intval( $this->request['word_id'] );
- $lang_id = intval( $this->request['id'] );
- $pack = explode( '/', $this->request['word_pack'] );
-
- //-----------------------------------------
- // Revert
- //-----------------------------------------
-
- $this->DB->update( 'core_sys_lang_words', array( 'word_custom' => '' ), "word_id={$word_id}" );
-
- //-----------------------------------------
- // Recache
- //-----------------------------------------
-
- $this->cacheToDisk( $lang_id );
-
- //-----------------------------------------
- // Redirect
- //-----------------------------------------
-
- $this->request['secure_key'] = $this->registry->adminFunctions->generated_acp_hash;
- $this->registry->output->global_message = $this->lang->words['language_word_revert'];
- $this->languageEditWordPack();
- }
-
- /**
- * Saves new language edits
- *
- * @return @e void
- */
- public function languageEditWordPackValues()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $id = intval( $this->request['id'] );
-
- $langCheck = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => 'lang_id=' . $id ) );
-
- if( $langCheck['lang_protected'] AND !IN_DEV )
- {
- $this->registry->output->showError( $this->lang->words['lang_pack_protected'] );
- }
-
- //-----------------------------------------
- // Loop through language bits submitted
- //-----------------------------------------
-
- if( is_array( $_POST['lang'] ) && count( $_POST['lang'] ) )
- {
- foreach( $_POST['lang'] as $k => $v )
- {
- if( $v )
- {
- $v = IPSText::safeSlashes($v);
- $v = str_replace( '\', '\\', $v );
-
- $this->DB->update( 'core_sys_lang_words', "word_custom='" . $this->DB->addSlashes( $v ) . "', word_custom_version=word_default_version", "word_id=" . intval($k), false, true );
- }
- }
- }
-
- //-----------------------------------------
- // Recache and redirect
- //-----------------------------------------
-
- $this->cacheToDisk( $id );
-
- $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code . "&do=edit_word_pack&word_pack={$this->request['pack']}&id={$this->request['id']}&search={$this->request['search']}&filter={$this->request['filter']}&st={$this->request['st']}", $this->lang->words['language_word_pack_edited'] );
- }
-
- /**
- * Handles the word entry form
- *
- * @param string $mode Either add or edit
- * @return @e void
- */
- public function handleWordEntryForm( $mode='add' )
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $lang_id = intval( $this->request['id'] );
- $word_id = intval( $this->request['word_id'] );
- $LATESTVERSION = IPSLib::fetchVersionNumber();
-
- //-----------------------------------------
- // Error checking
- //-----------------------------------------
-
- if( ! $this->request['word_pack_db'] )
- {
- $this->registry->output->global_error = $this->lang->words['l_packreq'];
- $this->languageWordEntryForm( $mode );
- return;
- }
-
- if( ! $this->request['word_key'] )
- {
- $this->registry->output->global_error = $this->lang->words['l_keyreq'];
- $this->languageWordEntryForm( $mode );
- return;
- }
-
- if( ! $this->request['word_default'] )
- {
- $this->registry->output->global_error = $this->lang->words['l_textreq'];
- $this->languageWordEntryForm( $mode );
- return;
- }
-
- $this->request['word_app'] = strtolower($this->request['word_app']);
- $this->request['word_pack_db'] = str_replace( '/', '_', strtolower($this->request['word_pack_db']) );
-
- if( $this->request['word_pack_db'] == 'admin_js' OR $this->request['word_pack_db'] == 'public_js' )
- {
- $this->request['word_app'] = 'core';
- }
-
- //-----------------------------------------
- // Build DB insert array
- //-----------------------------------------
-
- $db_array = array(
- 'lang_id' => $lang_id,
- 'word_app' => $this->request['word_app'],
- 'word_pack' => $this->request['word_pack_db'],
- 'word_key' => $this->request['word_key'],
- 'word_default' => IPSText::formToText( $_POST['word_default'] ),
- );
-
- //-----------------------------------------
- // Add or update
- //-----------------------------------------
-
- if( $mode == 'add' )
- {
- /* Check for a duplicate */
- $_check = $this->DB->buildAndFetch( array( 'select' => 'word_id', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id} AND word_app='{$db_array['word_app']}' AND word_pack='{$db_array['word_pack']}' AND word_key='{$db_array['word_key']}'" ) );
-
- if( $_check['word_id'] )
- {
- $this->registry->output->global_error = $this->lang->words['l_textexistsalready'];
- $this->languageWordEntryForm( $mode );
- return;
- }
-
- $this->DB->insert( 'core_sys_lang_words', $db_array );
-
- $text = $this->lang->words['l_added'];
- }
- else
- {
- $this->DB->update( 'core_sys_lang_words', $db_array, "word_id={$word_id}" );
-
- $text = $this->lang->words['l_updated'];
- }
-
- //-----------------------------------------
- // Recache and redirect
- //-----------------------------------------
-
- $this->cacheToDisk( $lang_id );
-
- $this->registry->output->redirect( "{$this->settings['base_url']}&module=languages§ion=manage_languages&do=list_word_packs&id={$lang_id}", $text );
- }
-
- /**
- * Form for adding/editing a word entry
- *
- * @param string $mode Either add or edit
- * @return @e void
- */
- public function languageWordEntryForm( $mode='add' )
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $word_id = intval( $this->request['word_id'] );
- $lang_id = intval( $this->request['id'] );
- $pack = explode( '/', $this->request['word_pack'] );
-
- //-----------------------------------------
- // Adding or editing
- //-----------------------------------------
-
- if( $mode == 'add' )
- {
- $op = 'do_add_word_entry';
- $title = $this->lang->words['l_addnew'];
- $header = $this->lang->words['l_addnewfull'];
- $button = $this->lang->words['l_addthis'];
- $data = array( 'word_pack' => $pack[1], 'word_app' => $pack[0] );
- }
- else
- {
- $op = 'do_edit_word_entry';
- $title = $this->lang->words['l_edit'];
- $header = $this->lang->words['l_editentry'];
- $button = $this->lang->words['l_savechanges'];
-
- //-----------------------------------------
- // Get data
- //-----------------------------------------
-
- $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "word_id={$word_id}" ) );
- }
-
- //-----------------------------------------
- // Set defaults
- //-----------------------------------------
-
- $data['word_app'] = !empty( $this->request['word_app'] ) ? $this->request['word_app'] : $data['word_app'];
- $data['word_pack'] = !empty( $this->request['word_pack_db'] ) ? $this->request['word_pack_db'] : $data['word_pack'];
- $data['word_key'] = !empty( $this->request['word_key'] ) ? $this->request['word_key'] : $data['word_key'];
- $data['word_default'] = !empty( $this->request['word_default'] ) ? $this->request['word_default'] : $data['word_default'];
-
- //-----------------------------------------
- // Applications dropdown
- //-----------------------------------------
-
- $_apps = array();
-
- foreach( ipsRegistry::$applications as $app => $appdata )
- {
- $_apps[] = array( $app, $appdata['app_title'] );
- }
-
- $data['word_app'] = $this->compileSelectOptions( $_apps, $data['word_app'] );
-
- //-----------------------------------------
- // Output form
- //-----------------------------------------
-
- $this->registry->output->html .= $this->html->languageWordEntryForm( $op, $word_id, $lang_id, $title, $header, $data, $button );
- }
-
- /**
- * Creates an option list for select tags
- *
- * @param array $options Array of values/text for dropdown
- * @param mixed [$selected] Selected value or array of selected values
- * @return string
- */
- public function compileSelectOptions( $options, $selected='' )
- {
- if( ! is_array( $selected ) )
- {
- $selected = array( $selected );
- }
-
- $html = '';
- if( is_array( $options ) )
- {
- foreach( $options as $option )
- {
- $sel = ( $option[0] AND in_array( $option[0], $selected ) ) ? ' selected="selected"' : '';
- $val = ( $option[0] == 'disabled' ) ? 'disabled="disabled"' : "value='{$option[0]}'";
-
- $html .= "{$option[1]} ";
- }
- }
-
- return $html;
- }
-
- /**
- * Adds the button and content to the tab list for this object
- *
- * @param string $button
- * @param string $content
- * @param string [$js_action]
- * @return @e void
- */
- public function addTab( $button, $content, $js_action='', $default_tab=0 )
- {
- $this->tab_buttons[] = $button;
- $this->tab_tabs[] = $content;
- $this->tab_js_action[] = $js_action;
-
- if( $default_tab )
- {
- $this->default_tab = count( $this->tab_tabs ) - 1;
- }
- }
-
- /**
- * Builds the html for the tabbed area
- *
- * @return string Tab HTML
- */
- public function buildTabs()
- {
- /* Buttons */
- $i = 0;
- $tabs = array();
- foreach( $this->tab_buttons as $i => $button )
- {
- /* Tab Button */
- $js = ( $this->tab_js_action[$i] ) ? 'onmousedown="'.$this->tab_js_action[$i].'"' : '';
- $tabs[] = array( 'id' => $i, 'text' => $button, 'js' => $js );
- }
-
- /* Tab Contents */
- $i = 0;
- $content = array();
- foreach( $this->tab_tabs as $tab )
- {
- /* Create the pane */
- $content[] = array( 'id' => $i, 'content' => $tab );
- $i++;
- }
-
- $default_tab = ( $this->default_tab ) ? $this->default_tab : '';
-
- /* End of tab pane */
- $tabs = $this->html->ui_content_tabs( $tabs, $content, $default_tab );
-
- return $tabs;
- }
-
- /**
- * Edit the entries in a word pack
- *
- * @return @e void
- */
- public function languageEditWordPack()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- /* Fix up for search */
- $keywordForPageLinks = $this->request['search'];
- $this->request['search'] = str_replace( "'", "\\'", $this->request['search'] );
-
- $id = intval( $this->request['id'] );
- $pack = explode( '/', $this->request['word_pack'] );
- $per_page = 20;
- $st = $this->request['st'] ? intval( $this->request['st'] ) : 0;
- $search = $this->request['search'] ? " AND ( word_default LIKE '%" . $this->request['search'] . "%' OR word_custom LIKE '%" . $this->request['search'] . "%' OR word_key LIKE '%" . $this->request['search'] . "%' )" : '';
- $filter = $this->request['filter'] ? " AND word_custom_version < word_default_version AND word_custom " . $this->DB->buildIsNull(false) . ' ' : '';
- $wp_query = $pack[0] && $pack[1] ? " AND word_app='{$pack[0]}' AND word_pack='{$pack[1]}' " : '';
-
- //-----------------------------------------
- // Get language pack
- //-----------------------------------------
-
- $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$id}" ) );
-
- //-----------------------------------------
- // How many words?
- //-----------------------------------------
-
- $count = $this->DB->buildAndFetch( array(
- 'select' => 'COUNT(*) as count',
- 'from' => 'core_sys_lang_words',
- 'where' => "lang_id={$id} {$wp_query} {$search} {$filter}"
- ) );
-
- //-----------------------------------------
- // Pagination
- //-----------------------------------------
-
- $pages = $this->registry->output->generatePagination( array(
- 'totalItems' => intval( $count['count'] ),
- 'itemsPerPage' => $per_page,
- 'currentStartValue' => $st,
- 'baseUrl' => "{$this->settings['base_url']}{$this->form_code}&do=edit_word_pack&word_pack=".implode( '/', $pack )."&id={$id}&search={$keywordForPageLinks}&filter={$this->request['filter']}",
- ) );
-
- //-----------------------------------------
- // Get the words
- //-----------------------------------------
-
- $this->DB->build( array(
- 'select' => '*',
- 'from' => 'core_sys_lang_words',
- 'where' => "lang_id={$id} {$wp_query} {$search} {$filter}",
- 'limit' => array( $st, $per_page ),
- 'order' => 'word_key ASC'
- ) );
- $this->DB->execute();
-
- $lang = array();
-
- while( $r = $this->DB->fetch() )
- {
- $lang[] = array(
- 'id' => $r['word_id'],
- 'default' => nl2br( htmlspecialchars( $r['word_default'], ENT_QUOTES ) ),
- 'custom' => htmlspecialchars( $r['word_custom'], ENT_QUOTES ),
- 'pack' => $r['word_app'] . '/' . $r['word_pack'],
- 'key' => $r['word_key']
- );
- }
-
- //-----------------------------------------
- // Output
- //-----------------------------------------
-
- $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=list_word_packs&id={$id}", $data['lang_title'] );
- $this->registry->output->extra_nav[] = array( '', $this->lang->words['language_word_pack_edit'] );
- $this->registry->output->html .= $this->html->languageWordPackEdit( $id, $lang, $pages );
- }
-
- /**
- * List the word packs available for the selected language set
- *
- * @return @e void
- * @author Josh
- */
- public function languageListWordPacks()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $id = intval( $this->request['id'] );
-
- //-----------------------------------------
- // Get language pack
- //-----------------------------------------
-
- $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$id}" ) );
-
- $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=list_word_packs&id={$data['lang_id']}", $data['lang_title'] );
-
- //-----------------------------------------
- // Get words
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$id}" ) );
- $this->DB->execute();
-
- //-----------------------------------------
- // Some init before looping
- //-----------------------------------------
-
- $_packs = array();
- $_missing = array();
- $_stats = array();
-
- while( $r = $this->DB->fetch() )
- {
- //-----------------------------------------
- // Create our array
- //-----------------------------------------
-
- $_stats[$r['word_app']] = isset( $_stats[$r['word_app']] ) ? $_stats[$r['word_app']] : array();
- $_stats[$r['word_app']][$r['word_pack']] = isset( $_stats[$r['word_app']][$r['word_pack']] ) ? $_stats[$r['word_app']][$r['word_pack']] : array();
- $_stats[$r['word_app']][$r['word_pack']]['total'] = isset( $_stats[$r['word_app']][$r['word_pack']]['total'] ) ? $_stats[$r['word_app']][$r['word_pack']]['total'] : 0;
-
- if( ! isset( $_packs[$r['word_app']] ) )
- {
- $_packs[$r['word_app']] = array();
- }
-
- //-----------------------------------------
- // Add this language pack to array
- //-----------------------------------------
-
- if( ! in_array( $r['word_pack'], $_packs[$r['word_app']] ) )
- {
- $_packs[$r['word_app']][] = $r['word_pack'];
- }
-
- //-----------------------------------------
- // Update stats
- //-----------------------------------------
-
- $_stats[$r['word_app']][$r['word_pack']]['total']++;
-
- if( $r['word_custom'] )
- {
- $_stats[$r['word_app']][$r['word_pack']]['custom']++;
-
- if( $r['word_custom_version'] < $r['word_default_version'] )
- {
- $_stats[$r['word_app']][$r['word_pack']]['outofdate']++;
- }
- }
- }
-
- //-----------------------------------------
- // Loop through applications
- //-----------------------------------------
-
- foreach( ipsRegistry::$applications as $app => $data )
- {
- //-----------------------------------------
- // Check if app has langs
- //-----------------------------------------
-
- if( isset( $_packs[$app] ) && count( $_packs[$app] ) )
- {
- $default_tab = ( $app == $this->request['app'] ) ? 1 : 0;
- asort($_packs[$app]);
-
- $this->addTab( $data['app_title'], $this->html->languageAppPackList( $app, $_packs[$app], $_stats[$app] ), '', $default_tab );
- }
- }
-
- //-----------------------------------------
- // And output
- //-----------------------------------------
-
- $this->registry->output->html .= $this->html->languageWordPackList( $id, $this->buildTabs(), $data['app_title'] );
- }
-
- /**
- * Handles the language information form submit
- *
- * @param string $mode Either new or edit
- * @return @e void
- */
- public function handleLanguageInformationForm( $mode='new' )
- {
- //-----------------------------------------
- // Error checking
- //-----------------------------------------
-
- $errors = array();
-
- if( ! $this->request['lang_title'] )
- {
- $errors[] = '' . $this->lang->words['language_title_missing'] . ' ';
- }
-
- if( ! $this->request['lang_short'] )
- {
- $errors[] = '' . $this->lang->words['language_locale_missing'] . ' ';
- }
-
- if( count( $errors ) )
- {
- $this->registry->output->global_message = ' '. implode( '', $errors ).' ';
- $this->lang_info_form( $mode );
- return;
- }
-
- //-----------------------------------------
- // Build insert array
- //-----------------------------------------
-
- $db_array = array(
- 'lang_title' => $this->request['lang_title'],
- 'lang_short' => $this->request['lang_short'],
- 'lang_default' => $this->request['lang_default'],
- 'lang_isrtl' => $this->request['lang_isrtl'],
- );
-
- //-----------------------------------------
- // Adding or editing
- //-----------------------------------------
-
- if( $mode == 'new' )
- {
- //-----------------------------------------
- // Default?
- //-----------------------------------------
-
- if( $this->request['lang_default'] )
- {
- $this->DB->update( 'core_sys_lang', array( 'lang_default' => 0 ) );
-
- $db_array['lang_default'] = 1;
- }
-
- //-----------------------------------------
- // Insert and get id
- //-----------------------------------------
-
- $this->DB->insert( 'core_sys_lang', $db_array );
-
- $id = $this->DB->getInsertId();
-
- //-----------------------------------------
- // Create directory
- //-----------------------------------------
-
- @mkdir( IPS_CACHE_PATH . 'cache/lang_cache/' . $id, IPS_FOLDER_PERMISSION );
- @file_put_contents( IPS_CACHE_PATH . 'cache/lang_cache/' . $id . '/index.html', '' );
- @chmod( IPS_CACHE_PATH . 'cache/lang_cache/' . $id, IPS_FOLDER_PERMISSION );
-
- //-----------------------------------------
- // Copy over language bits from default lang
- //-----------------------------------------
-
- $default = $this->DB->buildAndFetch( array( 'select' => 'lang_id', 'from' => 'core_sys_lang', 'where' => "lang_default=1" ) );
-
- $this->DB->build( array( 'select' => 'word_app,word_pack,word_key,word_default', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$default['lang_id']}" ) );
- $q = $this->DB->execute();
-
- while( $r = $this->DB->fetch( $q ) )
- {
- $r['lang_id'] = $id;
- $this->DB->insert( 'core_sys_lang_words', $r );
- }
-
- //-----------------------------------------
- // Rebuild IPB and disk caches
- //-----------------------------------------
-
- $this->registry->class_localization->rebuildLanguagesCache();
- $this->cacheToDisk($id);
-
- //-----------------------------------------
- // Show listing
- //-----------------------------------------
-
- $this->registry->output->global_message = $this->lang->words['language_pack_created'];
- $this->languagesList();
- }
- else
- {
- //-----------------------------------------
- // Default?
- //-----------------------------------------
-
- if( $this->request['lang_default'] )
- {
- $this->DB->update( 'core_sys_lang', array( 'lang_default' => 0 ) );
-
- $db_array['lang_default'] = 1;
- }
-
- //-----------------------------------------
- // Check ID and update
- //-----------------------------------------
-
- $id = intval( $this->request['id'] );
-
- $this->DB->update( 'core_sys_lang', $db_array, "lang_id={$id}" );
-
- //-----------------------------------------
- // Rebuild cache and show list
- //-----------------------------------------
-
- $this->registry->class_localization->rebuildLanguagesCache();
- $this->registry->output->global_message = $this->lang->words['language_pack_updated'];
- $this->languagesList();
- }
- }
-
- /**
- * Builds the language information form
- *
- * @param string $mode new or edit
- * @return @e void
- */
- public function languageInformationForm( $mode='new' )
- {
- //-----------------------------------------
- // Adding or editing
- //-----------------------------------------
-
- if( $mode == 'new' )
- {
- $title = $this->lang->words['language_form_new_title'];
- $button = $this->lang->words['language_form_new_button'];
- $op = 'do_new_language';
- $header = $this->lang->words['language_form_new_info'];
- $data = array(0);
- $id = 0;
- }
- else
- {
- $title = $this->lang->words['language_form_edit_title'];
- $button = $this->lang->words['language_form_edit_button'];
- $op = 'do_edit_lang_info';
- $header = $this->lang->words['language_form_edit_info'];
- $id = intval( $this->request['id'] );
-
- if( ! $id )
- {
- $this->registry->output->showError( $this->lang->words['invalid_id'], 11147 );
- }
-
- //-----------------------------------------
- // Get language pack info
- //-----------------------------------------
-
- $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$id}" ) );
- }
-
- //-----------------------------------------
- // Set some defaults
- //-----------------------------------------
-
- $data['lang_title'] = !empty( $this->request['lang_title'] ) ? $this->request['lang_title'] : $data['lang_title'];
- $data['lang_short'] = !empty( $this->request['lang_short'] ) ? $this->request['lang_short'] : $data['lang_short'];
- $data['lang_default'] = !empty( $this->request['lang_default'] ) ? $this->request['lang_default'] : $data['lang_default'];
- $data['lang_isrtl'] = !empty( $this->request['lang_isrtl'] ) ? $this->request['lang_isrtl'] : $data['lang_isrtl'];
-
- $data['lang_default'] = $this->registry->output->formYesNo( 'lang_default', $data['lang_default'] );
- $data['lang_isrtl'] = $this->registry->output->formYesNo( 'lang_isrtl', $data['lang_isrtl'] );
-
- //-----------------------------------------
- // Show form
- //-----------------------------------------
-
- $this->registry->output->extra_nav[] = array( '', $title );
- $this->registry->output->html .= $this->html->languageInformationForm( $op, $id, $title, $header, $data, $button );
- }
-
- /**
- * Lists currently installed languages
- *
- * @return @e void
- */
- public function languagesList()
- {
- /* Do we have a valid translation session? */
- $sessionData = $this->cache->getCache('translate_session');
- $hasTranslate = false;
-
- /* Check */
- if ( ! empty( $sessionData['lang_id'] ) AND count( $sessionData['files'] ) )
- {
- $hasTranslate = true;
- }
-
- /* Fallback for the recache all button */
- $forceEnglish = IPSCookie::get('forceEnglish');
-
- if ( !$this->lang->words['language_list_recache'] || $forceEnglish )
- {
- $this->lang->words['language_list_recache'] = 'Recache all...';
- }
-
- //-----------------------------------------
- // Get languages
- //-----------------------------------------
-
- $rows = array();
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- /* Get Local Data */
- //setlocale( LC_ALL, $r['lang_short'] );
- IPSLib::setlocale( $r['lang_short'] );
- $this->registry->class_localization->local_data = localeconv();
-
- $_menu = array();
-
- if( $r['lang_protected'] && ! IN_DEV )
- {
- $_menu[] = array( "", $this->lang->words['lang_pack_protected'], 'edit' );
- }
- else
- {
- $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=list_word_packs&id={$r['lang_id']}", $this->lang->words['language_list_translate'], 'info' );
-
- /* If we don't have a current session... */
- if ( ! $hasTranslate )
- {
- $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=translateExtSplash&id={$r['lang_id']}", $this->lang->words['language_list_translate_ext'], 'info' );
- }
- }
-
- $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=copy_lang_pack&id={$r['lang_id']}", $this->lang->words['language_list_copy'] );
-
- $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=export&id={$r['lang_id']}", $this->lang->words['l_xmlexportfull'], 'export' );
-
- if ( $r['lang_id'] )
- {
- $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=rebuildFromXml&id={$r['lang_id']}&type=public", $this->lang->words['rebuild_lang_from_xml'] );
- }
-
- foreach( ipsRegistry::$applications as $app_dir => $app_data )
- {
- $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=export&id={$r['lang_id']}&app_dir={$app_dir}", $this->lang->words['l_xmlexport'] . $app_data['app_title'], 'export' );
- }
-
- //-----------------------------------------
- // Data for output
- //-----------------------------------------
-
- $rows[] = array( 'title' => $r['lang_title'],
- 'local' => $r['lang_short'],
- 'date' => $this->registry->class_localization->getDate( time(), 'long', 1 ) . ' ' . $this->registry->class_localization->getDate( time(), 'short', 1 ),
- 'money' => $this->registry->class_localization->formatMoney( '12345231.12', 0 ),
- 'default' => $r['lang_default'],
- 'menu' => $_menu,
- 'id' => $r['lang_id'],
- 'protected'=> $r['lang_protected'],
- );
- }
-
- //-----------------------------------------
- // Reset locale
- //-----------------------------------------
-
- IPSLib::setlocale( $this->registry->class_localization->local );
- //setlocale( LC_ALL, $this->registry->class_localization->local );
- $this->registry->class_localization->local_data = localeconv();
-
- //-----------------------------------------
- // Output
- //-----------------------------------------
-
- $this->registry->output->html .= $this->html->languages_list( $rows, $hasTranslate );
- }
-
- /**
- * Updates the cached language files from the database
- *
- * @param integer ID of the language pack to export
- * @param string Just cache one app?
- * @return @e void
- */
- public function cacheToDisk( $lang_id, $app_override='' )
- {
- /* Generate cached warning */
- $warnString = "/*******************************************************\nNOTE: This is a cache file generated by IP.Board on " . date( "r" ) . " by " . $this->memberData['members_display_name'] . "\nDo not translate this file as you will lose your translations next time you edit via the ACP\nPlease translate via the ACP\n*******************************************************/\n\n";
-
- //-----------------------------------------
- // Build where statement
- //-----------------------------------------
-
- if ( $lang_id == 'master' )
- {
- $lang_id = 'master_lang';
- $where = "lang_id=1";
- }
- else if( $lang_id AND $lang_id != 1 )
- {
- $where = "lang_id={$lang_id}";
- }
- else
- {
- $lang_id = 1;
- $where = "lang_id=1";
- }
-
- //-----------------------------------------
- // If missing directory, create
- //-----------------------------------------
-
- if( ! is_dir( IPS_CACHE_PATH . 'cache/lang_cache/' . $lang_id . '/' ) )
- {
- mkdir( IPS_CACHE_PATH . 'cache/lang_cache/' . $lang_id . '/', IPS_FOLDER_PERMISSION );
- }
-
- /* Loop over apps */
- $this->DB->build( array( 'select' => 'DISTINCT(word_app) as word_app',
- 'from' => 'core_sys_lang_words',
- 'limit' => array(0, 100 ) ) ); # Because you never know.
-
- $o = $this->DB->execute();
-
- while( $langApps = $this->DB->fetch( $o ) )
- {
-
- if ( $app_override )
- {
- if ( $app_override != $langApps['word_app'] )
- {
- continue;
- }
- }
-
- //-----------------------------------------
- // Get the words
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'word_custom, word_default, word_app, word_pack, word_key',
- 'from' => 'core_sys_lang_words',
- 'where' => $where . " AND word_app='" . $langApps['word_app'] . "'",
- 'order' => 'word_key ASC' ) );
-
- $i = $this->DB->execute();
-
- $words_by_file = array();
-
- while( $r = $this->DB->fetch( $i ) )
- {
- $_text = ( $r['word_custom'] ) ? $r['word_custom'] : $r['word_default'];
- $words_by_file[$r['word_app']][$r['word_pack']][] = array( $r['word_key'], $_text );
- }
-
- //-----------------------------------------
- // Now loop and write to file
- //-----------------------------------------
-
- foreach( $words_by_file as $app => $word_packs )
- {
- foreach( $word_packs as $pack => $words )
- {
- if( $pack == 'public_js' )
- {
- $to_write = '';
- $_file = 'ipb.lang.js';
-
- foreach( $words as $word )
- {
- $word[1] = str_replace( "\\", "\\\\", $word[1] );
- $word[1] = str_replace( '"', '\\"', $word[1] );
- $to_write .= "ipb.lang['{$word[0]}'] = \"{$word[1]}\";\n";
- }
- }
- else if( $pack == 'admin_js' )
- {
- $to_write = '';
- $_file = 'acp.lang.js';
-
- foreach( $words as $word )
- {
- $word[1] = str_replace( "\\", "\\\\", $word[1] );
- $word[1] = str_replace( '"', '\\"', $word[1] );
- $to_write .= "ipb.lang['{$word[0]}'] = \"{$word[1]}\";\n";
- }
- }
- else
- {
- //-----------------------------------------
- // Build cache file contents
- //-----------------------------------------
-
- $to_write = " \"{$word[1]}\",\n";
- }
-
- $to_write .= " ); \n";
- }
-
- //-----------------------------------------
- // Write the file
- //-----------------------------------------
-
- $_dir = IPS_CACHE_PATH . 'cache/lang_cache/' . $lang_id . '/';
-
- if( is_file($_dir . $_file) )
- {
- @unlink( $_dir . $_file );
- }
-
- if ( $fh = @fopen( $_dir . $_file, 'wb' ) )
- {
- fwrite( $fh, $to_write, strlen( $to_write ) );
- fclose( $fh );
- @chmod( $_dir . $_file, IPS_FILE_PERMISSION );
- }
- else
- {
- $this->cache_errors[] = $this->lang->words['l_nowrite'] . $_dir . $_file;
- }
- }
- }
- }
- }
-
- /**
- * Imports language packs from an xml file and updates the database and recaches the languages
- *
- * @param integer $lang_id ID of the language pack to import
- * @param bool $in_dev Set to 1 for developer language import
- * @param bool $no_return If set to 1, this function will return a value, rather than outputting data
- * @param string $app_override Overrides the application for which languages are being imported
- * @param bool $skip_charset Skips charset conversion in the XML file (useful during upgrade routine as strings don't need to be converted)
- * @return mixed
- */
- public function imprtFromXML( $lang_id=0, $in_dev=0, $no_return=0, $app_override='', $skip_charset=false )
- {
- //-----------------------------------------
- // Set version..
- //-----------------------------------------
-
- $LATESTVERSION = IPSLib::fetchVersionNumber();
-
- //-----------------------------------------
- // INDEV?
- //-----------------------------------------
-
- if ( $in_dev )
- {
- $_FILES['FILE_UPLOAD']['name'] = '';
- }
- else if( $this->request['file_location'] )
- {
- $this->request['file_location'] = IPS_ROOT_PATH . $this->request['file_location'];
- }
-
- //-----------------------------------------
- // Not an upload?
- //-----------------------------------------
-
- if ( $_FILES['FILE_UPLOAD']['name'] == "" or ! $_FILES['FILE_UPLOAD']['name'] or ($_FILES['FILE_UPLOAD']['name'] == "none") )
- {
- //-----------------------------------------
- // Check and load from server
- //-----------------------------------------
-
- if ( ! $this->request['file_location'] )
- {
- $this->registry->output->global_message = $this->lang->words['l_nofile'];
- $this->languagesList();
- return;
- }
-
- if ( ! is_file( $this->request['file_location'] ) )
- {
- $this->registry->output->global_message = $this->lang->words['l_noopen'] . $this->request['file_location'];
- $this->languagesList();
- return;
- }
-
- if ( preg_match( '#\.gz$#', $this->request['file_location'] ) )
- {
- if ( $FH = @gzopen( $this->request['file_location'], 'rb' ) )
- {
- while ( ! @gzeof( $FH ) )
- {
- $content .= @gzread( $FH, 1024 );
- }
-
- @gzclose( $FH );
- }
- }
- else
- {
- $content = file_get_contents( $this->request['file_location'] );
- }
-
- $originalContent = $content;
-
- //-----------------------------------------
- // Extract archive
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH.'classXMLArchive.php' );/*noLibHook*/
- $xmlarchive = new classXMLArchive();
-
- //-----------------------------------------
- // Read the archive
- //-----------------------------------------
-
- $xmlarchive->readXML( $content );
-
- //-----------------------------------------
- // Get the data
- //-----------------------------------------
-
- $content = '';
-
- foreach( $xmlarchive->asArray() as $k => $f )
- {
- if( $k == 'language_entries.xml' )
- {
- $content = $f['content'];
- break;
- }
- }
-
- //-----------------------------------------
- // No content from de-archiving, must not
- // be archive, but rather raw XML file
- //-----------------------------------------
-
- if( $content == '' AND strpos( $originalContent, "registry->output->global_message = sprintf( $this->lang->words['lang_upload_too_large'], ini_get( 'upload_max_filesize' ) );
- $this->languagesList();
- return;
- break;
-
- default:
- $this->registry->output->global_message = $this->lang->words['lang_upload_other_error'];
- $this->languagesList();
- return;
- break;
- }
- }
-
- //-----------------------------------------
- // Get content
- //-----------------------------------------
-
- try
- {
- $uploadedContent = $this->registry->adminFunctions->importXml( $tmp_name );
- }
- catch ( Exception $e )
- {
- $this->registry->output->showError( $e->getMessage() );
- }
-
- //-----------------------------------------
- // Extract archive
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH.'classXMLArchive.php' );/*noLibHook*/
- $xmlarchive = new classXMLArchive();
-
- //-----------------------------------------
- // Read the archive
- //-----------------------------------------
-
- $xmlarchive->readXML( $uploadedContent );
-
- //-----------------------------------------
- // Get the data
- //-----------------------------------------
-
- $content = '';
-
- foreach( $xmlarchive->asArray() as $k => $f )
- {
- if( $k == 'language_entries.xml' )
- {
- $content = $f['content'];
- break;
- }
- }
-
- //-----------------------------------------
- // No content from de-archiving, must not
- // be archive, but rather raw XML file
- //-----------------------------------------
-
- if( $content == '' AND strpos( $uploadedContent, "registry->output->global_message = $this->lang->words['l_badfile'];
- $this->languagesList();
- return;
- }
-
- //-----------------------------------------
- // Get xml class
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
-
- $xml = new classXML( $skip_charset ? 'utf-8' : IPS_DOC_CHAR_SET );
- $xml->loadXML( $content );
-
- //-----------------------------------------
- // Is this full language pack?...
- //-----------------------------------------
-
- foreach( $xml->fetchElements('langinfo') as $lang_data )
- {
- $lang_info = $xml->fetchElementsFromRecord( $lang_data );
-
- $lang_data = array(
- 'lang_short' => $lang_info['lang_short'],
- 'lang_title' => $lang_info['lang_title'],
- );
- }
-
- $lang_ids = array();
- $insertId = 0;
-
- //-----------------------------------------
- // Do we have language pack info?
- //-----------------------------------------
-
- if( $lang_data['lang_short'] )
- {
- //-----------------------------------------
- // Does this pack already exist
- //-----------------------------------------
-
- $update_lang = $this->DB->buildAndFetch( array(
- 'select' => 'lang_id',
- 'from' => 'core_sys_lang',
- 'where' => "lang_short='{$lang_data['lang_short']}'",
- ) );
-
- //-----------------------------------------
- // If doesn't exist, then create new pack
- //-----------------------------------------
-
- if( !$update_lang['lang_id'] )
- {
- $this->DB->insert( 'core_sys_lang', $lang_data );
-
- $insertId = $this->DB->getInsertId();
-
- if( @mkdir( IPS_CACHE_PATH . '/cache/lang_cache/' . $insertId ) )
- {
- @file_put_contents( IPS_CACHE_PATH . 'cache/lang_cache/' . $insertId . '/index.html', '' );
- @chmod( IPS_CACHE_PATH . '/cache/lang_cache/' . $insertId, IPS_FOLDER_PERMISSION );
- }
-
- //-----------------------------------------
- // Copy over language bits from default lang
- //-----------------------------------------
-
- $default = $this->DB->buildAndFetch( array( 'select' => 'lang_id', 'from' => 'core_sys_lang', 'where' => "lang_default=1" ) );
-
- $this->DB->build( array( 'select' => 'word_app,word_pack,word_key,word_default,word_js', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$default['lang_id']}" ) );
- $q = $this->DB->execute();
-
- while( $r = $this->DB->fetch( $q ) )
- {
- $r['lang_id'] = $insertId;
- $r['word_custom'] = '';
-
- $this->DB->insert( 'core_sys_lang_words', $r );
- }
-
- //-----------------------------------------
- // Rebuild IPB and disk caches
- //-----------------------------------------
-
- $this->registry->class_localization->rebuildLanguagesCache();
- }
- else
- {
- $insertId = $update_lang['lang_id'];
- }
- }
-
- //-----------------------------------------
- // We need to add language bits to every pack..
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'lang_id', 'from' => 'core_sys_lang' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $lang_ids[] = $r['lang_id'];
- }
-
- //-----------------------------------------
- // Init counts array
- //-----------------------------------------
-
- $counts = array( 'updates' => 0, 'inserts' => 0 );
-
- //-----------------------------------------
- // Init a cache array to save entries
- //-----------------------------------------
-
- $lang_entries = array();
-
- if( $app_override )
- {
- $this->DB->build( array( 'select' => "MD5( CONCAT( lang_id, '-', word_app, '-', word_pack, '-', word_key ) ) as word_lookup, word_id, md5(word_default) as word_default, word_default_version",
- 'from' => 'core_sys_lang_words',
- 'where' => "word_app='{$app_override}' AND lang_id IN(" . implode( ",", $lang_ids ) . ")" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $lang_entries[ $r['word_lookup'] ] = $r;
- }
- }
-
- //-----------------------------------------
- // Start looping
- //-----------------------------------------
-
- foreach( $xml->fetchElements('lang') as $entry )
- {
- $lang = $xml->fetchElementsFromRecord( $entry );
-
- foreach( $lang_ids as $_lang_id )
- {
- $lang_entry = array();
-
- //-----------------------------------------
- // Build db array
- //-----------------------------------------
-
- $db_array = array(
- 'lang_id' => $_lang_id,
- 'word_app' => $app_override ? $app_override : $lang['word_app'],
- 'word_pack' => $lang['word_pack'],
- 'word_key' => $lang['word_key'],
- 'word_default' => $lang['word_default'],
- 'word_custom' => $in_dev ? '' : $lang['word_custom'],
- 'word_js' => intval($lang['word_js']),
- 'word_default_version' => $lang['word_default_version'] ? $lang['word_default_version'] : $LATESTVERSION['long'],
- 'word_custom_version' => $lang['word_custom_version'],
- );
-
- $dbKey = md5( $db_array['lang_id'] . '-' . $db_array['word_app'] . '-' . $db_array['word_pack'] . '-' . $db_array['word_key'] );
- $langIdKey = md5( $_lang_id . '-' . $db_array['word_app'] . '-' . $db_array['word_pack'] . '-' . $db_array['word_key'] );
-
- // If the default value hasn't changed, we don't need to update the word_default_version (see bug report 19172)
- if ( md5( $lang['word_default'] ) == $lang_entries[ $dbKey ]['word_default'] )
- {
- $db_array['word_default_version'] = $lang_entries[ $dbKey ]['word_default_version'];
- }
-
- //-----------------------------------------
- // If cached, get from cache
- //-----------------------------------------
-
- if ( $lang_entries[ $langIdKey ] )
- {
- $lang_entry = $lang_entries[ $langIdKey ];
- }
-
- //-----------------------------------------
- // Otherwise get all langs from this entry and
- // put in cache
- //-----------------------------------------
-
- else if( ! $app_override )
- {
- $this->DB->build( array(
- 'select' => '*',
- 'from' => 'core_sys_lang_words',
- 'where' => "lang_id={$_lang_id} AND word_app='{$db_array['word_app']}' AND word_pack='{$db_array['word_pack']}'"
- ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $lang_entries[ md5( $r['lang_id'] . '-' . $r['word_app'] . '-' . $r['word_pack'] . '-' . $r['word_key'] ) ] = $r;
- }
-
- if ( $lang_entries[ $langIdKey ] )
- {
- $lang_entry = $lang_entries[ $langIdKey ];
- }
- }
-
- //-----------------------------------------
- // Didn't find any match? Must be importing
- // a new language pack, huh?
- //-----------------------------------------
-
- if ( !isset( $lang_entry['word_id'] ) )
- {
- //continue 2;
- }
-
- //-----------------------------------------
- // If there is no new custom lang bit to insert
- // don't delete what is already there.
- //-----------------------------------------
-
- if( !$db_array['word_custom'] || ( $insertId > 0 && $insertId != $_lang_id ) )
- {
- unset($db_array['word_custom']);
- unset($db_array['word_custom_version']);
- }
-
- //-----------------------------------------
- // Lang bit already exists, update
- //-----------------------------------------
-
- if ( $lang_entry['word_id'] AND ( ! $insertId OR ( $insertId == $_lang_id ) ) )
- {
- //-----------------------------------------
- // Don't update default version
- //-----------------------------------------
-
- // This causes no languages to show "out of date" on upgrade
- // @link http://community.invisionpower.com/tracker/issue-31637-no-out-of-date-entries-for-language-string-updates
- // This WAS added to fix a previously reported bug, however, so need to watch out for this
- // unset( $db_array['word_default_version'] );
-
- $counts['updates']++;
- $this->DB->update( 'core_sys_lang_words', $db_array, "word_id={$lang_entry['word_id']}" );
- }
-
- //-----------------------------------------
- // Lang bit doesn't exist, so insert
- //-----------------------------------------
-
- else if( ! $lang_entry['word_id'] )
- {
- /* Ensure there is a value to avoid null */
- if ( ! $db_array['word_custom'] )
- {
- $db_array['word_custom'] = '';
- }
-
- /* Ensure custom word but isn't added to other packs that simply had missing strings */
- if ( $insertId AND $insertId != $_lang_id )
- {
- $db_array['word_custom'] = '';
- }
-
- $counts['inserts']++;
- $this->DB->insert( 'core_sys_lang_words', $db_array );
- }
-
- unset( $lang_entry, $db_array );
- }
- }
-
- /* Save some memory */
- unset( $lang_entries );
-
- //-----------------------------------------
- // Recache all our lang packs
- //-----------------------------------------
-
- foreach( $lang_ids as $_lang_id )
- {
- $this->cacheToDisk( $_lang_id, $app_override );
- }
-
- //-----------------------------------------
- // Set output message
- //-----------------------------------------
-
- $this->registry->output->global_message = sprintf( $this->lang->words['l_updatedcount'], $counts['updates'], $counts['inserts'] );
-
- if ( is_array( $this->cache_errors ) AND count( $this->cache_errors ) )
- {
- $this->registry->output->global_message .= " " . implode( " ", $this->cache_errors );
- }
-
- //-----------------------------------------
- // Free a little memory
- //-----------------------------------------
-
- unset( $xml );
-
- //-----------------------------------------
- // Update IPB cache
- //-----------------------------------------
-
- $this->registry->class_localization->rebuildLanguagesCache();
-
- //-----------------------------------------
- // Return! Now!
- //-----------------------------------------
-
- if ( ! $no_return )
- {
- $this->languagesList();
- return;
- }
- }
-
- /**
- * Export language entries to xml file
- *
- * @param integer $lang_id Language pack to export
- * @param bool $disk Save to disk instead
- * @return void
- */
- public function languageExportToXML( $lang_id, $disk=false )
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $app_dir = trim( $this->request['app_dir'] );
- $type = trim( $this->request['type'] );
- $_where = '';
- $_name = 'language.xml';
- $LATESTVERSION = IPSLib::fetchVersionNumber();
- $doPack = true;
-
- //-----------------------------------------
- // Filter
- //-----------------------------------------
-
- if ( $app_dir )
- {
- $_where = " AND word_app='" . $app_dir . "'";
- $_name = $app_dir . '_language_pack.xml';
- $doPack = false;
- }
-
- if ( $type )
- {
- if ( $type == 'admin' )
- {
- $_where .= " AND word_pack LIKE 'admin_%'";
- $_name = 'admin_' . $_name;
- }
- else
- {
- $_where .= " AND word_pack LIKE 'public_%'";
- $_name = 'public_' . $_name;
- }
-
- $doPack = false;
- }
-
- //-----------------------------------------
- // Create the XML library
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
- $xml = new classXML( IPS_DOC_CHAR_SET );
- $xml->newXMLDocument();
- $xml->addElement( 'languageexport' );
- $xml->addElement( 'languagegroup', 'languageexport' );
-
- //-----------------------------------------
- // Get language pack
- //-----------------------------------------
-
- $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$lang_id}" ) );
-
- //-----------------------------------------
- // Add pack if necessary
- //-----------------------------------------
-
- if( $doPack )
- {
- $xml->addElementAsRecord( 'languagegroup', 'langinfo', $data );
- }
-
- //-----------------------------------------
- // Get the words
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id}" . $_where ) );
- $this->DB->execute();
-
- //-----------------------------------------
- // Add words to export
- //-----------------------------------------
-
- $word_packs = array();
- $_strings = 0;
-
- while( $r = $this->DB->fetch() )
- {
- $content = array();
- $_strings++;
-
- if( $disk )
- {
- $content = array(
- 'word_app' => $r['word_app'],
- 'word_pack' => $r['word_pack'],
- 'word_key' => $r['word_key'],
- 'word_default' => $r['word_default'],
- //'word_default_version' => ( $r['word_default_version'] >= 30000 ) ? $r['word_default_version'] : $LATESTVERSION['long'],
- //'word_js' => $r['word_js']
- );
-
- if( $r['word_js'] )
- {
- $content['word_js'] = $r['word_js'];
- }
- }
- else
- {
- $content = array(
- 'word_app' => $r['word_app'],
- 'word_pack' => $r['word_pack'],
- 'word_key' => $r['word_key'],
- 'word_default' => $r['word_default'],
- 'word_custom' => $r['word_custom'],
- 'word_default_version' => ( $r['word_default_version'] >= 30000 ) ? $r['word_default_version'] : $LATESTVERSION['long'],
- 'word_custom_version' => $r['word_custom_version'],
- 'word_js' => $r['word_js']
- );
- }
-
- $xml->addElementAsRecord( 'languagegroup', 'lang', $content );
- }
-
- //-----------------------------------------
- // Got any strings?
- //-----------------------------------------
-
- if( !$_strings )
- {
- if( $disk )
- {
- return false;
- }
- else
- {
- $this->registry->output->global_message = $this->lang->words['l_nolangbits'];
- $this->languagesList();
- return;
- }
- }
-
- //-----------------------------------------
- // Write to disk or output to browser
- //-----------------------------------------
-
- if( $disk )
- {
- @unlink( IPSLib::getAppDir($app_dir) . '/xml/' . $_name );
- @file_put_contents( IPSLib::getAppDir($app_dir) . '/xml/' . $_name, $xml->fetchDocument() );
- return true;
- }
- else
- {
- //-----------------------------------------
- // Create xml archive
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
- $xmlArchive = new classXMLArchive();
-
- //-----------------------------------------
- // Add XML document
- //-----------------------------------------
-
- $xmlArchive->add( $xml->fetchDocument(), 'language_entries.xml' );
-
- //-----------------------------------------
- // Print to browser
- //-----------------------------------------
-
- $this->registry->output->showDownload( $xmlArchive->getArchiveContents(), $_name );
- exit();
- }
- }
-
- /**
- * Builds the language db entries from cache
- *
- * @param boolean return as normal
- * @return @e void
- * @author Josh
- */
- public function importFromCacheFiles( $returnAsNormal=TRUE )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $msg = array();
- $lang_id = 1;
- $LATESTVERSION = IPSLib::fetchVersionNumber();
-
- //-----------------------------------------
- // Check
- //-----------------------------------------
-
- if ( ! is_array( $_POST['apps'] ) )
- {
- $this->registry->output->global_message = $this->lang->words['l_noapp'];
- $this->languagesList();
- return;
- }
-
- //-----------------------------------------
- // Loop through apps...
- //-----------------------------------------
-
- foreach( ipsRegistry::$applications as $app => $app_data )
- {
- if ( in_array( $app, $_POST['apps'] ) )
- {
- //-----------------------------------------
- // Get directory
- //-----------------------------------------
-
- $_dir = IPS_CACHE_PATH . 'cache/lang_cache/master_lang/';
-
- //-----------------------------------------
- // Go through directories
- //-----------------------------------------
-
- if ( is_dir( $_dir ) )
- {
- $dh = opendir( $_dir );
-
- while( $f = readdir( $dh ) )
- {
- if ( $f[0] == '.' || $f == 'index.html' )
- {
- continue;
- }
-
- if ( preg_match( "#^" . $app . '_\S+?\.php$#', $f ) )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $updated = 0;
- $inserted = 0;
- $word_pack = preg_replace( "#^" . $app . '_(\S+?)\.php$#', "\\1", $f );
- $lang = array();
- $db_lang = array();
-
- //-----------------------------------------
- // Delete current language bits
- //-----------------------------------------
-
- $this->DB->delete( 'core_sys_lang_words', "lang_id=1 AND word_app='" . $app . "' AND word_pack='" . $word_pack . "'" );
-
- if ( IPS_IS_SHELL )
- {
- $stdout = fopen('php://stdout', 'w');
- fwrite( $stdout, 'Processing: ' . $f . "\n" );
- fclose( $stdout );
- }
-
- require( $_dir . $f );/*noLibHook*/
-
- //-----------------------------------------
- // Loop
- //-----------------------------------------
-
- foreach( $lang as $k => $v )
- {
- $inserted++;
-
- $insert = array(
- 'lang_id' => $lang_id,
- 'word_app' => $app,
- 'word_pack' => $word_pack,
- 'word_key' => $k,
- 'word_default' => IPSText::encodeForXml($v),
- 'word_default_version' => $LATESTVERSION['long'],
- 'word_js' => 0,
- );
-
- $this->DB->insert( 'core_sys_lang_words', $insert );
- }
-
- $msg[] = sprintf( $this->lang->words['indev_lang_import'], $f, $inserted, $updated );
- }
- else if( preg_match( '/(\.js)$/', $f ) AND $app == 'core' )
- {
- $_js_word_pack = '';
-
- if( $f == 'ipb.lang.js' )
- {
- $_js_word_pack = 'public_js';
- }
- else if( $f == 'acp.lang.js' )
- {
- $_js_word_pack = 'admin_js';
- }
-
- //-----------------------------------------
- // Delete current words for this app and word pack
- //-----------------------------------------
-
- $this->DB->delete( 'core_sys_lang_words', "lang_id=1 AND word_app='" . $app . "' AND word_pack='" . $_js_word_pack . "'" );
-
- if ( IPS_IS_SHELL )
- {
- $stdout = fopen('php://stdout', 'w');
- fwrite( $stdout, 'Processing: ' . $f . "\n" );
- fclose( $stdout );
- }
-
- //-----------------------------------------
- // Get each line
- //-----------------------------------------
-
- $js_file = file( $_dir . $f );
-
- //-----------------------------------------
- // Loop through lines and import
- //-----------------------------------------
-
- foreach( $js_file as $r )
- {
- //-----------------------------------------
- // preg_match what we want
- //-----------------------------------------
-
- preg_match( '#ipb\.lang\[\'(.+?)\'\](.+?)= ["\'](.+?)["\'];#', $r, $matches );
-
- //-----------------------------------------
- // Valid?
- //-----------------------------------------
-
- if( $matches[1] && $matches[3] )
- {
- $inserted++;
- $insert = array(
- 'lang_id' => $lang_id,
- 'word_app' => 'core',
- 'word_pack' => $_js_word_pack,
- 'word_key' => $matches[1],
- 'word_default' => IPSText::encodeForXml($matches[3]),
- 'word_js' => 1,
- );
- $this->DB->insert( 'core_sys_lang_words', $insert );
- }
- }
- }
- }
-
- closedir( $dh );
- }
- }
- }
-
- //-----------------------------------------
- // Done...
- //-----------------------------------------
-
- if ( $returnAsNormal === TRUE )
- {
- $this->registry->output->setMessage( implode( " ", $msg ), true );
-
- if ( ! $this->__daily )
- {
- $this->languagesList();
- }
- }
- else
- {
- return $msg;
- }
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Language Pack Management
+ * Last Updated: $LastChangedDate: 2013-05-29 10:48:49 -0400 (Wed, 29 May 2013) $
+ *
+ *
+ * @author $Author: AndyMillne $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @version $Rev: 12276 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+class admin_core_languages_manage_languages extends ipsCommand
+{
+ /**
+ * Daily flag
+ *
+ * @var bool
+ */
+ private $__daily = false;
+
+ /**
+ * Tab buttons
+ *
+ * @var array
+ */
+ public $tab_buttons = array();
+
+ /**
+ * Tabs
+ *
+ * @var array
+ */
+ public $tab_tabs = array();
+
+ /**
+ * Javascript action to execute on tab click
+ *
+ * @var string
+ */
+ public $tab_js_action = '';
+
+ /**
+ * Default tab
+ *
+ * @var string
+ */
+ public $default_tab = '';
+
+ /**
+ * Main class entry point
+ *
+ * @param object ipsRegistry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ //-----------------------------------------
+ // Get skin and language file
+ //-----------------------------------------
+
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_system', 'core' );
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_system' ), 'core' );
+
+ //-----------------------------------------
+ // Set urls
+ //-----------------------------------------
+
+ $this->form_code = $this->html->form_code = 'module=languages§ion=manage_languages&';
+ $this->form_code_js = $this->html->form_code_js = 'module=languages§ion=manage_languages&';
+
+ //-----------------------------------------
+ // Go
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ case 'copy_lang_pack':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
+ $this->languageCopy();
+ break;
+
+ case 'edit_word_entry':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
+ $this->languageWordEntryForm( 'edit' );
+ break;
+
+ case 'do_edit_word_entry':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
+ $this->handleWordEntryForm( 'edit' );
+ break;
+
+ case 'add_word_entry':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
+ $this->languageWordEntryForm( 'add' );
+ break;
+
+ case 'do_add_word_entry':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
+ $this->handleWordEntryForm( 'add' );
+ break;
+
+ case 'list_word_packs':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
+ $this->languageListWordPacks();
+ break;
+
+ case 'edit_word_pack':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
+ $this->languageEditWordPack();
+ break;
+
+ case 'do_edit_word_pack':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_packs' );
+ $this->languageEditWordPackValues();
+ break;
+
+ case 'edit_lang_info':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_pack_info' );
+ $this->languageInformationForm( 'edit' );
+ break;
+
+ case 'do_edit_lang_info':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_pack_info' );
+ $this->handleLanguageInformationForm( 'edit' );
+ break;
+
+ case 'new_language':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_packs' );
+ $this->languageInformationForm( 'new' );
+ break;
+
+ case 'do_new_language':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_packs' );
+ $this->handleLanguageInformationForm( 'new' );
+ break;
+
+ case 'language_swap':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_pack_info' );
+ $this->swapLanguages();
+ break;
+
+ case 'revert':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'lang_words' );
+ $this->languageDoRevertWord();
+ break;
+
+ case 'export':
+ $this->languageExportToXML( intval( $this->request['id'] ) );
+ break;
+
+ case 'language_do_import':
+ $this->imprtFromXML( intval( $this->request['id'] ) );
+ break;
+
+ case 'language_do_indev_export':
+ foreach( ipsRegistry::$applications as $app_dir => $app_data )
+ {
+ $this->request['app_dir'] = $app_dir;
+
+ $this->request['type'] = 'admin';
+ $this->languageExportToXML( 1, 1 );
+
+ $this->request['type'] = 'public';
+ $this->languageExportToXML( 1, 1 );
+ }
+
+ $this->registry->output->setMessage( $this->lang->words['indev_lang_export_done'], 1 );
+ $this->languagesList();
+ break;
+
+ case 'language_do_indev_import':
+ $this->importFromCacheFiles();
+ break;
+
+ case 'remove_language':
+ $this->languageRemove();
+ break;
+
+ case 'remove_word_entry':
+ $this->removeWordEntry();
+ break;
+
+ case 'remove_word_pack':
+ $this->removeWordPack();
+ break;
+
+ case 'rebuildFromXml':
+ $this->rebuildFromXml();
+ break;
+
+ case 'recache_lang_pack':
+ $this->recacheLangPack();
+ break;
+
+ case 'translateExtSplash':
+ $this->translateExtSplash();
+ break;
+
+ case 'translateImport':
+ $this->translateImport();
+ break;
+
+ case 'translateKill':
+ $this->translateKill();
+ break;
+
+ default:
+ $this->languagesList();
+ break;
+ }
+
+ //-----------------------------------------
+ // Pass to CP output hander
+ //-----------------------------------------
+
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Swap member language choice globally
+ *
+ * @return @e void
+ */
+ public function swapLanguages()
+ {
+ /* INIT */
+ $langFrom = intval( $this->request['lang_from'] );
+ $langTo = intval( $this->request['lang_to'] );
+
+ /* Run query... */
+ if( !$langFrom )
+ {
+ $this->DB->update( 'members', array( 'language' => $langTo > 0 ? $langTo : 0 ), "language=0 OR language " . $this->DB->buildIsNull( true ) );
+ }
+ else
+ {
+ $this->DB->update( 'members', array( 'language' => $langTo > 0 ? $langTo : 0 ), "language=" . intval( $langFrom ) );
+ }
+
+ /* Done */
+ $this->registry->output->global_message = $this->lang->words['mem_lang_choice_swapped'];
+ $this->languagesList();
+ return;
+ }
+
+ /**
+ * Finish a session and remove data
+ *
+ * @return @e void
+ */
+ public function translateKill()
+ {
+ /* INIT */
+ $langId = intval( $this->request['id'] );
+ $mainDir = DOC_IPS_ROOT_PATH . 'translate';
+ $words_by_file = array();
+ $errors = array();
+ $filesToImport = array();
+
+ /* Start top message */
+ if ( ! is_dir( $mainDir ) )
+ {
+ /* Just bounce back asking them to create translate */
+ $this->registry->output->global_error = $this->lang->words['ext_no_translate_dir'];
+ $this->languagesList();
+ return;
+ }
+
+ if ( ! is_writeable( $mainDir ) )
+ {
+ /* Just bounce back asking them to chmod translate */
+ $this->registry->output->global_error = $this->lang->words['ext_chmod_translate_dir'];
+ $this->languagesList();
+ return;
+ }
+
+ /* Load kernel class for file management */
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
+ $classFileManagement = new $classToLoad();
+
+ /* Remove files */
+ $classFileManagement->emptyDirectory( $mainDir );
+
+ /* Delete session */
+ $this->cache->deleteCache( 'translate_session' );
+
+ /* Done */
+ $this->registry->output->global_message = $this->lang->words['ext_all_killed'];
+ $this->languagesList();
+ return;
+ }
+
+ /**
+ * Translate externally import changed files
+ *
+ * @return @e void
+ */
+ public function translateImport()
+ {
+ /* INIT */
+ $langId = intval( $this->request['id'] );
+ $mainDir = DOC_IPS_ROOT_PATH . 'translate';
+ $words_by_file = array();
+ $errors = array();
+ $filesToImport = array();
+ $fileCount = 0;
+
+ /* Start top message */
+ if ( ! is_dir( $mainDir ) )
+ {
+ /* Just bounce back asking them to create translate */
+ $this->registry->output->global_error = $this->lang->words['ext_no_translate_dir'];
+ $this->languagesList();
+ return;
+ }
+
+ if ( ! is_writeable( $mainDir ) )
+ {
+ /* Just bounce back asking them to chmod translate */
+ $this->registry->output->global_error = $this->lang->words['ext_chmod_translate_dir'];
+ $this->languagesList();
+ return;
+ }
+
+ /* Get file count */
+ try
+ {
+ foreach( new DirectoryIterator( $mainDir ) as $f )
+ {
+ if ( !$f->isDir() )
+ {
+ $fileCount++;
+ }
+ }
+ }
+ catch ( Exception $e )
+ {
+ $fileCount = 0;
+ }
+
+ /* Get lang */
+ $lang = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => 'lang_id=' . $langId ) );
+
+ /* Get current session if one */
+ $sessionData = $this->cache->getCache('translate_session');
+
+ /* Check */
+ if ( empty( $sessionData['lang_id'] ) OR ! count( $sessionData['files'] ) OR !$fileCount )
+ {
+ /* Just bounce back asking them to create translate */
+ $this->registry->output->global_error = $this->lang->words['ext_no_translate_files'];
+ $this->languagesList();
+ return;
+ }
+
+ /* Still here? Okay */
+ if ( is_array( $_POST['cb'] ) AND count( $_POST['cb'] ) )
+ {
+ /* Gather a list of files to import */
+ foreach( $_POST['cb'] as $file => $value )
+ {
+ if ( $_POST['cb'][ $file ] )
+ {
+ $filesToImport[ $file ] = $file;
+ }
+ }
+
+ /* Assume nothing */
+ if ( count( $filesToImport ) )
+ {
+ $counts = $this->_importFromDisk( $mainDir, $sessionData['lang_id'], array_keys( $filesToImport ), true );
+
+ foreach( $counts as $file => $data )
+ {
+ /* Update session data */
+ $sessionData['files'][ $file ]['dbtime'] = time();
+
+ $this->registry->output->global_message = sprintf( $this->lang->words['ext_file_written'], $file, intval( $data['inserts'] ), intval( $data['updates'] ) );
+ }
+
+ $this->registry->output->global_message .= ' ' . sprintf( $this->lang->words['ext_recache'], "{$this->settings['base_url']}&{$this->form_code}&do=recache_lang_pack&id={$sessionData['lang_id']}" );
+
+ /* Update session */
+ $this->cache->setCache( 'translate_session', $sessionData, array( 'array' => 1, 'donow' => 1 ) );
+
+ $this->translateExtSplash();
+ return;
+ }
+ }
+ else
+ {
+ /* Just bounce back asking them to create translate */
+ $this->registry->output->global_error = $this->lang->words['ext_no_selected_files'];
+ $this->translateExtSplash();
+ return;
+ }
+ }
+
+ /**
+ * Translate externally splash
+ *
+ * @return @e void
+ */
+ public function translateExtSplash()
+ {
+ /* INIT */
+ $langId = intval( $this->request['id'] );
+ $mainDir = DOC_IPS_ROOT_PATH . 'translate';
+ $words_by_file = array();
+ $errors = array();
+
+ /* Start top message */
+ if ( ! is_dir( $mainDir ) )
+ {
+ /* Just bounce back asking them to create translate */
+ $this->registry->output->global_error = $this->lang->words['ext_no_translate_dir'];
+ $this->languagesList();
+ return;
+ }
+
+ if ( ! is_writeable( $mainDir ) )
+ {
+ /* Just bounce back asking them to chmod translate */
+ $this->registry->output->global_error = $this->lang->words['ext_chmod_translate_dir'];
+ $this->languagesList();
+ return;
+ }
+
+ /* Load kernel class for file management */
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
+ $classFileManagement = new $classToLoad();
+
+ /* Get lang */
+ $lang = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => 'lang_id=' . $langId ) );
+
+ /* Get current session if one */
+ $sessionData = $this->cache->getCache('translate_session');
+
+ /* No current session? */
+ if ( empty( $sessionData['lang_id'] ) OR ! count( $sessionData['files'] ) )
+ {
+ /* Ensure directory is empty */
+ $classFileManagement->emptyDirectory( $mainDir );
+
+ /* Ensure it's gone, gone */
+ $this->cache->deleteCache( 'translate_session' );
+ $sessionData = $lang;
+ $sessionData['files'] = array();
+ $header = "/*******************************************************\nNOTE: This is a translatable file generated by IP.Board " . IPB_VERSION . " (" . IPB_LONG_VERSION . ") on " . date( "r" ) . " by " . $this->memberData['members_display_name'] . "\nPLEASE set your text editor to save this document as UTF-8 regardless of your board's character-set\n*******************************************************/\n\n";
+
+ /* Export all the languages into flat files */
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => 'lang_id=' . $langId, 'order' => 'word_custom_version DESC, word_default_version DESC' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $_text = ( $r['word_custom'] ) ? $r['word_custom'] : $r['word_default'];
+ $_version = ( $r['word_custom_version'] ) ? $r['word_custom_version'] : $r['word_default_version'];
+ $words_by_file[$r['word_app']][$r['word_pack']][] = array( $r['word_key'], $_text );
+ }
+
+ //-----------------------------------------
+ // Now loop and write to file
+ //-----------------------------------------
+
+ foreach( $words_by_file as $app => $word_packs )
+ {
+ foreach( $word_packs as $pack => $words )
+ {
+ if( $pack == 'public_js' )
+ {
+ $to_write = '';
+ $_file = 'ipb.lang.js';
+
+ foreach( $words as $word )
+ {
+ $word[1] = str_replace( '"', '\\"', $word[1] );
+ $to_write .= "ipb.lang['{$word[0]}'] = \"{$word[1]}\";\n";
+ }
+ }
+ else if( $pack == 'admin_js' )
+ {
+ $to_write = '';
+ $_file = 'acp.lang.js';
+
+ foreach( $words as $word )
+ {
+ $word[1] = str_replace( '"', '\\"', $word[1] );
+ $to_write .= "ipb.lang['{$word[0]}'] = \"{$word[1]}\";\n";
+ }
+ }
+ else
+ {
+ //-----------------------------------------
+ // Build cache file contents
+ //-----------------------------------------
+
+ $to_write = " \"{$word[1]}\",\n";
+ }
+
+ $to_write .= " ); \n";
+ }
+
+ //-----------------------------------------
+ // Convert data
+ //-----------------------------------------
+
+ $to_write = IPSText::convertCharsets( $to_write, IPS_DOC_CHAR_SET, 'UTF-8' );
+
+ //-----------------------------------------
+ // Write the file
+ //-----------------------------------------
+
+ @unlink( $mainDir . '/' . $_file );
+
+ if ( $fh = @fopen( $mainDir . '/' . $_file, 'wb' ) )
+ {
+ fwrite( $fh, $to_write, strlen( $to_write ) );
+ fclose( $fh );
+ @chmod( $mainDir . '/' . $_file, IPS_FILE_PERMISSION );
+
+ $mtime = @filemtime( $mainDir . '/' . $_file );
+
+ $sessionData['files'][ $_file ] = array( 'mtime' => $mtime, 'dbtime' => $mtime );
+ }
+ else
+ {
+ $errors[] = $this->lang->words['l_nowrite'] . $mainDir . '/' . $_file;
+ }
+ }
+ }
+
+ /* Sort files */
+ ksort( $sessionData['files'] );
+
+ /* Save session */
+ $this->cache->setCache( 'translate_session', $sessionData, array( 'array' => 1, 'donow' => 1 ) );
+ }
+ else
+ {
+ /* Update mtime */
+ foreach( $sessionData['files'] as $file => $data )
+ {
+ $sessionData['files'][ $file ]['mtime'] = @filemtime( $mainDir . '/' . $file );
+ }
+ }
+
+ //-----------------------------------------
+ // Output
+ //-----------------------------------------
+
+ $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}&{$this->form_code}&do=translateExtSplash&id={$sessionData['lang_id']}", "{$this->lang->words['ext_title_for']} {$sessionData['lang_title']}" );
+
+ $this->registry->output->html .= $this->html->languages_translateExt( $sessionData, $lang );
+ }
+
+ /**
+ * Import files from disk
+ *
+ * @param string Directory to look in
+ * @param int Language ID to import into
+ * @param array [Only import these files]
+ * @param boolean [Perform character set translation from UTF-8]
+ * @return array List of files successfully imported
+ */
+ private function _importFromDisk( $mainDir, $langId, $onlyTheseFiles=array(), $convertCharSet=false )
+ {
+ /* INIT */
+ $imported = array();
+ $lang_entries = array();
+ $js_entries = array();
+ $counts = array();
+
+ /* Start looping */
+ if ( is_dir( $mainDir ) )
+ {
+ $dh = opendir( $mainDir );
+
+ /* Ensure it has a trailing slash */
+ if ( substr( $mainDir, -1 ) != '/' )
+ {
+ $mainDir .= '/';
+ }
+
+ while( $f = readdir( $dh ) )
+ {
+ if ( $f[0] == '.' || $f == 'index.html' )
+ {
+ continue;
+ }
+
+ /* Skipping? */
+ if ( is_array( $onlyTheseFiles ) AND count( $onlyTheseFiles ) AND ! in_array( $f, $onlyTheseFiles ) )
+ {
+ continue;
+ }
+
+ if ( preg_match( '#^\S+?_\S+?\.php$#', $f ) )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $updated = 0;
+ $inserted = 0;
+ $app = preg_replace( '#^([^_]+?)_(\S+?)\.php$#', "\\1", $f );
+ $word_pack = preg_replace( '#^([^_]+?)_(\S+?)\.php$#', "\\2", $f );
+ $lang = array();
+ $db_lang = array();
+
+ $counts[ $f ] = array();
+
+ if ( ! is_file( $mainDir . $f ) )
+ {
+ continue;
+ }
+
+ /* Require the file */
+ require( $mainDir . $f );/*noLibHook*/
+
+ //-----------------------------------------
+ // Loop
+ //-----------------------------------------
+
+ foreach( $lang as $k => $v )
+ {
+ //-----------------------------------------
+ // Build db array
+ //-----------------------------------------
+
+ $db_array = array(
+ 'lang_id' => $langId,
+ 'word_app' => $app,
+ 'word_pack' => $word_pack,
+ 'word_key' => $k,
+ 'word_custom' => IPSText::convertCharsets($v, 'UTF-8', IPS_DOC_CHAR_SET ),
+ 'word_js' => 0
+ );
+
+ //-----------------------------------------
+ // If cached, get from cache
+ //-----------------------------------------
+
+ if( $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ] )
+ {
+ $lang_entry = $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ];
+ }
+
+ //-----------------------------------------
+ // Otherwise get all langs from this entry and
+ // put in cache
+ //-----------------------------------------
+
+ else
+ {
+ $this->DB->build( array(
+ 'select' => '*',
+ 'from' => 'core_sys_lang_words',
+ 'where' => "lang_id={$langId} AND word_app='{$db_array['word_app']}' AND word_pack='{$db_array['word_pack']}'"
+ ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $lang_entries[ $r['lang_id'] ][ $r['word_app'] ][ $r['word_pack'] ][ $r['word_key'] ] = $r;
+ }
+
+ if( $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ] )
+ {
+ $lang_entry = $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ];
+ }
+ }
+
+ /* Finish off */
+ $db_array['word_default'] = $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ]['word_default'];
+ $db_array['word_default_version'] = $lang_entries[ $langId ][ $db_array['word_app'] ][ $db_array['word_pack'] ][ $db_array['word_key'] ]['word_default_version'];
+ $db_array['word_custom_version'] = IPB_LONG_VERSION;
+
+ //-----------------------------------------
+ // If there is no new custom lang bit to insert
+ // don't delete what is already there.
+ //-----------------------------------------
+
+ if( ! $db_array['word_custom'] )
+ {
+ unset($db_array['word_custom']);
+ }
+
+ //-----------------------------------------
+ // Lang bit already exists, update
+ //-----------------------------------------
+
+ if( $lang_entry['word_id'] )
+ {
+ //-----------------------------------------
+ // Don't update default version
+ //-----------------------------------------
+
+ unset( $db_array['word_default_version'] );
+
+ $counts[ $f ]['updates']++;
+ $this->DB->update( 'core_sys_lang_words', $db_array, "word_id={$lang_entry['word_id']}" );
+ }
+
+ //-----------------------------------------
+ // Lang bit doesn't exist, so insert
+ //-----------------------------------------
+
+ else if( !$lang_entry['word_id'] )
+ {
+ $counts[ $f ]['inserts']++;
+ $this->DB->insert( 'core_sys_lang_words', $db_array );
+ }
+ }
+ }
+ else if( preg_match( '/(\.js)$/', $f ) )
+ {
+ $_js_word_pack = '';
+
+ if( $f == 'ipb.lang.js' )
+ {
+ $_js_word_pack = 'public_js';
+ }
+ else if( $f == 'acp.lang.js' )
+ {
+ $_js_word_pack = 'admin_js';
+ }
+
+ //-----------------------------------------
+ // If not cached, get it
+ //-----------------------------------------
+
+ if( !$js_entries[ $langId ][ $_js_word_pack ] )
+ {
+ $this->DB->build( array(
+ 'select' => '*',
+ 'from' => 'core_sys_lang_words',
+ 'where' => "lang_id={$langId} AND word_pack='{$_js_word_pack}'"
+ ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $js_entries[ $r['word_pack'] ][ $r['word_key'] ] = $r;
+ }
+ }
+
+ //-----------------------------------------
+ // Delete current words for this app and word pack
+ //-----------------------------------------
+
+ $this->DB->delete( 'core_sys_lang_words', 'lang_id=' . $langId . " AND word_app='core' AND word_pack='" . $_js_word_pack . "'" );
+
+ //-----------------------------------------
+ // Get each line
+ //-----------------------------------------
+
+ $js_file = file( $mainDir . $f );
+
+ //-----------------------------------------
+ // Loop through lines and import
+ //-----------------------------------------
+
+ foreach( $js_file as $r )
+ {
+ //-----------------------------------------
+ // preg_match what we want
+ //-----------------------------------------
+
+ preg_match( '#ipb\.lang\[\'(.+?)\'\](.+?)= ["\'](.+?)["\'];#', $r, $matches );
+
+ //-----------------------------------------
+ // Valid?
+ //-----------------------------------------
+
+ if( $matches[1] && $matches[3] )
+ {
+ $counts[ $f ]['inserts']++;
+ $insert = array(
+ 'lang_id' => $langId,
+ 'word_app' => 'core',
+ 'word_pack' => $_js_word_pack,
+ 'word_key' => $matches[1],
+ 'word_custom' => IPSText::convertCharsets($matches[3], 'UTF-8', IPS_DOC_CHAR_SET ),
+ 'word_js' => 1,
+ 'word_default' => $js_entries[ $_js_word_pack ][ $matches[1] ]['word_default'],
+ 'word_default_version' => $js_entries[ $_js_word_pack ][ $matches[1] ]['word_default_version'],
+ 'word_custom_version' => IPB_LONG_VERSION,
+ );
+
+ $this->DB->insert( 'core_sys_lang_words', $insert );
+ }
+ }
+ }
+ }
+
+ closedir( $dh );
+ }
+
+ return $counts;
+ }
+
+
+ /**
+ * Recaches a language pack
+ *
+ * @return @e void
+ */
+ public function recacheLangPack()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $this->cache_errors = array();
+
+ $lang_id = intval( $this->request['id'] );
+
+ $this->cacheToDisk( $lang_id );
+
+ $this->registry->output->global_message = $this->lang->words['language_recache_done'] . ( !empty( $this->cache_errors ) ? ( " " . implode( " ", $this->cache_errors ) ) : '' );
+ $this->languagesList();
+ }
+
+ /**
+ * Remove a word entry
+ *
+ * @return @e void
+ */
+ public function removeWordEntry()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $word_id = intval($this->request['word_id']);
+ $lang_id = intval( $this->request['id'] );
+
+ //-----------------------------------------
+ // Delete lang bit
+ //-----------------------------------------
+
+ $this->DB->delete( 'core_sys_lang_words', 'word_id=' . $word_id );
+
+ //-----------------------------------------
+ // Recache to disk
+ //-----------------------------------------
+
+ $this->cacheToDisk( $lang_id );
+
+ //-----------------------------------------
+ // Bounce to new URL
+ //-----------------------------------------
+
+ $this->request['secure_key'] = $this->registry->adminFunctions->generated_acp_hash;
+ $this->registry->output->global_message = $this->lang->words['language_word_removed'];
+ $this->languageEditWordPack();
+ }
+
+ /**
+ * Remove a word pack
+ *
+ * @return @e void
+ */
+ public function removeWordPack()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $pack = explode( '/', $this->request['word_pack'] );
+ $lang_id = intval( $this->request['id'] );
+
+ if( $lang_id )
+ {
+ //-----------------------------------------
+ // Delete from DB
+ //-----------------------------------------
+
+ $this->DB->delete( 'core_sys_lang_words', "lang_id='{$lang_id}' AND word_pack='" . $pack[1] . "' AND word_app='" . $pack[0] . "'" );
+
+ //-----------------------------------------
+ // Delete from disk
+ //-----------------------------------------
+
+ $_file = IPS_CACHE_PATH . 'cache/lang_cache/' . $lang_id . '/' . $pack[0] . '_' . $pack[1] . '.php';
+
+ if( is_file( $_file ) )
+ {
+ @unlink( $_file );
+ }
+
+ //-----------------------------------------
+ // And recache
+ //-----------------------------------------
+
+ $this->cacheToDisk( $lang_id );
+ }
+
+ //-----------------------------------------
+ // Bounce back
+ //-----------------------------------------
+
+ $this->request['secure_key'] = $this->registry->adminFunctions->generated_acp_hash;
+ $this->registry->output->global_message = $this->lang->words['language_wordpack_removed'];
+ $this->languageListWordPacks();
+ }
+
+ /**
+ * Rebuilds language from XML files
+ *
+ * @return @e void
+ */
+ public function rebuildFromXml()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $apps = array();
+ $previous = trim( $this->request['previous'] );
+ $type = trim( $this->request['type'] );
+ $id = intval($this->request['id']);
+ $_word = ( $type == 'admin' ) ? 'admin' : 'public';
+
+ //-----------------------------------------
+ // Verify writable
+ //-----------------------------------------
+
+ if ( ! is_writeable( IPS_CACHE_PATH . 'cache/lang_cache/' . $id ) )
+ {
+ $this->registry->output->global_error = $this->lang->words['cannot_write_to_cache'] ? sprintf( $this->lang->words['cannot_write_to_cache'], $id ) : "Cannot write to cache/lang_cache/" . $id;
+ $this->languagesList();
+ return;
+ }
+
+ //-----------------------------------------
+ // Get setup class
+ //-----------------------------------------
+
+ require_once( IPS_ROOT_PATH . "setup/sources/base/setup.php" );/*noLibHook*/
+
+ //-----------------------------------------
+ // Get apps
+ //-----------------------------------------
+
+ foreach( ipsRegistry::$applications as $appDir => $appData )
+ {
+ $apps[] = $appDir;
+ }
+
+ //-----------------------------------------
+ // Klude for setup class
+ //-----------------------------------------
+
+ IPSSetUp::setSavedData( 'install_apps', implode( ',', $apps ) );
+
+ //-----------------------------------------
+ // Get next app
+ //-----------------------------------------
+
+ $next = IPSSetUp::fetchNextApplication( $previous, '', $this->settings['gb_char_set'] );
+
+ if ( $next['key'] )
+ {
+ $msg = $next['title'] . sprintf( $this->lang->words['importing_x_langs'], $_word );
+ $_PATH = IPSLib::getAppDir( $next['key'] ) . '/xml/';
+
+ //-----------------------------------------
+ // Try to import all the lang packs
+ //-----------------------------------------
+
+ try
+ {
+ foreach( new DirectoryIterator( $_PATH ) as $f )
+ {
+ if ( preg_match( "#" . $_word . "_(.+?)_language_pack.xml#", $f->getFileName() ) )
+ {
+ $this->request['file_location'] = $_PATH . $f->getFileName();
+ $this->imprtFromXML( 1, true, true, $next['key'], false, 1 );
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ //-----------------------------------------
+ // Off to next setp
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->registry->output->global_template->temporaryRedirect( $this->settings['base_url'] . $this->form_code . "do=rebuildFromXml&id={$id}&type={$type}&previous=" . $next['key'], $msg . ' ' . $this->registry->output->global_message );
+ $this->registry->output->global_message = '';
+ return;
+ }
+ else
+ {
+ if ( $type == 'public' )
+ {
+ //-----------------------------------------
+ // Onto admin languages
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->registry->output->global_template->temporaryRedirect( $this->settings['base_url'] . $this->form_code . "do=rebuildFromXml&id={$id}&type=admin", $this->lang->words['starting_admin_import'] );
+ return;
+ }
+ else
+ {
+ //-----------------------------------------
+ // And we're done
+ //-----------------------------------------
+
+ $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code, $this->lang->words['lang_reimport_done'] );
+ }
+ }
+ }
+
+ /**
+ * Copies a language pack
+ *
+ * @return void
+ */
+ public function languageCopy()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $id = intval( $this->request['id'] );
+
+ //-----------------------------------------
+ // Get lang pack
+ //-----------------------------------------
+
+ $lang_info = $this->DB->buildAndFetch( array( 'select' => 'lang_short, lang_title, lang_isrtl', 'from' => 'core_sys_lang', 'where' => "lang_id={$id}" ) );
+
+ $lang_info['lang_title'] .= " (COPY)";
+
+ //-----------------------------------------
+ // Insert language pack
+ //-----------------------------------------
+
+ $this->DB->insert( 'core_sys_lang', $lang_info );
+ $new_id = $this->DB->getInsertID();
+
+ //-----------------------------------------
+ // Copy the language bits now
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$id}" ) );
+ $q = $this->DB->execute();
+
+ while( $r = $this->DB->fetch( $q ) )
+ {
+ unset( $r['word_id'] );
+ $r['lang_id'] = $new_id;
+
+ $this->DB->insert( 'core_sys_lang_words', $r );
+ }
+
+ //-----------------------------------------
+ // Recache and redirect
+ //-----------------------------------------
+
+ $this->cacheToDisk( $new_id );
+ $this->registry->class_localization->rebuildLanguagesCache();
+
+ $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code, $this->lang->words['l_copied'] );
+ }
+
+ /**
+ * Removes a language pack and cleans up files
+ *
+ * @return void
+ */
+ public function languageRemove()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $id = intval( $this->request['id'] );
+
+ //-----------------------------------------
+ // Make sure this isn't default pack
+ //-----------------------------------------
+
+ $langCheck = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => 'lang_id=' . $id ) );
+
+ if( $langCheck['lang_default'] )
+ {
+ $this->registry->output->showError( $this->lang->words['cannot_delete_default_lang'] );
+ }
+
+ if( $langCheck['lang_protected'] AND !IN_DEV )
+ {
+ $this->registry->output->showError( $this->lang->words['cannot_delete_protected_lang'] );
+ }
+
+ //-----------------------------------------
+ // Delete from database
+ //-----------------------------------------
+
+ $this->DB->delete( 'core_sys_lang' , "lang_id={$id}" );
+ $this->DB->delete( 'core_sys_lang_words', "lang_id={$id}" );
+
+ //-----------------------------------------
+ // Delete from disk
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . '/classFileManagement.php', 'classFileManagement' );
+ $fileManagement = new $classToLoad();
+ $fileManagement->removeDirectory( IPS_CACHE_PATH . 'cache/lang_cache/' . $id . '/' );
+
+ //-----------------------------------------
+ // Update member default choice
+ //-----------------------------------------
+ $default = $this->DB->buildAndFetch( array( 'select' => 'lang_id', 'from' => 'core_sys_lang', 'where' => "lang_default=1" ) );
+ $this->DB->update( 'members', array( 'language' => intval($default['lang_id']) ), "language={$id}" );
+
+ //-----------------------------------------
+ // Update cache and redirect
+ //-----------------------------------------
+
+ $this->registry->class_localization->rebuildLanguagesCache();
+ $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code, $this->lang->words['l_removed'] );
+ }
+
+ /**
+ * Revert a word pack entry to the default value
+ *
+ * @return @e void
+ */
+ public function languageDoRevertWord()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $word_id = intval( $this->request['word_id'] );
+ $lang_id = intval( $this->request['id'] );
+ $pack = explode( '/', $this->request['word_pack'] );
+
+ //-----------------------------------------
+ // Revert
+ //-----------------------------------------
+
+ $this->DB->update( 'core_sys_lang_words', array( 'word_custom' => '' ), "word_id={$word_id}" );
+
+ //-----------------------------------------
+ // Recache
+ //-----------------------------------------
+
+ $this->cacheToDisk( $lang_id );
+
+ //-----------------------------------------
+ // Redirect
+ //-----------------------------------------
+
+ $this->request['secure_key'] = $this->registry->adminFunctions->generated_acp_hash;
+ $this->registry->output->global_message = $this->lang->words['language_word_revert'];
+ $this->languageEditWordPack();
+ }
+
+ /**
+ * Saves new language edits
+ *
+ * @return @e void
+ */
+ public function languageEditWordPackValues()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $id = intval( $this->request['id'] );
+
+ $langCheck = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => 'lang_id=' . $id ) );
+
+ if( $langCheck['lang_protected'] AND !IN_DEV )
+ {
+ $this->registry->output->showError( $this->lang->words['lang_pack_protected'] );
+ }
+
+ /* Got anything? */
+ if ( ! count( array_keys( $_POST['lang'] ) ) )
+ {
+ $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code . "&do=edit_word_pack&word_pack={$this->request['pack']}&id={$this->request['id']}&search={$this->request['search']}&filter={$this->request['filter']}&st={$this->request['st']}", $this->lang->words['language_word_pack_edited'] );
+ }
+
+ //-----------------------------------------
+ // Get the words
+ //-----------------------------------------
+
+ $lang = $this->DB->buildAndFetchAll( array(
+ 'select' => '*',
+ 'from' => 'core_sys_lang_words',
+ 'where' => "lang_id={$id} AND word_id IN(" . implode( ',', array_map( 'intval', array_keys( $_POST['lang'] ) ) ) . ')',
+ ), 'word_id' );
+
+ //-----------------------------------------
+ // Loop through language bits submitted
+ //-----------------------------------------
+
+ if( is_array( $_POST['lang'] ) && count( $_POST['lang'] ) )
+ {
+ foreach( $_POST['lang'] as $k => $v )
+ {
+ if( $v != "" )
+ {
+ $v = IPSText::safeSlashes($v);
+ $v = str_replace( '\', '\\', $v );
+
+ if( $lang[ $k ]['word_pack'] == 'admin_js' OR $lang[ $k ]['word_pack'] == 'public_js' )
+ {
+ $v = str_replace( array( "\r\n", "\r" ), "", $v );
+ }
+
+ $this->DB->update( 'core_sys_lang_words', "word_custom='" . $this->DB->addSlashes( $v ) . "', word_custom_version=word_default_version", "word_id=" . intval($k), false, true );
+ }
+ elseif ( isset( $lang[ $k ] ) and $lang[ $k ]['word_custom'] )
+ {
+ $this->DB->update( 'core_sys_lang_words', array( 'word_custom' => '' ), "word_id=" . intval( $k ) );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Recache and redirect
+ //-----------------------------------------
+
+ $this->cacheToDisk( $id );
+
+ $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code . "&do=edit_word_pack&word_pack={$this->request['pack']}&id={$this->request['id']}&search={$this->request['search']}&filter={$this->request['filter']}&st={$this->request['st']}", $this->lang->words['language_word_pack_edited'] );
+ }
+
+ /**
+ * Handles the word entry form
+ *
+ * @param string $mode Either add or edit
+ * @return @e void
+ */
+ public function handleWordEntryForm( $mode='add' )
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $lang_id = intval( $this->request['id'] );
+ $word_id = intval( $this->request['word_id'] );
+ $LATESTVERSION = IPSLib::fetchVersionNumber();
+
+ //-----------------------------------------
+ // Error checking
+ //-----------------------------------------
+
+ if( ! $this->request['word_pack_db'] )
+ {
+ $this->registry->output->global_error = $this->lang->words['l_packreq'];
+ $this->languageWordEntryForm( $mode );
+ return;
+ }
+
+ if( ! $this->request['word_key'] )
+ {
+ $this->registry->output->global_error = $this->lang->words['l_keyreq'];
+ $this->languageWordEntryForm( $mode );
+ return;
+ }
+
+ if( ! $this->request['word_default'] )
+ {
+ $this->registry->output->global_error = $this->lang->words['l_textreq'];
+ $this->languageWordEntryForm( $mode );
+ return;
+ }
+
+ $this->request['word_app'] = mb_strtolower($this->request['word_app']);
+ $this->request['word_pack_db'] = str_replace( '/', '_', mb_strtolower($this->request['word_pack_db']) );
+
+ if( $this->request['word_pack_db'] == 'admin_js' OR $this->request['word_pack_db'] == 'public_js' )
+ {
+ $this->request['word_app'] = 'core';
+ }
+
+ //-----------------------------------------
+ // Build DB insert array
+ //-----------------------------------------
+
+ $db_array = array(
+ 'lang_id' => $lang_id,
+ 'word_app' => $this->request['word_app'],
+ 'word_pack' => $this->request['word_pack_db'],
+ 'word_key' => $this->request['word_key'],
+ 'word_default' => IPSText::formToText( $_POST['word_default'] ),
+ );
+
+ //-----------------------------------------
+ // Add or update
+ //-----------------------------------------
+
+ if( $mode == 'add' )
+ {
+ /* Check for a duplicate */
+ $_check = $this->DB->buildAndFetch( array( 'select' => 'word_id', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id} AND word_app='{$db_array['word_app']}' AND word_pack='{$db_array['word_pack']}' AND word_key='{$db_array['word_key']}'" ) );
+
+ if( $_check['word_id'] )
+ {
+ $this->registry->output->global_error = $this->lang->words['l_textexistsalready'];
+ $this->languageWordEntryForm( $mode );
+ return;
+ }
+
+ $this->DB->insert( 'core_sys_lang_words', $db_array );
+
+ $text = $this->lang->words['l_added'];
+ }
+ else
+ {
+ $this->DB->update( 'core_sys_lang_words', $db_array, "word_id={$word_id}" );
+
+ $text = $this->lang->words['l_updated'];
+ }
+
+ //-----------------------------------------
+ // Recache and redirect
+ //-----------------------------------------
+
+ $this->cacheToDisk( $lang_id );
+
+ $this->registry->output->redirect( "{$this->settings['base_url']}&module=languages§ion=manage_languages&do=list_word_packs&id={$lang_id}", $text );
+ }
+
+ /**
+ * Form for adding/editing a word entry
+ *
+ * @param string $mode Either add or edit
+ * @return @e void
+ */
+ public function languageWordEntryForm( $mode='add' )
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $word_id = intval( $this->request['word_id'] );
+ $lang_id = intval( $this->request['id'] );
+ $pack = explode( '/', $this->request['word_pack'] );
+
+ //-----------------------------------------
+ // Adding or editing
+ //-----------------------------------------
+
+ if( $mode == 'add' )
+ {
+ $op = 'do_add_word_entry';
+ $title = $this->lang->words['l_addnew'];
+ $header = $this->lang->words['l_addnewfull'];
+ $button = $this->lang->words['l_addthis'];
+ $data = array( 'word_pack' => $pack[1], 'word_app' => $pack[0] );
+ }
+ else
+ {
+ $op = 'do_edit_word_entry';
+ $title = $this->lang->words['l_edit'];
+ $header = $this->lang->words['l_editentry'];
+ $button = $this->lang->words['l_savechanges'];
+
+ //-----------------------------------------
+ // Get data
+ //-----------------------------------------
+
+ $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "word_id={$word_id}" ) );
+ }
+
+ //-----------------------------------------
+ // Set defaults
+ //-----------------------------------------
+
+ $data['word_app'] = !empty( $this->request['word_app'] ) ? $this->request['word_app'] : $data['word_app'];
+ $data['word_pack'] = !empty( $this->request['word_pack_db'] ) ? $this->request['word_pack_db'] : $data['word_pack'];
+ $data['word_key'] = !empty( $this->request['word_key'] ) ? $this->request['word_key'] : $data['word_key'];
+ $data['word_default'] = !empty( $this->request['word_default'] ) ? $this->request['word_default'] : $data['word_default'];
+
+ //-----------------------------------------
+ // Applications dropdown
+ //-----------------------------------------
+
+ $_apps = array();
+
+ foreach( ipsRegistry::$applications as $app => $appdata )
+ {
+ $_apps[] = array( $app, $appdata['app_title'] );
+ }
+
+ $data['word_app'] = $this->compileSelectOptions( $_apps, $data['word_app'] );
+
+ //-----------------------------------------
+ // Output form
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->html->languageWordEntryForm( $op, $word_id, $lang_id, $title, $header, $data, $button );
+ }
+
+ /**
+ * Creates an option list for select tags
+ *
+ * @param array $options Array of values/text for dropdown
+ * @param mixed [$selected] Selected value or array of selected values
+ * @return string
+ */
+ public function compileSelectOptions( $options, $selected='' )
+ {
+ if( ! is_array( $selected ) )
+ {
+ $selected = array( $selected );
+ }
+
+ $html = '';
+ if( is_array( $options ) )
+ {
+ foreach( $options as $option )
+ {
+ $sel = ( $option[0] AND in_array( $option[0], $selected ) ) ? ' selected="selected"' : '';
+ $val = ( $option[0] == 'disabled' ) ? 'disabled="disabled"' : "value='{$option[0]}'";
+
+ $html .= "{$option[1]} ";
+ }
+ }
+
+ return $html;
+ }
+
+ /**
+ * Adds the button and content to the tab list for this object
+ *
+ * @param string $button
+ * @param string $content
+ * @param string [$js_action]
+ * @return @e void
+ */
+ public function addTab( $button, $content, $js_action='', $default_tab=0 )
+ {
+ $this->tab_buttons[] = $button;
+ $this->tab_tabs[] = $content;
+ $this->tab_js_action[] = $js_action;
+
+ if( $default_tab )
+ {
+ $this->default_tab = count( $this->tab_tabs ) - 1;
+ }
+ }
+
+ /**
+ * Builds the html for the tabbed area
+ *
+ * @return string Tab HTML
+ */
+ public function buildTabs()
+ {
+ /* Buttons */
+ $i = 0;
+ $tabs = array();
+ foreach( $this->tab_buttons as $i => $button )
+ {
+ /* Tab Button */
+ $js = ( $this->tab_js_action[$i] ) ? 'onmousedown="'.$this->tab_js_action[$i].'"' : '';
+ $tabs[] = array( 'id' => $i, 'text' => $button, 'js' => $js );
+ }
+
+ /* Tab Contents */
+ $i = 0;
+ $content = array();
+ foreach( $this->tab_tabs as $tab )
+ {
+ /* Create the pane */
+ $content[] = array( 'id' => $i, 'content' => $tab );
+ $i++;
+ }
+
+ $default_tab = ( $this->default_tab ) ? $this->default_tab : '';
+
+ /* End of tab pane */
+ $tabs = $this->html->ui_content_tabs( $tabs, $content, $default_tab );
+
+ return $tabs;
+ }
+
+ /**
+ * Edit the entries in a word pack
+ *
+ * @return @e void
+ */
+ public function languageEditWordPack()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ /* Fix up for search */
+ $keywordForPageLinks = $this->request['search'];
+ $this->request['search'] = str_replace( "'", "\\'", $this->request['search'] );
+
+ $id = intval( $this->request['id'] );
+ $pack = explode( '/', $this->request['word_pack'] );
+ $per_page = 20;
+ $st = $this->request['st'] ? intval( $this->request['st'] ) : 0;
+ $search = $this->request['search'] ? " AND ( word_default LIKE '%" . $this->request['search'] . "%' OR word_custom LIKE '%" . $this->request['search'] . "%' OR word_key LIKE '%" . $this->request['search'] . "%' )" : '';
+ $filter = $this->request['filter'] ? " AND word_custom_version < word_default_version AND word_custom " . $this->DB->buildIsNull(false) . ' ' : '';
+ $wp_query = $pack[0] && $pack[1] ? " AND word_app='{$pack[0]}' AND word_pack='{$pack[1]}' " : '';
+
+ //-----------------------------------------
+ // Get language pack
+ //-----------------------------------------
+
+ $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$id}" ) );
+
+ //-----------------------------------------
+ // How many words?
+ //-----------------------------------------
+
+ $count = $this->DB->buildAndFetch( array(
+ 'select' => 'COUNT(*) as count',
+ 'from' => 'core_sys_lang_words',
+ 'where' => "lang_id={$id} {$wp_query} {$search} {$filter}"
+ ) );
+
+ //-----------------------------------------
+ // Pagination
+ //-----------------------------------------
+
+ $pages = $this->registry->output->generatePagination( array(
+ 'totalItems' => intval( $count['count'] ),
+ 'itemsPerPage' => $per_page,
+ 'currentStartValue' => $st,
+ 'baseUrl' => "{$this->settings['base_url']}{$this->form_code}&do=edit_word_pack&word_pack=".implode( '/', $pack )."&id={$id}&search={$keywordForPageLinks}&filter={$this->request['filter']}",
+ ) );
+
+ //-----------------------------------------
+ // Get the words
+ //-----------------------------------------
+
+ $this->DB->build( array(
+ 'select' => '*',
+ 'from' => 'core_sys_lang_words',
+ 'where' => "lang_id={$id} {$wp_query} {$search} {$filter}",
+ 'limit' => array( $st, $per_page ),
+ 'order' => 'word_key ASC'
+ ) );
+ $this->DB->execute();
+
+ $lang = array();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $lang[] = array(
+ 'id' => $r['word_id'],
+ 'default' => nl2br( htmlspecialchars( $r['word_default'], ENT_QUOTES ) ),
+ 'custom' => htmlspecialchars( $r['word_custom'], ENT_QUOTES ),
+ 'pack' => $r['word_app'] . '/' . $r['word_pack'],
+ 'key' => $r['word_key']
+ );
+ }
+
+ //-----------------------------------------
+ // Output
+ //-----------------------------------------
+
+ $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=list_word_packs&id={$id}", $data['lang_title'] );
+ $this->registry->output->extra_nav[] = array( '', $this->lang->words['language_word_pack_edit'] );
+ $this->registry->output->html .= $this->html->languageWordPackEdit( $id, $lang, $pages );
+ }
+
+ /**
+ * List the word packs available for the selected language set
+ *
+ * @return @e void
+ * @author Josh
+ */
+ public function languageListWordPacks()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $id = intval( $this->request['id'] );
+
+ //-----------------------------------------
+ // Get language pack
+ //-----------------------------------------
+
+ $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$id}" ) );
+
+ $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=list_word_packs&id={$data['lang_id']}", $data['lang_title'] );
+
+ //-----------------------------------------
+ // Get words
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$id}" ) );
+ $this->DB->execute();
+
+ //-----------------------------------------
+ // Some init before looping
+ //-----------------------------------------
+
+ $_packs = array();
+ $_missing = array();
+ $_stats = array();
+
+ while( $r = $this->DB->fetch() )
+ {
+ //-----------------------------------------
+ // Create our array
+ //-----------------------------------------
+
+ $_stats[$r['word_app']] = isset( $_stats[$r['word_app']] ) ? $_stats[$r['word_app']] : array();
+ $_stats[$r['word_app']][$r['word_pack']] = isset( $_stats[$r['word_app']][$r['word_pack']] ) ? $_stats[$r['word_app']][$r['word_pack']] : array();
+ $_stats[$r['word_app']][$r['word_pack']]['total'] = isset( $_stats[$r['word_app']][$r['word_pack']]['total'] ) ? $_stats[$r['word_app']][$r['word_pack']]['total'] : 0;
+
+ if( ! isset( $_packs[$r['word_app']] ) )
+ {
+ $_packs[$r['word_app']] = array();
+ }
+
+ //-----------------------------------------
+ // Add this language pack to array
+ //-----------------------------------------
+
+ if( ! in_array( $r['word_pack'], $_packs[$r['word_app']] ) )
+ {
+ $_packs[$r['word_app']][] = $r['word_pack'];
+ }
+
+ //-----------------------------------------
+ // Update stats
+ //-----------------------------------------
+
+ $_stats[$r['word_app']][$r['word_pack']]['total']++;
+
+ if( $r['word_custom'] )
+ {
+ $_stats[$r['word_app']][$r['word_pack']]['custom']++;
+
+ if( $r['word_custom_version'] < $r['word_default_version'] )
+ {
+ $_stats[$r['word_app']][$r['word_pack']]['outofdate']++;
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Loop through applications
+ //-----------------------------------------
+
+ foreach( ipsRegistry::$applications as $app => $data )
+ {
+ //-----------------------------------------
+ // Check if app has langs
+ //-----------------------------------------
+
+ if( isset( $_packs[$app] ) && count( $_packs[$app] ) )
+ {
+ $default_tab = ( $app == $this->request['app'] ) ? 1 : 0;
+ asort($_packs[$app]);
+
+ $this->addTab( $data['app_title'], $this->html->languageAppPackList( $app, $_packs[$app], $_stats[$app] ), '', $default_tab );
+ }
+ }
+
+ //-----------------------------------------
+ // And output
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->html->languageWordPackList( $id, $this->buildTabs(), $data['app_title'] );
+ }
+
+ /**
+ * Handles the language information form submit
+ *
+ * @param string $mode Either new or edit
+ * @return @e void
+ */
+ public function handleLanguageInformationForm( $mode='new' )
+ {
+ //-----------------------------------------
+ // Error checking
+ //-----------------------------------------
+
+ $errors = array();
+
+ if( ! $this->request['lang_title'] )
+ {
+ $errors[] = $this->lang->words['language_title_missing'];
+ }
+
+ if( ! $this->request['lang_short'] )
+ {
+ $errors[] = $this->lang->words['language_locale_missing'];
+ }
+
+ if( count( $errors ) )
+ {
+ $this->registry->output->global_message = implode( ', ', $errors );
+ $this->languageInformationForm( $mode );
+ return;
+ }
+
+ //-----------------------------------------
+ // Build insert array
+ //-----------------------------------------
+
+ $db_array = array(
+ 'lang_title' => $this->request['lang_title'],
+ 'lang_short' => $this->request['lang_short'],
+ 'lang_default' => $this->request['lang_default'],
+ 'lang_isrtl' => $this->request['lang_isrtl'],
+ );
+
+ //-----------------------------------------
+ // Adding or editing
+ //-----------------------------------------
+
+ if( $mode == 'new' )
+ {
+ //-----------------------------------------
+ // Default?
+ //-----------------------------------------
+
+ if( $this->request['lang_default'] )
+ {
+ $this->DB->update( 'core_sys_lang', array( 'lang_default' => 0 ) );
+
+ $db_array['lang_default'] = 1;
+ }
+
+ //-----------------------------------------
+ // Insert and get id
+ //-----------------------------------------
+
+ $this->DB->insert( 'core_sys_lang', $db_array );
+
+ $id = $this->DB->getInsertId();
+
+ //-----------------------------------------
+ // Create directory
+ //-----------------------------------------
+
+ @mkdir( IPS_CACHE_PATH . 'cache/lang_cache/' . $id, IPS_FOLDER_PERMISSION );
+ @file_put_contents( IPS_CACHE_PATH . 'cache/lang_cache/' . $id . '/index.html', '' );
+ @chmod( IPS_CACHE_PATH . 'cache/lang_cache/' . $id, IPS_FOLDER_PERMISSION );
+
+ //-----------------------------------------
+ // Copy over language bits from default lang
+ //-----------------------------------------
+
+ $default = $this->DB->buildAndFetch( array( 'select' => 'lang_id', 'from' => 'core_sys_lang', 'where' => "lang_default=1" ) );
+
+ $this->DB->build( array( 'select' => 'word_app,word_pack,word_key,word_default', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$default['lang_id']}" ) );
+ $q = $this->DB->execute();
+
+ while( $r = $this->DB->fetch( $q ) )
+ {
+ $r['lang_id'] = $id;
+ $this->DB->insert( 'core_sys_lang_words', $r );
+ }
+
+ //-----------------------------------------
+ // Rebuild IPB and disk caches
+ //-----------------------------------------
+
+ $this->registry->class_localization->rebuildLanguagesCache();
+ $this->cacheToDisk($id);
+
+ //-----------------------------------------
+ // Show listing
+ //-----------------------------------------
+
+ $this->registry->output->global_message = $this->lang->words['language_pack_created'];
+ $this->languagesList();
+ }
+ else
+ {
+ //-----------------------------------------
+ // Default?
+ //-----------------------------------------
+
+ if( $this->request['lang_default'] )
+ {
+ $this->DB->update( 'core_sys_lang', array( 'lang_default' => 0 ) );
+
+ $db_array['lang_default'] = 1;
+ }
+
+ //-----------------------------------------
+ // Check ID and update
+ //-----------------------------------------
+
+ $id = intval( $this->request['id'] );
+
+ $this->DB->update( 'core_sys_lang', $db_array, "lang_id={$id}" );
+
+ //-----------------------------------------
+ // Rebuild cache and show list
+ //-----------------------------------------
+
+ $this->registry->class_localization->rebuildLanguagesCache();
+ $this->registry->output->global_message = $this->lang->words['language_pack_updated'];
+ $this->languagesList();
+ }
+ }
+
+ /**
+ * Builds the language information form
+ *
+ * @param string $mode new or edit
+ * @return @e void
+ */
+ public function languageInformationForm( $mode='new' )
+ {
+ //-----------------------------------------
+ // Adding or editing
+ //-----------------------------------------
+
+ if( $mode == 'new' )
+ {
+ $title = $this->lang->words['language_form_new_title'];
+ $button = $this->lang->words['language_form_new_button'];
+ $op = 'do_new_language';
+ $header = $this->lang->words['language_form_new_info'];
+ $data = array(0);
+ $id = 0;
+ }
+ else
+ {
+ $title = $this->lang->words['language_form_edit_title'];
+ $button = $this->lang->words['language_form_edit_button'];
+ $op = 'do_edit_lang_info';
+ $header = $this->lang->words['language_form_edit_info'];
+ $id = intval( $this->request['id'] );
+
+ if( ! $id )
+ {
+ $this->registry->output->showError( $this->lang->words['invalid_id'], 11147 );
+ }
+
+ //-----------------------------------------
+ // Get language pack info
+ //-----------------------------------------
+
+ $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$id}" ) );
+ }
+
+ //-----------------------------------------
+ // Set some defaults
+ //-----------------------------------------
+
+ $data['lang_title'] = !empty( $this->request['lang_title'] ) ? $this->request['lang_title'] : $data['lang_title'];
+ $data['lang_short'] = !empty( $this->request['lang_short'] ) ? $this->request['lang_short'] : $data['lang_short'];
+ $data['lang_default'] = !empty( $this->request['lang_default'] ) ? $this->request['lang_default'] : $data['lang_default'];
+ $data['lang_isrtl'] = !empty( $this->request['lang_isrtl'] ) ? $this->request['lang_isrtl'] : $data['lang_isrtl'];
+
+ $data['lang_default'] = $this->registry->output->formYesNo( 'lang_default', $data['lang_default'] );
+ $data['lang_isrtl'] = $this->registry->output->formYesNo( 'lang_isrtl', $data['lang_isrtl'] );
+
+ //-----------------------------------------
+ // Show form
+ //-----------------------------------------
+
+ $this->registry->output->extra_nav[] = array( '', $title );
+ $this->registry->output->html .= $this->html->languageInformationForm( $op, $id, $title, $header, $data, $button );
+ }
+
+ /**
+ * Lists currently installed languages
+ *
+ * @return @e void
+ */
+ public function languagesList()
+ {
+ /* Do we have a valid translation session? */
+ $sessionData = $this->cache->getCache('translate_session');
+ $hasTranslate = false;
+
+ /* Check */
+ if ( ! empty( $sessionData['lang_id'] ) AND count( $sessionData['files'] ) )
+ {
+ $hasTranslate = true;
+ }
+
+ /* Fallback for the recache all button */
+ $forceEnglish = IPSCookie::get('forceEnglish');
+
+ if ( !$this->lang->words['language_list_recache'] || $forceEnglish )
+ {
+ $this->lang->words['language_list_recache'] = 'Recache all...';
+ }
+
+ //-----------------------------------------
+ // Get languages
+ //-----------------------------------------
+
+ $rows = array();
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ /* Get Local Data */
+ //setlocale( LC_ALL, $r['lang_short'] );
+ IPSLib::setlocale( $r['lang_short'] );
+ $this->registry->class_localization->local_data = localeconv();
+
+ $_menu = array();
+
+ if( $r['lang_protected'] && ! IN_DEV )
+ {
+ $_menu[] = array( "", $this->lang->words['lang_pack_protected'], 'edit' );
+ }
+ else
+ {
+ $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=list_word_packs&id={$r['lang_id']}", $this->lang->words['language_list_translate'], 'info' );
+
+ /* If we don't have a current session... */
+ if ( ! $hasTranslate )
+ {
+ $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=translateExtSplash&id={$r['lang_id']}", $this->lang->words['language_list_translate_ext'], 'info' );
+ }
+ }
+
+ $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=copy_lang_pack&id={$r['lang_id']}", $this->lang->words['language_list_copy'] );
+
+ $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=export&id={$r['lang_id']}", $this->lang->words['l_xmlexportfull'], 'export' );
+
+ if ( $r['lang_id'] )
+ {
+ $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=rebuildFromXml&id={$r['lang_id']}&type=public", $this->lang->words['rebuild_lang_from_xml'] );
+ }
+
+ foreach( ipsRegistry::$applications as $app_dir => $app_data )
+ {
+ $_menu[] = array( "{$this->settings['base_url']}{$this->form_code}&do=export&id={$r['lang_id']}&app_dir={$app_dir}", $this->lang->words['l_xmlexport'] . $app_data['app_title'], 'export' );
+ }
+
+ //-----------------------------------------
+ // Data for output
+ //-----------------------------------------
+
+ $rows[] = array( 'title' => $r['lang_title'],
+ 'local' => $r['lang_short'],
+ 'date' => $this->registry->class_localization->getDate( time(), 'long', 1 ) . ' ' . $this->registry->class_localization->getDate( time(), 'short', 1 ),
+ 'money' => $this->registry->class_localization->formatMoney( '12345231.12', 0 ),
+ 'default' => $r['lang_default'],
+ 'menu' => $_menu,
+ 'id' => $r['lang_id'],
+ 'protected'=> $r['lang_protected'],
+ );
+ }
+
+ //-----------------------------------------
+ // Reset locale
+ //-----------------------------------------
+
+ IPSLib::setlocale( $this->registry->class_localization->local );
+ //setlocale( LC_ALL, $this->registry->class_localization->local );
+ $this->registry->class_localization->local_data = localeconv();
+
+ //-----------------------------------------
+ // Output
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->html->languages_list( $rows, $hasTranslate );
+ }
+
+ /**
+ * Updates the cached language files from the database
+ *
+ * @param integer ID of the language pack to export
+ * @param string Just cache one app?
+ * @return @e void
+ */
+ public function cacheToDisk( $lang_id, $app_override='' )
+ {
+ /* Generate cached warning */
+ $warnString = "/*******************************************************\nNOTE: This is a cache file generated by IP.Board on " . date( "r" ) . " by " . $this->memberData['members_display_name'] . "\nDo not translate this file as you will lose your translations next time you edit via the ACP\nPlease translate via the ACP\n*******************************************************/\n\n";
+
+ //-----------------------------------------
+ // Build where statement
+ //-----------------------------------------
+
+ if ( $lang_id == 'master' )
+ {
+ $lang_id = 'master_lang';
+ $where = "lang_id=1";
+ }
+ else if( $lang_id AND $lang_id != 1 )
+ {
+ $where = "lang_id={$lang_id}";
+ }
+ else
+ {
+ $lang_id = 1;
+ $where = "lang_id=1";
+ }
+
+ //-----------------------------------------
+ // If missing directory, create
+ //-----------------------------------------
+
+ if( ! is_dir( IPS_CACHE_PATH . 'cache/lang_cache/' . $lang_id . '/' ) )
+ {
+ mkdir( IPS_CACHE_PATH . 'cache/lang_cache/' . $lang_id . '/', IPS_FOLDER_PERMISSION );
+ }
+
+ /* Loop over apps */
+ $this->DB->build( array( 'select' => 'DISTINCT(word_app) as word_app',
+ 'from' => 'core_sys_lang_words',
+ 'limit' => array(0, 100 ) ) ); # Because you never know.
+
+ $o = $this->DB->execute();
+
+ while( $langApps = $this->DB->fetch( $o ) )
+ {
+
+ if ( $app_override )
+ {
+ if ( $app_override != $langApps['word_app'] )
+ {
+ continue;
+ }
+ }
+
+ //-----------------------------------------
+ // Get the words
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'word_custom, word_default, word_app, word_pack, word_key',
+ 'from' => 'core_sys_lang_words',
+ 'where' => $where . " AND word_app='" . $langApps['word_app'] . "'",
+ 'order' => 'word_key ASC' ) );
+
+ $i = $this->DB->execute();
+
+ $words_by_file = array();
+
+ while( $r = $this->DB->fetch( $i ) )
+ {
+ $_text = ( $r['word_custom'] ) ? $r['word_custom'] : $r['word_default'];
+ $words_by_file[$r['word_app']][$r['word_pack']][] = array( $r['word_key'], $_text );
+ }
+
+ //-----------------------------------------
+ // Now loop and write to file
+ //-----------------------------------------
+
+ foreach( $words_by_file as $app => $word_packs )
+ {
+ foreach( $word_packs as $pack => $words )
+ {
+ if( $pack == 'public_js' )
+ {
+ $to_write = '';
+ $_file = 'ipb.lang.js';
+
+ foreach( $words as $word )
+ {
+ $word[1] = str_replace( "\\", "\\\\", $word[1] );
+ $word[1] = str_replace( '"', '\\"', $word[1] );
+ $to_write .= "ipb.lang['{$word[0]}'] = \"{$word[1]}\";\n";
+ }
+ }
+ else if( $pack == 'admin_js' )
+ {
+ $to_write = '';
+ $_file = 'acp.lang.js';
+
+ foreach( $words as $word )
+ {
+ $word[1] = str_replace( "\\", "\\\\", $word[1] );
+ $word[1] = str_replace( '"', '\\"', $word[1] );
+ $to_write .= "ipb.lang['{$word[0]}'] = \"{$word[1]}\";\n";
+ }
+ }
+ else
+ {
+ //-----------------------------------------
+ // Build cache file contents
+ //-----------------------------------------
+
+ $to_write = " \"{$word[1]}\",\n";
+ }
+
+ $to_write .= " ); \n";
+ }
+
+ //-----------------------------------------
+ // Write the file
+ //-----------------------------------------
+
+ $_dir = IPS_CACHE_PATH . 'cache/lang_cache/' . $lang_id . '/';
+
+ if( is_file($_dir . $_file) )
+ {
+ @unlink( $_dir . $_file );
+ }
+
+ if ( $fh = @fopen( $_dir . $_file, 'wb' ) )
+ {
+ fwrite( $fh, $to_write, strlen( $to_write ) );
+ fclose( $fh );
+ @chmod( $_dir . $_file, IPS_FILE_PERMISSION );
+ }
+ else
+ {
+ $this->cache_errors[] = $this->lang->words['l_nowrite'] . $_dir . $_file;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Imports language packs from an xml file and updates the database and recaches the languages
+ *
+ * @param integer $lang_id ID of the language pack to import
+ * @param bool $in_dev Set to 1 for developer language import
+ * @param bool $no_return If set to 1, this function will return a value, rather than outputting data
+ * @param string $app_override Overrides the application for which languages are being imported
+ * @param bool $skip_charset Skips charset conversion in the XML file (useful during upgrade routine as strings don't need to be converted)
+ * @return mixed
+ */
+ public function imprtFromXML( $lang_id=0, $in_dev=0, $no_return=0, $app_override='', $skip_charset=false, $ru = '' )
+ {
+ //-----------------------------------------
+ // Set version..
+ //-----------------------------------------
+
+ $LATESTVERSION = IPSLib::fetchVersionNumber();
+
+ //-----------------------------------------
+ // INDEV?
+ //-----------------------------------------
+
+ if ( $in_dev )
+ {
+ $_FILES['FILE_UPLOAD']['name'] = '';
+ }
+ else if( $this->request['file_location'] )
+ {
+ $this->request['file_location'] = IPS_ROOT_PATH . $this->request['file_location'];
+ }
+
+ //-----------------------------------------
+ // Not an upload?
+ //-----------------------------------------
+
+ if ( $_FILES['FILE_UPLOAD']['name'] == "" or ! $_FILES['FILE_UPLOAD']['name'] or ($_FILES['FILE_UPLOAD']['name'] == "none") )
+ {
+ //-----------------------------------------
+ // Check and load from server
+ //-----------------------------------------
+
+ if ( ! $this->request['file_location'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['l_nofile'];
+ $this->languagesList();
+ return;
+ }
+
+ if ( ! is_file( $this->request['file_location'] ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['l_noopen'] . $this->request['file_location'];
+ $this->languagesList();
+ return;
+ }
+
+ if ( preg_match( '#\.gz$#', $this->request['file_location'] ) )
+ {
+ if ( $FH = @gzopen( $this->request['file_location'], 'rb' ) )
+ {
+ while ( ! @gzeof( $FH ) )
+ {
+ $content .= @gzread( $FH, 1024 );
+ }
+
+ @gzclose( $FH );
+ }
+ }
+ else
+ {
+ $content = file_get_contents( $this->request['file_location'] );
+ }
+
+ $originalContent = $content;
+
+ //-----------------------------------------
+ // Extract archive
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH.'classXMLArchive.php' );/*noLibHook*/
+ $xmlarchive = new classXMLArchive();
+
+ //-----------------------------------------
+ // Read the archive
+ //-----------------------------------------
+
+ $xmlarchive->readXML( $content );
+
+ //-----------------------------------------
+ // Get the data
+ //-----------------------------------------
+
+ $content = '';
+
+ foreach( $xmlarchive->asArray() as $k => $f )
+ {
+ if( $k == 'language_entries.xml' )
+ {
+ $content = $f['content'];
+ break;
+ }
+ }
+
+ //-----------------------------------------
+ // No content from de-archiving, must not
+ // be archive, but rather raw XML file
+ //-----------------------------------------
+
+ if( $content == '' AND strpos( $originalContent, "registry->output->global_message = sprintf( $this->lang->words['lang_upload_too_large'], ini_get( 'upload_max_filesize' ) );
+ $this->languagesList();
+ return;
+ break;
+
+ default:
+ $this->registry->output->global_message = $this->lang->words['lang_upload_other_error'];
+ $this->languagesList();
+ return;
+ break;
+ }
+ }
+
+ //-----------------------------------------
+ // Get content
+ //-----------------------------------------
+
+ try
+ {
+ $uploadedContent = $this->registry->adminFunctions->importXml( $tmp_name );
+ }
+ catch ( Exception $e )
+ {
+ $this->registry->output->showError( $e->getMessage() );
+ }
+
+ //-----------------------------------------
+ // Extract archive
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH.'classXMLArchive.php' );/*noLibHook*/
+ $xmlarchive = new classXMLArchive();
+
+ //-----------------------------------------
+ // Read the archive
+ //-----------------------------------------
+
+ $xmlarchive->readXML( $uploadedContent );
+
+ //-----------------------------------------
+ // Get the data
+ //-----------------------------------------
+
+ $content = '';
+
+ foreach( $xmlarchive->asArray() as $k => $f )
+ {
+ if( $k == 'language_entries.xml' )
+ {
+ $content = $f['content'];
+ break;
+ }
+ }
+
+ //-----------------------------------------
+ // No content from de-archiving, must not
+ // be archive, but rather raw XML file
+ //-----------------------------------------
+
+ if( $content == '' AND strpos( $uploadedContent, "registry->output->global_message = $this->lang->words['l_badfile'];
+ $this->languagesList();
+ return;
+ }
+
+ //-----------------------------------------
+ // Get xml class
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
+
+ $xml = new classXML( $skip_charset ? 'utf-8' : IPS_DOC_CHAR_SET );
+ $xml->loadXML( $content );
+
+ //-----------------------------------------
+ // Is this full language pack?...
+ //-----------------------------------------
+
+ foreach( $xml->fetchElements('langinfo') as $lang_data )
+ {
+ $lang_info = $xml->fetchElementsFromRecord( $lang_data );
+
+ $lang_data = array(
+ 'lang_short' => $lang_info['lang_short'],
+ 'lang_title' => $lang_info['lang_title'],
+ );
+ }
+
+ $lang_ids = array();
+ $insertId = 0;
+
+ //-----------------------------------------
+ // Do we have language pack info?
+ //-----------------------------------------
+
+ if( $lang_data['lang_short'] )
+ {
+ //-----------------------------------------
+ // Does this pack already exist
+ //-----------------------------------------
+
+ $update_lang = $this->DB->buildAndFetch( array(
+ 'select' => 'lang_id',
+ 'from' => 'core_sys_lang',
+ 'where' => "lang_short='{$lang_data['lang_short']}'",
+ ) );
+
+ //-----------------------------------------
+ // If doesn't exist, then create new pack
+ //-----------------------------------------
+
+ if( !$update_lang['lang_id'] )
+ {
+ $this->DB->insert( 'core_sys_lang', $lang_data );
+
+ $insertId = $this->DB->getInsertId();
+
+ if( @mkdir( IPS_CACHE_PATH . '/cache/lang_cache/' . $insertId ) )
+ {
+ @file_put_contents( IPS_CACHE_PATH . 'cache/lang_cache/' . $insertId . '/index.html', '' );
+ @chmod( IPS_CACHE_PATH . '/cache/lang_cache/' . $insertId, IPS_FOLDER_PERMISSION );
+ }
+
+ //-----------------------------------------
+ // Copy over language bits from default lang
+ //-----------------------------------------
+
+ $default = $this->DB->buildAndFetch( array( 'select' => 'lang_id', 'from' => 'core_sys_lang', 'where' => "lang_default=1" ) );
+
+ $this->DB->build( array( 'select' => 'word_app,word_pack,word_key,word_default,word_js', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$default['lang_id']}" ) );
+ $q = $this->DB->execute();
+
+ while( $r = $this->DB->fetch( $q ) )
+ {
+ $r['lang_id'] = $insertId;
+ $r['word_custom'] = '';
+
+ $this->DB->insert( 'core_sys_lang_words', $r );
+ }
+
+ //-----------------------------------------
+ // Rebuild IPB and disk caches
+ //-----------------------------------------
+
+ $this->registry->class_localization->rebuildLanguagesCache();
+ }
+ else
+ {
+ $insertId = $update_lang['lang_id'];
+ }
+ }
+
+ //-----------------------------------------
+ // We need to add language bits to every pack..
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'lang_id', 'from' => 'core_sys_lang' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $lang_ids[] = $r['lang_id'];
+ }
+
+ //-----------------------------------------
+ // Init counts array
+ //-----------------------------------------
+
+ $counts = array( 'updates' => 0, 'inserts' => 0 );
+
+ //-----------------------------------------
+ // Init a cache array to save entries
+ //-----------------------------------------
+
+ $lang_entries = array();
+
+ if( $app_override )
+ {
+ $this->DB->build( array( 'select' => "MD5( CONCAT( lang_id, '-', word_app, '-', word_pack, '-', word_key ) ) as word_lookup, word_id, md5(word_default) as word_default, word_default_version",
+ 'from' => 'core_sys_lang_words',
+ 'where' => "word_app='{$app_override}' AND lang_id IN(" . implode( ",", $lang_ids ) . ")" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $lang_entries[ $r['word_lookup'] ] = $r;
+ }
+ }
+
+ //-----------------------------------------
+ // Start looping
+ //-----------------------------------------
+
+ $_lastLookup = '';
+
+ foreach( $xml->fetchElements('lang') as $entry )
+ {
+ $lang = $xml->fetchElementsFromRecord( $entry );
+
+ foreach( $lang_ids as $_lang_id )
+ {
+ $lang_entry = array();
+
+ //-----------------------------------------
+ // Build db array
+ //-----------------------------------------
+
+ $db_array = array(
+ 'lang_id' => $_lang_id,
+ 'word_app' => $app_override ? $app_override : $lang['word_app'],
+ 'word_pack' => $lang['word_pack'],
+ 'word_key' => $lang['word_key'],
+ 'word_default' => $lang['word_default'],
+ 'word_custom' => $in_dev && !$ru ? '' : $lang['word_custom'],
+ 'word_js' => intval($lang['word_js']),
+ 'word_default_version' => $lang['word_default_version'] ? $lang['word_default_version'] : $LATESTVERSION['long'],
+ 'word_custom_version' => $lang['word_custom_version'],
+ );
+
+ $dbKey = md5( $db_array['lang_id'] . '-' . $db_array['word_app'] . '-' . $db_array['word_pack'] . '-' . $db_array['word_key'] );
+ $langIdKey = md5( $_lang_id . '-' . $db_array['word_app'] . '-' . $db_array['word_pack'] . '-' . $db_array['word_key'] );
+
+ // If the default value hasn't changed, we don't need to update the word_default_version (see bug report 19172)
+ if ( md5( $lang['word_default'] ) == $lang_entries[ $dbKey ]['word_default'] )
+ {
+ $db_array['word_default_version'] = $lang_entries[ $dbKey ]['word_default_version'];
+ }
+
+ //-----------------------------------------
+ // If cached, get from cache
+ //-----------------------------------------
+
+ if ( $lang_entries[ $langIdKey ] )
+ {
+ $lang_entry = $lang_entries[ $langIdKey ];
+ }
+
+ //-----------------------------------------
+ // Otherwise get all langs from this entry and
+ // put in cache
+ //-----------------------------------------
+
+ else if( ! $app_override )
+ {
+ if( $_lastLookup != md5( $db_array['word_app'] . '-' . $db_array['word_pack'] ) )
+ {
+ unset( $lang_entries );
+ }
+
+ $_lastLookup = md5( $db_array['word_app'] . '-' . $db_array['word_pack'] );
+
+ $this->DB->build( array(
+ 'select' => '*',
+ 'from' => 'core_sys_lang_words',
+ 'where' => "lang_id={$_lang_id} AND word_app='{$db_array['word_app']}' AND word_pack='{$db_array['word_pack']}'"
+ ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $lang_entries[ md5( $r['lang_id'] . '-' . $r['word_app'] . '-' . $r['word_pack'] . '-' . $r['word_key'] ) ] = $r;
+ }
+
+ if ( $lang_entries[ $langIdKey ] )
+ {
+ $lang_entry = $lang_entries[ $langIdKey ];
+ }
+ }
+
+ //-----------------------------------------
+ // Didn't find any match? Must be importing
+ // a new language pack, huh?
+ //-----------------------------------------
+
+ if ( !isset( $lang_entry['word_id'] ) )
+ {
+ //continue 2;
+ }
+
+ //-----------------------------------------
+ // If there is no new custom lang bit to insert
+ // don't delete what is already there.
+ //-----------------------------------------
+
+ if( !$db_array['word_custom'] || ( $insertId > 0 && $insertId != $_lang_id ) )
+ {
+ unset($db_array['word_custom']);
+ unset($db_array['word_custom_version']);
+ }
+
+ //-----------------------------------------
+ // Lang bit already exists, update
+ //-----------------------------------------
+
+ if ( $lang_entry['word_id'] AND ( ! $insertId OR ( $insertId == $_lang_id ) ) )
+ {
+ //-----------------------------------------
+ // Don't update default version
+ //-----------------------------------------
+
+ // This causes no languages to show "out of date" on upgrade
+ // @link http://community.invisionpower.com/tracker/issue-31637-no-out-of-date-entries-for-language-string-updates
+ // This WAS added to fix a previously reported bug, however, so need to watch out for this
+ // unset( $db_array['word_default_version'] );
+
+ $counts['updates']++;
+ $this->DB->update( 'core_sys_lang_words', $db_array, "word_id={$lang_entry['word_id']}" );
+ }
+
+ //-----------------------------------------
+ // Lang bit doesn't exist, so insert
+ //-----------------------------------------
+
+ else if( ! $lang_entry['word_id'] )
+ {
+ /* Ensure there is a value to avoid null */
+ if ( ! $db_array['word_custom'] )
+ {
+ $db_array['word_custom'] = '';
+ }
+
+ /* Ensure custom word but isn't added to other packs that simply had missing strings */
+ if ( $insertId AND $insertId != $_lang_id )
+ {
+ $db_array['word_custom'] = '';
+ }
+
+ $counts['inserts']++;
+ $this->DB->insert( 'core_sys_lang_words', $db_array );
+ }
+
+ unset( $lang_entry, $db_array );
+ }
+ }
+
+ /* Save some memory */
+ unset( $lang_entries );
+
+ //-----------------------------------------
+ // Recache all our lang packs
+ //-----------------------------------------
+
+ foreach( $lang_ids as $_lang_id )
+ {
+ $this->cacheToDisk( $_lang_id, $app_override );
+ }
+
+ //-----------------------------------------
+ // Set output message
+ //-----------------------------------------
+
+ $this->registry->output->global_message = sprintf( $this->lang->words['l_updatedcount'], $counts['updates'], $counts['inserts'] );
+
+ if ( is_array( $this->cache_errors ) AND count( $this->cache_errors ) )
+ {
+ $this->registry->output->global_message .= " " . implode( " ", $this->cache_errors );
+ }
+
+ //-----------------------------------------
+ // Free a little memory
+ //-----------------------------------------
+
+ unset( $xml );
+
+ //-----------------------------------------
+ // Update IPB cache
+ //-----------------------------------------
+
+ $this->registry->class_localization->rebuildLanguagesCache();
+
+ //-----------------------------------------
+ // Return! Now!
+ //-----------------------------------------
+
+ if ( ! $no_return )
+ {
+ $this->languagesList();
+ return;
+ }
+ }
+
+ /**
+ * Export language entries to xml file
+ *
+ * @param integer $lang_id Language pack to export
+ * @param bool $disk Save to disk instead
+ * @return void
+ */
+ public function languageExportToXML( $lang_id, $disk=false )
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $app_dir = trim( $this->request['app_dir'] );
+ $type = trim( $this->request['type'] );
+ $_where = '';
+ $_name = 'language.xml';
+ $LATESTVERSION = IPSLib::fetchVersionNumber();
+ $doPack = true;
+
+ //-----------------------------------------
+ // Filter
+ //-----------------------------------------
+
+ if ( $app_dir )
+ {
+ $_where = " AND word_app='" . $app_dir . "'";
+ $_name = $app_dir . '_language_pack.xml';
+ $doPack = false;
+ }
+
+ if ( $type )
+ {
+ if ( $type == 'admin' )
+ {
+ $_where .= " AND word_pack LIKE 'admin_%'";
+ $_name = 'admin_' . $_name;
+ }
+ else
+ {
+ $_where .= " AND word_pack LIKE 'public_%'";
+ $_name = 'public_' . $_name;
+ }
+
+ $doPack = false;
+ }
+
+ //-----------------------------------------
+ // Create the XML library
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+ $xml->newXMLDocument();
+ $xml->addElement( 'languageexport' );
+ $xml->addElement( 'languagegroup', 'languageexport' );
+
+ //-----------------------------------------
+ // Get language pack
+ //-----------------------------------------
+
+ $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_lang', 'where' => "lang_id={$lang_id}" ) );
+
+ //-----------------------------------------
+ // Add pack if necessary
+ //-----------------------------------------
+
+ if( $doPack )
+ {
+ $xml->addElementAsRecord( 'languagegroup', 'langinfo', $data );
+ }
+
+ //-----------------------------------------
+ // Get the words
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$lang_id}" . $_where ) );
+ $this->DB->execute();
+
+ //-----------------------------------------
+ // Add words to export
+ //-----------------------------------------
+
+ $word_packs = array();
+ $_strings = 0;
+
+ while( $r = $this->DB->fetch() )
+ {
+ $content = array();
+ $_strings++;
+
+ if( $disk )
+ {
+ $content = array(
+ 'word_app' => $r['word_app'],
+ 'word_pack' => $r['word_pack'],
+ 'word_key' => $r['word_key'],
+ 'word_default' => $r['word_default'],
+ //'word_default_version' => ( $r['word_default_version'] >= 30000 ) ? $r['word_default_version'] : $LATESTVERSION['long'],
+ //'word_js' => $r['word_js']
+ );
+
+ if( $r['word_js'] )
+ {
+ $content['word_js'] = $r['word_js'];
+ }
+ if( $r['word_custom'] )
+ {
+ $content['word_custom']=$r['word_custom'];
+ $content['word_custom_version'] = ($r['word_custom_version'])?$r['word_custom_version']:( $r['word_default_version'] )?$r['word_default_version']:$LATESTVERSION['long'];
+ }
+
+ }
+ else
+ {
+ $content = array(
+ 'word_app' => $r['word_app'],
+ 'word_pack' => $r['word_pack'],
+ 'word_key' => $r['word_key'],
+ 'word_default' => $r['word_default'],
+ 'word_custom' => $r['word_custom'],
+ 'word_default_version' => ( $r['word_default_version'] >= 30000 ) ? $r['word_default_version'] : $LATESTVERSION['long'],
+ 'word_custom_version' => $r['word_custom_version'],
+ 'word_js' => $r['word_js']
+ );
+ }
+
+ $xml->addElementAsRecord( 'languagegroup', 'lang', $content );
+ }
+
+ //-----------------------------------------
+ // Got any strings?
+ //-----------------------------------------
+
+ if( !$_strings )
+ {
+ if( $disk )
+ {
+ return false;
+ }
+ else
+ {
+ $this->registry->output->global_message = $this->lang->words['l_nolangbits'];
+ $this->languagesList();
+ return;
+ }
+ }
+
+ //-----------------------------------------
+ // Write to disk or output to browser
+ //-----------------------------------------
+
+ if( $disk )
+ {
+ @unlink( IPSLib::getAppDir($app_dir) . '/xml/' . $_name );
+ @file_put_contents( IPSLib::getAppDir($app_dir) . '/xml/' . $_name, $xml->fetchDocument() );
+ return true;
+ }
+ else
+ {
+ //-----------------------------------------
+ // Create xml archive
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
+ $xmlArchive = new classXMLArchive();
+
+ //-----------------------------------------
+ // Add XML document
+ //-----------------------------------------
+
+ $xmlArchive->add( $xml->fetchDocument(), 'language_entries.xml' );
+
+ //-----------------------------------------
+ // Print to browser
+ //-----------------------------------------
+
+ $this->registry->output->showDownload( $xmlArchive->getArchiveContents(), $_name );
+ exit();
+ }
+ }
+
+ /**
+ * Builds the language db entries from cache
+ *
+ * @param boolean return as normal
+ * @return @e void
+ * @author Josh
+ */
+ public function importFromCacheFiles( $returnAsNormal=TRUE )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $msg = array();
+ $lang_id = 1;
+ $LATESTVERSION = IPSLib::fetchVersionNumber();
+
+ //-----------------------------------------
+ // Check
+ //-----------------------------------------
+
+ if ( ! is_array( $_POST['apps'] ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['l_noapp'];
+ $this->languagesList();
+ return;
+ }
+
+ //-----------------------------------------
+ // Loop through apps...
+ //-----------------------------------------
+
+ foreach( ipsRegistry::$applications as $app => $app_data )
+ {
+ if ( in_array( $app, $_POST['apps'] ) )
+ {
+ //-----------------------------------------
+ // Get directory
+ //-----------------------------------------
+
+ $_dir = IPS_CACHE_PATH . 'cache/lang_cache/master_lang/';
+
+ //-----------------------------------------
+ // Go through directories
+ //-----------------------------------------
+
+ if ( is_dir( $_dir ) )
+ {
+ $dh = opendir( $_dir );
+
+ while( $f = readdir( $dh ) )
+ {
+ if ( $f[0] == '.' || $f == 'index.html' )
+ {
+ continue;
+ }
+
+ if ( preg_match( "#^" . $app . '_\S+?\.php$#', $f ) )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $updated = 0;
+ $inserted = 0;
+ $word_pack = preg_replace( "#^" . $app . '_(\S+?)\.php$#', "\\1", $f );
+ $lang = array();
+ $db_lang = array();
+
+ //-----------------------------------------
+ // Delete current language bits
+ //-----------------------------------------
+
+ $this->DB->delete( 'core_sys_lang_words', "lang_id=1 AND word_app='" . $app . "' AND word_pack='" . $word_pack . "'" );
+
+ if ( IPS_IS_SHELL )
+ {
+ $stdout = fopen('php://stdout', 'w');
+ fwrite( $stdout, 'Processing: ' . $f . "\n" );
+ fclose( $stdout );
+ }
+
+ require( $_dir . $f );/*noLibHook*/
+
+ //-----------------------------------------
+ // Loop
+ //-----------------------------------------
+
+ foreach( $lang as $k => $v )
+ {
+ $inserted++;
+
+ $insert = array(
+ 'lang_id' => $lang_id,
+ 'word_app' => $app,
+ 'word_pack' => $word_pack,
+ 'word_key' => $k,
+ 'word_default' => IPSText::encodeForXml($v),
+ 'word_default_version' => $LATESTVERSION['long'],
+ 'word_js' => 0,
+ );
+
+ $this->DB->insert( 'core_sys_lang_words', $insert );
+ }
+
+ $msg[] = sprintf( $this->lang->words['indev_lang_import'], $f, $inserted, $updated );
+ }
+ else if( preg_match( '/(\.js)$/', $f ) AND $app == 'core' )
+ {
+ $_js_word_pack = '';
+
+ if( $f == 'ipb.lang.js' )
+ {
+ $_js_word_pack = 'public_js';
+ }
+ else if( $f == 'acp.lang.js' )
+ {
+ $_js_word_pack = 'admin_js';
+ }
+
+ //-----------------------------------------
+ // Delete current words for this app and word pack
+ //-----------------------------------------
+
+ $this->DB->delete( 'core_sys_lang_words', "lang_id=1 AND word_app='" . $app . "' AND word_pack='" . $_js_word_pack . "'" );
+
+ if ( IPS_IS_SHELL )
+ {
+ $stdout = fopen('php://stdout', 'w');
+ fwrite( $stdout, 'Processing: ' . $f . "\n" );
+ fclose( $stdout );
+ }
+
+ //-----------------------------------------
+ // Get each line
+ //-----------------------------------------
+
+ $js_file = file( $_dir . $f );
+
+ //-----------------------------------------
+ // Loop through lines and import
+ //-----------------------------------------
+
+ foreach( $js_file as $r )
+ {
+ //-----------------------------------------
+ // preg_match what we want
+ //-----------------------------------------
+
+ preg_match( '#ipb\.lang\[\'(.+?)\'\](.+?)= ["\'](.+?)["\'];#', $r, $matches );
+
+ //-----------------------------------------
+ // Valid?
+ //-----------------------------------------
+
+ if( $matches[1] && $matches[3] )
+ {
+ $inserted++;
+ $insert = array(
+ 'lang_id' => $lang_id,
+ 'word_app' => 'core',
+ 'word_pack' => $_js_word_pack,
+ 'word_key' => $matches[1],
+ 'word_default' => IPSText::encodeForXml($matches[3]),
+ 'word_js' => 1,
+ );
+ $this->DB->insert( 'core_sys_lang_words', $insert );
+ }
+ }
+ }
+ }
+
+ closedir( $dh );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Done...
+ //-----------------------------------------
+
+ if ( $returnAsNormal === TRUE )
+ {
+ $this->registry->output->setMessage( implode( " ", $msg ), true );
+
+ if ( ! $this->__daily )
+ {
+ $this->languagesList();
+ }
+ }
+ else
+ {
+ return $msg;
+ }
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/languages/xml/menu.xml b/upload/admin/applications/core/modules_admin/languages/xml/menu.xml
index 53ee3a8d..8929d388 100644
--- a/upload/admin/applications/core/modules_admin/languages/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/languages/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Manage Languages
+ Языки Системы
- Manage Languages
+ Языки Системы
languages
manage_languages
diff --git a/upload/admin/applications/core/modules_admin/languages/xml/permissions.xml b/upload/admin/applications/core/modules_admin/languages/xml/permissions.xml
index c37f84af..8584058e 100644
--- a/upload/admin/applications/core/modules_admin/languages/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/languages/xml/permissions.xml
@@ -1,20 +1,20 @@
- Manage Languages
+ Управление языками
core_languages
-
lang_words
- Can add/edit the language bit texts?
+ Может добавлять/изменять слова?
-
lang_packs
- Can add/edit language packs?
+ Может добавлять/изменять языковые наборы?
-
lang_pack_info
- Can alter the language pack properties and information?
+ Может изменять настройки и информацию языковых наборов?
diff --git a/upload/admin/applications/core/modules_admin/login/manualResolver.php b/upload/admin/applications/core/modules_admin/login/manualResolver.php
index c731b84f..d88d939b 100644
--- a/upload/admin/applications/core/modules_admin/login/manualResolver.php
+++ b/upload/admin/applications/core/modules_admin/login/manualResolver.php
@@ -1,413 +1,452 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * ACP Login/Logout Routines
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since Tuesday 17th August 2004
- * @version $Revision: 10914 $
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-
-class admin_core_login_manualResolver extends ipsCommand
-{
- /**
- * HTML Skin object
- *
- * @var object
- */
- protected $html;
-
- /**#@+
- * Registry objects
- *
- * @var object
- */
- public $registry;
- public $DB;
- public $settings;
- public $request;
- public $lang;
- public $member;
- public $memberData;
- /**#@-*/
-
- /**
- * Login handler object
- *
- * @var object
- */
- protected $han_login;
-
- /**
- * Initiate login handler
- *
- * @return @e void
- */
- public function initHanLogin()
- {
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
-
- $this->han_login->is_admin_auth = 1;
- $this->han_login->init();
- }
-
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @param string Validation message
- * @return @e void [Outputs to screen/redirects]
- */
- public function doExecute( ipsRegistry $registry, $validationMessage='' )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->member = $this->registry->member();
- $this->memberData =& $this->registry->member()->fetchMemberData();
- $this->lang = $this->registry->getClass('class_localization');
-
- $this->registry->getClass('class_localization')->loadLanguageFile( array( 'admin_login' ), 'core' );
-
- $this->initHanLogin();
-
- //-----------------------------------------
- // What to do?
- //-----------------------------------------
-
- switch( $this->request['do'] )
- {
- case 'login':
- default:
- $this->loginForm();
- break;
-
- case 'login-complete':
- $this->loginComplete();
- break;
-
- case 'login-out':
- $this->loginOut();
- break;
- }
- }
-
- /**
- * Check and verify the login was successful
- *
- * @return @e void
- */
- public function loginComplete()
- {
- /* Fetch sessions API */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/session/api.php', 'session_api' );
- $publicApi = new $classToLoad( $this->registry );
-
- //-----------------------------------------
- // Check form details.
- //-----------------------------------------
-
- $this->request['email'] = str_replace( '|', '|', $this->request['email'] );
-
- $username = '';
- $email = '';
-
- //-----------------------------------------
- // Is this a username or email address?
- //-----------------------------------------
-
- $_type = $this->han_login->emailOrUsername();
-
- switch( $_type )
- {
- case 1:
- $username = $this->request['username'];
- break;
-
- case 2:
- $email = $this->request['username'];
- break;
-
- case 3:
- $username = $this->request['username'];
- $email = $this->request['username'];
- break;
- }
-
- //-----------------------------------------
- // Check auth
- //-----------------------------------------
-
- $this->han_login->loginAuthenticate( $username, $email, trim($this->request['password']) );
-
- //-----------------------------------------
- // Check return code...
- //-----------------------------------------
-
- $mem = $this->han_login->member_data;
-
- if ( ( ! $mem['member_id'] ) or ( $this->han_login->return_code == 'NO_USER' ) )
- {
- $this->_writeToLog( $this->request['username'], 'fail' );
- $this->loginForm( $this->lang->words['bad_email_password'] );
- }
-
- if ( $this->han_login->return_code == 'NO_ACCESS' )
- {
- $this->_writeToLog( $this->request['username'], 'fail' );
- $this->loginForm( $this->lang->words['no_acp_access'] );
- }
- else if ( $this->han_login->return_code != 'SUCCESS' )
- {
- $this->_writeToLog( $this->request['username'], 'fail' );
- $this->loginForm( $this->lang->words['bad_email_password'] );
- }
-
- //-----------------------------------------
- // And sort secondary groups...
- //-----------------------------------------
-
- $mem = $this->member->setUpSecondaryGroups( $mem );
-
- //-----------------------------------------
- // Check access...
- //-----------------------------------------
-
- if ( $mem['g_access_cp'] != 1 )
- {
- $this->_writeToLog( $this->request['username'], 'fail' );
- $this->loginForm( $this->lang->words['no_acp_access'] );
- }
- else
- {
- //-----------------------------------------
- // Fix up query string...
- //-----------------------------------------
-
- $extra_query = "";
-
- if ( $_POST['qstring'] )
- {
- $extra_query = stripslashes( $_POST['qstring'] );
- $extra_query = str_replace( $this->settings['_original_base_url'] , "" , $extra_query );
- $extra_query = str_ireplace( "?index." . $this->settings['php_ext'] , "" , $extra_query );
- $extra_query = ltrim( $extra_query, '?' );
- $extra_query = preg_replace( '!adsess=(\w){32}!' , "" , $extra_query );
- $extra_query = str_replace( "adsess=x" , "" , $extra_query );
- $extra_query = str_replace( array( 'old_&', 'old_&' ) , "" , $extra_query );
- $extra_query = preg_replace( '!s=(\w){32}!' , "" , $extra_query );
- $extra_query = str_replace( "module=login" , "" , $extra_query );
- $extra_query = str_replace( "do=login-complete" , "" , $extra_query );
- $extra_query = str_replace( "/admin" , "" , $extra_query );
- $extra_query = str_replace( '&' , '&', $extra_query );
- $extra_query = preg_replace( "#&{1,}#" , "&", $extra_query );
- $extra_query = preg_replace( "#messageinabottleacp=(.*?)$#" , "" , $extra_query );
- }
-
- //-----------------------------------------
- // Insert session
- //-----------------------------------------
-
- $sess_id = md5( uniqid( microtime() ) );
-
- $this->DB->delete( 'core_sys_cp_sessions', 'session_member_id=' . $mem['member_id'] );
-
- /* Grab user agent */
- $uAgent = array();
-
- $this->DB->insert( 'core_sys_cp_sessions', array( 'session_id' => $sess_id,
- 'session_ip_address' => $this->member->ip_address,
- 'session_member_name' => $mem['members_display_name'],
- 'session_member_id' => $mem['member_id'],
- 'session_member_login_key' => $mem['member_login_key'],
- 'session_location' => 'index',
- 'session_log_in_time' => time(),
- 'session_running_time' => time(),
- 'session_app_data' => serialize( $uAgent ),
- 'session_url' => '' ) );
-
- $this->request['adsess'] = $sess_id;
-
- /* Log them in public side if not already */
- $publicApi->logGuestInAsMember( $mem['member_id'] );
-
- //-----------------------------------------
- // Redirect...
- //-----------------------------------------
-
- $url = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/index.php?adsess=' . $sess_id . '&' . $extra_query;
-
- $this->_writeToLog( $this->request['username'], 'ok' );
-
- ipsRegistry::getClass('output')->global_message = '';
- ipsRegistry::getClass('output')->silentRedirect( $url );
- }
- }
-
- /**
- * Log the user out
- *
- * @return @e void
- */
- public function loginOut()
- {
- //-----------------------------------------
- // Do it..
- //-----------------------------------------
-
- $this->DB->delete( 'core_sys_cp_sessions', "session_id='" . $this->request['adsess'] . "'" );
-
- //-----------------------------------------
- // Redirect...
- //-----------------------------------------
-
- ipsRegistry::getClass('output')->silentRedirect( $this->settings['_admin_link'] );
- }
-
- /**
- * Log the user out
- *
- * @param string Message to show on the form
- * @return @e void
- */
- public function loginForm( $message='' )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $message = $message ? $message : $this->member->sessionClass()->getMessage();
-
- //-------------------------------------------------------
- // Remove all out of date sessions, like a good boy. Woof.
- //-------------------------------------------------------
-
- $cut_off_stamp = time() - 60*60*2;
-
- $this->DB->delete( 'core_sys_cp_sessions', "session_running_time < {$cut_off_stamp}" );
-
- //------------------------------------------------------
- // Start form
- //------------------------------------------------------
-
- $qs = str_replace( '&' , '&' , IPSText::parseCleanValue( urldecode( my_getenv( 'QUERY_STRING' ) ) ) );
- $qs = str_replace( 'adsess=' , 'old_adsess=' , $qs );
- $qs = str_replace( 'module=menu', '' , $qs );
-
- $additional_data = $this->han_login->additionalFormHTML();
- $replace = false;
- $data = array();
-
- if( !is_null($additional_data) AND is_array($additional_data) AND count($additional_data) )
- {
- $replace = $additional_data[0];
- $data = $additional_data[1];
- }
-
- $uses_name = false;
- $uses_email = false;
-
- foreach( ipsRegistry::cache()->getCache('login_methods') as $method )
- {
- $login_methods[ $method['login_folder_name'] ] = $method['login_folder_name'];
-
- if( $method['login_user_id'] == 'username' or $method['login_user_id'] == 'either' )
- {
- $uses_name = true;
- }
-
- if( $method['login_user_id'] == 'email' or $method['login_user_id'] == 'either' )
- {
- $uses_email = true;
- }
- }
-
- if( $uses_name AND $uses_email )
- {
- $this->lang->words['gl_signinname'] = $this->lang->words['enter_name_and_email'];
- }
- else if( $uses_email )
- {
- $this->lang->words['gl_signinname'] = $this->lang->words['enter_useremail'];
- }
- else
- {
- $this->lang->words['gl_signinname'] = $this->lang->words['enter_username'];
- }
-
- ipsRegistry::getClass('output')->html_title = $this->lang->words['ipb_login'];
- ipsRegistry::getClass('output')->html_main = ipsRegistry::getClass('output')->global_template->log_in_form( $qs, $message, $replace == 'replace' ? true : false, $data );
- ipsRegistry::getClass('output')->html_main = str_replace( '<%TITLE%>' , ipsRegistry::getClass('output')->html_title, ipsRegistry::getClass('output')->html_main );
-
- @header("Content-type: text/html");
- print ipsRegistry::getClass('output')->html_main;
- exit();
- }
-
- /**
- * Write to the admin log in loggy ma log
- *
- * @param string Username
- * @param string ok/fail flag
- * @return @e void
- * @note This is private so that a hacker couldn't get into ACP, upload a new hook that lets them clear the log, and then clear the login log
- */
- private function _writeToLog( $username='', $flag='fail' )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $username = $username ? $username : $this->request['username'];
- $flag = ( $flag == 'ok' ) ? 1 : 0;
- $admin_post_details = array();
-
- //-----------------------------------------
- // Generate POST / GET details
- //-----------------------------------------
-
- foreach( $_GET as $k => $v )
- {
- $admin_post_details['get'][ $k ] = $v;
- }
-
- foreach( $_POST as $k => $v )
- {
- if ( $k == 'password' AND IPSText::mbstrlen( $v ) > 1 )
- {
- $v = $v ? ( (IPSText::mbstrlen( $v ) - 1) > 0 ? str_repeat( '*', IPSText::mbstrlen( $v ) - 1 ) : '' ) . substr( $v, -1, 1 ) : '';
- }
-
- $admin_post_details['post'][ $k ] = $v;
- }
-
- //-----------------------------------------
- // Write to disk...
- //-----------------------------------------
-
- $this->DB->insert( 'admin_login_logs', array( 'admin_ip_address' => $this->member->ip_address,
- 'admin_username' => $username,
- 'admin_time' => time(),
- 'admin_success' => $flag,
- 'admin_post_details' => serialize( $admin_post_details ) ) );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * ACP Login/Logout Routines
+ * Last Updated: $Date: 2013-03-20 10:14:51 -0400 (Wed, 20 Mar 2013) $
+ *
+ *
+ * @author $Author: mmecham $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since Tuesday 17th August 2004
+ * @version $Revision: 12094 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+
+class admin_core_login_manualResolver extends ipsCommand
+{
+ /**
+ * HTML Skin object
+ *
+ * @var object
+ */
+ protected $html;
+
+ /**#@+
+ * Registry objects
+ *
+ * @var object
+ */
+ public $registry;
+ public $DB;
+ public $settings;
+ public $request;
+ public $lang;
+ public $member;
+ public $memberData;
+ /**#@-*/
+
+ /**
+ * Login handler object
+ *
+ * @var object
+ */
+ protected $han_login;
+
+ /**
+ * Initiate login handler
+ *
+ * @return @e void
+ */
+ public function initHanLogin()
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+
+ $this->han_login->is_admin_auth = 1;
+ $this->han_login->init();
+ }
+
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @param string Validation message
+ * @return @e void [Outputs to screen/redirects]
+ */
+ public function doExecute( ipsRegistry $registry, $validationMessage='' )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->member = $this->registry->member();
+ $this->memberData =& $this->registry->member()->fetchMemberData();
+ $this->lang = $this->registry->getClass('class_localization');
+
+ $this->registry->getClass('class_localization')->loadLanguageFile( array( 'admin_login' ), 'core' );
+
+ $this->initHanLogin();
+
+ //-----------------------------------------
+ // What to do?
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ case 'login':
+ default:
+ $this->loginForm();
+ break;
+
+ case 'login-complete':
+ $this->loginComplete();
+ break;
+
+ case 'login-out':
+ $this->loginOut();
+ break;
+ }
+ }
+
+ /**
+ * Check and verify the login was successful
+ *
+ * @return @e void
+ */
+ public function loginComplete()
+ {
+ /* Fetch sessions API */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/session/api.php', 'session_api' );
+ $publicApi = new $classToLoad( $this->registry );
+
+ //-----------------------------------------
+ // Check form details.
+ //-----------------------------------------
+
+ $username = '';
+ $email = '';
+
+ //-----------------------------------------
+ // Is this a username or email address?
+ //-----------------------------------------
+
+ $_type = $this->han_login->emailOrUsername();
+
+ switch( $_type )
+ {
+ case 1:
+ $username = $this->request['username'];
+ break;
+
+ case 2:
+ $email = $this->request['username'];
+ break;
+
+ case 3:
+ $username = $this->request['username'];
+ $email = $this->request['username'];
+ break;
+ }
+
+ //-----------------------------------------
+ // Check auth
+ //-----------------------------------------
+
+ $this->han_login->loginAuthenticate( $username, $email, trim($this->request['password']) );
+
+ //-----------------------------------------
+ // Check return code...
+ //-----------------------------------------
+
+ $mem = $this->han_login->member_data;
+
+ if ( ( ! $mem['member_id'] ) or ( $this->han_login->return_code == 'NO_USER' ) )
+ {
+ $this->_writeToLog( $this->request['username'], 'fail' );
+ $this->loginForm( $this->lang->words['bad_email_password'] );
+ }
+
+ if ( $this->han_login->return_code == 'NO_ACCESS' )
+ {
+ $this->_writeToLog( $this->request['username'], 'fail' );
+ $this->loginForm( $this->lang->words['no_acp_access'] );
+ }
+ else if ( $this->han_login->return_code != 'SUCCESS' )
+ {
+ $this->_writeToLog( $this->request['username'], 'fail' );
+ $this->loginForm( $this->lang->words['bad_email_password'] );
+ }
+
+ //-----------------------------------------
+ // And sort secondary groups...
+ //-----------------------------------------
+
+ $mem = $this->member->setUpSecondaryGroups( $mem );
+
+ //-----------------------------------------
+ // Check access...
+ //-----------------------------------------
+
+ if ( $mem['g_access_cp'] != 1 )
+ {
+ $this->_writeToLog( $this->request['username'], 'fail' );
+ $this->loginForm( $this->lang->words['no_acp_access'] );
+ }
+ else
+ {
+ //-----------------------------------------
+ // Fix up query string...
+ //-----------------------------------------
+
+ $extra_query = "";
+
+ if ( $_POST['qstring'] )
+ {
+ $extra_query = stripslashes( htmlspecialchars( $_POST['qstring'] ) );
+ $extra_query = str_replace( $this->settings['_original_base_url'] , "" , $extra_query );
+ $extra_query = str_ireplace( "?index." . $this->settings['php_ext'] , "" , $extra_query );
+ $extra_query = ltrim( $extra_query, '?' );
+ $extra_query = preg_replace( '!adsess=(\w){32}!' , "" , $extra_query );
+ $extra_query = str_replace( "adsess=x" , "" , $extra_query );
+ $extra_query = str_replace( array( 'old_&', 'old_&' ) , "" , $extra_query );
+ $extra_query = preg_replace( '!s=(\w){32}!' , "" , $extra_query );
+ $extra_query = str_replace( "module=login" , "" , $extra_query );
+ $extra_query = str_replace( "do=login-complete" , "" , $extra_query );
+ $extra_query = str_replace( "/admin" , "" , $extra_query );
+ $extra_query = str_replace( '&' , '&', $extra_query );
+ $extra_query = preg_replace( "#&{1,}#" , "&", $extra_query );
+ $extra_query = preg_replace( "#messageinabottleacp=(.*?)$#" , "" , $extra_query );
+ }
+
+ //-----------------------------------------
+ // Insert session
+ //-----------------------------------------
+
+ $sess_id = md5( uniqid( microtime() ) );
+
+ $this->DB->delete( 'core_sys_cp_sessions', 'session_member_id=' . $mem['member_id'] );
+
+ /* Grab user agent */
+ $uAgent = array();
+
+ $this->DB->insert( 'core_sys_cp_sessions', array( 'session_id' => $sess_id,
+ 'session_ip_address' => $this->member->ip_address,
+ 'session_member_name' => $mem['members_display_name'],
+ 'session_member_id' => $mem['member_id'],
+ 'session_member_login_key' => $mem['member_login_key'],
+ 'session_location' => 'index',
+ 'session_log_in_time' => time(),
+ 'session_running_time' => time(),
+ 'session_app_data' => serialize( $uAgent ),
+ 'session_url' => '' ) );
+
+ $this->request['adsess'] = $sess_id;
+
+ /* Log them in public side if not already */
+ $publicApi->logGuestInAsMember( $mem['member_id'] );
+
+ //-----------------------------------------
+ // Redirect...
+ //-----------------------------------------
+
+ if ( $extra_query )
+ {
+ $url = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/index.php?adsess=' . $sess_id . '&' . $extra_query;
+ }
+ else
+ {
+ /* Load main page? */
+ require_once( IPS_ROOT_PATH . 'sources/classes/admin/bookmarks.php' );
+ $bookmarks = new classes_admin_bookmarks();
+ $bookmarks->setMember( $mem['member_id'] );
+
+ $home = $bookmarks->getHomeUrl();
+
+ if ( $home !== false )
+ {
+ $url = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/index.php?adsess=' . $sess_id . '&' . $home;
+ }
+ else
+ {
+ $url = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/index.php?adsess=' . $sess_id;
+ }
+ }
+
+ $this->_writeToLog( $this->request['username'], 'ok' );
+
+ ipsRegistry::getClass('output')->global_message = '';
+ ipsRegistry::getClass('output')->silentRedirect( $url );
+ }
+ }
+
+ /**
+ * Log the user out
+ *
+ * @return @e void
+ */
+ public function loginOut()
+ {
+ //-----------------------------------------
+ // Do it..
+ //-----------------------------------------
+
+ $this->DB->delete( 'core_sys_cp_sessions', "session_id='" . $this->request['adsess'] . "'" );
+
+ //-----------------------------------------
+ // Redirect...
+ //-----------------------------------------
+
+ ipsRegistry::getClass('output')->silentRedirect( $this->settings['_admin_link'] );
+ }
+
+ /**
+ * Log the user out
+ *
+ * @param string Message to show on the form
+ * @return @e void
+ */
+ public function loginForm( $message='' )
+ {
+ //-----------------------------------------
+ // Hang on, do we need the upgrader?
+ //-----------------------------------------
+
+ if ( !IN_DEV AND ( !defined('SKIP_UPGRADE_CHECK') OR !SKIP_UPGRADE_CHECK ) )
+ {
+ require_once( IPS_ROOT_PATH . 'setup/sources/base/setup.php' );/*noLibHook*/
+ foreach( ipsRegistry::$applications as $app_dir => $app )
+ {
+ $_a = ( $app_dir == 'forums' or $app_dir == 'members' ) ? 'core' : $app_dir;
+ $numbers = IPSSetUp::fetchAppVersionNumbers( $_a );
+
+ if ( $numbers['latest'][0] and $numbers['latest'][0] > $numbers['current'][0] )
+ {
+ $this->registry->output->silentRedirect( $this->settings['base_acp_url'] . '/upgrade/index.php?_acpRedirect=1' );
+ return;
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $message = $message ? $message : $this->member->sessionClass()->getMessage();
+
+ //-------------------------------------------------------
+ // Remove all out of date sessions, like a good boy. Woof.
+ //-------------------------------------------------------
+
+ $cut_off_stamp = time() - 60*60*2;
+
+ $this->DB->delete( 'core_sys_cp_sessions', "session_running_time < {$cut_off_stamp}" );
+
+ //------------------------------------------------------
+ // Start form
+ //------------------------------------------------------
+
+ $qs = str_replace( '&' , '&' , IPSText::parseCleanValue( urldecode( my_getenv( 'QUERY_STRING' ) ) ) );
+ $qs = str_replace( 'adsess=' , 'old_adsess=' , $qs );
+ $qs = str_replace( 'module=menu', '' , $qs );
+
+ $additional_data = $this->han_login->additionalFormHTML();
+ $replace = false;
+ $data = array();
+
+ if( !is_null($additional_data) AND is_array($additional_data) AND count($additional_data) )
+ {
+ $replace = $additional_data[0];
+ $data = $additional_data[1];
+ }
+
+ $uses_name = false;
+ $uses_email = false;
+
+ foreach( ipsRegistry::cache()->getCache('login_methods') as $method )
+ {
+ $login_methods[ $method['login_folder_name'] ] = $method['login_folder_name'];
+
+ if( $method['login_user_id'] == 'username' or $method['login_user_id'] == 'either' )
+ {
+ $uses_name = true;
+ }
+
+ if( $method['login_user_id'] == 'email' or $method['login_user_id'] == 'either' )
+ {
+ $uses_email = true;
+ }
+ }
+
+ if( $uses_name AND $uses_email )
+ {
+ $this->lang->words['gl_signinname'] = $this->lang->words['enter_name_and_email'];
+ }
+ else if( $uses_email )
+ {
+ $this->lang->words['gl_signinname'] = $this->lang->words['enter_useremail'];
+ }
+ else
+ {
+ $this->lang->words['gl_signinname'] = $this->lang->words['enter_username'];
+ }
+
+ ipsRegistry::getClass('output')->html_title = $this->lang->words['ipb_login'];
+ ipsRegistry::getClass('output')->html_main = ipsRegistry::getClass('output')->global_template->log_in_form( $qs, $message, $replace == 'replace' ? true : false, $data );
+ ipsRegistry::getClass('output')->html_main = str_replace( '<%TITLE%>' , ipsRegistry::getClass('output')->html_title, ipsRegistry::getClass('output')->html_main );
+
+ @header("Content-type: text/html;charset={$this->settings['gb_char_set']}");
+ print ipsRegistry::getClass('output')->html_main;
+ exit();
+ }
+
+ /**
+ * Write to the admin log in loggy ma log
+ *
+ * @param string Username
+ * @param string ok/fail flag
+ * @return @e void
+ * @note This is private so that a hacker couldn't get into ACP, upload a new hook that lets them clear the log, and then clear the login log
+ */
+ private function _writeToLog( $username='', $flag='fail' )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $username = $username ? $username : $this->request['username'];
+ $flag = ( $flag == 'ok' ) ? 1 : 0;
+ $admin_post_details = array();
+
+ //-----------------------------------------
+ // Generate POST / GET details
+ //-----------------------------------------
+
+ foreach( $_GET as $k => $v )
+ {
+ $admin_post_details['get'][ $k ] = $v;
+ }
+
+ foreach( $_POST as $k => $v )
+ {
+ if ( $k == 'password' AND IPSText::mbstrlen( $v ) > 1 )
+ {
+ $v = $v ? ( (IPSText::mbstrlen( $v ) - 1) > 0 ? str_repeat( '*', IPSText::mbstrlen( $v ) - 1 ) : '' ) . substr( $v, -1, 1 ) : '';
+ }
+
+ $admin_post_details['post'][ $k ] = $v;
+ }
+
+ //-----------------------------------------
+ // Write to disk...
+ //-----------------------------------------
+
+ $this->DB->insert( 'admin_login_logs', array( 'admin_ip_address' => $this->member->ip_address,
+ 'admin_username' => $username,
+ 'admin_time' => time(),
+ 'admin_success' => $flag,
+ 'admin_post_details' => serialize( $admin_post_details ) ) );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/logs/adminlogs.php b/upload/admin/applications/core/modules_admin/logs/adminlogs.php
index 8ebfed0e..84099dec 100644
--- a/upload/admin/applications/core/modules_admin/logs/adminlogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/adminlogs.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Admin logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/logs/defaultSection.php b/upload/admin/applications/core/modules_admin/logs/defaultSection.php
index 25c2b19b..76fba66d 100644
--- a/upload/admin/applications/core/modules_admin/logs/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/logs/defaultSection.php
@@ -4,11 +4,11 @@
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: bfarber $
+ * $Author: mark $
* @since 20th February 2002
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $LastChangedDate: 2012-04-02 11:17:19 -0400 (Mon, 02 Apr 2012) $
+ * @version v3.4.5
+ * $Revision: 10537 $
*/
$DEFAULT_SECTION = 'logsSplash';
diff --git a/upload/admin/applications/core/modules_admin/logs/emailerrorlogs.php b/upload/admin/applications/core/modules_admin/logs/emailerrorlogs.php
index 4e55b484..064946a5 100644
--- a/upload/admin/applications/core/modules_admin/logs/emailerrorlogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/emailerrorlogs.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Email error logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/logs/errorlogs.php b/upload/admin/applications/core/modules_admin/logs/errorlogs.php
index faafb7c3..92189a06 100644
--- a/upload/admin/applications/core/modules_admin/logs/errorlogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/errorlogs.php
@@ -3,19 +3,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Error logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2013-02-01 20:54:48 -0500 (Fri, 01 Feb 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 11930 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -152,6 +152,7 @@ class admin_core_logs_errorlogs extends ipsCommand
$url_query[] = 'type=' . $this->request['type'];
$url_query[] = 'string=' . urlencode( $string );
+ $url_query[] = 'match=' . $this->request['match'];
switch( $this->request['type'] )
{
diff --git a/upload/admin/applications/core/modules_admin/logs/loginlog.php b/upload/admin/applications/core/modules_admin/logs/loginlog.php
index 071db5e8..813b04da 100644
--- a/upload/admin/applications/core/modules_admin/logs/loginlog.php
+++ b/upload/admin/applications/core/modules_admin/logs/loginlog.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Admin Login Logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2013-03-19 11:50:13 -0400 (Tue, 19 Mar 2013) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 12087 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -83,9 +83,7 @@ class admin_core_logs_loginlog extends ipsCommand
if ( ! $log['admin_id'] )
{
- $this->registry->output->global_message = $this->lang->words['ll_noid'];
- $this->login_logs_view();
- return;
+ $this->registry->output->showError( 'll_noid' );
}
//-----------------------------------------
@@ -101,7 +99,8 @@ class admin_core_logs_loginlog extends ipsCommand
{
foreach( $log['_admin_post_details'][ $r ] as $k => $v )
{
- $log['_admin_post_details'][ $r ][ $k ] = htmlspecialchars( $v );
+ unset( $log['_admin_post_details'][ $r ][ $k ] );
+ $log['_admin_post_details'][ $r ][ htmlspecialchars( $k ) ] = htmlspecialchars( $v );
}
}
}
diff --git a/upload/admin/applications/core/modules_admin/logs/logsSplash.php b/upload/admin/applications/core/modules_admin/logs/logsSplash.php
index 807dd083..0b5ed2f3 100644
--- a/upload/admin/applications/core/modules_admin/logs/logsSplash.php
+++ b/upload/admin/applications/core/modules_admin/logs/logsSplash.php
@@ -7,7 +7,7 @@
* $Author: bfarber $
* @since 8th Feb 2011
* $LastChangedDate: 2011-09-12 20:59:05 -0400 (Mon, 12 Sep 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 9483 $
*/
diff --git a/upload/admin/applications/core/modules_admin/logs/mobilelogs.php b/upload/admin/applications/core/modules_admin/logs/mobilelogs.php
index 21f2abb3..0aba647c 100644
--- a/upload/admin/applications/core/modules_admin/logs/mobilelogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/mobilelogs.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Mobile Notification logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/logs/modlogs.php b/upload/admin/applications/core/modules_admin/logs/modlogs.php
index d6853c5c..017ef0a3 100644
--- a/upload/admin/applications/core/modules_admin/logs/modlogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/modlogs.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Moderator logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/logs/spamlogs.php b/upload/admin/applications/core/modules_admin/logs/spamlogs.php
index aa7bc430..91f082fc 100644
--- a/upload/admin/applications/core/modules_admin/logs/spamlogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/spamlogs.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Admin logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2013-05-01 17:35:09 -0400 (Wed, 01 May 2013) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 12211 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -138,7 +138,7 @@ class admin_core_logs_spamlogs extends ipsCommand
if( $this->request['search_term'] )
{
- $where = "log_msg LIKE '%{$this->request['search_term']}%' OR email_address LIKE '%{$this->request['search_term']}%'";
+ $where = "log_msg LIKE '%{$this->request['search_term']}%' OR email_address LIKE '%{$this->request['search_term']}%' OR ip_address LIKE '%{$this->request['search_term']}%'";
$qs = '&search_term=' . $this->request['search_term'];
}
diff --git a/upload/admin/applications/core/modules_admin/logs/spiderlogs.php b/upload/admin/applications/core/modules_admin/logs/spiderlogs.php
index 85b4f0a9..8d0949cc 100644
--- a/upload/admin/applications/core/modules_admin/logs/spiderlogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/spiderlogs.php
@@ -1,281 +1,281 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Search Engine Spider logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since 27th January 2004
- * @version $Rev: 10914 $
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-class admin_core_logs_spiderlogs extends ipsCommand
-{
- /**
- * Skin object
- *
- * @var object Skin templates
- */
- protected $html;
-
- /**
- * Spider map
- *
- * @var array Spider keys to values
- */
- protected $bot_map = array();
-
- /**
- * Main class entry point
- *
- * @param object ipsRegistry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Load bat names from the useragents cache */
- foreach( $this->cache->getCache( 'useragents' ) as $agent )
- {
- if( $agent['uagent_type'] == 'search' )
- {
- $this->bot_map[ $agent['uagent_key'] ] = $agent['uagent_name'];
- }
- }
-
- //-----------------------------------------
- // Load skin
- //-----------------------------------------
-
- $this->html = $this->registry->output->loadTemplate('cp_skin_spiderlogs');
-
- //-----------------------------------------
- // Set up stuff
- //-----------------------------------------
-
- $this->form_code = $this->html->form_code = 'module=logs§ion=spiderlogs';
- $this->form_code_js = $this->html->form_code_js = 'module=logs§ion=spiderlogs';
-
- //-----------------------------------------
- // Load lang
- //-----------------------------------------
-
- $this->registry->getClass('class_localization')->loadLanguageFile( array( 'admin_logs' ) );
-
- $this->registry->output->core_nav[] = array( $this->settings['base_url'] . 'module=logs§ion=spiderlogs', $this->lang->words['slog_spider_logs'] );
-
- ///----------------------------------------
- // What to do...
- //-----------------------------------------
-
- switch( $this->request['do'] )
- {
- case 'view':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'spiderlogs_view' );
- $this->_view();
- break;
-
- case 'remove':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'spiderlogs_delete' );
- $this->_remove();
- break;
-
- default:
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'spiderlogs_view' );
- $this->_listCurrent();
- break;
- }
-
- /* Output */
- $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
- $this->registry->output->sendOutput();
- }
-
- /**
- * View all logs for a given moderator
- *
- * @return @e void [Outputs to screen]
- */
- protected function _view()
- {
- ///----------------------------------------
- // Basic init
- //-----------------------------------------
-
- $start = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0;
-
- $botty = IPSText::parseCleanValue( urldecode($this->request['bid'] ) );
- $botty = str_replace( "!", "!", $botty );
-
- ///----------------------------------------
- // No bid or search string?
- //-----------------------------------------
-
- if ( !$this->request['search_string'] AND !$this->request['bid'] )
- {
- $this->registry->output->global_message = $this->lang->words['slog_nostring'];
- $this->_listCurrent();
- return;
- }
-
- ///----------------------------------------
- // mid?
- //-----------------------------------------
-
- if ( !$this->request['search_string'] )
- {
- $row = $this->DB->buildAndFetch( array( 'select' => 'COUNT(sid) as count', 'from' => 'spider_logs', 'where' => "bot='{$botty}'" ) );
-
- $row_count = $row['count'];
-
- $query = "&{$this->form_code}&bid=" . $this->request['bid'] . "&do=view";
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'spider_logs',
- 'where' => "bot='{$botty}'",
- 'order' => 'entry_date DESC',
- 'limit' => array( $start, 20 ) ) );
- $this->DB->execute();
- }
- else
- {
- $this->request['search_string'] = IPSText::parseCleanValue( urldecode($this->request['search_string'] ) );
-
- $row = $this->DB->buildAndFetch( array( 'select' => 'COUNT(sid) as count', 'from' => 'spider_logs', 'where' => "query_string LIKE '%" . $this->request['search_string'] . "%'" ) );
-
- $row_count = $row['count'];
-
- $query = "&{$this->form_code}&do=view&search_string=" . urlencode($this->request['search_string']);
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'spider_logs',
- 'where' => "(query_string LIKE '%" . $this->request['search_string'] . "%') OR (request_addr LIKE '%" . $this->request['search_string'] . "%')",
- 'order' => 'entry_date DESC',
- 'limit' => array( $start, 20 ) ) );
- $this->DB->execute();
- }
-
- ///----------------------------------------
- // Page links
- //-----------------------------------------
-
- $links = $this->registry->output->generatePagination( array( 'totalItems' => $row_count,
- 'itemsPerPage' => 20,
- 'currentStartValue' => $start,
- 'baseUrl' => $this->settings['base_url'] . $query,
- )
- );
-
- ///----------------------------------------
- // Get db results
- //-----------------------------------------
-
- while ( $row = $this->DB->fetch() )
- {
- $extra = "";
-
- if( $row['query_string'] )
- {
- if ( stripos( '#lo-fi#i', $row['query_string'] ) !== false )
- {
- $extra = $this->lang->words['slog_lofi'];
-
- $query_string_html = $extra . ' ' . $row['query_string'];
- }
- else
- {
- $query_string_html = "settings['php_ext'] . "?{$row['query_string']}' target='_blank'>" . IPSText::truncate($row['query_string']) . " ";
- }
- }
- else
- {
- $query_string_html = "" . IPSText::truncate($row['request_addr']) . " ";
- }
-
- $row['_bot_name'] = $this->bot_map[ strtolower($row['bot']) ];
- $row['_query_string'] = $query_string_html;
- $row['_time'] = $this->registry->getClass('class_localization')->getDate( $row['entry_date'], 'LONG' );
-
- $rows[] = $row;
- }
-
- ///----------------------------------------
- // And output
- //-----------------------------------------
-
- $this->registry->output->html .= $this->html->spiderlogsView( $rows, $links );
- }
-
- /**
- * Remove logs by a moderator
- *
- * @return @e void [Outputs to screen]
- */
- protected function _remove()
- {
- if ( $this->request['bid'] == "" )
- {
- $this->registry->output->showError( $this->lang->words['slog_nologs'], 11132 );
- }
-
- $botty = urldecode($this->request['bid']);
- $botty = str_replace( "!", "!", $botty );
-
- $this->DB->delete( 'spider_logs', "bot='{$botty}'" );
-
- $this->registry->getClass('adminFunctions')->saveAdminLog($this->lang->words['slog_adminlog']);
-
- $this->registry->output->silentRedirect( $this->settings['base_url']."&{$this->form_code}" );
- }
-
-
- /**
- * List the current logs with links to view per-admin
- *
- * @return @e void [Outputs to screen]
- */
- protected function _listCurrent()
- {
- $spiders = array();
-
- //-----------------------------------------
- // All bots
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'count(*) as cnt, bot, max(entry_date) as entry_date',
- 'from' => 'spider_logs',
- 'group' => 'bot',
- 'order' => 'entry_date DESC',
- ) );
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- $r['_bot_name'] = $this->bot_map[ strtolower($r['bot']) ];
- $r['_time'] = $this->registry->getClass('class_localization')->getDate( $r['entry_date'], 'SHORT' );
- $r['_bot_url'] = urlencode($r['bot']);
-
- $spiders[] = $r;
- }
-
- //-----------------------------------------
- // And output
- //-----------------------------------------
-
- $this->registry->output->html .= $this->html->spiderlogsWrapper( $spiders );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Search Engine Spider logs
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 27th January 2004
+ * @version $Rev: 10721 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+class admin_core_logs_spiderlogs extends ipsCommand
+{
+ /**
+ * Skin object
+ *
+ * @var object Skin templates
+ */
+ protected $html;
+
+ /**
+ * Spider map
+ *
+ * @var array Spider keys to values
+ */
+ protected $bot_map = array();
+
+ /**
+ * Main class entry point
+ *
+ * @param object ipsRegistry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Load bat names from the useragents cache */
+ foreach( $this->cache->getCache( 'useragents' ) as $agent )
+ {
+ if( $agent['uagent_type'] == 'search' )
+ {
+ $this->bot_map[ $agent['uagent_key'] ] = $agent['uagent_name'];
+ }
+ }
+
+ //-----------------------------------------
+ // Load skin
+ //-----------------------------------------
+
+ $this->html = $this->registry->output->loadTemplate('cp_skin_spiderlogs');
+
+ //-----------------------------------------
+ // Set up stuff
+ //-----------------------------------------
+
+ $this->form_code = $this->html->form_code = 'module=logs§ion=spiderlogs';
+ $this->form_code_js = $this->html->form_code_js = 'module=logs§ion=spiderlogs';
+
+ //-----------------------------------------
+ // Load lang
+ //-----------------------------------------
+
+ $this->registry->getClass('class_localization')->loadLanguageFile( array( 'admin_logs' ) );
+
+ $this->registry->output->core_nav[] = array( $this->settings['base_url'] . 'module=logs§ion=spiderlogs', $this->lang->words['slog_spider_logs'] );
+
+ ///----------------------------------------
+ // What to do...
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ case 'view':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'spiderlogs_view' );
+ $this->_view();
+ break;
+
+ case 'remove':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'spiderlogs_delete' );
+ $this->_remove();
+ break;
+
+ default:
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'spiderlogs_view' );
+ $this->_listCurrent();
+ break;
+ }
+
+ /* Output */
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * View all logs for a given moderator
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _view()
+ {
+ ///----------------------------------------
+ // Basic init
+ //-----------------------------------------
+
+ $start = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0;
+
+ $botty = IPSText::parseCleanValue( urldecode($this->request['bid'] ) );
+ $botty = str_replace( "!", "!", $botty );
+
+ ///----------------------------------------
+ // No bid or search string?
+ //-----------------------------------------
+
+ if ( !$this->request['search_string'] AND !$this->request['bid'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['slog_nostring'];
+ $this->_listCurrent();
+ return;
+ }
+
+ ///----------------------------------------
+ // mid?
+ //-----------------------------------------
+
+ if ( !$this->request['search_string'] )
+ {
+ $row = $this->DB->buildAndFetch( array( 'select' => 'COUNT(sid) as count', 'from' => 'spider_logs', 'where' => "bot='{$botty}'" ) );
+
+ $row_count = $row['count'];
+
+ $query = "&{$this->form_code}&bid=" . $this->request['bid'] . "&do=view";
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'spider_logs',
+ 'where' => "bot='{$botty}'",
+ 'order' => 'entry_date DESC',
+ 'limit' => array( $start, 20 ) ) );
+ $this->DB->execute();
+ }
+ else
+ {
+ $this->request['search_string'] = IPSText::parseCleanValue( urldecode($this->request['search_string'] ) );
+
+ $row = $this->DB->buildAndFetch( array( 'select' => 'COUNT(sid) as count', 'from' => 'spider_logs', 'where' => "query_string LIKE '%" . $this->request['search_string'] . "%'" ) );
+
+ $row_count = $row['count'];
+
+ $query = "&{$this->form_code}&do=view&search_string=" . urlencode($this->request['search_string']);
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'spider_logs',
+ 'where' => "(query_string LIKE '%" . $this->request['search_string'] . "%') OR (request_addr LIKE '%" . $this->request['search_string'] . "%')",
+ 'order' => 'entry_date DESC',
+ 'limit' => array( $start, 20 ) ) );
+ $this->DB->execute();
+ }
+
+ ///----------------------------------------
+ // Page links
+ //-----------------------------------------
+
+ $links = $this->registry->output->generatePagination( array( 'totalItems' => $row_count,
+ 'itemsPerPage' => 20,
+ 'currentStartValue' => $start,
+ 'baseUrl' => $this->settings['base_url'] . $query,
+ )
+ );
+
+ ///----------------------------------------
+ // Get db results
+ //-----------------------------------------
+
+ while ( $row = $this->DB->fetch() )
+ {
+ $extra = "";
+
+ if( $row['query_string'] )
+ {
+ if ( stripos( '#lo-fi#i', $row['query_string'] ) !== false )
+ {
+ $extra = $this->lang->words['slog_lofi'];
+
+ $query_string_html = $extra . ' ' . $row['query_string'];
+ }
+ else
+ {
+ $query_string_html = "settings['php_ext'] . "?{$row['query_string']}' target='_blank'>" . IPSText::truncate($row['query_string']) . " ";
+ }
+ }
+ else
+ {
+ $query_string_html = "" . IPSText::truncate($row['request_addr']) . " ";
+ }
+
+ $row['_bot_name'] = $this->bot_map[ mb_strtolower($row['bot']) ];
+ $row['_query_string'] = $query_string_html;
+ $row['_time'] = $this->registry->getClass('class_localization')->getDate( $row['entry_date'], 'LONG' );
+
+ $rows[] = $row;
+ }
+
+ ///----------------------------------------
+ // And output
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->html->spiderlogsView( $rows, $links );
+ }
+
+ /**
+ * Remove logs by a moderator
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _remove()
+ {
+ if ( $this->request['bid'] == "" )
+ {
+ $this->registry->output->showError( $this->lang->words['slog_nologs'], 11132 );
+ }
+
+ $botty = urldecode($this->request['bid']);
+ $botty = str_replace( "!", "!", $botty );
+
+ $this->DB->delete( 'spider_logs', "bot='{$botty}'" );
+
+ $this->registry->getClass('adminFunctions')->saveAdminLog($this->lang->words['slog_adminlog']);
+
+ $this->registry->output->silentRedirect( $this->settings['base_url']."&{$this->form_code}" );
+ }
+
+
+ /**
+ * List the current logs with links to view per-admin
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _listCurrent()
+ {
+ $spiders = array();
+
+ //-----------------------------------------
+ // All bots
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'count(*) as cnt, bot, max(entry_date) as entry_date',
+ 'from' => 'spider_logs',
+ 'group' => 'bot',
+ 'order' => 'entry_date DESC',
+ ) );
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ $r['_bot_name'] = $this->bot_map[ strtolower($r['bot']) ];
+ $r['_time'] = $this->registry->getClass('class_localization')->getDate( $r['entry_date'], 'SHORT' );
+ $r['_bot_url'] = urlencode($r['bot']);
+
+ $spiders[] = $r;
+ }
+
+ //-----------------------------------------
+ // And output
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->html->spiderlogsWrapper( $spiders );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/logs/sqlerror.php b/upload/admin/applications/core/modules_admin/logs/sqlerror.php
index 80617a16..7ab90120 100644
--- a/upload/admin/applications/core/modules_admin/logs/sqlerror.php
+++ b/upload/admin/applications/core/modules_admin/logs/sqlerror.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* SQL error logs
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2013-04-15 17:26:30 -0400 (Mon, 15 Apr 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 12179 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -151,7 +151,7 @@ class admin_core_logs_sqlerror extends ipsCommand
continue;
}
- if ( preg_match( "#^sql_error_log_(\d+)_(\d+)_(\d+).cgi$#", $file->getFilename() ) )
+ if ( preg_match( "#^sql_error_log_(\d+)_(\d+)_(\d+).cgi$#", $file->getFilename() ) || $file->getFilename() == "sql_error_latest.cgi" )
{
$count++;
diff --git a/upload/admin/applications/core/modules_admin/logs/tasklogs.php b/upload/admin/applications/core/modules_admin/logs/tasklogs.php
index 4669a5f8..90a4a141 100644
--- a/upload/admin/applications/core/modules_admin/logs/tasklogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/tasklogs.php
@@ -4,10 +4,10 @@
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: bfarber $
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $Author: AndyMillne $
+ * $LastChangedDate: 2012-11-28 09:38:19 -0500 (Wed, 28 Nov 2012) $
+ * @version v3.4.5
+ * $Revision: 11659 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -71,17 +71,17 @@ class admin_core_logs_tasklogs extends ipsCommand
{
default:
case 'task_logs':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tasklogs_view' );
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tasklogs_view', '', 'system' );
$this->taskLogsOverview();
break;
case 'task_log_show':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tasklogs_view' );
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tasklogs_view', '', 'system' );
$this->taskLogsShow();
break;
case 'task_log_delete':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tasklogs_delete' );
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tasklogs_delete', '', 'system' );
$this->taskLogsDelete();
break;
}
diff --git a/upload/admin/applications/core/modules_admin/logs/warnlogs.php b/upload/admin/applications/core/modules_admin/logs/warnlogs.php
index df31b4fe..384ff15b 100644
--- a/upload/admin/applications/core/modules_admin/logs/warnlogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/warnlogs.php
@@ -6,9 +6,9 @@
* $License: http://www.invisionpower.com/company/standards.php#license$
* $Author: bfarber $
* @since 27th January 2004
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $LastChangedDate: 2013-05-02 23:43:16 -0400 (Thu, 02 May 2013) $
+ * @version v3.4.5
+ * $Revision: 12217 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -223,7 +223,7 @@ class admin_core_logs_warnlogs extends ipsCommand
$row['_date'] = $this->registry->class_localization->getDate( $row['wl_date'], 'LONG' );
$row['wl_reason'] = $row['wl_reason'] ? $reasons[ $row['wl_reason'] ]['wr_name'] : '--';
$row['_mod'] = $row['wl_mq'] == -1 ? $this->lang->words['wlog_indef'] : ( $row['wl_mq'] == 0 ? $this->lang->words['wlog_none'] : $row['wl_mq'] . ' ' . $days[ $row['wl_mq_unit'] ? $row['wl_mq_unit'] : 'd' ] );
- $row['_susp'] = $row['wl_suspend'] == -1 ? $this->lang->words['wlog_indef'] : ( $row['wl_suspend'] == 0 ? $this->lang->words['wlog_none'] : $row['wl_suspend'] . ' ' . $row[ $row['wl_suspend_unit'] ? $row['wl_suspend_unit'] : 'd' ] );
+ $row['_susp'] = ( in_array( $row['wl_suspend'], array( -1, -2 ) ) ) ? $this->lang->words['wlog_indef'] : ( $row['wl_suspend'] == 0 ? $this->lang->words['wlog_none'] : $row['wl_suspend'] . ' ' . $row[ $row['wl_suspend_unit'] ? $row['wl_suspend_unit'] : 'd' ] );
$row['_post'] = $row['wl_rpa'] == -1 ? $this->lang->words['wlog_indef'] : ( $row['wl_rpa'] == 0 ? $this->lang->words['wlog_none'] : $row['wl_rpa'] . ' ' . $days[ $row['wl_rpa_unit'] ? $row['wl_rpa_unit'] : 'd' ] );
$rows[] = $row;
diff --git a/upload/admin/applications/core/modules_admin/logs/xml/menu.xml b/upload/admin/applications/core/modules_admin/logs/xml/menu.xml
index 58fb1b0a..4c476fba 100644
--- a/upload/admin/applications/core/modules_admin/logs/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/logs/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Logs
+ Журналы
- Logs
+ Журналы
splashlogs
logsSplash
diff --git a/upload/admin/applications/core/modules_admin/logs/xml/permissions.xml b/upload/admin/applications/core/modules_admin/logs/xml/permissions.xml
index 014c5f0f..38e29d01 100644
--- a/upload/admin/applications/core/modules_admin/logs/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/logs/xml/permissions.xml
@@ -1,110 +1,110 @@
- Admin Logs
+ Журнал действий администраторов
core_adminlogs
-
adminlogs_view
- Can view admin logs?
+ Может просматривать журнал?
-
adminlogs_delete
- Can delete admin logs?
+ Может удалять записи?
- Admin Login Logs
+ Журнал входа администраторов
core_acp_loginlogs
-
acplogin_log
- Can view admin login logs?
+ Может просматривать журнал входа администраторов?
- Moderator Logs
+ Журнал действий модераторов
core_modlogs
-
modlogs_view
- Can view moderator logs?
+ Может просматривать журнал?
-
modlogs_delete
- Can delete moderator logs?
+ Может удалять записи?
- Email Error Logs
+ Журнал ошибок Email
core_eelogs
-
emailerrorlogs_view
- Can view email error logs?
+ Может просматривать журнал?
-
emailerrorlogs_delete
- Can delete email error logs?
+ Может удалять записи?
- Spider Logs
+ Журнал действий поисковых роботов
core_spiderlogs
-
spiderlogs_view
- Can view spider logs?
+ Может просматривать журнал?
-
spiderlogs_delete
- Can delete spider logs?
+ Может удалять записи?
- Warn Logs
+ Журнал предупреждений
core_warnlogs
-
warnlogs_view
- Can view warn logs?
+ Может просматривать журнал?
-
warnlogs_delete
- Can delete warn logs?
+ Может удалять записи?
- Error Logs
+ Журнал ошибок системы
core_errorlogs
-
errorlogs_view
- Can view error logs?
+ Может просматривать журнал?
-
errorlogs_delete
- Can delete error logs?
+ Может удалять записи?
- SQL Error Logs
+ Журнал SQL ошибок
core_selogs
-
sqlerrorlogs_view
- Can view SQL error logs?
+ Может просматривать журнал?
-
sqlerrorlogs_delete
- Can delete SQL error logs?
+ Может удалять записи?
diff --git a/upload/admin/applications/core/modules_admin/logs/xmlrpclogs.php b/upload/admin/applications/core/modules_admin/logs/xmlrpclogs.php
index 80e330f5..807a880b 100644
--- a/upload/admin/applications/core/modules_admin/logs/xmlrpclogs.php
+++ b/upload/admin/applications/core/modules_admin/logs/xmlrpclogs.php
@@ -3,19 +3,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* API Users
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-11-28 09:38:19 -0500 (Wed, 28 Nov 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright © 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 1st march 2002
- * @version $Revision: 10914 $
+ * @version $Revision: 11659 $
*
*/
@@ -77,11 +77,11 @@ class admin_core_logs_xmlrpclogs extends ipsCommand
{
default:
case 'log_list':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'api_logs' );
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'api_logs', '', 'tools' );
$this->logList();
break;
case 'log_view_detail':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'api_logs' );
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'api_logs', '', 'tools' );
$this->logViewDetail();
break;
}
diff --git a/upload/admin/applications/core/modules_admin/mobileapp/defaultSection.php b/upload/admin/applications/core/modules_admin/mobileapp/defaultSection.php
index 7157b576..48c981ad 100644
--- a/upload/admin/applications/core/modules_admin/mobileapp/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/mobileapp/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2010-10-14 13:11:17 -0400 (Thu, 14 Oct 2010) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 477 $
*/
diff --git a/upload/admin/applications/core/modules_admin/mobileapp/images.php b/upload/admin/applications/core/modules_admin/mobileapp/images.php
index 186ea684..4d55a372 100644
--- a/upload/admin/applications/core/modules_admin/mobileapp/images.php
+++ b/upload/admin/applications/core/modules_admin/mobileapp/images.php
@@ -3,7 +3,7 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Manage mobile app images
* Last Updated: $Date: 2012-03-30 16:23:27 +0100 (Fri, 30 Mar 2012) $
*
diff --git a/upload/admin/applications/core/modules_admin/mobileapp/xml/menu.xml b/upload/admin/applications/core/modules_admin/mobileapp/xml/menu.xml
index e8d4bb24..9a5f9ac7 100644
--- a/upload/admin/applications/core/modules_admin/mobileapp/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/mobileapp/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Mobile App
+ Мобильное Приложение
- Mobile App
+ Мобильное Приложение
skins_manage_app_images
images
do=overview
diff --git a/upload/admin/applications/core/modules_admin/mobileapp/xml/permissions.xml b/upload/admin/applications/core/modules_admin/mobileapp/xml/permissions.xml
index 86629af2..58897301 100644
--- a/upload/admin/applications/core/modules_admin/mobileapp/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/mobileapp/xml/permissions.xml
@@ -1,12 +1,12 @@
- Manage App Images
+ Изображения
core_templates
-
app_images
- Can view and manage app images?
+ Может управлять изображениями?
diff --git a/upload/admin/applications/core/modules_admin/mycp/dashboard.php b/upload/admin/applications/core/modules_admin/mycp/dashboard.php
index ca5e5ef6..ea559e58 100644
--- a/upload/admin/applications/core/modules_admin/mycp/dashboard.php
+++ b/upload/admin/applications/core/modules_admin/mycp/dashboard.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Dashboard
- * Last Updated: $Date: 2012-07-03 12:20:08 -0400 (Tue, 03 Jul 2012) $
+ * Last Updated: $Date: 2012-10-23 15:11:59 -0400 (Tue, 23 Oct 2012) $
*
*
- * @author $Author: AndyMillne $
+ * @author $Author: bfarber $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 5th January 2005
- * @version $Revision: 11029 $
+ * @version $Revision: 11511 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -116,6 +116,10 @@ class admin_core_mycp_dashboard extends ipsCommand
//-----------------------------------------
// Hang on, do we need the upgrader?
+ // The only reason this is still here, since we check on the login form, is because Rhett Buck AKA BHP wants to
+ // login to the ACP, then upload files, then click the System tab and be automatically redirected to the upgrader.
+ // Seriously though? Who does that? The login form redirects you, so if you happen to upload files and click on
+ // the ACP link you're already covered. Only Mr. RB, that's who.
//-----------------------------------------
if ( !IN_DEV AND ( !defined('SKIP_UPGRADE_CHECK') OR !SKIP_UPGRADE_CHECK ) )
@@ -178,7 +182,7 @@ class admin_core_mycp_dashboard extends ipsCommand
$latest_version = array( 'upgrade_version_id' => NULL );
- $this->DB->build( array( 'select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC', 'limit' => array(1) ) );
+ $this->DB->build( array( 'select' => '*', 'from' => 'upgrade_history', 'order' => 'upgrade_version_id DESC', 'limit' => array(1) ) );
$this->DB->execute();
while( $r = $this->DB->fetch() )
diff --git a/upload/admin/applications/core/modules_admin/mycp/defaultSection.php b/upload/admin/applications/core/modules_admin/mycp/defaultSection.php
index 780df46f..4553a0ee 100644
--- a/upload/admin/applications/core/modules_admin/mycp/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/mycp/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/mycp/details.php b/upload/admin/applications/core/modules_admin/mycp/details.php
index 57e8c069..d5a2a64b 100644
--- a/upload/admin/applications/core/modules_admin/mycp/details.php
+++ b/upload/admin/applications/core/modules_admin/mycp/details.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Admin change email/password
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 5th January 2005
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/mycp/tabs.php b/upload/admin/applications/core/modules_admin/mycp/tabs.php
new file mode 100644
index 00000000..594f314d
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/mycp/tabs.php
@@ -0,0 +1,143 @@
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Dashboard
+ * Last Updated: $Date: 2012-07-12 18:15:50 +0100 (Thu, 12 Jul 2012) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 5th January 2005
+ * @version $Revision: 11070 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+class admin_core_mycp_tabs extends ipsCommand
+{
+ /**
+ * Skin object
+ *
+ * @var object Skin templates
+ */
+ protected $html;
+
+ /**
+ * Shortcut for url
+ *
+ * @var string URL shortcut
+ */
+ protected $form_code;
+
+ /**
+ * Shortcut for url (javascript)
+ *
+ * @var string JS URL shortcut
+ */
+ protected $form_code_js;
+
+ /**
+ * Main function executed automatically by the controller
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ //-----------------------------------------
+ // Load skin
+ //-----------------------------------------
+
+ $this->html = $this->registry->output->loadTemplate('cp_skin_mycp');
+
+ //-----------------------------------------
+ // Load language
+ //-----------------------------------------
+
+ $this->registry->getClass('class_localization')->loadLanguageFile( array( 'admin_mycp' ) );
+
+ //-----------------------------------------
+ // Set up stuff
+ //-----------------------------------------
+
+ $this->form_code = $this->html->form_code = 'module=mycp§ion=tabs';
+ $this->form_code_js = $this->html->form_code_js = 'module=mycp§ion=tabs';
+
+ /* Geddit */
+ if ( $this->request['do'] == 'save' )
+ {
+ $this->tabsSave();
+ }
+ else
+ {
+ $this->tabsForm();
+ }
+
+ //-----------------------------------------
+ // Pass to CP output hander
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
+ $this->registry->getClass('output')->sendOutput();
+ }
+
+ /**
+ * Saves the tab form
+ *
+ * @return array
+ */
+ public function tabsSave()
+ {
+ $tabBar = array();
+ $otherMenu = array();
+
+ if ( empty( $_GET['reset'] ) && is_array( $_GET ) )
+ {
+ foreach( $_GET as $k => $v )
+ {
+ if ( substr( $k, 0, 7 ) == 'tabBar_' )
+ {
+ $tabBar[ str_replace( 'tabBar_', '', $k ) ] = $v;
+ }
+
+ if ( substr( $k, 0, 10 ) == 'otherMenu_' )
+ {
+ $otherMenu[ str_replace( 'otherMenu_', '', $k ) ] = $v;
+ }
+ }
+ }
+
+ /* Save it */
+ $this->registry->adminFunctions->staffSaveCookie( 'tabPrefs', array( 'tabBar' => $tabBar, 'otherMenu' => $otherMenu ) );
+
+ /* Reload */
+ $this->registry->output->silentRedirect( $this->settings['base_url'] . '&' . $this->form_code . '&do=show' );
+ }
+
+ /**
+ * Builds the tab form
+ *
+ * @return array
+ */
+ public function tabsForm()
+ {
+ $applications = ipsRegistry::$applications;
+ $mainTabs = $this->registry->output->getMainTabKeys();
+ $otherTabs = $this->registry->output->getOtherTabKeys();
+
+ $mainTabData = $this->registry->output->getTabDataFromKeys( $mainTabs );
+ $otherTabData = $this->registry->output->getTabDataFromKeys( $otherTabs );
+
+ $this->registry->output->html = $this->html->tabsForm( $mainTabData, $otherTabData );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/mycp/xml/menu.xml b/upload/admin/applications/core/modules_admin/mycp/xml/menu.xml
index 49326433..5b81c7a1 100644
--- a/upload/admin/applications/core/modules_admin/mycp/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/mycp/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
My Dashboard
+ Панель Управления
- My Dashboard
+ Панель Управления
dashboard
dashboard
@@ -15,10 +15,10 @@
-
-
Change My Details
+ Изменить Мои Данные
- Change My Details
+ Изменить Мои Данные
mydetails
details
diff --git a/upload/admin/applications/core/modules_admin/mycp/xml/permissions.xml b/upload/admin/applications/core/modules_admin/mycp/xml/permissions.xml
index 8fef67e3..2fd6734f 100644
--- a/upload/admin/applications/core/modules_admin/mycp/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/mycp/xml/permissions.xml
@@ -1,12 +1,12 @@
- My Control Panel
+ Панель управления
core_mycp
-
dashboard
- Can access the dashboard?
+ Имеет доступ к панели?
diff --git a/upload/admin/applications/core/modules_admin/posts/acronyms.php b/upload/admin/applications/core/modules_admin/posts/acronyms.php
new file mode 100644
index 00000000..30a52bb6
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/posts/acronyms.php
@@ -0,0 +1,245 @@
+Incorrect accessYou cannot access this file directly.";
+ exit();
+}
+
+class admin_core_posts_acronyms extends ipsCommand
+{
+ /**
+ * Skin object shortcut
+ *
+ * @var $html
+ */
+ public $html;
+
+ /**
+ * String for the screen url bit
+ *
+ * @var $form_code
+ */
+ public $form_code = '';
+
+ /**
+ * String for the JS url bit
+ *
+ * @var $form_code_js
+ */
+ public $form_code_js = '';
+
+ /**
+ * Main function executed automatically by the controller
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'acronyms_manage' );
+
+ ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_seo' ) );
+
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_seo' );
+
+ $this->form_code = $this->html->form_code = 'module=posts§ion=acronyms&';
+ $this->form_code_js = $this->html->form_code_js = 'module=posts§ion=acronyms&';
+
+ //-----------------------------------------
+ // What are we doing
+ //-----------------------------------------
+
+ switch ( $this->request['do'] )
+ {
+ case 'add':
+ $this->form( 'add' );
+ break;
+
+ case 'edit':
+ $this->form( 'edit' );
+ break;
+
+ case 'save':
+ $this->save();
+ break;
+
+ case 'delete':
+ $this->delete();
+ break;
+
+ default:
+ $this->manage();
+ break;
+ }
+
+ //-----------------------------------------
+ // Pass to CP output hander
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->html_main .= $this->registry->getClass('output')->global_template->global_frame_wrapper();
+ $this->registry->getClass('output')->sendOutput();
+ }
+
+ /**
+ * Acronyms dashboard
+ *
+ * @return @e void
+ */
+ private function manage()
+ {
+ $acronyms = array();
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'seo_acronyms', 'order' => 'a_short' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $acronyms[ $row['a_id'] ] = $row;
+ }
+
+ $this->registry->output->html .= $this->html->acronyms( $acronyms );
+ }
+
+ /**
+ * Displays a form to add/edit acronyms
+ *
+ * @return @e void
+ */
+ private function form( $type )
+ {
+ /* Normal form logic */
+ $current = array();
+
+ if ( $type == 'edit' )
+ {
+ $current = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'seo_acronyms', 'where' => 'a_id=' . intval($this->request['id']) ) );
+
+ if ( !$current['a_id'] )
+ {
+ ipsRegistry::getClass('output')->showError( 'err_no_acronym', '11SEO100', FALSE, '', 404 );
+ }
+ }
+
+ $this->registry->output->html .= $this->html->acronymForm( $current );
+ }
+
+ /**
+ * Saves the new/edited acronym
+ *
+ * @return @e void
+ */
+ private function save()
+ {
+ //-----------------------------------------
+ // Validate Data
+ //-----------------------------------------
+
+ if ( !$this->request['short'] or !$this->request['long'] )
+ {
+ ipsRegistry::getClass('output')->showError( 'err_acronym_details', '11SEO101', FALSE, '', 500 );
+ }
+
+ if ( strlen( $this->request['short'] ) > 255 or strlen( $this->request['long'] ) > 255 )
+ {
+ ipsRegistry::getClass('output')->showError( 'err_acronym_toolong', '21SEO102', FALSE, '', 500 );
+ }
+
+ //-----------------------------------------
+ // Save
+ //-----------------------------------------
+
+ $save = array( 'a_short' => $this->request['short'],
+ 'a_long' => $this->request['long'],
+ 'a_semantic' => intval( $this->request['semantic'] ),
+ 'a_casesensitive' => intval( $this->request['casesensitive'] )
+ );
+
+ if ( ! empty($this->request['id']) )
+ {
+ $current = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'seo_acronyms', 'where' => 'a_id=' . intval($this->request['id']) ) );
+
+ if ( empty($current['a_id']) )
+ {
+ ipsRegistry::getClass('output')->showError( 'err_no_acronym', '11SEO100', FALSE, '', 404 );
+ }
+
+ $this->DB->update( 'seo_acronyms', $save, "a_id={$current['a_id']}" );
+ }
+ else
+ {
+ $this->DB->insert( 'seo_acronyms', $save );
+ }
+
+ // And recache
+ $this->recache();
+
+ //-----------------------------------------
+ // Display
+ //-----------------------------------------
+
+ $this->registry->output->global_message = $this->lang->words['acronym_saved'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code );
+ }
+
+ /**
+ * Deletes acronyms
+ *
+ * @return @e void
+ */
+ private function delete()
+ {
+ $id = intval( $this->request['id'] );
+ $current = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'seo_acronyms', 'where' => "a_id={$id}" ) );
+ if ( !$current['a_id'] )
+ {
+ ipsRegistry::getClass('output')->showError( 'err_no_acronym', '11SEO103', FALSE, '', 404 );
+ }
+
+ $this->DB->delete( 'seo_acronyms', "a_id={$id}" );
+
+ $this->recache();
+
+ $this->registry->output->global_message = $this->lang->words['acronym_deleted'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code );
+ }
+
+ /**
+ * Rebuilds the acronyms cache
+ *
+ * @return @e void
+ */
+ public function recache()
+ {
+ $cache = array();
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'seo_acronyms', 'order' => 'a_short' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $cache[ $row['a_short'] ] = $row;
+ }
+
+ $this->cache->setCache( 'ipseo_acronyms', $cache, array( 'array' => 1 ) );
+ }
+
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/posts/badwords.php b/upload/admin/applications/core/modules_admin/posts/badwords.php
index 3c0bebf3..15482bc2 100644
--- a/upload/admin/applications/core/modules_admin/posts/badwords.php
+++ b/upload/admin/applications/core/modules_admin/posts/badwords.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Bad Word Filters
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/posts/bbcode.php b/upload/admin/applications/core/modules_admin/posts/bbcode.php
index 47b0be36..9008b306 100644
--- a/upload/admin/applications/core/modules_admin/posts/bbcode.php
+++ b/upload/admin/applications/core/modules_admin/posts/bbcode.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* BBCode Management
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/posts/defaultSection.php b/upload/admin/applications/core/modules_admin/posts/defaultSection.php
index 8a69e2ab..71430a4e 100644
--- a/upload/admin/applications/core/modules_admin/posts/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/posts/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/posts/emoticons.php b/upload/admin/applications/core/modules_admin/posts/emoticons.php
index 2cd54dc3..01191a69 100644
--- a/upload/admin/applications/core/modules_admin/posts/emoticons.php
+++ b/upload/admin/applications/core/modules_admin/posts/emoticons.php
@@ -1,1381 +1,1381 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Emoticon Management
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since 27th January 2004
- * @version $Rev: 10914 $
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-class admin_core_posts_emoticons extends ipsCommand
-{
- /**
- * Allowed file types
- *
- * @var array
- */
- public $allowed_files = array( 'png', 'jpeg', 'jpg', 'gif' );
-
- protected $setCache = array();
-
- /**
- * Main class entry point
- *
- * @param object ipsRegistry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Load Skin and Lang */
- $this->html = $this->registry->output->loadTemplate( 'cp_skin_emoticons' );
- $this->html->form_code = '&module=posts§ion=emoticons&';
- $this->html->form_code_js = '&module=posts§ion=emoticons&';
-
- $this->lang->loadLanguageFile( array( 'admin_posts' ) );
-
- //-----------------------------------------
- // What to do...
- //-----------------------------------------
-
- switch( $this->request['do'] )
- {
- case 'emo_packsplash':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
- $this->emoticonsPackSplash();
- break;
-
- case 'emo_packexport':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
- $this->emoticonsPackExport();
- break;
-
- case 'emo_packimport':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
- $this->emoticonsPackImport();
- break;
-
- case 'emo_manage':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
- $this->emoticonsManageDirectory();
- break;
-
- case 'emo_doedit':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_edit' );
- $this->emoticonsEdit();
- break;
-
- case 'emo_doadd':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_add' );
- $this->emoticonsAdd();
- break;
-
- case 'emo_remove':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_delete' );
- $this->emoticonsRemove();
- break;
-
- case 'emo_setadd':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_add' );
- $this->emoticonsSetAlter( $type='add' );
- break;
-
- case 'emo_setedit':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_edit' );
- $this->emoticonsSetAlter( $type='edit' );
- break;
-
- case 'emo_setremove':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_delete' );
- $this->emoticonsSetRemove();
- break;
-
- case 'emo_upload':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_add' );
- $this->emoticonsUpload();
- break;
-
- case 'emo':
- case 'overview':
- default:
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
- $this->emoticonsOverview();
- break;
- case 'reorder':
- $this->_reorder();
- break;
- }
-
- /* Output */
- $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
- $this->registry->output->sendOutput();
- }
-
- /**
- * Reorder hooks
- *
- * @return @e void [Outputs to screen]
- */
- protected function _reorder()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
- $ajax = new $classToLoad();
- $set = trim( $this->request['id'] );
-
- //-----------------------------------------
- // Save new position
- //-----------------------------------------
-
- $position = 1;
-
- if ( is_array( $this->request['emoticons'] ) AND count( $this->request['emoticons'] ) )
- {
- /* Reset all emoticons to 0 temporarily */
- $this->DB->update( 'emoticons', array( 'emo_position' => 0 ), 'emo_set=\'' . $this->DB->addSlashes( $set ) . "'" );
-
- foreach( $this->request['emoticons'] as $this_id )
- {
- $this->DB->update( 'emoticons', array( 'emo_position' => $position ), 'id=' . intval($this_id) );
-
- $position++;
- }
- }
-
- $this->emoticonsRebuildCache();
-
- $ajax->returnString( 'OK' );
- }
-
- /**
- * Import an emoticon pack
- *
- * @return @e void
- */
- public function emoticonsPackImport()
- {
- /* Make sure all emoticon directories are writable */
- $this->DB->build( array( 'select' => $this->DB->buildDistinct('emo_set') . ' as folder', 'from' => 'emoticons' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $_folders[] = $r['folder'];
- }
-
- if( count($_folders) )
- {
- foreach( $_folders as $folder )
- {
- if( !IPSLib::isWritable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $folder ) )
- {
- $this->registry->output->global_error = sprintf( $this->lang->words['emodir_not_write'], PUBLIC_DIRECTORY . '/style_emoticons/' . $folder );
- return $this->emoticonsPackSplash();
- }
- }
- }
-
- /* Get the xml file */
- try
- {
- $content = $this->registry->adminFunctions->importXml( 'ipb_emoticons.xml' );
- }
- catch ( Exception $e )
- {
- $this->registry->output->showError( $e->getMessage() );
- }
-
- /* Check for content */
- if ( ! $content )
- {
- $this->registry->output->global_error = $this->lang->words['emo_fail'];
- return $this->emoticonsPackSplash();
- }
-
- /* Setup XML */
- require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
- $xml = new classXML( IPS_DOC_CHAR_SET );
-
- require_once( IPS_KERNEL_PATH.'classXMLArchive.php' );/*noLibHook*/
- $xmlarchive = new classXMLArchive();
-
- /* Read the archive */
- $xmlarchive->readXML( $content );
-
- /* Get the data file */
- $emoticons = array();
- $emoticon_data = array();
-
- foreach( $xmlarchive->asArray() as $k => $f )
- {
- if ( $k == 'emoticon_data.xml' )
- {
- $emoticon_data = $f;
- }
- else
- {
- $emoticons[ $f['filename'] ] = $f['content'];
- }
- }
-
- /* Parse the XML Document */
- $xml->loadXML( $emoticon_data['content'] );
-
- /* Make sure we have a destination for these emoicons */
- if ( ! $this->request['emo_set'] and ! $this->request['new_emo_set'] )
- {
- $this->registry->output->global_error = $this->lang->words['emo_specify'];
- }
-
- /* Current emoticon set directory */
- $emo_set_dir = trim( $this->request['emo_set'] );
-
- /* New emoticon set directory */
- $this->request['new_emo_set'] = preg_replace( '/[^a-zA-Z0-9\-_]/', "", $this->request['new_emo_set'] );
-
- /* Create the new set */
- if ( $this->request['new_emo_set'] )
- {
- $emo_set_dir = trim( $this->request['new_emo_set'] );
-
- /* Check to see if the directory already exists */
- if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir ) )
- {
- $this->registry->output->global_error = sprintf( $this->lang->words['emo_already'], $emo_set_dir );
- return $this->emoticonsPackSplash();
- }
-
- /* Create the directory */
- if ( @mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir, IPS_FOLDER_PERMISSION ) )
- {
- @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir, IPS_FOLDER_PERMISSION );
- @file_put_contents( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir . '/index.html', '' );
- }
- else
- {
- $this->registry->output->global_error = $this->lang->words['emo_ftp'];
- return $this->emoticonsPackSplash();
- }
- }
-
- /* Get a list of current emoticons, if we are not overwriting */
- $emo_image = array();
- $emo_typed = array();
-
- if ( $this->request['overwrite'] != 1 )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='" . $emo_set_dir . "'" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $emo_image[ $r['image'] ] = 1;
- $emo_typed[ $r['typed'] ] = 1;
- }
- }
-
- /* Loop through the emoticons in the xml document */
- foreach( $xml->fetchElements('emoticon') as $emoticon )
- {
- $entry = $xml->fetchElementsFromRecord( $emoticon );
-
- /* Emoticon Data */
- $image = $entry['image'];
- $typed = $entry['typed'];
- $click = $entry['clickable'];
-
- /* Skip if we're not overwriting */
- if ( $emo_image[ $image ] or $emo_typed[ $typed ] )
- {
- continue;
- }
-
- /* Get the extension */
- $file_extension = preg_replace( '#^.*\.(.+?)$#si', "\\1", strtolower( $image ) );
-
- /* Make sure it's allowed */
- if ( ! in_array( $file_extension, $this->allowed_files ) )
- {
- continue;
- }
-
- /* Remove any existing emoticon */
- @unlink( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir . '/' . $image );
-
- $this->DB->delete( 'emoticons', "typed='$typed' and image='$image' and emo_set='$emo_set_dir'" );
-
- /* Create the image in the file system */
- if( $FH = fopen( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' .$emo_set_dir . '/' . $image, 'wb' ) )
- {
- if ( fwrite( $FH, $emoticons[ $image ] ) )
- {
- fclose( $FH );
-
- /* Insert the emoticon record */
- $this->DB->insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'clickable' => $click, 'emo_set' => $emo_set_dir ) );
- }
- }
-
- /* Add the emoticon to all the other directories */
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' ) as $file )
- {
- if( ! $file->isDot() && $file->isDir() )
- {
- if ( substr( $file->getFilename(), 0, 1 ) == '.' )
- {
- continue;
- }
-
- if ( ! is_file( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $file->getFilename() . '/' . $image ) )
- {
- $this->DB->delete( 'emoticons', "typed='$typed' and image='$image' and emo_set='{$file->getFilename()}'" );
-
- if ( $FH = @fopen( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $file->getFilename() . '/' . $image, 'wb' ) )
- {
- if ( fwrite( $FH, $emoticons[ $image ] ) )
- {
- fclose( $FH );
-
- $this->DB->insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'clickable' => $click, 'emo_set' => $file->getFilename() ) );
- }
- }
- }
- }
- }
- } catch ( Exception $e ) {}
- }
-
- /* Recache and bounce */
- $this->emoticonsRebuildCache();
-
- $this->registry->output->global_message = $this->lang->words['emo_xml_good'];
- $this->emoticonsOverview();
-
- }
-
- /**
- * Export the specified emoticon directory
- *
- * @return @e void
- */
- public function emoticonsPackExport()
- {
- /* Setup XML */
- require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
- $xml = new classXML( IPS_DOC_CHAR_SET );
-
- require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
- $xmlarchive = new classXMLArchive();
-
- /* Check the emoticon set */
- if ( ! $this->request['emo_set'] )
- {
- $this->registry->output->global_message = $this->lang->words['emo_specify_exS'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Get emoticons from the database */
- $emo_db = array();
-
- $this->DB->build( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='{$this->request['emo_set']}'" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $emo_db[ $r['image'] ] = $r;
- }
-
- /* Get Emoticon Folders */
- $emodirs = array();
- $emodd = array();
- $files_to_add = array();
-
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['emo_set'] ) as $file )
- {
- if( ! $file->isDot() )
- {
- if ( $emo_db[ $file->getFilename() ] != "" )
- {
- $files_to_add[] = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['emo_set'] . '/' . $file->getFilename();
- }
- }
- }
- } catch ( Exception $e ) {}
-
- /* Add each file to the xml archive */
- foreach( $files_to_add as $f )
- {
- $xmlarchive->add( $f );
- }
-
- $xml->newXMLDocument();
- $xml->addElement( 'emoticonexport' );
- $xml->addElement( 'emogroup', 'emoticonexport' );
-
- foreach( $emo_db as $r )
- {
- $content = array();
-
- $content['typed'] = $r['typed'];
- $content['image'] = $r['image'];
- $content['clickable'] = $r['clickable'];
-
- $xml->addElementAsRecord( 'emogroup', 'emoticon', $content );
- }
-
- /* Create the XML Document */
- $xmlData = $xml->fetchDocument();
-
- /* Add the xml document to the archive */
- $xmlarchive->add( $xmlData, 'emoticon_data.xml' );
-
- /* Send the archive to the browser */
- $imagearchive = $xmlarchive->getArchiveContents();
- $this->registry->output->showDownload( $imagearchive, 'ipb_emoticons.xml' );
- }
-
- /**
- * Builds the emoticon import/export pack splash screen
- *
- * @return @e void
- */
- public function emoticonsPackSplash()
- {
- /* Check for the emoticon directory */
- if( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) )
- {
- $this->registry->output->showError( $this->lang->words['emo_nolocate'], 2110 );
-
- }
-
- /* Count the number of current emoticons */
- $this->DB->build( array( 'select' => 'id, count(id) as count, emo_set',
- 'from' => 'emoticons',
- 'group' => 'id, emo_set',
- 'order' => 'emo_set'
- ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $emo_db[ $r['emo_set'] ] = $r;
- }
-
- /* Get the emoticon folders */
- $emodirs = array();
- $emodd = array();
-
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $file )
- {
- if( $file->isDir() && ! $file->isDot() )
- {
- $emodirs[] = $file->getFilename();
- $emodd[] = array( $file->getFilename(), $file->getFilename() );
- }
- }
- } catch ( Exception $e ) {}
-
- /* Build Form Elements */
- $form = array();
- $form['emo_set'] = $this->registry->output->formDropdown( 'emo_set', $emodd );
- $form['new_emo_set'] = $this->registry->output->formInput( 'new_emo_set' );
- $form['overwrite'] = $this->registry->output->formYesNo( 'overwrite' );
-
- /* Output */
- $this->registry->output->html .= $this->html->emoticonsPackSplash( $form );
- }
-
- /**
- * Remove the specified emoticon
- *
- * @return @e void
- */
- public function emoticonsRemove()
- {
- /* Check the ID */
- if( $this->request['id'] == "" )
- {
- $this->registry->output->global_message = $this->lang->words['emo_nogid'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Can only remove the default set */
- if( $this->request['id'] != "default" )
- {
- $this->registry->output->global_message = $this->lang->words['emo_onlydothis'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Check for the emoticon ID */
- $this->request['eid'] = intval( $this->request['eid'] );
-
- if( ! $this->request['eid'] )
- {
- $this->registry->output->global_message = $this->lang->words['emo_noid'];
- $this->emoticonsManageDirectory();
- return;
- }
-
- /* Get the emoticon info */
- $emo_info = $this->DB->buildAndFetch( array( 'select' => 'typed', 'from' => 'emoticons', 'where' => "id=" . $this->request['eid']) );
-
- /* Delete the emoticon */
- $this->DB->delete( 'emoticons', "typed='{$emo_info['typed']}'" );
-
- /* Rebuild the cache and bounce */
- $this->emoticonsRebuildCache();
-
- $this->registry->output->global_message = $this->lang->words['emo_removed'];
- $this->emoticonsManageDirectory();
- }
-
- /**
- * Add emoticons to the default directory
- *
- * @return @e void
- */
- public function emoticonsAdd()
- {
- $image = str_replace( '---', '.', trim( $this->request['emo_image'] ) );
- $set = trim( $this->request['id'] );
- $typed = $this->_getNameFromImg( $image, $set );
- $position = $this->_getNextPosition( $set );
-
- /* Check the id */
- if ( empty( $set ) )
- {
- $this->registry->output->global_message = $this->lang->words['emo_nogid'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Can only upload to the default directory */
- if( $this->request['id'] != "default" )
- {
- $this->registry->output->global_message = $this->lang->words['emo_onlydothis'];
- $this->emoticonsOverview();
- return;
- }
-
- if ( ! $image OR ! $typed )
- {
- $this->registry->output->global_message = $this->lang->words['emo_nogid'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Insert the emo record */
- // as per http://community.invisionpower.com/tracker/issue-34269-emoticon-imports - add to all records rather than
- // just the default. In future version, will hopefully rewrite emoticon management and make this process less mental
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $_emoticon )
- {
- if ( $_emoticon->isDir() AND ! $_emoticon->isDot() AND $_emoticon->getFilename() != '.svn' )
- {
- if ( is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $_emoticon ) )
- {
- $this->DB->insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'emo_set' => $_emoticon->getFilename(), 'emo_position' => $position ) );
- }
- }
- }
-
- /* Emoticon list */
- $emodirs = array( 0 => '');
-
- /* Loop through all the emoticons */
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $file )
- {
- if ( ! $file->isDot() && $file->isDir() && strpos( $file->getFilename(), '.' ) != 0 )
- {
- if( $file->getFilename() == 'default' )
- {
- $emodirs[0] = $file->getFilename();
- }
- else
- {
- $emodirs[] = $file->getFilename();
- }
- }
- }
- } catch ( Exception $e ) {}
-
- /* Add this emoticon to the other sets */
- foreach( $emodirs as $directory )
- {
- if ( $directory == $set )
- {
- continue;
- }
-
- if ( empty( $directory ) )
- {
- continue;
- }
-
- $this->DB->insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'emo_set' => $directory, 'emo_position' => $position ) );
- }
-
- /* Rebuild the cache and bounce */
- $this->emoticonsRebuildCache();
-
- $this->registry->output->global_message = $this->lang->words['emo_updated'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->html->form_code . '&do=emo_manage&id=' . $this->request['id'] );
- }
-
- /**
- * Handles the upload emoticon form
- *
- * @return @e void
- */
- public function emoticonsUpload()
- {
- /* INI */
- $overwrite = 1;
- $uploaded = 0;
-
- /* Check the request for uploads */
- $directories = array();
- $first_dir = '';
-
- foreach( $this->request as $key => $value )
- {
- if( preg_match( "/^dir_(.*)$/", $key, $match ) )
- {
- if( $this->request[ $match[0] ] == 1 )
- {
- $directories[] = $match[1];
- }
- }
- }
-
- /* Can't upload to default */
- if ( ! count( $directories ) )
- {
- $this->registry->output->global_message = $this->lang->words['emo_pickanother'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Remove default from the directories list */
- if ( ! in_array( 'default', $directories ) )
- {
- array_push( $directories, 'default' );
- }
-
- /* Get the first directory */
- $first_dir = array_shift( $directories );
-
- /* Loop through the dirs */
- $emodirs = array( 0 => '' );
-
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $file )
- {
- if( ! $file->isDot() && $file->isDir() )
- {
- /* Add to emoticon list */
- if( $file->getFilename() == 'default' )
- {
- $emodirs[0] = $file->getFilename();
- }
- else
- {
- $emodirs[] = $file->getFilename();
- }
- }
- }
- } catch ( Exception $e ) {}
-
- /* Loop through each form upload field */
- foreach( array( 1,2,3,4 ) as $i )
- {
- /* Upload Data */
- $field = 'upload_'.$i;
- $FILE_NAME = $_FILES[$field]['name'];
- $FILE_SIZE = $_FILES[$field]['size'];
- $FILE_TYPE = $_FILES[$field]['type'];
-
- //-----------------------------------------
- // Naughty Opera adds the filename on the end of the
- // mime type - we don't want this.
- //-----------------------------------------
-
- $FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
-
- //-----------------------------------------
- // Naughty Mozilla likes to use "none" to indicate an empty upload field.
- // I love universal languages that aren't universal.
- //-----------------------------------------
-
- if ( $_FILES[$field]['name'] == "" or ! $_FILES[$field]['name'] or ($_FILES[$field]['name'] == "none") )
- {
- continue;
- }
-
- //-----------------------------------------
- // Make sure it's not a NAUGHTY file
- //-----------------------------------------
-
- $file_extension = preg_replace( '#^.*\.(.+?)$#si', "\\1", strtolower( $_FILES[ $field ]['name'] ) );
-
- if ( ! in_array( $file_extension, $this->allowed_files ) )
- {
- $this->registry->output->global_message = $this->lang->words['emo_mimes']; // The screams of angst from Emo Mimes are silent...
- $this->emoticonsOverview();
- return;
- }
-
- //-----------------------------------------
- // Copy the upload to the uploads directory
- //-----------------------------------------
-
- if ( ! @move_uploaded_file( $_FILES[ $field ]['tmp_name'], DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $first_dir . "/" . $FILE_NAME) )
- {
- $this->registry->output->global_message = "The upload failed, sorry!";
- $this->emoticonsOverview();
- return;
- }
- else
- {
- @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $first_dir . "/" . $FILE_NAME, IPS_FILE_PERMISSION );
-
- //-----------------------------------------
- // Copy to other folders
- //-----------------------------------------
-
- if ( is_array( $directories ) and count( $directories ) )
- {
- foreach ( $directories as $newdir )
- {
- if ( is_file( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME ) )
- {
- if ( $overwrite != 1 OR $newdir == 'default' )
- {
- continue;
- }
- }
-
- if ( @copy( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $first_dir . "/" . $FILE_NAME, DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME ) )
- {
- @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME, IPS_FILE_PERMISSION );
- }
- }
- }
-
- // Let's make sure this 'image' is available in all directories too
- if ( is_array( $emodirs ) and count( $emodirs ) )
- {
- foreach ( $emodirs as $newdir )
- {
- if ( is_file( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME ) )
- {
- continue;
- }
-
- if( @copy( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $first_dir . "/" .$FILE_NAME, DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME ) )
- {
- @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME, IPS_FILE_PERMISSION );
- }
- }
- }
-
- $uploaded++;
- }
- }
-
- if( !$uploaded )
- {
- $this->registry->output->global_message = $this->lang->words['no_emo_selected'];
- }
- else
- {
- $this->registry->output->global_message = $this->lang->words['emo_complete'];
- }
-
- $this->emoticonsOverview();
- }
-
- /**
- * Removes an emoticon set
- *
- * @return @e void
- */
- public function emoticonsSetRemove()
- {
- /* Check the ID */
- if ( ! $this->request['id'] )
- {
- $this->registry->output->global_message = $this->lang->words['emo_noset'];
- $this->emoticonsOverview();
- }
-
- /* Can't remove the default set */
- if( $this->request['id'] == 'default' )
- {
- $this->registry->output->global_message = $this->lang->words['emo_norename'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Remove the directory */
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . '/classFileManagement.php', 'classFileManagement' );
- $fileManagement = new $classToLoad();
- $fileManagement->removeDirectory( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['id'] );
-
- /* Remove the database entry */
- $this->DB->delete( 'emoticons', "emo_set='{$this->request['id']}'" );
-
- /* Rebuild cache */
- $this->emoticonsRebuildCache();
-
- /* Bounce */
- $this->registry->output->global_message = $this->lang->words['emo_folder_rem'];
- $this->emoticonsOverview();
- }
-
- /**
- * Add/Edit an emoticon folder name
- *
- * @param string Type (add or edit)
- * @return @e void
- */
- public function emoticonsSetAlter( $type='add' )
- {
- /* Get the name */
- $name = preg_replace( '/[^a-zA-Z0-9\-_]/', "", $this->request['emoset'] );
-
- /* Check th ename */
- if( $name == "" )
- {
- $this->registry->output->global_message = $this->lang->words['emo_a_to_z'];
- return $this->emoticonsOverview();
- }
-
- /* Check Safe Mode */
- if( SAFE_MODE_ON )
- {
- $this->registry->output->global_message = $this->lang->words['emo_safemode'];
- return $this->emoticonsOverview();
- }
-
- /* Check to see if the directory already exists */
- if( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name ) )
- {
- $this->registry->output->global_message = sprintf( $this->lang->words['emo_already'], $name );
- return $this->emoticonsOverview();
- }
-
- if( $type == 'add' )
- {
- /* Create the directory */
- if( @mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name, IPS_FOLDER_PERMISSION ) )
- {
- @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name, IPS_FOLDER_PERMISSION );
- @file_put_contents( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name . '/index.html', '' );
-
- /* Copy default emoticons */
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/default/' ) as $file )
- {
- if( ! $file->isDot() )
- {
- @copy( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/default/' . $file->getFilename(), DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name . '/' . $file->getFilename() );
- @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name . '/' . $file->getFilename(), IPS_FILE_PERMISSION );
- }
- }
- } catch ( Exception $e ) {}
-
- /* Query the default set */
- $this->DB->build( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='default'" ) );
- $outer = $this->DB->execute();
-
- /* Insert emoticons for the new set */
- while( $r = $this->DB->fetch($outer) )
- {
- $this->DB->insert( "emoticons", array( 'clickable' => $r['clickable'], 'typed' => $r['typed'], 'emo_set' => $name, 'image' => $r['image'] ) );
- }
-
- /* Bounce */
- $this->registry->output->global_message = $this->lang->words['emo_folder_new'];
- return $this->emoticonsOverview();
- }
- else
- {
- /* Couldn't create the directory, Bounce */
- $this->registry->output->global_message = $this->lang->words['emo_ftp'];
- return $this->emoticonsOverview();
- }
- }
- /* Edit Folder Name */
- else
- {
- /* Check the directory ID */
- if ( ! $this->request['id'] )
- {
- $this->registry->output->global_message = $this->lang->words['emo_miss_dir'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Can't rename the default directory */
- if( $this->request['id'] == 'default' )
- {
- $this->registry->output->global_message = $this->lang->words['emo_norename'];
- $this->emoticonsOverview();
- return;
- }
-
- /* Rename the directory */
- if ( @rename( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['id'], DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name ) )
- {
- /* Check to see if the rename worked */
- if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name ) )
- {
- /* Update all the emoticons */
- $this->DB->update( 'emoticons', array( 'emo_set' => $name ), "emo_set='{$this->request['id']}'" );
- }
-
- /* Rebuild the cache */
- $this->emoticonsRebuildCache();
-
- /* Update skins that are using this set */
- $rebuild_sets = array();
-
- /* Querh skin sets */
- $this->DB->build( array( 'select' => 'set_id', 'from' => 'skin_collections', 'where' => "set_emo_dir='{$this->request['id']}'" ) );
- $outer = $this->DB->execute();
-
- /* Loop thorugh and update the emoticon folder */
- while( $r = $this->DB->fetch($outer) )
- {
- $this->DB->update( 'skin_collections', array( 'set_emo_dir' => $name ), 'set_id=' . $r['set_id'] );
- $rebuild_sets[] = $r['set_id'];
- }
-
- /* Bounce */
- $this->registry->output->global_message = $this->lang->words['emo_folder_name'];
- return $this->emoticonsOverview();
- }
- else
- {
- /* Error and bounce */
- $this->registry->output->global_message = $this->lang->words['emo_wecantdoit'];
- return $this->emoticonsOverview();
- }
- }
- }
-
- /**
- * Process edit emoticons forum
- *
- * @return @e void
- */
- public function emoticonsEdit()
- {
- /* Check ID */
- if( $this->request['id'] == '' )
- {
- $this->registry->output->global_error = $this->lang->words['emo_nogid'];
- return $this->emoticonsOverview();
- }
-
- /* Loop through the request and pull out emoticons */
- foreach( $this->request as $key => $value )
- {
- /* Check to see if its an emoticon */
- if ( preg_match( '/^emo_id_(\d+)$/', $key, $match ) )
- {
- if ( $match[0] )
- {
- /* INI */
- $typed = '';
-
- /* Format type for default set */
- if( $this->request['id'] == 'default' )
- {
- $typed = str_replace( '"', "", $this->request[ 'emo_type_' . $match[1] ] );
- $typed = str_replace( '\', "", $typed );
- }
-
- /* Check clickable */
- $click = $this->request[ 'emo_click_' . $match[1] ];
-
- /* Update the emoticon */
- if ( $match[1] )
- {
- if( $typed )
- {
- /* Get the original name */
- $orig_typed = $this->DB->buildAndFetch( array( 'select' => 'typed', 'from' => 'emoticons', 'where' => 'id=' . intval( $match[1] ) ) );
-
- /* Update to new name */
- $this->DB->update( 'emoticons', array( 'clickable' => intval( $click ), 'typed' => $typed ), 'id=' . intval( $match[1] ) );
- $this->DB->update( 'emoticons', array( 'typed' => $typed ), "typed='" . $this->DB->addSlashes($orig_typed['typed']) . "'" );
- }
- else
- {
- /* Just update clickable */
- $this->DB->update( 'emoticons', array( 'clickable' => intval( $click ) ), 'id=' . intval( $match[1] ) );
- }
- }
- }
- }
- }
-
- /* Recache and bounce */
- $this->emoticonsRebuildCache();
-
- $this->registry->output->global_message = $this->lang->words['emo_updated'];
- $this->emoticonsManageDirectory();
- }
-
- /**
- * Manage emoticons
- *
- * @return @e void
- */
- public function emoticonsManageDirectory()
- {
- /* INI */
- $this->request['id'] = trim( $this->request['id'] );
-
- /* Get emoticons for this group */
- $emo_db = $this->_getEmoSet( $this->request['id'] );
- $emo_file = array();
-
- /* Get emoticons from the directory */
- $emo_file = array();
- $emo_rfile = $this->_emoticonGetGolderContents( $this->request['id'] );
-
- foreach( $emo_rfile as $ef )
- {
- $emo_file[ $ef ] = $ef;
- }
-
- /* Loop through the database emoticons */
- $poss_names = array();
- $db_rows = array();
-
- foreach( $emo_db as $image => $data )
- {
- /* Remove this from the file list, it's already added */
- unset( $emo_file[ $data['image'] ] );
-
- /* Add image to array */
- $data['image'] = $data['image'];
- /* Addd array to output */
- $db_rows[] = $data;
-
- /* Possible names filter */
- $poss_names[$data['typed']] = $data['typed'];
- }
-
- /* Check for unassigned images in the emoticon directory */
- $file_rows = array();
-
- if ( count( $emo_file ) && $this->request['id'] == 'default' )
- {
- /* Loop through the unassigned emoticons */
- foreach( $emo_file as $image )
- {
- /* INI */
- $_fdata = array();
-
- /* Suggest an emoticon name */
- $_fdata['poss_name'] = ':'.preg_replace( '/(.*)(\..+?)$/', "\\1", $image ).':';
-
- if ( ! empty($poss_names[ $_fdata['poss_name'] ]) )
- {
- $_fdata['poss_name'] = preg_replace( "/:$/", "2:", $_fdata['poss_name'] );
- }
-
- /* Add the image */
- $_fdata['image'] = $image;
-
- /* Add to output array */
- $file_rows[] = $_fdata;
- }
- }
-
- /* Output */
-
- $this->registry->output->extra_nav[] = array( '', $this->lang->words['emo_manage_set'].$this->request['id'] );
- $this->registry->output->html .= $this->html->emoticonsDirectoryManagement( $db_rows, $file_rows);
- }
-
- /**
- * Builds the emoticons overview screen
- *
- * @return @e void
- */
- public function emoticonsOverview()
- {
- /* Check for the emoticon directory */
- if ( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) )
- {
- $this->registry->output->showError( $this->lang->words['emo_nolocate'], 2111 );
-
- }
-
- /* Check the emoticon count */
- $this->DB->build( array( 'select' => 'id, count(id) as count, emo_set',
- 'from' => 'emoticons',
- 'group' => 'emo_set, id',
- 'order' => 'emo_set'
- ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $emo_db[ $r['emo_set'] ] = $r;
- }
-
- /* Get emoticon folders */
- $emodirs = array( 0 => '');
-
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $_emoticon )
- {
- if ( $_emoticon->isDir() AND ! $_emoticon->isDot() AND $_emoticon->getFilename() != '.svn' )
- {
- if ( is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $_emoticon ) )
- {
- if( $_emoticon->getFilename() == 'default' )
- {
- $emodirs[0] = $_emoticon->getFilename();
- }
- else
- {
- $emodirs[] = $_emoticon->getFilename();
- }
- }
- }
- }
- } catch ( Exception $e ) {}
-
- /* Loop through the emoticon directories */
- $rows = array();
- $i = 0;
- $total = count($emodirs);
-
- foreach( $emodirs as $dir )
- {
- $i++;
-
- $data = array();
-
- $files = $this->_emoticonGetGolderContents( $dir );
- $data['count'] = intval( count($files) );
-
- if( $dir == 'default' )
- {
- $data['line_image'] = '';
- $data['link_text'] = $this->lang->words['emo_manageemos'];
- }
- else
- {
- $data['link_text'] = $this->lang->words['emo_setclickable'];
-
- if( $i == $total )
- {
- $data['line_image'] = " ";
- }
- else
- {
- $data['line_image'] = " ";
- }
- }
-
- if ( is_writeable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $dir ) )
- {
- if( $dir == 'default' )
- {
- $checked_def = "checked='checked' disabled='disabled' ";
- }
- else
- {
- $checked_def = "";
- }
-
- $data['icon'] = 'writable.png';
- $data['title'] = $this->lang->words['emo_writeable'];
- $data['checkbox'] = " ";
- }
- else
- {
- $data['icon'] = 'unwritable.png';
- $data['title'] = $this->lang->words['emo_writeable_not'];
- $data['checkbox'] = "-";
- }
-
- $data['dir'] = $dir;
- $data['dir_count'] = intval( $emo_db[ $dir ]['count'] );
-
- $rows[] = $data;
- }
-
- $this->registry->output->html .= $this->html->emoticonsOverview( $rows );
- }
-
- /**
- * Rebuilds the emoticon cache
- *
- * @return @e void
- */
- public function emoticonsRebuildCache()
- {
- $cache = array();
-
- $this->DB->build( array( 'select' => 'typed,image,clickable,emo_set', 'from' => 'emoticons', 'order' => 'emo_position asc' ) );
- $c = $this->DB->execute();
-
- while ( $r = $this->DB->fetch( $c ) )
- {
- $cache[] = $r;
- }
-
- ipsRegistry::cache()->setCache( 'emoticons', $cache, array( 'array' => 1 ) );
- }
-
- /**
- * Fetch next position
- * @param string Emo set ID (default)
- *
- */
- protected function _getNextPosition( $set )
- {
- $res = $this->DB->buildAndFetch( array( 'select' => 'MAX(emo_position) as max',
- 'from' => 'emoticons',
- 'where' => "emo_set='" . $this->DB->addSlashes( $set ) . "'" ) );
-
- return intval( $res['max'] ) + 1;
- }
-
- /**
- * Fetch possible name
- * @param string Image name (smile.gif)
- * @param string Emo set ID (default)
- *
- */
- protected function _getNameFromImg( $img, $set )
- {
- $emos = $this->_getEmoSet( $set );
- $name = ':' . preg_replace( '/(.*)(\..+?)$/', "\\1", $img ).':';
-
- /* Ensure we're not doubling up */
- foreach( $emos as $im => $data )
- {
- if ( $name == $data['typed'] )
- {
- $name = preg_replace( "/:$/", "2:", $name );
- break;
- }
- }
-
- return $name;
- }
-
- /**
- * Get all emos in a set
- * @param string Emo set ID (default)
- */
- protected function _getEmoSet( $set )
- {
- if ( ! is_array( $this->setCache[ $set ] ) OR ! count( $this->setCache[ $set ] ) )
- {
- $this->setCache[ $set ] = array();
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'emoticons',
- 'where' => "emo_set='" . $this->DB->addSlashes( $set ) . "'",
- 'order' => 'emo_position ASC' ) );
- $this->DB->execute();
-
- /* Loop through the emoticons */
- while( $r = $this->DB->fetch() )
- {
- $this->setCache[ $set ][ $r['emo_position'] . '.' . rand(0, 10000 ) ] = $r;
- }
-
- ksort( $this->setCache[ $set ] );
- }
-
- return $this->setCache[ $set ];
- }
-
- /**
- * Custom sort operation
- *
- * @param string A
- * @param string B
- * @return integer
- */
- protected static function _thisUsort($a, $b)
- {
- if ( strlen($a['typed']) == strlen($b['typed']) )
- {
- return 0;
- }
-
- return ( strlen($a['typed']) > strlen($b['typed']) ) ? -1 : 1;
- }
-
- /**
- * Gets all the emoticons from the specified directory
- *
- * @param string $folder Emoticon folder to pull emoticons from
- * @return array
- */
- protected function _emoticonGetGolderContents( $folder='default' )
- {
- $files = array();
-
- /* Loop through the emoticon directory */
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $folder ) as $_emo )
- {
- if( $_emo->isFile() && ! $_emo->isDot() )
- {
- if ( preg_match( '/\.(?:gif|jpg|jpeg|png|swf)$/i', $_emo->getFilename() ) )
- {
- $files[] = $_emo->getFilename();
- }
- }
- }
- } catch ( Exception $e ) {}
-
- return $files;
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Emoticon Management
+ * Last Updated: $LastChangedDate: 2012-05-24 16:20:59 -0400 (Thu, 24 May 2012) $
+ *
+ *
+ * @author $Author: ips_terabyte $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 27th January 2004
+ * @version $Rev: 10792 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+class admin_core_posts_emoticons extends ipsCommand
+{
+ /**
+ * Allowed file types
+ *
+ * @var array
+ */
+ public $allowed_files = array( 'png', 'jpeg', 'jpg', 'gif' );
+
+ protected $setCache = array();
+
+ /**
+ * Main class entry point
+ *
+ * @param object ipsRegistry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Load Skin and Lang */
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_emoticons' );
+ $this->html->form_code = '&module=posts§ion=emoticons&';
+ $this->html->form_code_js = '&module=posts§ion=emoticons&';
+
+ $this->lang->loadLanguageFile( array( 'admin_posts' ) );
+
+ //-----------------------------------------
+ // What to do...
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ case 'emo_packsplash':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
+ $this->emoticonsPackSplash();
+ break;
+
+ case 'emo_packexport':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
+ $this->emoticonsPackExport();
+ break;
+
+ case 'emo_packimport':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
+ $this->emoticonsPackImport();
+ break;
+
+ case 'emo_manage':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
+ $this->emoticonsManageDirectory();
+ break;
+
+ case 'emo_doedit':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_edit' );
+ $this->emoticonsEdit();
+ break;
+
+ case 'emo_doadd':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_add' );
+ $this->emoticonsAdd();
+ break;
+
+ case 'emo_remove':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_delete' );
+ $this->emoticonsRemove();
+ break;
+
+ case 'emo_setadd':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_add' );
+ $this->emoticonsSetAlter( $type='add' );
+ break;
+
+ case 'emo_setedit':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_edit' );
+ $this->emoticonsSetAlter( $type='edit' );
+ break;
+
+ case 'emo_setremove':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_delete' );
+ $this->emoticonsSetRemove();
+ break;
+
+ case 'emo_upload':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_add' );
+ $this->emoticonsUpload();
+ break;
+
+ case 'emo':
+ case 'overview':
+ default:
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'emoticons_manage' );
+ $this->emoticonsOverview();
+ break;
+ case 'reorder':
+ $this->_reorder();
+ break;
+ }
+
+ /* Output */
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Reorder hooks
+ *
+ * @return @e void [Outputs to screen]
+ */
+ protected function _reorder()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
+ $ajax = new $classToLoad();
+ $set = trim( $this->request['id'] );
+
+ //-----------------------------------------
+ // Save new position
+ //-----------------------------------------
+
+ $position = 1;
+
+ if ( is_array( $this->request['emoticons'] ) AND count( $this->request['emoticons'] ) )
+ {
+ /* Reset all emoticons to 0 temporarily */
+ $this->DB->update( 'emoticons', array( 'emo_position' => 0 ), 'emo_set=\'' . $this->DB->addSlashes( $set ) . "'" );
+
+ foreach( $this->request['emoticons'] as $this_id )
+ {
+ $this->DB->update( 'emoticons', array( 'emo_position' => $position ), 'id=' . intval($this_id) );
+
+ $position++;
+ }
+ }
+
+ $this->emoticonsRebuildCache();
+
+ $ajax->returnString( 'OK' );
+ }
+
+ /**
+ * Import an emoticon pack
+ *
+ * @return @e void
+ */
+ public function emoticonsPackImport()
+ {
+ /* Make sure all emoticon directories are writable */
+ $this->DB->build( array( 'select' => $this->DB->buildDistinct('emo_set') . ' as folder', 'from' => 'emoticons' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $_folders[] = $r['folder'];
+ }
+
+ if( count($_folders) )
+ {
+ foreach( $_folders as $folder )
+ {
+ if( !IPSLib::isWritable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $folder ) )
+ {
+ $this->registry->output->global_error = sprintf( $this->lang->words['emodir_not_write'], PUBLIC_DIRECTORY . '/style_emoticons/' . $folder );
+ return $this->emoticonsPackSplash();
+ }
+ }
+ }
+
+ /* Get the xml file */
+ try
+ {
+ $content = $this->registry->adminFunctions->importXml( 'ipb_emoticons.xml' );
+ }
+ catch ( Exception $e )
+ {
+ $this->registry->output->showError( $e->getMessage() );
+ }
+
+ /* Check for content */
+ if ( ! $content )
+ {
+ $this->registry->output->global_error = $this->lang->words['emo_fail'];
+ return $this->emoticonsPackSplash();
+ }
+
+ /* Setup XML */
+ require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+
+ require_once( IPS_KERNEL_PATH.'classXMLArchive.php' );/*noLibHook*/
+ $xmlarchive = new classXMLArchive();
+
+ /* Read the archive */
+ $xmlarchive->readXML( $content );
+
+ /* Get the data file */
+ $emoticons = array();
+ $emoticon_data = array();
+
+ foreach( $xmlarchive->asArray() as $k => $f )
+ {
+ if ( $k == 'emoticon_data.xml' )
+ {
+ $emoticon_data = $f;
+ }
+ else
+ {
+ $emoticons[ $f['filename'] ] = $f['content'];
+ }
+ }
+
+ /* Parse the XML Document */
+ $xml->loadXML( $emoticon_data['content'] );
+
+ /* Make sure we have a destination for these emoicons */
+ if ( ! $this->request['emo_set'] and ! $this->request['new_emo_set'] )
+ {
+ $this->registry->output->global_error = $this->lang->words['emo_specify'];
+ }
+
+ /* Current emoticon set directory */
+ $emo_set_dir = trim( $this->request['emo_set'] );
+
+ /* New emoticon set directory */
+ $this->request['new_emo_set'] = preg_replace( '/[^a-zA-Z0-9\-_]/', "", $this->request['new_emo_set'] );
+
+ /* Create the new set */
+ if ( $this->request['new_emo_set'] )
+ {
+ $emo_set_dir = trim( $this->request['new_emo_set'] );
+
+ /* Check to see if the directory already exists */
+ if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir ) )
+ {
+ $this->registry->output->global_error = sprintf( $this->lang->words['emo_already'], $emo_set_dir );
+ return $this->emoticonsPackSplash();
+ }
+
+ /* Create the directory */
+ if ( @mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir, IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir, IPS_FOLDER_PERMISSION );
+ @file_put_contents( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir . '/index.html', '' );
+ }
+ else
+ {
+ $this->registry->output->global_error = $this->lang->words['emo_ftp'];
+ return $this->emoticonsPackSplash();
+ }
+ }
+
+ /* Get a list of current emoticons, if we are not overwriting */
+ $emo_image = array();
+ $emo_typed = array();
+
+ if ( $this->request['overwrite'] != 1 )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='" . $emo_set_dir . "'" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $emo_image[ $r['image'] ] = 1;
+ $emo_typed[ $r['typed'] ] = 1;
+ }
+ }
+
+ /* Loop through the emoticons in the xml document */
+ foreach( $xml->fetchElements('emoticon') as $emoticon )
+ {
+ $entry = $xml->fetchElementsFromRecord( $emoticon );
+
+ /* Emoticon Data */
+ $image = $entry['image'];
+ $typed = $entry['typed'];
+ $click = $entry['clickable'];
+
+ /* Skip if we're not overwriting */
+ if ( $emo_image[ $image ] or $emo_typed[ $typed ] )
+ {
+ continue;
+ }
+
+ /* Get the extension */
+ $file_extension = preg_replace( '#^.*\.(.+?)$#si', "\\1", mb_strtolower( $image ) );
+
+ /* Make sure it's allowed */
+ if ( ! in_array( $file_extension, $this->allowed_files ) )
+ {
+ continue;
+ }
+
+ /* Remove any existing emoticon */
+ @unlink( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $emo_set_dir . '/' . $image );
+
+ $this->DB->delete( 'emoticons', "typed='$typed' and image='$image' and emo_set='$emo_set_dir'" );
+
+ /* Create the image in the file system */
+ if( $FH = fopen( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' .$emo_set_dir . '/' . $image, 'wb' ) )
+ {
+ if ( fwrite( $FH, $emoticons[ $image ] ) )
+ {
+ fclose( $FH );
+
+ /* Insert the emoticon record */
+ $this->DB->insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'clickable' => $click, 'emo_set' => $emo_set_dir ) );
+ }
+ }
+
+ /* Add the emoticon to all the other directories */
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' ) as $file )
+ {
+ if( ! $file->isDot() && $file->isDir() )
+ {
+ if ( substr( $file->getFilename(), 0, 1 ) == '.' )
+ {
+ continue;
+ }
+
+ if ( ! is_file( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $file->getFilename() . '/' . $image ) )
+ {
+ $this->DB->delete( 'emoticons', "typed='$typed' and image='$image' and emo_set='{$file->getFilename()}'" );
+
+ if ( $FH = @fopen( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $file->getFilename() . '/' . $image, 'wb' ) )
+ {
+ if ( fwrite( $FH, $emoticons[ $image ] ) )
+ {
+ fclose( $FH );
+
+ $this->DB->insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'clickable' => $click, 'emo_set' => $file->getFilename() ) );
+ }
+ }
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+ }
+
+ /* Recache and bounce */
+ $this->emoticonsRebuildCache();
+
+ $this->registry->output->global_message = $this->lang->words['emo_xml_good'];
+ $this->emoticonsOverview();
+
+ }
+
+ /**
+ * Export the specified emoticon directory
+ *
+ * @return @e void
+ */
+ public function emoticonsPackExport()
+ {
+ /* Setup XML */
+ require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+
+ require_once( IPS_KERNEL_PATH . 'classXMLArchive.php' );/*noLibHook*/
+ $xmlarchive = new classXMLArchive();
+
+ /* Check the emoticon set */
+ if ( ! $this->request['emo_set'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_specify_exS'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Get emoticons from the database */
+ $emo_db = array();
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='{$this->request['emo_set']}'" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $emo_db[ $r['image'] ] = $r;
+ }
+
+ /* Get Emoticon Folders */
+ $emodirs = array();
+ $emodd = array();
+ $files_to_add = array();
+
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['emo_set'] ) as $file )
+ {
+ if( ! $file->isDot() )
+ {
+ if ( $emo_db[ $file->getFilename() ] != "" )
+ {
+ $files_to_add[] = DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['emo_set'] . '/' . $file->getFilename();
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ /* Add each file to the xml archive */
+ foreach( $files_to_add as $f )
+ {
+ $xmlarchive->add( $f );
+ }
+
+ $xml->newXMLDocument();
+ $xml->addElement( 'emoticonexport' );
+ $xml->addElement( 'emogroup', 'emoticonexport' );
+
+ foreach( $emo_db as $r )
+ {
+ $content = array();
+
+ $content['typed'] = $r['typed'];
+ $content['image'] = $r['image'];
+ $content['clickable'] = $r['clickable'];
+
+ $xml->addElementAsRecord( 'emogroup', 'emoticon', $content );
+ }
+
+ /* Create the XML Document */
+ $xmlData = $xml->fetchDocument();
+
+ /* Add the xml document to the archive */
+ $xmlarchive->add( $xmlData, 'emoticon_data.xml' );
+
+ /* Send the archive to the browser */
+ $imagearchive = $xmlarchive->getArchiveContents();
+ $this->registry->output->showDownload( $imagearchive, 'ipb_emoticons.xml' );
+ }
+
+ /**
+ * Builds the emoticon import/export pack splash screen
+ *
+ * @return @e void
+ */
+ public function emoticonsPackSplash()
+ {
+ /* Check for the emoticon directory */
+ if( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) )
+ {
+ $this->registry->output->showError( $this->lang->words['emo_nolocate'], 2110 );
+
+ }
+
+ /* Count the number of current emoticons */
+ $this->DB->build( array( 'select' => 'id, count(id) as count, emo_set',
+ 'from' => 'emoticons',
+ 'group' => 'id, emo_set',
+ 'order' => 'emo_set'
+ ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $emo_db[ $r['emo_set'] ] = $r;
+ }
+
+ /* Get the emoticon folders */
+ $emodirs = array();
+ $emodd = array();
+
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $file )
+ {
+ if( $file->isDir() && ! $file->isDot() )
+ {
+ $emodirs[] = $file->getFilename();
+ $emodd[] = array( $file->getFilename(), $file->getFilename() );
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ /* Build Form Elements */
+ $form = array();
+ $form['emo_set'] = $this->registry->output->formDropdown( 'emo_set', $emodd );
+ $form['new_emo_set'] = $this->registry->output->formInput( 'new_emo_set' );
+ $form['overwrite'] = $this->registry->output->formYesNo( 'overwrite' );
+
+ /* Output */
+ $this->registry->output->html .= $this->html->emoticonsPackSplash( $form );
+ }
+
+ /**
+ * Remove the specified emoticon
+ *
+ * @return @e void
+ */
+ public function emoticonsRemove()
+ {
+ /* Check the ID */
+ if( $this->request['id'] == "" )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_nogid'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Can only remove the default set */
+ if( $this->request['id'] != "default" )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_onlydothis'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Check for the emoticon ID */
+ $this->request['eid'] = intval( $this->request['eid'] );
+
+ if( ! $this->request['eid'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_noid'];
+ $this->emoticonsManageDirectory();
+ return;
+ }
+
+ /* Get the emoticon info */
+ $emo_info = $this->DB->buildAndFetch( array( 'select' => 'typed', 'from' => 'emoticons', 'where' => "id=" . $this->request['eid']) );
+
+ /* Delete the emoticon */
+ $this->DB->delete( 'emoticons', "typed='{$emo_info['typed']}'" );
+
+ /* Rebuild the cache and bounce */
+ $this->emoticonsRebuildCache();
+
+ $this->registry->output->global_message = $this->lang->words['emo_removed'];
+ $this->emoticonsManageDirectory();
+ }
+
+ /**
+ * Add emoticons to the default directory
+ *
+ * @return @e void
+ */
+ public function emoticonsAdd()
+ {
+ $image = str_replace( '---', '.', trim( $this->request['emo_image'] ) );
+ $set = trim( $this->request['id'] );
+ $typed = $this->_getNameFromImg( $image, $set );
+ $position = $this->_getNextPosition( $set );
+
+ /* Check the id */
+ if ( empty( $set ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_nogid'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Can only upload to the default directory */
+ if( $this->request['id'] != "default" )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_onlydothis'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ if ( ! $image OR ! $typed )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_nogid'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Insert the emo record */
+ // as per http://community.invisionpower.com/tracker/issue-34269-emoticon-imports - add to all records rather than
+ // just the default. In future version, will hopefully rewrite emoticon management and make this process less mental
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $_emoticon )
+ {
+ if ( $_emoticon->isDir() AND ! $_emoticon->isDot() AND $_emoticon->getFilename() != '.svn' )
+ {
+ if ( is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $_emoticon ) )
+ {
+ $this->DB->insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'emo_set' => $_emoticon->getFilename(), 'emo_position' => $position ) );
+ }
+ }
+ }
+
+ /* Emoticon list */
+ $emodirs = array( 0 => '');
+
+ /* Loop through all the emoticons */
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $file )
+ {
+ if ( ! $file->isDot() && $file->isDir() && strpos( $file->getFilename(), '.' ) != 0 )
+ {
+ if( $file->getFilename() == 'default' )
+ {
+ $emodirs[0] = $file->getFilename();
+ }
+ else
+ {
+ $emodirs[] = $file->getFilename();
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ /* Add this emoticon to the other sets */
+ foreach( $emodirs as $directory )
+ {
+ if ( $directory == $set )
+ {
+ continue;
+ }
+
+ if ( empty( $directory ) )
+ {
+ continue;
+ }
+
+ $this->DB->insert( 'emoticons', array( 'typed' => $typed, 'image' => $image, 'emo_set' => $directory, 'emo_position' => $position ) );
+ }
+
+ /* Rebuild the cache and bounce */
+ $this->emoticonsRebuildCache();
+
+ $this->registry->output->global_message = $this->lang->words['emo_updated'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->html->form_code . '&do=emo_manage&id=' . $this->request['id'] );
+ }
+
+ /**
+ * Handles the upload emoticon form
+ *
+ * @return @e void
+ */
+ public function emoticonsUpload()
+ {
+ /* INI */
+ $overwrite = 1;
+ $uploaded = 0;
+
+ /* Check the request for uploads */
+ $directories = array();
+ $first_dir = '';
+
+ foreach( $this->request as $key => $value )
+ {
+ if( preg_match( "/^dir_(.*)$/", $key, $match ) )
+ {
+ if( $this->request[ $match[0] ] == 1 )
+ {
+ $directories[] = $match[1];
+ }
+ }
+ }
+
+ /* Can't upload to default */
+ if ( ! count( $directories ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_pickanother'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Remove default from the directories list */
+ if ( ! in_array( 'default', $directories ) )
+ {
+ array_push( $directories, 'default' );
+ }
+
+ /* Get the first directory */
+ $first_dir = array_shift( $directories );
+
+ /* Loop through the dirs */
+ $emodirs = array( 0 => '' );
+
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $file )
+ {
+ if( ! $file->isDot() && $file->isDir() )
+ {
+ /* Add to emoticon list */
+ if( $file->getFilename() == 'default' )
+ {
+ $emodirs[0] = $file->getFilename();
+ }
+ else
+ {
+ $emodirs[] = $file->getFilename();
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ /* Loop through each form upload field */
+ foreach( array( 1,2,3,4 ) as $i )
+ {
+ /* Upload Data */
+ $field = 'upload_'.$i;
+ $FILE_NAME = $_FILES[$field]['name'];
+ $FILE_SIZE = $_FILES[$field]['size'];
+ $FILE_TYPE = $_FILES[$field]['type'];
+
+ //-----------------------------------------
+ // Naughty Opera adds the filename on the end of the
+ // mime type - we don't want this.
+ //-----------------------------------------
+
+ $FILE_TYPE = preg_replace( "/^(.+?);.*$/", "\\1", $FILE_TYPE );
+
+ //-----------------------------------------
+ // Naughty Mozilla likes to use "none" to indicate an empty upload field.
+ // I love universal languages that aren't universal.
+ //-----------------------------------------
+
+ if ( $_FILES[$field]['name'] == "" or ! $_FILES[$field]['name'] or ($_FILES[$field]['name'] == "none") )
+ {
+ continue;
+ }
+
+ //-----------------------------------------
+ // Make sure it's not a NAUGHTY file
+ //-----------------------------------------
+
+ $file_extension = preg_replace( '#^.*\.(.+?)$#si', "\\1", mb_strtolower( $_FILES[ $field ]['name'] ) );
+
+ if ( ! in_array( $file_extension, $this->allowed_files ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_mimes']; // The screams of angst from Emo Mimes are silent...
+ $this->emoticonsOverview();
+ return;
+ }
+
+ //-----------------------------------------
+ // Copy the upload to the uploads directory
+ //-----------------------------------------
+
+ if ( ! @move_uploaded_file( $_FILES[ $field ]['tmp_name'], DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $first_dir . "/" . $FILE_NAME) )
+ {
+ $this->registry->output->global_message = "The upload failed, sorry!";
+ $this->emoticonsOverview();
+ return;
+ }
+ else
+ {
+ @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $first_dir . "/" . $FILE_NAME, IPS_FILE_PERMISSION );
+
+ //-----------------------------------------
+ // Copy to other folders
+ //-----------------------------------------
+
+ if ( is_array( $directories ) and count( $directories ) )
+ {
+ foreach ( $directories as $newdir )
+ {
+ if ( is_file( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME ) )
+ {
+ if ( $overwrite != 1 OR $newdir == 'default' )
+ {
+ continue;
+ }
+ }
+
+ if ( @copy( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $first_dir . "/" . $FILE_NAME, DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME ) )
+ {
+ @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME, IPS_FILE_PERMISSION );
+ }
+ }
+ }
+
+ // Let's make sure this 'image' is available in all directories too
+ if ( is_array( $emodirs ) and count( $emodirs ) )
+ {
+ foreach ( $emodirs as $newdir )
+ {
+ if ( is_file( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME ) )
+ {
+ continue;
+ }
+
+ if( @copy( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $first_dir . "/" .$FILE_NAME, DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME ) )
+ {
+ @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $newdir . "/" . $FILE_NAME, IPS_FILE_PERMISSION );
+ }
+ }
+ }
+
+ $uploaded++;
+ }
+ }
+
+ if( !$uploaded )
+ {
+ $this->registry->output->global_message = $this->lang->words['no_emo_selected'];
+ }
+ else
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_complete'];
+ }
+
+ $this->emoticonsOverview();
+ }
+
+ /**
+ * Removes an emoticon set
+ *
+ * @return @e void
+ */
+ public function emoticonsSetRemove()
+ {
+ /* Check the ID */
+ if ( ! $this->request['id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_noset'];
+ $this->emoticonsOverview();
+ }
+
+ /* Can't remove the default set */
+ if( $this->request['id'] == 'default' )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_norename'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Remove the directory */
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . '/classFileManagement.php', 'classFileManagement' );
+ $fileManagement = new $classToLoad();
+ $fileManagement->removeDirectory( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['id'] );
+
+ /* Remove the database entry */
+ $this->DB->delete( 'emoticons', "emo_set='{$this->request['id']}'" );
+
+ /* Rebuild cache */
+ $this->emoticonsRebuildCache();
+
+ /* Bounce */
+ $this->registry->output->global_message = $this->lang->words['emo_folder_rem'];
+ $this->emoticonsOverview();
+ }
+
+ /**
+ * Add/Edit an emoticon folder name
+ *
+ * @param string Type (add or edit)
+ * @return @e void
+ */
+ public function emoticonsSetAlter( $type='add' )
+ {
+ /* Get the name */
+ $name = preg_replace( '/[^a-zA-Z0-9\-_]/', "", $this->request['emoset'] );
+
+ /* Check th ename */
+ if( $name == "" )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_a_to_z'];
+ return $this->emoticonsOverview();
+ }
+
+ /* Check Safe Mode */
+ if( SAFE_MODE_ON )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_safemode'];
+ return $this->emoticonsOverview();
+ }
+
+ /* Check to see if the directory already exists */
+ if( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name ) )
+ {
+ $this->registry->output->global_message = sprintf( $this->lang->words['emo_already'], $name );
+ return $this->emoticonsOverview();
+ }
+
+ if( $type == 'add' )
+ {
+ /* Create the directory */
+ if( @mkdir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name, IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name, IPS_FOLDER_PERMISSION );
+ @file_put_contents( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name . '/index.html', '' );
+
+ /* Copy default emoticons */
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/default/' ) as $file )
+ {
+ if( ! $file->isDot() )
+ {
+ @copy( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/default/' . $file->getFilename(), DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name . '/' . $file->getFilename() );
+ @chmod( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name . '/' . $file->getFilename(), IPS_FILE_PERMISSION );
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ /* Query the default set */
+ $this->DB->build( array( 'select' => '*', 'from' => 'emoticons', 'where' => "emo_set='default'" ) );
+ $outer = $this->DB->execute();
+
+ /* Insert emoticons for the new set */
+ while( $r = $this->DB->fetch($outer) )
+ {
+ $this->DB->insert( "emoticons", array( 'clickable' => $r['clickable'], 'typed' => $r['typed'], 'emo_set' => $name, 'image' => $r['image'] ) );
+ }
+
+ /* Bounce */
+ $this->registry->output->global_message = $this->lang->words['emo_folder_new'];
+ return $this->emoticonsOverview();
+ }
+ else
+ {
+ /* Couldn't create the directory, Bounce */
+ $this->registry->output->global_message = $this->lang->words['emo_ftp'];
+ return $this->emoticonsOverview();
+ }
+ }
+ /* Edit Folder Name */
+ else
+ {
+ /* Check the directory ID */
+ if ( ! $this->request['id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_miss_dir'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Can't rename the default directory */
+ if( $this->request['id'] == 'default' )
+ {
+ $this->registry->output->global_message = $this->lang->words['emo_norename'];
+ $this->emoticonsOverview();
+ return;
+ }
+
+ /* Rename the directory */
+ if ( @rename( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $this->request['id'], DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name ) )
+ {
+ /* Check to see if the rename worked */
+ if ( file_exists( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $name ) )
+ {
+ /* Update all the emoticons */
+ $this->DB->update( 'emoticons', array( 'emo_set' => $name ), "emo_set='{$this->request['id']}'" );
+ }
+
+ /* Rebuild the cache */
+ $this->emoticonsRebuildCache();
+
+ /* Update skins that are using this set */
+ $rebuild_sets = array();
+
+ /* Querh skin sets */
+ $this->DB->build( array( 'select' => 'set_id', 'from' => 'skin_collections', 'where' => "set_emo_dir='{$this->request['id']}'" ) );
+ $outer = $this->DB->execute();
+
+ /* Loop thorugh and update the emoticon folder */
+ while( $r = $this->DB->fetch($outer) )
+ {
+ $this->DB->update( 'skin_collections', array( 'set_emo_dir' => $name ), 'set_id=' . $r['set_id'] );
+ $rebuild_sets[] = $r['set_id'];
+ }
+
+ /* Bounce */
+ $this->registry->output->global_message = $this->lang->words['emo_folder_name'];
+ return $this->emoticonsOverview();
+ }
+ else
+ {
+ /* Error and bounce */
+ $this->registry->output->global_message = $this->lang->words['emo_wecantdoit'];
+ return $this->emoticonsOverview();
+ }
+ }
+ }
+
+ /**
+ * Process edit emoticons forum
+ *
+ * @return @e void
+ */
+ public function emoticonsEdit()
+ {
+ /* Check ID */
+ if( $this->request['id'] == '' )
+ {
+ $this->registry->output->global_error = $this->lang->words['emo_nogid'];
+ return $this->emoticonsOverview();
+ }
+
+ /* Loop through the request and pull out emoticons */
+ foreach( $this->request as $key => $value )
+ {
+ /* Check to see if its an emoticon */
+ if ( preg_match( '/^emo_id_(\d+)$/', $key, $match ) )
+ {
+ if ( $match[0] )
+ {
+ /* INI */
+ $typed = '';
+
+ /* Format type for default set */
+ if( $this->request['id'] == 'default' )
+ {
+ $typed = str_replace( '"', "", $this->request[ 'emo_type_' . $match[1] ] );
+ $typed = str_replace( '\', "", $typed );
+ }
+
+ /* Check clickable */
+ $click = $this->request[ 'emo_click_' . $match[1] ];
+
+ /* Update the emoticon */
+ if ( $match[1] )
+ {
+ if( $typed )
+ {
+ /* Get the original name */
+ $orig_typed = $this->DB->buildAndFetch( array( 'select' => 'typed', 'from' => 'emoticons', 'where' => 'id=' . intval( $match[1] ) ) );
+
+ /* Update to new name */
+ $this->DB->update( 'emoticons', array( 'clickable' => intval( $click ), 'typed' => $typed ), 'id=' . intval( $match[1] ) );
+ $this->DB->update( 'emoticons', array( 'typed' => $typed ), "typed='" . $this->DB->addSlashes($orig_typed['typed']) . "'" );
+ }
+ else
+ {
+ /* Just update clickable */
+ $this->DB->update( 'emoticons', array( 'clickable' => intval( $click ) ), 'id=' . intval( $match[1] ) );
+ }
+ }
+ }
+ }
+ }
+
+ /* Recache and bounce */
+ $this->emoticonsRebuildCache();
+
+ $this->registry->output->global_message = $this->lang->words['emo_updated'];
+ $this->emoticonsManageDirectory();
+ }
+
+ /**
+ * Manage emoticons
+ *
+ * @return @e void
+ */
+ public function emoticonsManageDirectory()
+ {
+ /* INI */
+ $this->request['id'] = trim( $this->request['id'] );
+
+ /* Get emoticons for this group */
+ $emo_db = $this->_getEmoSet( $this->request['id'] );
+ $emo_file = array();
+
+ /* Get emoticons from the directory */
+ $emo_file = array();
+ $emo_rfile = $this->_emoticonGetGolderContents( $this->request['id'] );
+
+ foreach( $emo_rfile as $ef )
+ {
+ $emo_file[ $ef ] = $ef;
+ }
+
+ /* Loop through the database emoticons */
+ $poss_names = array();
+ $db_rows = array();
+
+ foreach( $emo_db as $image => $data )
+ {
+ /* Remove this from the file list, it's already added */
+ unset( $emo_file[ $data['image'] ] );
+
+ /* Add image to array */
+ $data['image'] = $data['image'];
+ /* Addd array to output */
+ $db_rows[] = $data;
+
+ /* Possible names filter */
+ $poss_names[$data['typed']] = $data['typed'];
+ }
+
+ /* Check for unassigned images in the emoticon directory */
+ $file_rows = array();
+
+ if ( count( $emo_file ) && $this->request['id'] == 'default' )
+ {
+ /* Loop through the unassigned emoticons */
+ foreach( $emo_file as $image )
+ {
+ /* INI */
+ $_fdata = array();
+
+ /* Suggest an emoticon name */
+ $_fdata['poss_name'] = ':'.preg_replace( '/(.*)(\..+?)$/', "\\1", $image ).':';
+
+ if ( ! empty($poss_names[ $_fdata['poss_name'] ]) )
+ {
+ $_fdata['poss_name'] = preg_replace( "/:$/", "2:", $_fdata['poss_name'] );
+ }
+
+ /* Add the image */
+ $_fdata['image'] = $image;
+
+ /* Add to output array */
+ $file_rows[] = $_fdata;
+ }
+ }
+
+ /* Output */
+
+ $this->registry->output->extra_nav[] = array( '', $this->lang->words['emo_manage_set'].$this->request['id'] );
+ $this->registry->output->html .= $this->html->emoticonsDirectoryManagement( $db_rows, $file_rows);
+ }
+
+ /**
+ * Builds the emoticons overview screen
+ *
+ * @return @e void
+ */
+ public function emoticonsOverview()
+ {
+ /* Check for the emoticon directory */
+ if ( ! is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) )
+ {
+ $this->registry->output->showError( $this->lang->words['emo_nolocate'], 2111 );
+
+ }
+
+ /* Check the emoticon count */
+ $this->DB->build( array( 'select' => 'id, count(id) as count, emo_set',
+ 'from' => 'emoticons',
+ 'group' => 'emo_set, id',
+ 'order' => 'emo_set'
+ ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $emo_db[ $r['emo_set'] ] = $r;
+ }
+
+ /* Get emoticon folders */
+ $emodirs = array( 0 => '');
+
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons' ) as $_emoticon )
+ {
+ if ( $_emoticon->isDir() AND ! $_emoticon->isDot() AND $_emoticon->getFilename() != '.svn' )
+ {
+ if ( is_dir( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $_emoticon ) )
+ {
+ if( $_emoticon->getFilename() == 'default' )
+ {
+ $emodirs[0] = $_emoticon->getFilename();
+ }
+ else
+ {
+ $emodirs[] = $_emoticon->getFilename();
+ }
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ /* Loop through the emoticon directories */
+ $rows = array();
+ $i = 0;
+ $total = count($emodirs);
+
+ foreach( $emodirs as $dir )
+ {
+ $i++;
+
+ $data = array();
+
+ $files = $this->_emoticonGetGolderContents( $dir );
+ $data['count'] = intval( count($files) );
+
+ if( $dir == 'default' )
+ {
+ $data['line_image'] = '';
+ $data['link_text'] = $this->lang->words['emo_manageemos'];
+ }
+ else
+ {
+ $data['link_text'] = $this->lang->words['emo_setclickable'];
+
+ if( $i == $total )
+ {
+ $data['line_image'] = " ";
+ }
+ else
+ {
+ $data['line_image'] = " ";
+ }
+ }
+
+ if ( is_writeable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $dir ) )
+ {
+ if( $dir == 'default' )
+ {
+ $checked_def = "checked='checked' disabled='disabled' ";
+ }
+ else
+ {
+ $checked_def = "";
+ }
+
+ $data['icon'] = 'writable.png';
+ $data['title'] = $this->lang->words['emo_writeable'];
+ $data['checkbox'] = " ";
+ }
+ else
+ {
+ $data['icon'] = 'unwritable.png';
+ $data['title'] = $this->lang->words['emo_writeable_not'];
+ $data['checkbox'] = "-";
+ }
+
+ $data['dir'] = $dir;
+ $data['dir_count'] = intval( $emo_db[ $dir ]['count'] );
+
+ $rows[] = $data;
+ }
+
+ $this->registry->output->html .= $this->html->emoticonsOverview( $rows );
+ }
+
+ /**
+ * Rebuilds the emoticon cache
+ *
+ * @return @e void
+ */
+ public function emoticonsRebuildCache()
+ {
+ $cache = array();
+
+ $this->DB->build( array( 'select' => 'typed,image,clickable,emo_set', 'from' => 'emoticons', 'order' => 'emo_position asc' ) );
+ $c = $this->DB->execute();
+
+ while ( $r = $this->DB->fetch( $c ) )
+ {
+ $cache[] = $r;
+ }
+
+ ipsRegistry::cache()->setCache( 'emoticons', $cache, array( 'array' => 1 ) );
+ }
+
+ /**
+ * Fetch next position
+ * @param string Emo set ID (default)
+ *
+ */
+ protected function _getNextPosition( $set )
+ {
+ $res = $this->DB->buildAndFetch( array( 'select' => 'MAX(emo_position) as max',
+ 'from' => 'emoticons',
+ 'where' => "emo_set='" . $this->DB->addSlashes( $set ) . "'" ) );
+
+ return intval( $res['max'] ) + 1;
+ }
+
+ /**
+ * Fetch possible name
+ * @param string Image name (smile.gif)
+ * @param string Emo set ID (default)
+ *
+ */
+ protected function _getNameFromImg( $img, $set )
+ {
+ $emos = $this->_getEmoSet( $set );
+ $name = ':' . preg_replace( '/(.*)(\..+?)$/', "\\1", $img ).':';
+
+ /* Ensure we're not doubling up */
+ foreach( $emos as $im => $data )
+ {
+ if ( $name == $data['typed'] )
+ {
+ $name = preg_replace( "/:$/", "2:", $name );
+ break;
+ }
+ }
+
+ return $name;
+ }
+
+ /**
+ * Get all emos in a set
+ * @param string Emo set ID (default)
+ */
+ protected function _getEmoSet( $set )
+ {
+ if ( ! is_array( $this->setCache[ $set ] ) OR ! count( $this->setCache[ $set ] ) )
+ {
+ $this->setCache[ $set ] = array();
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'emoticons',
+ 'where' => "emo_set='" . $this->DB->addSlashes( $set ) . "'",
+ 'order' => 'emo_position ASC' ) );
+ $this->DB->execute();
+
+ /* Loop through the emoticons */
+ while( $r = $this->DB->fetch() )
+ {
+ $this->setCache[ $set ][ $r['emo_position'] . '.' . rand(0, 10000 ) ] = $r;
+ }
+
+ ksort( $this->setCache[ $set ] );
+ }
+
+ return $this->setCache[ $set ];
+ }
+
+ /**
+ * Custom sort operation
+ *
+ * @param string A
+ * @param string B
+ * @return integer
+ */
+ protected static function _thisUsort($a, $b)
+ {
+ if ( strlen($a['typed']) == strlen($b['typed']) )
+ {
+ return 0;
+ }
+
+ return ( strlen($a['typed']) > strlen($b['typed']) ) ? -1 : 1;
+ }
+
+ /**
+ * Gets all the emoticons from the specified directory
+ *
+ * @param string $folder Emoticon folder to pull emoticons from
+ * @return array
+ */
+ protected function _emoticonGetGolderContents( $folder='default' )
+ {
+ $files = array();
+
+ /* Loop through the emoticon directory */
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . '/style_emoticons/' . $folder ) as $_emo )
+ {
+ if( $_emo->isFile() && ! $_emo->isDot() )
+ {
+ if ( preg_match( '/\.(?:gif|jpg|jpeg|png|swf)$/i', $_emo->getFilename() ) )
+ {
+ $files[] = $_emo->getFilename();
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ return $files;
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/posts/media.php b/upload/admin/applications/core/modules_admin/posts/media.php
index e3583145..f1dfc894 100644
--- a/upload/admin/applications/core/modules_admin/posts/media.php
+++ b/upload/admin/applications/core/modules_admin/posts/media.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* BBCode Media Tag Management
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-22 13:10:11 -0400 (Tue, 22 May 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 10783 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/posts/xml/menu.xml b/upload/admin/applications/core/modules_admin/posts/xml/menu.xml
index c71e6b43..8be530ab 100644
--- a/upload/admin/applications/core/modules_admin/posts/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/posts/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Emoticon Management
+ Управление Смайликами
- Emoticon Management
+ Управление Смайликами
emoticons
emoticons
do=overview
@@ -15,10 +15,10 @@
-
-
BBCode Management
+ Управление BB-кодами
- BBCode Management
+ Управление BB-кодами
bbcode
bbcode
do=overview
@@ -28,10 +28,10 @@
-
-
Manage Media Tag
+ Управление Media-тагами
- Manage Media Tag
+ Управление Media-тагами
mediatag
media
do=overview
@@ -41,10 +41,10 @@
-
-
Bad Word Filters
+ Фильтр Нецензурных Слов
- Bad Word Filters
+ Фильтр Нецензурных Слов
badwords
badwords
do=overview
@@ -53,5 +53,18 @@
+ -
+
Расшифровка Сокращений
+
+
+ Расшифровка Сокращений
+ acronyms
+ acronyms
+
+ acronyms_manage
+ 0
+
+
+
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/posts/xml/permissions.xml b/upload/admin/applications/core/modules_admin/posts/xml/permissions.xml
index fddf3821..fc2b3b84 100644
--- a/upload/admin/applications/core/modules_admin/posts/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/posts/xml/permissions.xml
@@ -1,66 +1,76 @@
- Manage Badwords
+ Управление нецензурными словами
core_badwords
-
badword_manage
- Can manage badwords?
+ Может добавлять/изменять?
-
badword_delete
- Can delete badwords?
+ Может удалять?
- Emoticons
+ Смайлики
core_emoticons
-
emoticons_manage
- Can access emoticon manager?
+ Имеет доступ к менеджеру смайликов?
-
emoticons_edit
- Can edit emoticons?
+ Может изменять смайлики?
-
emoticons_add
- Can add new emoticons?
+ Может добавлять смайлики?
-
emoticons_delete
- Can remove emoticons?
+ Может удалять смайлики?
- BBCode
+ BB-коды
core_bbcode
-
bbcode_manage
- Can manage bbcode?
+ Может добавлять/изменять?
-
bbcode_delete
- Can delete bbcode?
+ Может удалять?
- Manage Media
+ Расшифровка сокращений
+ acronyms
+
+ -
+
acronyms_manage
+ Может управлять сокращениями?
+
+
+
+
+ Управление Media-тегами
core_media
-
media_manage
- Can manage media bbcode supported sites?
+ Может добавлять/изменять?
-
media_delete
- Can remove supported media bbcode sites?
+ Может удалять?
diff --git a/upload/admin/applications/core/modules_admin/report/defaultSection.php b/upload/admin/applications/core/modules_admin/report/defaultSection.php
index b0c0fa5b..05122579 100644
--- a/upload/admin/applications/core/modules_admin/report/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/report/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/report/reports.php b/upload/admin/applications/core/modules_admin/report/reports.php
index a93a440d..444f60b4 100644
--- a/upload/admin/applications/core/modules_admin/report/reports.php
+++ b/upload/admin/applications/core/modules_admin/report/reports.php
@@ -4,12 +4,12 @@
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: bfarber $
+ * $Author: AndyMillne $
* @author Based on original "Report Center" by Luke Scott
* @since -
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $LastChangedDate: 2013-02-14 19:17:38 -0500 (Thu, 14 Feb 2013) $
+ * @version v3.4.5
+ * $Revision: 11992 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -237,25 +237,39 @@ class admin_core_report_reports extends ipsCommand
// Make sure stuff is right
//-----------------------------------------
- if( ! $_POST['plugi_title'] || ! $_POST['plugi_desc'] || ! $_POST['plugi_file'] )
+ $errors = array();
+
+ if( ! $_POST['plugi_title'] )
{
- $this->registry->output->global_error = $this->lang->words['r_missingfield'];
+ $errors[] = "{$this->lang->words['r_missing_title']} ";
}
- elseif( preg_match("/[^a-z0-9\-_]/i", $this->request['plugi_file'] ) )
- {
- $this->registry->output->global_error = $this->lang->words['r_incchar'];
+ if( ! $_POST['plugi_desc'] )
+ {
+ $errors[] = "{$this->lang->words['r_missing_desc']} ";
}
- elseif( ! is_file( IPSLib::getAppDir( $this->request['appPlugin'] ) . '/extensions/reportPlugins/' . $this->request['plugi_file'] . '.php' ) )
+ if( ! $_POST['plugi_file'] )
+ {
+ $errors[] = "{$this->lang->words['r_missing_file']} ";
+ }
+ if( preg_match("/[^a-z0-9\-_]/i", $this->request['plugi_file'] ) )
{
- $this->registry->output->global_error = $this->lang->words['r_404file'];
+ $errors[] = "{$this->lang->words['r_incchar']} ";
+ }
+ if( ! is_file( IPSLib::getAppDir( $this->request['appPlugin'] ) . '/extensions/reportPlugins/' . $this->request['plugi_file'] . '.php' ) )
+ {
+ $errors[] = "{$this->lang->words['r_404file']} ";
}
- //-----------------------------------------
- // If no errors, create the plugin
- //-----------------------------------------
-
- if( ! $this->registry->output->global_error )
+ if( count( $errors ) )
+ {
+ $this->registry->output->html .= "{$this->lang->words['sl_formerror']} " . implode( '', $errors ) . " ";
+ }
+ else
{
+ //-----------------------------------------
+ // If no errors, create the plugin
+ //-----------------------------------------
+
$build_plugin = array(
'onoff' => 1,
'class_title' => $this->request['plugi_title'],
@@ -379,8 +393,7 @@ class admin_core_report_reports extends ipsCommand
'onoff' => $this->request['plugi_onoff'],
'group_can_report' => $p_can_report,
'mod_group_perm' => $p_can_gperm,
- 'extra_data' => serialize( $plugin->_extra ),
- 'app' => $this->request['appPlugin']
+ 'extra_data' => serialize( $plugin->_extra )
);
if( $plug_data['lockd'] == 0 || IN_DEV == 1 )
diff --git a/upload/admin/applications/core/modules_admin/report/xml/menu.xml b/upload/admin/applications/core/modules_admin/report/xml/menu.xml
index b87a4c7b..d96e9d96 100644
--- a/upload/admin/applications/core/modules_admin/report/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/report/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Plugin Manager
+ Управление Плагинами
- Plugin Manager
+ Управление Плагинами
reports_plugin
reports
do=plugin
@@ -15,10 +15,10 @@
-
-
Status & Severity Levels
+ Статус и Приоритеты Жалоб
- Status & Severity Levels
+ Статус и Приоритеты Жалоб
reports_ssl
reports
do=status
diff --git a/upload/admin/applications/core/modules_admin/report/xml/permissions.xml b/upload/admin/applications/core/modules_admin/report/xml/permissions.xml
index 13c7f749..2cb2af5a 100644
--- a/upload/admin/applications/core/modules_admin/report/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/report/xml/permissions.xml
@@ -1,30 +1,30 @@
- Report Center Plugins
+ Плагины системы жалоб
core_reports
-
plugins_manage
- Can add/edit supported reported content plugins?
+ Может добавлять/изменять плагины?
-
plugins_remove
- Can remove reported content plugins?
+ Может удалять плагины?
- Report Center Status and Severity Management
+ Управление статусами жалоб
core_statsev
-
sands_manage
- Can add/edit report center status and severity levels?
+ Может добавлять/изменять статусы жалоб?
-
sands_remove
- Can remove status and severity levels?
+ Может удалять статусы?
diff --git a/upload/admin/applications/core/modules_admin/seo/activity.php b/upload/admin/applications/core/modules_admin/seo/activity.php
new file mode 100644
index 00000000..87d91e55
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/seo/activity.php
@@ -0,0 +1,650 @@
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+class admin_core_seo_activity extends ipsCommand
+{
+ public $html;
+ protected $engine = null;
+
+ /**
+ * Main class entry point
+ *
+ * @access public
+ * @param object ipsRegistry reference
+ * @return void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'seo_activity' );
+
+ ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_seo' ) );
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_seo' );
+
+ if( $this->request['engine'] )
+ {
+ $this->engine = $this->DB->addSlashes( strtolower( $this->request['engine'] ) );
+ $this->engine = $this->engine == 'msnbot' ? 'bing' : $this->engine;
+ }
+
+ $app = $this->DB->buildAndFetch( array( 'select' => 'app_added', 'from' => 'core_applications', 'where' => "app_directory = 'ipseo'" ) );
+
+ $days = 7;
+
+ if($app['app_added'] > time() - (86400*7))
+ {
+ $days = 2;
+ }
+
+ if($app['app_added'] > time() - (86400*2))
+ {
+ $days = 1;
+ }
+
+ $this->days = $this->request['days'] ? intval( $this->request['days'] ) : $days;
+
+ if ( $this->days == 1 )
+ {
+ $this->mysqlGroup = '%H';
+ $this->phpGroup = 'H';
+ }
+ else if ( $this->days == 28 )
+ {
+ $this->mysqlGroup = '%e';
+ $this->phpGroup = 'j';
+ }
+ else
+ {
+ $this->mysqlGroup = '%w';
+ $this->phpGroup = 'w';
+ }
+
+ //-----------------------------------------
+ // What are we doing?
+ //-----------------------------------------
+
+ switch($this->request['do'])
+ {
+ case 'keywords':
+ $this->_showKeywords();
+ break;
+
+ case 'visitors':
+ $this->_showVisitors();
+ break;
+
+ case 'search_chart':
+ $this->renderSearchChart();
+ break;
+
+ case 'spider_chart':
+ $this->renderSpiderChart();
+ break;
+
+ default:
+ $this->showDashboard();
+ break;
+ }
+
+ //-----------------------------------------
+ // Display
+ //-----------------------------------------
+
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Page: Keywords
+ */
+ protected function _showKeywords()
+ {
+ $st = $this->request['st'] ? $this->request['st'] : 0;
+
+ /* Pagination */
+ $max = $this->DB->buildAndFetch( array( 'select' => "COUNT(*) as total",
+ 'from' => "search_keywords" ) );
+
+ $pagination = $this->registry->output->generatePagination( array( 'totalItems' => intval($max['total']),
+ 'itemsPerPage' => 20,
+ 'currentStartValue' => $st,
+ 'baseUrl' => $this->settings['base_url'].'&module=seo§ion=activity&do=keywords' ) );
+
+ /* Get results */
+ $keywords = array();
+ $this->DB->build( array(
+ 'select' => '*',
+ 'from' => 'search_keywords',
+ 'limit' => array( $st, 20 ),
+ 'order' => 'count DESC'
+ ) );
+ $this->DB->execute();
+ while ( $row = $this->DB->fetch() )
+ {
+ $row['keyword'] = IPSText::parseCleanValue( strtolower( $row['keyword'] ) );
+ $keywords[] = $row;
+ }
+
+ /* Display */
+ $this->registry->output->html = $this->html->keywords( $pagination, $keywords );
+ }
+
+ /**
+ * Page: Visitors
+ */
+ protected function _showVisitors()
+ {
+ /* Init vars */
+ $st = intval($this->request['st']);
+ $visitors = array();
+ $where = array();
+
+ /* Looking for a specific search engine? */
+ if ( ! is_null($this->engine) )
+ {
+ $where[] = 's.engine = \''.$this->engine.'\'';
+ }
+
+ /* Looking for a specific keyword? */
+ if ( ! is_null($this->request['keyword']) )
+ {
+ $where[] = 's.keywords = \''.$this->request['keyword'].'\'';
+ }
+
+ /* Pagination */
+ $max = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as total', 'from' => 'search_visitors s', 'where' => implode(' AND ', $where) ) );
+
+ $base = $this->settings['base_url'].'module=seo§ion=activity&do=visitors&';
+ $base .= !is_null($this->engine) ? 'engine=' . $this->engine . '&' : '';
+ $base .= !is_null($this->request['keyword']) ? 'keyword=' . $this->request['keyword'] . '&' : '';
+
+ $pagination = $this->registry->output->generatePagination( array( 'totalItems' => intval($max['total']),
+ 'itemsPerPage' => 20,
+ 'currentStartValue' => $st,
+ 'baseUrl' => $base
+ ) );
+
+ /* Get results */
+ if ( $max['total'] )
+ {
+ $this->DB->build( array( 'select' => 's.*',
+ 'from' => array( 'search_visitors' => 's' ),
+ 'where' => implode(' AND ', $where),
+ 'limit' => array( $st, 20 ),
+ 'order' => 'date DESC',
+ 'add_join' => array( array( 'select' => 'm.member_id, m.members_display_name',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => 'm.member_id=s.member',
+ 'type' => 'left' ) )
+ ) );
+ $e = $this->DB->execute();
+
+ while ( $row = $this->DB->fetch( $e ) )
+ {
+ $row['date'] = $this->lang->getDate( $row['date'], 'SHORT' );
+ $row['keywords'] = IPSText::parseCleanValue( urldecode( strtolower( $row['keywords'] ) ) );
+ $row['page'] = $this->makeLinkText( $row['url'] );
+
+ $visitors[] = $row;
+ }
+ }
+
+ /* Display */
+ $this->registry->output->html = $this->html->visitors( $pagination, $visitors );
+ }
+
+ /**
+ * Page: Dashboard
+ */
+ protected function showDashboard()
+ {
+ //-----------------------------------------
+ // Get Keywords
+ //-----------------------------------------
+
+ $keywords = array();
+ $this->DB->build( array(
+ 'select' => '*',
+ 'from' => 'search_keywords',
+ 'limit' => array( 0, 5 ),
+ 'order' => 'count DESC'
+ ) );
+ $this->DB->execute();
+ while ( $row = $this->DB->fetch() )
+ {
+ $row['keyword'] = IPSText::parseCleanValue( strtolower( $row['keyword'] ) );
+ $keywords[] = $row;
+ }
+
+ //-----------------------------------------
+ // Get Spider Hits
+ //-----------------------------------------
+
+ $spiders = array();
+
+ $query = array(
+ 'select' => '*',
+ 'from' => 'spider_logs',
+ 'order' => 'sid DESC',
+ 'limit' => array(0, 5)
+ );
+
+ if(!is_null($this->engine))
+ {
+ $query['where'] = 'bot = \''.($this->engine == 'bing' ? 'msnbot\' OR \'bing' : $this->engine).'\'';
+ }
+
+ $this->DB->build( $query );
+ $this->DB->execute();
+ while($row = ipsRegistry::DB()->fetch($result))
+ {
+ $row['entry_date'] = $this->lang->getDate( $row['entry_date'], 'SHORT' );
+ $row['page'] = $this->makeLinkText( $row['query_string'] ? $row['query_string'] : $row['request_addr'] );
+ $spiders[] = $row;
+ }
+
+ //-----------------------------------------
+ // Get Visitors
+ //-----------------------------------------
+
+ $visitors = array();
+
+ $this->DB->build( array( 'select' => 's.*',
+ 'from' => array( 'search_visitors' => 's' ),
+ 'limit' => array( 0, 5 ),
+ 'order' => 'date DESC',
+ 'add_join' => array( array( 'select' => 'm.member_id, m.members_display_name',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => 'm.member_id=s.member',
+ 'type' => 'left' ) )
+ ) );
+ $e = $this->DB->execute();
+
+ while ( $row = $this->DB->fetch( $e ) )
+ {
+ $row['date'] = $this->lang->getDate( $row['date'], 'SHORT' );
+ $row['keywords'] = IPSText::parseCleanValue( urldecode( strtolower( $row['keywords'] ) ) );
+ $row['page'] = $this->makeLinkText( $row['url'] );
+
+ $visitors[] = $row;
+ }
+
+ //-----------------------------------------
+ // Display
+ //-----------------------------------------
+
+ $this->registry->output->html = $this->html->activity( $keywords, $spiders, $visitors );
+ }
+
+ /**
+ * Work out page title
+ */
+ protected function makeLinkText($qs)
+ {
+ $matches = array();
+
+ if( $qs == '' )
+ {
+ return 'Board index';
+ }
+ elseif(preg_match('/showtopic\=([0-9]+)/', $qs, $matches))
+ {
+ return 'Topic: ' . $this->getContentTitle('title', 'topics', 'tid = ' . intval($matches[1]) );
+ }
+ elseif(preg_match('/showforum\=([0-9]+)/', $qs, $matches))
+ {
+ return 'Forum: ' . $this->getContentTitle('name', 'forums', 'id = ' . intval($matches[1]) );
+ }
+ elseif(preg_match('/showuser\=([0-9]+)/', $qs, $matches))
+ {
+ return 'User: ' . $this->getContentTitle('members_display_name', 'members', 'member_id = ' . intval($matches[1]) );
+ }
+ elseif(preg_match('/entry\=([0-9]+)/', $qs, $matches))
+ {
+ return 'Blog Entry: ' . $this->getContentTitle('entry_name', 'blog_entries', 'entry_id = ' . intval($matches[1]) );
+ }
+ elseif(preg_match('/blogid\=([0-9]+)/', $qs, $matches))
+ {
+ return 'Blog: ' . $this->getContentTitle('blog_name', 'blog_blogs', 'blog_id = ' . intval($matches[1]) );
+ }
+ elseif(preg_match('/showfile\=([0-9]+)/', $qs, $matches))
+ {
+ return 'Download: ' . $this->getContentTitle('file_name', 'downloads_files', 'file_id = ' . intval($matches[1]) );
+ }
+ elseif(preg_match('/app=downloads(.*)showcat\=([0-9]+)/', $qs, $matches))
+ {
+ return 'Download: ' . $this->getContentTitle('cname', 'downloads_categories', 'cid = ' . intval($matches[2]) );
+ }
+ elseif(preg_match('/app=sitemap(.*)sitemap\=(.*)$/', $qs, $matches))
+ {
+ return 'Sitemap: ' . IPSText::parseCleanValue( $matches[2] );
+ }
+ elseif(preg_match('/app=seo(.*)sitemap\=(.*)$/', $qs, $matches))
+ {
+ return 'Sitemap: ' . IPSText::parseCleanValue( $matches[2] );
+ }
+ elseif(preg_match('/app=ipseo(.*)sitemap\=(.*)$/', $qs, $matches))
+ {
+ return 'Sitemap: ' . IPSText::parseCleanValue( $matches[2] );
+ }
+ else
+ {
+
+ foreach( ipsRegistry::$applications as $appDir => $appData )
+ {
+ if( preg_match( "/app\={$appDir}/", $qs ) )
+ {
+ return IPSLib::getAppTitle( $appDir, true ) ? IPSLib::getAppTitle( $appDir, true ) : IPSLib::getAppTitle( $appDir );
+ }
+ }
+ }
+
+ return 'Unknown';
+ }
+
+ protected function getContentTitle( $select, $table, $where )
+ {
+ $data = $this->DB->buildAndFetch( array( 'select' => $select . ' AS content_title', 'from' => $table, 'where' => $where ) );
+
+ if( empty($data['content_title']) )
+ {
+ return '(Could not load title)';
+ }
+ else
+ {
+ return $data['content_title'];
+ }
+ }
+
+ /**
+ * Action: Render Latest Visitors Chart
+ */
+ public function renderSearchChart()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $week = $this->getDateFrom();
+ $engine= is_null($this->engine) ? '' : ' AND engine = \''.$this->engine.'\'';
+
+ $graph = $this->_buildChart( $week );
+
+ $series = array();
+ if ( $this->days == 1 )
+ {
+ for ( IPSTime::setTimestamp( $week ); IPSTime::getTimestamp()<(time()+3600); IPSTime::add_minutes( 60 ) )
+ {
+ $series[ intval( date( $this->phpGroup, IPSTime::getTimestamp() ) ) ] = 0;
+ }
+ }
+ else
+ {
+ for ( IPSTime::setTimestamp( $week ); IPSTime::getTimestamp()phpGroup, IPSTime::getTimestamp() ) ) ] = 0;
+ }
+ }
+
+ //-----------------------------------------
+ // Get Results
+ //-----------------------------------------
+
+ $this->DB->build(array(
+ 'select' => $this->DB->buildFromUnixtime('date', $this->mysqlGroup ) . ' AS chart_day, COUNT(*) AS chart_count',
+ 'from' => 'search_visitors',
+ 'where' => 'date >= ' . $week . $engine,
+ 'group' => $this->DB->buildFromUnixtime('date', $this->mysqlGroup ),
+ 'order' => 'id ASC'
+ ));
+
+ $result = $this->DB->execute();
+
+ if($result)
+ {
+ $i = 0;
+ $rows = ipsRegistry::DB()->getTotalRows();
+ while($row = ipsRegistry::DB()->fetch($result))
+ {
+ $i++;
+
+ $title = false;
+ switch($this->days)
+ {
+ case 1:
+ if($i == 1 || $i % 2)
+ {
+ $title = true;
+ }
+ break;
+
+ case 2:
+ if($i == 1 || $i == $rows || $i == round($rows/2))
+ {
+ $title = true;
+ }
+ break;
+
+ default:
+ $title = true;
+ break;
+ }
+
+ if ( isset( $series[ intval( $row['chart_day'] ) ] ) )
+ {
+ $series[ intval( $row['chart_day'] ) ] = $row['chart_count'];
+ }
+ }
+ }
+
+ $plotSeries = array();
+ foreach ( $series as $v )
+ {
+ $plotSeries[] = $v;
+ }
+
+ //-----------------------------------------
+ // Render
+ //-----------------------------------------
+
+ $graph->addSeries( '', $plotSeries );
+
+ @$graph->display( $this->getDateFrom() );
+
+ exit;
+ }
+
+ /**
+ * Action: Render Latest Spider Hits
+ */
+ public function renderSpiderChart()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $week = $this->getDateFrom();
+ $engine= is_null($this->engine) ? '' : ' AND engine = \''.$this->engine.'\'';
+
+ $graph = $this->_buildChart( $week );
+
+ $series = array();
+ if ( $this->days == 1 )
+ {
+ for ( IPSTime::setTimestamp( $week ); IPSTime::getTimestamp()<(time()+3600); IPSTime::add_minutes( 60 ) )
+ {
+ $series[ intval( date( $this->phpGroup, IPSTime::getTimestamp() ) ) ] = 0;
+ }
+ }
+ else
+ {
+ for ( IPSTime::setTimestamp( $week ); IPSTime::getTimestamp()phpGroup, IPSTime::getTimestamp() ) ) ] = 0;
+ }
+ }
+
+ //-----------------------------------------
+ // Get Results
+ //-----------------------------------------
+
+ $this->DB->build(array(
+ 'select' => $this->DB->buildFromUnixtime('entry_date', $this->mysqlGroup ) . ' AS chart_day, COUNT(*) AS chart_count',
+ 'from' => 'spider_logs',
+ 'where' => 'entry_date >= ' . $week . $engine,
+ 'group' => $this->DB->buildFromUnixtime('entry_date', $this->mysqlGroup ),
+ 'order' => 'entry_date ASC'
+ ));
+
+ $result = $this->DB->execute();
+
+ if($result)
+ {
+ $i = 0;
+ $rows = ipsRegistry::DB()->getTotalRows();
+ while($row = ipsRegistry::DB()->fetch($result))
+ {
+ $i++;
+
+ $title = false;
+ switch($this->days)
+ {
+ case 1:
+ if($i == 1 || $i % 2)
+ {
+ $title = true;
+ }
+ break;
+
+ case 2:
+ if($i == 1 || $i == $rows || $i == round($rows/2))
+ {
+ $title = true;
+ }
+ break;
+
+ default:
+ $title = true;
+ break;
+ }
+
+ if ( isset( $series[ intval( $row['chart_day'] ) ] ) )
+ {
+ $series[ intval( $row['chart_day'] ) ] = $row['chart_count'];
+ }
+ }
+ }
+
+ $plotSeries = array();
+ foreach ( $series as $v )
+ {
+ $plotSeries[] = $v;
+ }
+
+ //-----------------------------------------
+ // Render
+ //-----------------------------------------
+
+ $graph->addSeries( '', $plotSeries );
+
+ @$graph->display( $this->getDateFrom() );
+
+ exit;
+ }
+
+ /**
+ * Work out start date
+ */
+ protected function getDateFrom()
+ {
+ $now = time();
+
+ if ( $this->days == 1 )
+ {
+ return $now - 86400 + 3600;
+ }
+ else
+ {
+ $minus = $now - (86400 * ($this->days-1));
+ $from = strtotime('00:00:01', $minus);
+ }
+
+ return $from;
+ }
+
+ /**
+ * Build A Chart
+ */
+ private function _buildChart( $startTime )
+ {
+ //-----------------------------------------
+ // Silly Timezones
+ //-----------------------------------------
+
+ $this->DB->setTimeZone( $this->memberData['time_offset'] );
+
+ //-----------------------------------------
+ // Init Graph
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH . 'classGraph.php' );/*noLibHook*/
+ $graph = new classGraph();
+ $graph->options['font'] = DOC_IPS_ROOT_PATH . '/public/style_captcha/captcha_fonts/DejaVuSans.ttf';
+ $graph->options['width'] = 800;
+ $graph->options['height'] = 300;
+ $graph->options['style3D'] = 0;
+ $graph->options['charttype'] = 'Area';
+ $graph->options['showgridlinesx'] = 0;
+ $graph->options['showdatalabels'] = 0;
+ $graph->options['title'] = '';
+ $graph->options['showlegend'] = 0;
+
+ //-----------------------------------------
+ // Add Labels
+ //-----------------------------------------
+
+ $labels = array();
+ if ( $this->days == 1 )
+ {
+ for ( IPSTime::setTimestamp( $startTime ); IPSTime::getTimestamp()<(time()+3600); IPSTime::add_minutes( 60 ) )
+ {
+ $labels[] = date( 'ga', IPSTime::getTimestamp() );
+ }
+ }
+ else
+ {
+ for ( IPSTime::setTimestamp( $startTime ); IPSTime::getTimestamp()addLabels( $labels );
+
+ //-----------------------------------------
+ // Return
+ //-----------------------------------------
+
+ return $graph;
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/seo/advice.php b/upload/admin/applications/core/modules_admin/seo/advice.php
new file mode 100644
index 00000000..29668a0c
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/seo/advice.php
@@ -0,0 +1,217 @@
+registry->getClass('class_permissions')->checkPermissionAutoMsg( 'seo_advice' );
+
+ ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_seo' ) );
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_seo' );
+
+ //-----------------------------------------
+ // What are we doing?
+ //-----------------------------------------
+
+ switch($this->request['do'])
+ {
+ case 'ignore':
+ $this->ignoreWarning();
+ break;
+
+ case 'clear_warnings':
+ $this->clearWarnings();
+ break;
+
+ case 'download_sitemap':
+ $this->downloadSitemap();
+ break;
+
+ default:
+ $this->dashboard();
+ break;
+
+ }
+
+ //-----------------------------------------
+ // Display
+ //-----------------------------------------
+
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Action: Download Sitemap
+ */
+ public function downloadSitemap()
+ {
+ header( "Content-type: application/xml" );
+ header( "Content-Disposition: attachment; filename=\"sitemap.xml\"" );
+ exit;
+ }
+
+ /**
+ * Action: Show Dashboard
+ */
+ public function dashboard()
+ {
+ $messages = array();
+
+ //-----------------------------------------
+ // Get Ignored Messages
+ //-----------------------------------------
+
+ $ignores = ips_CacheRegistry::instance()->getCache('ipseo_ignore_messages');
+ if(!$ignores) $ignores = array();
+
+ //-----------------------------------------
+ // Work out the setting group for SEO settings
+ //-----------------------------------------
+
+ $group = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword='seo'" ) );
+
+ //-----------------------------------------
+ // Get meta tags for board index
+ //-----------------------------------------
+
+ $metaTags = $this->cache->getCache('meta_tags');
+
+ //-----------------------------------------
+ // Any messages?
+ //-----------------------------------------
+
+ /* Sitemap path not writable */
+ $this->settings['sitemap_path'] = $this->settings['sitemap_path'] ? $this->settings['sitemap_path'] : DOC_IPS_ROOT_PATH;
+ if ( !array_key_exists( 'sitemap_path', $ignores ) and ( !file_exists( $this->settings['sitemap_path'] . 'sitemap.xml' ) or !is_writable( $this->settings['sitemap_path'] . 'sitemap.xml' ) ) )
+ {
+ // Hang on, can we create one?
+ @file_put_contents( $this->settings['sitemap_path'] . 'sitemap.xml', '' );
+ @chmod( $this->settings['sitemap_path'] . 'sitemap.xml', 0777 );
+
+ if ( !file_exists( $this->settings['sitemap_path'] . 'sitemap.xml' ) or !is_writable( $this->settings['sitemap_path'] . 'sitemap.xml' ) )
+ {
+ $messages[] = array( 'level' => 'bad', 'fix' => 'app=core&module=seo§ion=advice&do=download_sitemap', 'key' => 'sitemap_path' );
+ }
+ }
+
+ /* URL type not path info */
+ if(!array_key_exists('url_type', $ignores) && $this->settings['url_type'] != 'path_info')
+ {
+ $messages[] = array('level' => 'bad', 'fix' => "app=core&module=settings§ion=settings&do=setting_view&conf_group={$group['conf_title_id']}", 'key' => 'url_type');
+ }
+
+ /* No board index title */
+ if(!array_key_exists('seo_index_title', $ignores) && !$this->settings['seo_index_title'] )
+ {
+ $messages[] = array('level' => 'bad', 'fix' => "app=core&module=settings§ion=settings&do=setting_view&conf_group={$group['conf_title_id']}", 'key' => 'seo_index_title');
+ }
+
+ /* No board index description */
+ if( !array_key_exists('seo_index_md', $ignores) && !$this->settings['seo_index_md'] )
+ {
+ $messages[] = array('level' => 'bad', 'fix' => "app=core&module=settings§ion=settings&do=setting_view&conf_group={$group['conf_title_id']}", 'key' => 'seo_index_md');
+ }
+
+ /* Not logging spider visits */
+ if(!array_key_exists('spider_visit', $ignores) && !$this->settings['spider_visit'] )
+ {
+ $messages[] = array('level' => 'bad', 'fix' => "app=core&module=settings§ion=settings&do=setting_view&conf_group={$group['conf_title_id']}", 'key' => 'spider_visit');
+ }
+
+ /* No Meta Tags */
+ if( !array_key_exists('ipseo_no_meta', $ignores) && empty( $metaTags ) )
+ {
+ $messages[] = array('level' => 'warn', 'fix' => 'app=core&module=templates§ion=meta', 'key' => 'ipseo_no_meta');
+ }
+
+ /* Sitemap ping disabled */
+ if(!array_key_exists('sitemap_ping', $ignores) && !$this->settings['sitemap_ping'])
+ {
+ $messages[] = array('level' => 'warn', 'fix' => 'app=core&module=settings§ion=settings&&do=findsetting&key=sitemap', 'key' => 'sitemap_ping');
+ }
+
+ if(!array_key_exists('seo_r_on', $ignores) && !$this->settings['seo_r_on'])
+ {
+ $messages[] = array('level' => 'warn', 'fix' => "app=core&module=settings§ion=settings&do=setting_view&conf_group={$group['conf_title_id']}", 'key' => 'seo_r_on');
+ }
+
+ if(!array_key_exists('htaccess_mod_rewrite', $ignores) && !$this->settings['htaccess_mod_rewrite'])
+ {
+ $messages[] = array('level' => 'warn', 'fix' => "app=core&module=settings§ion=settings&do=setting_view&conf_group={$group['conf_title_id']}", 'key' => 'htaccess_mod_rewrite');
+ }
+
+ //-----------------------------------------
+ // Display
+ //-----------------------------------------
+
+ $this->registry->output->html = $this->html->dashboard( $messages, $ignores );
+ }
+
+ /**
+ * Action: Ignore Message
+ */
+ public function ignoreWarning()
+ {
+ $ignores = ips_CacheRegistry::instance()->getCache('ipseo_ignore_messages');
+ if( !$ignores )
+ {
+ $ignores = array();
+ }
+
+ $ignores[ $this->request['key'] ] = 1;
+
+ ips_CacheRegistry::instance()->setCache( 'ipseo_ignore_messages', $ignores, array( 'array' => 1 ) );
+
+ $this->registry->output->silentRedirect( ipsRegistry::$settings['base_url'] . "module=seo" );
+ }
+
+ /**
+ * Action: Clear Warnings
+ */
+ public function clearWarnings()
+ {
+ ips_CacheRegistry::instance()->setCache( 'ipseo_ignore_messages', array(), array( 'array' => 1 ) );
+
+ $this->registry->output->silentRedirect( ipsRegistry::$settings['base_url'] . "module=seo" );
+ }
+
+ /**
+ * Recache
+ */
+ public function recache()
+ {
+ $current = ipsRegistry::instance()->cache()->getCache('ipseo_ignore_messages');
+
+ if(!is_array($current))
+ {
+ $current = array();
+ }
+
+ ipsRegistry::instance()->cache()->setCache( 'ipseo_ignore_messages', $current, array( 'array' => 1, 'donow' => 1 ) );
+ }
+
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/seo/defaultSection.php b/upload/admin/applications/core/modules_admin/seo/defaultSection.php
new file mode 100644
index 00000000..6736017c
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/seo/defaultSection.php
@@ -0,0 +1,5 @@
+loadLanguageFile( array( 'admin_seo' ) );
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_seo' );
+
+ //-----------------------------------------
+ // What are we doing?
+ //-----------------------------------------
+
+ switch($this->request['do'])
+ {
+ case 'ok':
+ $this->ok();
+ break;
+
+ default:
+ $this->splash();
+ break;
+
+ }
+
+ //-----------------------------------------
+ // Display
+ //-----------------------------------------
+
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Action: Splash
+ */
+ public function splash()
+ {
+ $this->registry->output->html = $this->html->upgradeSplash();
+ }
+
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/seo/xml/menu.xml b/upload/admin/applications/core/modules_admin/seo/xml/menu.xml
new file mode 100644
index 00000000..895f8318
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/seo/xml/menu.xml
@@ -0,0 +1,31 @@
+
+
+
+ -
+
SEO-поддержка
+
+
+ SEO-поддержка
+ seo_advice
+ advice
+
+ seo_advice
+ 0
+
+
+
+ -
+
Активность Поисковых Машин
+
+
+ Активность Поисковых Машин
+ seo_dashboard
+ activity
+
+ seo_activity
+ 0
+
+
+
+
+
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/seo/xml/permissions.xml b/upload/admin/applications/core/modules_admin/seo/xml/permissions.xml
new file mode 100644
index 00000000..353625a3
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/seo/xml/permissions.xml
@@ -0,0 +1,17 @@
+
+
+
+ SEO
+ core_seo
+
+ -
+
seo_advice
+ Может просматривать SEO-поддержку?
+
+ -
+
seo_activity
+ Может просматривать SEO-активность?
+
+
+
+
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/settings/defaultSection.php b/upload/admin/applications/core/modules_admin/settings/defaultSection.php
index a8787f7d..bef69d2d 100644
--- a/upload/admin/applications/core/modules_admin/settings/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/settings/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/settings/settings.php b/upload/admin/applications/core/modules_admin/settings/settings.php
index f2a2c202..22ac6753 100644
--- a/upload/admin/applications/core/modules_admin/settings/settings.php
+++ b/upload/admin/applications/core/modules_admin/settings/settings.php
@@ -1,2103 +1,2106 @@
-Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-class admin_core_settings_settings extends ipsCommand
-{
- /**
- * Key array
- *
- * @var array Array of keys
- */
- protected $key_array = array();
-
- /**
- * Setting groups array
- *
- * @var array Array of setting groups
- */
- protected $setting_groups = array();
-
- /**
- * Setting groups array mapping
- *
- * @var array Array of setting groups
- */
- protected $setting_groups_by_key = array();
-
- /**
- * Skin object
- * This is public so that the portal can access it
- *
- * @var object Skin templates
- */
- public $html;
-
- /**
- * Form code
- * This is public so that the portal can access it
- *
- * @var string Form code
- */
- public $form_code;
-
- /**
- * Form code
- * This is public so that the portal can access it
- *
- * @var string JS Form code
- */
- public $form_code_js;
-
- /**
- * Application to use
- *
- * @var string Application
- */
- protected $_app;
-
- /**
- * Where to return to after save
- *
- * @var string URL to go to
- */
- public $return_after_save;
-
- /**
- * Breadcrumb url to use in place of the default
- *
- * @var string
- */
- public $base_nav_url;
-
- /**
- * Object for the editor shortcut
- *
- * @var $editor
- */
- public $editor = NULL;
-
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- //-----------------------------------------
- // Load language
- //-----------------------------------------
-
- $this->registry->class_localization->loadLanguageFile( array( 'admin_tools' ) );
-
- $this->html = $this->registry->output->loadTemplate('cp_skin_settings');
-
- $this->form_code = $this->html->form_code = 'module=settings§ion=settings&';
- $this->form_code_js = $this->html->form_code_js = 'module=settings§ion=settings&';
-
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'settings_manage' );
-
- /* What to do? */
- switch( $this->request['do'] )
- {
- case 'settinggroup_resync':
- $this->_resynchSettingGroup();
- break;
-
- case 'settinggroup_delete':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'settings_delete' );
- $this->_deleteSettingGroup();
- break;
-
- case 'settinggroup_new':
- $this->_settingGroupForm('add');
- break;
-
- case 'settinggroup_showedit':
- $this->_settingGroupForm('edit');
- break;
-
- case 'settinggroup_add':
- $this->_settingGroupSave('add');
- break;
-
- case 'settinggroup_edit':
- $this->_settingGroupSave('edit');
- break;
-
- case 'settingnew':
- $this->_settingForm('add');
- break;
-
- case 'setting_showedit':
- $this->_settingForm('edit');
- break;
-
- case 'setting_add':
- $this->_settingSave('add');
- break;
-
- case 'setting_edit':
- $this->_settingSave('edit');
- break;
-
- case 'reorder':
- $this->reorder();
- break;
-
- case 'setting_view':
- $this->_viewSettings();
- break;
-
- case 'setting_delete':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'settings_delete' );
- $this->_deleteSettings();
- break;
-
- case 'setting_revert':
- $this->_revertSettings();
- break;
-
- case 'setting_update':
- $this->_updateSettings();
- break;
-
- case 'findsetting':
- $this->_findSettingGroup();
- break;
-
- case 'settings_do_import':
- $this->importAllSettings();
- break;
- case 'settings_do_import_indev':
- $this->importAllSettings(1);
- break;
-
- case 'MOD_export_setting':
- $this->_exportSettingsGroup();
- break;
-
- case 'settingsExportApps':
- $messages = $this->exportAllApps();
-
- $this->registry->output->setMessage( implode( " ", $messages ), 1 );
- $this->_settingsOverview();
- break;
-
- case 'settingsImportApps':
- $messages = $this->importAllApps();
-
- $this->registry->output->setMessage( implode( " ", $messages ), 1 );
- $this->_settingsOverview();
- break;
- default:
- $this->request['do'] = 'settingsview';
- $this->_settingsOverview();
- break;
- }
-
- //-----------------------------------------
- // Pass to CP output hander
- //-----------------------------------------
-
- $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
- $this->registry->output->sendOutput();
- }
-
- /**
- * Reorder the settings
- *
- * @return @e void
- */
- public function reorder()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
- $ajax = new $classToLoad();
-
- //-----------------------------------------
- // Checks...
- //-----------------------------------------
-
- if( $this->registry->adminFunctions->checkSecurityKey( $this->request['md5check'], true ) === false )
- {
- $ajax->returnString( $this->lang->words['postform_badmd5'] );
- exit();
- }
-
- //-----------------------------------------
- // Save new position
- //-----------------------------------------
-
- $position = 1;
-
- if( is_array($this->request['settings']) AND count($this->request['settings']) )
- {
- foreach( $this->request['settings'] as $this_id )
- {
- $this->DB->update( 'core_sys_conf_settings', array( 'conf_position' => $position ), 'conf_id=' . $this_id );
-
- $position++;
- }
- }
-
- $ajax->returnString( 'OK' );
- exit();
- }
-
- /**
- * Setting group export
- *
- * @return @e void
- */
- protected function _exportSettingsGroup()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $this->request[ 'conf_group'] = intval($this->request['conf_group'] );
-
- /* Got anything? */
- if ( ! $this->request['conf_group'] )
- {
- return;
- }
-
- //-----------------------------------------
- // Get setting groups
- //-----------------------------------------
-
- $this->_settingsGetGroups( true );
-
- //-----------------------------------------
- // Get xml class
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
-
- $xml = new classXML( IPS_DOC_CHAR_SET );
-
- $xml->newXMLDocument();
- $xml->addElement( 'settingexport' );
- $xml->addElement( 'settinggroup', 'settingexport' );
-
- foreach( $this->setting_groups as $i => $roar )
- {
- //-----------------------------------------
- // App check?
- //-----------------------------------------
-
- if ( $this->request['conf_group'] != $roar['conf_title_id'] )
- {
- continue;
- }
-
- //-----------------------------------------
- // First, add in setting group title
- //-----------------------------------------
-
- $thisconf = array( 'conf_is_title' => 1,
- 'conf_title_keyword' => $roar['conf_title_keyword'],
- 'conf_title_title' => $roar['conf_title_title'],
- 'conf_title_desc' => $roar['conf_title_desc'],
- 'conf_title_tab' => $roar['conf_title_tab'],
- 'conf_title_app' => $roar['conf_title_app'] ? $roar['conf_title_app'] : 'core',
- 'conf_title_noshow' => $roar['conf_title_noshow'] );
-
- $xml->addElementAsRecord( 'settinggroup', 'setting', $thisconf );
-
- //-----------------------------------------
- // Get settings...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'core_sys_conf_settings',
- 'where' => "conf_group='{$roar['conf_title_id']}'",
- 'order' => 'conf_position, conf_title' ) );
-
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- //-----------------------------------------
- // Clean up...
- //-----------------------------------------
-
- unset( $r['conf_value'], $r['conf_id'] );
-
- $r['conf_title_keyword'] = $roar['conf_title_keyword'];
- $r['conf_is_title'] = 0;
-
- $xml->addElementAsRecord( 'settinggroup', 'setting', $r );
- }
- }
-
- //-----------------------------------------
- // Grab the XML document
- //-----------------------------------------
-
- $xmlData = $xml->fetchDocument();
-
- $this->registry->output->showDownload( $xmlData, 'settingGroup_' . IPSText::makeSeoTitle( $thisconf['conf_title_title'] ) . '.xml', '', 0 );
- }
-
- /**
- * Find setting group (don't rely on IDs)
- *
- * @return @e void
- */
- public function _findSettingGroup()
- {
- if ( ! $this->request['key'] )
- {
- $this->_settingsOverview();
- }
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- if( ( $r['conf_title_keyword'] == $this->request['key'] ) OR strtolower( str_replace( " ", "", trim( $r['conf_title_title'] ) ) ) == urldecode( trim( $this->request['key'] ) ) )
- {
- $this->registry->output->silentRedirect( $this->settings['base_url'] . '&' . $this->form_code . '&do=setting_view&conf_group=' . $r['conf_title_id'] );
- break;
- }
- }
-
- $this->_settingsOverview();
- }
-
- /**
- * Import all settings
- *
- * @param boolean In development mode?
- * @param boolean Return (ignore the var name)
- * @param array Array of known setting values
- * @return @e void
- */
- public function importAllSettings( $in_dev=0, $no_return=0, $known=array() )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $updated = 0;
- $inserted = 0;
- $need_update = array();
-
- //-----------------------------------------
- // Make sure we have titles
- //-----------------------------------------
-
- $this->_settingsTitlesCheck();
-
- //-----------------------------------------
- // INDEV?
- //-----------------------------------------
-
- if ( $in_dev )
- {
- $_FILES['FILE_UPLOAD']['name'] = '';
- $this->request['file_location'] = IPSLib::getAppDir( $this->request['app_dir'] ) . '/xml/' . $this->request['app_dir'] . '_settings.xml';
- }
- else
- {
- $this->request['file_location'] = IPS_ROOT_PATH . $this->request['file_location'] ;
- }
-
- //-----------------------------------------
- // Go for it
- //-----------------------------------------
-
- if ( $_FILES['FILE_UPLOAD']['name'] == "" or ! $_FILES['FILE_UPLOAD']['name'] or ($_FILES['FILE_UPLOAD']['name'] == "none") )
- {
- //-----------------------------------------
- // check and load from server
- //-----------------------------------------
-
- if ( ! $this->request['file_location'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_nofile'];
- $this->_settingsOverview();
- return;
- }
-
- if ( ! is_file( $this->request['file_location'] ) )
- {
- $this->registry->output->global_message = sprintf( $this->lang->words['s_noopen'], $this->request['file_location'] );
- $this->_settingsOverview();
- return;
- }
-
- if ( preg_match( '#\.gz$#', $this->request['file_location'] ) )
- {
- if ( $FH = @gzopen( $this->request['file_location'], 'rb' ) )
- {
- while ( ! @gzeof( $FH ) )
- {
- $content .= @gzread( $FH, 1024 );
- }
-
- @gzclose( $FH );
- }
- }
- else
- {
- if ( $FH = @fopen( $this->request['file_location'], 'rb' ) )
- {
- $content = @fread( $FH, filesize($this->request['file_location']) );
- @fclose( $FH );
- }
- }
- }
- else
- {
- //-----------------------------------------
- // Get uploaded schtuff
- //-----------------------------------------
-
- $tmp_name = $_FILES['FILE_UPLOAD']['name'];
- $tmp_name = preg_replace( '#\.gz$#', "", $tmp_name );
-
- try
- {
- $content = ipsRegistry::getClass('adminFunctions')->importXml( $tmp_name );
- }
- catch ( Exception $e )
- {
- $this->registry->output->showError( $e->getMessage() );
- }
- }
-
- if ( ! $content )
- {
- $this->registry->output->global_message = $this->lang->words['s_nofile'];
- $this->_settingsOverview();
- return;
- }
-
- $return = $this->_importXML( $content, $this->request['app_dir'], $known );
-
- if ( $no_return )
- {
- $this->registry->output->global_message = sprintf( $this->lang->words['s_upandin'], $return['updatedCount'], $return['insertedCount'] );
- return TRUE;
- }
- else
- {
- $this->registry->output->global_message = sprintf( $this->lang->words['s_upandin'], $return['updatedCount'], $return['insertedCount'] );
- $this->_settingsOverview();
- return;
- }
- }
-
- /**
- * Delete a setting group
- *
- * @return @e void
- */
- protected function _deleteSettingGroup()
- {
- if ( $this->request['id'] )
- {
- $conf = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group=' . $this->request['id'] ) );
-
- $count = intval($conf['count']);
-
- if ( $count > 0 )
- {
- $this->registry->output->global_message = $this->lang->words['s_cantremove'];
- }
- else
- {
- $this->DB->delete( 'core_sys_settings_titles', 'conf_title_id=' . $this->request['id'] );
-
- $this->registry->output->global_message = $this->lang->words['s_removed'];
- }
-
- }
-
- $this->settingsRebuildCache();
-
- $this->_settingsOverview();
- }
-
- /**
- * Resynchronize settings in a group
- *
- * @return @e void
- */
- protected function _resynchSettingGroup()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $this->request['id'] = intval( $this->request['id'] );
-
- //-----------------------------------------
- // Doit...
- //-----------------------------------------
-
- $this->_resynchGroup( $this->request['id'] );
-
- $this->registry->output->global_message = $this->lang->words['s_recounted'];
-
- //-----------------------------------------
- // Get conf title details
- //-----------------------------------------
-
- $conf_group = $this->DB->buildAndFetch( array( 'select' => 'conf_title_tab',
- 'from' => 'core_sys_settings_titles',
- 'where' => 'conf_title_id='.$this->request['id'] ) );
-
- $this->_settingsOverview( $conf_group['conf_title_tab'] );
- }
-
- /**
- * Does the resync
- *
- * @param integer Group id
- * @return @e void
- */
- protected function _resynchGroup( $id )
- {
- if ( $id )
- {
- $conf = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group='.$id ) );
-
- $count = intval($conf['count']);
-
- $this->DB->update( 'core_sys_settings_titles', array( 'conf_title_count' => $count ), 'conf_title_id=' . $id );
- }
- }
-
- /**
- * Form to add/edit a setting group
- *
- * @param string [add|edit]
- * @return @e void
- */
- protected function _settingGroupForm( $type='add' )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $conf_title_id = intval( $this->request['id'] );
- $form = array();
- $apps = array( 0 => array( 'core', $this->lang->words['s_global_dd'] ) );
-
- //-----------------------------------------
- // Build applications drop down
- //-----------------------------------------
-
- foreach( ipsRegistry::$applications as $app_dir => $app_data )
- {
- $apps[] = array( $app_dir, $app_data['app_title'] );
- }
-
- //-----------------------------------------
- // Type
- //-----------------------------------------
-
- if ( $type == 'add' )
- {
- $formcode = 'settinggroup_add';
- $title = $this->lang->words['s_createnew'];
- $button = $this->lang->words['s_createnew'];
- }
- else
- {
- $conf = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'core_sys_settings_titles',
- 'where' => 'conf_title_id='.$conf_title_id ) );
-
- if ( ! $conf['conf_title_id'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_noid'];
- $this->_settingsOverview();
- }
-
- $formcode = 'settinggroup_edit';
- $title = sprintf($this->lang->words['s_editsetting'], $conf['conf_title'] );
- $button = $this->lang->words['s_savechanges'];
- }
-
- //-----------------------------------------
- // Form elements
- //-----------------------------------------
-
- $form['conf_title_title'] = $this->registry->output->formInput( 'conf_title_title', $_POST['conf_title_title'] ? $_POST['conf_title_title'] : $conf['conf_title_title'] );
- $form['conf_title_desc'] = $this->registry->output->formTextarea( 'conf_title_desc', $_POST['conf_title_desc'] ? $_POST['conf_title_desc'] : $conf['conf_title_desc'] );
- $form['conf_title_app'] = $this->registry->output->formDropdown( 'conf_title_app', $apps, $_POST['conf_title_app'] ? $_POST['conf_title_app'] : $conf['conf_title_app'] );
- $form['conf_title_tab'] = $this->registry->output->formInput( 'conf_title_tab', $_POST['conf_title_tab'] ? $_POST['conf_title_tab'] : $conf['conf_title_tab'] );
-
- //if ( IN_DEV )
- //{
- $form['conf_title_keyword'] = $this->registry->output->formInput( 'conf_title_keyword', $_POST['conf_title_keyword'] ? $_POST['conf_title_keyword'] : $conf['conf_title_keyword'] );
- $form['conf_title_noshow'] = $this->registry->output->formYesNo( 'conf_title_noshow', $_POST['conf_title_noshow'] ? $_POST['conf_title_noshow'] : $conf['conf_title_noshow'] );
- //}
-
- $this->registry->output->html .= $this->html->settings_title_form( $form, $title, $formcode, $button );
- }
-
- /**
- * Save a setting group
- *
- * @param string [add|edit]
- * @return @e void
- */
- protected function _settingGroupSave($type='add')
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- if ( $type == 'edit' )
- {
- if ( ! $this->request['id'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_noid'];
- $this->_settingForm();
- return;
- }
- }
-
- if( ! $this->request['conf_title_title'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_notitle'];
- $this->_settingGroupForm( $type );
- return;
- }
-
- if( ! $this->request['conf_title_keyword'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_nokeyword'];
- $this->_settingGroupForm( $type );
- return;
- }
-
- //--------------------------------------------
- // Check...
- //--------------------------------------------
-
- $array = array( 'conf_title_title' => $this->request['conf_title_title'],
- 'conf_title_desc' => IPSText::safeslashes( $_POST['conf_title_desc'] ),
- 'conf_title_keyword' => IPSText::safeslashes( $_POST['conf_title_keyword'] ),
- 'conf_title_noshow' => $this->request['conf_title_noshow'],
- 'conf_title_app' => trim( $this->request['conf_title_app'] ),
- 'conf_title_tab' => trim( $this->request['conf_title_tab'] )
- );
-
-
- if ( $type == 'add' )
- {
- $this->DB->insert( 'core_sys_settings_titles', $array );
- $this->registry->output->global_message = $this->lang->words['s_added'];
- }
- else
- {
- $this->DB->update( 'core_sys_settings_titles', $array, 'conf_title_id=' . $this->request['id'] );
- $this->registry->output->global_message = $this->lang->words['s_edited'];
- }
-
- $this->settingsRebuildCache();
-
- $this->_settingsOverview();
- }
-
- /**
- * Form to add/edit a setting
- *
- * @param string [add|edit]
- * @return @e void
- */
- protected function _settingForm( $type='add' )
- {
- if ( $type == 'add' )
- {
- $formcode = 'setting_add';
- $title = $this->lang->words['s_createnewtitle'];
- $button = $this->lang->words['s_createnewtitle'];
- $conf = array( 'conf_group' => $this->request['conf_group'], 'conf_add_cache' => 1 );
-
- if ( IN_DEV )
- {
- $conf['conf_protected'] = 1;
- }
-
- if ( $this->request['conf_group'] )
- {
- $max = $this->DB->buildAndFetch( array( 'select' => 'max(conf_position) as max', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group=' . $this->request['conf_group'] ) );
- }
- else
- {
- $max = $this->DB->buildAndFetch( array( 'select' => 'max(conf_position) as max', 'from' => 'core_sys_conf_settings' ) );
- }
-
- $conf['conf_position'] = $max['max'] + 1;
- }
- else
- {
- $conf = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id=' . $this->request['id'] ) );
-
- if ( ! $conf['conf_id'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_noid'];
- $this->_settingsOverview();
- }
-
- $formcode = 'setting_edit';
- $title = sprintf($this->lang->words['s_editsetting'], $conf['conf_title'] );
- $button = $this->lang->words['s_savechanges'];
- }
-
- //-----------------------------------------
- // Get groups
- //-----------------------------------------
-
- $this->_settingsGetGroups();
-
- $groups = array();
-
- foreach( $this->setting_groups as $i => $r )
- {
- $groups[] = array( $r['conf_title_id'], $r['conf_title_title'] );
- }
-
- //-----------------------------------------
- // Type
- //-----------------------------------------
-
- $types = array(
- array( 'input' , $this->lang->words['s_input'] ),
- array( 'dropdown' , $this->lang->words['s_dropdown'] ),
- array( 'yes_no' , $this->lang->words['s_yes_no'] ),
- array( 'textarea' , $this->lang->words['s_textarea'] ),
- array( 'editor' , $this->lang->words['s_editor'] ),
- array( 'multi' , $this->lang->words['s_multi'] ),
- array( 'name_autocomplete' , $this->lang->words['s_name_autocomplete'] ),
- );
-
-
-
- $form['conf_title'] = $this->registry->output->formInput( 'conf_title' , $_POST['conf_title'] ? $_POST['conf_title'] : $conf['conf_title'] );
- $form['conf_position'] = $this->registry->output->formInput( 'conf_position' , $_POST['conf_position'] ? $_POST['conf_position'] : $conf['conf_position'] );
- $form['conf_description'] = $this->registry->output->formTextarea( 'conf_description', $_POST['conf_description'] ? $_POST['conf_description'] : $conf['conf_description'] );
- $form['conf_group'] = $this->registry->output->formDropdown( 'conf_group' , $groups, $_POST['conf_group'] ? $_POST['conf_group'] : $conf['conf_group'] );
- $form['conf_type'] = $this->registry->output->formDropdown( 'conf_type' , $types, $_POST['conf_type'] ? $_POST['conf_type'] : $conf['conf_type'] );
- $form['conf_key'] = $this->registry->output->formInput( 'conf_key' , $_POST['conf_key'] ? $_POST['conf_key'] : $conf['conf_key'] );
- $form['conf_value'] = $this->registry->output->formTextarea( 'conf_value' , $_POST['conf_value'] ? $_POST['conf_value'] : $conf['conf_value'] );
- $form['conf_default'] = $this->registry->output->formTextarea( 'conf_default' , $_POST['conf_default'] ? $_POST['conf_default'] : $conf['conf_default'] );
- $form['conf_extra'] = $this->registry->output->formTextarea( 'conf_extra' , $_POST['conf_extra'] ? $_POST['conf_extra'] : $conf['conf_extra'] );
- $form['conf_evalphp'] = $this->registry->output->formTextarea( 'conf_evalphp' , $_POST['conf_evalphp'] ? $_POST['conf_evalphp'] : $conf['conf_evalphp'] );
- $form['conf_keywords'] = $this->registry->output->formTextarea( 'conf_keywords' , $_POST['conf_keywords'] ? $_POST['conf_keywords'] : $conf['conf_keywords'] );
- $form['conf_start_group'] = $this->registry->output->formInput( 'conf_start_group', $_POST['conf_start_group'] ? $_POST['conf_start_group'] : $conf['conf_start_group'] );
- $form['conf_add_cache'] = $this->registry->output->formYesNo( 'conf_add_cache', $_POST['conf_add_cache'] ? $_POST['conf_add_cache'] : $conf['conf_add_cache'] );
-
- if ( IN_DEV )
- {
- $form['conf_protected'] = $this->registry->output->formYesNo( 'conf_protected', $_POST['conf_protected'] ? $_POST['conf_protected'] : $conf['conf_protected'] );
- }
-
-
-
- //-----------------------------------------
- // start form
- //-----------------------------------------
-
- $this->registry->output->html .= $this->html->settings_form( $form, $title, $formcode, $button );
- }
-
- /**
- * View all settings (form) in a group
- * This is public so that portal can access it
- *
- * @return @e void
- */
- public function _viewSettings()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $search_key = trim( $this->request['search'] );
- $conf_group = trim( $this->request['conf_group'] );
- $conf_titles = array();
- $last_conf_id = -1;
- $start = intval( $this->request['st'] );
- $end = 150;
- $get_by_key = isset( $this->request['conf_title_keyword'] ) ? $this->request['conf_title_keyword'] : '';
-
- //-----------------------------------------
- // Get settings in group
- //-----------------------------------------
-
- $this->_settingsGetGroups( ( $get_by_key ) ? TRUE : FALSE );
-
- //-----------------------------------------
- // Grabbing by key?
- //-----------------------------------------
-
- if( $get_by_key )
- {
- $data = $this->DB->buildAndFetch( array(
- 'select' => 'conf_title_id, conf_title_keyword, conf_title_title',
- 'from' => 'core_sys_settings_titles',
- 'where' => "conf_title_keyword='{$get_by_key}'"
- ) );
-
- $this->request['conf_group'] = $data['conf_title_id'] ;
- $conf_group = $data['conf_title_id'];
- $this->request['groupHelpKey'] = $data['conf_title_keyword'];
- }
-
- //-----------------------------------------
- // check...
- //-----------------------------------------
-
- if( !$conf_group and !$search_key )
- {
- $this->registry->output->global_message = $this->lang->words['s_nogroup'];
- $this->_settingsOverview();
- return;
- }
-
- //--------------------------------------
- // Redirect to Nexus for ads
- //--------------------------------------
-
- if ( $this->setting_groups[ $conf_group ]['conf_title_keyword'] == 'adcodeintegration' and IPSLib::appIsInstalled('nexus') )
- {
- $this->registry->output->silentRedirect( $this->settings['base_url'] . 'app=nexus&module=promotion§ion=advertisements' );
- }
-
- //-----------------------------------------
- // Pagination
- //-----------------------------------------
-
- $pages = $this->registry->output->generatePagination( array(
- 'totalItems' => $this->setting_groups[$conf_group]['conf_title_count'],
- 'itemsPerPage' => $end,
- 'currentStartValue' => $start,
- 'baseUrl' => $this->settings['base_url'] . "&{$this->form_code}&&search={$search_key}",
- ) );
-
-
- //-----------------------------------------
- // Did we search?
- //-----------------------------------------
-
- if( $search_key )
- {
- $keywords = strtolower($search_key);
- $whereExtra = $conf_group ? " AND c.conf_group={$conf_group}" : '';
-
- $this->DB->build( array(
- 'select' => 'c.*',
- 'from' => array( 'core_sys_conf_settings' => 'c' ),
- 'where' => '(' . $this->DB->buildLower('c.conf_title') . " LIKE '%{$keywords}%' OR " . $this->DB->buildLower('c.conf_description') . " LIKE '%{$keywords}%' OR " . $this->DB->buildLower('c.conf_keywords') . " LIKE '%{$keywords}%')" . $whereExtra,
- 'order' => 'c.conf_title',
- 'limit' => array( $start, $end ),
- 'add_join' => array(
- array(
- 'select' => 'ct.conf_title_id, ct.conf_title_noshow, ct.conf_title_title, ct.conf_title_tab',
- 'from' => array( 'core_sys_settings_titles' => 'ct' ),
- 'where' => 'ct.conf_title_id=c.conf_group',
- 'type' => 'left'
- )
- )
- ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $r['conf_start_group'] = "";
- $r['conf_description'] .= ' ' . $this->lang->words['conf_desc_search'] . "" . $r['conf_title_title'] . " ";
- $conf_entry[ $r['conf_id'] ] = $r;
- }
-
- if( ! count( $conf_entry ) )
- {
- $this->registry->output->global_message = sprintf( $this->lang->words['s_nomatches'], $keywords );
- $this->_settingsOverview();
- return;
- }
-
- $title = sprintf( $this->lang->words['s_searchedfor'], $keywords );
- $tab = '';
- }
-
- //-----------------------------------------
- // Or not...
- //-----------------------------------------
-
- else
- {
- $this->DB->build( array(
- 'select' => '*',
- 'from' => 'core_sys_conf_settings',
- 'where' => "conf_group='{$conf_group}'",
- 'order' => 'conf_position, conf_title',
- 'limit' => array( $start,$end )
- ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $conf_entry[ $r['conf_id'] ] = $r;
- }
-
- $title = $this->setting_groups[$conf_group]['conf_title_title'];
- $tab = IPSText::md5Clean( $this->setting_groups[$conf_group]['conf_title_tab'] );
- $this->request['groupHelpKey'] = $this->setting_groups[ $conf_group ]['conf_title_keyword'];
- }
-
- //-----------------------------------------
- // Start output
- //-----------------------------------------
-
- $content = "";
-
- if( is_array( $conf_entry ) and count( $conf_entry ) )
- {
- foreach( $conf_entry as $id => $r )
- {
- $content .= $this->_processSettingEntry( $r );
- }
- }
-
- if( ! $search_key AND ! $get_by_key )
- {
- $searchbutton = 1;
- }
-
- /* Navigation */
- if( $this->base_nav_url )
- {
- $this->registry->output->extra_nav[] = array( $this->base_nav_url, ipsRegistry::$applications[ $this->setting_groups[$conf_group]['conf_title_app'] ]['app_title'] );
- $this->registry->output->extra_nav[] = array( "", $title );
-
- }
- else if( $tab )
- {
- $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&_dtab={$tab}", $this->setting_groups[$conf_group]['conf_title_tab'] ? $this->setting_groups[$conf_group]['conf_title_tab'] : ipsRegistry::$applications[ $this->setting_groups[$conf_group]['conf_title_app'] ]['app_title'] );
- $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=setting_view&conf_group={$conf_group}", $title );
- }
- else
- {
- $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&_dtab=System", $this->setting_groups[$conf_group]['conf_title_tab'] ? $this->setting_groups[$conf_group]['conf_title_tab'] : ipsRegistry::$applications[ $this->setting_groups[$conf_group]['conf_title_app'] ]['app_title'] );
- $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=setting_view&conf_group={$conf_group}", $title );
- }
-
- /* Output */
- $this->registry->output->html .= $this->html->settings_view_wrapper( $title, $content, $searchbutton, $this->return_after_save );
- $this->registry->output->html = str_replace( '', " ", $this->registry->output->html );
- }
-
- /**
- * Process an individual setting for display
- *
- * @param array Setting record
- * @return @e void
- */
- protected function _processSettingEntry($r)
- {
- /* Init editor class */
- if ( !is_object($this->editor) )
- {
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
- $this->editor = new $classToLoad();
- }
-
- /* Init vars */
- $tempSkinUrl = $this->settings['skin_app_url'];
- $this->settings['skin_app_url'] = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/applications/core/skin_cp/' ;
- $form_element = "";
- $form_type = 'normal';
- $dropdown = array();
- $start = "";
- $revert_button = "";
-
- $key = $r['conf_key'];
- $value = $r['conf_value'] != "" ? $r['conf_value'] : $r['conf_default'];
- $value = $value == "{blank}" ? '' : $value;
-
- $show = 1;
-
- //-----------------------------------------------
- // Default?
- //-----------------------------------------------
-
- $css = "";
-
- if ( $r['conf_value'] != "" and ( $r['conf_value'] != $r['conf_default'] ) )
- {
- $revert_button = "form_code}&do=setting_revert&id={$r['conf_id']}&conf_group={$r['conf_group']}&search=" . $this->request['search'] . "' title='{$this->lang->words['s_revertback']}'>{$this->lang->words['revert']} ";
- }
-
- //-----------------------------------------------
- // Evil eval
- //-----------------------------------------------
-
- if ( $r['conf_evalphp'] )
- {
-
- $r['conf_evalphp'] = str_replace( '\', '\\', $r['conf_evalphp'] );
- $show = 1;
-
- eval( $r['conf_evalphp'] );
- }
-
- if( ! $show && ! IN_DEV )
- {
- return '';
- }
-
- switch( $r['conf_type'] )
- {
- case 'input':
- $form_element = $this->registry->output->formInput( $key, str_replace( "'", "'", $value ) );
- break;
-
- case 'textarea':
- $form_element = $this->registry->output->formTextarea( $key, str_replace( "\", "\", IPSText::textToForm($value) ), 45 );
- break;
-
- case 'editor':
- $this->editor->setIsHtml( true );
- $this->editor->setContent( $value );
-
- $form_element = $this->editor->show( $key, array( 'minimize' => 1, 'isHtml' => 1 ) );
- $form_type = 'rte';
-
- break;
-
- case 'yes_no':
- $form_element = $this->registry->output->formYesNo( $key, $value );
- break;
-
- case 'name_autocomplete':
- $form_element = $this->html->nameAutoCompleteField( $key, $value );
- break;
-
- default:
-
- if ( $r['conf_extra'] )
- {
- if ( $r['conf_extra'] == '#show_forums#' )
- {
- //-----------------------------------------
- // Require the library
- // (Not a building with books)
- //-----------------------------------------
-
- require_once( IPSLib::getAppDir( 'forums' ) .'/sources/classes/forums/class_forums.php' );/*noLibHook*/
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) .'/sources/classes/forums/admin_forum_functions.php', 'admin_forum_functions', 'forums' );
-
- $aff = new $classToLoad( $this->registry );
- $aff->forumsInit();
- $dropdown = $aff->adForumsForumList(1);
- }
- else if ( $r['conf_extra'] == '#show_groups#' )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'groups', 'order' => 'g_title ASC' ) );
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- if ( $row['g_access_cp'] )
- {
- $row['g_title'] .= ' ' . $this->lang->words['setting_staff_tag'] . ' ';
- }
-
- $dropdown[] = array( $row['g_id'], $row['g_title'] );
- }
- }
- else if ( $r['conf_extra'] == '#show_applications#' )
- {
- foreach( ipsRegistry::$applications as $app )
- {
- $dropdown[] = array( $app['app_directory'], $app['app_title'] );
- }
- }
- else if ( $r['conf_extra'] == '#show_skins#' )
- {
- $dropdown = $this->registry->output->generateSkinDropdown();
- }
- else
- {
- foreach( explode( "\n", $r['conf_extra'] ) as $l )
- {
- list ($k, $v) = explode( "=", $l );
- if ( $k != "" and $v != "" )
- {
- $dropdown[] = array( trim($k), trim($v) );
- }
- }
- }
- }
-
- if ( $r['conf_type'] == 'dropdown' )
- {
- $form_element = $this->registry->output->formDropdown( $key, $dropdown, $value );
- }
- else
- {
- $form_element = $this->registry->output->formMultiDropdown( $key, $dropdown, explode( ",", $value ) );
- }
-
- break;
- }
-
- $delete = "form_code}&do=setting_delete&id={$r['conf_id']}\");' title='key: {$r['conf_key']}'>{$this->lang->words['delete']} ";
- $edit = "form_code}&do=setting_showedit&id={$r['conf_id']}' title='id: {$r['conf_id']}'>{$this->lang->words['edit']} ";
-
- if ( $r['conf_protected'] and ! IN_DEV )
- {
- $delete = "";
- $edit = "";
- }
-
- if ( $r['conf_start_group'] )
- {
- $start = $this->html->settings_row_start_group( $r );
- }
-
- $r['conf_description'] = str_replace( '{ACP_URL}', $this->settings['_base_url'], $r['conf_description'] );
-
- //-----------------------------------------------
- // Search hi-lite
- //-----------------------------------------------
-
- if ( $this->request['search'] )
- {
- $_replacements = array();
-
- preg_match_all( "/(&([a-zA-Z0-9]+);)/i", $r['conf_title'], $matches );
-
- if( count($matches[0]) )
- {
- for( $i=0, $cnt=count($matches[0]); $i <= $cnt; $i++ )
- {
- $r['conf_title'] = str_replace( $matches[0][$i], '{{{' . $i . '}}}', $r['conf_title'] );
- }
- }
-
- $r['conf_title'] = preg_replace( "/(". str_replace( '/', '\\/', $this->request['search'] ) .")/i", "\\1 ", $r['conf_title'] );
-
- if( count($matches[0]) )
- {
- for( $i=0, $cnt=count($matches); $i <= $cnt; $i++ )
- {
- $r['conf_title'] = str_replace( '{{{' . $i . '}}}', $matches[0][$i], $r['conf_title'] );
- }
- }
-
- /**
- * Ok this is just annoying....
- */
- $_did = 0;
- preg_match_all( "/(href=['\"].*?[\"'])/i", $r['conf_description'], $matches );
-
- if( count($matches[0]) )
- {
- for( $i=$_did, $cnt=count($matches[0]); $i <= $cnt; $i++ )
- {
- $r['conf_description'] = str_replace( $matches[0][$i], '{{{' . $i . '}}}', $r['conf_description'] );
-
- $_replacements[ $i ] = $matches[0][$i];
- $_did++;
- }
- }
-
- preg_match_all( "/(&([a-zA-Z0-9]+);)/i", $r['conf_description'], $matches );
-
- if( count($matches[0]) )
- {
- for( $i=$_did, $cnt=count($matches[0]); $i <= $cnt; $i++ )
- {
- $r['conf_description'] = str_replace( $matches[0][$i], '{{{' . $i . '}}}', $r['conf_description'] );
-
- $_replacements[ $i ] = $matches[0][$i];
- $_did++;
- }
- }
-
- $r['conf_description'] = preg_replace( "/(". str_replace( '/', '\\/', $this->request['search'] ) .")/i", "\\1 ", $r['conf_description'] );
-
- if( count($_replacements) )
- {
- foreach( $_replacements as $index => $val )
- {
- $r['conf_description'] = str_replace( '{{{' . $index . '}}}', $val, $r['conf_description'] );
- }
- }
- }
-
- $html .= $start . $this->html->settings_view_row( $r, $edit, $delete, $form_element, $revert_button, $form_type );
-
- $this->key_array[] = preg_replace( '/\[\]$/', "", $key );
-
- $this->settings[ 'skin_app_url'] = $tempSkinUrl ;
-
- return $html;
- }
-
- /**
- * View setting groups
- *
- * @param string Application to default to
- * @return @e void
- */
- protected function _settingsOverview( $start_app='' )
- {
- $content = "";
- $title = "";
- $settings = array();
- $start_app = ( $start_app ) ? $start_app : trim( $this->request['start_app'] );
-
- //-----------------------------------------
- // Get the groups
- //-----------------------------------------
-
- $this->_settingsGetGroups();
-
- //-----------------------------------------
- // Build settings..
- //-----------------------------------------
-
- foreach( $this->setting_groups as $i => $r )
- {
- $r['conf_title_app'] = ( $r['conf_title_app'] ) ? $r['conf_title_app'] : 'core';
- $r['conf_title_tab'] = ( $r['conf_title_tab'] ) ? $r['conf_title_tab'] : 'System';
- $r['conf_title_title'] = ( $r['conf_title_noshow'] ) ? $r['conf_title_title'] . ' ' . $this->lang->words['s_ishidden'] : $r['conf_title_title'];
-
- $settings[ $r['conf_title_tab'] ][] = $r;
- }
-
- $this->registry->output->html .= $this->html->settings_titles_wrapper( $settings, $start_app );
- }
-
- /**
- * Update setting values/ordering
- *
- * @param boolean Return afterwards?
- * @return @e void
- */
- protected function _updateSettings( $donothing="" )
- {
- /* Init vars */
- $bounceback = str_replace( '&', '&', $this->request['bounceback'] );
-
- /* Check for something to save... */
- if ( ! $this->request['id'] and ! $this->request['search'] AND !$this->request['settings_save'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_noid'];
- $this->_settingsOverview();
- return;
- }
-
- /* ...and check for fields */
- $fields = explode( ",", trim($this->request['settings_save']) );
-
- if ( ! count($fields ) )
- {
- $this->registry->output->global_message = $this->lang->words['s_nofields'];
- $this->_viewSettings();
- return;
- }
-
- /* Init editor class */
- if ( !is_object($this->editor) )
- {
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
- $this->editor = new $classToLoad();
- }
-
- //--------------------------------------------
- // Update
- //--------------------------------------------
-
- $update = array();
- foreach ( $fields as $f )
- {
- $update[ $f ] = $_POST[ $f ];
- }
-
- IPSLib::updateSettings( $update, TRUE );
-
- $this->request['conf_group'] = $this->request['id'];
- $this->registry->output->global_message = $this->lang->words['s_updated'];
-
- //-----------------------------------------
- // We're bouncing back (Boing boing)
- //-----------------------------------------
-
- if ( $bounceback )
- {
- $this->registry->output->silentRedirectWithMessage( $bounceback );
- }
-
- //-----------------------------------------
- // Still here?
- //-----------------------------------------
-
-
- if ( ! $donothing )
- {
- $this->_viewSettings();
- }
- }
-
- /**
- * Save the settings form
- *
- * @param string [add|edit]
- * @return @e void
- */
- protected function _settingSave($type='add')
- {
- if ( $type == 'edit' )
- {
- if ( ! $this->request['id'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_noid'];
- $this->_settingForm();
- return;
- }
- }
-
- //--------------------------------------------
- // check...
- //--------------------------------------------
-
- $conf_group = $this->request['conf_newgroup'] ? $this->request['conf_newgroup'] : $this->request['conf_group'];
-
- $array = array( 'conf_title' => $this->request['conf_title'],
- 'conf_description' => IPSText::stripslashes( $_POST['conf_description'] ),
- 'conf_group' => $this->request['conf_group'],
- 'conf_type' => $this->request['conf_type'],
- 'conf_key' => str_replace( '-', '_', IPSText::alphanumericalClean( $this->request['conf_key'] ) ),
- 'conf_value' => IPSText::stripslashes( $_POST['conf_value'] ),
- 'conf_default' => IPSText::stripslashes( $_POST['conf_default'] ),
- 'conf_extra' => IPSText::stripslashes( $_POST['conf_extra'] ),
- 'conf_evalphp' => IPSText::stripslashes( $_POST['conf_evalphp'] ),
- 'conf_protected' => intval( $this->request['conf_protected'] ),
- 'conf_position' => intval( $this->request['conf_position'] ),
- 'conf_start_group' => $this->request['conf_start_group'],
- 'conf_add_cache' => intval( $this->request['conf_add_cache'] ),
- 'conf_keywords' => IPSText::stripslashes( $_POST['conf_keywords'] ),
- );
-
- //-----------------------------------------
- // Do we have a title and key?
- //-----------------------------------------
-
- if( !$array['conf_title'] OR !$array['conf_key'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_missing_key_data'];
- $this->_settingForm();
- return;
- }
-
- if ( $type == 'add' )
- {
- //-----------------------------------------
- // Is the key already in use?
- //-----------------------------------------
-
- if ( $this->settings[ $array['conf_key'] ] )
- {
- $this->registry->output->global_message = $this->lang->words['s_keyinuse_already'];
- $this->_settingForm();
- return;
- }
-
- $this->DB->insert( 'core_sys_conf_settings', $array );
- $this->registry->output->global_message = $this->lang->words['s_added2'];
- }
- else
- {
- $conf = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id=' . $this->request['id'] ) );
-
- $this->DB->update( 'core_sys_conf_settings', $array, 'conf_id=' . $this->request['id'] );
- $this->registry->output->global_message = $this->lang->words['s_edited2'];
-
- // Recount old group
- $this->_resynchGroup( $conf['conf_group'] );
- }
-
- //-----------------------------------------
- // Recount new group
- //-----------------------------------------
-
- if( $this->request['conf_group'] )
- {
- $this->_resynchGroup( $this->request['conf_group'] );
- }
-
- $this->settingsRebuildCache();
-
- $this->_viewSettings();
- }
-
- /**
- * Revert a setting to the default value
- *
- * @return @e void
- */
- protected function _revertSettings()
- {
- $this->request[ 'id'] = intval($this->request['id'] );
-
- if ( ! $this->request['id'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_noid'];
- $this->_settingForm();
- return;
- }
-
- $conf = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id=' . $this->request['id'] ) );
-
- //--------------------------------------------
- // Revert...
- //--------------------------------------------
-
- IPSLib::updateSettings( array( $conf['conf_key'] => $conf['conf_default'] ) );
-
- $this->registry->output->global_message = $this->lang->words['s_revertedback'];
-
- $this->settingsRebuildCache();
-
- //-----------------------------------------
- // Boink
- //-----------------------------------------
-
- $referrer = my_getenv('HTTP_REFERER');
-
- if ( strstr( $referrer, $this->settings['_admin_link'] ) and !strstr( $referrer, 'app=core&module=settings§ion=settings' ) )
- {
- $this->registry->output->silentRedirect( $referrer );
- return;
- }
- else
- {
- $this->_viewSettings();
- }
-
- }
-
- /**
- * Delete a setting
- *
- * @return @e void
- */
- protected function _deleteSettings()
- {
- if ( ! $this->request['id'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_noid'];
- $this->_settingsOverview();
- return;
- }
-
- $conf = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id=' . $this->request['id'] ) );
-
- if ( ! $conf['conf_id'] )
- {
- $this->registry->output->global_message = $this->lang->words['s_noid'];
- $this->_settingsOverview();
- return;
- }
-
- //--------------------------------------------
- // Delete...
- //--------------------------------------------
-
- $this->DB->delete( 'core_sys_conf_settings', 'conf_id=' . $this->request['id'] );
-
- $this->DB->update( 'core_sys_settings_titles', 'conf_title_count=conf_title_count-1', 'conf_title_id=' . $conf['conf_group'], false, true );
-
- $this->registry->output->global_message = $this->lang->words['s_deleted'];
-
- $this->settingsRebuildCache();
-
- $this->_settingsOverview();
- }
-
-
- /**
- * Rebuild settings cache
- *
- * @return @e void
- */
- public function settingsRebuildCache()
- {
- $settings = array();
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_add_cache=1' ) );
- $info = $this->DB->execute();
-
- while ( $r = $this->DB->fetch($info) )
- {
- $value = $r['conf_value'] != "" ? $r['conf_value'] : $r['conf_default'];
-
- if ( $value == '{blank}' )
- {
- $value = '';
- }
-
- $settings[ $r['conf_key'] ] = $value;
- }
-
- $this->cache->setCache( 'settings', $settings, array( 'array' => 1 ) );
- }
-
- /**
- * Grab all setting groups and store in an internal array
- *
- * @param boolean Pull all settings, not just visible ones
- * @return @e void
- */
- protected function _settingsGetGroups( $ignoreInDev=false )
- {
- $this->setting_groups = array();
-
- if ( IN_DEV OR $ignoreInDev )
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'order' => 'conf_title_title' ) );
- $this->DB->execute();
- }
- else
- {
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'where' => 'conf_title_noshow=0', 'order' => 'conf_title_title' ) );
- $this->DB->execute();
- }
-
- while( $r = $this->DB->fetch() )
- {
- $this->setting_groups[ $r['conf_title_id'] ] = $r;
- $this->setting_groups_by_key[ $r['conf_title_keyword'] ] = $r;
- }
- }
-
- /**
- * Make sure all titles have keywords set
- *
- * @return @e void
- */
- protected function _settingsTitlesCheck()
- {
- //-----------------------------------------
- // Get 'em
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles' ) );
- $outer = $this->DB->execute();
-
- while( $row = $this->DB->fetch( $outer ) )
- {
- if ( ! $row['conf_title_keyword'] )
- {
- $new_keyword = strtolower( preg_replace( '#[^\d\w]#', "", $row['conf_title_title'] ) );
- $this->DB->update( 'core_sys_settings_titles', array( 'conf_title_keyword' => $new_keyword ), 'conf_title_id='.$row['conf_title_id'] );
- }
- }
- }
-
- /**
- * Import XML Settings on an app by app basis
- *
- * @return array Array of messages
- */
- public function importAllApps()
- {
- $message = array();
-
- foreach( ipsRegistry::$applications as $app_dir => $app_data )
- {
- $file = IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml';
-
- if ( is_file( $file ) )
- {
- $contents = file_get_contents( $file );
-
- $return = $this->_importXML( $contents, $app_dir );
-
- $message[] = $app_data['app_title'] . " " . sprintf( $this->lang->words['s_upandin'], $return['updatedCount'], $return['insertedCount'] );
-
- /* In dev time stamp? */
- if ( IN_DEV )
- {
- $cache = $this->caches['indev'];
- $cache['import']['settings'][ $app_dir ] = time();
- $this->cache->setCache( 'indev', $cache, array( 'donow' => 1, 'array' => 1 ) );
- }
- }
- }
-
- /* Check for settings not needed anymore */
- $this->_loadDeleteList();
-
- return $message;
- }
-
- /**
- * Import XML Settings
- *
- * @param string XML Data
- * @param string Application (should be set by XML file, however)
- * @param array Array of any known settings and their values
- * @return array array( 'insertedCount' => x, 'updatedCount' => x, 'updatedKeys' => array(..), 'insertedKeys' => array() )
- */
- protected function _importXML( $content, $app='core', $knownSettings=array() )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $cur_settings = array();
- $updated = 0;
- $inserted = 0;
- $updatedKeys = array();
- $insertedKeys = array();
- $known = array();
-
- //-----------------------------------------
- // Get current settings.
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'conf_id, conf_key',
- 'from' => 'core_sys_conf_settings',
- 'order' => 'conf_id' ) );
-
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- $cur_settings[ $r['conf_key'] ] = $r['conf_id'];
- }
-
- //-----------------------------------------
- // Get current titles
- //-----------------------------------------
-
- $this->_settingsGetGroups( true );
-
- //-----------------------------------------
- // Get xml class
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
-
- $xml = new classXML( IPS_DOC_CHAR_SET );
- $xml->loadXML( $content );
-
- //-----------------------------------------
- // Loop through and sort out settings...
- //-----------------------------------------
-
- foreach( $xml->fetchElements('setting') as $setting )
- {
- $entry = $xml->fetchElementsFromRecord( $setting );
-
- //-----------------------------------------
- // Is setting?
- //-----------------------------------------
-
- if ( ! $entry['conf_is_title'] )
- {
- unset( $entry['conf_is_title'] );
- unset( $entry['conf_help_key'] );
- unset( $entry['conf_id'] );
- unset( $entry['conf_end_group'] );
- $new_settings[] = $entry;
- }
-
- //-----------------------------------------
- // Is title?
- //-----------------------------------------
-
- else
- {
- $new_titles[] = $entry;
- }
- }
-
- //-----------------------------------------
- // Sort out titles...
- //-----------------------------------------
-
- if ( is_array( $new_titles ) and count( $new_titles ) )
- {
- foreach( $new_titles as $idx => $data )
- {
- if ( $data['conf_title_title'] AND $data['conf_title_keyword'] )
- {
- //-----------------------------------------
- // Get ID based on key
- //-----------------------------------------
-
- $conf_id = $this->setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
-
- $save = array( 'conf_title_title' => $data['conf_title_title'],
- 'conf_title_desc' => $data['conf_title_desc'],
- 'conf_title_keyword' => $data['conf_title_keyword'],
- 'conf_title_tab' => $data['conf_title_tab'],
- 'conf_title_app' => $data['conf_title_app'] ? $data['conf_title_app'] : $app,
- 'conf_title_noshow' => $data['conf_title_noshow'] );
-
- //-----------------------------------------
- // Not got a row, insert first!
- //-----------------------------------------
-
- if ( ! $conf_id )
- {
- $this->DB->insert( 'core_sys_settings_titles', $save );
- $conf_id = $this->DB->getInsertId();
-
- }
- else
- {
- //-----------------------------------------
- // Update...
- //-----------------------------------------
-
- $this->DB->update( 'core_sys_settings_titles', $save, 'conf_title_id='.$conf_id );
- }
-
- //-----------------------------------------
- // Update settings cache
- //-----------------------------------------
-
- $save['conf_title_id'] = $conf_id;
- $this->setting_groups_by_key[ $save['conf_title_keyword'] ] = $save;
- $this->setting_groups[ $save['conf_title_id'] ] = $save;
-
- //-----------------------------------------
- // Remove need update...
- //-----------------------------------------
-
- $need_update[] = $conf_id;
- }
- }
- }
-
- //-----------------------------------------
- // Sort out settings
- //-----------------------------------------
-
- if ( is_array( $new_settings ) and count( $new_settings ) )
- {
- foreach( $new_settings as $idx => $data )
- {
- //-----------------------------------------
- // Insert known
- //-----------------------------------------
-
- $data['conf_value'] = '';
-
- if( is_array($knownSettings) AND count($knownSettings) )
- {
- if ( ! $data['conf_value'] AND ( in_array( $data['conf_key'], array_keys( $knownSettings ) ) ) )
- {
- $data['conf_value'] = $knownSettings[ $data['conf_key'] ];
- }
- }
-
- $data['conf_group'] = $this->setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
-
- //-----------------------------------------
- // Remove from array
- //-----------------------------------------
-
- unset( $data['conf_title_keyword'] );
-
- if ( $cur_settings[ $data['conf_key'] ] )
- {
- //-----------------------------------------
- // Don't change the setting value
- //-----------------------------------------
- unset( $data['conf_value'] );
-
- //-----------------------------------------
- // Update
- //-----------------------------------------
-
- $this->DB->update( 'core_sys_conf_settings', $data, 'conf_id='.$cur_settings[ $data['conf_key'] ] );
- $updatedKeys[] = $data['conf_key'];
- $updated++;
- }
- else
- {
- //-----------------------------------------
- // INSERT
- //-----------------------------------------
-
- $this->DB->insert( 'core_sys_conf_settings', $data );
- $insertedKeys[] = $data['conf_key'];
- $inserted++;
- }
- }
- }
-
- //-----------------------------------------
- // Update group counts...
- //-----------------------------------------
-
- if ( count( $need_update ) )
- {
- foreach( $need_update as $i => $idx )
- {
- $conf = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group='.$idx ) );
-
- $count = intval($conf['count']);
-
- $this->DB->update( 'core_sys_settings_titles', array( 'conf_title_count' => $count ), 'conf_title_id='.$idx );
- }
- }
-
- //-----------------------------------------
- // Resync
- //-----------------------------------------
-
- $this->settingsRebuildCache();
-
- //-----------------------------------------
- // Return
- //-----------------------------------------
-
- return array( 'insertedCount' => $inserted,
- 'updatedCount' => $updated,
- 'insertedKeys' => $insertedKeys,
- 'updatedKeys' => $updatedKeys );
- }
-
- /**
- * Export all apps: Wrapper function really. Yes. It is.
- *
- * @return array Array of messages or errors
- */
- public function exportAllApps()
- {
- $messages = array();
- $errors = array();
-
- /* Check for settings not needed anymore */
- $this->_loadDeleteList();
-
- foreach( ipsRegistry::$applications as $app_dir => $app_data )
- {
- @unlink( IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml' );
-
- if ( ! is_dir( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
- {
- $errors[] = "Error: " . IPSLib::getAppDir( $app_dir ) . "/xml/ does not exist";
- continue;
- }
- else if ( ! IPSLib::isWritable( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
- {
- if ( ! @chmod( IPSLib::isWritable( IPSLib::getAppDir( $app_dir ) . '/xml', 0755 ) ) )
- {
- $errors[] = "Error: " . IPSLib::getAppDir( $app_dir ) . "/xml/ is not writeable";
- continue;
- }
- }
- else if ( is_file( IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml' ) AND ! IPSLib::isWritable( IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml' ) )
- {
- $errors[] = "Error: " . IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . "_settings.xml is not writeable";
- continue;
- }
-
- $this->_exportXML( $app_dir );
-
- $messages[] = $app_data['app_title'] . " Settings written into the application's XML directory";
-
- /* In dev time stamp? */
- if ( IN_DEV )
- {
- $cache = $this->caches['indev'];
- $cache['import']['settings'][ $app_dir ] = time();
- $this->cache->setCache( 'indev', $cache, array( 'donow' => 1, 'array' => 1 ) );
- }
- }
-
- return $errors ? $errors : $messages;
- }
-
-
- /**
- * Export all settings to XML (IN_DEV mode)
- *
- * @param string Application directory
- * @return boolean
- */
- protected function _exportXML( $app_dir='core' )
- {
- //-----------------------------------------
- // Get setting groups
- //-----------------------------------------
-
- $this->_settingsGetGroups( true );
-
- //-----------------------------------------
- // Get xml class
- //-----------------------------------------
-
- require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
-
- $xml = new classXML( IPS_DOC_CHAR_SET );
-
- $xml->newXMLDocument();
- $xml->addElement( 'settingexport' );
- $xml->addElement( 'settinggroup', 'settingexport' );
-
- foreach( $this->setting_groups as $i => $roar )
- {
- //-----------------------------------------
- // App check?
- //-----------------------------------------
-
- if ( $app_dir != $roar['conf_title_app'] )
- {
- continue;
- }
-
- //-----------------------------------------
- // First, add in setting group title
- //-----------------------------------------
-
- $thisconf = array( 'conf_is_title' => 1,
- 'conf_title_keyword' => $roar['conf_title_keyword'],
- 'conf_title_title' => $roar['conf_title_title'],
- 'conf_title_desc' => $roar['conf_title_desc'],
- 'conf_title_tab' => $roar['conf_title_tab'],
- 'conf_title_app' => $roar['conf_title_app'] ? $roar['conf_title_app'] : $app_dir,
- 'conf_title_noshow' => $roar['conf_title_noshow'] );
-
- $xml->addElementAsRecord( 'settinggroup', 'setting', $thisconf );
-
- //-----------------------------------------
- // Get settings...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'core_sys_conf_settings',
- 'where' => "conf_group='{$roar['conf_title_id']}'",
- 'order' => 'conf_position, conf_title' ) );
-
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- //-----------------------------------------
- // Clean up...
- //-----------------------------------------
-
- unset( $r['conf_value'], $r['conf_id'] );
-
- $r['conf_title_keyword'] = $roar['conf_title_keyword'];
- $r['conf_is_title'] = 0;
-
- $xml->addElementAsRecord( 'settinggroup', 'setting', $r );
- }
- }
-
- //-----------------------------------------
- // Grab the XML document
- //-----------------------------------------
-
- $xmlData = $xml->fetchDocument();
-
- //-----------------------------------------
- // Attempt to write...
- //-----------------------------------------
-
- $file = IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml';
-
- @unlink( $file );
- @file_put_contents( $file, $xmlData );
- @chmod( $file, IPS_FOLDER_PERMISSION );
- }
-
- /**
- * Load and parse settings delete list (IN_DEV)
- *
- * @return @e void
- */
- protected function _loadDeleteList()
- {
- if ( IN_DEV )
- {
- /* Check for group settings */
- if ( is_file( DOC_IPS_ROOT_PATH . '_deleteGroupSettings.txt' ) )
- {
- $notTheseGroups = file( DOC_IPS_ROOT_PATH . '_deleteGroupSettings.txt' );
-
- if ( count($notTheseGroups) )
- {
- $notTheseGroups = array_map('trim', $notTheseGroups);
-
- $this->DB->build( array( 'select' => 'conf_title_id', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN ('" . implode("','", $notTheseGroups) . "')" ) );
- $this->DB->execute();
-
- if ( $this->DB->getTotalRows() )
- {
- $_deleteTheseGroups = array();
-
- while( $s = $this->DB->fetch() )
- {
- $_deleteTheseGroups[] = $s['conf_title_id'];
- }
-
- if ( count($_deleteTheseGroups) )
- {
- $this->DB->delete( 'core_sys_conf_settings', 'conf_group IN (' . implode(',', $_deleteTheseGroups) . ')' );
- $this->DB->delete( 'core_sys_settings_titles', "conf_title_keyword IN ('" . implode("','", $notTheseGroups) . "')" );
- }
- }
- }
- }
-
- /* Check for single settings */
- if ( is_file( DOC_IPS_ROOT_PATH . '_deleteSettings.txt' ) )
- {
- $notTheseSettings = file( DOC_IPS_ROOT_PATH . '_deleteSettings.txt' );
-
- if ( count($notTheseSettings) )
- {
- $notTheseSettings = array_map('trim', $notTheseSettings);
-
- $this->DB->delete( 'core_sys_conf_settings', "conf_key IN('" . implode( "','", $notTheseSettings ) . "')" );
- }
- }
- }
- }
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+class admin_core_settings_settings extends ipsCommand
+{
+ /**
+ * Key array
+ *
+ * @var array Array of keys
+ */
+ protected $key_array = array();
+
+ /**
+ * Setting groups array
+ *
+ * @var array Array of setting groups
+ */
+ protected $setting_groups = array();
+
+ /**
+ * Setting groups array mapping
+ *
+ * @var array Array of setting groups
+ */
+ protected $setting_groups_by_key = array();
+
+ /**
+ * Skin object
+ * This is public so that the portal can access it
+ *
+ * @var object Skin templates
+ */
+ public $html;
+
+ /**
+ * Form code
+ * This is public so that the portal can access it
+ *
+ * @var string Form code
+ */
+ public $form_code;
+
+ /**
+ * Form code
+ * This is public so that the portal can access it
+ *
+ * @var string JS Form code
+ */
+ public $form_code_js;
+
+ /**
+ * Application to use
+ *
+ * @var string Application
+ */
+ protected $_app;
+
+ /**
+ * Where to return to after save
+ *
+ * @var string URL to go to
+ */
+ public $return_after_save;
+
+ /**
+ * Breadcrumb url to use in place of the default
+ *
+ * @var string
+ */
+ public $base_nav_url;
+
+ /**
+ * Object for the editor shortcut
+ *
+ * @var $editor
+ */
+ public $editor = NULL;
+
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ //-----------------------------------------
+ // Load language
+ //-----------------------------------------
+
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_tools' ) );
+
+ $this->html = $this->registry->output->loadTemplate('cp_skin_settings');
+
+ $this->form_code = $this->html->form_code = 'module=settings§ion=settings&';
+ $this->form_code_js = $this->html->form_code_js = 'module=settings§ion=settings&';
+
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'settings_manage' );
+
+ /* What to do? */
+ switch( $this->request['do'] )
+ {
+ case 'settinggroup_resync':
+ $this->_resynchSettingGroup();
+ break;
+
+ case 'settinggroup_delete':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'settings_delete' );
+ $this->_deleteSettingGroup();
+ break;
+
+ case 'settinggroup_new':
+ $this->_settingGroupForm('add');
+ break;
+
+ case 'settinggroup_showedit':
+ $this->_settingGroupForm('edit');
+ break;
+
+ case 'settinggroup_add':
+ $this->_settingGroupSave('add');
+ break;
+
+ case 'settinggroup_edit':
+ $this->_settingGroupSave('edit');
+ break;
+
+ case 'settingnew':
+ $this->_settingForm('add');
+ break;
+
+ case 'setting_showedit':
+ $this->_settingForm('edit');
+ break;
+
+ case 'setting_add':
+ $this->_settingSave('add');
+ break;
+
+ case 'setting_edit':
+ $this->_settingSave('edit');
+ break;
+
+ case 'reorder':
+ $this->reorder();
+ break;
+
+ case 'setting_view':
+ $this->_viewSettings();
+ break;
+
+ case 'setting_delete':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'settings_delete' );
+ $this->_deleteSettings();
+ break;
+
+ case 'setting_revert':
+ $this->_revertSettings();
+ break;
+
+ case 'setting_update':
+ $this->_updateSettings();
+ break;
+
+ case 'findsetting':
+ $this->_findSettingGroup();
+ break;
+
+ case 'settings_do_import':
+ $this->importAllSettings();
+ break;
+ case 'settings_do_import_indev':
+ $this->importAllSettings(1);
+ break;
+
+ case 'MOD_export_setting':
+ $this->_exportSettingsGroup();
+ break;
+
+ case 'settingsExportApps':
+ $messages = $this->exportAllApps();
+
+ $this->registry->output->setMessage( implode( " ", $messages ), 1 );
+ $this->_settingsOverview();
+ break;
+
+ case 'settingsImportApps':
+ $messages = $this->importAllApps();
+
+ $this->registry->output->setMessage( implode( " ", $messages ), 1 );
+ $this->_settingsOverview();
+ break;
+ default:
+ $this->request['do'] = 'settingsview';
+ $this->_settingsOverview();
+ break;
+ }
+
+ //-----------------------------------------
+ // Pass to CP output hander
+ //-----------------------------------------
+
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Reorder the settings
+ *
+ * @return @e void
+ */
+ public function reorder()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
+ $ajax = new $classToLoad();
+
+ //-----------------------------------------
+ // Checks...
+ //-----------------------------------------
+
+ if( $this->registry->adminFunctions->checkSecurityKey( $this->request['md5check'], true ) === false )
+ {
+ $ajax->returnString( $this->lang->words['postform_badmd5'] );
+ exit();
+ }
+
+ //-----------------------------------------
+ // Save new position
+ //-----------------------------------------
+
+ $position = 1;
+
+ if( is_array($this->request['settings']) AND count($this->request['settings']) )
+ {
+ foreach( $this->request['settings'] as $this_id )
+ {
+ $this->DB->update( 'core_sys_conf_settings', array( 'conf_position' => $position ), 'conf_id=' . $this_id );
+
+ $position++;
+ }
+ }
+
+ $ajax->returnString( 'OK' );
+ exit();
+ }
+
+ /**
+ * Setting group export
+ *
+ * @return @e void
+ */
+ protected function _exportSettingsGroup()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $this->request[ 'conf_group'] = intval($this->request['conf_group'] );
+
+ /* Got anything? */
+ if ( ! $this->request['conf_group'] )
+ {
+ return;
+ }
+
+ //-----------------------------------------
+ // Get setting groups
+ //-----------------------------------------
+
+ $this->_settingsGetGroups( true );
+
+ //-----------------------------------------
+ // Get xml class
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
+
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+
+ $xml->newXMLDocument();
+ $xml->addElement( 'settingexport' );
+ $xml->addElement( 'settinggroup', 'settingexport' );
+
+ foreach( $this->setting_groups as $i => $roar )
+ {
+ //-----------------------------------------
+ // App check?
+ //-----------------------------------------
+
+ if ( $this->request['conf_group'] != $roar['conf_title_id'] )
+ {
+ continue;
+ }
+
+ //-----------------------------------------
+ // First, add in setting group title
+ //-----------------------------------------
+
+ $thisconf = array( 'conf_is_title' => 1,
+ 'conf_title_keyword' => $roar['conf_title_keyword'],
+ 'conf_title_title' => $roar['conf_title_title'],
+ 'conf_title_desc' => $roar['conf_title_desc'],
+ 'conf_title_tab' => $roar['conf_title_tab'],
+ 'conf_title_app' => $roar['conf_title_app'] ? $roar['conf_title_app'] : 'core',
+ 'conf_title_noshow' => $roar['conf_title_noshow'] );
+
+ $xml->addElementAsRecord( 'settinggroup', 'setting', $thisconf );
+
+ //-----------------------------------------
+ // Get settings...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'core_sys_conf_settings',
+ 'where' => "conf_group='{$roar['conf_title_id']}'",
+ 'order' => 'conf_position, conf_title' ) );
+
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ //-----------------------------------------
+ // Clean up...
+ //-----------------------------------------
+
+ unset( $r['conf_value'], $r['conf_id'] );
+
+ $r['conf_title_keyword'] = $roar['conf_title_keyword'];
+ $r['conf_is_title'] = 0;
+
+ $xml->addElementAsRecord( 'settinggroup', 'setting', $r );
+ }
+ }
+
+ //-----------------------------------------
+ // Grab the XML document
+ //-----------------------------------------
+
+ $xmlData = $xml->fetchDocument();
+
+ $this->registry->output->showDownload( $xmlData, 'settingGroup_' . IPSText::makeSeoTitle( $thisconf['conf_title_title'] ) . '.xml', '', 0 );
+ }
+
+ /**
+ * Find setting group (don't rely on IDs)
+ *
+ * @return @e void
+ */
+ public function _findSettingGroup()
+ {
+ if ( ! $this->request['key'] )
+ {
+ $this->_settingsOverview();
+ }
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ if( ( $r['conf_title_keyword'] == $this->request['key'] ) OR mb_strtolower( str_replace( " ", "", trim( $r['conf_title_title'] ) ) ) == urldecode( trim( $this->request['key'] ) ) )
+ {
+ $this->registry->output->silentRedirect( $this->settings['base_url'] . '&' . $this->form_code . '&do=setting_view&conf_group=' . $r['conf_title_id'] );
+ break;
+ }
+ }
+
+ $this->_settingsOverview();
+ }
+
+ /**
+ * Import all settings
+ *
+ * @param boolean In development mode?
+ * @param boolean Return (ignore the var name)
+ * @param array Array of known setting values
+ * @return @e void
+ */
+ public function importAllSettings( $in_dev=0, $no_return=0, $known=array() )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $updated = 0;
+ $inserted = 0;
+ $need_update = array();
+
+ //-----------------------------------------
+ // Make sure we have titles
+ //-----------------------------------------
+
+ $this->_settingsTitlesCheck();
+
+ //-----------------------------------------
+ // INDEV?
+ //-----------------------------------------
+
+ if ( $in_dev )
+ {
+ $_FILES['FILE_UPLOAD']['name'] = '';
+ $this->request['file_location'] = IPSLib::getAppDir( $this->request['app_dir'] ) . '/xml/' . $this->request['app_dir'] . '_settings.xml';
+ }
+ else
+ {
+ $this->request['file_location'] = IPS_ROOT_PATH . $this->request['file_location'] ;
+ }
+
+ //-----------------------------------------
+ // Go for it
+ //-----------------------------------------
+
+ if ( $_FILES['FILE_UPLOAD']['name'] == "" or ! $_FILES['FILE_UPLOAD']['name'] or ($_FILES['FILE_UPLOAD']['name'] == "none") )
+ {
+ //-----------------------------------------
+ // check and load from server
+ //-----------------------------------------
+
+ if ( ! $this->request['file_location'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_nofile'];
+ $this->_settingsOverview();
+ return;
+ }
+
+ if ( ! is_file( $this->request['file_location'] ) )
+ {
+ $this->registry->output->global_message = sprintf( $this->lang->words['s_noopen'], $this->request['file_location'] );
+ $this->_settingsOverview();
+ return;
+ }
+
+ if ( preg_match( '#\.gz$#', $this->request['file_location'] ) )
+ {
+ if ( $FH = @gzopen( $this->request['file_location'], 'rb' ) )
+ {
+ while ( ! @gzeof( $FH ) )
+ {
+ $content .= @gzread( $FH, 1024 );
+ }
+
+ @gzclose( $FH );
+ }
+ }
+ else
+ {
+ if ( $FH = @fopen( $this->request['file_location'], 'rb' ) )
+ {
+ $content = @fread( $FH, filesize($this->request['file_location']) );
+ @fclose( $FH );
+ }
+ }
+ }
+ else
+ {
+ //-----------------------------------------
+ // Get uploaded schtuff
+ //-----------------------------------------
+
+ $tmp_name = $_FILES['FILE_UPLOAD']['name'];
+ $tmp_name = preg_replace( '#\.gz$#', "", $tmp_name );
+
+ try
+ {
+ $content = ipsRegistry::getClass('adminFunctions')->importXml( $tmp_name );
+ }
+ catch ( Exception $e )
+ {
+ $this->registry->output->showError( $e->getMessage() );
+ }
+ }
+
+ if ( ! $content )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_nofile'];
+ $this->_settingsOverview();
+ return;
+ }
+
+ $return = $this->_importXML( $content, $this->request['app_dir'], $known );
+
+ if ( $no_return )
+ {
+ $this->registry->output->global_message = sprintf( $this->lang->words['s_upandin'], $return['updatedCount'], $return['insertedCount'] );
+ return TRUE;
+ }
+ else
+ {
+ $this->registry->output->global_message = sprintf( $this->lang->words['s_upandin'], $return['updatedCount'], $return['insertedCount'] );
+ $this->_settingsOverview();
+ return;
+ }
+ }
+
+ /**
+ * Delete a setting group
+ *
+ * @return @e void
+ */
+ protected function _deleteSettingGroup()
+ {
+ if ( $this->request['id'] )
+ {
+ $conf = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group=' . $this->request['id'] ) );
+
+ $count = intval($conf['count']);
+
+ if ( $count > 0 )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_cantremove'];
+ }
+ else
+ {
+ $this->DB->delete( 'core_sys_settings_titles', 'conf_title_id=' . $this->request['id'] );
+
+ $this->registry->output->global_message = $this->lang->words['s_removed'];
+ }
+
+ }
+
+ $this->settingsRebuildCache();
+
+ $this->_settingsOverview();
+ }
+
+ /**
+ * Resynchronize settings in a group
+ *
+ * @return @e void
+ */
+ protected function _resynchSettingGroup()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $this->request['id'] = intval( $this->request['id'] );
+
+ //-----------------------------------------
+ // Doit...
+ //-----------------------------------------
+
+ $this->_resynchGroup( $this->request['id'] );
+
+ $this->registry->output->global_message = $this->lang->words['s_recounted'];
+
+ //-----------------------------------------
+ // Get conf title details
+ //-----------------------------------------
+
+ $conf_group = $this->DB->buildAndFetch( array( 'select' => 'conf_title_tab',
+ 'from' => 'core_sys_settings_titles',
+ 'where' => 'conf_title_id='.$this->request['id'] ) );
+
+ $this->_settingsOverview( $conf_group['conf_title_tab'] );
+ }
+
+ /**
+ * Does the resync
+ *
+ * @param integer Group id
+ * @return @e void
+ */
+ protected function _resynchGroup( $id )
+ {
+ if ( $id )
+ {
+ $conf = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group='.$id ) );
+
+ $count = intval($conf['count']);
+
+ $this->DB->update( 'core_sys_settings_titles', array( 'conf_title_count' => $count ), 'conf_title_id=' . $id );
+ }
+ }
+
+ /**
+ * Form to add/edit a setting group
+ *
+ * @param string [add|edit]
+ * @return @e void
+ */
+ protected function _settingGroupForm( $type='add' )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $conf_title_id = intval( $this->request['id'] );
+ $form = array();
+ $apps = array( 0 => array( 'core', $this->lang->words['s_global_dd'] ) );
+
+ //-----------------------------------------
+ // Build applications drop down
+ //-----------------------------------------
+
+ foreach( ipsRegistry::$applications as $app_dir => $app_data )
+ {
+ $apps[] = array( $app_dir, $app_data['app_title'] );
+ }
+
+ //-----------------------------------------
+ // Type
+ //-----------------------------------------
+
+ if ( $type == 'add' )
+ {
+ $formcode = 'settinggroup_add';
+ $title = $this->lang->words['s_createnew'];
+ $button = $this->lang->words['s_createnew'];
+ }
+ else
+ {
+ $conf = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'core_sys_settings_titles',
+ 'where' => 'conf_title_id='.$conf_title_id ) );
+
+ if ( ! $conf['conf_title_id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_noid'];
+ $this->_settingsOverview();
+ }
+
+ $formcode = 'settinggroup_edit';
+ $title = sprintf($this->lang->words['s_editsetting'], $conf['conf_title'] );
+ $button = $this->lang->words['s_savechanges'];
+ }
+
+ //-----------------------------------------
+ // Form elements
+ //-----------------------------------------
+
+ $form['conf_title_title'] = $this->registry->output->formInput( 'conf_title_title', $_POST['conf_title_title'] ? $_POST['conf_title_title'] : $conf['conf_title_title'] );
+ $form['conf_title_desc'] = $this->registry->output->formTextarea( 'conf_title_desc', $_POST['conf_title_desc'] ? $_POST['conf_title_desc'] : $conf['conf_title_desc'] );
+ $form['conf_title_app'] = $this->registry->output->formDropdown( 'conf_title_app', $apps, $_POST['conf_title_app'] ? $_POST['conf_title_app'] : $conf['conf_title_app'] );
+ $form['conf_title_tab'] = $this->registry->output->formInput( 'conf_title_tab', $_POST['conf_title_tab'] ? $_POST['conf_title_tab'] : $conf['conf_title_tab'] );
+
+ //if ( IN_DEV )
+ //{
+ $form['conf_title_keyword'] = $this->registry->output->formInput( 'conf_title_keyword', $_POST['conf_title_keyword'] ? $_POST['conf_title_keyword'] : $conf['conf_title_keyword'] );
+ $form['conf_title_noshow'] = $this->registry->output->formYesNo( 'conf_title_noshow', $_POST['conf_title_noshow'] ? $_POST['conf_title_noshow'] : $conf['conf_title_noshow'] );
+ //}
+
+ $this->registry->output->html .= $this->html->settings_title_form( $form, $title, $formcode, $button );
+ }
+
+ /**
+ * Save a setting group
+ *
+ * @param string [add|edit]
+ * @return @e void
+ */
+ protected function _settingGroupSave($type='add')
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ if ( $type == 'edit' )
+ {
+ if ( ! $this->request['id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_noid'];
+ $this->_settingForm();
+ return;
+ }
+ }
+
+ if( ! $this->request['conf_title_title'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_notitle'];
+ $this->_settingGroupForm( $type );
+ return;
+ }
+
+ if( ! $this->request['conf_title_keyword'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_nokeyword'];
+ $this->_settingGroupForm( $type );
+ return;
+ }
+
+ //--------------------------------------------
+ // Check...
+ //--------------------------------------------
+
+ $array = array( 'conf_title_title' => $this->request['conf_title_title'],
+ 'conf_title_desc' => IPSText::safeslashes( $_POST['conf_title_desc'] ),
+ 'conf_title_keyword' => IPSText::safeslashes( $_POST['conf_title_keyword'] ),
+ 'conf_title_noshow' => $this->request['conf_title_noshow'],
+ 'conf_title_app' => trim( $this->request['conf_title_app'] ),
+ 'conf_title_tab' => trim( $this->request['conf_title_tab'] )
+ );
+
+
+ if ( $type == 'add' )
+ {
+ $this->DB->insert( 'core_sys_settings_titles', $array );
+ $this->registry->output->global_message = $this->lang->words['s_added'];
+ }
+ else
+ {
+ $this->DB->update( 'core_sys_settings_titles', $array, 'conf_title_id=' . $this->request['id'] );
+ $this->registry->output->global_message = $this->lang->words['s_edited'];
+ }
+
+ $this->settingsRebuildCache();
+
+ $this->_settingsOverview();
+ }
+
+ /**
+ * Form to add/edit a setting
+ *
+ * @param string [add|edit]
+ * @return @e void
+ */
+ protected function _settingForm( $type='add' )
+ {
+ if ( $type == 'add' )
+ {
+ $formcode = 'setting_add';
+ $title = $this->lang->words['s_createnewtitle'];
+ $button = $this->lang->words['s_createnewtitle'];
+ $conf = array( 'conf_group' => $this->request['conf_group'], 'conf_add_cache' => 1 );
+
+ if ( IN_DEV )
+ {
+ $conf['conf_protected'] = 1;
+ }
+
+ if ( $this->request['conf_group'] )
+ {
+ $max = $this->DB->buildAndFetch( array( 'select' => 'max(conf_position) as max', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group=' . $this->request['conf_group'] ) );
+ }
+ else
+ {
+ $max = $this->DB->buildAndFetch( array( 'select' => 'max(conf_position) as max', 'from' => 'core_sys_conf_settings' ) );
+ }
+
+ $conf['conf_position'] = $max['max'] + 1;
+ }
+ else
+ {
+ $conf = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id=' . $this->request['id'] ) );
+
+ if ( ! $conf['conf_id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_noid'];
+ $this->_settingsOverview();
+ }
+
+ $formcode = 'setting_edit';
+ $title = sprintf($this->lang->words['s_editsetting'], $conf['conf_title'] );
+ $button = $this->lang->words['s_savechanges'];
+ }
+
+ //-----------------------------------------
+ // Get groups
+ //-----------------------------------------
+
+ $this->_settingsGetGroups();
+
+ $groups = array();
+
+ foreach( $this->setting_groups as $i => $r )
+ {
+ $groups[] = array( $r['conf_title_id'], $r['conf_title_title'] );
+ }
+
+ //-----------------------------------------
+ // Type
+ //-----------------------------------------
+
+ $types = array(
+ array( 'input' , $this->lang->words['s_input'] ),
+ array( 'dropdown' , $this->lang->words['s_dropdown'] ),
+ array( 'yes_no' , $this->lang->words['s_yes_no'] ),
+ array( 'textarea' , $this->lang->words['s_textarea'] ),
+ array( 'editor' , $this->lang->words['s_editor'] ),
+ array( 'multi' , $this->lang->words['s_multi'] ),
+ array( 'name_autocomplete' , $this->lang->words['s_name_autocomplete'] ),
+ );
+
+
+
+ $form['conf_title'] = $this->registry->output->formInput( 'conf_title' , $_POST['conf_title'] ? $_POST['conf_title'] : $conf['conf_title'] );
+ $form['conf_position'] = $this->registry->output->formInput( 'conf_position' , $_POST['conf_position'] ? $_POST['conf_position'] : $conf['conf_position'] );
+ $form['conf_description'] = $this->registry->output->formTextarea( 'conf_description', $_POST['conf_description'] ? $_POST['conf_description'] : $conf['conf_description'] );
+ $form['conf_group'] = $this->registry->output->formDropdown( 'conf_group' , $groups, $_POST['conf_group'] ? $_POST['conf_group'] : $conf['conf_group'] );
+ $form['conf_type'] = $this->registry->output->formDropdown( 'conf_type' , $types, $_POST['conf_type'] ? $_POST['conf_type'] : $conf['conf_type'] );
+ $form['conf_key'] = $this->registry->output->formInput( 'conf_key' , $_POST['conf_key'] ? $_POST['conf_key'] : $conf['conf_key'] );
+ $form['conf_value'] = $this->registry->output->formTextarea( 'conf_value' , $_POST['conf_value'] ? $_POST['conf_value'] : $conf['conf_value'] );
+ $form['conf_default'] = $this->registry->output->formTextarea( 'conf_default' , $_POST['conf_default'] ? $_POST['conf_default'] : $conf['conf_default'] );
+ $form['conf_extra'] = $this->registry->output->formTextarea( 'conf_extra' , $_POST['conf_extra'] ? $_POST['conf_extra'] : $conf['conf_extra'] );
+ $form['conf_evalphp'] = $this->registry->output->formTextarea( 'conf_evalphp' , $_POST['conf_evalphp'] ? $_POST['conf_evalphp'] : $conf['conf_evalphp'] );
+ $form['conf_keywords'] = $this->registry->output->formTextarea( 'conf_keywords' , $_POST['conf_keywords'] ? $_POST['conf_keywords'] : $conf['conf_keywords'] );
+ $form['conf_start_group'] = $this->registry->output->formInput( 'conf_start_group', $_POST['conf_start_group'] ? $_POST['conf_start_group'] : $conf['conf_start_group'] );
+ $form['conf_add_cache'] = $this->registry->output->formYesNo( 'conf_add_cache', $_POST['conf_add_cache'] ? $_POST['conf_add_cache'] : $conf['conf_add_cache'] );
+
+ if ( IN_DEV )
+ {
+ $form['conf_protected'] = $this->registry->output->formYesNo( 'conf_protected', $_POST['conf_protected'] ? $_POST['conf_protected'] : $conf['conf_protected'] );
+ }
+
+
+
+ //-----------------------------------------
+ // start form
+ //-----------------------------------------
+
+ $this->registry->output->html .= $this->html->settings_form( $form, $title, $formcode, $button );
+ }
+
+ /**
+ * View all settings (form) in a group
+ * This is public so that portal can access it
+ *
+ * @return @e void
+ */
+ public function _viewSettings()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $search_key = trim( $this->request['search'] );
+ $conf_group = trim( $this->request['conf_group'] );
+ $conf_titles = array();
+ $last_conf_id = -1;
+ $start = intval( $this->request['st'] );
+ $end = 150;
+ $get_by_key = isset( $this->request['conf_title_keyword'] ) ? $this->request['conf_title_keyword'] : '';
+
+ //-----------------------------------------
+ // Get settings in group
+ //-----------------------------------------
+
+ $this->_settingsGetGroups( ( $get_by_key ) ? TRUE : FALSE );
+
+ //-----------------------------------------
+ // Grabbing by key?
+ //-----------------------------------------
+
+ if( $get_by_key )
+ {
+ $data = $this->DB->buildAndFetch( array(
+ 'select' => 'conf_title_id, conf_title_keyword, conf_title_title',
+ 'from' => 'core_sys_settings_titles',
+ 'where' => "conf_title_keyword='{$get_by_key}'"
+ ) );
+
+ $this->request['conf_group'] = $data['conf_title_id'] ;
+ $conf_group = $data['conf_title_id'];
+ $this->request['groupHelpKey'] = $data['conf_title_keyword'];
+ }
+
+ //-----------------------------------------
+ // check...
+ //-----------------------------------------
+
+ if( !$conf_group and !$search_key )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_nogroup'];
+ $this->_settingsOverview();
+ return;
+ }
+
+ //--------------------------------------
+ // Redirect to Nexus for ads
+ //--------------------------------------
+
+ if ( $this->setting_groups[ $conf_group ]['conf_title_keyword'] == 'adcodeintegration' and IPSLib::appIsInstalled('nexus') )
+ {
+ $this->registry->output->silentRedirect( $this->settings['base_url'] . 'app=nexus&module=promotion§ion=advertisements' );
+ }
+
+ //-----------------------------------------
+ // Pagination
+ //-----------------------------------------
+
+ $pages = $this->registry->output->generatePagination( array(
+ 'totalItems' => $this->setting_groups[$conf_group]['conf_title_count'],
+ 'itemsPerPage' => $end,
+ 'currentStartValue' => $start,
+ 'baseUrl' => $this->settings['base_url'] . "&{$this->form_code}&&search={$search_key}",
+ ) );
+
+
+ //-----------------------------------------
+ // Did we search?
+ //-----------------------------------------
+
+ if( $search_key )
+ {
+ $keywords = mb_strtolower($search_key);
+ $whereExtra = $conf_group ? " AND c.conf_group={$conf_group}" : '';
+
+ $this->DB->build( array(
+ 'select' => 'c.*',
+ 'from' => array( 'core_sys_conf_settings' => 'c' ),
+ 'where' => '(' . $this->DB->buildLower('c.conf_title') . " LIKE '%{$keywords}%' OR " . $this->DB->buildLower('c.conf_description') . " LIKE '%{$keywords}%' OR " . $this->DB->buildLower('c.conf_keywords') . " LIKE '%{$keywords}%')" . $whereExtra,
+ 'order' => 'c.conf_title',
+ 'limit' => array( $start, $end ),
+ 'add_join' => array(
+ array(
+ 'select' => 'ct.conf_title_id, ct.conf_title_noshow, ct.conf_title_title, ct.conf_title_tab',
+ 'from' => array( 'core_sys_settings_titles' => 'ct' ),
+ 'where' => 'ct.conf_title_id=c.conf_group',
+ 'type' => 'left'
+ )
+ )
+ ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $r['conf_start_group'] = "";
+ $r['conf_description'] .= ' ' . $this->lang->words['conf_desc_search'] . "" . $r['conf_title_title'] . " ";
+ $conf_entry[ $r['conf_id'] ] = $r;
+ }
+
+ if( ! count( $conf_entry ) )
+ {
+ $this->registry->output->global_message = sprintf( $this->lang->words['s_nomatches'], $keywords );
+ $this->_settingsOverview();
+ return;
+ }
+
+ $title = sprintf( $this->lang->words['s_searchedfor'], $keywords );
+ $tab = '';
+ }
+
+ //-----------------------------------------
+ // Or not...
+ //-----------------------------------------
+
+ else
+ {
+ $this->DB->build( array(
+ 'select' => '*',
+ 'from' => 'core_sys_conf_settings',
+ 'where' => "conf_group='{$conf_group}'",
+ 'order' => 'conf_position, conf_title',
+ 'limit' => array( $start,$end )
+ ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $conf_entry[ $r['conf_id'] ] = $r;
+ }
+
+ $title = $this->setting_groups[$conf_group]['conf_title_title'];
+ $tab = IPSText::md5Clean( $this->setting_groups[$conf_group]['conf_title_tab'] );
+ $this->request['groupHelpKey'] = $this->setting_groups[ $conf_group ]['conf_title_keyword'];
+ }
+
+ //-----------------------------------------
+ // Start output
+ //-----------------------------------------
+
+ $content = "";
+
+ if( is_array( $conf_entry ) and count( $conf_entry ) )
+ {
+ foreach( $conf_entry as $id => $r )
+ {
+ $content .= $this->_processSettingEntry( $r );
+ }
+ }
+
+ if( ! $search_key AND ! $get_by_key )
+ {
+ $searchbutton = 1;
+ }
+
+ if ( ! $this->registry->output->ignoreCoreNav ) // Bug #39467
+ {
+ /* Navigation */
+ if( $this->base_nav_url )
+ {
+ $this->registry->output->extra_nav[] = array( $this->base_nav_url, ipsRegistry::$applications[ $this->setting_groups[$conf_group]['conf_title_app'] ]['app_title'] );
+ $this->registry->output->extra_nav[] = array( "", $title );
+
+ }
+ else if( $tab )
+ {
+ $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&_dtab={$tab}", $this->setting_groups[$conf_group]['conf_title_tab'] ? $this->setting_groups[$conf_group]['conf_title_tab'] : ipsRegistry::$applications[ $this->setting_groups[$conf_group]['conf_title_app'] ]['app_title'] );
+ $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=setting_view&conf_group={$conf_group}", $title );
+ }
+ else
+ {
+ $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&_dtab=System", $this->setting_groups[$conf_group]['conf_title_tab'] ? $this->setting_groups[$conf_group]['conf_title_tab'] : ipsRegistry::$applications[ $this->setting_groups[$conf_group]['conf_title_app'] ]['app_title'] );
+ $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=setting_view&conf_group={$conf_group}", $title );
+ }
+ }
+
+ /* Output */
+ $this->registry->output->html .= $this->html->settings_view_wrapper( $title, $content, $searchbutton, $this->return_after_save );
+ $this->registry->output->html = str_replace( '', " ", $this->registry->output->html );
+ }
+
+ /**
+ * Process an individual setting for display
+ *
+ * @param array Setting record
+ * @return @e void
+ */
+ public function _processSettingEntry($r)
+ {
+ /* Init editor class */
+ if ( !is_object($this->editor) )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $this->editor = new $classToLoad();
+ }
+
+ /* Init vars */
+ $tempSkinUrl = $this->settings['skin_app_url'];
+ $this->settings['skin_app_url'] = $this->settings['_original_base_url'] . '/' . CP_DIRECTORY . '/applications/core/skin_cp/' ;
+ $form_element = "";
+ $form_type = 'normal';
+ $dropdown = array();
+ $start = "";
+ $revert_button = "";
+
+ $key = $r['conf_key'];
+ $value = $r['conf_value'] != "" ? $r['conf_value'] : $r['conf_default'];
+ $value = $value == "{blank}" ? '' : $value;
+
+ $show = 1;
+
+ //-----------------------------------------------
+ // Default?
+ //-----------------------------------------------
+
+ $css = "";
+
+ if ( $r['conf_value'] != "" and ( $r['conf_value'] != $r['conf_default'] ) )
+ {
+ $revert_button = "form_code}&do=setting_revert&id={$r['conf_id']}&conf_group={$r['conf_group']}&search=" . $this->request['search'] . "' title='{$this->lang->words['s_revertback']}'>{$this->lang->words['revert']} ";
+ }
+
+ //-----------------------------------------------
+ // Evil eval
+ //-----------------------------------------------
+
+ if ( $r['conf_evalphp'] )
+ {
+
+ $r['conf_evalphp'] = str_replace( '\', '\\', $r['conf_evalphp'] );
+ $show = 1;
+
+ eval( $r['conf_evalphp'] );
+ }
+
+ if( ! $show && ! IN_DEV )
+ {
+ return '';
+ }
+
+ switch( $r['conf_type'] )
+ {
+ case 'input':
+ $form_element = $this->registry->output->formInput( $key, str_replace( "'", "'", $value ) );
+ break;
+
+ case 'textarea':
+ $form_element = $this->registry->output->formTextarea( $key, str_replace( "\", "\", IPSText::textToForm($value) ), 45 );
+ break;
+
+ case 'editor':
+ //$this->editor->setIsHtml( true );
+ $this->editor->setContent( $value );
+
+ $form_element = $this->editor->show( $key, array( 'minimize' => 1 ) );
+ $form_type = 'rte';
+
+ break;
+
+ case 'yes_no':
+ $form_element = $this->registry->output->formYesNo( $key, $value );
+ break;
+
+ case 'name_autocomplete':
+ $form_element = $this->html->nameAutoCompleteField( $key, $value );
+ break;
+
+ default:
+
+ if ( $r['conf_extra'] )
+ {
+ if ( $r['conf_extra'] == '#show_forums#' )
+ {
+ //-----------------------------------------
+ // Require the library
+ // (Not a building with books)
+ //-----------------------------------------
+
+ require_once( IPSLib::getAppDir( 'forums' ) .'/sources/classes/forums/class_forums.php' );/*noLibHook*/
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) .'/sources/classes/forums/admin_forum_functions.php', 'admin_forum_functions', 'forums' );
+
+ $aff = new $classToLoad( $this->registry );
+ $aff->forumsInit();
+ $dropdown = $aff->adForumsForumList(1);
+ }
+ else if ( $r['conf_extra'] == '#show_groups#' )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'groups', 'order' => 'g_title ASC' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ if ( $row['g_access_cp'] )
+ {
+ $row['g_title'] .= ' ' . $this->lang->words['setting_staff_tag'] . ' ';
+ }
+
+ $dropdown[] = array( $row['g_id'], $row['g_title'] );
+ }
+ }
+ else if ( $r['conf_extra'] == '#show_applications#' )
+ {
+ foreach( ipsRegistry::$applications as $app )
+ {
+ $dropdown[] = array( $app['app_directory'], $app['app_title'] );
+ }
+ }
+ else if ( $r['conf_extra'] == '#show_skins#' )
+ {
+ $dropdown = $this->registry->output->generateSkinDropdown();
+ }
+ else
+ {
+ foreach( explode( "\n", $r['conf_extra'] ) as $l )
+ {
+ list ($k, $v) = explode( "=", $l );
+ if ( $k != "" and $v != "" )
+ {
+ $dropdown[] = array( trim($k), trim($v) );
+ }
+ }
+ }
+ }
+
+ if ( $r['conf_type'] == 'dropdown' )
+ {
+ $form_element = $this->registry->output->formDropdown( $key, $dropdown, $value );
+ }
+ else
+ {
+ $form_element = $this->registry->output->formMultiDropdown( $key, $dropdown, explode( ",", $value ) );
+ }
+
+ break;
+ }
+
+ $delete = "form_code}&do=setting_delete&id={$r['conf_id']}\");' title='key: {$r['conf_key']}'>{$this->lang->words['delete']} ";
+ $edit = "form_code}&do=setting_showedit&id={$r['conf_id']}' title='id: {$r['conf_id']}'>{$this->lang->words['edit']} ";
+
+ if ( $r['conf_protected'] and ! IN_DEV )
+ {
+ $delete = "";
+ $edit = "";
+ }
+
+ if ( $r['conf_start_group'] )
+ {
+ $start = $this->html->settings_row_start_group( $r );
+ }
+
+ $r['conf_description'] = str_replace( '{ACP_URL}', $this->settings['_base_url'], $r['conf_description'] );
+
+ //-----------------------------------------------
+ // Search hi-lite
+ //-----------------------------------------------
+
+ if ( $this->request['search'] )
+ {
+ $_replacements = array();
+
+ preg_match_all( "/(&([a-zA-Z0-9]+);)/i", $r['conf_title'], $matches );
+
+ if( count($matches[0]) )
+ {
+ for( $i=0, $cnt=count($matches[0]); $i <= $cnt; $i++ )
+ {
+ $r['conf_title'] = str_replace( $matches[0][$i], '{{{' . $i . '}}}', $r['conf_title'] );
+ }
+ }
+
+ $r['conf_title'] = preg_replace( "/(". str_replace( '/', '\\/', $this->request['search'] ) .")/i", "\\1 ", $r['conf_title'] );
+
+ if( count($matches[0]) )
+ {
+ for( $i=0, $cnt=count($matches); $i <= $cnt; $i++ )
+ {
+ $r['conf_title'] = str_replace( '{{{' . $i . '}}}', $matches[0][$i], $r['conf_title'] );
+ }
+ }
+
+ /**
+ * Ok this is just annoying....
+ */
+ $_did = 0;
+ preg_match_all( "/(href=['\"].*?[\"'])/i", $r['conf_description'], $matches );
+
+ if( count($matches[0]) )
+ {
+ for( $i=$_did, $cnt=count($matches[0]); $i <= $cnt; $i++ )
+ {
+ $r['conf_description'] = str_replace( $matches[0][$i], '{{{' . $i . '}}}', $r['conf_description'] );
+
+ $_replacements[ $i ] = $matches[0][$i];
+ $_did++;
+ }
+ }
+
+ preg_match_all( "/(&([a-zA-Z0-9]+);)/i", $r['conf_description'], $matches );
+
+ if( count($matches[0]) )
+ {
+ for( $i=$_did, $cnt=count($matches[0]); $i <= $cnt; $i++ )
+ {
+ $r['conf_description'] = str_replace( $matches[0][$i], '{{{' . $i . '}}}', $r['conf_description'] );
+
+ $_replacements[ $i ] = $matches[0][$i];
+ $_did++;
+ }
+ }
+
+ $r['conf_description'] = preg_replace( "/(". str_replace( '/', '\\/', $this->request['search'] ) .")/i", "\\1 ", $r['conf_description'] );
+
+ if( count($_replacements) )
+ {
+ foreach( $_replacements as $index => $val )
+ {
+ $r['conf_description'] = str_replace( '{{{' . $index . '}}}', $val, $r['conf_description'] );
+ }
+ }
+ }
+
+ $html .= $start . $this->html->settings_view_row( $r, $edit, $delete, $form_element, $revert_button, $form_type );
+
+ $this->key_array[] = preg_replace( '/\[\]$/', "", $key );
+
+ $this->settings[ 'skin_app_url'] = $tempSkinUrl ;
+
+ return $html;
+ }
+
+ /**
+ * View setting groups
+ *
+ * @param string Application to default to
+ * @return @e void
+ */
+ protected function _settingsOverview( $start_app='' )
+ {
+ $content = "";
+ $title = "";
+ $settings = array();
+ $start_app = ( $start_app ) ? $start_app : trim( $this->request['start_app'] );
+
+ //-----------------------------------------
+ // Get the groups
+ //-----------------------------------------
+
+ $this->_settingsGetGroups();
+
+ //-----------------------------------------
+ // Build settings..
+ //-----------------------------------------
+
+ foreach( $this->setting_groups as $i => $r )
+ {
+ $r['conf_title_app'] = ( $r['conf_title_app'] ) ? $r['conf_title_app'] : 'core';
+ $r['conf_title_tab'] = ( $r['conf_title_tab'] ) ? $r['conf_title_tab'] : 'System';
+ $r['conf_title_title'] = ( $r['conf_title_noshow'] ) ? $r['conf_title_title'] . ' ' . $this->lang->words['s_ishidden'] : $r['conf_title_title'];
+
+ $settings[ $r['conf_title_tab'] ][] = $r;
+ }
+
+ $this->registry->output->html .= $this->html->settings_titles_wrapper( $settings, $start_app );
+ }
+
+ /**
+ * Update setting values/ordering
+ *
+ * @param boolean Return afterwards?
+ * @return @e void
+ */
+ protected function _updateSettings( $donothing="" )
+ {
+ /* Init vars */
+ $bounceback = str_replace( '&', '&', $this->request['bounceback'] );
+
+ /* Check for something to save... */
+ if ( ! $this->request['id'] and ! $this->request['search'] AND !$this->request['settings_save'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_noid'];
+ $this->_settingsOverview();
+ return;
+ }
+
+ /* ...and check for fields */
+ $fields = explode( ",", trim($this->request['settings_save']) );
+
+ if ( ! count($fields ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_nofields'];
+ $this->_viewSettings();
+ return;
+ }
+
+ /* Init editor class */
+ if ( !is_object($this->editor) )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $this->editor = new $classToLoad();
+ }
+
+ //--------------------------------------------
+ // Update
+ //--------------------------------------------
+
+ $update = array();
+ foreach ( $fields as $f )
+ {
+ $update[ $f ] = $_POST[ $f ];
+ }
+
+ IPSLib::updateSettings( $update, TRUE );
+
+ $this->request['conf_group'] = $this->request['id'];
+ $this->registry->output->global_message = $this->lang->words['s_updated'];
+
+ //-----------------------------------------
+ // We're bouncing back (Boing boing)
+ //-----------------------------------------
+
+ if ( $bounceback )
+ {
+ $this->registry->output->silentRedirectWithMessage( $bounceback );
+ }
+
+ //-----------------------------------------
+ // Still here?
+ //-----------------------------------------
+
+
+ if ( ! $donothing )
+ {
+ $this->_viewSettings();
+ }
+ }
+
+ /**
+ * Save the settings form
+ *
+ * @param string [add|edit]
+ * @return @e void
+ */
+ protected function _settingSave($type='add')
+ {
+ if ( $type == 'edit' )
+ {
+ if ( ! $this->request['id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_noid'];
+ $this->_settingForm();
+ return;
+ }
+ }
+
+ //--------------------------------------------
+ // check...
+ //--------------------------------------------
+
+ $conf_group = $this->request['conf_newgroup'] ? $this->request['conf_newgroup'] : $this->request['conf_group'];
+
+ $array = array( 'conf_title' => $this->request['conf_title'],
+ 'conf_description' => IPSText::stripslashes( $_POST['conf_description'] ),
+ 'conf_group' => $this->request['conf_group'],
+ 'conf_type' => $this->request['conf_type'],
+ 'conf_key' => str_replace( '-', '_', IPSText::alphanumericalClean( $this->request['conf_key'] ) ),
+ 'conf_value' => IPSText::stripslashes( $_POST['conf_value'] ),
+ 'conf_default' => IPSText::stripslashes( $_POST['conf_default'] ),
+ 'conf_extra' => IPSText::stripslashes( $_POST['conf_extra'] ),
+ 'conf_evalphp' => IPSText::stripslashes( $_POST['conf_evalphp'] ),
+ 'conf_protected' => intval( $this->request['conf_protected'] ),
+ 'conf_position' => intval( $this->request['conf_position'] ),
+ 'conf_start_group' => $this->request['conf_start_group'],
+ 'conf_add_cache' => intval( $this->request['conf_add_cache'] ),
+ 'conf_keywords' => IPSText::stripslashes( $_POST['conf_keywords'] ),
+ );
+
+ //-----------------------------------------
+ // Do we have a title and key?
+ //-----------------------------------------
+
+ if( !$array['conf_title'] OR !$array['conf_key'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_missing_key_data'];
+ $this->_settingForm();
+ return;
+ }
+
+ if ( $type == 'add' )
+ {
+ //-----------------------------------------
+ // Is the key already in use?
+ //-----------------------------------------
+
+ if ( $this->settings[ $array['conf_key'] ] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_keyinuse_already'];
+ $this->_settingForm();
+ return;
+ }
+
+ $this->DB->insert( 'core_sys_conf_settings', $array );
+ $this->registry->output->global_message = $this->lang->words['s_added2'];
+ }
+ else
+ {
+ $conf = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id=' . $this->request['id'] ) );
+
+ $this->DB->update( 'core_sys_conf_settings', $array, 'conf_id=' . $this->request['id'] );
+ $this->registry->output->global_message = $this->lang->words['s_edited2'];
+
+ // Recount old group
+ $this->_resynchGroup( $conf['conf_group'] );
+ }
+
+ //-----------------------------------------
+ // Recount new group
+ //-----------------------------------------
+
+ if( $this->request['conf_group'] )
+ {
+ $this->_resynchGroup( $this->request['conf_group'] );
+ }
+
+ $this->settingsRebuildCache();
+
+ $this->_viewSettings();
+ }
+
+ /**
+ * Revert a setting to the default value
+ *
+ * @return @e void
+ */
+ protected function _revertSettings()
+ {
+ $this->request[ 'id'] = intval($this->request['id'] );
+
+ if ( ! $this->request['id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_noid'];
+ $this->_settingForm();
+ return;
+ }
+
+ $conf = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id=' . $this->request['id'] ) );
+
+ //--------------------------------------------
+ // Revert...
+ //--------------------------------------------
+
+ IPSLib::updateSettings( array( $conf['conf_key'] => $conf['conf_default'] ) );
+
+ $this->registry->output->global_message = $this->lang->words['s_revertedback'];
+
+ $this->settingsRebuildCache();
+
+ //-----------------------------------------
+ // Boink
+ //-----------------------------------------
+
+ $referrer = my_getenv('HTTP_REFERER');
+
+ if ( strstr( $referrer, $this->settings['_admin_link'] ) and !strstr( $referrer, 'app=core&module=settings§ion=settings' ) )
+ {
+ $this->registry->output->silentRedirect( $referrer );
+ return;
+ }
+ else
+ {
+ $this->_viewSettings();
+ }
+
+ }
+
+ /**
+ * Delete a setting
+ *
+ * @return @e void
+ */
+ protected function _deleteSettings()
+ {
+ if ( ! $this->request['id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_noid'];
+ $this->_settingsOverview();
+ return;
+ }
+
+ $conf = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_id=' . $this->request['id'] ) );
+
+ if ( ! $conf['conf_id'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['s_noid'];
+ $this->_settingsOverview();
+ return;
+ }
+
+ //--------------------------------------------
+ // Delete...
+ //--------------------------------------------
+
+ $this->DB->delete( 'core_sys_conf_settings', 'conf_id=' . $this->request['id'] );
+
+ $this->DB->update( 'core_sys_settings_titles', 'conf_title_count=conf_title_count-1', 'conf_title_id=' . $conf['conf_group'], false, true );
+
+ $this->registry->output->global_message = $this->lang->words['s_deleted'];
+
+ $this->settingsRebuildCache();
+
+ $this->_settingsOverview();
+ }
+
+
+ /**
+ * Rebuild settings cache
+ *
+ * @return @e void
+ */
+ public function settingsRebuildCache()
+ {
+ $settings = array();
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => 'conf_add_cache=1' ) );
+ $info = $this->DB->execute();
+
+ while ( $r = $this->DB->fetch($info) )
+ {
+ $value = $r['conf_value'] != "" ? $r['conf_value'] : $r['conf_default'];
+
+ if ( $value == '{blank}' )
+ {
+ $value = '';
+ }
+
+ $settings[ $r['conf_key'] ] = $value;
+ }
+
+ $this->cache->setCache( 'settings', $settings, array( 'array' => 1 ) );
+ }
+
+ /**
+ * Grab all setting groups and store in an internal array
+ *
+ * @param boolean Pull all settings, not just visible ones
+ * @return @e void
+ */
+ protected function _settingsGetGroups( $ignoreInDev=false )
+ {
+ $this->setting_groups = array();
+
+ if ( IN_DEV OR $ignoreInDev )
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'order' => 'conf_title_title' ) );
+ $this->DB->execute();
+ }
+ else
+ {
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'where' => 'conf_title_noshow=0', 'order' => 'conf_title_title' ) );
+ $this->DB->execute();
+ }
+
+ while( $r = $this->DB->fetch() )
+ {
+ $this->setting_groups[ $r['conf_title_id'] ] = $r;
+ $this->setting_groups_by_key[ $r['conf_title_keyword'] ] = $r;
+ }
+ }
+
+ /**
+ * Make sure all titles have keywords set
+ *
+ * @return @e void
+ */
+ protected function _settingsTitlesCheck()
+ {
+ //-----------------------------------------
+ // Get 'em
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles' ) );
+ $outer = $this->DB->execute();
+
+ while( $row = $this->DB->fetch( $outer ) )
+ {
+ if ( ! $row['conf_title_keyword'] )
+ {
+ $new_keyword = mb_strtolower( preg_replace( '#[^\d\w]#', "", $row['conf_title_title'] ) );
+ $this->DB->update( 'core_sys_settings_titles', array( 'conf_title_keyword' => $new_keyword ), 'conf_title_id='.$row['conf_title_id'] );
+ }
+ }
+ }
+
+ /**
+ * Import XML Settings on an app by app basis
+ *
+ * @return array Array of messages
+ */
+ public function importAllApps()
+ {
+ $message = array();
+
+ foreach( ipsRegistry::$applications as $app_dir => $app_data )
+ {
+ $file = IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml';
+
+ if ( is_file( $file ) )
+ {
+ $contents = file_get_contents( $file );
+
+ $return = $this->_importXML( $contents, $app_dir );
+
+ $message[] = $app_data['app_title'] . " " . sprintf( $this->lang->words['s_upandin'], $return['updatedCount'], $return['insertedCount'] );
+
+ /* In dev time stamp? */
+ if ( IN_DEV )
+ {
+ $cache = $this->caches['indev'];
+ $cache['import']['settings'][ $app_dir ] = time();
+ $this->cache->setCache( 'indev', $cache, array( 'donow' => 1, 'array' => 1 ) );
+ }
+ }
+ }
+
+ /* Check for settings not needed anymore */
+ $this->_loadDeleteList();
+
+ return $message;
+ }
+
+ /**
+ * Import XML Settings
+ *
+ * @param string XML Data
+ * @param string Application (should be set by XML file, however)
+ * @param array Array of any known settings and their values
+ * @return array array( 'insertedCount' => x, 'updatedCount' => x, 'updatedKeys' => array(..), 'insertedKeys' => array() )
+ */
+ protected function _importXML( $content, $app='core', $knownSettings=array() )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $cur_settings = array();
+ $updated = 0;
+ $inserted = 0;
+ $updatedKeys = array();
+ $insertedKeys = array();
+ $known = array();
+
+ //-----------------------------------------
+ // Get current settings.
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'conf_id, conf_key',
+ 'from' => 'core_sys_conf_settings',
+ 'order' => 'conf_id' ) );
+
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ $cur_settings[ $r['conf_key'] ] = $r['conf_id'];
+ }
+
+ //-----------------------------------------
+ // Get current titles
+ //-----------------------------------------
+
+ $this->_settingsGetGroups( true );
+
+ //-----------------------------------------
+ // Get xml class
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
+
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+ $xml->loadXML( $content );
+
+ //-----------------------------------------
+ // Loop through and sort out settings...
+ //-----------------------------------------
+
+ foreach( $xml->fetchElements('setting') as $setting )
+ {
+ $entry = $xml->fetchElementsFromRecord( $setting );
+
+ //-----------------------------------------
+ // Is setting?
+ //-----------------------------------------
+
+ if ( ! $entry['conf_is_title'] )
+ {
+ unset( $entry['conf_is_title'] );
+ unset( $entry['conf_help_key'] );
+ unset( $entry['conf_id'] );
+ unset( $entry['conf_end_group'] );
+ $new_settings[] = $entry;
+ }
+
+ //-----------------------------------------
+ // Is title?
+ //-----------------------------------------
+
+ else
+ {
+ $new_titles[] = $entry;
+ }
+ }
+
+ //-----------------------------------------
+ // Sort out titles...
+ //-----------------------------------------
+
+ if ( is_array( $new_titles ) and count( $new_titles ) )
+ {
+ foreach( $new_titles as $idx => $data )
+ {
+ if ( $data['conf_title_title'] AND $data['conf_title_keyword'] )
+ {
+ //-----------------------------------------
+ // Get ID based on key
+ //-----------------------------------------
+
+ $conf_id = $this->setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
+
+ $save = array( 'conf_title_title' => $data['conf_title_title'],
+ 'conf_title_desc' => $data['conf_title_desc'],
+ 'conf_title_keyword' => $data['conf_title_keyword'],
+ 'conf_title_tab' => $data['conf_title_tab'],
+ 'conf_title_app' => $data['conf_title_app'] ? $data['conf_title_app'] : $app,
+ 'conf_title_noshow' => $data['conf_title_noshow'] );
+
+ //-----------------------------------------
+ // Not got a row, insert first!
+ //-----------------------------------------
+
+ if ( ! $conf_id )
+ {
+ $this->DB->insert( 'core_sys_settings_titles', $save );
+ $conf_id = $this->DB->getInsertId();
+
+ }
+ else
+ {
+ //-----------------------------------------
+ // Update...
+ //-----------------------------------------
+
+ $this->DB->update( 'core_sys_settings_titles', $save, 'conf_title_id='.$conf_id );
+ }
+
+ //-----------------------------------------
+ // Update settings cache
+ //-----------------------------------------
+
+ $save['conf_title_id'] = $conf_id;
+ $this->setting_groups_by_key[ $save['conf_title_keyword'] ] = $save;
+ $this->setting_groups[ $save['conf_title_id'] ] = $save;
+
+ //-----------------------------------------
+ // Remove need update...
+ //-----------------------------------------
+
+ $need_update[] = $conf_id;
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Sort out settings
+ //-----------------------------------------
+
+ if ( is_array( $new_settings ) and count( $new_settings ) )
+ {
+ foreach( $new_settings as $idx => $data )
+ {
+ //-----------------------------------------
+ // Insert known
+ //-----------------------------------------
+
+ $data['conf_value'] = '';
+
+ if( is_array($knownSettings) AND count($knownSettings) )
+ {
+ if ( ! $data['conf_value'] AND ( in_array( $data['conf_key'], array_keys( $knownSettings ) ) ) )
+ {
+ $data['conf_value'] = $knownSettings[ $data['conf_key'] ];
+ }
+ }
+
+ $data['conf_group'] = $this->setting_groups_by_key[ $data['conf_title_keyword'] ]['conf_title_id'];
+
+ //-----------------------------------------
+ // Remove from array
+ //-----------------------------------------
+
+ unset( $data['conf_title_keyword'] );
+
+ if ( $cur_settings[ $data['conf_key'] ] )
+ {
+ //-----------------------------------------
+ // Don't change the setting value
+ //-----------------------------------------
+ unset( $data['conf_value'] );
+
+ //-----------------------------------------
+ // Update
+ //-----------------------------------------
+
+ $this->DB->update( 'core_sys_conf_settings', $data, 'conf_id='.$cur_settings[ $data['conf_key'] ] );
+ $updatedKeys[] = $data['conf_key'];
+ $updated++;
+ }
+ else
+ {
+ //-----------------------------------------
+ // INSERT
+ //-----------------------------------------
+
+ $this->DB->insert( 'core_sys_conf_settings', $data );
+ $insertedKeys[] = $data['conf_key'];
+ $inserted++;
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Update group counts...
+ //-----------------------------------------
+
+ if ( count( $need_update ) )
+ {
+ foreach( $need_update as $i => $idx )
+ {
+ $conf = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'core_sys_conf_settings', 'where' => 'conf_group='.$idx ) );
+
+ $count = intval($conf['count']);
+
+ $this->DB->update( 'core_sys_settings_titles', array( 'conf_title_count' => $count ), 'conf_title_id='.$idx );
+ }
+ }
+
+ //-----------------------------------------
+ // Resync
+ //-----------------------------------------
+
+ $this->settingsRebuildCache();
+
+ //-----------------------------------------
+ // Return
+ //-----------------------------------------
+
+ return array( 'insertedCount' => $inserted,
+ 'updatedCount' => $updated,
+ 'insertedKeys' => $insertedKeys,
+ 'updatedKeys' => $updatedKeys );
+ }
+
+ /**
+ * Export all apps: Wrapper function really. Yes. It is.
+ *
+ * @return array Array of messages or errors
+ */
+ public function exportAllApps()
+ {
+ $messages = array();
+ $errors = array();
+
+ /* Check for settings not needed anymore */
+ $this->_loadDeleteList();
+
+ foreach( ipsRegistry::$applications as $app_dir => $app_data )
+ {
+ @unlink( IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml' );
+
+ if ( ! is_dir( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
+ {
+ $errors[] = "Error: " . IPSLib::getAppDir( $app_dir ) . "/xml/ does not exist";
+ continue;
+ }
+ else if ( ! IPSLib::isWritable( IPSLib::getAppDir( $app_dir ) . '/xml' ) )
+ {
+ if ( ! @chmod( IPSLib::isWritable( IPSLib::getAppDir( $app_dir ) . '/xml', 0755 ) ) )
+ {
+ $errors[] = "Error: " . IPSLib::getAppDir( $app_dir ) . "/xml/ is not writeable";
+ continue;
+ }
+ }
+ else if ( is_file( IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml' ) AND ! IPSLib::isWritable( IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml' ) )
+ {
+ $errors[] = "Error: " . IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . "_settings.xml is not writeable";
+ continue;
+ }
+
+ $this->_exportXML( $app_dir );
+
+ $messages[] = $app_data['app_title'] . " Settings written into the application's XML directory";
+
+ /* In dev time stamp? */
+ if ( IN_DEV )
+ {
+ $cache = $this->caches['indev'];
+ $cache['import']['settings'][ $app_dir ] = time();
+ $this->cache->setCache( 'indev', $cache, array( 'donow' => 1, 'array' => 1 ) );
+ }
+ }
+
+ return $errors ? $errors : $messages;
+ }
+
+
+ /**
+ * Export all settings to XML (IN_DEV mode)
+ *
+ * @param string Application directory
+ * @return boolean
+ */
+ protected function _exportXML( $app_dir='core' )
+ {
+ //-----------------------------------------
+ // Get setting groups
+ //-----------------------------------------
+
+ $this->_settingsGetGroups( true );
+
+ //-----------------------------------------
+ // Get xml class
+ //-----------------------------------------
+
+ require_once( IPS_KERNEL_PATH.'classXML.php' );/*noLibHook*/
+
+ $xml = new classXML( IPS_DOC_CHAR_SET );
+
+ $xml->newXMLDocument();
+ $xml->addElement( 'settingexport' );
+ $xml->addElement( 'settinggroup', 'settingexport' );
+
+ foreach( $this->setting_groups as $i => $roar )
+ {
+ //-----------------------------------------
+ // App check?
+ //-----------------------------------------
+
+ if ( $app_dir != $roar['conf_title_app'] )
+ {
+ continue;
+ }
+
+ //-----------------------------------------
+ // First, add in setting group title
+ //-----------------------------------------
+
+ $thisconf = array( 'conf_is_title' => 1,
+ 'conf_title_keyword' => $roar['conf_title_keyword'],
+ 'conf_title_title' => $roar['conf_title_title'],
+ 'conf_title_desc' => $roar['conf_title_desc'],
+ 'conf_title_tab' => $roar['conf_title_tab'],
+ 'conf_title_app' => $roar['conf_title_app'] ? $roar['conf_title_app'] : $app_dir,
+ 'conf_title_noshow' => $roar['conf_title_noshow'] );
+
+ $xml->addElementAsRecord( 'settinggroup', 'setting', $thisconf );
+
+ //-----------------------------------------
+ // Get settings...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'core_sys_conf_settings',
+ 'where' => "conf_group='{$roar['conf_title_id']}'",
+ 'order' => 'conf_position, conf_title' ) );
+
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ //-----------------------------------------
+ // Clean up...
+ //-----------------------------------------
+
+ unset( $r['conf_value'], $r['conf_group'], $r['conf_id'] );
+
+ $r['conf_title_keyword'] = $roar['conf_title_keyword'];
+ $r['conf_is_title'] = 0;
+
+ $xml->addElementAsRecord( 'settinggroup', 'setting', $r );
+ }
+ }
+
+ //-----------------------------------------
+ // Grab the XML document
+ //-----------------------------------------
+
+ $xmlData = $xml->fetchDocument();
+
+ //-----------------------------------------
+ // Attempt to write...
+ //-----------------------------------------
+
+ $file = IPSLib::getAppDir( $app_dir ) . '/xml/' . $app_dir . '_settings.xml';
+
+ @unlink( $file );
+ @file_put_contents( $file, $xmlData );
+ @chmod( $file, IPS_FOLDER_PERMISSION );
+ }
+
+ /**
+ * Load and parse settings delete list (IN_DEV)
+ *
+ * @return @e void
+ */
+ protected function _loadDeleteList()
+ {
+ if ( IN_DEV )
+ {
+ /* Check for group settings */
+ if ( is_file( DOC_IPS_ROOT_PATH . '_deleteGroupSettings.txt' ) )
+ {
+ $notTheseGroups = file( DOC_IPS_ROOT_PATH . '_deleteGroupSettings.txt' );
+
+ if ( count($notTheseGroups) )
+ {
+ $notTheseGroups = array_map('trim', $notTheseGroups);
+
+ $this->DB->build( array( 'select' => 'conf_title_id', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_keyword IN ('" . implode("','", $notTheseGroups) . "')" ) );
+ $this->DB->execute();
+
+ if ( $this->DB->getTotalRows() )
+ {
+ $_deleteTheseGroups = array();
+
+ while( $s = $this->DB->fetch() )
+ {
+ $_deleteTheseGroups[] = $s['conf_title_id'];
+ }
+
+ if ( count($_deleteTheseGroups) )
+ {
+ $this->DB->delete( 'core_sys_conf_settings', 'conf_group IN (' . implode(',', $_deleteTheseGroups) . ')' );
+ $this->DB->delete( 'core_sys_settings_titles', "conf_title_keyword IN ('" . implode("','", $notTheseGroups) . "')" );
+ }
+ }
+ }
+ }
+
+ /* Check for single settings */
+ if ( is_file( DOC_IPS_ROOT_PATH . '_deleteSettings.txt' ) )
+ {
+ $notTheseSettings = file( DOC_IPS_ROOT_PATH . '_deleteSettings.txt' );
+
+ if ( count($notTheseSettings) )
+ {
+ $notTheseSettings = array_map('trim', $notTheseSettings);
+
+ $this->DB->delete( 'core_sys_conf_settings', "conf_key IN('" . implode( "','", $notTheseSettings ) . "')" );
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/settings/xml/menu.xml b/upload/admin/applications/core/modules_admin/settings/xml/menu.xml
index 9018c226..48a60c75 100644
--- a/upload/admin/applications/core/modules_admin/settings/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/settings/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
System Settings
+ Системные Настройки
- System Settings
+ Системные Настройки
settings
settings
do=settingsview
diff --git a/upload/admin/applications/core/modules_admin/settings/xml/permissions.xml b/upload/admin/applications/core/modules_admin/settings/xml/permissions.xml
index 3ace6faf..405a70de 100644
--- a/upload/admin/applications/core/modules_admin/settings/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/settings/xml/permissions.xml
@@ -1,24 +1,16 @@
- Manage Settings
+ Настройки системы
core_settings
-
settings_manage
- Can edit/add settings and setting groups?
+ Может изменять/добавлять группы настроек?
-
settings_delete
- Can delete settings and setting groups?
-
- -
-
performance_toggle
- Can toggle performance mode?
-
- -
-
licensekey_manage
- Can manage license key?
+ Может удалять группы настроек?
diff --git a/upload/admin/applications/core/modules_admin/sql/defaultSection.php b/upload/admin/applications/core/modules_admin/sql/defaultSection.php
index 6119d75a..32c9d5e1 100644
--- a/upload/admin/applications/core/modules_admin/sql/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/sql/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/sql/mysql.php b/upload/admin/applications/core/modules_admin/sql/mysql.php
index c76b0a02..7c75c3fe 100644
--- a/upload/admin/applications/core/modules_admin/sql/mysql.php
+++ b/upload/admin/applications/core/modules_admin/sql/mysql.php
@@ -3,18 +3,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* mySQL Admin
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-01-23 21:10:55 -0500 (Wed, 23 Jan 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11891 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -188,14 +188,8 @@ class admin_core_sql_toolbox_module extends ipsCommand {
$this->registry->output->showError( $this->lang->words['my_cantdo'], 2114, true );
}
- /**
- * Rikki wants a stupid template so we can output his stupid header. Yes, this creates more work for me.
- * This template serves no other purpose than to make Rikki happy. Must make Rikki happy. Rikki gets cranky when he's not happy.
- *
- * Ask him about roundabouts sometime. Apparently...they're round.
- */
- $this->registry->output->html .= $this->html->sqlToolResultHeader();
-
+ $output = '';
+
/* Loop through each table and run the tool */
foreach( $tables as $table )
{
@@ -224,8 +218,25 @@ class admin_core_sql_toolbox_module extends ipsCommand {
}
/* Add to output */
- $this->registry->output->html .= $this->html->sqlToolResult( $this->lang->words['resultprefix'] . $this->request['tool'] . " " . $table, $columns, $rows );
+ $output .= $this->html->sqlToolResult( $columns, $rows );
}
+
+ /**
+ * Rikki wants a stupid template so we can output his stupid header. Yes, this creates more work for me.
+ * This template serves no other purpose than to make Rikki happy. Must make Rikki happy. Rikki gets cranky when he's not happy.
+ *
+ * Ask him about roundabouts sometime. Apparently...they're round.
+ */
+ $this->registry->output->html .= $this->html->sqlToolResultHeader( $columns );
+
+ $this->registry->output->html .= $output;
+
+ /**
+ * Rikki wanted a stupid header template so we could output his stupid header. This created more work for Brandon.
+ * This in turn meant I had to create a stupid footer to keep other people happy. Must make other people happy. I'm on a horse.
+ */
+ $this->registry->output->html .= $this->html->sqlToolResultFooter();
+
}
/**
@@ -395,13 +406,22 @@ class admin_core_sql_toolbox_module extends ipsCommand {
if( strstr( $sql, ";" ) )
{
- $the_queries = preg_split( "/;[\r\n|\n]+/", $sql, -1, PREG_SPLIT_NO_EMPTY );
+ $queries = preg_split( "/;[\r\n|\n]+/", $sql, -1, PREG_SPLIT_NO_EMPTY );
+
+ foreach( $queries as $query )
+ {
+ if( substr( $query, -1, 1 ) == ";" )
+ {
+ $query = substr( $query, 0, -1 );
+ }
+ $the_queries[]['sql'] = $query;
+ }
}
else
{
if( $sql )
{
- $the_queries[] = $sql;
+ $the_queries[]['sql'] = $sql;
}
}
@@ -418,28 +438,25 @@ class admin_core_sql_toolbox_module extends ipsCommand {
else
{
/* Loop through the queries and run them */
- foreach( $the_queries as $sql )
+ foreach( $the_queries as $key => $sql )
{
/* INIT */
$links = "";
- $sql = trim( $sql );
+ $sql['sql'] = trim( $sql['sql'] );
- if ( ! $tableName )
+ if ( preg_match( "#^SELECT(?:.*)\s+?FROM\s+?(\S+?)(;?)(?:\s|$)#i", $sql['sql'], $match ) )
{
- if ( preg_match( "#^SELECT(?:.*)\s+?FROM\s+?(\S+?)(?:\s|$)#i", $sql, $match ) )
- {
- $tableName = $match[1];
- }
+ $the_queries[$key]['tableName'] = $match[1];
}
/* Check the sql */
- $test_sql = str_replace( "\'", "", $sql );
+ $test_sql = str_replace( "\'", "", $sql['sql'] );
$apos_count = substr_count( $test_sql, "'" );
if( $apos_count % 2 != 0 )
{
$columns[ $queryCntForArray ][] = $this->lang->words['manual_error'];
- $rows[ $queryCntForArray ][] = array( 'error' => $this->lang->words['manual_invalid'] . htmlspecialchars( $sql ) );
+ $rows[ $queryCntForArray ][] = array( 'error' => $this->lang->words['manual_invalid'] . htmlspecialchars( $sql['sql'] ) );
unset( $apos_count, $test_sql );
continue;
@@ -448,14 +465,14 @@ class admin_core_sql_toolbox_module extends ipsCommand {
unset( $apos_count, $test_sql );
/* Check for drop and flush */
- if ( preg_match( "/^(DROP|FLUSH)/i",$sql ) )
+ if ( preg_match( "/^(DROP|FLUSH)/i",$sql['sql'] ) )
{
$columns[ $queryCntForArray ][] = $this->lang->words['manual_error'];
$rows[ $queryCntForArray ][] = array( 'error' => $this->lang->words['manual_notallowed'] );
continue;
}
/* Protect admin_login_logs */
- else if ( preg_match( "/^(?!SELECT)/i", preg_replace( "#\s{1,}#s", "", $sql ) ) and preg_match( "/admin_login_logs/i", preg_replace( "#\s{1,}#s", "", $sql ) ) )
+ else if ( preg_match( "/^(?!SELECT)/i", preg_replace( "#\s{1,}#s", "", $sql['sql'] ) ) and ( preg_match( "/admin_login_logs/i", preg_replace( "#\s{1,}#s", "", $sql['sql'] ) ) || preg_match( "/admin_permission_rows/i", preg_replace( "#\s{1,}#s", "", $sql['sql'] ) ) ) )
{
$columns[ $queryCntForArray ][] = $this->lang->words['manual_error'];
$rows[ $queryCntForArray ][] = array( 'error' => $this->lang->words['manual_loginlogs'] );
@@ -467,7 +484,7 @@ class admin_core_sql_toolbox_module extends ipsCommand {
$this->DB->allow_sub_select = 1;
/* Run the query */
- $this->DB->query( $sql, 1 );
+ $this->DB->query( $sql['sql'], 1 );
/* Check for errors... */
if ( $this->DB->error != "")
@@ -481,10 +498,10 @@ class admin_core_sql_toolbox_module extends ipsCommand {
$rows[ $queryCntForArray ] = array();
$columns[ $queryCntForArray ] = array();
- if ( preg_match( "/^SELECT/i", $sql ) or preg_match( "/^SHOW/i", $sql ) or preg_match( "/^EXPLAIN/i", $sql ) )
+ if ( preg_match( "/^SELECT/i", $sql['sql'] ) or preg_match( "/^SHOW/i", $sql['sql'] ) or preg_match( "/^EXPLAIN/i", $sql['sql'] ) )
{
/* Sort out the pages and stuff, auto limit if need be */
- if ( ( ! preg_match( "/^EXPLAIN/i", $sql ) && ! preg_match( "/^SHOW/i", $sql ) ) AND ! preg_match( "/LIMIT[ 0-9,]+$/i", $sql ) )
+ if ( ( ! preg_match( "/^EXPLAIN/i", $sql['sql'] ) && ! preg_match( "/^SHOW/i", $sql['sql'] ) ) AND ! preg_match( "/LIMIT[ 0-9,]+$/i", $sql['sql'] ) )
{
/* Start value */
$start = $this->request['st'] ? intval( $this->request['st'] ) : 0;
@@ -499,19 +516,19 @@ class admin_core_sql_toolbox_module extends ipsCommand {
'totalItems' => $rows_returned,
'itemsPerPage' => $limit,
'currentStartValue' => $start,
- 'baseUrl' => "{$this->settings['base_url']}{$this->form_code}&do=runsql&query=" . urlencode( $sql ),
+ 'baseUrl' => "{$this->settings['base_url']}{$this->form_code}&do=runsql&query=" . urlencode( $sql['sql'] ),
) );
/* Reformat the query with a LIMIT */
- if( substr( $sql, -1, 1 ) == ";" )
+ if( substr( $sql['sql'], -1, 1 ) == ";" )
{
- $sql = substr( $sql, 0, -1 );
+ $sql['sql'] = substr( $sql['sql'], 0, -1 );
}
- $sql .= " LIMIT $start, $limit";
+ $sql['sql'] .= " LIMIT $start, $limit";
/* Re-run with limit */
- $this->DB->query( $sql, 1 );
+ $this->DB->query( $sql['sql'], 1 );
}
}
@@ -534,7 +551,7 @@ class admin_core_sql_toolbox_module extends ipsCommand {
{
if( $man_query == 1 )
{
- if( IPSText::mbstrlen( $r[ $fields[$i]->name ] ) > 200 AND ! preg_match( "/^SHOW/i", $sql ) )
+ if( IPSText::mbstrlen( $r[ $fields[$i]->name ] ) > 200 AND ! preg_match( "/^SHOW/i", $sql['sql'] ) )
{
if ( ! $this->request['notruncate'] )
{
@@ -571,13 +588,13 @@ class admin_core_sql_toolbox_module extends ipsCommand {
}
}
- if ( $tableName )
+ if ( count($the_queries) == 1 && $the_queries[0]['tableName'] )
{
- $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=runsql&query=" . urlencode( "SELECT * FROM $tableName" ), $tableName );
+ $this->registry->output->extra_nav[] = array( "{$this->settings['base_url']}{$this->form_code}&do=runsql&query=" . urlencode( "SELECT * FROM {$the_queries[0]['tableName']}" ), $the_queries[0]['tableName'] );
}
/* Output */
- $this->registry->output->html .= $this->html->sqlViewResults( $the_queries, $columns, $rows, $links, $tableName, $truncated );
+ $this->registry->output->html .= $this->html->sqlViewResults( $the_queries, $columns, $rows, $links, $truncated );
}
/**
@@ -667,17 +684,11 @@ class admin_core_sql_toolbox_module extends ipsCommand {
if( $create_tbl )
{
/* Generate table structure */
- if( $this->request['addticks'] )
- {
- $this->DB->query( "SHOW CREATE TABLE `{$this->settings['sql_database']}.{$tbl}`" );
- }
- else
- {
- $this->DB->query( "SHOW CREATE TABLE {$this->settings['sql_database']}.{$tbl}" );
- }
+ $this->DB->query( "SHOW CREATE TABLE {$this->settings['sql_database']}.{$tbl}" );
$ctable = $this->DB->fetch();
-
+
+
echo $this->sqlStripTicks( $ctable['Create Table'] ).";\n";
}
diff --git a/upload/admin/applications/core/modules_admin/sql/toolbox.php b/upload/admin/applications/core/modules_admin/sql/toolbox.php
index 195bde62..aa556708 100644
--- a/upload/admin/applications/core/modules_admin/sql/toolbox.php
+++ b/upload/admin/applications/core/modules_admin/sql/toolbox.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* SQL Admin
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/sql/xml/menu.xml b/upload/admin/applications/core/modules_admin/sql/xml/menu.xml
index d2d84b6f..2373455a 100644
--- a/upload/admin/applications/core/modules_admin/sql/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/sql/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
SQL Toolbox
+ Инструменты SQL
- SQL Toolbox
+ Инструменты SQL
sql_toolbox
toolbox
do=overview
@@ -15,10 +15,10 @@
-
-
SQL Back Up
+ Резервное Копирование SQL
- SQL Back Up
+ Резервное Копирование SQL
sql_backup
toolbox
do=backup
@@ -28,10 +28,10 @@
-
-
SQL Runtime Info
+ Состояние SQL-сервера
- SQL Runtime Info
+ Состояние SQL-сервера
sql_ri
toolbox
do=runtime
@@ -54,10 +54,10 @@
-
-
SQL Processes
+ SQL-процессы
- SQL Processes
+ SQL-процессы
sql_processes
toolbox
do=processes
diff --git a/upload/admin/applications/core/modules_admin/system/charts.php b/upload/admin/applications/core/modules_admin/system/charts.php
index 138e958f..cd30b37d 100644
--- a/upload/admin/applications/core/modules_admin/system/charts.php
+++ b/upload/admin/applications/core/modules_admin/system/charts.php
@@ -7,7 +7,7 @@
* $Author: bfarber $
* @since -
* $LastChangedDate: 2011-11-23 14:13:15 -0500 (Wed, 23 Nov 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 9873 $
*/
diff --git a/upload/admin/applications/core/modules_admin/system/defaultSection.php b/upload/admin/applications/core/modules_admin/system/defaultSection.php
index 61eb3bb1..a1a950c0 100644
--- a/upload/admin/applications/core/modules_admin/system/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/system/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/system/security.php b/upload/admin/applications/core/modules_admin/system/security.php
index aa802837..aecc8414 100644
--- a/upload/admin/applications/core/modules_admin/system/security.php
+++ b/upload/admin/applications/core/modules_admin/system/security.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Security center tools
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-11-29 16:02:25 -0500 (Thu, 29 Nov 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 2.2 IIRC
- * @version $Revision: 10914 $
+ * @version $Revision: 11663 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -298,13 +298,65 @@ class admin_core_system_security extends ipsCommand
$content = array( 'bad' => '', 'good' => '', 'ok' => '' );
$cache_array = $this->cache->getCache('systemvars');
+ /* Disabled functions */
+ $functionsToDisable = array( 'exec', 'system', 'passhtru', 'pcntl_exec', 'popen', 'proc_open', 'shell_exec' );
+ $showingFunctionWarning = FALSE;
+ foreach ( $functionsToDisable as $k => $function )
+ {
+ if ( function_exists( $function ) )
+ {
+ $showingFunctionWarning = TRUE;
+ }
+ else
+ {
+ unset( $functionsToDisable[ $k ] );
+ }
+ }
+ if ( $showingFunctionWarning )
+ {
+ $content['bad'] .= $this->html->security_item_bad( $this->lang->words['s_functions'],
+ sprintf( $this->lang->words['s_functions_bad'], implode( ', ', $functionsToDisable ) ),
+ $this->lang->words['s_learnmore'],
+ 'http://external.ipslink.com/ipboard30/landing/?p=security',
+ 'functions' );
+ }
+ else
+ {
+ $content['good'] .= $this->html->security_item_good($this->lang->words['s_functions'],
+ $this->lang->words['s_functions_good'],
+ $this->lang->words['s_learnmore'],
+ 'http://external.ipslink.com/ipboard30/landing/?p=security',
+ 'functions' );
+ }
+
+ /* open_basedir */
+ $dir = @dir( '/' );
+ if ( $dir instanceof Directory )
+ {
+ $content['bad'] .= $this->html->security_item_bad( $this->lang->words['s_open_basedir'],
+ $this->lang->words['s_open_basedir_bad'],
+ $this->lang->words['s_learnmore'],
+ 'http://external.ipslink.com/ipboard30/landing/?p=security',
+ 'open_basedir' );
+ }
+ else
+ {
+ $value = @ini_get( 'open_basedir' );
+
+ $content['good'] .= $this->html->security_item_good( $this->lang->words['s_open_basedir'],
+ $value ? sprintf( $this->lang->words['s_open_basedir_good'], $value ) : $this->lang->words['s_open_basedir_good_noval'],
+ $this->lang->words['s_learnmore'],
+ 'http://external.ipslink.com/ipboard30/landing/?p=security',
+ 'open_basedir' );
+ }
+
/* Virus checker link */
if ( intval($cache_array['last_virus_check']) < time() - 7 * 86400 )
{
$content['bad'] .= $this->html->security_item_bad( $this->lang->words['s_virus'],
$this->lang->words['s_virus_bad'],
$this->lang->words['s_runtool'],
- $this->form_code_js.'&code=virus_check',
+ $this->settings['base_url'] . $this->form_code_js . '&code=virus_check',
'vchecker' );
}
@@ -314,7 +366,7 @@ class admin_core_system_security extends ipsCommand
$content['good'] .= $this->html->security_item_good( $this->lang->words['s_virus'],
$this->lang->words['s_virus_good'].$last_run,
$this->lang->words['s_runtool'],
- $this->form_code_js.'&code=virus_check',
+ $this->settings['base_url'] . $this->form_code_js . '&code=virus_check',
'vchecker' );
}
@@ -324,7 +376,7 @@ class admin_core_system_security extends ipsCommand
$content['bad'] .= $this->html->security_item_bad( $this->lang->words['s_deep'],
$this->lang->words['s_deep_bad'],
$this->lang->words['s_runtool'],
- $this->form_code_js.'&do=deep_scan',
+ $this->settings['base_url'] . $this->form_code_js . '&do=deep_scan',
'deepscan' );
}
@@ -334,7 +386,7 @@ class admin_core_system_security extends ipsCommand
$content['good'] .= $this->html->security_item_good( $this->lang->words['s_deep'],
$this->lang->words['s_deep_good'] . $last_run,
$this->lang->words['s_runtool'],
- $this->form_code_js.'&do=deep_scan',
+ $this->settings['base_url'] . $this->form_code_js . '&do=deep_scan',
'deepscan' );
}
@@ -346,7 +398,7 @@ class admin_core_system_security extends ipsCommand
$content['ok'] .= $this->html->security_item_ok( $this->lang->words['s_htaccess'],
sprintf( $this->lang->words['s_htaccess_bad'], CP_DIRECTORY ),
$this->lang->words['s_learnmore'],
- $this->form_code_js.'&do=acphtaccess',
+ $this->settings['base_url'] . $this->form_code_js . '&do=acphtaccess',
'acphtaccess' );
}
else
@@ -354,7 +406,7 @@ class admin_core_system_security extends ipsCommand
$content['good'] .= $this->html->security_item_good( $this->lang->words['s_htaccess'],
sprintf( $this->lang->words['s_htaccess_good'], CP_DIRECTORY ),
$this->lang->words['s_learnmore'],
- $this->form_code_js.'&do=acphtaccess',
+ $this->settings['base_url'] . $this->form_code_js . '&do=acphtaccess',
'acphtaccess' );
}
@@ -364,7 +416,7 @@ class admin_core_system_security extends ipsCommand
$content['ok'] .= $this->html->security_item_ok( $this->lang->words['s_phpcgi'],
$this->lang->words['s_phpcgi_bad'],
$this->lang->words['s_runtool'],
- $this->form_code_js.'&do=htaccess',
+ $this->settings['base_url'] . $this->form_code_js . '&do=htaccess',
'htaccess' );
}
else
@@ -372,7 +424,7 @@ class admin_core_system_security extends ipsCommand
$content['good'] .= $this->html->security_item_good( $this->lang->words['s_phpcgi'],
$this->lang->words['s_phpcgi_good'],
$this->lang->words['s_runtool'],
- $this->form_code_js.'&do=htaccess',
+ $this->settings['base_url'] . $this->form_code_js . '&do=htaccess',
'htaccess' );
}
@@ -382,7 +434,7 @@ class admin_core_system_security extends ipsCommand
$content['bad'] .= $this->html->security_item_bad( $this->lang->words['s_conf'],
$this->lang->words['s_conf_bad'],
$this->lang->words['s_runtool'],
- $this->form_code_js.'&do=confglobal',
+ $this->settings['base_url'] . $this->form_code_js . '&do=confglobal',
'confglobal' );
}
@@ -391,7 +443,7 @@ class admin_core_system_security extends ipsCommand
$content['good'] .= $this->html->security_item_good( $this->lang->words['s_conf'],
$this->lang->words['s_conf_good'],
$this->lang->words['s_learnmore'],
- $this->form_code_js.'&do=confglobal',
+ $this->settings['base_url'] . $this->form_code_js . '&do=confglobal',
'confglobal' );
}
}
@@ -402,7 +454,7 @@ class admin_core_system_security extends ipsCommand
$content['ok'] .= $this->html->security_item_ok( $this->lang->words['s_rename'],
$this->lang->words['s_rename_bad'],
$this->lang->words['s_learnmore'],
- $this->form_code_js.'&do=acprename',
+ $this->settings['base_url'] . $this->form_code_js . '&do=acprename',
'acprename' );
}
@@ -411,7 +463,7 @@ class admin_core_system_security extends ipsCommand
$content['good'] .= $this->html->security_item_good( $this->lang->words['s_rename'],
$this->lang->words['s_rename_good'],
$this->lang->words['s_learnmore'],
- $this->form_code_js.'&do=acprename',
+ $this->settings['base_url'] . $this->form_code_js . '&do=acprename',
'acprename' );
}
diff --git a/upload/admin/applications/core/modules_admin/system/taskmanager.php b/upload/admin/applications/core/modules_admin/system/taskmanager.php
index c2bd1e48..08a95076 100644
--- a/upload/admin/applications/core/modules_admin/system/taskmanager.php
+++ b/upload/admin/applications/core/modules_admin/system/taskmanager.php
@@ -4,10 +4,10 @@
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: bfarber $
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $Author: ips_terabyte $
+ * $LastChangedDate: 2012-03-26 12:16:52 -0400 (Mon, 26 Mar 2012) $
+ * @version v3.4.5
+ * $Revision: 10490 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/system/xml/menu.xml b/upload/admin/applications/core/modules_admin/system/xml/menu.xml
index d5159cf8..d73c8bf5 100644
--- a/upload/admin/applications/core/modules_admin/system/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/system/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
System Scheduler
+ Планировщик Задач
- System Scheduler
+ Планировщик Задач
taskmanager
taskmanager
do=overview
@@ -15,10 +15,10 @@
-
-
Security Center
+ Центр Безопасности
- Security Center
+ Центр Безопасности
security
security
@@ -28,10 +28,10 @@
-
-
List Admins
+ Список Администраторов
- List Admins
+ Список Администраторов
listadmins
security
do=list_admins
diff --git a/upload/admin/applications/core/modules_admin/system/xml/permissions.xml b/upload/admin/applications/core/modules_admin/system/xml/permissions.xml
index 66dbb838..212e8de0 100644
--- a/upload/admin/applications/core/modules_admin/system/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/system/xml/permissions.xml
@@ -1,70 +1,70 @@
- Security Center
+ Центр безопасности
core_security
-
security_center
- Can view the Security Center?
+ Может просматривать центр безопасности?
-
acplink_remove
- Remove the ACP Link?
+ Может удалить ссылку на АЦ?
-
deepscan
- Perform a deepscan for suspicious files?
+ Может запустить глубокое сканирование на подозрительные файлы?
-
virus_checker
- Run the virus-checker scanner?
+ Может запустить обычное сканирование на подозрительные файлы?
-
list_admins
- List members with administrative access?
+ Может просматривать список пользователей, имеющих доступ в АЦ?
-
htaccess_protection
- Create a .htaccess to protect writable directories?
+ Может создать .htaccess для защиты директорий?
-
nowrite_conf_global
- Make conf_global.php not writable?
+ Может сделать conf_global.php незаписываемым?
-
acp_rename
- Rename the ACP directory?
+ Может переименовать директорию АЦ?
-
acp_htaccess
- Create a .htaccess to protect the ACP?
+ Может создать .htaccess для защиты АЦ?
- Manage Scheduled Tasks
+ Управление задачами планировщика
core_tasks
-
task_manage
- Can manage scheduled tasks?
+ Может добавлять/изменять задачи?
-
task_remove
- Can remove scheduled tasks?
+ Может удалять задачи?
-
task_run_lock
- Can unlock and/or run scheduled tasks manually?
+ Может блокировать выполнение задач или запускать задачи вручную?
-
tasklogs_view
- Can view task logs?
+ Может просматривать журнал задач?
-
tasklogs_delete
- Can remove task logs?
+ Может удалять записи из журнала?
diff --git a/upload/admin/applications/core/modules_admin/templates/defaultSection.php b/upload/admin/applications/core/modules_admin/templates/defaultSection.php
index 6fdf0f25..3cd643b4 100644
--- a/upload/admin/applications/core/modules_admin/templates/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/templates/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_admin/templates/easylogo.php b/upload/admin/applications/core/modules_admin/templates/easylogo.php
index 700f6dd1..b8f7359e 100644
--- a/upload/admin/applications/core/modules_admin/templates/easylogo.php
+++ b/upload/admin/applications/core/modules_admin/templates/easylogo.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Easy Logo Changer
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-10-11 17:27:04 -0400 (Thu, 11 Oct 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Tuesday 17th August 2004
- * @version $Revision: 10914 $
+ * @version $Revision: 11446 $
*
*/
@@ -135,7 +135,7 @@ class admin_core_templates_easylogo extends ipsCommand
}
else
{
- if ( ! is_writable(DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . "/style_images" ) )
+ if ( ! is_writable( DOC_IPS_ROOT_PATH . PUBLIC_DIRECTORY . "/style_images" ) )
{
$this->registry->output->global_message = $this->lang->words['el_chmod'];
$this->splash();
diff --git a/upload/admin/applications/core/modules_admin/templates/external.php b/upload/admin/applications/core/modules_admin/templates/external.php
index c7dea0b6..c08e339d 100644
--- a/upload/admin/applications/core/modules_admin/templates/external.php
+++ b/upload/admin/applications/core/modules_admin/templates/external.php
@@ -3,7 +3,7 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Externally edit templates and css
* Last Updated: $Date: 2011-05-05 12:03:47 +0100 (Thu, 05 May 2011) $
*
diff --git a/upload/admin/applications/core/modules_admin/templates/importexport.php b/upload/admin/applications/core/modules_admin/templates/importexport.php
index a2be54e2..4bffe43c 100644
--- a/upload/admin/applications/core/modules_admin/templates/importexport.php
+++ b/upload/admin/applications/core/modules_admin/templates/importexport.php
@@ -3,19 +3,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Import and export skin sets
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-11 06:56:52 -0400 (Fri, 11 May 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 10725 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/templates/meta.php b/upload/admin/applications/core/modules_admin/templates/meta.php
new file mode 100644
index 00000000..3babd96a
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/templates/meta.php
@@ -0,0 +1,188 @@
+registry->getClass('class_permissions')->checkPermissionAutoMsg( 'settemplates_meta' );
+
+ ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'admin_seo' ) );
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_seo' );
+
+ //-----------------------------------------
+ // What are we doing?
+ //-----------------------------------------
+
+ switch($this->request['do'])
+ {
+ case 'add':
+ case 'edit':
+ $this->form();
+ break;
+
+ case 'save':
+ $this->save();
+ break;
+
+ case 'delete':
+ $this->delete();
+ break;
+
+ default:
+ $this->manage();
+ break;
+ }
+
+ //-----------------------------------------
+ // Display
+ //-----------------------------------------
+
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Action: Manage Meta Tags
+ */
+ protected function manage()
+ {
+ $metaTags = ips_CacheRegistry::instance()->getCache('meta_tags');
+
+ /* Display */
+ $this->registry->output->html = $this->html->metaTags( $metaTags );
+ }
+
+ /**
+ * Action: Show Form
+ */
+ public function form()
+ {
+ $page = '';
+ $tags = array();
+
+ if ( $this->request['do'] == 'edit' && isset($this->request['page']) )
+ {
+ $cache = ips_CacheRegistry::instance()->getCache('meta_tags');
+
+ $page = IPSText::base64_decode_urlSafe($this->request['page']);
+
+ if ( is_array($cache[ $page ]) && count($cache[ $page ]) )
+ {
+ $tags = $cache[ $page ];
+ }
+ }
+
+ /* Display */
+ $this->registry->output->html = $this->html->metaTagForm( $page, $tags );
+ }
+
+ /**
+ * Action: Save
+ */
+ protected function save()
+ {
+ /* Get Cache */
+ $cache = ips_CacheRegistry::instance()->getCache('meta_tags');
+
+ /* Delete any DB entries for this page as we're about to rebuild them */
+ $escapedPage = $this->DB->addSlashes( $this->request['old-page'] );
+ $this->DB->delete( 'seo_meta', "url='{$escapedPage}'" );
+ unset( $cache[ $this->request['old-page'] ] );
+
+ /* Init Page */
+ if ( !$this->request['page'] )
+ {
+ $this->registry->output->showError( 'err_no_page' );
+ }
+ $cache[ $this->request['page'] ] = array();
+
+ /* Insert Tags */
+ $id = 0;
+ do
+ {
+ if ( !empty( $this->request[ 'title-' . $id ] ) )
+ {
+ $cache[ $this->request['page'] ][ $this->request[ 'title-' . $id ] ] = $this->request[ 'content-' . $id ];
+ $this->DB->insert('seo_meta', array(
+ 'url' => $this->request['page'],
+ 'name' => $this->request[ 'title-' . $id ],
+ 'content' => $this->request[ 'content-' . $id ]
+ ) );
+ }
+
+ $id++;
+ }
+ while ( isset( $this->request[ 'title-' . $id ] ) );
+
+ /* Rebuild Cache */
+ ips_CacheRegistry::instance()->setCache( 'meta_tags', serialize( $cache ) );
+
+ /* Boink */
+ $this->registry->output->silentRedirect( ipsRegistry::$settings['base_url'] . "module=templates§ion=meta" );
+ }
+
+ /**
+ * Action: Delete
+ */
+ protected function delete()
+ {
+ /* Rebuild Cache */
+ $cache = ips_CacheRegistry::instance()->getCache('meta_tags');
+ unset( $cache[ $this->request['page'] ] );
+ ips_CacheRegistry::instance()->setCache( 'meta_tags', serialize( $cache ) );
+
+ /* Delete any DB entries for this page */
+ $page = IPSText::base64_decode_urlSafe( $this->request['page'] );
+
+ $escapedPage = $this->DB->addSlashes( $page );
+ $this->DB->delete( 'seo_meta', "url='{$escapedPage}'" );
+
+ /* Rebuild Cache */
+ $this->rebuildMetaTagCache();
+
+ /* Boink */
+ $this->registry->output->silentRedirect( ipsRegistry::$settings['base_url'] . "module=templates§ion=meta" );
+ }
+
+ /**
+ * Recache
+ */
+ public function rebuildMetaTagCache()
+ {
+ $meta = array();
+ $db = ipsRegistry::DB();
+
+ $db->build(array('select' => '*', 'from' => 'seo_meta'));
+ $db->execute();
+
+ while($row = $db->fetch())
+ {
+ $meta[$row['url']][$row['name']] = $row['content'];
+ }
+
+ ipsRegistry::instance()->cache()->setCache( 'meta_tags', $meta, array( 'array' => 1, 'donow' => 1 ) );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/templates/replacements.php b/upload/admin/applications/core/modules_admin/templates/replacements.php
index f5233358..dd3768f3 100644
--- a/upload/admin/applications/core/modules_admin/templates/replacements.php
+++ b/upload/admin/applications/core/modules_admin/templates/replacements.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Macros/replacements
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/templates/searchandreplace.php b/upload/admin/applications/core/modules_admin/templates/searchandreplace.php
index 74b3e7ae..fdbcb20d 100644
--- a/upload/admin/applications/core/modules_admin/templates/searchandreplace.php
+++ b/upload/admin/applications/core/modules_admin/templates/searchandreplace.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Skin search and replace tool
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/templates/skindiff.php b/upload/admin/applications/core/modules_admin/templates/skindiff.php
index 0bea2482..259a0deb 100644
--- a/upload/admin/applications/core/modules_admin/templates/skindiff.php
+++ b/upload/admin/applications/core/modules_admin/templates/skindiff.php
@@ -3,19 +3,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Skin diff report tools
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-08-15 10:33:53 -0400 (Wed, 15 Aug 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mark $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 11219 $
*
*/
@@ -177,6 +177,9 @@ class admin_core_templates_skindiff extends ipsCommand
}
}
+ /* Flush CDN */
+ $this->skinFunctions->flushipscdn();
+
/* Throw it out */
$this->registry->output->global_message = $this->lang->words['skindiff_okmsg'];
return $this->_viewReport();
diff --git a/upload/admin/applications/core/modules_admin/templates/skinsets.php b/upload/admin/applications/core/modules_admin/templates/skinsets.php
index e492fca7..81ea389b 100644
--- a/upload/admin/applications/core/modules_admin/templates/skinsets.php
+++ b/upload/admin/applications/core/modules_admin/templates/skinsets.php
@@ -3,19 +3,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Skin set management
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-01-15 15:27:53 -0500 (Tue, 15 Jan 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 11832 $
*
*/
@@ -273,7 +273,7 @@ class admin_core_templates_skinsets extends ipsCommand
if ( ! $set_name )
{
$this->registry->getClass('output')->global_message = $this->lang->words['ss_specifyname'];
- $this->_start();
+ $this->_skinGenStepOne();
return;
}
@@ -1037,6 +1037,13 @@ class admin_core_templates_skinsets extends ipsCommand
}
}
+ foreach ($sets as $key => $row)
+ {
+ $order[$key] = $row['set_order'];
+ }
+
+ array_multisort( $order, SORT_ASC, $sets );
+
//-----------------------------------------
// Check through...
//-----------------------------------------
@@ -1054,7 +1061,7 @@ class admin_core_templates_skinsets extends ipsCommand
//-----------------------------------------
$licenseData = $this->cache->getCache('licenseData');
- $skinGenIsSupported = true;
+ $skinGenIsSupported = (bool) $licenseData['skinGen'];
//-----------------------------------------
// Print it...
diff --git a/upload/admin/applications/core/modules_admin/templates/systemTemplates.php b/upload/admin/applications/core/modules_admin/templates/systemTemplates.php
new file mode 100644
index 00000000..d4261772
--- /dev/null
+++ b/upload/admin/applications/core/modules_admin/templates/systemTemplates.php
@@ -0,0 +1,229 @@
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Manage System Templates
+ * Last Updated: $Date: 2011-05-05 12:03:47 +0100 (Thu, 05 May 2011) $
+ *
+ *
+ * @author $Author: mark $
+ * @copyright (c) 2012 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 5th September 2012
+ * @version $Revision: 8644 $
+ *
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+
+class admin_core_templates_systemtemplates extends ipsCommand
+{
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen/redirects]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'systemtemplates' );
+ $this->registry->getClass('class_localization')->loadLanguageFile( array( 'admin_templates' ), 'core' );
+ $this->html = $this->registry->output->loadTemplate('cp_skin_templates');
+
+ //-----------------------------------------
+ // Get the class that handles this
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/output/systemTemplates.php', 'systemTemplates' );
+ $this->systemTemplates = new $classToLoad;
+
+ //-----------------------------------------
+ // What are we doing?
+ //-----------------------------------------
+
+ switch ( $this->request['do'] )
+ {
+ case 'edit':
+ $this->edit();
+ break;
+
+ case 'save':
+ $this->save();
+ break;
+
+ case 'revert':
+ $this->revert();
+ break;
+
+ case 'preview':
+ $this->preview();
+ break;
+
+ default:
+ $this->manage();
+ break;
+ }
+
+ //-----------------------------------------
+ // Output
+ //-----------------------------------------
+
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Show List
+ */
+ public function manage()
+ {
+ $this->registry->output->html .= $this->html->systemTemplatesList( is_writable( IPS_CACHE_PATH . 'cache/skin_cache/system' ), $this->systemTemplates->getList() );
+ }
+
+ /**
+ * Edit
+ */
+ public function edit()
+ {
+ $key = $this->request['k'];
+
+ try
+ {
+ $class = $this->systemTemplates->getClass( $key );
+
+ if ( !is_writable( IPS_CACHE_PATH . 'cache/skin_cache/system/' . $key . '.php' ) )
+ {
+ $this->registry->output->showError( sprintf( $this->lang->words['system_templates_nowrite_file'], IPS_CACHE_PATH . 'cache/skin_cache/system/' . $key . '.php' ) );
+ }
+
+ $reflector = new ReflectionClass( $class );
+ $params = $reflector->getMethod( 'getTemplate' )->getParameters();
+
+ $paramsToPass = array();
+ foreach ( $params as $p )
+ {
+ if ( !$p->isOptional() or !is_array( $p->getDefaultValue() ) )
+ {
+ $paramsToPass[] = '{$' . $p->name . '}';
+ }
+ else
+ {
+ $paramsToPass[] = new fakeArray( $p->name );
+ }
+ }
+
+ $this->registry->output->html .= $this->html->systemTemplatesEdit( $key, $key, $params, str_replace( '&', '&', call_user_func_array( array( $class, 'getTemplate' ), $paramsToPass ) ) );
+ }
+ catch ( Exception $e )
+ {
+ $this->registry->output->showError( 'system_templates_err' );
+ }
+ }
+
+ /**
+ * Preview
+ */
+ public function preview()
+ {
+ $key = $this->request['k'];
+
+ try
+ {
+ $class = $this->systemTemplates->getClass( $key );
+
+ $reflector = new ReflectionClass( $class );
+ $params = $reflector->getMethod( 'getTemplate' )->getParameters();
+
+ $paramsToPass = array();
+ foreach ( $params as $p )
+ {
+ if ( !$p->isOptional() or !is_array( $p->getDefaultValue() ) )
+ {
+ $paramsToPass[] = '{$' . $p->name . '}';
+ }
+ else
+ {
+ if ( $p->name == 'settings' )
+ {
+ $paramsToPass[] = ipsRegistry::$settings;
+ }
+ else
+ {
+ $paramsToPass[] = new fakeArray( $p->name );
+ }
+ }
+ }
+
+ echo call_user_func_array( array( $class, 'getTemplate' ), $paramsToPass );
+ exit;
+ }
+ catch ( Exception $e )
+ {
+ $this->registry->output->showError( 'system_templates_err' );
+ }
+ }
+
+ /**
+ * Save
+ */
+ public function save()
+ {
+ $key = $this->request['k'];
+
+ try
+ {
+ $class = $this->systemTemplates->getClass( $key );
+
+ $reflector = new ReflectionClass( $class );
+ $params = array();
+ foreach ( $reflector->getMethod( 'getTemplate' )->getParameters() as $param )
+ {
+ $params[] = '$' . $param->name . ( $param->isOptional() ? ( ' = ' . var_export( $param->getDefaultValue(), TRUE ) ) : '' );
+ }
+
+ if ( $this->systemTemplates->write( $key, $params, $_POST['content'] ) === FALSE )
+ {
+ $this->registry->output->showError( 'system_templates_errwrite' );
+ }
+
+ $this->registry->output->redirect( "{$this->settings['base_url']}app=core&&module=templates§ion=systemTemplates", $this->lang->words['system_templates_saved'] );
+ }
+ catch ( Exception $e )
+ {
+ $this->registry->output->showError( 'system_templates_err' );
+ }
+ }
+
+ /**
+ * Revert
+ */
+ public function revert()
+ {
+ $key = $this->request['k'];
+
+ try
+ {
+ $this->systemTemplates->revert( $key );
+ $this->registry->output->redirect( "{$this->settings['base_url']}app=core&&module=templates§ion=systemTemplates", $this->lang->words['system_templates_saved'] );
+ }
+ catch ( Exception $e )
+ {
+ $this->registry->output->showError( 'system_templates_err' );
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/templates/templates.php b/upload/admin/applications/core/modules_admin/templates/templates.php
index f36e6a54..5cd63382 100644
--- a/upload/admin/applications/core/modules_admin/templates/templates.php
+++ b/upload/admin/applications/core/modules_admin/templates/templates.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Template editing
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/templates/tools.php b/upload/admin/applications/core/modules_admin/templates/tools.php
index 25bb00c7..341be1c5 100644
--- a/upload/admin/applications/core/modules_admin/templates/tools.php
+++ b/upload/admin/applications/core/modules_admin/templates/tools.php
@@ -3,19 +3,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Skin tools
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-08-15 10:33:53 -0400 (Wed, 15 Aug 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mark $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 11219 $
*
*/
@@ -754,6 +754,9 @@ class admin_core_templates_tools extends ipsCommand
if( $setID == -1 )
{
+ /* Flush CDN */
+ $this->skinFunctions->flushipscdn();
+
$this->registry->output->global_message = $this->lang->words['to_recache_done'];
$this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code . '&do=overview', TRUE );
@@ -840,6 +843,9 @@ class admin_core_templates_tools extends ipsCommand
/* All done */
$this->registry->output->setMessage( $this->lang->words['to_recache_done'] . ' ' . implode( ' ', $messages ), true );
+ /* Flush CDN */
+ $this->skinFunctions->flushipscdn();
+
if ( count( $errors ) )
{
$this->registry->output->global_error = implode( ' ', $errors );
diff --git a/upload/admin/applications/core/modules_admin/templates/urlmap.php b/upload/admin/applications/core/modules_admin/templates/urlmap.php
index 977df402..71b8f2ef 100644
--- a/upload/admin/applications/core/modules_admin/templates/urlmap.php
+++ b/upload/admin/applications/core/modules_admin/templates/urlmap.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Skin URL mapping
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 2.3.x
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/templates/useragents.php b/upload/admin/applications/core/modules_admin/templates/useragents.php
index dc0ae826..b5e2d08e 100644
--- a/upload/admin/applications/core/modules_admin/templates/useragents.php
+++ b/upload/admin/applications/core/modules_admin/templates/useragents.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Gallery Application
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/templates/xml/menu.xml b/upload/admin/applications/core/modules_admin/templates/xml/menu.xml
index 7fc6c74a..196d879e 100644
--- a/upload/admin/applications/core/modules_admin/templates/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/templates/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Manage Skin Sets & Templates
+ Управление Стилями
- Manage Skin Sets & Templates
+ Управление Стилями
skins_manage
skinsets
do=overview
@@ -15,10 +15,36 @@
-
-
Template Tools
+ Управление Мета-тэгами
- Template Tools
+ Управление Мета-тэгами
+ skins_meta
+ meta
+
+ settemplates_meta
+ 0
+
+
+
+ -
+
Управление Системными Шаблонами
+
+
+ Управление Системными Шаблонами
+ skins_systemtemplates
+ systemTemplates
+
+ systemtemplates
+ 0
+
+
+
+ -
+
Инструменты Стилей
+
+
+ Инструменты Стилей
skins_tools
tools
do=splash
@@ -28,10 +54,10 @@
-
-
Template Merge Center
+ Слияние Стилей
- Template Merge Center
+ Слияние Стилей
skins_merge
skindiff
do=overview
@@ -41,10 +67,10 @@
-
-
Search and Replace
+ Поиск и Замена
- Search and Replace
+ Поиск и Замена
skins_sar
searchandreplace
do=showform
@@ -54,10 +80,10 @@
-
-
Easy Logo Changer
+ Смена Логотипа
- Easy Logo Changer
+ Смена Логотипа
skins_logo
easylogo
@@ -67,10 +93,10 @@
-
-
Import / Export
+ Импорт / Экспорт
- Import / Export
+ Импорт / Экспорт
skins_ie
importexport
do=overview
@@ -80,10 +106,10 @@
-
-
Externally Edit Templates & CSS
+ Внешнее Редактирование Шаблонов и CSS
- Externally Edit Templates & CSS
+ Внешнее Редактирование Шаблонов и CSS
skins_external
external
do=overview
diff --git a/upload/admin/applications/core/modules_admin/templates/xml/permissions.xml b/upload/admin/applications/core/modules_admin/templates/xml/permissions.xml
index 57381384..07be0f78 100644
--- a/upload/admin/applications/core/modules_admin/templates/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/templates/xml/permissions.xml
@@ -1,73 +1,85 @@
- Manage Templates
+ Управление стилями
core_templates
-
settemplates_manage
- Can view and manage skins?
+ Может просматривать и управлять стилями?
-
settemplates_delete
- Can remove skins?
+ Может удалять стили?
-
templates_manage
- Can manage templates?
+ Может добавлять/изменять шаблоны?
-
templates_delete
- Can remove and revert templates?
+ Может сбрасывать изменения или полностью удалять шаблоны?
-
css_manage
- Can edit/add CSS?
+ Может изменять/добавлять CSS?
-
css_delete
- Can remove and revert CSS?
+ Может сбрасывать изменения или полностью удалять CSS?
-
replacements_manage
- Can add/edit macro replacements?
+ Может добавлять/изменять макросы?
-
replacements_delete
- Can remove and revert macro replacements?
+ Может сбрасывать изменения или полностью удалять макросы?
-
settemplates_export
- Can export skins?
+ Может экспортировать стили?
+
+ -
+
settemplates_meta
+ Может управлять мета-тэгами?
+
+ -
+
systemtemplates
+ Может управлять системными шаблонами?
-
template_tools
- Can run the various skin system tools?
+ Может запускать инструменты стилей?
-
skindiff_reports
- Can use the Template Merge Center?
+ Может запускать инструмент сравнения стилей?
-
url_map_manage
- Can add/edit skin url mappings?
+ Может управлять URL-переназначениями стилей?
-
url_map_delete
- Can remove skin url mappings?
+ Может удалять URL-переназначения?
-
useragent_skin_map
- Can manage useragent skin mappings?
+ Может управлять переназначениями по useragent?
-
easy_logo
- Can use the easy logo changer?
+ Может воспользоваться инструментом смены логотипа?
-
settemplates_external
- Can enable/disable external skin editing?
+ Может включить/выключить внешнее редактирование стилей?
+ -
+
settemplates_external_edit
+ Может использовать внешнее редактирование стилей?
+
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/tools/api.php b/upload/admin/applications/core/modules_admin/tools/api.php
index 63798a07..b63d9148 100644
--- a/upload/admin/applications/core/modules_admin/tools/api.php
+++ b/upload/admin/applications/core/modules_admin/tools/api.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* API Users
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 1st march 2002
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_admin/tools/cache.php b/upload/admin/applications/core/modules_admin/tools/cache.php
index 79eea6d2..78aaeb96 100644
--- a/upload/admin/applications/core/modules_admin/tools/cache.php
+++ b/upload/admin/applications/core/modules_admin/tools/cache.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* ACP : Cache management
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-11-19 13:33:07 -0500 (Mon, 19 Nov 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since 26th January 2004
- * @version $Revision: 10914 $
+ * @version $Revision: 11614 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -410,8 +410,8 @@ class admin_core_tools_cache extends ipsCommand
if ( IPSContentCache::isEnabled() )
{
/* Get all posts */
- $cacheContent['posts'] = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count',
- 'from' => 'posts' ) );
+ $statsCache = ipsRegistry::cache()->getCache('stats');
+ $cacheContent['posts'] = array ( 'count' => intval( $statsCache['total_replies'] + $statsCache['total_topics'] ) );
/* Get all members */
$cacheContent['members'] = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as count',
diff --git a/upload/admin/applications/core/modules_admin/tools/defaultSection.php b/upload/admin/applications/core/modules_admin/tools/defaultSection.php
index 571de3b8..db979bfd 100644
--- a/upload/admin/applications/core/modules_admin/tools/defaultSection.php
+++ b/upload/admin/applications/core/modules_admin/tools/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: bfarber $
* @since 20th February 2002
* $LastChangedDate: 2011-08-05 20:51:01 -0400 (Fri, 05 Aug 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 9373 $
*/
diff --git a/upload/admin/applications/core/modules_admin/tools/help.php b/upload/admin/applications/core/modules_admin/tools/help.php
index 0d174d16..27f9b3f3 100644
--- a/upload/admin/applications/core/modules_admin/tools/help.php
+++ b/upload/admin/applications/core/modules_admin/tools/help.php
@@ -2,18 +2,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Help Files
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-12-17 12:34:52 -0500 (Mon, 17 Dec 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11719 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -288,11 +288,19 @@ class admin_core_tools_help extends ipsCommand
{
$this->registry->output->showError( $this->lang->words['h_entertitle'], 11150 );
}
-
- $text = trim( $_POST['editor_main'] );
- $text = preg_replace( "/\\\/", "\", $text );
- $text = str_replace( '%7Bstyle_image_url%7D', '{style_image_url}', $text );
+ /* Load editor */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $editor = new $classToLoad();
+
+ $editor->setLegacyMode(false);
+
+ $text = $editor->process( $_POST['Post'] );
+
+ $text = preg_replace( "/\\\/", "\", $text );
+ $text = str_replace( '%7Bstyle_image_url%7D', '{style_image_url}', $text );
+ $text = str_replace( $this->settings['base_acp_url'] . "/", "", $text);
+
/* Build DB Array */
$db_array = array(
'title' => $this->request['title'],
@@ -392,10 +400,25 @@ class admin_core_tools_help extends ipsCommand
$form['title'] = $this->registry->output->formInput('title' , $r['title'] );
$form['description'] = $this->registry->output->formTextarea('description', $r['description'] );
$form['appDir'] = $this->registry->output->formDropdown( 'appDir', $dropdown, $r['app'] );
- $form['text'] = IPSText::textToForm( $r['text'] );
+ // $form['text'] = IPSText::textToForm( $r['text'] );
+
+ /* editor */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
+ $editor = new $classToLoad();
+
+// $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
+// $parser = new $classToLoad();
+
+ /** DISABLE LEGACY MODE **/
+ $editor->setLegacyMode(false);
+
+ /* Set up initial value of editor */
+ $editor->setContent( $r['text'] );
+
+ $editorHtml = $html = $editor->show( 'Post', array( 'autoSaveKey' => 'acpHelp', 'bypassCKEditor' => 0 ) );
/* Ouput */
- $this->registry->output->html .= $this->html->helpFileForm( $code, $id, $form, $button );
+ $this->registry->output->html .= $this->html->helpFileForm( $code, $id, $form, $button, $editorHtml );
}
/**
@@ -449,24 +472,34 @@ class admin_core_tools_help extends ipsCommand
* @return @e void
*/
public function helpFilesList()
- {
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
+
+ $parser = new $classToLoad();
+
+ /* Set up some settings */
+ $parser->set( array( 'parseArea' => 'topics',
+ 'memberData' => $this->memberData,
+ 'parseBBCode' => true,
+ 'parseHtml' => true,
+ 'parseEmoticons' => true ) );
+
/* Query Help Files */
$this->DB->build( array( 'select' => '*', 'from' => 'faq', 'order' => "position" ) );
- $this->DB->execute();
+ $res = $this->DB->execute();
/* Do we have help files? */
$rows = array();
- if( $this->DB->getTotalRows() )
- {
- while( $r = $this->DB->fetch() )
- {
+ while( $r = $this->DB->fetch( $res ) )
+ {
+ $r['text'] = $parser->display( $r['text'] );
+
/* Add to output array */
$rows[] = $r;
}
- }
/* Output */
- $this->registry->output->html .= $this->html->helpFilesList( $rows );
+ $this->registry->output->html .= $this->html->helpFilesList( $rows );
}
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/tools/incomingEmails.php b/upload/admin/applications/core/modules_admin/tools/incomingEmails.php
index 47dfac52..5d654abd 100644
--- a/upload/admin/applications/core/modules_admin/tools/incomingEmails.php
+++ b/upload/admin/applications/core/modules_admin/tools/incomingEmails.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Incoming Email Routing
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/tools/licensekey.php b/upload/admin/applications/core/modules_admin/tools/licensekey.php
index cb5af098..1ce430b0 100644
--- a/upload/admin/applications/core/modules_admin/tools/licensekey.php
+++ b/upload/admin/applications/core/modules_admin/tools/licensekey.php
@@ -2,18 +2,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* License Manager
- * Last Updated: $LastChangedDate: 2012-07-11 9:30:49 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2013-05-28 10:00:25 -0400 (Tue, 28 May 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 12273 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -28,7 +28,7 @@ class admin_core_tools_licensekey extends ipsCommand
/**
* Main entry point
*
- * @param array ipsRegistry reference
+ * @param object ipsRegistry reference
* @return @e void
*/
public function doExecute( ipsRegistry $registry )
@@ -49,8 +49,8 @@ class admin_core_tools_licensekey extends ipsCommand
break;
case 'remove':
- IPSLib::updateSettings( array( 'ipb_reg_number' => 'Nulled by _Dark_ (IPBMafia.Ru)' ) );
- $this->settings['ipb_reg_number'] = 'Nulled by _Dark_ (IPBMafia.Ru)';
+ IPSLib::updateSettings( array( 'ipb_reg_number' => '' ) );
+ $this->settings['ipb_reg_number'] = '';
// Deliberately no break as we'll do onto recahce and then default action
case 'refresh':
@@ -86,8 +86,33 @@ class admin_core_tools_licensekey extends ipsCommand
*/
protected function activate()
{
- IPSLib::updateSettings( array( 'ipb_reg_number' => 'Nulled by _Dark_ (IPBMafia.Ru)' ) );
- $this->settings['ipb_reg_number'] = 'Nulled by _Dark_ (IPBMafia.Ru)';
+ /* Fetch data */
+ $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classFileManagement.php', 'classFileManagement' );
+ $classFileManagement = new $classToLoad();
+
+ $response = $classFileManagement->getFileContents( "http://license.invisionpower.com/?a=activate&key={$this->request['license_key']}&url={$this->settings['board_url']}" );
+
+ /* Is the key invalid? */
+ if ( !$response )
+ {
+ return $this->activateForm( $this->lang->words['license_key_server_error'] );
+ }
+ if( $response == 'NO_KEY' )
+ {
+ return $this->activateForm( $this->lang->words['license_key_notfound'] );
+ }
+ elseif ( $response == 'TEST_INSTALL_ALREADY_ACTIVE' )
+ {
+ return $this->activateForm( $this->lang->words['license_key_test_in_use'] );
+ }
+ $response = @json_decode( $response, true );
+ if( !isset( $response['result'] ) or $response['result'] != 'ok' )
+ {
+ return $this->activateForm( $this->lang->words['license_key_bad'] );
+ }
+
+ IPSLib::updateSettings( array( 'ipb_reg_number' => $this->request['license_key'] ) );
+ $this->settings['ipb_reg_number'] = $this->request['license_key'];
$this->recache();
$this->registry->output->silentRedirect( $this->settings['base_url'] . $this->form_code );
@@ -98,19 +123,19 @@ class admin_core_tools_licensekey extends ipsCommand
*/
protected function overview()
{
- $this->registry->output->html .= $this->html->licenseKeyStatusScreen( $this->settings['ipb_reg_number'], $this->cache->getCache( 'licenseData' ) );
+ $this->registry->output->html .= $this->html->licenseKeyStatusScreen( substr_replace( $this->settings['ipb_reg_number'], "**********", -10 ), $this->cache->getCache( 'licenseData' ) );
}
/**
* Recache License Data
*/
public function recache()
- {
+ {
+ /* Save */
+ $licenseData = darkLAE::getLicenseData();
$licenseData['_cached_date'] = time();
$licenseData['key']['_expires'] = $licenseData['key']['_expires'] ? $licenseData['key']['_expires'] : 9999999999;
$licenseData['key']['expires'] = $licenseData['key']['expires'] ? $licenseData['key']['expires'] : 9999999999;
$this->cache->setCache( 'licenseData', $licenseData, array( 'array' => 1 ) );
-
- IPSLib::updateSettings( array( 'ipb_copy_number' => 'Nulled by _Dark_ (IPBMafia.Ru)', 'ips_cp_purchase' => 1 ) );
}
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/tools/login.php b/upload/admin/applications/core/modules_admin/tools/login.php
index 43a2bd84..2b7d4d0d 100644
--- a/upload/admin/applications/core/modules_admin/tools/login.php
+++ b/upload/admin/applications/core/modules_admin/tools/login.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Login Manager Administration
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-05-03 23:09:37 -0400 (Fri, 03 May 2013) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Thursday 26th January 2006 (11:03)
- * @version $Revision: 10914 $
+ * @version $Revision: 12226 $
*
*/
@@ -31,7 +31,7 @@ class admin_core_tools_login extends ipsCommand
*
* @var object Skin templates
*/
- protected $html;
+ public $html;
/**
* Shortcut for url
@@ -207,6 +207,18 @@ class admin_core_tools_login extends ipsCommand
$save[ $option['key'] ] = str_replace( '\', '\\', $_POST[ $option['key'] ] );
}
}
+
+ //-----------------------------------------
+ // Specific check for IPS Connect
+ //-----------------------------------------
+
+ if( $login['login_folder_name'] == 'ipsconnect' )
+ {
+ if( $save['master_url'] == $this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php' )
+ {
+ ipsRegistry::getClass('output')->showError( $this->lang->words['l_slave_master_slave'] );
+ }
+ }
$this->DB->update( 'login_methods', array( 'login_custom_config' => serialize( $save ) ), 'login_id=' . $login_id );
@@ -220,8 +232,7 @@ class admin_core_tools_login extends ipsCommand
// And then show list
//-----------------------------------------
- ipsRegistry::getClass('output')->global_message = sprintf($this->lang->words['l_confup'], $login['login_title'] );
- $this->_loginList();
+ ipsRegistry::getClass('output')->redirect( $this->settings['base_url'] . $this->form_code . "", sprintf($this->lang->words['l_confup'], $login['login_title'] ) );
return true;
}
@@ -231,7 +242,7 @@ class admin_core_tools_login extends ipsCommand
* @return mixed Outputs, or return false
* @todo [Future] Remove legacy check for conf.php file in IPB 3.4 or higher
*/
- protected function _loginACPConf()
+ public function _loginACPConf()
{
//-----------------------------------------
// Init Vars
@@ -291,7 +302,7 @@ class admin_core_tools_login extends ipsCommand
$this->_loginList();
return false;
}
-
+
//-----------------------------------------
// Teh form
//-----------------------------------------
@@ -322,7 +333,7 @@ class admin_core_tools_login extends ipsCommand
);
}
- ipsRegistry::getClass('output')->html .= $this->html->login_conf_form( $login, $form );
+ ipsRegistry::getClass('output')->html .= $this->html->login_conf_form( $login, $form, isset( $help ) ? $help : NULL );
}
@@ -364,14 +375,6 @@ class admin_core_tools_login extends ipsCommand
{
$r['login_enabled'] = 1;
}
- else if ( $r['login_folder_name'] == 'ipconverge' )
- {
- $r['login_maintain_url'] = '';
- $r['login_register_url'] = '';
- $r['login_login_url'] = '';
- $r['login_logout_url'] = '';
- $r['login_enabled'] = 0;
- }
unset($r['login_id']);
@@ -562,28 +565,19 @@ class admin_core_tools_login extends ipsCommand
if ( $type == 'add' )
{
$this->DB->insert( 'login_methods', $array );
-
- ipsRegistry::getClass('output')->global_message = $this->lang->words['l_added'];
}
else
{
$this->DB->update( 'login_methods', $array, 'login_id='.$login_id );
-
- ipsRegistry::getClass('output')->global_message = $this->lang->words['l_edited'];
}
- if( $login_folder_name == 'ipconverge' )
- {
- IPSLib::updateSettings( array( 'ipconverge_enabled' => $login_enabled ) );
- }
-
//-----------------------------------------
// Recache
//-----------------------------------------
$this->loginsRecache();
- $this->_loginList();
+ ipsRegistry::getClass('output')->redirect( $this->settings['base_url'] . $this->form_code . "", ( $type == 'add' ) ? $this->lang->words['l_added'] : $this->lang->words['l_edited'] );
}
/**
@@ -821,22 +815,12 @@ class admin_core_tools_login extends ipsCommand
$toggle = $this->lang->words['l_disabled'];
$this->DB->update( 'login_methods', array( 'login_enabled' => 0 ), 'login_id=' . $login_id );
-
- if( $login['login_folder_name'] == 'ipconverge' )
- {
- IPSLib::updateSettings( array( 'ipconverge_enabled' => 0 ) );
- }
}
else
{
$toggle = $this->lang->words['l_enabled'];
$this->DB->update( 'login_methods', array( 'login_enabled' => 1 ), 'login_id=' . $login_id );
-
- if( $login['login_folder_name'] == 'ipconverge' )
- {
- IPSLib::updateSettings( array( 'ipconverge_enabled' => 1 ) );
- }
}
//-----------------------------------------
@@ -845,9 +829,7 @@ class admin_core_tools_login extends ipsCommand
$this->loginsRecache();
- ipsRegistry::getClass('output')->global_message = $this->lang->words['l_successfully'] . $toggle;
-
- $this->_loginList();
+ ipsRegistry::getClass('output')->redirect( $this->settings['base_url'] . $this->form_code . "", $this->lang->words['l_successfully'] . $toggle );
}
/**
@@ -873,11 +855,6 @@ class admin_core_tools_login extends ipsCommand
}
$this->DB->delete( 'login_methods', 'login_id=' . $login_id );
-
- if( $login['login_folder_name'] == 'ipconverge' )
- {
- IPSLib::updateSettings( array( 'ipconverge_enabled' => 0 ) );
- }
//-----------------------------------------
// Recache
@@ -885,9 +862,7 @@ class admin_core_tools_login extends ipsCommand
$this->loginsRecache();
- ipsRegistry::getClass('output')->global_message = $this->lang->words['l_uninstalled'];
-
- $this->_loginList();
+ ipsRegistry::getClass('output')->redirect( $this->settings['base_url'] . $this->form_code . "", $this->lang->words['l_uninstalled'] );
}
/**
@@ -982,10 +957,8 @@ class admin_core_tools_login extends ipsCommand
//-----------------------------------------
$this->loginsRecache();
-
- ipsRegistry::getClass('output')->global_message = $this->lang->words['l_yesinstalled'];
- $this->_loginList();
+ ipsRegistry::getClass('output')->redirect( $this->settings['base_url'] . $this->form_code . "", $this->lang->words['l_yesinstalled'] );
}
/**
diff --git a/upload/admin/applications/core/modules_admin/tools/logsSplash.php b/upload/admin/applications/core/modules_admin/tools/logsSplash.php
index 324a3b2a..eee2c5e7 100644
--- a/upload/admin/applications/core/modules_admin/tools/logsSplash.php
+++ b/upload/admin/applications/core/modules_admin/tools/logsSplash.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Log Splash Screen
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/tools/performance.php b/upload/admin/applications/core/modules_admin/tools/performance.php
index a3827250..8d0843a5 100644
--- a/upload/admin/applications/core/modules_admin/tools/performance.php
+++ b/upload/admin/applications/core/modules_admin/tools/performance.php
@@ -2,18 +2,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Toggle performance mode on/off
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-22 13:10:11 -0400 (Tue, 22 May 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10783 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/tools/qanda.php b/upload/admin/applications/core/modules_admin/tools/qanda.php
index 75a0fdc0..7bf08644 100644
--- a/upload/admin/applications/core/modules_admin/tools/qanda.php
+++ b/upload/admin/applications/core/modules_admin/tools/qanda.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Registration question and answer challenges
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/tools/rebuild.php b/upload/admin/applications/core/modules_admin/tools/rebuild.php
index 39dff785..0b26b880 100644
--- a/upload/admin/applications/core/modules_admin/tools/rebuild.php
+++ b/upload/admin/applications/core/modules_admin/tools/rebuild.php
@@ -1,3028 +1,3063 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Rebuild & Other Tools
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @version $Rev: 10914 $
- */
-
-if ( ! defined( 'IN_ACP' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-class admin_core_tools_rebuild extends ipsCommand
-{
- /**
- * Skin object
- *
- * @var object Skin templates
- */
- protected $html;
-
- /**#@+
- * URL bits
- *
- * @var string
- */
- public $form_code = '';
- public $form_code_js = '';
- /**#@-*/
-
- /**
- * Main class entry point
- *
- * @param object ipsRegistry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'applications/forums/sources/classes/forums/class_forums.php', 'class_forums', 'forums' );
- $this->registry->setClass( 'class_forums', new $classToLoad( $registry ) );
- $this->registry->class_forums->forumsInit();
-
- /* Load lang and skin */
- $this->registry->class_localization->loadLanguageFile( array( 'admin_tools' ) );
- $this->html = $this->registry->output->loadTemplate( 'cp_skin_rebuild' );
-
- /* URLs */
- $this->form_code = $this->html->form_code = 'module=tools§ion=rebuild';
- $this->form_code_js = $this->html->form_code_js = 'module=tools§ion=rebuild';
-
- /* What to do */
- switch( $this->request['do'] )
- {
- case 'docount':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_recount' );
- $this->doCount();
- break;
-
- case 'doresyncforums':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_resynch' );
- $this->resyncForums();
- break;
-
- case 'doresynctopics':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_resyncht' );
- $this->resyncTopics();
- break;
-
- case 'doposts':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_rebuild' );
- $this->rebuildPosts();
- break;
-
- case 'dopostnames':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_postcounts' );
- $this->rebuildPostNames();
- break;
-
- case 'dopostcounts':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_postcounts' );
- $this->rebuildPostCount();
- break;
-
- case 'doreputationcount':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_postcounts' );
- $this->rebuildReputationCount();
- break;
-
- case 'dothumbnails':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_thumbs' );
- $this->rebuildThumbnails();
- break;
-
- case 'dophotos':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_thumbs' );
- $this->rebuildPhotos();
- break;
-
- case 'doattachdata':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_attach' );
- $this->rebuildAttachdata();
- break;
-
- case 'doseousernames':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_rebuild' );
- $this->rebuildSeoUserNames();
- break;
- case 'cleanattachments':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_orphaned' );
- $this->cleanAttachments();
- break;
-
- case 'cleanphotos':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_orphanp' );
- $this->cleanPhotos();
- break;
-
- case 'domsgcounts':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_postcounts' );
- $this->rebuildMsgCounts();
- break;
-
- //-----------------------------------------
- // Tools
- //-----------------------------------------
-
- case '320photos':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->tools320Photos();
- break;
-
- case '300pms':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->tools300Pms();
- break;
-
- case '220tool_contacts':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->tools220Contacts();
- break;
-
- case '210polls':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->tools210Polls();
- break;
-
- case '210calevents':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->tools210Calevents();
- break;
-
- case '210tool_settings':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->tools210DupeSettings();
- break;
-
- case 'tool_settings':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->toolsDupeSettings();
- break;
-
- case 'tool_converge':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->toolsConverge();
- break;
-
- case 'tool_bansettings':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->toolBanSettings();
- break;
-
- case 'tools':
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
- $this->toolsSplashScreen();
- break;
-
- case 'rebuild_overview':
- default:
- $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'rebuild_manage' );
- $this->rebuildSplashScreen();
- break;
- }
-
- /* Output */
- $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
- $this->registry->output->sendOutput();
- }
-
- /**
- * 3.2.x Tools: Convert photos
- *
- * @return @e void
- */
- public function tools320photos()
- {
- /* INIT */
- $convertFrom = $this->request['from'] == 'avatars' ? 'avatars' : 'photos';
- $st = intval($this->request['st']);
- $did = 0;
- $each = 200;
-
- /* Photo library */
- require_once( IPS_ROOT_PATH . 'sources/classes/member/photo.php' );/*noLibHook*/
- $photo = new classes_member_photo( $this->registry );
-
- /* Loop over members */
- $this->DB->build( array( 'select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'limit' => array( $st, $each ) ) );
- $outer = $this->DB->execute();
-
- while( $r = $this->DB->fetch($outer) )
- {
- $did++;
-
- $update = array();
-
- if( $r['fb_photo'] )
- {
- $update['pp_photo_type'] = 'facebook';
- }
- else if( $r['tc_photo'] )
- {
- $update['pp_photo_type'] = 'twitter';
- }
- else
- {
- if( $convertFrom == 'avatars' )
- {
- if( $r['avatar_type'] == 'upload' AND $r['avatar_location'] )
- {
- $update['pp_photo_type'] = 'custom';
- $update['pp_main_photo'] = $r['avatar_location'];
- $_dims = @getimagesize( $this->settings['upload_dir'] . '/' . $r['avatar_location'] );
- $update['pp_main_width'] = $_dims[0];
- $update['pp_main_height'] = $_dims[1];
- }
- else if( $r['avatar_type'] == 'gravatar' )
- {
- $update['pp_photo_type'] = 'gravatar';
- $update['pp_gravatar'] = $r['avatar_location'];
-
- $md5Gravatar = md5( $update['pp_gravatar'] );
-
- $_url = "http://www.gravatar.com";
-
- if( $this->registry->output->isHTTPS )
- {
- $_url = "https://secure.gravatar.com";
- }
-
- $update['pp_main_photo'] = $_url . "/avatar/" .$md5Gravatar . "?s=100";
- $update['pp_main_width'] = 100;
- $update['pp_main_height'] = 100;
- $update['pp_thumb_photo'] = $_url . "/avatar/" .$md5Gravatar . "?s=100";
- $update['pp_thumb_width'] = 100;
- $update['pp_thumb_height'] = 100;
- }
- }
- else
- {
- if( $r['pp_main_photo'] )
- {
- $update['pp_photo_type'] = 'custom';
- $update['pp_main_photo'] = $r['pp_main_photo'];
- }
- }
- }
-
- if( $update['pp_photo_type'] == 'custom' )
- {
- $info = $photo->buildSizedPhotos( str_replace( 'upload:', '', $update['pp_main_photo'] ), $r['pp_member_id'], true );
-
- $update['pp_main_width'] = intval( $info['final_width'] );
- $update['pp_main_height'] = intval( $info['final_height'] );
- $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
- $update['pp_thumb_width'] = intval( $info['t_final_width'] );
- $update['pp_thumb_height'] = intval( $info['t_final_height'] );
- }
-
- if( count($update) )
- {
- $this->DB->update( 'profile_portal', $update, 'pp_member_id=' . $r['pp_member_id'] );
- }
- }
-
- /* Show message and redirect */
- if( $did > 0 )
- {
- $this->request['st'] = ( $st + $did );
-
- $url = "{$this->settings['base_url']}{$this->form_code}&do=" . $this->request['do'] . '&from=' . $this->request['from'] . '&st=' . $this->request['st'];
-
- $this->_specialRedirect( $url, sprintf( $this->lang->words['tools320photos'], $this->request['st'], $did ) );
- }
- else
- {
- $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code . '&do=tools', $this->lang->words['re_photosconverted'] );
- }
- }
-
- /**
- * 3.0.x Tools: PM Conversion
- *
- * @return @e void
- */
- public function tools300pms()
- {
- /* INIT */
- $pergo = 100;
- $start = intval( $this->request['st'] );
- $converted = 0;
- $seen = 0;
-
- //-----------------------------------------
- // Check to make sure table exists
- //-----------------------------------------
-
- if ( ! $this->DB->checkForTable( 'message_text' ) )
- {
- $this->registry->output->global_message = $this->lang->words['re_msgsconverted'];
- $this->toolsSplashScreen();
- return;
- }
-
-
- /* Select max topic ID thus far */
- $_tmp = $this->DB->buildAndFetch( array( 'select' => 'MAX(mt_id) as max',
- 'from' => 'message_topics' ) );
-
- $topicID = intval( $_tmp['max'] );
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'message_text',
- 'order' => 'msg_id ASC',
- 'limit' => array( $start, $pergo ) ) );
-
- $o = $this->DB->execute();
-
- while( $post = $this->DB->fetch( $o ) )
- {
- $seen++;
-
- /* Make sure all data is valid */
- if ( intval( $post['msg_sent_to_count'] ) < 1 )
- {
- continue;
- }
-
- /* a little set up */
- $oldTopics = array();
-
- /* Now fetch all topics */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'message_topics_old',
- 'where' => 'mt_msg_id=' . intval( $post['msg_id'] ) ) );
-
- $t = $this->DB->execute();
-
- while( $topic = $this->DB->fetch( $t ) )
- {
- /* Got any data? */
- if ( ! $topic['mt_from_id'] OR ! $topic['mt_to_id'] )
- {
- continue;
- }
-
- $oldTopics[ $topic['mt_id'] ] = $topic;
- }
-
- /* Fail safe */
- if ( ! count( $oldTopics ) )
- {
- continue;
- }
-
- /* Increment number */
- $topicID++;
-
- /* Add in the post */
- $this->DB->insert( 'message_posts', array( 'msg_topic_id' => $topicID,
- 'msg_date' => $post['msg_date'],
- 'msg_post' => $post['msg_post'],
- 'msg_post_key' => $post['msg_post_key'],
- 'msg_author_id' => $post['msg_author_id'],
- 'msg_ip_address' => $post['msg_ip_address'],
- 'msg_is_first_post' => 1 ) );
- $postID = $this->DB->getInsertId();
-
- /* Define some stuff. "To" member is added last in IPB 2 */
- $_tmp = $oldTopics;
- ksort( $_tmp );
- $topicData = array_pop( $_tmp );
- $_invited = array();
- $_seenOwner = array();
- $_isDeleted = 0;
-
- /* Add the member rows */
- foreach( $oldTopics as $mt_id => $data )
- {
- /* Prevent SQL error with unique index: Seen the owner ID already? */
- if ( $_seenOwner[ $data['mt_owner_id'] ] )
- {
- continue;
- }
-
- $_seenOwner[ $data['mt_owner_id'] ] = $data['mt_owner_id'];
-
- /* Build invited - does not include 'to' person */
- if ( $data['mt_owner_id'] AND ( $post['msg_author_id'] != $data['mt_owner_id'] ) AND ( $topicData['mt_to_id'] != $data['mt_owner_id'] ) )
- {
- $_invited[ $data['mt_owner_id'] ] = $data['mt_owner_id'];/*noLibHook*/
- }
-
- $_isSent = ( $data['mt_vid_folder'] == 'sent' ) ? 1 : 0;
- $_isDraft = ( $data['mt_vid_folder'] == 'unsent' ) ? 1 : 0;
-
- $this->DB->insert( 'message_topic_user_map', array( 'map_user_id' => $data['mt_owner_id'],
- 'map_topic_id' => $topicID,
- 'map_folder_id' => ( $_isDraft ) ? 'drafts' : 'myconvo',
- 'map_read_time' => ( $data['mt_user_read'] ) ? $data['mt_user_read'] : ( $data['mt_read'] ? time() : 0 ),
- 'map_user_active' => 1,
- 'map_user_banned' => 0,
- 'map_has_unread' => 0, //( $data['mt_read'] ) ? 0 : 1,
- 'map_is_system' => 0,
- 'map_last_topic_reply' => $post['msg_date'],
- 'map_is_starter' => ( $data['mt_owner_id'] == $post['msg_author_id'] ) ? 1 : 0 ) );
-
- }
-
- /* Now, did we see the author? If not, add them too but as inactive */
- if ( ! $_seenOwner[ $post['msg_author_id'] ] )
- {
- $_isDeleted = 1;
-
- /*$this->DB->insert( 'message_topic_user_map', array( 'map_user_id' => $post['msg_author_id'],
- 'map_topic_id' => $topicID,
- 'map_folder_id' => 'myconvo',
- 'map_read_time' => 0,
- 'map_user_active' => 0,
- 'map_user_banned' => 0,
- 'map_has_unread' => 0,
- 'map_is_system' => 0,
- 'map_is_starter' => 1 ) );*/
- }
-
- $_isSent = ( $topicData['mt_vid_folder'] == 'sent' ) ? 1 : 0;
- $_isDraft = ( $topicData['mt_vid_folder'] == 'unsent' ) ? 1 : 0;
-
- /* This is for MSSQL. I need a quick fix. This is it. Enjoy. */
- if ( method_exists( $this->DB, 'setTableIdentityInsert' ) )
- {
- $this->DB->setTableIdentityInsert( 'message_topics', 'ON' );
- }
-
- /* Add the topic */
- $this->DB->insert( 'message_topics', array( 'mt_id' => $topicID,
- 'mt_date' => $topicData['mt_date'],
- 'mt_title' => $topicData['mt_title'],
- 'mt_starter_id' => $post['msg_author_id'],
- 'mt_start_time' => $post['msg_date'],
- 'mt_last_post_time' => $post['msg_date'],
- 'mt_invited_members' => serialize( array_keys( $_invited ) ),
- 'mt_to_count' => count( array_keys( $_invited ) ) + 1,
- 'mt_to_member_id' => $topicData['mt_to_id'],
- 'mt_replies' => 0,
- 'mt_last_msg_id' => $postID,
- 'mt_first_msg_id' => $postID,
- 'mt_is_draft' => $_isDraft,
- 'mt_is_deleted' => $_isDeleted,
- 'mt_is_system' => 0 ) );
-
- /* This is for MSSQL. I need a quick fix. This is it. Enjoy. */
- if ( method_exists( $this->DB, 'setTableIdentityInsert' ) )
- {
- $this->DB->setTableIdentityInsert( 'message_topics', 'OFF' );
- }
-
- $converted++;
- }
-
- /* What to do? */
- if ( $seen )
- {
- $this->request['st'] = $start + $pergo;
-
- /* Re-do Page */
- $url = "{$this->settings['base_url']}{$this->form_code}&do=".$this->request['do'].'&st=' . $this->request['st'];
-
- $this->_specialRedirect( $url, sprintf( $this->lang->words['tools300pms'], $this->request['st'], $converted ) );
- }
- else
- {
- /* Update all members */
- $this->DB->update( 'members', array( 'msg_count_reset' => 1 ) );
-
- $this->registry->output->redirect( "{$this->settings['base_url']}{$this->form_code}&do=tools", $this->lang->words['re_pmsconverted'], 1 );
- }
- }
-
- /**
- * Tools: Ban Settings
- *
- * @return @e void
- */
- public function toolBanSettings()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $bomb = array();
- $ban = array();
- $ip_count = 0;
- $email_count = 0;
- $name_count = 0;
-
- //-----------------------------------------
- // Get current entries
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'banfilters', 'order' => 'ban_date desc' ) );
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- $ban[ $r['ban_type'] ][ $r['ban_content'] ] = $r;
- }
-
- //-----------------------------------------
- // Get $INFO (again) ip email name
- //-----------------------------------------
- $INFO = array();
- require( DOC_IPS_ROOT_PATH . 'conf_global.php' );/*noLibHook*/
-
- //-----------------------------------------
- // IP
- //-----------------------------------------
-
- if ( $INFO['ban_ip'] )
- {
- $bomb = explode( '|', $INFO['ban_ip'] );
-
- if ( is_array( $bomb ) and count( $bomb ) )
- {
- foreach( $bomb as $bang )
- {
- if ( ! is_array($ban['ip'][ $bang ]) )
- {
- $this->DB->insert( 'banfilters', array( 'ban_type' => 'ip', 'ban_content' => $bang, 'ban_date' => time() ) );
-
- $ip_count++;
- }
- }
- }
- }
-
- //-----------------------------------------
- // EMAIL
- //-----------------------------------------
-
- if ( $INFO['ban_email'] )
- {
- $bomb = explode( '|', $INFO['ban_email'] );
-
- if ( is_array( $bomb ) and count( $bomb ) )
- {
- foreach( $bomb as $bang )
- {
- if ( ! is_array($ban['email'][ $bang ]) )
- {
- $this->DB->insert( 'banfilters', array( 'ban_type' => 'email', 'ban_content' => $bang, 'ban_date' => time() ) );
-
- $email_count++;
- }
- }
- }
- }
-
- //-----------------------------------------
- // EMAIL
- //-----------------------------------------
-
- if ( $INFO['ban_names'] )
- {
- $bomb = explode( '|', $INFO['ban_names'] );
-
- if ( is_array( $bomb ) and count( $bomb ) )
- {
- foreach( $bomb as $bang )
- {
- if ( ! is_array($ban['name'][ $bang ]) )
- {
- $this->DB->insert( 'banfilters', array( 'ban_type' => 'name', 'ban_content' => $bang, 'ban_date' => time() ) );
-
- $name_count++;
- }
- }
- }
- }
-
- $this->registry->output->global_message = sprintf( $this->lang->words['re_bansimport'], $ip_count, $email_count, $name_count );
-
- $this->cache->rebuildCache( 'banfilters', 'global' );
-
- $this->toolsSplashScreen();
- }
-
- /**
- * 2.0.0 Tools: Converge
- *
- * @return @e void
- */
- public function toolsConverge()
- {
- //-----------------------------------------
- // Get all validating members...
- //-----------------------------------------
-
- $to_unconverge = array();
- $unconverge_count = 0;
-
- $this->DB->build( array( 'select' => 'member_id, email, member_group_id', 'from' => 'members', 'where' => 'member_group_id='.$this->settings['auth_group'] ) );
- $this->DB->execute();
-
- while( $m = $this->DB->fetch() )
- {
- if ( preg_match( "#^{$m['member_id']}\-#", $m['email'] ) )
- {
- $to_unconverge[] = $m['member_id'];
- }
- }
-
- $unconverge_count = intval( count( $to_unconverge ) );
-
- if ( $unconverge_count )
- {
- foreach( $to_unconverge as $mid )
- {
- $this->DB->update( 'members' , array( 'member_group_id' => $this->settings['member_group'] ), 'member_id='.$mid );
- }
- }
-
- //-----------------------------------------
- // Time to move on dude
- //-----------------------------------------
-
- $this->registry->output->global_message = (sprintf( $this->lang->words['re_convergerest'], $unconverge_count ) );
- $this->toolsSplashScreen();
- }
-
- /**
- * 2.0.0 Tools: Dupe Settings
- *
- * @return @e void
- */
- public function toolsDupeSettings()
- {
- //-----------------------------------------
- // Remove dupe categories
- //-----------------------------------------
-
- $title_id_to_keep = array();
- $title_id_to_delete = array();
- $title_deleted_count = 0;
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'order' => 'conf_title_id' ) );
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- if ( $title_id_to_keep[ $r['conf_title_title'] ] )
- {
- $title_id_to_delete[ $r['conf_title_id'] ] = $r['conf_title_id'];
- }
- else
- {
- $title_id_to_keep[ $r['conf_title_title'] ] = $r['conf_title_id'];
- }
- }
-
- if ( count( $title_id_to_delete ) )
- {
- $this->DB->delete( 'conf_settings_titles', 'conf_title_id IN ('.implode( ',', $title_id_to_delete ).')' );
- }
-
- $title_deleted_count = intval( count($title_id_to_delete) );
-
- //-----------------------------------------
- // Remove dupe settings
- //-----------------------------------------
-
- $setting_id_to_keep = array();
- $setting_id_to_delete = array();
- $setting_id_deleted_count = 0;
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'order' => 'conf_id' ) );
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- if ( $setting_id_to_keep[ $r['conf_title'].','.$r['conf_key'] ] )
- {
- $setting_id_to_delete[ $r['conf_id'] ] = $r['conf_id'];
- }
- else
- {
- $setting_id_to_keep[ $r['conf_title'].','.$r['conf_key'] ] = $r['conf_id'];
- }
- }
-
- if ( count( $setting_id_to_delete ) )
- {
- $this->DB->delete( 'conf_settings', 'conf_id IN ('.implode( ',', $setting_id_to_delete ).')' );
- }
-
- $setting_deleted_count = intval( count($setting_id_to_delete) );
-
- //-----------------------------------------
- // Time to move on dude
- //-----------------------------------------
-
- $this->registry->output->global_message = sprintf( $this->lang->words['re_deletetitle'], $title_deleted_count, $setting_deleted_count ) ;
- $this->toolsSplashScreen();
- }
-
- /**
- * 2.1.0 Tools: Dupe Settings
- *
- * @return @e void
- */
- public function tools210DupeSettings()
- {
- //-----------------------------------------
- // Remove dupe categories
- //-----------------------------------------
-
- $title_id_to_keep = array();
- $title_id_to_delete = array();
- $title_deleted_count = 0;
- $msg = '';
-
- $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'order' => 'conf_title_id DESC' ) );
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- if ( $title_id_to_keep[ $r['conf_title_title'] ] )
- {
- $title_id_to_delete[ $r['conf_title_id'] ] = $r['conf_title_id'];
-
- $msg .= sprintf( $this->lang->words['re_deletingid'], $r['conf_title_title'], $r['conf_title_id'] ) . " ";
- }
- else
- {
- $title_id_to_keep[ $r['conf_title_title'] ] = $r['conf_title_id'];
- $msg .= sprintf( $this->lang->words['re_keepingid'], $r['conf_title_title'], $r['conf_title_id'] ) . " ";
- }
- }
-
- if ( count( $title_id_to_delete ) )
- {
- $this->DB->delete( 'core_sys_conf_settings', 'conf_title_id IN ('.implode( ',', $title_id_to_delete ).')' );
- }
-
- $title_deleted_count = intval( count($title_id_to_delete) );
-
- //-----------------------------------------
- // Time to move on dude
- //-----------------------------------------
-
- $this->registry->output->global_message = sprintf( $this->lang->words['re_duplicatetitle'], $title_deleted_count, $msg );
- $this->toolsSplashScreen();
- }
-
- /**
- * 2.1.0 Tools: Calendar Events
- *
- * @return @e void
- */
- public function tools210Calevents()
- {
- $start = intval($_GET['st']);
- $lend = 50;
- $end = $start + $lend;
- $max = intval($_GET['max']);
-
- //-----------------------------------------
- // Check to make sure table exists
- //-----------------------------------------
-
- if ( ! $this->DB->checkForTable( 'calendar_events' ) )
- {
- $this->registry->output->global_message = $this->lang->words['re_calremoved'];
- $this->toolsSplashScreen();
- return;
- }
-
- //-----------------------------------------
- // Do we need to run this tool?
- //-----------------------------------------
-
- if ( ! $max )
- {
- $original = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as max', 'from' => 'calendar_events' ) );
- $new = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as max', 'from' => 'cal_events' ) );
-
- if ( $new['max'] >= $original['max'] OR ! $original['max'] )
- {
- $this->registry->output->global_message = $this->lang->words['re_calalready'];
- $this->toolsSplashScreen();
- }
- }
-
- $max = intval( $original['max'] );
-
- //-----------------------------------------
- // In steps...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'calendar_events', 'limit' => array( $start, $lend ) ) );
- $o = $this->DB->execute();
-
- //-----------------------------------------
- // Do it...
- //-----------------------------------------
-
- if ( $this->DB->getTotalRows($o) )
- {
- //-----------------------------------------
- // Got some to convert!
- //-----------------------------------------
-
- while ( $r = $this->DB->fetch($o) )
- {
- $recur_remap = array( 'w' => 1,
- 'm' => 2,
- 'y' => 3 );
-
- $begin_date = IPSTime::date_getgmdate( $r['unix_stamp'] );
- $end_date = IPSTime::date_getgmdate( $r['end_unix_stamp'] );
-
- if ( ! $begin_date OR ! $end_date )
- {
- continue;
- }
-
- $day = $begin_date['mday'];
- $month = $begin_date['mon'];
- $year = $begin_date['year'];
-
- $end_day = $end_date['mday'];
- $end_month = $end_date['mon'];
- $end_year = $end_date['year'];
-
- $_final_unix_from = gmmktime(0, 0, 0, $month, $day, $year );
-
- //-----------------------------------------
- // Recur or ranged...
- //-----------------------------------------
-
- if ( $r['event_repeat'] OR $r['event_ranged'] )
- {
- $_final_unix_to = gmmktime(23, 59, 59, $end_month, $end_day, $end_year);
- }
- else
- {
- $_final_unix_to = 0;
- }
-
- $new_event = array( 'event_calendar_id' => 1,
- 'event_member_id' => $r['userid'],
- 'event_content' => $r['event_text'],
- 'event_title' => $r['title'],
- 'event_smilies' => $r['show_emoticons'],
- 'event_perms' => $r['read_perms'],
- 'event_private' => $r['priv_event'],
- 'event_approved' => 1,
- 'event_unixstamp' => $r['unix_stamp'],
- 'event_recurring' => ( $r['event_repeat'] && $recur_remap[ $r['repeat_unit'] ] ) ? $recur_remap[ $r['repeat_unit'] ] : 0,
- 'event_tz' => 0,
- 'event_unix_from' => $_final_unix_from,
- 'event_unix_to' => $_final_unix_to );
-
- //-----------------------------------------
- // INSERT
- //-----------------------------------------
-
- $this->DB->insert( 'cal_events', $new_event );
- }
-
- $this->registry->output->global_message = sprintf( $this->lang->words['re_calstartto'], $start, $end );
-
- $url = "{$this->settings['base_url']}{$this->form_code}&do=".$this->request['do'].'&max='.$max.'&st='.$end;
- }
- else
- {
- $this->registry->output->global_message = $this->lang->words['re_calsconverted'];
-
- $url = "{$this->settings['base_url']}{$this->form_code}&do=tools";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->registry->output->redirect( $url, $this->registry->output->global_message );
- }
-
- /**
- * 2.1.0 Tools: Polls
- *
- * @return @e void
- */
- public function tools210Polls()
- {
- $start = intval( $this->request['st'] );
- $lend = 50;
- $end = $start + $lend;
- $max = intval( $this->request['max'] );
- $done = 0;
- $converted = intval( $this->request['conv'] );
-
- //-----------------------------------------
- // First off.. grab number of polls to convert
- //-----------------------------------------
-
- if ( ! $max )
- {
- $total = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as max',
- 'from' => 'topics',
- 'where' => "poll_state IN ('open', 'close', 'closed')" ) );
-
- $max = $total['max'];
- }
-
- if ( $max < 1 )
- {
- $done = 1;
- }
-
- //-----------------------------------------
- // In steps...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'topics',
- 'where' => "poll_state IN ('open', 'close', 'closed' )",
- 'limit' => array( $start, $lend ) ) );
- $o = $this->DB->execute();
-
- //-----------------------------------------
- // Do it...
- //-----------------------------------------
-
- if ( $this->DB->getTotalRows($o) )
- {
- //-----------------------------------------
- // Got some to convert!
- //-----------------------------------------
-
- while ( $r = $this->DB->fetch($o) )
- {
- $converted++;
-
- $new_poll = array( 1 => array() );
-
- $poll_data = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'polls',
- 'where' => "tid=".$r['tid']
- ) );
- if ( ! $poll_data['pid'] )
- {
- continue;
- }
-
- if ( ! $poll_data['poll_question'] )
- {
- $poll_data['poll_question'] = $r['title'];
- }
-
- //-----------------------------------------
- // Kick start new poll
- //-----------------------------------------
-
- $new_poll[1]['question'] = $poll_data['poll_question'];
-
- //-----------------------------------------
- // Get OLD polls
- //-----------------------------------------
-
- $poll_answers = unserialize( stripslashes( $poll_data['choices'] ) );
-
- reset($poll_answers);
-
- foreach ( $poll_answers as $entry )
- {
- $id = $entry[0];
- $choice = $entry[1];
- $votes = $entry[2];
-
- $total_votes += $votes;
-
- if ( strlen($choice) < 1 )
- {
- continue;
- }
-
- $new_poll[ 1 ]['choice'][ $id ] = $choice;
- $new_poll[ 1 ]['votes'][ $id ] = $votes;
- }
-
- //-----------------------------------------
- // Got something?
- //-----------------------------------------
-
- if ( count( $new_poll[1]['choice'] ) )
- {
- $this->DB->update( 'polls' , array( 'choices' => serialize( $new_poll ) ), 'tid='.$r['tid'] );
- $this->DB->update( 'topics', array( 'poll_state' => 1 ), 'tid='.$r['tid'] );
- }
-
- //-----------------------------------------
- // All done?
- //-----------------------------------------
-
- if ( $converted >= $max )
- {
- $done = 1;
- continue;
- }
- }
- }
- else
- {
- $done = 1;
- }
-
-
- if ( ! $done )
- {
- $this->registry->output->global_message = sprintf( $this->lang->words['re_pollstartto'], $start, $end, $max );
-
- $url = "{$this->settings['base_url']}{$this->form_code}&do=".$this->request['do'].'&max='.$max.'&st='.$end.'&conv='.$converted;
- }
- else
- {
- $this->registry->output->global_message = $this->lang->words['re_pollconverted'];
-
- $url = "{$this->settings['base_url']}{$this->form_code}&do=tools";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->registry->output->redirect( $url, $this->registry->output->global_message );
- }
-
- /**
- * 2.2.0 Tools: Contacts
- * DEPRECATED
- *
- * @return @e void
- */
- public function tools220Contacts()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $start = intval($_GET['st']);
- $lend = 50;
- $end = $start + $lend;
- $done = 0;
- $updated = 0;
-
- //-----------------------------------------
- // Get lib
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('members') . '/sources/friends.php', 'profileFriendsLib', 'members' );
- $profile = new $classToLoad( $this->registry );
-
-
- //-----------------------------------------
- // OK..
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'contacts',
- 'where' => 'allow_msg=1',
- 'limit' => array( $start, $lend ) ) );
-
- $o = $this->DB->execute();
-
- //-----------------------------------------
- // Do it...
- //-----------------------------------------
-
- if ( $this->DB->getTotalRows($o) )
- {
- //-----------------------------------------
- // Got some to convert!
- //-----------------------------------------
-
- while( $row = $this->DB->fetch( $o ) )
- {
- //-----------------------------------------
- // Already a friend
- //-----------------------------------------
-
- $friend = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'profile_friends',
- 'where' => 'friends_member_id=' . intval( $row['member_id'] ) . ' AND friends_friend_id=' . intval( $row['contact_id'] ) ) );
-
- if ( ! $friend['friends_id'] )
- {
- //-----------------------------------------
- // Add to DB
- //-----------------------------------------
-
- $this->DB->insert( 'profile_friends', array( 'friends_member_id' => $row['member_id'],
- 'friends_friend_id' => $row['contact_id'],
- 'friends_approved' => 1,
- 'friends_added' => time() ) );
-
- //-----------------------------------------
- // Rebuild...
- //-----------------------------------------
-
- $profile->recacheFriends( array( 'member_id' => $row['member_id'] ) );
-
- $updated++;
- }
-
- $this->DB->delete( "contacts", "id={$row['id']}" );
- }
- }
- else
- {
- $done = 1;
- }
-
- //-----------------------------------------
- // Done?
- //-----------------------------------------
-
- if ( ! $done )
- {
- $this->registry->output->global_message = sprintf( $this->lang->words['re_contactsstartto'],$start, $end, $updated );
-
- $url = "{$this->settings['base_url']}{$this->form_code}&do=".$this->request['do'].'&st='.$end;
- }
- else
- {
- $this->registry->output->global_message = $this->lang->words['re_contactsup'];
-
- $url = "{$this->settings['base_url']}{$this->form_code}&do=tools";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->registry->output->redirect( $url, $this->registry->output->global_message );
- }
-
- /**
- * Cleanup Tools Splash Screen
- *
- * @return @e void
- */
- public function toolsSplashScreen()
- {
- /* Output */
- $this->registry->output->html .= $this->html->toolsSplashScreen();
- }
-
- /**
- * Count stats
- *
- * @return @e void
- */
- public function doCount()
- {
- if ( empty($this->request['posts']) && empty($this->request['online']) && empty($this->request['members']) && empty($this->request['lastreg']) )
- {
- $this->registry->output->showError( $this->lang->words['re_nothing'], 11154 );
- }
-
- $stats = $this->cache->getCache('stats');
-
- if ( $this->request['posts'] )
- {
- $topics = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as tcount',
- 'from' => 'topics',
- 'where' => $this->registry->getClass('class_forums')->fetchTopicHiddenQuery( array( 'visible' ), '' ) ) );
-
- $posts = $this->DB->buildAndFetch( array( 'select' => 'SUM(posts) as replies',
- 'from' => 'topics',
- 'where' => $this->registry->getClass('class_forums')->fetchTopicHiddenQuery( array( 'visible' ), '' ) ) );
-
- $stats['total_topics'] = $topics['tcount'];
- $stats['total_replies'] = $posts['replies'];
- }
-
- if ( $this->request['members'] )
- {
- $r = $this->DB->buildAndFetch( array( 'select' => 'count(member_id) as members', 'from' => 'members', 'where' => "member_group_id <> '{$this->settings['auth_group']}'" ) );
-
- $stats['mem_count'] = intval($r['members']);
- }
-
- if ( $this->request['lastreg'] )
- {
- $stats = array_merge( $stats, IPSMember::resetLastRegisteredMember( true ) );
- }
-
- if ( $this->request['online'] )
- {
- $stats['most_date'] = time();
- $stats['most_count'] = 1;
- }
-
- $this->cache->setCache( 'stats', $stats, array( 'array' => 1 ) );
-
- $this->registry->output->global_message = $this->lang->words['re_statsrecount'];
- $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code );
- }
-
- /**
- * Clean out photos
- *
- * @return @e void
- */
- public function cleanPhotos()
- {
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $display = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Pop open the directory and
- // peek inside...
- //-----------------------------------------
-
- $i = 0;
-
- try
- {
- foreach( new DirectoryIterator( $this->settings['upload_dir'] . '/profile' ) as $file )
- {
- if ( strstr( $file->getFilename(), 'photo-' ) )
- {
- $fullfile = $file->getPathname();
- $relativefile = str_replace( $this->settings['upload_dir'] . '/', '', $fullfile );
-
- $i++;
-
- //-----------------------------------------
- // Already started?
- //-----------------------------------------
-
- if ( $start > $i )
- {
- continue;
- }
-
- //-----------------------------------------
- // Done for this iteration?
- //-----------------------------------------
-
- if ( $i > $display )
- {
- break;
- }
-
- //-----------------------------------------
- // Try and get attach row
- //-----------------------------------------
-
- $found = $this->DB->buildAndFetch( array( 'select' => 'pp_member_id', 'from' => 'profile_portal', 'where' => "pp_main_photo='{$relativefile}' OR pp_thumb_photo='{$relativefile}'" ) );
-
- if ( ! $found['pp_member_id'] )
- {
- @unlink( $fullfile );
- $output[] = "{$this->lang->words['re_removedorph']} {$file->getFilename()} ";
- }
- else
- {
- $output[] = "{$this->lang->words['re_attachedok']} {$file->getFilename()} ";
- }
- }
- }
- } catch ( Exception $e ) {}
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( $i < $display)
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $display );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$display}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Clean out attachments
- *
- * @return @e void
- */
- public function cleanAttachments()
- {
- /* Upload Class */
- require_once( IPS_KERNEL_PATH.'classUpload.php' );/*noLibHook*/
- $upload = new classUpload();
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Pop open the directory and
- // peek inside...
- //-----------------------------------------
-
- $i = 0;
-
- try
- {
- foreach( new DirectoryIterator( $this->settings['upload_dir'] ) as $file )
- {
- if ( $file->getFilename() == '.' OR $file->getFilename() == '..' )
- {
- continue;
- }
-
- $fullfile = $this->settings['upload_dir'] . '/' . $file->getFilename();
-
- if( is_dir( $fullfile ) )
- {
- $ndh = opendir( $fullfile );
-
- try
- {
- foreach( new DirectoryIterator( $fullfile ) as $nfile )
- {
- if ( $nfile->getFilename() == '.' OR $nfile->getFilename() == '..' )
- {
- continue;
- }
-
- if ( strstr( $nfile->getFilename(), 'post-' ) )
- {
- $i++;
-
- //-----------------------------------------
- // Already started?
- //-----------------------------------------
-
- if ( $start > $i )
- {
- continue;
- }
-
- //-----------------------------------------
- // Done for this iteration?
- //-----------------------------------------
-
- if ( $i > $dis )
- {
- break;
- }
-
- //-----------------------------------------
- // Try and get attach row
- //-----------------------------------------
-
- $found = $this->DB->buildAndFetch( array( 'select' => 'attach_id', 'from' => 'attachments', 'where' => "attach_location='{$file->getFilename()}/{$nfile->getFilename()}' OR attach_thumb_location='{$file->getFilename()}/{$nfile->getFilename()}'" ) );
-
- if ( ! $found['attach_id'] )
- {
- @unlink( $fullfile . '/' . $nfile );
- $output[] = "{$this->lang->words['re_removedorph']} {$nfile->getFilename()} ";
- }
- else
- {
- $output[] = "{$this->lang->words['re_attachedok']} {$nfile->getFilename()} ";
- }
- }
- }
- } catch ( Exception $e ) {}
-
- closedir( $ndh );
- }
- else if ( strstr( $file, 'post-' ) )
- {
- $i++;
-
- //-----------------------------------------
- // Already started?
- //-----------------------------------------
-
- if ( $start > $i )
- {
- continue;
- }
-
- //-----------------------------------------
- // Done for this iteration?
- //-----------------------------------------
-
- if ( $i > $dis )
- {
- break;
- }
-
- //-----------------------------------------
- // Try and get attach row
- //-----------------------------------------
-
- $found = $this->DB->buildAndFetch( array( 'select' => 'attach_id', 'from' => 'attachments', 'where' => "attach_location='{$file->getFilename()}' OR attach_thumb_location='{$file->getFilename()}'" ) );
-
- if ( ! $found['attach_id'] )
- {
- @unlink( $fullfile );
- $output[] = "{$this->lang->words['re_removedorph']} {$file->getFilename()} ";
- }
- else
- {
- $output[] = "{$this->lang->words['re_attachedok']} {$file->getFilename()} ";
- }
- }
- }
- } catch ( Exception $e ) {}
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( $i < $dis)
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
-
- $text = sprintf( $this->lang->words['re_thisgoeshere'], $dis ) . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Rebuild Attachment Data
- *
- * @return @e void
- */
- public function rebuildAttachdata()
- {
- /* Upload Class */
- require_once( IPS_KERNEL_PATH.'classUpload.php' );/*noLibHook*/
- $upload = new classUpload();
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'attach_id', 'from' => 'attachments', 'limit' => array($dis,1) ) );
- $max = intval( $tmp['attach_id'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'attachments', 'order' => 'attach_id ASC', 'limit' => array($start,$end) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- //-----------------------------------------
- // Get ext
- //-----------------------------------------
-
- $update = array();
-
- $update['attach_ext'] = IPSText::getFileExtension( $r['attach_file'] );
-
- if ( $r['attach_location'] )
- {
- if ( is_file( $this->settings['upload_dir'].'/'.$r['attach_location'] ) )
- {
- $update['attach_filesize'] = @filesize( $this->settings['upload_dir'].'/'.$r['attach_location'] );
-
- if( $r['attach_is_image'] )
- {
- $dims = @getimagesize( $this->settings['upload_dir'].'/'.$r['attach_location'] );
-
- if( $dims[0] AND $dims[1] )
- {
- $update['attach_img_width'] = $dims[0];
- $update['attach_img_height'] = $dims[1];
- }
- }
- }
- }
-
- if ( count( $update ) )
- {
- $this->DB->update( 'attachments', $update, 'attach_id='.$r['attach_id'] );
- }
-
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Rebuild Photos
- *
- * @return @e void
- */
- public function rebuildPhotos()
- {
- /* Image Class */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo' );
- $photoClass = new $classToLoad( $this->registry );
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'pp_member_id', 'from' => 'profile_portal', 'where' => "pp_main_photo != ''", 'order' => 'pp_member_id ASC', 'limit' => array($dis,1) ) );
- $max = intval( $tmp['pp_member_id'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'where' => "pp_main_photo != ''", 'limit' => array($start,$end) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- /* Preserve FB, Twitter and Gravatar photos */
- if( $r['pp_photo_type'] != 'custom' )
- {
- continue;
- }
-
- $update = array();
-
- $info = $photoClass->buildSizedPhotos( str_replace( 'upload:', '', $r['pp_main_photo'] ), $r['pp_member_id'], true );
-
- if( $info['status'] == 'missing_image' )
- {
- $update['pp_main_photo'] = '';
- $update['pp_main_width'] = 0;
- $update['pp_main_height'] = 0;
- $update['pp_thumb_photo'] = '';
- $update['pp_thumb_width'] = 0;
- $update['pp_thumb_height'] = 0;
- }
- else
- {
- $update['pp_main_width'] = intval( $info['final_width'] );
- $update['pp_main_height'] = intval( $info['final_height'] );
- $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
- $update['pp_thumb_width'] = intval( $info['t_final_width'] );
- $update['pp_thumb_height'] = intval( $info['t_final_height'] );
- }
-
- $this->DB->update( 'profile_portal', $update, 'pp_member_id=' . $r['pp_member_id'] );
-
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Rebuild Post Thumbnails
- *
- * @return @e void
- */
- public function rebuildThumbnails()
- {
- require_once( IPS_KERNEL_PATH . 'classImage.php' );/*noLibHook*/
- require_once( IPS_KERNEL_PATH . 'classImageGd.php' );/*noLibHook*/
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'attach_id', 'from' => 'attachments', 'where' => "attach_rel_module IN('post','msg')", 'limit' => array($dis,1) ) );
- $max = intval( $tmp['attach_id'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'attachments', 'where' => "attach_rel_module IN('post','msg')", 'order' => 'attach_id ASC', 'limit' => array($start,$end) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- if ( $r['attach_is_image'] )
- {
- if ( $r['attach_thumb_location'] and ( $r['attach_thumb_location'] != $r['attach_location'] ) )
- {
- if ( is_file( $this->settings['upload_dir'] . '/' . $r['attach_thumb_location'] ) )
- {
- if ( ! @unlink( $this->settings['upload_dir'] . '/' . $r['attach_thumb_location'] ) )
- {
- $output[] = $this->lang->words['re_noremove'] . $r['attach_thumb_location'];
- continue;
- }
- }
- }
-
- $attach_data = array();
- $thumbnail = preg_replace( "/^(.*)\.(.+?)$/", "\\1_thumb.\\2", $r['attach_location'] );
-
- $image = new classImageGd();
-
- $image->init( array(
- 'image_path' => $this->settings['upload_dir'],
- 'image_file' => $r['attach_location'],
- ) );
-
- $image->force_resize = false;
-
- $return = $image->resizeImage( $this->settings['siu_width'], $this->settings['siu_height'] );
-
- if( !$return['noResize'] )
- {
- $image->writeImage( $this->settings['upload_dir'] . '/' . $thumbnail );
-
- $attach_data['attach_thumb_location'] = $thumbnail;
- }
-
- $attach_data['attach_thumb_width'] = intval($return['newWidth'] ? $return['newWidth'] : $image->cur_dimensions['width']);
- $attach_data['attach_thumb_height'] = intval($return['newHeight'] ? $return['newHeight'] : $image->cur_dimensions['height']);
-
- if ( count( $attach_data ) )
- {
- $this->DB->update( 'attachments', $attach_data, 'attach_id='.$r['attach_id'] );
-
- $output[] = $this->lang->words['re_resized'] . $r['attach_location'];
- }
-
- unset($image);
- }
-
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Rebuild Messenger Totals
- *
- * @return @e void
- */
- public function rebuildMsgCounts()
- {
- //-----------------------------------------
- // Grab messenger lib
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'members' ) . '/sources/classes/messaging/messengerFunctions.php', 'messengerFunctions', 'members' );
- $messengerFunctions = new $classToLoad( $this->registry );
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array($dis,1) ) );
- $max = intval( $tmp['member_id'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array($start,$end) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- $messengerFunctions->resetMembersFolderCounts( $r['member_id'] );
- $messengerFunctions->resetMembersTotalTopicCount( $r['member_id'] );
- $messengerFunctions->resetMembersNewTopicCount( $r['member_id'] );
-
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Rebuild Post Count
- *
- * @return @e void
- */
- public function rebuildPostCount()
- {
- //-----------------------------------------
- // Forums not to count?
- //-----------------------------------------
-
- $forums = array();
-
- foreach( $this->registry->class_forums->forum_by_id as $data )
- {
- if ( ! $data['inc_postcount'] )
- {
- $forums[] = $data['id'];
- }
- }
-
- /* Init */
- if ( ! $this->registry->isClassLoaded('topics') )
- {
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums' );
- $this->registry->setClass( 'topics', new $classToLoad( $this->registry ) );
- }
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array($dis,1) ) );
- $max = intval( $tmp['member_id'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'member_id, name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array($start,$end) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- if ( ! count( $forums ) )
- {
- $count = $this->registry->topics->getPosts( array( 'onlyViewable' => false,
- 'skipForumCheck' => true,
- 'getCountOnly' => true,
- 'authorId' => $r['member_id'] ) );
- }
- else
- {
- $count = $this->registry->topics->getPosts( array( 'onlyViewable' => false,
- 'skipForumCheck' => true,
- 'getCountOnly' => true,
- 'notForumId' => $forums,
- 'authorId' => $r['member_id'] ) );
- }
-
- if ( $this->settings['archive_on'] )
- {
- if ( ! count( $forums ) )
- {
- $acount = $this->registry->topics->getPosts( array( 'onlyViewable' => false,
- 'skipForumCheck' => true,
- 'getCountOnly' => true,
- 'isArchivedTopic' => true,
- 'authorId' => $r['member_id'] ) );
- }
- else
- {
- $acount = $this->registry->topics->getPosts( array( 'onlyViewable' => false,
- 'skipForumCheck' => true,
- 'getCountOnly' => true,
- 'notForumId' => $forums,
- 'isArchivedTopic' => true,
- 'authorId' => $r['member_id'] ) );
- }
-
- $count += intval( $acount );
- }
-
- $this->DB->update( 'members', array( 'posts' => intval( $count ) ), 'member_id='.$r['member_id'] );
-
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Rebuild Reputation Counts
- *
- * @return @e void
- */
- public function rebuildReputationCount()
- {
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Load reputation classes
- //-----------------------------------------
-
- $_rep_author_config = array();
- $_rep_log_joins = array();
- foreach( ipsRegistry::$applications as $appKey => $data )
- {
- $rep_author_config = array();
- $rep_log_joins = array();
- $file = IPSLib::getAppDir( $appKey ) . '/extensions/reputation.php';
-
- if ( file_exists( $file ) )
- {
- require( $file );/*noLibHook*/
- $_rep_author_config[ $appKey ] = $rep_author_config;
- $_rep_log_joins[ $appKey ] = $rep_log_joins;
- }
- }
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array($dis,1) ) );
- $max = intval( $tmp['member_id'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'member_id, name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array($start,$end) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- $total = 0;
-
- foreach ( $_rep_author_config as $app => $types )
- {
- foreach ( $types as $type => $data )
- {
- $prefix = NULL;
- foreach ( $_rep_log_joins[ $app ] as $j )
- {
- if ( is_array( $j['from'] ) AND count( $j['from'] ) )
- {
- foreach ( $j['from'] as $t => $p )
- {
- if ( $t == $data['table'] )
- {
- $prefix = $p;
- break 2;
- }
- }
- }
- }
-
- if ( !is_null( $prefix ) )
- {
- $_total = $this->DB->buildAndFetch( array(
- 'select' => "sum(r.rep_rating) as total",
- 'from' => array( 'reputation_index' => 'r' ),
- 'add_join' => $_rep_log_joins[ $app ],
- 'where' => "r.app='{$app}' AND r.type='{$type}' AND {$prefix}.{$data['column']}={$r['member_id']}",
- 'group' => "{$prefix}.{$data['column']}",
- ) );
-
- $total += $_total['total'];
- }
- }
- }
-
- $this->DB->update( 'profile_portal', array( 'pp_reputation_points' => $total ), 'pp_member_id='.$r['member_id'] );
-
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Rebuild Seo User Names
- *
- * @return @e void
- */
- public function rebuildSeoUserNames()
- {
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array( $dis, 1 ) ) );
- $max = intval( $tmp['member_id'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array( $start, $end ) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- $this->DB->update( 'members', array( 'members_seo_name' => IPSText::makeSeoTitle( $r['members_display_name'] ) ), "member_id=" . $r['member_id'] );
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
-
- /**
- * Rebuild Post Names
- *
- * @return @e void
- */
- public function rebuildPostNames()
- {
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array( $dis, 1 ) ) );
- $max = intval( $tmp['member_id'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array( $start, $end ) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- $seoName = IPSText::makeSeoTitle( $r['members_display_name'] );
- $this->DB->update( 'topics', array( 'starter_name' => $r['members_display_name'], 'seo_first_name' => $seoName ), "starter_id=" . $r['member_id'] );
- $this->DB->update( 'topics', array( 'last_poster_name' => $r['members_display_name'], 'seo_last_name' => $seoName ), "last_poster_id=" . $r['member_id'] );
-
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Rebuild posts
- *
- * @return @e void
- */
- public function rebuildPosts()
- {
- //-----------------------------------------
- // If it's "none", go back
- //-----------------------------------------
-
- if( !$this->request['type'] OR $this->request['type'] == 'none' )
- {
- $this->rebuildSplashScreen();
- return;
- }
-
- //-----------------------------------------
- // Only need to rebuild once
- //-----------------------------------------
-
- $sections = array();
- $alreadyRebuilt = $this->DB->buildAndFetch( array( 'select' => 'cs_value', 'from' => 'cache_store', 'where' => "cs_key='isRebuilt'" ) );
-
- if( $alreadyRebuilt['cs_value'] )
- {
- $sections = explode( ',', $alreadyRebuilt['cs_value'] );
- }
-
- //-----------------------------------------
- // Get new parser and old parser
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_parse_bbcode.php', 'parseBbcode' );
- $parser = new $classToLoad( $this->registry );
- $oldparser = new $classToLoad( $this->registry, 'legacy' );
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $last = 0;
- $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = intval($this->request['dis']) >=0 ? intval($this->request['dis']) : 0;
- $output = array();
- $plugin = null;
-
- $types = array( 'posts', 'pms', 'announce', 'sigs', 'aboutme', 'rules' );
-
- foreach( ipsRegistry::$applications as $app_dir => $app_data )
- {
- //-----------------------------------------
- // Retrieve the RSS links for the header
- //-----------------------------------------
-
- if( is_file( IPSLib::getAppDir( $app_dir ) . '/extensions/upgradePostRebuild.php' ) )
- {
- $className = IPSLib::loadLibrary( IPSLib::getAppDir( $app_dir ) . '/extensions/upgradePostRebuild.php', 'postRebuild_'.$app_dir, $app_dir );
-
- if( class_exists( $className ) )
- {
- $rebuild = new $className( $this->registry );
-
- if( method_exists( $rebuild, "getDropdown" ) )
- {
- $options = $rebuild->getDropdown();
-
- if( count($options) )
- {
- foreach( $options as $appOption )
- {
- $types[] = $appOption[0];
-
- if( $appOption[0] == $this->request['type'] )
- {
- $plugin =& $rebuild;
- break 2;
- }
- }
- }
- }
- }
- }
- }
-
- $type = in_array( $this->request['type'], $types ) ? $this->request['type'] : 'posts';
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- switch( $type )
- {
- case 'announce':
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'announce_id', 'from' => 'announcements', 'limit' => array($dis,1) ) );
- $max = intval( $tmp['announce_id'] );
- break;
-
- case 'pms':
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'msg_id', 'from' => 'message_posts', 'limit' => array($dis,1) ) );
- $max = intval( $tmp['msg_id'] );
- break;
-
- case 'sigs':
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'pp_member_id', 'from' => 'profile_portal', 'where' => "signature IS NOT NULL AND signature != ''", 'limit' => array($dis,1) ) );
- $max = intval( $tmp['pp_member_id'] );
- break;
-
- case 'aboutme':
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'pp_member_id', 'from' => 'profile_portal', 'where' => "pp_about_me IS NOT NULL AND pp_about_me != ''", 'limit' => array($dis,1) ) );
- $max = intval( $tmp['pp_member_id'] );
- break;
-
- case 'posts':
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'pid', 'from' => 'posts', 'limit' => array($dis,1) ) );
- $max = intval( $tmp['pid'] );
- break;
-
- case 'rules':
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'id', 'from' => 'forums', 'where' => "rules_text IS NOT NULL AND rules_text != ''", 'limit' => array($dis,1) ) );
- $max = intval( $tmp['id'] );
- break;
-
- default:
- $max = $rebuild->getMax( $type, $dis );
- break;
-
- }
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- switch( $type )
- {
- case 'announce':
- $this->DB->build( array( 'select' => 'a.*',
- 'from' => array( 'announcements' => 'a' ),
- 'order' => 'a.announce_id ASC',
- 'where' => 'a.announce_id > ' . $start,
- 'limit' => array($end),
- 'add_join' => array( 1 => array( 'type' => 'left',
- 'select' => 'm.member_group_id, m.mgroup_others',
- 'from' => array( 'members' => 'm' ),
- 'where' => "m.member_id=a.announce_member_id"
- ) )
- ) );
- break;
-
- case 'pms':
- $this->DB->build( array( 'select' => 'p.*',
- 'from' => array( 'message_posts' => 'p' ),
- 'order' => 'p.msg_id ASC',
- 'where' => 'p.msg_id > ' . $start,
- 'limit' => array($end),
- 'add_join' => array( 1 => array( 'type' => 'left',
- 'select' => 'm.member_group_id, m.mgroup_others',
- 'from' => array( 'members' => 'm' ),
- 'where' => "m.member_id=p.msg_author_id"
- ) )
- ) );
- break;
-
- case 'sigs':
- $this->DB->build( array( 'select' => 'me.signature, me.pp_member_id',
- 'from' => array( 'profile_portal' => 'me' ),
- 'order' => 'me.pp_member_id ASC',
- 'where' => "me.signature IS NOT NULL AND me.signature != '' AND me.pp_member_id > " . $start,
- 'limit' => array($end),
- 'add_join' => array( 1 => array( 'type' => 'left',
- 'select' => 'm.member_group_id, m.mgroup_others',
- 'from' => array( 'members' => 'm' ),
- 'where' => "m.member_id=me.pp_member_id"
- ) )
- ) );
- break;
-
- case 'aboutme':
- $this->DB->build( array( 'select' => 'pp.pp_about_me, pp.pp_member_id',
- 'from' => array( 'profile_portal' => 'pp' ),
- 'order' => 'pp.pp_member_id ASC',
- 'where' => "pp.pp_about_me != '' AND pp.pp_about_me IS NOT NULL AND pp.pp_member_id > " . $start,
- 'limit' => array($end),
- 'add_join' => array( 1 => array( 'type' => 'left',
- 'select' => 'm.member_group_id, m.mgroup_others',
- 'from' => array( 'members' => 'm' ),
- 'where' => "m.member_id=pp.pp_member_id"
- ) )
- ) );
- break;
-
- case 'posts':
- $this->DB->build( array( 'select' => 'p.*',
- 'from' => array( 'posts' => 'p' ),
- 'order' => 'p.pid ASC',
- 'where' => 'p.pid > ' . $start,
- 'limit' => array($end),
- 'add_join' => array( 1 => array( 'type' => 'left',
- 'select' => 't.forum_id',
- 'from' => array( 'topics' => 't' ),
- 'where' => "t.tid=p.topic_id"
- ),
- 2 => array( 'type' => 'left',
- 'select' => 'm.member_group_id, m.mgroup_others',
- 'from' => array( 'members' => 'm' ),
- 'where' => "m.member_id=p.author_id"
- ) )
- ) );
- break;
-
- case 'rules':
- $this->DB->build( array( 'select' => '*', 'from' => 'forums', 'order' => 'id ASC', 'where' => "rules_text IS NOT NULL AND rules_text != '' AND id > " . $start, 'limit' => array($end) ) );
- break;
-
- default:
- $plugin->executeQuery( $type, $start, $end );
- break;
- }
-
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- /* On mssql, the select query blocks all the updates. Doing this causes the engine not to lock */
- if ( method_exists( $this->DB, 'setQueryRowLocking' ) )
- {
- $this->DB->setQueryRowLocking( 'OFF' );
- }
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- //-----------------------------------------
- // Group
- //-----------------------------------------
-
- if( $r['member_group_id'] )
- {
- $r = array_merge( $r, $this->caches['group_cache'][ $r['member_group_id'] ] );
- }
-
- //-----------------------------------------
- // Reset
- //-----------------------------------------
-
- $parser->quote_open = $oldparser->quote_open = 0;
- $parser->quote_closed = $oldparser->quote_closed = 0;
- $parser->quote_error = $oldparser->quote_error = 0;
- $parser->error = $oldparser->error = '';
- $parser->image_count = $oldparser->image_count = 0;
- $parser->parsing_mgroup = $oldparser->parsing_mgroup = $r['member_group_id'];
- $parser->parsing_mgroup_others = $oldparser->parsing_mgroup_others = $r['mgroup_others'];
-
- $this->memberData['g_bypass_badwords'] = $this->caches['group_cache'][ $r['member_group_id'] ]['g_bypass_badwords'];
-
- switch( $type )
- {
- case 'announce':
- $parser->parse_smilies = $oldparser->parse_smilies = 1;
- $parser->parse_html = $oldparser->parse_html = $r['announce_html_enabled'];
- $parser->parse_bbcode = $oldparser->parse_bbcode = 1;
- $parser->parse_nl2br = $oldparser->parse_nl2br = ( $r['announce_html_enabled'] ? $r['announce_nlbr_enabled'] : 1 );
- $parser->parsing_section = 'announcement';
-
- $rawpost = $oldparser->preEditParse( $r['announce_post'] );
- break;
-
- case 'pms':
- $parser->parse_smilies = $oldparser->parse_smilies = 1;
- $parser->parse_html = $oldparser->parse_html = $r['g_dohtml'];
- $parser->parse_bbcode = $oldparser->parse_bbcode = 1;
- $parser->parse_nl2br = $oldparser->parse_nl2br = 1;
- $parser->parsing_section = 'pms';
-
- $rawpost = $oldparser->preEditParse( $r['msg_post'] );
- break;
-
- case 'sigs':
- $parser->parse_smilies = $oldparser->parse_smilies = 0;
- $parser->parse_html = $oldparser->parse_html = $r['g_dohtml'];
- $parser->parse_bbcode = $oldparser->parse_bbcode = 1;
- $parser->parse_nl2br = $oldparser->parse_nl2br = 1;
- $parser->parsing_section = 'signatures';
-
- $rawpost = $oldparser->preEditParse( $r['signature'] );
- break;
-
- case 'aboutme':
- $parser->parse_smilies = $oldparser->parse_smilies = 1;
- $parser->parse_html = $oldparser->parse_html = $r['g_dohtml'];
- $parser->parse_bbcode = $oldparser->parse_bbcode = 1;
- $parser->parse_nl2br = $oldparser->parse_nl2br = 1;
- $parser->parsing_section = 'aboutme';
-
- $rawpost = $oldparser->preEditParse( $r['pp_about_me'] );
- break;
-
- case 'posts':
- $parser->parse_smilies = $oldparser->parse_smilies = $r['use_emo'];
- $parser->parse_html = $oldparser->parse_html = ( $this->registry->class_forums->forum_by_id[ $r['forum_id'] ]['use_html'] AND $r['g_dohtml'] AND $r['post_htmlstate'] > 0 ) ? 1 : 0;
- $parser->parse_bbcode = $oldparser->parse_bbcode = $this->registry->class_forums->forum_by_id[ $r['forum_id'] ]['use_ibc'];
- $parser->parse_nl2br = $oldparser->parse_nl2br = ( $r['post_htmlstate'] != 1 ) ? 1 : 0;
- $parser->parsing_section = 'topics';
-
- $rawpost = $oldparser->preEditParse( $r['post'] );
- break;
-
- case 'rules':
- $parser->parse_smilies = $oldparser->parse_smilies = 1;
- $parser->parse_html = $oldparser->parse_html = 1;
- $parser->parse_bbcode = $oldparser->parse_bbcode = 1;
- $parser->parse_nl2br = $oldparser->parse_nl2br = 1;
- $parser->parsing_section = 'rules';
-
- $rawpost = $oldparser->preEditParse( $r['rules_text'] );
- break;
-
- default:
- $plugin->parser =& $parser;
- $plugin->oldparser =& $oldparser;
-
- $rawpost = $plugin->getRawPost( $type, $r );
- break;
- }
-
- /* @link http://community.invisionpower.com/tracker/issue-36434-rebuild-post-content-remove-break-from-post-content/ New parser retains , legacy retains \n */
- if ( strstr( $rawpost, "\n" ) )
- {
- $rawpost = nl2br( $rawpost );
- }
-
- $newpost = $parser->preDbParse( $rawpost );
-
- //-----------------------------------------
- // Remove old \' escaping
- //-----------------------------------------
-
- $newpost = str_replace( "\\'", "'", $newpost );
-
- //-----------------------------------------
- // Convert old dohtml?
- //-----------------------------------------
-
- $htmlstate = 0;
-
- if ( strstr( strtolower($newpost), '[dohtml]' ) )
- {
- //-----------------------------------------
- // Can we use HTML?
- //-----------------------------------------
-
- if ( $type == 'posts' AND $this->registry->class_forums->forum_by_id[ $r['forum_id'] ]['use_html'] )
- {
- $htmlstate = 2;
- }
-
- $newpost = preg_replace( "#\[dohtml\]#i" , "", $newpost );
- $newpost = preg_replace( "#\[/dohtml\]#i", "", $newpost );
- }
- else
- {
- $htmlstate = intval( $r['post_htmlstate'] );
- }
-
- //-----------------------------------------
- // Convert old attachment tags
- //-----------------------------------------
-
- $newpost = preg_replace( "#\[attachmentid=(\d+?)\]#is", "[attachment=\\1:attachment]", $newpost );
-
- if ( $newpost OR $type == 'sigs' OR $type == 'aboutme' )
- {
- switch( $type )
- {
- case 'posts':
- $this->DB->update( 'posts', array( 'post' => $newpost, 'post_htmlstate' => $htmlstate ), 'pid='.$r['pid'] );
- $last = $r['pid'];
- break;
-
- case 'pms':
- $this->DB->update( 'message_posts', array( 'msg_post' => $newpost ), 'msg_id='.$r['msg_id'] );
- $last = $r['msg_id'];
- break;
-
- case 'sigs':
- $this->DB->update( 'profile_portal', array( 'signature' => $newpost ), 'pp_member_id='.$r['pp_member_id'] );
- $last = $r['pp_member_id'];
- break;
-
- case 'aboutme':
- $this->DB->update( 'profile_portal', array( 'pp_about_me' => $newpost ), 'pp_member_id='.$r['pp_member_id'] );
- $last = $r['pp_member_id'];
- break;
-
- case 'announce':
- $this->DB->update( 'announcements', array( 'announce_post' => $newpost ), 'announce_id='.$r['announce_id'] );
- $last = $r['announce_id'];
- break;
-
- case 'rules':
- $this->DB->update( 'forums', array( 'rules_text' => $newpost ), 'id='.$r['id'] );
- $last = $r['id'];
- break;
-
- default:
- $last = $plugin->storeNewPost( $type, $r, $newpost );
- break;
- }
- }
-
- $done++;
- }
-
- if ( method_exists( $this->DB, 'setQueryRowLocking' ) )
- {
- $this->DB->setQueryRowLocking( 'ON' );
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $last and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
-
- $sections[] = $type;
- $this->DB->replace( 'cache_store', array( 'cs_key' => 'isRebuilt', 'cs_value' => implode( ',', $sections ) ), array( "cs_key" ) );
-
- if( $type == 'posts' )
- {
- $this->DB->delete( 'content_cache_posts' );
- }
- else if( $type == 'sigs' )
- {
- $this->DB->delete( 'content_cache_sigs' );
- }
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
-
- $dis = $dis + $done;
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&type={$type}&pergo={$this->request['pergo']}&st={$last}&dis={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Resyncronize Topics
- *
- * @return @e void
- */
- public function resyncTopics()
- {
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums' );
- $modfunc = new $classToLoad( $this->registry );
-
- $this->registry->class_localization->loadLanguageFile( array( 'public_global' ) );
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval( $this->request['st'] ) >= 0 ? intval( $this->request['st'] ) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'topics', 'limit' => array( $dis, 1 ) ) );
- $max = intval( $tmp['count'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'topics', 'where' => "state != 'link'", 'order' => 'tid ASC', 'limit' => array( $start, $end ) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- $modfunc->rebuildTopic($r['tid'], 0);
-
- if ( $this->request['pergo'] <= 200 )
- {
- $output[] = $this->lang->words['re_processed'].$r['title'];
- }
-
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Resyncronize forum data
- *
- * @return @e void
- */
- public function resyncForums()
- {
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums' );
- $modfunc = new $classToLoad( $this->registry );
-
- //-----------------------------------------
- // Set up
- //-----------------------------------------
-
- $done = 0;
- $start = intval( $this->request['st'] ) >= 0 ? intval( $this->request['st'] ) : 0;
- $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
- $dis = $end + $start;
- $output = array();
-
- //-----------------------------------------
- // Got any more?
- //-----------------------------------------
-
- $tmp = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'forums', 'limit' => array( $dis, 1 ) ) );
- $max = intval( $tmp['count'] );
-
- //-----------------------------------------
- // Avoid limit...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'forums', 'order' => 'id ASC', 'limit' => array( $start, $end ) ) );
- $outer = $this->DB->execute();
-
- //-----------------------------------------
- // Process...
- //-----------------------------------------
-
- while( $r = $this->DB->fetch( $outer ) )
- {
- $modfunc->forumRecount( $r['id'] );
- $output[] = sprintf( $this->lang->words['rebuild_process_f'], $r['name'] );
- $done++;
- }
-
- //-----------------------------------------
- // Finish - or more?...
- //-----------------------------------------
-
- if ( ! $done and ! $max )
- {
- //-----------------------------------------
- // Done..
- //-----------------------------------------
-
- $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}";
- }
- else
- {
- //-----------------------------------------
- // More..
- //-----------------------------------------
- $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
- $text = $thisgoeshere . ' ' . implode( " ", $output );
- $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
- }
-
- //-----------------------------------------
- // Bye....
- //-----------------------------------------
-
- $this->_specialRedirect( $url, $text );
- }
-
- /**
- * Splash screen with rebuild options
- *
- * @return @e void
- */
- public function rebuildSplashScreen()
- {
- /* Build Form Elements */
- $form = array();
-
- $form['posts'] = $this->registry->output->formDropdown( 'posts' , array( 0 => array( 0, $this->lang->words['yesno_no'] ), 1 => array( 1, $this->lang->words['yesno_yes'] ) ) );
- $form['members'] = $this->registry->output->formDropdown( 'members', array( 0 => array( 0, $this->lang->words['yesno_no'] ), 1 => array( 1, $this->lang->words['yesno_yes'] ) ) );
- $form['lastreg'] = $this->registry->output->formDropdown( 'lastreg', array( 0 => array( 0, $this->lang->words['yesno_no'] ), 1 => array( 1, $this->lang->words['yesno_yes'] ) ) );
- $form['online'] = $this->registry->output->formDropdown( 'online' , array( 0 => array( 0, $this->lang->words['yesno_no'] ), 1 => array( 1, $this->lang->words['yesno_yes'] ) ) );
-
- //-----------------------------------------
- // Only need to rebuild once
- //-----------------------------------------
-
- $todo = array(
- array( 'posts' , $this->lang->words['remenu_posts'] ),
- array( 'pms' , $this->lang->words['remenu_pms'] ),
- array( 'announce', $this->lang->words['remenu_announce'] ),
- array( 'sigs' , $this->lang->words['remenu_sigs'] ),
- array( 'aboutme' , $this->lang->words['remenu_aboutme'] ),
- array( 'rules' , $this->lang->words['remenu_rules'] ),
- );
-
- foreach( ipsRegistry::$applications as $app_dir => $app_data )
- {
- //-----------------------------------------
- // Retrieve the RSS links for the header
- //-----------------------------------------
-
- if( is_file( IPSLib::getAppDir( $app_dir ) . '/extensions/upgradePostRebuild.php' ) )
- {
- $className = IPSLib::loadLibrary( IPSLib::getAppDir( $app_dir ) . '/extensions/upgradePostRebuild.php', 'postRebuild_'.$app_dir, $app_dir );
-
- if( class_exists( $className ) )
- {
- $rebuild = new $className( $this->registry );
-
- if( method_exists( $rebuild, "getDropdown" ) )
- {
- $todo = array_merge( $todo, $rebuild->getDropdown() );
- }
- }
- }
- }
-
- $final = array();
- $sections = array();
-
- $alreadyRebuilt = $this->DB->buildAndFetch( array( 'select' => 'cs_value', 'from' => 'cache_store', 'where' => "cs_key='isRebuilt'" ) );
-
- if( $alreadyRebuilt['cs_value'] )
- {
- $sections = explode( ',', $alreadyRebuilt['cs_value'] );
- }
-
- $form['pergo'] = $this->registry->output->formSimpleInput( 'pergo', '50', 5 );
-
- /* Output */
- $this->registry->output->html .= $this->html->rebuildSplashScreen( $form, $todo, $sections );
- }
-
- /**
- * Redirect via a temporary page
- *
- * @param string $url URL to redirect to
- * @param string $text Text to display
- * @return @e void
- */
- protected function _specialRedirect( $url, $text )
- {
- $this->registry->output->html .= $this->registry->output->global_template->temporaryRedirect( $url, $text );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Rebuild & Other Tools
+ * Last Updated: $LastChangedDate: 2013-05-06 17:14:06 -0400 (Mon, 06 May 2013) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @version $Rev: 12230 $
+ */
+
+if ( ! defined( 'IN_ACP' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+class admin_core_tools_rebuild extends ipsCommand
+{
+ /**
+ * Skin object
+ *
+ * @var object Skin templates
+ */
+ protected $html;
+
+ /**#@+
+ * URL bits
+ *
+ * @var string
+ */
+ public $form_code = '';
+ public $form_code_js = '';
+ /**#@-*/
+
+ /**
+ * Main class entry point
+ *
+ * @param object ipsRegistry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'applications/forums/sources/classes/forums/class_forums.php', 'class_forums', 'forums' );
+ $this->registry->setClass( 'class_forums', new $classToLoad( $registry ) );
+ $this->registry->class_forums->forumsInit();
+
+ /* Load lang and skin */
+ $this->registry->class_localization->loadLanguageFile( array( 'admin_tools' ) );
+ $this->html = $this->registry->output->loadTemplate( 'cp_skin_rebuild' );
+
+ /* URLs */
+ $this->form_code = $this->html->form_code = 'module=tools§ion=rebuild';
+ $this->form_code_js = $this->html->form_code_js = 'module=tools§ion=rebuild';
+
+ /* What to do */
+ switch( $this->request['do'] )
+ {
+ case 'docount':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_recount' );
+ $this->doCount();
+ break;
+
+ case 'doresyncforums':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_resynch' );
+ $this->resyncForums();
+ break;
+
+ case 'doresynctopics':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_resyncht' );
+ $this->resyncTopics();
+ break;
+
+ case 'doposts':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_rebuild' );
+ $this->rebuildPosts();
+ break;
+
+ case 'dopostnames':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_postcounts' );
+ $this->rebuildPostNames();
+ break;
+
+ case 'dopostcounts':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_postcounts' );
+ $this->rebuildPostCount();
+ break;
+
+ case 'doreputationcount':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_postcounts' );
+ $this->rebuildReputationCount();
+ break;
+
+ case 'dothumbnails':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_thumbs' );
+ $this->rebuildThumbnails();
+ break;
+
+ case 'dophotos':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_thumbs' );
+ $this->rebuildPhotos();
+ break;
+
+ case 'doattachdata':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_attach' );
+ $this->rebuildAttachdata();
+ break;
+
+ case 'doseousernames':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_rebuild' );
+ $this->rebuildSeoUserNames();
+ break;
+ case 'cleanattachments':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_orphaned' );
+ $this->cleanAttachments();
+ break;
+
+ case 'cleanphotos':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_orphanp' );
+ $this->cleanPhotos();
+ break;
+
+ case 'domsgcounts':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'tools_postcounts' );
+ $this->rebuildMsgCounts();
+ break;
+
+ //-----------------------------------------
+ // Tools
+ //-----------------------------------------
+
+ case '320photos':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->tools320Photos();
+ break;
+
+ case '300pms':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->tools300Pms();
+ break;
+
+ case '220tool_contacts':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->tools220Contacts();
+ break;
+
+ case '210polls':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->tools210Polls();
+ break;
+
+ case '210calevents':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->tools210Calevents();
+ break;
+
+ case '210tool_settings':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->tools210DupeSettings();
+ break;
+
+ case 'tool_settings':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->toolsDupeSettings();
+ break;
+
+ case 'tool_converge':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->toolsConverge();
+ break;
+
+ case 'tool_bansettings':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->toolBanSettings();
+ break;
+
+ case 'tools':
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'cleanup_manage' );
+ $this->toolsSplashScreen();
+ break;
+
+ case 'rebuild_overview':
+ default:
+ $this->registry->getClass('class_permissions')->checkPermissionAutoMsg( 'rebuild_manage' );
+ $this->rebuildSplashScreen();
+ break;
+ }
+
+ /* Output */
+ $this->registry->output->html_main .= $this->registry->output->global_template->global_frame_wrapper();
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * 3.2.x Tools: Convert photos
+ *
+ * @return @e void
+ */
+ public function tools320photos()
+ {
+ /* INIT */
+ $convertFrom = $this->request['from'] == 'avatars' ? 'avatars' : 'photos';
+ $st = intval($this->request['st']);
+ $did = 0;
+ $each = 200;
+
+ /* Photo library */
+ require_once( IPS_ROOT_PATH . 'sources/classes/member/photo.php' );/*noLibHook*/
+ $photo = new classes_member_photo( $this->registry );
+
+ /* Loop over members */
+ $this->DB->build( array( 'select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'limit' => array( $st, $each ) ) );
+ $outer = $this->DB->execute();
+
+ while( $r = $this->DB->fetch($outer) )
+ {
+ $did++;
+
+ $update = array();
+
+ if( $r['fb_photo'] )
+ {
+ $update['pp_photo_type'] = 'facebook';
+ }
+ else if( $r['tc_photo'] )
+ {
+ $update['pp_photo_type'] = 'twitter';
+ }
+ else if( $r['vc_photo'] )
+ {
+ $update['pp_photo_type'] = 'vkontakte';
+ }
+
+ else
+ {
+ if( $convertFrom == 'avatars' )
+ {
+ if( $r['avatar_type'] == 'upload' AND $r['avatar_location'] )
+ {
+ $update['pp_photo_type'] = 'custom';
+ $update['pp_main_photo'] = $r['avatar_location'];
+ $_dims = @getimagesize( $this->settings['upload_dir'] . '/' . $r['avatar_location'] );
+ $update['pp_main_width'] = $_dims[0];
+ $update['pp_main_height'] = $_dims[1];
+ }
+ else if( $r['avatar_type'] == 'gravatar' )
+ {
+ $update['pp_photo_type'] = 'gravatar';
+ $update['pp_gravatar'] = $r['avatar_location'];
+
+ $md5Gravatar = md5( $update['pp_gravatar'] );
+
+ $_url = "http://www.gravatar.com";
+
+ if( $this->registry->output->isHTTPS )
+ {
+ $_url = "https://secure.gravatar.com";
+ }
+
+ $update['pp_main_photo'] = $_url . "/avatar/" .$md5Gravatar . "?s=100";
+ $update['pp_main_width'] = 100;
+ $update['pp_main_height'] = 100;
+ $update['pp_thumb_photo'] = $_url . "/avatar/" .$md5Gravatar . "?s=100";
+ $update['pp_thumb_width'] = 100;
+ $update['pp_thumb_height'] = 100;
+ }
+ }
+ else
+ {
+ if( $r['pp_main_photo'] )
+ {
+ $update['pp_photo_type'] = 'custom';
+ $update['pp_main_photo'] = $r['pp_main_photo'];
+ }
+ }
+ }
+
+ if( $update['pp_photo_type'] == 'custom' )
+ {
+ $info = $photo->buildSizedPhotos( str_replace( 'upload:', '', $update['pp_main_photo'] ), $r['pp_member_id'], true );
+
+ $update['pp_main_width'] = intval( $info['final_width'] );
+ $update['pp_main_height'] = intval( $info['final_height'] );
+ $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
+ $update['pp_thumb_width'] = intval( $info['t_final_width'] );
+ $update['pp_thumb_height'] = intval( $info['t_final_height'] );
+ }
+
+ if( count($update) )
+ {
+ $this->DB->update( 'profile_portal', $update, 'pp_member_id=' . $r['pp_member_id'] );
+ }
+ }
+
+ /* Show message and redirect */
+ if( $did > 0 )
+ {
+ $this->request['st'] = ( $st + $did );
+
+ $url = "{$this->settings['base_url']}{$this->form_code}&do=" . $this->request['do'] . '&from=' . $this->request['from'] . '&st=' . $this->request['st'];
+
+ $this->_specialRedirect( $url, sprintf( $this->lang->words['tools320photos'], $this->request['st'], $did ) );
+ }
+ else
+ {
+ $this->registry->output->redirect( $this->settings['base_url'] . $this->form_code . '&do=tools', $this->lang->words['re_photosconverted'] );
+ }
+ }
+
+ /**
+ * 3.0.x Tools: PM Conversion
+ *
+ * @return @e void
+ */
+ public function tools300pms()
+ {
+ /* INIT */
+ $pergo = 100;
+ $start = intval( $this->request['st'] );
+ $converted = 0;
+ $seen = 0;
+
+ //-----------------------------------------
+ // Check to make sure table exists
+ //-----------------------------------------
+
+ if ( ! $this->DB->checkForTable( 'message_text' ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['re_msgsconverted'];
+ $this->toolsSplashScreen();
+ return;
+ }
+
+
+ /* Select max topic ID thus far */
+ $_tmp = $this->DB->buildAndFetch( array( 'select' => 'MAX(mt_id) as max',
+ 'from' => 'message_topics' ) );
+
+ $topicID = intval( $_tmp['max'] );
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'message_text',
+ 'order' => 'msg_id ASC',
+ 'limit' => array( $start, $pergo ) ) );
+
+ $o = $this->DB->execute();
+
+ while( $post = $this->DB->fetch( $o ) )
+ {
+ $seen++;
+
+ /* Make sure all data is valid */
+ if ( intval( $post['msg_sent_to_count'] ) < 1 )
+ {
+ continue;
+ }
+
+ /* a little set up */
+ $oldTopics = array();
+
+ /* Now fetch all topics */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'message_topics_old',
+ 'where' => 'mt_msg_id=' . intval( $post['msg_id'] ) ) );
+
+ $t = $this->DB->execute();
+
+ while( $topic = $this->DB->fetch( $t ) )
+ {
+ /* Got any data? */
+ if ( ! $topic['mt_from_id'] OR ! $topic['mt_to_id'] )
+ {
+ continue;
+ }
+
+ $oldTopics[ $topic['mt_id'] ] = $topic;
+ }
+
+ /* Fail safe */
+ if ( ! count( $oldTopics ) )
+ {
+ continue;
+ }
+
+ /* Increment number */
+ $topicID++;
+
+ /* Add in the post */
+ $this->DB->insert( 'message_posts', array( 'msg_topic_id' => $topicID,
+ 'msg_date' => $post['msg_date'],
+ 'msg_post' => $post['msg_post'],
+ 'msg_post_key' => $post['msg_post_key'],
+ 'msg_author_id' => $post['msg_author_id'],
+ 'msg_ip_address' => $post['msg_ip_address'],
+ 'msg_is_first_post' => 1 ) );
+ $postID = $this->DB->getInsertId();
+
+ /* Update attachments */
+ $this->DB->update( 'attachments', array( 'attach_rel_id' => $postID ), "attach_rel_module='msg' AND attach_rel_id=".$post['msg_id'] );
+
+ /* Define some stuff. "To" member is added last in IPB 2 */
+ $_tmp = $oldTopics;
+ ksort( $_tmp );
+ $topicData = array_pop( $_tmp );
+ $_invited = array();
+ $_seenOwner = array();
+ $_isDeleted = 0;
+
+ /* Add the member rows */
+ foreach( $oldTopics as $mt_id => $data )
+ {
+ /* Prevent SQL error with unique index: Seen the owner ID already? */
+ if ( $_seenOwner[ $data['mt_owner_id'] ] )
+ {
+ continue;
+ }
+
+ $_seenOwner[ $data['mt_owner_id'] ] = $data['mt_owner_id'];
+
+ /* Build invited - does not include 'to' person */
+ if ( $data['mt_owner_id'] AND ( $post['msg_author_id'] != $data['mt_owner_id'] ) AND ( $topicData['mt_to_id'] != $data['mt_owner_id'] ) )
+ {
+ $_invited[ $data['mt_owner_id'] ] = $data['mt_owner_id'];/*noLibHook*/
+ }
+
+ $_isSent = ( $data['mt_vid_folder'] == 'sent' ) ? 1 : 0;
+ $_isDraft = ( $data['mt_vid_folder'] == 'unsent' ) ? 1 : 0;
+
+ $this->DB->insert( 'message_topic_user_map', array( 'map_user_id' => $data['mt_owner_id'],
+ 'map_topic_id' => $topicID,
+ 'map_folder_id' => ( $_isDraft ) ? 'drafts' : 'myconvo',
+ 'map_read_time' => ( $data['mt_user_read'] ) ? $data['mt_user_read'] : ( $data['mt_read'] ? time() : 0 ),
+ 'map_user_active' => 1,
+ 'map_user_banned' => 0,
+ 'map_has_unread' => 0, //( $data['mt_read'] ) ? 0 : 1,
+ 'map_is_system' => 0,
+ 'map_last_topic_reply' => $post['msg_date'],
+ 'map_is_starter' => ( $data['mt_owner_id'] == $post['msg_author_id'] ) ? 1 : 0 ) );
+
+ }
+
+ /* Now, did we see the author? If not, add them too but as inactive */
+ if ( ! $_seenOwner[ $post['msg_author_id'] ] )
+ {
+ $_isDeleted = 1;
+
+ /*$this->DB->insert( 'message_topic_user_map', array( 'map_user_id' => $post['msg_author_id'],
+ 'map_topic_id' => $topicID,
+ 'map_folder_id' => 'myconvo',
+ 'map_read_time' => 0,
+ 'map_user_active' => 0,
+ 'map_user_banned' => 0,
+ 'map_has_unread' => 0,
+ 'map_is_system' => 0,
+ 'map_is_starter' => 1 ) );*/
+ }
+
+ $_isSent = ( $topicData['mt_vid_folder'] == 'sent' ) ? 1 : 0;
+ $_isDraft = ( $topicData['mt_vid_folder'] == 'unsent' ) ? 1 : 0;
+
+ /* This is for MSSQL. I need a quick fix. This is it. Enjoy. */
+ if ( method_exists( $this->DB, 'setTableIdentityInsert' ) )
+ {
+ $this->DB->setTableIdentityInsert( 'message_topics', 'ON' );
+ }
+
+ /* Add the topic */
+ $this->DB->insert( 'message_topics', array( 'mt_id' => $topicID,
+ 'mt_date' => $topicData['mt_date'],
+ 'mt_title' => $topicData['mt_title'],
+ 'mt_starter_id' => $post['msg_author_id'],
+ 'mt_start_time' => $post['msg_date'],
+ 'mt_last_post_time' => $post['msg_date'],
+ 'mt_invited_members' => serialize( array_keys( $_invited ) ),
+ 'mt_to_count' => count( array_keys( $_invited ) ) + 1,
+ 'mt_to_member_id' => $topicData['mt_to_id'],
+ 'mt_replies' => 0,
+ 'mt_last_msg_id' => $postID,
+ 'mt_first_msg_id' => $postID,
+ 'mt_is_draft' => $_isDraft,
+ 'mt_is_deleted' => $_isDeleted,
+ 'mt_is_system' => 0 ) );
+
+ /* This is for MSSQL. I need a quick fix. This is it. Enjoy. */
+ if ( method_exists( $this->DB, 'setTableIdentityInsert' ) )
+ {
+ $this->DB->setTableIdentityInsert( 'message_topics', 'OFF' );
+ }
+
+ $converted++;
+ }
+
+ /* What to do? */
+ if ( $seen )
+ {
+ $this->request['st'] = $start + $pergo;
+
+ /* Re-do Page */
+ $url = "{$this->settings['base_url']}{$this->form_code}&do=".$this->request['do'].'&st=' . $this->request['st'];
+
+ $this->_specialRedirect( $url, sprintf( $this->lang->words['tools300pms'], $this->request['st'], $converted ) );
+ }
+ else
+ {
+ /* Update all members */
+ $this->DB->update( 'members', array( 'msg_count_reset' => 1 ) );
+
+ $this->registry->output->redirect( "{$this->settings['base_url']}{$this->form_code}&do=tools", $this->lang->words['re_pmsconverted'], 1 );
+ }
+ }
+
+ /**
+ * Tools: Ban Settings
+ *
+ * @return @e void
+ */
+ public function toolBanSettings()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $bomb = array();
+ $ban = array();
+ $ip_count = 0;
+ $email_count = 0;
+ $name_count = 0;
+
+ //-----------------------------------------
+ // Get current entries
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'banfilters', 'order' => 'ban_date desc' ) );
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ $ban[ $r['ban_type'] ][ $r['ban_content'] ] = $r;
+ }
+
+ //-----------------------------------------
+ // Get $INFO (again) ip email name
+ //-----------------------------------------
+ $INFO = array();
+ require( DOC_IPS_ROOT_PATH . 'conf_global.php' );/*noLibHook*/
+
+ //-----------------------------------------
+ // IP
+ //-----------------------------------------
+
+ if ( $INFO['ban_ip'] )
+ {
+ $bomb = explode( '|', $INFO['ban_ip'] );
+
+ if ( is_array( $bomb ) and count( $bomb ) )
+ {
+ foreach( $bomb as $bang )
+ {
+ if ( ! is_array($ban['ip'][ $bang ]) )
+ {
+ $this->DB->insert( 'banfilters', array( 'ban_type' => 'ip', 'ban_content' => $bang, 'ban_date' => time() ) );
+
+ $ip_count++;
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // EMAIL
+ //-----------------------------------------
+
+ if ( $INFO['ban_email'] )
+ {
+ $bomb = explode( '|', $INFO['ban_email'] );
+
+ if ( is_array( $bomb ) and count( $bomb ) )
+ {
+ foreach( $bomb as $bang )
+ {
+ if ( ! is_array($ban['email'][ $bang ]) )
+ {
+ $this->DB->insert( 'banfilters', array( 'ban_type' => 'email', 'ban_content' => $bang, 'ban_date' => time() ) );
+
+ $email_count++;
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // EMAIL
+ //-----------------------------------------
+
+ if ( $INFO['ban_names'] )
+ {
+ $bomb = explode( '|', $INFO['ban_names'] );
+
+ if ( is_array( $bomb ) and count( $bomb ) )
+ {
+ foreach( $bomb as $bang )
+ {
+ if ( ! is_array($ban['name'][ $bang ]) )
+ {
+ $this->DB->insert( 'banfilters', array( 'ban_type' => 'name', 'ban_content' => $bang, 'ban_date' => time() ) );
+
+ $name_count++;
+ }
+ }
+ }
+ }
+
+ $this->registry->output->global_message = sprintf( $this->lang->words['re_bansimport'], $ip_count, $email_count, $name_count );
+
+ $this->cache->rebuildCache( 'banfilters', 'global' );
+
+ $this->toolsSplashScreen();
+ }
+
+ /**
+ * 2.0.0 Tools: Converge
+ *
+ * @return @e void
+ */
+ public function toolsConverge()
+ {
+ //-----------------------------------------
+ // Get all validating members...
+ //-----------------------------------------
+
+ $to_unconverge = array();
+ $unconverge_count = 0;
+
+ $this->DB->build( array( 'select' => 'member_id, email, member_group_id', 'from' => 'members', 'where' => 'member_group_id='.$this->settings['auth_group'] ) );
+ $this->DB->execute();
+
+ while( $m = $this->DB->fetch() )
+ {
+ if ( preg_match( "#^{$m['member_id']}\-#", $m['email'] ) )
+ {
+ $to_unconverge[] = $m['member_id'];
+ }
+ }
+
+ $unconverge_count = intval( count( $to_unconverge ) );
+
+ if ( $unconverge_count )
+ {
+ foreach( $to_unconverge as $mid )
+ {
+ $this->DB->update( 'members' , array( 'member_group_id' => $this->settings['member_group'] ), 'member_id='.$mid );
+ }
+ }
+
+ //-----------------------------------------
+ // Time to move on dude
+ //-----------------------------------------
+
+ $this->registry->output->global_message = (sprintf( $this->lang->words['re_convergerest'], $unconverge_count ) );
+ $this->toolsSplashScreen();
+ }
+
+ /**
+ * 2.0.0 Tools: Dupe Settings
+ *
+ * @return @e void
+ */
+ public function toolsDupeSettings()
+ {
+ //-----------------------------------------
+ // Remove dupe categories
+ //-----------------------------------------
+
+ $title_id_to_keep = array();
+ $title_id_to_delete = array();
+ $title_deleted_count = 0;
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'order' => 'conf_title_id' ) );
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ if ( $title_id_to_keep[ $r['conf_title_title'] ] )
+ {
+ $title_id_to_delete[ $r['conf_title_id'] ] = $r['conf_title_id'];
+ }
+ else
+ {
+ $title_id_to_keep[ $r['conf_title_title'] ] = $r['conf_title_id'];
+ }
+ }
+
+ if ( count( $title_id_to_delete ) )
+ {
+ $this->DB->delete( 'conf_settings_titles', 'conf_title_id IN ('.implode( ',', $title_id_to_delete ).')' );
+ }
+
+ $title_deleted_count = intval( count($title_id_to_delete) );
+
+ //-----------------------------------------
+ // Remove dupe settings
+ //-----------------------------------------
+
+ $setting_id_to_keep = array();
+ $setting_id_to_delete = array();
+ $setting_id_deleted_count = 0;
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'order' => 'conf_id' ) );
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ if ( $setting_id_to_keep[ $r['conf_title'].','.$r['conf_key'] ] )
+ {
+ $setting_id_to_delete[ $r['conf_id'] ] = $r['conf_id'];
+ }
+ else
+ {
+ $setting_id_to_keep[ $r['conf_title'].','.$r['conf_key'] ] = $r['conf_id'];
+ }
+ }
+
+ if ( count( $setting_id_to_delete ) )
+ {
+ $this->DB->delete( 'conf_settings', 'conf_id IN ('.implode( ',', $setting_id_to_delete ).')' );
+ }
+
+ $setting_deleted_count = intval( count($setting_id_to_delete) );
+
+ //-----------------------------------------
+ // Time to move on dude
+ //-----------------------------------------
+
+ $this->registry->output->global_message = sprintf( $this->lang->words['re_deletetitle'], $title_deleted_count, $setting_deleted_count ) ;
+ $this->toolsSplashScreen();
+ }
+
+ /**
+ * 2.1.0 Tools: Dupe Settings
+ *
+ * @return @e void
+ */
+ public function tools210DupeSettings()
+ {
+ //-----------------------------------------
+ // Remove dupe categories
+ //-----------------------------------------
+
+ $title_id_to_keep = array();
+ $title_id_to_delete = array();
+ $title_deleted_count = 0;
+ $msg = '';
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_sys_settings_titles', 'order' => 'conf_title_id DESC' ) );
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ if ( $title_id_to_keep[ $r['conf_title_title'] ] )
+ {
+ $title_id_to_delete[ $r['conf_title_id'] ] = $r['conf_title_id'];
+
+ $msg .= sprintf( $this->lang->words['re_deletingid'], $r['conf_title_title'], $r['conf_title_id'] ) . " ";
+ }
+ else
+ {
+ $title_id_to_keep[ $r['conf_title_title'] ] = $r['conf_title_id'];
+ $msg .= sprintf( $this->lang->words['re_keepingid'], $r['conf_title_title'], $r['conf_title_id'] ) . " ";
+ }
+ }
+
+ if ( count( $title_id_to_delete ) )
+ {
+ $this->DB->delete( 'core_sys_conf_settings', 'conf_title_id IN ('.implode( ',', $title_id_to_delete ).')' );
+ }
+
+ $title_deleted_count = intval( count($title_id_to_delete) );
+
+ //-----------------------------------------
+ // Time to move on dude
+ //-----------------------------------------
+
+ $this->registry->output->global_message = sprintf( $this->lang->words['re_duplicatetitle'], $title_deleted_count, $msg );
+ $this->toolsSplashScreen();
+ }
+
+ /**
+ * 2.1.0 Tools: Calendar Events
+ *
+ * @return @e void
+ */
+ public function tools210Calevents()
+ {
+ $start = intval($_GET['st']);
+ $lend = 50;
+ $end = $start + $lend;
+ $max = intval($_GET['max']);
+
+ //-----------------------------------------
+ // Check to make sure table exists
+ //-----------------------------------------
+
+ if ( ! $this->DB->checkForTable( 'calendar_events' ) )
+ {
+ $this->registry->output->global_message = $this->lang->words['re_calremoved'];
+ $this->toolsSplashScreen();
+ return;
+ }
+
+ //-----------------------------------------
+ // Do we need to run this tool?
+ //-----------------------------------------
+
+ if ( ! $max )
+ {
+ $original = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as max', 'from' => 'calendar_events' ) );
+ $new = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as max', 'from' => 'cal_events' ) );
+
+ if ( $new['max'] >= $original['max'] OR ! $original['max'] )
+ {
+ $this->registry->output->global_message = $this->lang->words['re_calalready'];
+ $this->toolsSplashScreen();
+ }
+ }
+
+ $max = intval( $original['max'] );
+
+ //-----------------------------------------
+ // In steps...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'calendar_events', 'limit' => array( $start, $lend ) ) );
+ $o = $this->DB->execute();
+
+ //-----------------------------------------
+ // Do it...
+ //-----------------------------------------
+
+ if ( $this->DB->getTotalRows($o) )
+ {
+ //-----------------------------------------
+ // Got some to convert!
+ //-----------------------------------------
+
+ while ( $r = $this->DB->fetch($o) )
+ {
+ $recur_remap = array( 'w' => 1,
+ 'm' => 2,
+ 'y' => 3 );
+
+ $begin_date = IPSTime::date_getgmdate( $r['unix_stamp'] );
+ $end_date = IPSTime::date_getgmdate( $r['end_unix_stamp'] );
+
+ if ( ! $begin_date OR ! $end_date )
+ {
+ continue;
+ }
+
+ $day = $begin_date['mday'];
+ $month = $begin_date['mon'];
+ $year = $begin_date['year'];
+
+ $end_day = $end_date['mday'];
+ $end_month = $end_date['mon'];
+ $end_year = $end_date['year'];
+
+ $_final_unix_from = gmmktime(0, 0, 0, $month, $day, $year );
+
+ //-----------------------------------------
+ // Recur or ranged...
+ //-----------------------------------------
+
+ if ( $r['event_repeat'] OR $r['event_ranged'] )
+ {
+ $_final_unix_to = gmmktime(23, 59, 59, $end_month, $end_day, $end_year);
+ }
+ else
+ {
+ $_final_unix_to = 0;
+ }
+
+ $new_event = array( 'event_calendar_id' => 1,
+ 'event_member_id' => $r['userid'],
+ 'event_content' => $r['event_text'],
+ 'event_title' => $r['title'],
+ 'event_smilies' => $r['show_emoticons'],
+ 'event_perms' => $r['read_perms'],
+ 'event_private' => $r['priv_event'],
+ 'event_approved' => 1,
+ 'event_unixstamp' => $r['unix_stamp'],
+ 'event_recurring' => ( $r['event_repeat'] && $recur_remap[ $r['repeat_unit'] ] ) ? $recur_remap[ $r['repeat_unit'] ] : 0,
+ 'event_tz' => 0,
+ 'event_unix_from' => $_final_unix_from,
+ 'event_unix_to' => $_final_unix_to );
+
+ //-----------------------------------------
+ // INSERT
+ //-----------------------------------------
+
+ $this->DB->insert( 'cal_events', $new_event );
+ }
+
+ $this->registry->output->global_message = sprintf( $this->lang->words['re_calstartto'], $start, $end );
+
+ $url = "{$this->settings['base_url']}{$this->form_code}&do=".$this->request['do'].'&max='.$max.'&st='.$end;
+ }
+ else
+ {
+ $this->registry->output->global_message = $this->lang->words['re_calsconverted'];
+
+ $url = "{$this->settings['base_url']}{$this->form_code}&do=tools";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->registry->output->redirect( $url, $this->registry->output->global_message );
+ }
+
+ /**
+ * 2.1.0 Tools: Polls
+ *
+ * @return @e void
+ */
+ public function tools210Polls()
+ {
+ $start = intval( $this->request['st'] );
+ $lend = 50;
+ $end = $start + $lend;
+ $max = intval( $this->request['max'] );
+ $done = 0;
+ $converted = intval( $this->request['conv'] );
+
+ //-----------------------------------------
+ // First off.. grab number of polls to convert
+ //-----------------------------------------
+
+ if ( ! $max )
+ {
+ $total = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as max',
+ 'from' => 'topics',
+ 'where' => "poll_state IN ('open', 'close', 'closed')" ) );
+
+ $max = $total['max'];
+ }
+
+ if ( $max < 1 )
+ {
+ $done = 1;
+ }
+
+ //-----------------------------------------
+ // In steps...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'topics',
+ 'where' => "poll_state IN ('open', 'close', 'closed' )",
+ 'limit' => array( $start, $lend ) ) );
+ $o = $this->DB->execute();
+
+ //-----------------------------------------
+ // Do it...
+ //-----------------------------------------
+
+ if ( $this->DB->getTotalRows($o) )
+ {
+ //-----------------------------------------
+ // Got some to convert!
+ //-----------------------------------------
+
+ while ( $r = $this->DB->fetch($o) )
+ {
+ $converted++;
+
+ $new_poll = array( 1 => array() );
+
+ $poll_data = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'polls',
+ 'where' => "tid=".$r['tid']
+ ) );
+ if ( ! $poll_data['pid'] )
+ {
+ continue;
+ }
+
+ if ( ! $poll_data['poll_question'] )
+ {
+ $poll_data['poll_question'] = $r['title'];
+ }
+
+ //-----------------------------------------
+ // Kick start new poll
+ //-----------------------------------------
+
+ $new_poll[1]['question'] = $poll_data['poll_question'];
+
+ //-----------------------------------------
+ // Get OLD polls
+ //-----------------------------------------
+
+ $poll_answers = unserialize( stripslashes( $poll_data['choices'] ) );
+
+ reset($poll_answers);
+
+ foreach ( $poll_answers as $entry )
+ {
+ $id = $entry[0];
+ $choice = $entry[1];
+ $votes = $entry[2];
+
+ $total_votes += $votes;
+
+ if ( strlen($choice) < 1 )
+ {
+ continue;
+ }
+
+ $new_poll[ 1 ]['choice'][ $id ] = $choice;
+ $new_poll[ 1 ]['votes'][ $id ] = $votes;
+ }
+
+ //-----------------------------------------
+ // Got something?
+ //-----------------------------------------
+
+ if ( count( $new_poll[1]['choice'] ) )
+ {
+ $this->DB->update( 'polls' , array( 'choices' => serialize( $new_poll ) ), 'tid='.$r['tid'] );
+ $this->DB->update( 'topics', array( 'poll_state' => 1 ), 'tid='.$r['tid'] );
+ }
+
+ //-----------------------------------------
+ // All done?
+ //-----------------------------------------
+
+ if ( $converted >= $max )
+ {
+ $done = 1;
+ continue;
+ }
+ }
+ }
+ else
+ {
+ $done = 1;
+ }
+
+
+ if ( ! $done )
+ {
+ $this->registry->output->global_message = sprintf( $this->lang->words['re_pollstartto'], $start, $end, $max );
+
+ $url = "{$this->settings['base_url']}{$this->form_code}&do=".$this->request['do'].'&max='.$max.'&st='.$end.'&conv='.$converted;
+ }
+ else
+ {
+ $this->registry->output->global_message = $this->lang->words['re_pollconverted'];
+
+ $url = "{$this->settings['base_url']}{$this->form_code}&do=tools";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->registry->output->redirect( $url, $this->registry->output->global_message );
+ }
+
+ /**
+ * 2.2.0 Tools: Contacts
+ * DEPRECATED
+ *
+ * @return @e void
+ */
+ public function tools220Contacts()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $start = intval($_GET['st']);
+ $lend = 50;
+ $end = $start + $lend;
+ $done = 0;
+ $updated = 0;
+
+ //-----------------------------------------
+ // Get lib
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir('members') . '/sources/friends.php', 'profileFriendsLib', 'members' );
+ $profile = new $classToLoad( $this->registry );
+
+
+ //-----------------------------------------
+ // OK..
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'contacts',
+ 'where' => 'allow_msg=1',
+ 'limit' => array( $start, $lend ) ) );
+
+ $o = $this->DB->execute();
+
+ //-----------------------------------------
+ // Do it...
+ //-----------------------------------------
+
+ if ( $this->DB->getTotalRows($o) )
+ {
+ //-----------------------------------------
+ // Got some to convert!
+ //-----------------------------------------
+
+ while( $row = $this->DB->fetch( $o ) )
+ {
+ //-----------------------------------------
+ // Already a friend
+ //-----------------------------------------
+
+ $friend = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'profile_friends',
+ 'where' => 'friends_member_id=' . intval( $row['member_id'] ) . ' AND friends_friend_id=' . intval( $row['contact_id'] ) ) );
+
+ if ( ! $friend['friends_id'] )
+ {
+ //-----------------------------------------
+ // Add to DB
+ //-----------------------------------------
+
+ $this->DB->insert( 'profile_friends', array( 'friends_member_id' => $row['member_id'],
+ 'friends_friend_id' => $row['contact_id'],
+ 'friends_approved' => 1,
+ 'friends_added' => time() ) );
+
+ //-----------------------------------------
+ // Rebuild...
+ //-----------------------------------------
+
+ $profile->recacheFriends( array( 'member_id' => $row['member_id'] ) );
+
+ $updated++;
+ }
+
+ $this->DB->delete( "contacts", "id={$row['id']}" );
+ }
+ }
+ else
+ {
+ $done = 1;
+ }
+
+ //-----------------------------------------
+ // Done?
+ //-----------------------------------------
+
+ if ( ! $done )
+ {
+ $this->registry->output->global_message = sprintf( $this->lang->words['re_contactsstartto'],$start, $end, $updated );
+
+ $url = "{$this->settings['base_url']}{$this->form_code}&do=".$this->request['do'].'&st='.$end;
+ }
+ else
+ {
+ $this->registry->output->global_message = $this->lang->words['re_contactsup'];
+
+ $url = "{$this->settings['base_url']}{$this->form_code}&do=tools";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->registry->output->redirect( $url, $this->registry->output->global_message );
+ }
+
+ /**
+ * Cleanup Tools Splash Screen
+ *
+ * @return @e void
+ */
+ public function toolsSplashScreen()
+ {
+ /* Output */
+ $this->registry->output->html .= $this->html->toolsSplashScreen();
+ }
+
+ /**
+ * Count stats
+ *
+ * @return @e void
+ */
+ public function doCount()
+ {
+ if ( empty($this->request['posts']) && empty($this->request['online']) && empty($this->request['members']) && empty($this->request['lastreg']) )
+ {
+ $this->registry->output->showError( $this->lang->words['re_nothing'], 11154 );
+ }
+
+ $stats = $this->cache->getCache('stats');
+
+ if ( $this->request['posts'] )
+ {
+ $topics = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as tcount',
+ 'from' => 'topics',
+ 'where' => $this->registry->getClass('class_forums')->fetchTopicHiddenQuery( array( 'visible' ), '' ) ) );
+
+ $posts = $this->DB->buildAndFetch( array( 'select' => 'SUM(posts) as replies',
+ 'from' => 'topics',
+ 'where' => $this->registry->getClass('class_forums')->fetchTopicHiddenQuery( array( 'visible' ), '' ) ) );
+
+ $stats['total_topics'] = $topics['tcount'];
+ $stats['total_replies'] = $posts['replies'];
+ }
+
+ if ( $this->request['members'] )
+ {
+ $r = $this->DB->buildAndFetch( array( 'select' => 'count(member_id) as members', 'from' => 'members', 'where' => "member_group_id <> '{$this->settings['auth_group']}'" ) );
+
+ $stats['mem_count'] = intval($r['members']);
+ }
+
+ if ( $this->request['lastreg'] )
+ {
+ $stats = array_merge( $stats, IPSMember::resetLastRegisteredMember( true ) );
+ }
+
+ if ( $this->request['online'] )
+ {
+ $stats['most_date'] = time();
+ $stats['most_count'] = 1;
+ }
+
+ $this->cache->setCache( 'stats', $stats, array( 'array' => 1 ) );
+
+ $this->registry->output->global_message = $this->lang->words['re_statsrecount'];
+ $this->registry->output->silentRedirectWithMessage( $this->settings['base_url'] . $this->form_code );
+ }
+
+ /**
+ * Clean out photos
+ *
+ * @return @e void
+ */
+ public function cleanPhotos()
+ {
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >= 0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $display = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Pop open the directory and
+ // peek inside...
+ //-----------------------------------------
+
+ $i = 0;
+
+ try
+ {
+ foreach( new DirectoryIterator( $this->settings['upload_dir'] . '/profile' ) as $file )
+ {
+ if ( strstr( $file->getFilename(), 'photo-' ) )
+ {
+ $fullfile = $file->getPathname();
+ $relativefile = str_replace( $this->settings['upload_dir'] . '/', '', $fullfile );
+
+ $i++;
+
+ //-----------------------------------------
+ // Already started?
+ //-----------------------------------------
+
+ if ( $start > $i )
+ {
+ continue;
+ }
+
+ //-----------------------------------------
+ // Done for this iteration?
+ //-----------------------------------------
+
+ if ( $i > $display )
+ {
+ break;
+ }
+
+ //-----------------------------------------
+ // Try and get attach row
+ //-----------------------------------------
+
+ $found = $this->DB->buildAndFetch( array( 'select' => 'pp_member_id', 'from' => 'profile_portal', 'where' => "pp_main_photo='{$relativefile}' OR pp_thumb_photo='{$relativefile}'" ) );
+
+ if ( ! $found['pp_member_id'] )
+ {
+ @unlink( $fullfile );
+ $output[] = "{$this->lang->words['re_removedorph']} {$file->getFilename()} ";
+ }
+ else
+ {
+ $output[] = "{$this->lang->words['re_attachedok']} {$file->getFilename()} ";
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( $i < $display)
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $display );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$display}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Clean out attachments
+ *
+ * @return @e void
+ */
+ public function cleanAttachments()
+ {
+ /* Upload Class */
+ require_once( IPS_KERNEL_PATH.'classUpload.php' );/*noLibHook*/
+ $upload = new classUpload();
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Pop open the directory and
+ // peek inside...
+ //-----------------------------------------
+
+ $i = 0;
+
+ try
+ {
+ foreach( new DirectoryIterator( $this->settings['upload_dir'] ) as $file )
+ {
+ if ( $file->getFilename() == '.' OR $file->getFilename() == '..' )
+ {
+ continue;
+ }
+
+ $fullfile = $this->settings['upload_dir'] . '/' . $file->getFilename();
+
+ if( is_dir( $fullfile ) )
+ {
+ $ndh = opendir( $fullfile );
+
+ try
+ {
+ foreach( new DirectoryIterator( $fullfile ) as $nfile )
+ {
+ if ( $nfile->getFilename() == '.' OR $nfile->getFilename() == '..' )
+ {
+ continue;
+ }
+
+ if ( strstr( $nfile->getFilename(), 'post-' ) )
+ {
+ $i++;
+
+ //-----------------------------------------
+ // Already started?
+ //-----------------------------------------
+
+ if ( $start > $i )
+ {
+ continue;
+ }
+
+ //-----------------------------------------
+ // Done for this iteration?
+ //-----------------------------------------
+
+ if ( $i > $dis )
+ {
+ break;
+ }
+
+ //-----------------------------------------
+ // Try and get attach row
+ //-----------------------------------------
+
+ $found = $this->DB->buildAndFetch( array( 'select' => 'attach_id', 'from' => 'attachments', 'where' => "attach_location='{$file->getFilename()}/{$nfile->getFilename()}' OR attach_thumb_location='{$file->getFilename()}/{$nfile->getFilename()}'" ) );
+
+ if ( ! $found['attach_id'] )
+ {
+ @unlink( $fullfile . '/' . $nfile );
+ $output[] = "{$this->lang->words['re_removedorph']} {$nfile->getFilename()} ";
+ }
+ else
+ {
+ $output[] = "{$this->lang->words['re_attachedok']} {$nfile->getFilename()} ";
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ closedir( $ndh );
+ }
+ else if ( strstr( $file, 'post-' ) )
+ {
+ $i++;
+
+ //-----------------------------------------
+ // Already started?
+ //-----------------------------------------
+
+ if ( $start > $i )
+ {
+ continue;
+ }
+
+ //-----------------------------------------
+ // Done for this iteration?
+ //-----------------------------------------
+
+ if ( $i > $dis )
+ {
+ break;
+ }
+
+ //-----------------------------------------
+ // Try and get attach row
+ //-----------------------------------------
+
+ $found = $this->DB->buildAndFetch( array( 'select' => 'attach_id', 'from' => 'attachments', 'where' => "attach_location='{$file->getFilename()}' OR attach_thumb_location='{$file->getFilename()}'" ) );
+
+ if ( ! $found['attach_id'] )
+ {
+ @unlink( $fullfile );
+ $output[] = "{$this->lang->words['re_removedorph']} {$file->getFilename()} ";
+ }
+ else
+ {
+ $output[] = "{$this->lang->words['re_attachedok']} {$file->getFilename()} ";
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( $i < $dis)
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+
+ $text = sprintf( $this->lang->words['re_thisgoeshere'], $dis ) . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Rebuild Attachment Data
+ *
+ * @return @e void
+ */
+ public function rebuildAttachdata()
+ {
+ /* Upload Class */
+ require_once( IPS_KERNEL_PATH.'classUpload.php' );/*noLibHook*/
+ $upload = new classUpload();
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'attach_id', 'from' => 'attachments', 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['attach_id'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'attachments', 'order' => 'attach_id ASC', 'limit' => array($start,$end) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ //-----------------------------------------
+ // Get ext
+ //-----------------------------------------
+
+ $update = array();
+
+ $update['attach_ext'] = IPSText::getFileExtension( $r['attach_file'] );
+
+ if ( $r['attach_location'] )
+ {
+ if ( is_file( $this->settings['upload_dir'].'/'.$r['attach_location'] ) )
+ {
+ $update['attach_filesize'] = @filesize( $this->settings['upload_dir'].'/'.$r['attach_location'] );
+
+ if( $r['attach_is_image'] )
+ {
+ $dims = @getimagesize( $this->settings['upload_dir'].'/'.$r['attach_location'] );
+
+ if( $dims[0] AND $dims[1] )
+ {
+ $update['attach_img_width'] = $dims[0];
+ $update['attach_img_height'] = $dims[1];
+ }
+ }
+ }
+ }
+
+ if ( count( $update ) )
+ {
+ $this->DB->update( 'attachments', $update, 'attach_id='.$r['attach_id'] );
+ }
+
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Rebuild Photos
+ *
+ * @return @e void
+ */
+ public function rebuildPhotos()
+ {
+ /* Image Class */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo' );
+ $photoClass = new $classToLoad( $this->registry );
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'pp_member_id', 'from' => 'profile_portal', 'where' => "pp_main_photo != ''", 'order' => 'pp_member_id ASC', 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['pp_member_id'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'where' => "pp_main_photo != ''", 'limit' => array($start,$end) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ /* Preserve FB, Twitter and Gravatar photos */
+ if( $r['pp_photo_type'] != 'custom' )
+ {
+ continue;
+ }
+
+ $update = array();
+
+ $info = $photoClass->buildSizedPhotos( str_replace( 'upload:', '', $r['pp_main_photo'] ), $r['pp_member_id'], true );
+
+ if( $info['status'] == 'missing_image' )
+ {
+ $update['pp_main_photo'] = '';
+ $update['pp_main_width'] = 0;
+ $update['pp_main_height'] = 0;
+ $update['pp_thumb_photo'] = '';
+ $update['pp_thumb_width'] = 0;
+ $update['pp_thumb_height'] = 0;
+ }
+ else
+ {
+ $update['pp_main_width'] = intval( $info['final_width'] );
+ $update['pp_main_height'] = intval( $info['final_height'] );
+ $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
+ $update['pp_thumb_width'] = intval( $info['t_final_width'] );
+ $update['pp_thumb_height'] = intval( $info['t_final_height'] );
+ }
+
+ $this->DB->update( 'profile_portal', $update, 'pp_member_id=' . $r['pp_member_id'] );
+
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Rebuild Post Thumbnails
+ *
+ * @return @e void
+ */
+ public function rebuildThumbnails()
+ {
+ require_once( IPS_KERNEL_PATH . 'classImage.php' );/*noLibHook*/
+ require_once( IPS_KERNEL_PATH . 'classImageGd.php' );/*noLibHook*/
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'attach_id', 'from' => 'attachments', 'where' => "attach_rel_module IN('post','msg')", 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['attach_id'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'attachments', 'where' => "attach_rel_module IN('post','msg')", 'order' => 'attach_id ASC', 'limit' => array($start,$end) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ if ( $r['attach_is_image'] )
+ {
+ if ( $r['attach_thumb_location'] and ( $r['attach_thumb_location'] != $r['attach_location'] ) )
+ {
+ if ( is_file( $this->settings['upload_dir'] . '/' . $r['attach_thumb_location'] ) )
+ {
+ if ( ! @unlink( $this->settings['upload_dir'] . '/' . $r['attach_thumb_location'] ) )
+ {
+ $output[] = $this->lang->words['re_noremove'] . $r['attach_thumb_location'];
+ continue;
+ }
+ }
+ }
+
+ $attach_data = array();
+ $thumbnail = preg_replace( "/^(.*)\.(.+?)$/", "\\1_thumb.\\2", $r['attach_location'] );
+
+ $image = new classImageGd();
+
+ $image->init( array(
+ 'image_path' => $this->settings['upload_dir'],
+ 'image_file' => $r['attach_location'],
+ ) );
+
+ $image->force_resize = false;
+
+ $return = $image->resizeImage( $this->settings['siu_width'], $this->settings['siu_height'] );
+
+ if( !$return['noResize'] )
+ {
+ $image->writeImage( $this->settings['upload_dir'] . '/' . $thumbnail );
+
+ $attach_data['attach_thumb_location'] = $thumbnail;
+ }
+ else
+ {
+ $attach_data['attach_thumb_location'] = $r['attach_location'];
+ }
+
+ $attach_data['attach_thumb_width'] = intval($return['newWidth'] ? $return['newWidth'] : $image->cur_dimensions['width']);
+ $attach_data['attach_thumb_height'] = intval($return['newHeight'] ? $return['newHeight'] : $image->cur_dimensions['height']);
+
+ if ( count( $attach_data ) )
+ {
+ $this->DB->update( 'attachments', $attach_data, 'attach_id='.$r['attach_id'] );
+
+ $output[] = $this->lang->words['re_resized'] . $r['attach_location'];
+ }
+
+ unset($image);
+ }
+
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Rebuild Messenger Totals
+ *
+ * @return @e void
+ */
+ public function rebuildMsgCounts()
+ {
+ //-----------------------------------------
+ // Grab messenger lib
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'members' ) . '/sources/classes/messaging/messengerFunctions.php', 'messengerFunctions', 'members' );
+ $messengerFunctions = new $classToLoad( $this->registry );
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['member_id'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array($start,$end) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ $messengerFunctions->resetMembersFolderCounts( $r['member_id'] );
+ $messengerFunctions->resetMembersTotalTopicCount( $r['member_id'] );
+ $messengerFunctions->resetMembersNewTopicCount( $r['member_id'] );
+
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Rebuild Post Count
+ *
+ * @return @e void
+ */
+ public function rebuildPostCount()
+ {
+ //-----------------------------------------
+ // Forums not to count?
+ //-----------------------------------------
+
+ $forums = array();
+
+ foreach( $this->registry->class_forums->forum_by_id as $data )
+ {
+ if ( ! $data['inc_postcount'] )
+ {
+ $forums[] = $data['id'];
+ }
+ }
+
+ /* Init */
+ if ( ! $this->registry->isClassLoaded('topics') )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . "/sources/classes/topics.php", 'app_forums_classes_topics', 'forums' );
+ $this->registry->setClass( 'topics', new $classToLoad( $this->registry ) );
+ }
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['member_id'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'member_id, name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array($start,$end) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ if ( ! count( $forums ) )
+ {
+ $count = $this->registry->topics->getPosts( array( 'onlyViewable' => false,
+ 'skipForumCheck' => true,
+ 'getCountOnly' => true,
+ 'authorId' => $r['member_id'] ) );
+ }
+ else
+ {
+ $count = $this->registry->topics->getPosts( array( 'onlyViewable' => false,
+ 'skipForumCheck' => true,
+ 'getCountOnly' => true,
+ 'notForumId' => $forums,
+ 'authorId' => $r['member_id'] ) );
+ }
+
+ if ( $this->settings['archive_on'] )
+ {
+ if ( ! count( $forums ) )
+ {
+ $acount = $this->registry->topics->getPosts( array( 'onlyViewable' => false,
+ 'skipForumCheck' => true,
+ 'getCountOnly' => true,
+ 'isArchivedTopic' => true,
+ 'authorId' => $r['member_id'] ) );
+ }
+ else
+ {
+ $acount = $this->registry->topics->getPosts( array( 'onlyViewable' => false,
+ 'skipForumCheck' => true,
+ 'getCountOnly' => true,
+ 'notForumId' => $forums,
+ 'isArchivedTopic' => true,
+ 'authorId' => $r['member_id'] ) );
+ }
+
+ $count += intval( $acount );
+ }
+
+ $this->DB->update( 'members', array( 'posts' => intval( $count ) ), 'member_id='.$r['member_id'] );
+
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Rebuild Reputation Counts
+ *
+ * @return @e void
+ */
+ public function rebuildReputationCount()
+ {
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Load reputation classes
+ //-----------------------------------------
+
+ $_rep_author_config = array();
+ $_rep_log_joins = array();
+ foreach( ipsRegistry::$applications as $appKey => $data )
+ {
+ $rep_author_config = array();
+ $rep_log_joins = array();
+ $file = IPSLib::getAppDir( $appKey ) . '/extensions/reputation.php';
+
+ if ( file_exists( $file ) )
+ {
+ require( $file );/*noLibHook*/
+ $_rep_author_config[ $appKey ] = $rep_author_config;
+ $_rep_log_joins[ $appKey ] = $rep_log_joins;
+ }
+ }
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['member_id'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'member_id, name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array($start,$end) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ $total = 0;
+
+ foreach ( $_rep_author_config as $app => $types )
+ {
+ foreach ( $types as $type => $data )
+ {
+ $prefix = NULL;
+ foreach ( $_rep_log_joins[ $app ] as $j )
+ {
+ if ( is_array( $j['from'] ) AND count( $j['from'] ) )
+ {
+ foreach ( $j['from'] as $t => $p )
+ {
+ if ( $t == $data['table'] )
+ {
+ $prefix = $p;
+ break 2;
+ }
+ }
+ }
+ }
+
+ if ( !is_null( $prefix ) )
+ {
+ $_total = $this->DB->buildAndFetch( array(
+ 'select' => "sum(r.rep_rating) as total",
+ 'from' => array( 'reputation_index' => 'r' ),
+ 'add_join' => $_rep_log_joins[ $app ],
+ 'where' => "r.app='{$app}' AND r.type='{$type}' AND {$prefix}.{$data['column']}={$r['member_id']}",
+ 'group' => "{$prefix}.{$data['column']}",
+ ) );
+
+ $total += $_total['total'];
+ }
+ }
+ }
+
+ $this->DB->update( 'profile_portal', array( 'pp_reputation_points' => $total ), 'pp_member_id='.$r['member_id'] );
+
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Rebuild Seo User Names
+ *
+ * @return @e void
+ */
+ public function rebuildSeoUserNames()
+ {
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array( $dis, 1 ) ) );
+ $max = intval( $tmp['member_id'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array( $start, $end ) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ $this->DB->update( 'members', array( 'members_seo_name' => IPSText::makeSeoTitle( $r['members_display_name'] ) ), "member_id=" . $r['member_id'] );
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+
+ /**
+ * Rebuild Post Names
+ *
+ * @return @e void
+ */
+ public function rebuildPostNames()
+ {
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'member_id', 'from' => 'members', 'limit' => array( $dis, 1 ) ) );
+ $max = intval( $tmp['member_id'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'member_id, members_display_name', 'from' => 'members', 'order' => 'member_id ASC', 'limit' => array( $start, $end ) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ $seoName = IPSText::makeSeoTitle( $r['members_display_name'] );
+ $this->DB->update( 'topics', array( 'starter_name' => $r['members_display_name'], 'seo_first_name' => $seoName ), "starter_id=" . $r['member_id'] );
+ $this->DB->update( 'topics', array( 'last_poster_name' => $r['members_display_name'], 'seo_last_name' => $seoName ), "last_poster_id=" . $r['member_id'] );
+
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Rebuild posts
+ *
+ * @return @e void
+ */
+ public function rebuildPosts()
+ {
+ //-----------------------------------------
+ // If it's "none", go back
+ //-----------------------------------------
+
+ if( !$this->request['type'] OR $this->request['type'] == 'none' )
+ {
+ $this->rebuildSplashScreen();
+ return;
+ }
+
+ //-----------------------------------------
+ // Only need to rebuild once
+ //-----------------------------------------
+
+ $sections = array();
+ $alreadyRebuilt = $this->DB->buildAndFetch( array( 'select' => 'cs_value', 'from' => 'cache_store', 'where' => "cs_key='isRebuilt'" ) );
+
+ if( $alreadyRebuilt['cs_value'] )
+ {
+ $sections = explode( ',', $alreadyRebuilt['cs_value'] );
+ }
+
+ //-----------------------------------------
+ // Get new parser and old parser
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/bbcode/core.php', 'class_bbcode_core' );
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/bbcode/legacy.php', 'class_bbcode_legacy' );
+ $parser = new $classToLoad( $this->registry );
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
+ $newParser = new $classToLoad();
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $last = 0;
+ $start = intval($this->request['st']) >=0 ? intval($this->request['st']) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = intval($this->request['dis']) >=0 ? intval($this->request['dis']) : 0;
+ $output = array();
+ $plugin = null;
+
+ $types = array( 'posts', 'pms', 'announce', 'sigs', 'aboutme', 'rules' );
+
+ foreach( ipsRegistry::$applications as $app_dir => $app_data )
+ {
+ //-----------------------------------------
+ // Retrieve the RSS links for the header
+ //-----------------------------------------
+
+ if( is_file( IPSLib::getAppDir( $app_dir ) . '/extensions/upgradePostRebuild.php' ) )
+ {
+ $className = IPSLib::loadLibrary( IPSLib::getAppDir( $app_dir ) . '/extensions/upgradePostRebuild.php', 'postRebuild_'.$app_dir, $app_dir );
+
+ if( class_exists( $className ) )
+ {
+ $rebuild = new $className( $this->registry );
+
+ if( method_exists( $rebuild, "getDropdown" ) )
+ {
+ $options = $rebuild->getDropdown();
+
+ if( count($options) )
+ {
+ foreach( $options as $appOption )
+ {
+ $types[] = $appOption[0];
+
+ if( $appOption[0] == $this->request['type'] )
+ {
+ $plugin =& $rebuild;
+ break 2;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ $type = in_array( $this->request['type'], $types ) ? $this->request['type'] : 'posts';
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ switch( $type )
+ {
+ case 'announce':
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'announce_id', 'from' => 'announcements', 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['announce_id'] );
+ break;
+
+ case 'pms':
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'msg_id', 'from' => 'message_posts', 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['msg_id'] );
+ break;
+
+ case 'sigs':
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'pp_member_id', 'from' => 'profile_portal', 'where' => "signature IS NOT NULL AND signature != ''", 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['pp_member_id'] );
+ break;
+
+ case 'aboutme':
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'pp_member_id', 'from' => 'profile_portal', 'where' => "pp_about_me IS NOT NULL AND pp_about_me != ''", 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['pp_member_id'] );
+ break;
+
+ case 'posts':
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'pid', 'from' => 'posts', 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['pid'] );
+ break;
+
+ case 'rules':
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'id', 'from' => 'forums', 'where' => "rules_text IS NOT NULL AND rules_text != ''", 'limit' => array($dis,1) ) );
+ $max = intval( $tmp['id'] );
+ break;
+
+ default:
+ $max = $rebuild->getMax( $type, $dis );
+ break;
+
+ }
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ switch( $type )
+ {
+ case 'announce':
+ $this->DB->build( array( 'select' => 'a.*',
+ 'from' => array( 'announcements' => 'a' ),
+ 'order' => 'a.announce_id ASC',
+ 'where' => 'a.announce_id > ' . $start,
+ 'limit' => array($end),
+ 'add_join' => array( 1 => array( 'type' => 'left',
+ 'select' => 'm.member_group_id, m.mgroup_others',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => "m.member_id=a.announce_member_id"
+ ) )
+ ) );
+ break;
+
+ case 'pms':
+ $this->DB->build( array( 'select' => 'p.*',
+ 'from' => array( 'message_posts' => 'p' ),
+ 'order' => 'p.msg_id ASC',
+ 'where' => 'p.msg_id > ' . $start,
+ 'limit' => array($end),
+ 'add_join' => array( 1 => array( 'type' => 'left',
+ 'select' => 'm.member_group_id, m.mgroup_others',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => "m.member_id=p.msg_author_id"
+ ) )
+ ) );
+ break;
+
+ case 'sigs':
+ $this->DB->build( array( 'select' => 'me.signature, me.pp_member_id',
+ 'from' => array( 'profile_portal' => 'me' ),
+ 'order' => 'me.pp_member_id ASC',
+ 'where' => "me.signature IS NOT NULL AND me.signature != '' AND me.pp_member_id > " . $start,
+ 'limit' => array($end),
+ 'add_join' => array( 1 => array( 'type' => 'left',
+ 'select' => 'm.member_group_id, m.mgroup_others',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => "m.member_id=me.pp_member_id"
+ ) )
+ ) );
+ break;
+
+ case 'aboutme':
+ $this->DB->build( array( 'select' => 'pp.pp_about_me, pp.pp_member_id',
+ 'from' => array( 'profile_portal' => 'pp' ),
+ 'order' => 'pp.pp_member_id ASC',
+ 'where' => "pp.pp_about_me != '' AND pp.pp_about_me IS NOT NULL AND pp.pp_member_id > " . $start,
+ 'limit' => array($end),
+ 'add_join' => array( 1 => array( 'type' => 'left',
+ 'select' => 'm.member_group_id, m.mgroup_others',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => "m.member_id=pp.pp_member_id"
+ ) )
+ ) );
+ break;
+
+ case 'posts':
+ $this->DB->build( array( 'select' => 'p.*',
+ 'from' => array( 'posts' => 'p' ),
+ 'order' => 'p.pid ASC',
+ 'where' => 'p.pid > ' . $start,
+ 'limit' => array($end),
+ 'add_join' => array( 1 => array( 'type' => 'left',
+ 'select' => 't.forum_id',
+ 'from' => array( 'topics' => 't' ),
+ 'where' => "t.tid=p.topic_id"
+ ),
+ 2 => array( 'type' => 'left',
+ 'select' => 'm.member_group_id, m.mgroup_others',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => "m.member_id=p.author_id"
+ ) )
+ ) );
+ break;
+
+ case 'rules':
+ $this->DB->build( array( 'select' => '*', 'from' => 'forums', 'order' => 'id ASC', 'where' => "rules_text IS NOT NULL AND rules_text != '' AND id > " . $start, 'limit' => array($end) ) );
+ break;
+
+ default:
+ $plugin->executeQuery( $type, $start, $end );
+ break;
+ }
+
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ /* On mssql, the select query blocks all the updates. Doing this causes the engine not to lock */
+ if ( method_exists( $this->DB, 'setQueryRowLocking' ) )
+ {
+ $this->DB->setQueryRowLocking( 'OFF' );
+ }
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ //-----------------------------------------
+ // Group
+ //-----------------------------------------
+
+ if( $r['member_group_id'] )
+ {
+ $r = array_merge( $r, $this->caches['group_cache'][ $r['member_group_id'] ] );
+ }
+
+ //-----------------------------------------
+ // Reset
+ //-----------------------------------------
+
+ $parser->quote_open = 0;
+ $parser->quote_closed = 0;
+ $parser->quote_error = 0;
+ $parser->error = '';
+ $parser->image_count = 0;
+ $parser->parsing_mgroup = $r['member_group_id'];
+ $parser->parsing_mgroup_others = $r['mgroup_others'];
+
+ $this->memberData['g_bypass_badwords'] = $this->caches['group_cache'][ $r['member_group_id'] ]['g_bypass_badwords'];
+
+ switch( $type )
+ {
+ case 'announce':
+ $parser->parse_smilies = 1;
+ $parser->parse_html = $r['announce_html_enabled'];
+ $parser->parse_bbcode = 1;
+ $parser->parse_nl2br = ( $r['announce_html_enabled'] ? $r['announce_nlbr_enabled'] : 1 );
+ $parser->parsing_section = 'announcement';
+
+ $rawpost = $parser->preEditParse( $r['announce_post'] );
+ break;
+
+ case 'pms':
+ $parser->parse_smilies = 1;
+ $parser->parse_html = $r['g_dohtml'];
+ $parser->parse_bbcode = 1;
+ $parser->parse_nl2br = 1;
+ $parser->parsing_section = 'pms';
+
+ $rawpost = $parser->preEditParse( $r['msg_post'] );
+ break;
+
+ case 'sigs':
+ $parser->parse_smilies = 0;
+ $parser->parse_html = $r['g_dohtml'];
+ $parser->parse_bbcode = 1;
+ $parser->parse_nl2br = 1;
+ $parser->parsing_section = 'signatures';
+
+ $rawpost = $parser->preEditParse( $r['signature'] );
+ break;
+
+ case 'aboutme':
+ $parser->parse_smilies = 1;
+ $parser->parse_html = $r['g_dohtml'];
+ $parser->parse_bbcode = 1;
+ $parser->parse_nl2br = 1;
+ $parser->parsing_section = 'aboutme';
+
+ $rawpost = $parser->preEditParse( $r['pp_about_me'] );
+ break;
+
+ case 'posts':
+ $parser->parse_smilies = $r['use_emo'];
+ $parser->parse_html = ( $r['post_htmlstate'] && $this->registry->class_forums->forum_by_id[ $r['forum_id'] ]['use_html'] && $r['g_dohtml'] );
+ $parser->parse_bbcode = $this->registry->class_forums->forum_by_id[ $r['forum_id'] ]['use_ibc'];
+ $parser->parse_nl2br = 1;
+ $parser->parsing_section = 'topics';
+
+ $rawpost = $parser->preEditParse( $r['post'] );
+
+ $allowHtml = ( $r['post_htmlstate'] && $this->registry->class_forums->forum_by_id[ $r['forum_id'] ]['use_html'] && $r['g_dohtml'] );
+
+ $newParser->set( array( 'parseArea' => 'topics',
+ 'memberData' => $r,
+ 'parseBBCode' => $this->registry->class_forums->forum_by_id[ $r['forum_id'] ]['use_ibc'],
+ 'parseHtml' => $allowHtml,
+ 'parseEmoticons' => $r['use_emo'] ) );
+
+ $rawpost = $newParser->BBCodeToHtml( $rawpost );
+ break;
+
+ case 'rules':
+ $parser->parse_smilies = 1;
+ $parser->parse_html = 1;
+ $parser->parse_bbcode = 1;
+ $parser->parse_nl2br = 1;
+ $parser->parsing_section = 'rules';
+
+ $rawpost = $parser->preEditParse( $r['rules_text'] );
+ break;
+
+ default:
+ $plugin->parser =& $parser;
+
+ $rawpost = $plugin->getRawPost( $type, $r );
+ break;
+ }
+
+ /* @link http://community.invisionpower.com/tracker/issue-36434-rebuild-post-content-remove-break-from-post-content/ New parser retains , legacy retains \n */
+ if ( $type == 'posts' || $type == 'sigs' )
+ {
+ /* Anything special here? */
+ $newpost = $rawpost;
+ }
+ else
+ {
+ if ( strstr( $rawpost, "\n" ) )
+ {
+ $rawpost = nl2br( $rawpost );
+ }
+
+ $newpost = $parser->preDbParse( $rawpost );
+ }
+
+
+ //-----------------------------------------
+ // Remove old \' escaping
+ //-----------------------------------------
+
+ $newpost = str_replace( "\\'", "'", $newpost );
+
+ //-----------------------------------------
+ // Convert old dohtml?
+ //-----------------------------------------
+
+ $htmlstate = 0;
+
+ if ( strstr( strtolower($newpost), '[dohtml]' ) )
+ {
+ //-----------------------------------------
+ // Can we use HTML?
+ //-----------------------------------------
+
+ if ( $type == 'posts' AND $this->registry->class_forums->forum_by_id[ $r['forum_id'] ]['use_html'] )
+ {
+ $htmlstate = 2;
+ }
+
+ $newpost = preg_replace( "#\[dohtml\]#i" , "", $newpost );
+ $newpost = preg_replace( "#\[/dohtml\]#i", "", $newpost );
+ }
+ else
+ {
+ $htmlstate = intval( $r['post_htmlstate'] );
+ }
+
+ //-----------------------------------------
+ // Convert old attachment tags
+ //-----------------------------------------
+
+ $newpost = preg_replace( "#\[attachmentid=(\d+?)\]#is", "[attachment=\\1:attachment]", $newpost );
+
+ if ( $newpost OR $type == 'sigs' OR $type == 'aboutme' )
+ {
+ switch( $type )
+ {
+ case 'posts':
+ $this->DB->update( 'posts', array( 'post' => $newpost, 'post_htmlstate' => $htmlstate ), 'pid='.$r['pid'] );
+ $last = $r['pid'];
+ break;
+
+ case 'pms':
+ $this->DB->update( 'message_posts', array( 'msg_post' => $newpost ), 'msg_id='.$r['msg_id'] );
+ $last = $r['msg_id'];
+ break;
+
+ case 'sigs':
+ $this->DB->update( 'profile_portal', array( 'signature' => $newpost ), 'pp_member_id='.$r['pp_member_id'] );
+ $last = $r['pp_member_id'];
+ break;
+
+ case 'aboutme':
+ $this->DB->update( 'profile_portal', array( 'pp_about_me' => $newpost ), 'pp_member_id='.$r['pp_member_id'] );
+ $last = $r['pp_member_id'];
+ break;
+
+ case 'announce':
+ $this->DB->update( 'announcements', array( 'announce_post' => $newpost ), 'announce_id='.$r['announce_id'] );
+ $last = $r['announce_id'];
+ break;
+
+ case 'rules':
+ $this->DB->update( 'forums', array( 'rules_text' => $newpost ), 'id='.$r['id'] );
+ $last = $r['id'];
+ break;
+
+ default:
+ $last = $plugin->storeNewPost( $type, $r, $newpost );
+ break;
+ }
+ }
+
+ $done++;
+ }
+
+ if ( method_exists( $this->DB, 'setQueryRowLocking' ) )
+ {
+ $this->DB->setQueryRowLocking( 'ON' );
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $last and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+
+ $sections[] = $type;
+ $this->DB->replace( 'cache_store', array( 'cs_key' => 'isRebuilt', 'cs_value' => implode( ',', $sections ) ), array( "cs_key" ) );
+
+ if( $type == 'posts' )
+ {
+ $this->DB->delete( 'content_cache_posts' );
+ }
+ else if( $type == 'sigs' )
+ {
+ $this->DB->delete( 'content_cache_sigs' );
+ }
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+
+ $dis = $dis + $done;
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&type={$type}&pergo={$this->request['pergo']}&st={$last}&dis={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Resyncronize Topics
+ *
+ * @return @e void
+ */
+ public function resyncTopics()
+ {
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums' );
+ $modfunc = new $classToLoad( $this->registry );
+
+ $this->registry->class_localization->loadLanguageFile( array( 'public_global' ) );
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval( $this->request['st'] ) >= 0 ? intval( $this->request['st'] ) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $last = $start + 1;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'topics', 'where' => "state != 'link' AND tid>{$start} AND topic_archive_status NOT IN (" . $this->registry->class_forums->fetchTopicArchiveFlag( 'working' ) . "," . $this->registry->class_forums->fetchTopicArchiveFlag( 'restore' ) . ")", 'limit' => array( 0, 1 ) ) );
+ $max = intval( $tmp['count'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'topics', 'where' => "state != 'link' AND tid>{$start} AND topic_archive_status NOT IN (" . $this->registry->class_forums->fetchTopicArchiveFlag( 'working' ) . "," . $this->registry->class_forums->fetchTopicArchiveFlag( 'restore' ) . ")", 'order' => 'tid ASC', 'limit' => array( 0, $end ) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ $modfunc->rebuildTopic($r['tid'], 0);
+
+ if ( $this->request['pergo'] <= 200 )
+ {
+ $output[] = $this->lang->words['re_processed'].$r['title'];
+ }
+
+ $done++;
+ $last = $r['tid'];
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $last );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$last}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Resyncronize forum data
+ *
+ * @return @e void
+ */
+ public function resyncForums()
+ {
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'forums' ) . '/sources/classes/moderate.php', 'moderatorLibrary', 'forums' );
+ $modfunc = new $classToLoad( $this->registry );
+
+ //-----------------------------------------
+ // Set up
+ //-----------------------------------------
+
+ $done = 0;
+ $start = intval( $this->request['st'] ) >= 0 ? intval( $this->request['st'] ) : 0;
+ $end = intval( $this->request['pergo'] ) ? intval( $this->request['pergo'] ) : 100;
+ $dis = $end + $start;
+ $output = array();
+
+ //-----------------------------------------
+ // Got any more?
+ //-----------------------------------------
+
+ $tmp = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count', 'from' => 'forums', 'limit' => array( $dis, 1 ) ) );
+ $max = intval( $tmp['count'] );
+
+ //-----------------------------------------
+ // Avoid limit...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'forums', 'order' => 'id ASC', 'limit' => array( $start, $end ) ) );
+ $outer = $this->DB->execute();
+
+ //-----------------------------------------
+ // Process...
+ //-----------------------------------------
+
+ while( $r = $this->DB->fetch( $outer ) )
+ {
+ $modfunc->forumRecount( $r['id'] );
+ $output[] = sprintf( $this->lang->words['rebuild_process_f'], $r['name'] );
+ $done++;
+ }
+
+ //-----------------------------------------
+ // Finish - or more?...
+ //-----------------------------------------
+
+ if ( ! $done and ! $max )
+ {
+ //-----------------------------------------
+ // Done..
+ //-----------------------------------------
+
+ $text = $this->lang->words['re_rebuildcomp'] . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}";
+ }
+ else
+ {
+ //-----------------------------------------
+ // More..
+ //-----------------------------------------
+ $thisgoeshere = sprintf( $this->lang->words['re_thisgoeshere'], $dis );
+ $text = $thisgoeshere . ' ' . implode( " ", $output );
+ $url = "{$this->settings['base_url']}{$this->form_code}&do={$this->request['do']}&pergo={$this->request['pergo']}&st={$dis}";
+ }
+
+ //-----------------------------------------
+ // Bye....
+ //-----------------------------------------
+
+ $this->_specialRedirect( $url, $text );
+ }
+
+ /**
+ * Splash screen with rebuild options
+ *
+ * @return @e void
+ */
+ public function rebuildSplashScreen()
+ {
+ /* Build Form Elements */
+ $form = array();
+
+ $form['posts'] = $this->registry->output->formDropdown( 'posts' , array( 0 => array( 0, $this->lang->words['yesno_no'] ), 1 => array( 1, $this->lang->words['yesno_yes'] ) ) );
+ $form['members'] = $this->registry->output->formDropdown( 'members', array( 0 => array( 0, $this->lang->words['yesno_no'] ), 1 => array( 1, $this->lang->words['yesno_yes'] ) ) );
+ $form['lastreg'] = $this->registry->output->formDropdown( 'lastreg', array( 0 => array( 0, $this->lang->words['yesno_no'] ), 1 => array( 1, $this->lang->words['yesno_yes'] ) ) );
+ $form['online'] = $this->registry->output->formDropdown( 'online' , array( 0 => array( 0, $this->lang->words['yesno_no'] ), 1 => array( 1, $this->lang->words['yesno_yes'] ) ) );
+
+ //-----------------------------------------
+ // Only need to rebuild once
+ //-----------------------------------------
+
+ $todo = array(
+ array( 'posts' , $this->lang->words['remenu_posts'] ),
+ array( 'pms' , $this->lang->words['remenu_pms'] ),
+ array( 'announce', $this->lang->words['remenu_announce'] ),
+ array( 'sigs' , $this->lang->words['remenu_sigs'] ),
+ array( 'aboutme' , $this->lang->words['remenu_aboutme'] ),
+ array( 'rules' , $this->lang->words['remenu_rules'] ),
+ );
+
+ foreach( ipsRegistry::$applications as $app_dir => $app_data )
+ {
+ //-----------------------------------------
+ // Retrieve the RSS links for the header
+ //-----------------------------------------
+
+ if( is_file( IPSLib::getAppDir( $app_dir ) . '/extensions/upgradePostRebuild.php' ) )
+ {
+ $className = IPSLib::loadLibrary( IPSLib::getAppDir( $app_dir ) . '/extensions/upgradePostRebuild.php', 'postRebuild_'.$app_dir, $app_dir );
+
+ if( class_exists( $className ) )
+ {
+ $rebuild = new $className( $this->registry );
+
+ if( method_exists( $rebuild, "getDropdown" ) )
+ {
+ $todo = array_merge( $todo, $rebuild->getDropdown() );
+ }
+ }
+ }
+ }
+
+ $final = array();
+ $sections = array();
+
+ $alreadyRebuilt = $this->DB->buildAndFetch( array( 'select' => 'cs_value', 'from' => 'cache_store', 'where' => "cs_key='isRebuilt'" ) );
+
+ if( $alreadyRebuilt['cs_value'] )
+ {
+ $sections = explode( ',', $alreadyRebuilt['cs_value'] );
+ }
+
+ $form['pergo'] = $this->registry->output->formSimpleInput( 'pergo', '50', 5 );
+
+ /* Output */
+ $this->registry->output->html .= $this->html->rebuildSplashScreen( $form, $todo, $sections );
+ }
+
+ /**
+ * Redirect via a temporary page
+ *
+ * @param string $url URL to redirect to
+ * @param string $text Text to display
+ * @return @e void
+ */
+ protected function _specialRedirect( $url, $text )
+ {
+ $this->registry->output->html .= $this->registry->output->global_template->temporaryRedirect( $url, $text );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_admin/tools/sharelinks.php b/upload/admin/applications/core/modules_admin/tools/sharelinks.php
index 71d0de67..cf107996 100644
--- a/upload/admin/applications/core/modules_admin/tools/sharelinks.php
+++ b/upload/admin/applications/core/modules_admin/tools/sharelinks.php
@@ -2,18 +2,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Bookmarks
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2013-01-07 12:09:37 -0500 (Mon, 07 Jan 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mark $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Blog
* @link http://www.invisionpower.com
* @since 27th January 2004
- * @version $Rev: 10914 $
+ * @version $Rev: 11791 $
*/
if ( ! defined( 'IN_ACP' ) )
@@ -198,7 +198,8 @@ class admin_core_tools_sharelinks extends ipsCommand
'share_title' => $this->request['share_title'],
'share_key' => $this->request['share_key'],
'share_enabled' => $this->request['share_enabled'],
- 'share_canonical' => $this->request['share_canonical']
+ 'share_canonical' => $this->request['share_canonical'],
+ 'share_groups' => empty( $this->request['share_groups'] ) ? '*' : implode( ',', $this->request['share_groups'] )
);
/* Check the type */
@@ -282,6 +283,7 @@ class admin_core_tools_sharelinks extends ipsCommand
$form['share_key'] = $this->registry->output->formInput( 'share_key' , $data['share_key'] , 'share_key' , 50 );
$form['share_enabled'] = $this->registry->output->formYesNo( 'share_enabled' , $data['share_enabled'] );
$form['share_canonical'] = $this->registry->output->formYesNo( 'share_canonical' , $data['share_canonical'] );
+ $form['share_groups'] = $this->registry->output->generateGroupDropdown( 'share_groups[]', ( $data['share_groups'] == '*' ? NULL : explode( ',', $data['share_groups'] ) ), TRUE );
$this->registry->output->html .= $this->html->sharelinksForm( $id, $req, $title, $button, $form );
}
diff --git a/upload/admin/applications/core/modules_admin/tools/uagents.php b/upload/admin/applications/core/modules_admin/tools/uagents.php
index 0f33360e..e61d9df1 100644
--- a/upload/admin/applications/core/modules_admin/tools/uagents.php
+++ b/upload/admin/applications/core/modules_admin/tools/uagents.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* User agent management
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
if ( ! defined( 'IN_ACP' ) )
diff --git a/upload/admin/applications/core/modules_admin/tools/xml/menu.xml b/upload/admin/applications/core/modules_admin/tools/xml/menu.xml
index fc96b241..85b45c4c 100644
--- a/upload/admin/applications/core/modules_admin/tools/xml/menu.xml
+++ b/upload/admin/applications/core/modules_admin/tools/xml/menu.xml
@@ -2,10 +2,10 @@
-
-
Performance Mode
+ Режим Повышенной Производительности
- Performance Mode
+ Режим Повышенной Производительности
performance
performance
@@ -15,10 +15,10 @@
-
-
License Key
+ Ключ лицензии
- License Key
+ Ключ лицензии
licensekey
licensekey
@@ -28,10 +28,10 @@
-
-
User Agent Management
+ Управление User Agent
- User Agent Management
+ Управление User Agent
uagents
uagents
do=list
@@ -42,10 +42,10 @@
-
-
Recount & Rebuild
+ Пересчет и Перестроение
- Recount & Rebuild
+ Пересчет и Перестроение
recount_rebuild
rebuild
do=rebuild_overview
@@ -55,10 +55,10 @@
-
-
Clean Up Tools
+ Инструменты Очистки
- Clean Up Tools
+ Инструменты Очистки
cleanup_tools
rebuild
do=tools
@@ -68,10 +68,10 @@
-
-
Manage Help Files
+ Управление Разделами Помощи
- Manage Help Files
+ Управление Разделами Помощи
manage_help
help
do=help_overview
@@ -81,10 +81,10 @@
-
-
Cache Management
+ Управление Кешем
- Cache Management
+ Управление Кешем
caches
cache
do=cache_overview
@@ -94,10 +94,10 @@
-
-
Question & Answer Challenge
+ Система «Вопрос-ответ»
- Question & Answer Challenge
+ Система «Вопрос-ответ»
qanda
qanda
@@ -107,10 +107,10 @@
-
-
API Users
+ Пользователи API
- API Users
+ Пользователи API
api_users
api
@@ -120,10 +120,10 @@
-
-
Log In Management
+ Управление Авторизацией
- Log In Management
+ Управление Авторизацией
login_modules
login
do=login_overview
@@ -133,10 +133,10 @@
-
-
Share Links
+ Публикация Ссылок
- Share Links
+ Публикация Ссылок
sharelinks
sharelinks
@@ -146,10 +146,10 @@
-
-
Incoming Email Rules
+ Правила Входящей Почты
- Incoming Email Rules
+ Правила Входящей Почты
incoming_emails
incomingEmails
diff --git a/upload/admin/applications/core/modules_admin/tools/xml/permissions.xml b/upload/admin/applications/core/modules_admin/tools/xml/permissions.xml
index e183ce2e..cd205d25 100644
--- a/upload/admin/applications/core/modules_admin/tools/xml/permissions.xml
+++ b/upload/admin/applications/core/modules_admin/tools/xml/permissions.xml
@@ -1,160 +1,174 @@
- Manage Caches
+ Настройки Инструментов
+ core_tands
+
+ -
+
performance_toggle
+ Может включать режим производительности?
+
+ -
+
licensekey_manage
+ Может работать с информацией о лицензии?
+
+
+
+
+ Управление кешем
core_caches
-
cache_manage
- Can view and recache caches?
+ Может посматривать и обновлять кеш?
- Manage Log In Modules
+ Управление модулями авторизации
core_login_modules
-
login_manage
- Can manage log in modules?
+ Может управлять модулями авторизации?
- Registration questions and answers
+ Система вопросов при регистрации
core_qanda
-
qanda_view
- Can access questions and answers?
+ Может просматривать?
-
qa_manage
- Can add, edit and remove questions and answers?
+ Может изменять, добавлять и удалять?
- Manage Help Files
+ Управление разделами помощи
core_helpfiles
-
helpfiles_manage
- Can access help files?
+ Может просматривать?
-
help_manage
- Can edit/add help files?
+ Может изменять/добавлять?
-
help_remove
- Can remove help files?
+ Может удалять?
- API Users
+ Пользователи API
core_apiusers
-
api_manage
- Can edit/add API users?
+ Может изменять/добавлять?
-
api_remove
- Can remove API users?
+ Может удалять?
-
api_logs
- Can access API logs?
+ Может просматривать логи?
- Share Links
+ Сервисы публикации ссылок
core_sharelinks
-
sharelinks_manage
- Can edit/add/delete share links?
+ Может изменять/добавлять/удалять?
- Manage User Agents
+ Управление User Agents
core_uagents
-
uagents
- Can manage user agents?
+ Может управлять?
-
ua_manage
- Can edit/add user agents and user agent groups?
+ Может изменять/добавлять группы и агенты?
-
ua_remove
- Can remove user agents and user agent groups?
+ Может удалять группы и агенты?
- Cleanup and Rebuild Tools
+ Инструменты очистки и перестроения
core_cleanuprebuild
-
rebuild_manage
- Can access rebuild tools?
+ Имеет доступ к инструментам перестроения?
-
cleanup_manage
- Can access recount tools?
+ Имеет доступ к инструментам пересчета?
-
tools_recount
- Can recount site statistics?
+ Может производить пересчет статистики форума?
-
tools_resynch
- Can resynchronize forums?
+ Может производить пересчет статистики форумов?
-
tools_resyncht
- Can resynchronize topics?
+ Может производить пересчет статистики тем?
-
tools_rebuild
- Can rebuild bbcode in post and other content?
+ Может производить перестроение содержимого сообщений?
-
tools_postcounts
- Can reset post counts and usernames in posts?
+ Может производить пересчет сообщений пользователей?
-
tools_thumbs
- Can rebuild thumbnails and user photos?
+ Может производить обновление изображений предпросмотра?
-
tools_attach
- Can rebuild attachment data?
+ Может производить перестроение прикреплений?
-
tools_orphaned
- Can remove orphaned attachments?
+ Может удалять потерянные файлы?
-
tools_orphanp
- Can remove orphaned photos?
+ Может удалять потерянные фотографии?
- Incoming Email Rules
+ Правила входящей почты
core_emailrules
-
incomingemail_manage
- Can manage Incoming Email rules?
+ Может управлять правилами?
diff --git a/upload/admin/applications/core/modules_public/ajax/attach.php b/upload/admin/applications/core/modules_public/ajax/attach.php
index e3ce8d44..0e1235cd 100644
--- a/upload/admin/applications/core/modules_public/ajax/attach.php
+++ b/upload/admin/applications/core/modules_public/ajax/attach.php
@@ -4,11 +4,11 @@
*
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: ips_terabyte $
+ * $Author: mmecham $
* @since -
- * $LastChangedDate: 2011-05-25 10:30:28 -0400 (Wed, 25 May 2011) $
- * @version v3.3.4
- * $Revision: 8887 $
+ * $LastChangedDate: 2013-03-19 09:02:31 -0400 (Tue, 19 Mar 2013) $
+ * @version v3.4.5
+ * $Revision: 12085 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -44,9 +44,58 @@ class public_core_ajax_attach extends ipsAjaxCommand
case 'setPref':
$this->_setPref();
break;
+ case 'getForumsAppUploader':
+ $this->_getForumsAppUploader();
+ break;
}
}
+ /**
+ * Gets the uploader form/data for ajaxy stuffs
+ */
+ protected function _getForumsAppUploader()
+ {
+ $this->registry->getClass('class_localization')->loadLanguageFile( array( 'public_post', 'public_topics' ), 'forums' );
+
+ $attach_post_key = trim( $this->request['attach_post_key'] );
+ $attach_rel_id = intval( $this->request['attach_rel_id'] );
+ $forum_id = intval( $this->request['forum_id'] );
+
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
+ $class_attach = new $classToLoad( $this->registry );
+ $class_attach->type = 'post';
+ $class_attach->attach_post_key = $attach_post_key;
+ $class_attach->init();
+ $class_attach->getUploadFormSettings();
+
+ $html = $this->registry->getClass('output')->getTemplate('post')->uploadForm( $this->post_key, 'post', $class_attach->attach_stats, $attach_rel_id, $forum_id );
+
+ /* Need to make sure they are unique - if we implement, change template to accept a prefix */
+ $html = str_replace( "id='add_files_attach_" , "id='add_files_attach_pu_" , $html );
+ $html = str_replace( "id='nojs_attach_" , "id='nojs_attach_pu_" , $html );
+ $html = str_replace( "id='help_msg'" , "id='pu_help_msg'" , $html );
+ $html = str_replace( "id='space_info_attach_", "id='space_info_attach_pu_", $html );
+ $html = str_replace( "" , "" , $html );
+
+ /* Remove help msg */
+
+ /* remove inline execution */
+ preg_match_all( '##is', $html, $matches, PREG_SET_ORDER );
+
+ foreach( $matches as $val )
+ {
+ $all = $val[0];
+ $javascript = $val[1];
+
+ if ( stristr( $all, 'ipb.attach.registerUploader' ) )
+ {
+ $html = str_replace( $all, '', $html );
+ }
+ }
+
+ $this->returnHtml( $html );
+ }
+
/**
* Sets uploader preference
*
diff --git a/upload/admin/applications/core/modules_public/ajax/captcha.php b/upload/admin/applications/core/modules_public/ajax/captcha.php
index 3ad104f9..aa2340ce 100644
--- a/upload/admin/applications/core/modules_public/ajax/captcha.php
+++ b/upload/admin/applications/core/modules_public/ajax/captcha.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Update captcha image
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 2.3
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_public/ajax/comments.php b/upload/admin/applications/core/modules_public/ajax/comments.php
index 40e80c69..b272fdd2 100644
--- a/upload/admin/applications/core/modules_public/ajax/comments.php
+++ b/upload/admin/applications/core/modules_public/ajax/comments.php
@@ -2,17 +2,17 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Image Ajax
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2013-02-08 10:22:34 -0500 (Fri, 08 Feb 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mark $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Gallery
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11963 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -72,7 +72,7 @@ class public_core_ajax_comments extends ipsAjaxCommand
$parentId = intval( $this->request['parentId'] );
$commentIds = ( is_array( $_POST['commentIds'] ) ) ? IPSLib::cleanIntArray( $_POST['commentIds'] ) : array();
$modact = trim( $this->request['modact'] );
-
+
if ( count( $commentIds ) )
{
try
@@ -83,7 +83,14 @@ class public_core_ajax_comments extends ipsAjaxCommand
}
catch( Exception $error )
{
- $this->returnJsonError( 'Error ' . $error->getMessage() . ' line: ' . $error->getFile() . '.' . $error->getLine() );
+ if ( $error->getMessage() == 'NO_PERMISSION' )
+ {
+ $this->returnJsonError( $this->lang->words['ap_np_msg'] );
+ }
+ else
+ {
+ $this->returnJsonError( 'Error ' . $error->getMessage() . ' line: ' . $error->getFile() . '.' . $error->getLine() );
+ }
}
}
}
diff --git a/upload/admin/applications/core/modules_public/ajax/defaultSection.php b/upload/admin/applications/core/modules_public/ajax/defaultSection.php
index d3f13232..f8801479 100644
--- a/upload/admin/applications/core/modules_public/ajax/defaultSection.php
+++ b/upload/admin/applications/core/modules_public/ajax/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_public/ajax/editor.php b/upload/admin/applications/core/modules_public/ajax/editor.php
index 9312a78d..f917ee12 100644
--- a/upload/admin/applications/core/modules_public/ajax/editor.php
+++ b/upload/admin/applications/core/modules_public/ajax/editor.php
@@ -2,18 +2,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Handles ajax functions for IP.Board Text Editor
* Author: Matt "Matt Mecham" Mecham
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-10-10 06:39:40 -0400 (Wed, 10 Oct 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Gallery
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11434 $
*
*/
@@ -38,6 +38,8 @@ class public_core_ajax_editor extends ipsAjaxCommand
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/editor/composite.php', 'classes_editor_composite' );
$this->editor = new $classToLoad();
+ $this->lang->loadLanguageFile( 'public_editors', 'core' );
+
/* What to do? */
switch( $this->request['do'] )
{
@@ -92,17 +94,16 @@ class public_core_ajax_editor extends ipsAjaxCommand
}
$clearSavedContent = intval( $this->request['clearSavedContent'] );
- $bw_cke_contextmenu = intval( $this->request['bw_cke_contextmenu'] );
+ $pastePlain = intval( $this->request['pastePlain'] );
if ( $clearSavedContent )
{
$this->DB->delete( 'core_editor_autosave', 'eas_member_id=' . $this->memberData['member_id'] );
}
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'bw_cke_contextmenu' => $bw_cke_contextmenu ) ) );
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'bw_paste_plain' => $pastePlain ) ) );
$member = IPSMember::load( $this->memberData['member_id'] );
-
/* return if no errors occurred */
return $this->returnJsonArray( array( 'status' => 'ok' ) );
}
diff --git a/upload/admin/applications/core/modules_public/ajax/facebook.php b/upload/admin/applications/core/modules_public/ajax/facebook.php
index 720e405d..c09d8c85 100644
--- a/upload/admin/applications/core/modules_public/ajax/facebook.php
+++ b/upload/admin/applications/core/modules_public/ajax/facebook.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Login handler abstraction : AJAX login
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Tuesday 1st March 2005 (11:52)
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_public/ajax/findnames.php b/upload/admin/applications/core/modules_public/ajax/findnames.php
index bdff3534..74915012 100644
--- a/upload/admin/applications/core/modules_public/ajax/findnames.php
+++ b/upload/admin/applications/core/modules_public/ajax/findnames.php
@@ -1,110 +1,110 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Login handler abstraction : AJAX Find Names functions
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since Tuesday 1st March 2005 (11:52)
- * @version $Revision: 10914 $
- * @see admin_core_ajax_findnames
- *
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class public_core_ajax_findnames extends ipsAjaxCommand
-{
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- switch( $this->request['do'] )
- {
- case 'get-member-names':
- $this->_getMemberNames();
- break;
- }
- }
-
- /**
- * Returns possible matches for the string input
- *
- * @return @e void Outputs to screen
- */
- protected function _getMemberNames()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $name = IPSText::convertUnicode( $this->convertAndMakeSafe( $this->request['name'], 0 ), true );
- $name = IPSText::convertCharsets( $name, 'utf-8', IPS_DOC_CHAR_SET );
-
- //-----------------------------------------
- // Check length
- //-----------------------------------------
-
- if ( IPSText::mbstrlen( $name ) < 3 )
- {
- $this->returnJsonError( 'requestTooShort' );
- }
-
- //-----------------------------------------
- // Try query...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'm.members_display_name, m.name, m.member_id, m.member_group_id',
- 'from' => array( 'members' => 'm' ),
- 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes( strtolower( $name ) ) . "%'",
- 'order' => $this->DB->buildLength( 'm.members_display_name' ) . ' ASC',
- 'limit' => array( 0, 15 ),
- 'add_join' => array( array( 'select' => 'p.*',
- 'from' => array( 'profile_portal' => 'p' ),
- 'where' => 'p.pp_member_id=m.member_id',
- 'type' => 'left' ) ) ) );
- $this->DB->execute();
-
- //-----------------------------------------
- // Got any results?
- //-----------------------------------------
-
- if ( ! $this->DB->getTotalRows() )
- {
- $this->returnJsonArray( array( ) );
- }
-
- $return = array();
-
- while( $r = $this->DB->fetch() )
- {
- $photo = IPSMember::buildProfilePhoto( $r );
- $group = IPSMember::makeNameFormatted( '' , $r['member_group_id'] );
- $return[ $r['member_id'] ] = array( 'name' => $r['members_display_name'],
- 'showas'=> '' . $r['members_display_name'] . ' (' . $group . ')',
- 'img' => $photo['pp_mini_photo'],
- 'img_w' => $photo['pp_mini_width'],
- 'img_h' => $photo['pp_mini_height']
- );
- }
-
- $this->returnJsonArray( $return );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Login handler abstraction : AJAX Find Names functions
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since Tuesday 1st March 2005 (11:52)
+ * @version $Revision: 10721 $
+ * @see admin_core_ajax_findnames
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class public_core_ajax_findnames extends ipsAjaxCommand
+{
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ switch( $this->request['do'] )
+ {
+ case 'get-member-names':
+ $this->_getMemberNames();
+ break;
+ }
+ }
+
+ /**
+ * Returns possible matches for the string input
+ *
+ * @return @e void Outputs to screen
+ */
+ protected function _getMemberNames()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $name = IPSText::convertUnicode( $this->convertAndMakeSafe( $this->request['name'], 0 ), true );
+ $name = IPSText::convertCharsets( $name, 'utf-8', IPS_DOC_CHAR_SET );
+
+ //-----------------------------------------
+ // Check length
+ //-----------------------------------------
+
+ if ( IPSText::mbstrlen( $name ) < 3 )
+ {
+ $this->returnJsonError( 'requestTooShort' );
+ }
+
+ //-----------------------------------------
+ // Try query...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'm.members_display_name, m.name, m.member_id, m.member_group_id',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes( mb_strtolower( $name ) ) . "%'",
+ 'order' => $this->DB->buildLength( 'm.members_display_name' ) . ' ASC',
+ 'limit' => array( 0, 15 ),
+ 'add_join' => array( array( 'select' => 'p.*',
+ 'from' => array( 'profile_portal' => 'p' ),
+ 'where' => 'p.pp_member_id=m.member_id',
+ 'type' => 'left' ) ) ) );
+ $this->DB->execute();
+
+ //-----------------------------------------
+ // Got any results?
+ //-----------------------------------------
+
+ if ( ! $this->DB->getTotalRows() )
+ {
+ $this->returnJsonArray( array( ) );
+ }
+
+ $return = array();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $photo = IPSMember::buildProfilePhoto( $r );
+ $group = IPSMember::makeNameFormatted( '' , $r['member_group_id'] );
+ $return[ $r['member_id'] ] = array( 'name' => $r['members_display_name'],
+ 'showas'=> '' . $r['members_display_name'] . ' (' . $group . ')',
+ 'img' => $photo['pp_mini_photo'],
+ 'img_w' => $photo['pp_mini_width'],
+ 'img_h' => $photo['pp_mini_height']
+ );
+ }
+
+ $this->returnJsonArray( $return );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/ajax/like.php b/upload/admin/applications/core/modules_public/ajax/like.php
index eb8b3558..58732697 100644
--- a/upload/admin/applications/core/modules_public/ajax/like.php
+++ b/upload/admin/applications/core/modules_public/ajax/like.php
@@ -7,7 +7,7 @@
* $Author: bfarber $
* @since -
* $LastChangedDate: 2011-08-05 20:51:01 -0400 (Fri, 05 Aug 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 9373 $
*/
diff --git a/upload/admin/applications/core/modules_public/ajax/login.php b/upload/admin/applications/core/modules_public/ajax/login.php
index 13d2730f..beef3bbc 100644
--- a/upload/admin/applications/core/modules_public/ajax/login.php
+++ b/upload/admin/applications/core/modules_public/ajax/login.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Login handler abstraction : AJAX login
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Tuesday 1st March 2005 (11:52)
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/modules_public/ajax/media.php b/upload/admin/applications/core/modules_public/ajax/media.php
index e986a69b..16aaebde 100644
--- a/upload/admin/applications/core/modules_public/ajax/media.php
+++ b/upload/admin/applications/core/modules_public/ajax/media.php
@@ -2,18 +2,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Handles ajax functions for IP.Board Text Editor
* Author: Matt "Matt Mecham" Mecham
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-06-07 06:21:09 -0400 (Thu, 07 Jun 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Gallery
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10885 $
*
*/
diff --git a/upload/admin/applications/core/modules_public/ajax/modcp.php b/upload/admin/applications/core/modules_public/ajax/modcp.php
index 0eb6aec4..bd0cdf9a 100644
--- a/upload/admin/applications/core/modules_public/ajax/modcp.php
+++ b/upload/admin/applications/core/modules_public/ajax/modcp.php
@@ -1,175 +1,175 @@
-Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
- exit();
-}
-
-/**
- *
- * @class public_core_ajax_modcp
- * @brief Moderator control panel
- *
- */
-class public_core_ajax_modcp extends ipsAjaxCommand
-{
- /**
- * Main function executed automatically by the controller
- *
- * @param object $registry Registry object
- * @return @e void
- */
- public function doExecute( ipsRegistry $registry )
- {
- //-----------------------------------------
- // Load basic things
- //-----------------------------------------
-
- $this->registry->class_localization->loadLanguageFile( array( 'public_modcp' ) );
-
- //-----------------------------------------
- // Which road are we going to take?
- //-----------------------------------------
-
- switch( $this->request['do'] )
- {
- default:
- case 'index':
- $this->_getTab();
- break;
-
- case 'getmembers':
- $this->_getMembers();
- break;
- }
-
- //-----------------------------------------
- // Output
- //-----------------------------------------
-
- $this->registry->getClass('output')->addContent( $this->output );
- $this->registry->output->sendOutput();
- }
-
- /**
- * Returns possible matches for the string input
- *
- * @return @e void Outputs to screen
- */
- protected function _getMembers()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $name = IPSText::convertUnicode( $this->convertAndMakeSafe( $this->request['name'], 0 ), true );
- $name = IPSText::convertCharsets( $name, 'utf-8', IPS_DOC_CHAR_SET );
-
- //-----------------------------------------
- // Check length
- //-----------------------------------------
-
- if ( IPSText::mbstrlen( $name ) < 3 )
- {
- $this->returnJsonError( 'requestTooShort' );
- }
-
- //-----------------------------------------
- // Try query...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => 'm.members_display_name, m.member_id, m.members_seo_name, m.member_group_id',
- 'from' => array( 'members' => 'm' ),
- 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes( strtolower( $name ) ) . "%'",
- 'order' => $this->DB->buildLength( 'm.members_display_name' ) . ' ASC',
- 'limit' => array( 0, 15 ),
- 'add_join' => array( array( 'select' => 'p.*',
- 'from' => array( 'profile_portal' => 'p' ),
- 'where' => 'p.pp_member_id=m.member_id',
- 'type' => 'left' ) ) ) );
- $this->DB->execute();
-
- //-----------------------------------------
- // Got any results?
- //-----------------------------------------
-
- if ( ! $this->DB->getTotalRows() )
- {
- $this->returnJsonArray( array( ) );
- }
-
- $return = array();
-
- while( $r = $this->DB->fetch() )
- {
- $url = $this->registry->output->buildSEOUrl( "app=core&module=modcp&do=editmember&mid={$r['member_id']}", 'public' );
- $photo = IPSMember::buildProfilePhoto( $r );
- $group = IPSMember::makeNameFormatted( '' , $r['member_group_id'] );
-
- $return[ $r['member_id'] ] = array( 'name' => $r['members_display_name'],
- 'showas'=> '' . $r['members_display_name'] . ' (' . $group . ')',
- 'img' => $photo['pp_thumb_photo'],
- 'img_w' => $photo['pp_mini_width'],
- 'img_h' => $photo['pp_mini_height'],
- 'url' => $url,
- );
- }
-
- $this->returnJsonArray( $return );
- }
-
- /**
- * Retrieve modcp tab based
- *
- * @return @e void
- */
- protected function _getTab()
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- ipsRegistry::getAppClass( 'forums' );
-
- $app = trim($this->request['fromapp']);
- $plugin = trim($this->request['tab']);
- $moderator = $this->registry->class_forums->getModerator();
- $_output = '';
-
- //-----------------------------------------
- // Get plugin output
- //-----------------------------------------
-
- if( is_file( IPSLib::getAppDir( $app ) . '/extensions/modcp/plugin_' . $app . '_' . $plugin . '.php' ) )
- {
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/modcp/plugin_' . $app . '_' . $plugin . '.php', 'plugin_' . $app . '_' . $plugin, $app );
- $_thisPlugin = new $classToLoad( $this->registry );
-
- $_output = $_thisPlugin->executePlugin( $moderator );
- }
-
- //-----------------------------------------
- // Output
- //-----------------------------------------
-
- if( $_output )
- {
- $this->returnJsonArray( array( 'html' => $_output ) );
- }
- else
- {
- $this->returnJsonError( $this->lang->words['plugin_not_found'] );
- }
- }
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
+ exit();
+}
+
+/**
+ *
+ * @class public_core_ajax_modcp
+ * @brief Moderator control panel
+ *
+ */
+class public_core_ajax_modcp extends ipsAjaxCommand
+{
+ /**
+ * Main function executed automatically by the controller
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ //-----------------------------------------
+ // Load basic things
+ //-----------------------------------------
+
+ $this->registry->class_localization->loadLanguageFile( array( 'public_modcp' ) );
+
+ //-----------------------------------------
+ // Which road are we going to take?
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ default:
+ case 'index':
+ $this->_getTab();
+ break;
+
+ case 'getmembers':
+ $this->_getMembers();
+ break;
+ }
+
+ //-----------------------------------------
+ // Output
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->addContent( $this->output );
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Returns possible matches for the string input
+ *
+ * @return @e void Outputs to screen
+ */
+ protected function _getMembers()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $name = IPSText::convertUnicode( $this->convertAndMakeSafe( $this->request['name'], 0 ), true );
+ $name = IPSText::convertCharsets( $name, 'utf-8', IPS_DOC_CHAR_SET );
+
+ //-----------------------------------------
+ // Check length
+ //-----------------------------------------
+
+ if ( IPSText::mbstrlen( $name ) < 3 )
+ {
+ $this->returnJsonError( 'requestTooShort' );
+ }
+
+ //-----------------------------------------
+ // Try query...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => 'm.members_display_name, m.member_id, m.members_seo_name, m.member_group_id',
+ 'from' => array( 'members' => 'm' ),
+ 'where' => "m.members_l_display_name LIKE '" . $this->DB->addSlashes( mb_strtolower( $name ) ) . "%'",
+ 'order' => $this->DB->buildLength( 'm.members_display_name' ) . ' ASC',
+ 'limit' => array( 0, 15 ),
+ 'add_join' => array( array( 'select' => 'p.*',
+ 'from' => array( 'profile_portal' => 'p' ),
+ 'where' => 'p.pp_member_id=m.member_id',
+ 'type' => 'left' ) ) ) );
+ $this->DB->execute();
+
+ //-----------------------------------------
+ // Got any results?
+ //-----------------------------------------
+
+ if ( ! $this->DB->getTotalRows() )
+ {
+ $this->returnJsonArray( array( ) );
+ }
+
+ $return = array();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $url = $this->registry->output->buildSEOUrl( "app=core&module=modcp&do=editmember&mid={$r['member_id']}", 'public' );
+ $photo = IPSMember::buildProfilePhoto( $r );
+ $group = IPSMember::makeNameFormatted( '' , $r['member_group_id'] );
+
+ $return[ $r['member_id'] ] = array( 'name' => $r['members_display_name'],
+ 'showas'=> '' . $r['members_display_name'] . ' (' . $group . ')',
+ 'img' => $photo['pp_thumb_photo'],
+ 'img_w' => $photo['pp_mini_width'],
+ 'img_h' => $photo['pp_mini_height'],
+ 'url' => $url,
+ );
+ }
+
+ $this->returnJsonArray( $return );
+ }
+
+ /**
+ * Retrieve modcp tab based
+ *
+ * @return @e void
+ */
+ protected function _getTab()
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ ipsRegistry::getAppClass( 'forums' );
+
+ $app = trim($this->request['fromapp']);
+ $plugin = trim($this->request['tab']);
+ $moderator = $this->registry->class_forums->getModerator();
+ $_output = '';
+
+ //-----------------------------------------
+ // Get plugin output
+ //-----------------------------------------
+
+ if( is_file( IPSLib::getAppDir( $app ) . '/extensions/modcp/plugin_' . $app . '_' . $plugin . '.php' ) )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( $app ) . '/extensions/modcp/plugin_' . $app . '_' . $plugin . '.php', 'plugin_' . $app . '_' . $plugin, $app );
+ $_thisPlugin = new $classToLoad( $this->registry );
+
+ $_output = $_thisPlugin->executePlugin( $moderator );
+ }
+
+ //-----------------------------------------
+ // Output
+ //-----------------------------------------
+
+ if( $_output )
+ {
+ $this->returnJsonArray( array( 'html' => $_output ) );
+ }
+ else
+ {
+ $this->returnJsonError( $this->lang->words['plugin_not_found'] );
+ }
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/ajax/navigation.php b/upload/admin/applications/core/modules_public/ajax/navigation.php
index 54bd260b..c8254c8b 100644
--- a/upload/admin/applications/core/modules_public/ajax/navigation.php
+++ b/upload/admin/applications/core/modules_public/ajax/navigation.php
@@ -6,7 +6,7 @@
* $Author: bfarber $
* @since 2/14/2011
* $LastChangedDate: 2011-04-27 19:56:50 -0400 (Wed, 27 Apr 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8514 $
*/
diff --git a/upload/admin/applications/core/modules_public/ajax/notifications.php b/upload/admin/applications/core/modules_public/ajax/notifications.php
index f71845f4..73f49ec0 100644
--- a/upload/admin/applications/core/modules_public/ajax/notifications.php
+++ b/upload/admin/applications/core/modules_public/ajax/notifications.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Notification AJAX methods
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-08-28 17:56:22 -0400 (Tue, 28 Aug 2012) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Tuesday 1st March 2005 (11:52)
- * @version $Revision: 10914 $
+ * @version $Revision: 11296 $
*
*/
@@ -170,6 +170,6 @@ class public_core_ajax_notifications extends ipsAjaxCommand
// Return results
//-----------------------------------------
- $this->returnJsonArray( array( 'html' => $this->cleanOutput( $this->registry->output->getTemplate('global_other')->notificationsList( $_data ) ) ) );
+ $this->returnJsonArray( array( 'html' => $this->registry->output->getTemplate('global_other')->notificationsList( $_data ) ), true );
}
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/ajax/register.php b/upload/admin/applications/core/modules_public/ajax/register.php
index 9881f407..55b1398a 100644
--- a/upload/admin/applications/core/modules_public/ajax/register.php
+++ b/upload/admin/applications/core/modules_public/ajax/register.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Registration AJAX routines
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-07-19 11:49:35 -0400 (Thu, 19 Jul 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mark $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since Who knows...
- * @version $Revision: 10914 $
+ * @version $Revision: 11095 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -120,7 +120,9 @@ class public_core_ajax_register extends ipsAjaxCommand
$han_login = new $classToLoad( $this->registry );
$han_login->init();
- if( $han_login->emailExistsCheck( $email ) )
+ $han_login->emailExistsCheck( $email );
+
+ if( $han_login->return_code AND $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'EMAIL_NOT_IN_USE' )
{
$this->returnString('found');
}
diff --git a/upload/admin/applications/core/modules_public/ajax/reports.php b/upload/admin/applications/core/modules_public/ajax/reports.php
index efdcce39..623b6c82 100644
--- a/upload/admin/applications/core/modules_public/ajax/reports.php
+++ b/upload/admin/applications/core/modules_public/ajax/reports.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Reports AJAX options
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/modules_public/ajax/reputation.php b/upload/admin/applications/core/modules_public/ajax/reputation.php
index f68105b1..b0564f13 100644
--- a/upload/admin/applications/core/modules_public/ajax/reputation.php
+++ b/upload/admin/applications/core/modules_public/ajax/reputation.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Reputation
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/modules_public/ajax/search.php b/upload/admin/applications/core/modules_public/ajax/search.php
index 68d69902..0fa1b7d2 100644
--- a/upload/admin/applications/core/modules_public/ajax/search.php
+++ b/upload/admin/applications/core/modules_public/ajax/search.php
@@ -3,11 +3,11 @@
* @file search.php AJAX configure VNC filters
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: ips_terabyte $
+ * $Author: AndyMillne $
* @since 2/14/2011
- * $LastChangedDate: 2011-05-25 10:30:28 -0400 (Wed, 25 May 2011) $
- * @version v3.3.4
- * $Revision: 8887 $
+ * $LastChangedDate: 2013-03-22 17:35:37 -0400 (Fri, 22 Mar 2013) $
+ * @version v3.4.5
+ * $Revision: 12112 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -60,9 +60,94 @@ class public_core_ajax_search extends ipsAjaxCommand
case 'saveForumsVncFilter':
$this->saveForm();
break;
+
+ case 'saveFollow':
+ $this->saveFollow();
+ break;
}
}
+ /**
+ * Save the 'like' preferences for a single object
+ *
+ * @return @e void
+ */
+ protected function saveFollow()
+ {
+ //-----------------------------------------
+ // Get like helper class
+ //-----------------------------------------
+
+ $bootstraps = array();
+
+ require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
+ $_bootstrap = classes_like::bootstrap( $this->request['searchApp'], $this->request['contentType'] );
+ $_likeKey = classes_like_registry::getKey( $this->request['id'], $this->memberData['member_id'] );
+ $_frequencies = $_bootstrap->allowedFrequencies();
+
+ //-----------------------------------------
+ // What action to take?
+ //-----------------------------------------
+
+ switch( $this->request['modaction'] )
+ {
+ case 'delete':
+ $_bootstrap->remove( $this->request['id'], $this->memberData['member_id'] );
+ break;
+
+ case 'change-donotify':
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'immediate' ), "like_id='" . addslashes($_likeKey) . "'" );
+ break;
+
+ case 'change-donotnotify':
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 0 ), "like_id='" . addslashes($_likeKey) . "'" );
+ break;
+
+ case 'change-immediate':
+ if( in_array( 'immediate', $_frequencies ) )
+ {
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'immediate' ), "like_id='" . addslashes($_likeKey) . "'" );
+ }
+ break;
+
+ case 'change-offline':
+ if( in_array( 'offline', $_frequencies ) )
+ {
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'offline' ), "like_id='" . addslashes($_likeKey) . "'" );
+ }
+ break;
+
+ case 'change-daily':
+ if( in_array( 'daily', $_frequencies ) )
+ {
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'daily' ), "like_id='" . addslashes($_likeKey) . "'" );
+ }
+ break;
+
+ case 'change-weekly':
+ if( in_array( 'weekly', $_frequencies ) )
+ {
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'weekly' ), "like_id='" . addslashes($_likeKey) . "'" );
+ }
+ break;
+
+ case 'change-anon':
+ $this->DB->update( 'core_like', array( 'like_is_anon' => 1 ), "like_id='" . addslashes($_likeKey) . "'" );
+ break;
+
+ case 'change-noanon':
+ $this->DB->update( 'core_like', array( 'like_is_anon' => 0 ), "like_id='" . addslashes($_likeKey) . "'" );
+ break;
+ default:
+ $this->returnJsonError("follow_no_action");
+ break;
+ }
+
+ $_data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_like', 'where' => "like_id='" . addslashes($_likeKey) . "'" ) );
+
+ $this->returnJsonArray( array( 'html' => $this->registry->output->getTemplate('search')->followData( $_data ) ) );
+ }
+
/**
* Save the form to configure VNC forum filters
*
diff --git a/upload/admin/applications/core/modules_public/ajax/sharelinks.php b/upload/admin/applications/core/modules_public/ajax/sharelinks.php
index 90d7125a..3c26723a 100644
--- a/upload/admin/applications/core/modules_public/ajax/sharelinks.php
+++ b/upload/admin/applications/core/modules_public/ajax/sharelinks.php
@@ -4,10 +4,10 @@
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2012 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: ips_terabyte $
- * $LastChangedDate: 2012-06-22 07:55:48 -0400 (Fri, 22 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10969 $
+ * $Author: mmecham $
+ * $LastChangedDate: 2012-09-19 10:57:30 -0400 (Wed, 19 Sep 2012) $
+ * @version v3.4.5
+ * $Revision: 11350 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -176,7 +176,7 @@ class public_core_ajax_sharelinks extends ipsAjaxCommand
if ( $user['id'] )
{
- $sid = $connect->updateStatusWithUrl( $tweet, $url );
+ $sid = $connect->updateStatusWithUrl( $tweet, $url, true, $this->settings['twitter_hashtag'] );
if ( $sid )
{
diff --git a/upload/admin/applications/core/modules_public/ajax/skin.php b/upload/admin/applications/core/modules_public/ajax/skin.php
index 9c412814..07f0de18 100644
--- a/upload/admin/applications/core/modules_public/ajax/skin.php
+++ b/upload/admin/applications/core/modules_public/ajax/skin.php
@@ -7,7 +7,7 @@
* $Author: bfarber $
* @since -
* $LastChangedDate: 2011-08-06 01:51:01 +0100 (Sat, 06 Aug 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 9373 $
*/
@@ -73,10 +73,7 @@ class public_core_ajax_skin extends ipsAjaxCommand
/* Make sure mobile skin is removed */
IPSCookie::set("mobileApp", 'false', -1);
IPSCookie::set("mobileBrowser", 0, -1);
-
- /* remove user agent bypass */
- IPSCookie::set("uagent_bypass", 0, -1);
-
+
/* Update member row */
$this->memberData['skin'] = $skinId;
}
@@ -106,10 +103,17 @@ class public_core_ajax_skin extends ipsAjaxCommand
break;
}
}
-
- /* Update... */
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'skin' => $skinId ) ) );
- }
+
+ /* Update... */
+ if ( $this->memberData['member_id'] )
+ {
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'skin' => $skinId ) ) );
+ }
+ else
+ {
+ IPSCookie::set( 'guestSkinChoice', $skinId );
+ }
+ }
}
else if ( $skinId == 'unlockUserAgent' )
{
diff --git a/upload/admin/applications/core/modules_public/ajax/skingen.php b/upload/admin/applications/core/modules_public/ajax/skingen.php
index eef345ab..88b93611 100644
--- a/upload/admin/applications/core/modules_public/ajax/skingen.php
+++ b/upload/admin/applications/core/modules_public/ajax/skingen.php
@@ -2,7 +2,7 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Like Ajax
* Last Updated: $LastChangedDate: 2011-05-05 12:03:47 +0100 (Thu, 05 May 2011) $
*
diff --git a/upload/admin/applications/core/modules_public/ajax/tags.php b/upload/admin/applications/core/modules_public/ajax/tags.php
index 27cef64d..b27e0042 100644
--- a/upload/admin/applications/core/modules_public/ajax/tags.php
+++ b/upload/admin/applications/core/modules_public/ajax/tags.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Like Ajax
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -12,7 +12,7 @@
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Gallery
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_public/ajax/templates.php b/upload/admin/applications/core/modules_public/ajax/templates.php
index 81014d0e..11bc142a 100644
--- a/upload/admin/applications/core/modules_public/ajax/templates.php
+++ b/upload/admin/applications/core/modules_public/ajax/templates.php
@@ -7,7 +7,7 @@
* $Author: mmecham $
* @since Friday 19th May 2006 17:33
* $LastChangedDate: 2011-05-03 04:53:04 -0400 (Tue, 03 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8588 $
*/
diff --git a/upload/admin/applications/core/modules_public/ajax/usercp.php b/upload/admin/applications/core/modules_public/ajax/usercp.php
index 21b3a2ab..d52cbb2a 100644
--- a/upload/admin/applications/core/modules_public/ajax/usercp.php
+++ b/upload/admin/applications/core/modules_public/ajax/usercp.php
@@ -1,111 +1,111 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Login handler abstraction : AJAX UserCP functions
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since Tuesday 1st March 2005 (11:52)
- * @version $Revision: 10914 $
- *
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class public_core_ajax_usercp extends ipsAjaxCommand
-{
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen]
- */
- public function doExecute( ipsRegistry $registry )
- {
- switch( $this->request['do'] )
- {
- case 'displayNameCheck':
- $this->displayNameCheck();
- break;
- }
- }
-
- /**
- * Checks a display name
- *
- * @return @e void [Outputs JSON to browser AJAX call]
- */
- protected function displayNameCheck()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $name = strtolower( $this->convertAndMakeSafe( $this->request['name'], 0 ) );
- $name = str_replace("+", "+", $name );
- $member = array();
- $return = TRUE;
- $id = intval( $this->request['member_id'] );
-
- # Set member ID
- $id = $this->memberData['member_id'] ? $this->memberData['member_id'] : $id;
-
- //-----------------------------------------
- // Load member if required
- //-----------------------------------------
-
- if ( $id != $this->memberData['member_id'] )
- {
- $member = IPSMember::load( $id, 'all' );
- }
- else
- {
- $member = $this->member->fetchMemberData();
- }
-
- //-----------------------------------------
- // Test name
- //-----------------------------------------
-
- try
- {
- $return = IPSMember::getFunction()->checkNameExists( $name, $member );
- }
- catch( Exception $error )
- {
- $_msg = $error->getMessage();
-
- if ( $_msg == 'NO_MORE_CHANGES' )
- {
- $this->returnString( 'nomorechanges' );
- return;
- }
-
- # Really, we're not very interested why it didn't work at this point, so
- # just return with a 'found' string which will make a nice red cross and
- # force the user to choose another.
-
- $this->returnString('found');
- return;
- }
-
- //-----------------------------------------
- // So, what's it to be?
- //-----------------------------------------
-
- $this->returnString( ( $return === TRUE ) ? 'found' : 'notfound' );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Login handler abstraction : AJAX UserCP functions
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since Tuesday 1st March 2005 (11:52)
+ * @version $Revision: 10721 $
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class public_core_ajax_usercp extends ipsAjaxCommand
+{
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ switch( $this->request['do'] )
+ {
+ case 'displayNameCheck':
+ $this->displayNameCheck();
+ break;
+ }
+ }
+
+ /**
+ * Checks a display name
+ *
+ * @return @e void [Outputs JSON to browser AJAX call]
+ */
+ protected function displayNameCheck()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $name = mb_strtolower( $this->convertAndMakeSafe( $this->request['name'], 0 ) );
+ $name = str_replace("+", "+", $name );
+ $member = array();
+ $return = TRUE;
+ $id = intval( $this->request['member_id'] );
+
+ # Set member ID
+ $id = $this->memberData['member_id'] ? $this->memberData['member_id'] : $id;
+
+ //-----------------------------------------
+ // Load member if required
+ //-----------------------------------------
+
+ if ( $id != $this->memberData['member_id'] )
+ {
+ $member = IPSMember::load( $id, 'all' );
+ }
+ else
+ {
+ $member = $this->member->fetchMemberData();
+ }
+
+ //-----------------------------------------
+ // Test name
+ //-----------------------------------------
+
+ try
+ {
+ $return = IPSMember::getFunction()->checkNameExists( $name, $member );
+ }
+ catch( Exception $error )
+ {
+ $_msg = $error->getMessage();
+
+ if ( $_msg == 'NO_MORE_CHANGES' )
+ {
+ $this->returnString( 'nomorechanges' );
+ return;
+ }
+
+ # Really, we're not very interested why it didn't work at this point, so
+ # just return with a 'found' string which will make a nice red cross and
+ # force the user to choose another.
+
+ $this->returnString('found');
+ return;
+ }
+
+ //-----------------------------------------
+ // So, what's it to be?
+ //-----------------------------------------
+
+ $this->returnString( ( $return === TRUE ) ? 'found' : 'notfound' );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/attach/attach.php b/upload/admin/applications/core/modules_public/attach/attach.php
index de186292..b9b97c3a 100644
--- a/upload/admin/applications/core/modules_public/attach/attach.php
+++ b/upload/admin/applications/core/modules_public/attach/attach.php
@@ -2,18 +2,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Attachment Poster
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-08-22 05:05:53 -0400 (Wed, 22 Aug 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: mmecham $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11245 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -24,20 +24,6 @@ if ( ! defined( 'IN_IPB' ) )
class public_core_attach_attach extends ipsCommand
{
- /**
- * Attachment Library
- *
- * @var object class_attach
- */
- public $class_attach;
-
- /**
- * AJAX Library
- *
- * @var object classAjax
- */
- public $ajax;
-
/**
* Class entry point
*
@@ -46,298 +32,10 @@ class public_core_attach_attach extends ipsCommand
*/
public function doExecute( ipsRegistry $registry )
{
- /* AJAX Class */
- $classToLoad = IPSLib::loadLibrary( IPS_KERNEL_PATH . 'classAjax.php', 'classAjax' );
- $this->ajax = new $classToLoad();
-
- /* Attachment Class */
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/class_attach.php', 'class_attach' );
- $this->class_attach = new $classToLoad( $registry );
+ /* Attachment Controller Class */
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'core' ) . '/sources/classes/attach/controller.php', 'classes_attach_controller' );
+ $controller = new $classToLoad( $registry );
- /* What to do... */
- switch( $this->request['do'] )
- {
- case 'attach_upload_show':
- $this->ajax->returnHtml( $this->attachmentUploadShow() );
- break;
-
- case 'attach_upload_process':
- $this->attachmentUploadProcess();
- break;
-
- case 'attach_upload_remove':
- $this->attachmentUploadRemove();
- break;
-
- /* IFrame based upload */
- case 'attachiFrame':
- $this->attachiFrame();
- break;
- case 'attachUploadiFrame':
- $this->attachUploadiFrame();
- break;
-
- default:
- $this->showPostAttachment();
- break;
- }
- }
-
- /**
- * View Post Attachment
- *
- * @return @e void
- */
- public function showPostAttachment()
- {
- /* INIT */
- $attach_id = intval( $this->request['attach_id'] );
-
- /* INIT module */
- $this->class_attach->init();
-
- /* Display */
- $this->class_attach->showAttachment( $attach_id );
- }
-
- /**
- * Remove an upload
- *
- * @return @e void
- */
- public function attachmentUploadRemove()
- {
- /* INIT */
- $attach_post_key = trim( IPSText::alphanumericalClean( $this->request['attach_post_key'] ) );
- $attach_rel_module = trim( IPSText::alphanumericalClean( $this->request['attach_rel_module'] ) );
- $attach_rel_id = intval( $this->request['attach_rel_id'] );
- $attach_id = intval( $this->request['attach_id'] );
-
- /* Setup Module */
- $this->class_attach->type = $attach_rel_module;
- $this->class_attach->attach_post_key = $attach_post_key;
- $this->class_attach->attach_rel_id = $attach_rel_id;
- $this->class_attach->attach_id = $attach_id;
- $this->class_attach->init();
-
- /* Remove the attachment */
- $removed = $this->class_attach->removeAttachment();
-
- /* Show the form */
- if( $removed )
- {
- $this->ajax->returnHtml( $this->attachmentUploadShow( 'attach_removed', 0 ) );
- }
- else
- {
- $this->ajax->returnHtml( $this->attachmentUploadShow( 'remove_failed', 1 ) );
- }
- }
-
- /**
- * Perform the actual upload
- *
- * @return @e void
- */
- public function attachmentUploadProcess()
- {
- /* INIT */
- $attach_post_key = trim( IPSText::alphanumericalClean( $this->request['attach_post_key'] ) );
- $attach_rel_module = trim( IPSText::alphanumericalClean( $this->request['attach_rel_module'] ) );
- $attach_rel_id = intval( $this->request['attach_rel_id'] );
- $attach_current_items = '';
-
- /* INIT module */
- $this->class_attach->type = $attach_rel_module;
- $this->class_attach->attach_post_key = $attach_post_key;
- $this->class_attach->attach_rel_id = $attach_rel_id;
- $this->class_attach->init();
-
- /* Process upload */
- $insert_id = $this->class_attach->processUpload();
-
- /* Got an error? */
- if( $this->class_attach->error )
- {
- $this->ajax->returnHtml( $this->attachmentUploadShow( $this->class_attach->error, 1, $insert_id ) );
- }
- else
- {
- $this->ajax->returnHtml( $this->attachmentUploadShow( 'upload_ok', 0, $insert_id ) );
- }
- }
-
- /**
- * Show the attach upload field
- *
- * @param string $msg
- * @param bool $is_error
- * @param integer $insert_id
- * @return @e void
- */
- public function attachmentUploadShow( $msg="ready", $is_error=0, $insert_id=0 )
- {
- /* INIT JSON */
- $JSON = array();
- $JSON['msg'] = $msg;
- $JSON['is_error'] = $is_error;
-
- $is_reset = 0;
-
- /* Check the upload domain setting */
- if( $this->settings['upload_domain'] )
- {
- $is_reset = 1;
- $original = $this->settings['base_url'];
-
- if( $this->member->session_type == 'cookie' )
- {
- $this->settings['base_url'] = $this->settings['upload_domain'] . '/index.' . $this->settings['php_ext'].'?';
- }
- else
- {
- $this->settings['base_url'] = $this->settings['upload_domain'] . '/index.' . $this->settings['php_ext'].'?s='.$this->member->session_id .'&';
- }
- }
-
- /* JSON Data */
- $JSON['attach_post_key'] = $attach_post_key = trim( IPSText::alphanumericalClean( $this->request['attach_post_key'] ) );
- $JSON['attach_rel_module'] = $attach_rel_module = trim( IPSText::alphanumericalClean( $this->request['attach_rel_module'] ) );
- $JSON['attach_rel_id'] = $attach_rel_id = intval( $this->request['attach_rel_id'] );
-
- if( $insert_id )
- {
- $JSON['insert_id'] = $insert_id;
- }
-
- /* Get extra form fields */
- foreach( $_GET as $k => $v )
- {
- if( preg_match( "#^--ff--#", $k ) )
- {
- $JSON['extra_upload_form_url'] .= '&' . str_replace( '--ff--', '', $k ) . '='.$v;
- $JSON['extra_upload_form_url'] .= '&' . $k . '='.$v;
- }
- }
-
- /* INIT module */
- $this->class_attach->type = $attach_rel_module;
- $this->class_attach->attach_post_key = $attach_post_key;
- $this->class_attach->init();
- $this->class_attach->getUploadFormSettings();
-
- /* Load Language Bits */
- $this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'lang_post' ) );
-
- /* Generate current items... */
- $_more = ( $attach_rel_id ) ? ' OR c.attach_rel_id=' . $attach_rel_id : '';
-
- $this->DB->build( array(
- 'select' => 'c.*',
- 'from' => array( 'attachments' => 'c' ),
- 'where' => "c.attach_rel_module='{$attach_rel_module}' AND c.attach_post_key='{$attach_post_key}'{$_more}",
- 'add_join' => array( array(
- 'select' => 't.*',
- 'from' => array( 'attachments_type' => 't' ),
- 'where' => 't.atype_extension=c.attach_ext',
- 'type' => 'left'
- ) )
-
- ) );
-
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- if ( $attach_rel_module != $row['attach_rel_module'] )
- {
- continue;
- }
-
- if( ( $insert_id && $row['attach_id'] == $insert_id ) || $this->request['fetch_all'] )
- {
- if ( $row['attach_is_image'] and ! $row['attach_thumb_location'] )
- {
- $row['attach_thumb_location'] = $row['attach_location'];
- $row['attach_thumb_width'] = $row['attach_width'];
- $row['attach_thumb_height'] = $row['attach_height'];
- }
-
- $JSON['current_items'][ $row['attach_id'] ] = array( $row['attach_id'] ,
- str_replace( array( '[', ']' ), '', $row['attach_file'] ),
- $row['attach_filesize'],
- $row['attach_is_image'],
- $row['attach_thumb_location'],
- $row['attach_thumb_width'],
- $row['attach_thumb_height'],
- $row['atype_img']
- );
- }
- }
-
- $JSON['attach_stats'] = $this->class_attach->attach_stats;
-
- /* Formatting nonsense for special char sets */
- $result = IPSText::jsonEncodeForTemplate( $JSON );
-
- IPSDebug::addLogMessage( $result, 'uploads' );
-
- /* Return JSON */
- return $result;
- }
-
- /**
- * Show the attach upload field
- *
- * @param string $msg
- * @param bool $is_error
- * @param integer $insert_id
- * @return @e void
- */
- public function attachiFrame( $msg="ready", $is_error=0, $insert_id=0 )
- {
- /* INIT JSON */
- $JSON = $this->attachmentUploadShow( $msg, $is_error, $insert_id );
-
- $this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'public_post' ), 'forums' );
-
- $this->ajax->returnHtml( $this->registry->output->getTemplate( 'post' )->attachiFrame( $JSON, intval( $this->request['attach_rel_id'] ) ) );
- }
-
- /**
- * Perform the actual upload
- *
- * @return @e void
- */
- public function attachUploadiFrame()
- {
- /* INIT */
- $attach_post_key = trim( IPSText::alphanumericalClean( $this->request['attach_post_key'] ) );
- $attach_rel_module = trim( IPSText::alphanumericalClean( $this->request['attach_rel_module'] ) );
- $attach_rel_id = intval( $this->request['attach_rel_id'] );
- $attach_current_items = '';
-
- $this->registry->getClass( 'class_localization')->loadLanguageFile( array( 'public_post' ), 'forums' );
-
- /* INIT module */
- $this->class_attach->type = $attach_rel_module;
- $this->class_attach->attach_post_key = $attach_post_key;
- $this->class_attach->attach_rel_id = $attach_rel_id;
- $this->class_attach->init();
-
- /* Process upload */
- $insert_id = $this->class_attach->processUpload();
-
- /* Got an error? */
- if( $this->class_attach->error )
- {
- $JSON = $this->attachmentUploadShow( $this->class_attach->error, 1, $insert_id );
- }
- else
- {
- $JSON = $this->attachmentUploadShow( 'upload_ok', 0, $insert_id );
- }
-
- $this->ajax->returnHtml( $this->registry->output->getTemplate( 'post' )->attachiFrame( $JSON, $attach_rel_id ) );
+ $controller->run( $this->request['do'] );
}
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/attach/defaultSection.php b/upload/admin/applications/core/modules_public/attach/defaultSection.php
index b1ad5ef3..0c3b828d 100644
--- a/upload/admin/applications/core/modules_public/attach/defaultSection.php
+++ b/upload/admin/applications/core/modules_public/attach/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_public/global/captcha.php b/upload/admin/applications/core/modules_public/global/captcha.php
index 4596c8c2..f0ae99a1 100644
--- a/upload/admin/applications/core/modules_public/global/captcha.php
+++ b/upload/admin/applications/core/modules_public/global/captcha.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Captcha
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 20th February 2002
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/modules_public/global/comments.php b/upload/admin/applications/core/modules_public/global/comments.php
index 3506131a..7facec79 100644
--- a/upload/admin/applications/core/modules_public/global/comments.php
+++ b/upload/admin/applications/core/modules_public/global/comments.php
@@ -2,17 +2,17 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Image Ajax
- * Last Updated: $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $LastChangedDate: 2012-10-03 17:32:06 -0400 (Wed, 03 Oct 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Gallery
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11410 $
*
*/
@@ -117,7 +117,14 @@ class public_core_global_comments extends ipsCommand
/* Init */
$parentId = intval( $this->request['parentId'] );
- $this->_comments->redirectToComment( 'last', $parentId );
+ try
+ {
+ $this->_comments->redirectToComment( 'last', $parentId );
+ }
+ catch ( Exception $error )
+ {
+ $this->registry->getClass('output')->showError( 'no_permission', '1-global-comments-_findlast', null, null, 403 );
+ }
}
/**
@@ -136,7 +143,14 @@ class public_core_global_comments extends ipsCommand
$this->registry->output->showError( 'nocomment_found', '1-global-comments-find' );
}
- $this->_comments->redirectToComment( $comment_id, $parentId );
+ try
+ {
+ $this->_comments->redirectToComment( $comment_id, $parentId );
+ }
+ catch ( Exception $error )
+ {
+ $this->registry->getClass('output')->showError( 'no_permission', '1-global-comments-_find', null, null, 403 );
+ }
}
/**
diff --git a/upload/admin/applications/core/modules_public/global/defaultSection.php b/upload/admin/applications/core/modules_public/global/defaultSection.php
index 3066d827..47e7c4c6 100644
--- a/upload/admin/applications/core/modules_public/global/defaultSection.php
+++ b/upload/admin/applications/core/modules_public/global/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_public/global/like.php b/upload/admin/applications/core/modules_public/global/like.php
index 88a5c706..08740aee 100644
--- a/upload/admin/applications/core/modules_public/global/like.php
+++ b/upload/admin/applications/core/modules_public/global/like.php
@@ -4,11 +4,11 @@
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: bfarber $
+ * $Author: AndyMillne $
* @since -
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $LastChangedDate: 2013-02-06 16:33:34 -0500 (Wed, 06 Feb 2013) $
+ * @version v3.4.5
+ * $Revision: 11947 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -127,12 +127,12 @@ class public_core_global_like extends ipsCommand
if ( ( $memberId != $likeMemberId ) || ( $memberId != $this->memberData['member_id'] ) )
{
- $this->registry->output->showError( 'no_permission', 'pcgl-2' );
+ $this->registry->output->showError( 'no_unfollow', 'pcgl-2' );
}
if ( $email != $this->memberData['email'] )
{
- $this->registry->output->showError( 'no_permission', 'pcgl-3' );
+ $this->registry->output->showError( 'no_unfollow', 'pcgl-3' );
}
/* Think we're safe... */
diff --git a/upload/admin/applications/core/modules_public/global/login.php b/upload/admin/applications/core/modules_public/global/login.php
index ef40a9ad..420ba5e2 100644
--- a/upload/admin/applications/core/modules_public/global/login.php
+++ b/upload/admin/applications/core/modules_public/global/login.php
@@ -1,525 +1,558 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Login handler abstraction
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since Tuesday 1st March 2005 (11:52)
- * @version $Revision: 10914 $
- *
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class public_core_global_login extends ipsCommand
-{
- /**
- * Login handler object
- *
- * @var object
- */
- protected $han_login;
-
- /**
- * Facebook connect class
- *
- * @var object
- */
- protected $_facebook;
-
- /**
- * Initiate login handler
- *
- * @return @e void
- */
- public function initHanLogin()
- {
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
- }
-
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen/redirects]
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->lang = $this->registry->getClass('class_localization');
- $this->member = $this->registry->member();
- $this->memberData =& $this->registry->member()->fetchMemberData();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
-
- $this->registry->getClass( 'class_localization' )->loadLanguageFile( array( 'public_login' ), 'core' );
-
- //-----------------------------------------
- // Load handler...
- //-----------------------------------------
-
- $this->initHanLogin();
-
- //-----------------------------------------
- // Are we enforcing log ins?
- //-----------------------------------------
-
- $msg = "";
-
- if ( !$this->request['do'] == 'showForm' AND $this->settings['force_login'] == 1 )
- {
- $msg = 'admin_force_log_in';
- }
-
- //-----------------------------------------
- // Meta tags
- //-----------------------------------------
-
- $this->registry->output->addMetaTag( 'robots', 'noindex' );
-
- //-----------------------------------------
- // What to do?
- //-----------------------------------------
-
- switch( $this->request['do'] )
- {
- case 'process':
- $return = $this->doLogin();
-
- if( $return[2] )
- {
- //$this->registry->getClass('output')->showError( $return[2], 1014 );
- $this->loginForm( $return[2], $return[3] );
- }
- else
- {
- $this->registry->getClass('output')->redirectScreen( $return[0], $return[1] );
- }
- break;
-
- case 'logout':
- $return = $this->doLogout();
-
- /* URL */
- $return[2] = $return[2] ? $return[2] : '';
-
- if( $return[0] == 'immediate' )
- {
- $this->registry->getClass('output')->silentRedirect( $return[2] );
- }
- else
- {
- $this->registry->getClass('output')->redirectScreen( $return[1], $return[2] );
- }
- break;
-
- case 'deleteCookies':
- $return = $this->deleteCookies();
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] );
- break;
-
- case 'autologin':
- $return = $this->autoLogin();
- break;
-
- case 'showForm':
- default:
- $return = $this->loginForm($msg);
- break;
- }
-
- //-----------------------------------------
- // If we have any HTML to print, do so...
- //-----------------------------------------
-
- $this->registry->getClass('output')->addContent( $this->output );
- $this->registry->getClass('output')->sendOutput();
- }
-
- /**
- * Attempt to automatically log a user in
- *
- * @return array [0=Words to display,1=URL to send to]
- */
- public function autoLogin()
- {
- /* Verify the login */
- $this->han_login->verifyLogin();
-
- /* Lang Bits */
- $true_words = $this->lang->words['logged_in'];
- $false_words = $this->lang->words['not_logged_in'];
- $method = 'no_show';
-
- /* Register Redirect */
- if ($this->request['fromreg'] == 1)
- {
- $true_words = $this->lang->words['reg_log_in'];
- $false_words = $this->lang->words['reg_not_log_in'];
- $method = 'show';
- }
- /* Email Redirect */
- else if ($this->request['fromemail'] == 1)
- {
- $true_words = $this->lang->words['email_log_in'];
- $false_words = $this->lang->words['email_not_log_in'];
- $method = 'show';
- }
- /* Password Redirect */
- else if ($this->request['frompass'] == 1)
- {
- $true_words = $this->lang->words['pass_log_in'];
- $false_words = $this->lang->words['pass_not_log_in'];
- $method = 'show';
- }
-
- if( $this->memberData['member_id'] )
- {
- /* Member Sync */
- IPSLib::runMemberSync( 'onLogin', $this->memberData );
-
- if ( ! $this->request['fromreg'] )
- {
- IPSCookie::set('session_id', '0', -1 );
- }
-
- if( $method == 'show' )
- {
- $this->registry->getClass('output')->redirectScreen( $true_words, $this->settings['base_url'] );
- }
- else
- {
- $this->registry->getClass('output')->silentRedirect( $this->settings['board_url'] . '/index.php' );
- }
- }
- else
- {
- if( $method == 'show' )
- {
- $this->registry->getClass('output')->redirectScreen( $false_words, $this->settings['base_url'] . 'app=core&module=global§ion=login' );
- }
- else
- {
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=global§ion=login' );
- }
- }
- }
-
- /**
- * Delete a user's cookies
- *
- * @param boolean Check the key
- * @return mixed Output error page if key checking fails, else boolean true
- */
- public function deleteCookies( $check_key=true )
- {
- //-----------------------------------------
- // Check the md5 key
- //-----------------------------------------
-
- if( $check_key )
- {
- $key = $this->request['k'];
-
- if ( $key != $this->member->form_hash )
- {
- $this->registry->getClass('output')->showError( 'bad_delete_cookies_key', 2010 );
- }
- }
-
- //-----------------------------------------
- // Wipe out any forum password cookies
- //-----------------------------------------
-
- if ( is_array($_COOKIE) )
- {
- foreach( $_COOKIE as $cookie => $value )
- {
- if ( stripos( $cookie, $this->settings['cookie_id']."ipbforum" ) !== false )
- {
- IPSCookie::set( str_replace( $this->settings['cookie_id'], "", $cookie ), '-', -1 );
- }
-
- if ( stripos( $cookie, $this->settings['cookie_id']."itemMarking_" ) !== false )
- {
- IPSCookie::set( str_replace( $this->settings['cookie_id'], "", $cookie ), '-', -1 );
- }
- }
- }
-
- //-----------------------------------------
- // And the rest of the cookies
- //-----------------------------------------
-
- IPSCookie::set('pass_hash' , '-1');
- IPSCookie::set('member_id' , '-1');
- IPSCookie::set('session_id', '-1');
-
- return true;
- }
-
- /**
- * Show the login form
- *
- * @param string Message to show on login form
- * @return string Login form HTML
- */
- public function loginForm( $message="", $replacement='' )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $extra_form = "";
- $show_form = 1;
- $template = '';
- $serviceClick = trim( $this->request['serviceClick'] );
-
- //-----------------------------------------
- // Are they banned?
- //-----------------------------------------
-
- if ( IPSMember::isBanned( 'ip', $this->member->ip_address ) )
- {
- $this->registry->getClass('output')->showError( 'you_are_banned', 2011, null, null, 403 );
- }
-
- if ( $message != "" )
- {
- if( $replacement )
- {
- $message = sprintf( $this->lang->words[ $message ], $replacement );
- }
- else
- {
- $message = $this->lang->words[ $message ];
- }
- $name = $this->request['UserName'] ? $this->request['UserName'] : $this->request['address'];
- $message = str_replace( "<#NAME#>", "" . $name . " ", $message );
-
- $template .= $this->registry->getClass('output')->getTemplate('login')->errors($message);
- }
-
- //-----------------------------------------
- // Using an alternate log in form?
- //-----------------------------------------
-
- $this->han_login->checkLoginUrlRedirect();
-
- /* Did we click a service? */
- if ( $serviceClick )
- {
- switch ($serviceClick)
- {
- case 'facebook':
- $this->registry->getClass('output')->silentRedirect( $this->settings['_original_base_url'] . "/interface/facebook/index.php?_reg=1" );
- break;
- case 'twitter':
- $this->registry->getClass('output')->silentRedirect( $this->settings['_original_base_url'] . "/interface/twitter/index.php?_reg=1" );
- break;
- }
- }
-
- //-----------------------------------------
- // Extra HTML?
- //-----------------------------------------
-
- $additionalForm = $this->han_login->additionalFormHTML();
-
- if ( count($additionalForm[1]) )
- {
- if ( $additionalForm[0] == 'add' )
- {
- $extra_form = $additionalForm[1];
- $show_form = 1;
- }
- else
- {
- $template .= $additionalForm[1];
- $show_form = 0;
- }
- }
-
- //-----------------------------------------
- // Continue...
- //-----------------------------------------
-
- if ( $show_form )
- {
- if( $this->request['referer'] )
- {
- $http_referrer = $this->request['referer'];
- }
- else
- {
- /* @link http://community.invisionpower.com/tracker/issue-32302-login-redirect-when-activating */
- $_urlPieces = @parse_url($this->settings['board_url']);
-
- if( strpos( my_getenv('HTTP_REFERER'), $_urlPieces['host'] ? $_urlPieces['host'] : $this->settings['board_url'] ) !== false )
- {
- $http_referrer = my_getenv('HTTP_REFERER');
- }
- else
- {
- $http_referrer = '';
- }
- }
-
- $login_methods = false;
- $uses_name = false;
- $uses_email = false;
-
- foreach( $this->cache->getCache('login_methods') as $method )
- {
- $login_methods[ $method['login_folder_name'] ] = $method['login_folder_name'];
-
- if( $method['login_user_id'] == 'username' or $method['login_user_id'] == 'either' )
- {
- $uses_name = true;
- }
-
- if( $method['login_user_id'] == 'email' or $method['login_user_id'] == 'either' )
- {
- $uses_email = true;
- }
- }
-
- if( $uses_name AND $uses_email )
- {
- $this->lang->words['enter_name'] = $this->lang->words['enter_name_and_email'];
- }
- else if( $uses_email )
- {
- $this->lang->words['enter_name'] = $this->lang->words['enter_useremail'];
- }
- else
- {
- $this->lang->words['enter_name'] = $this->lang->words['enter_username'];
- }
-
- $template .= $this->registry->getClass('output')->getTemplate('login')->showLogInForm( $this->lang->words['please_log_in'], htmlentities(urldecode($http_referrer)), $extra_form, $login_methods );
- }
-
-
- $this->registry->getClass('output')->addNavigation( $this->lang->words['log_in'], '' );
- $this->registry->getClass('output')->setTitle( $this->lang->words['log_in'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->getClass('output')->addContent( $template );
- $this->registry->getClass('output')->sendOutput();
- }
-
- /**
- * Verify login form submission and log user in
- *
- * @return mixed array [0=Words to show, 1=URL to send to, 2=error array]
- */
- public function doLogin()
- {
- if( !defined('IGNORE_AUTH_KEY') OR !IGNORE_AUTH_KEY )
- {
- if ( $this->request['auth_key'] != $this->member->form_hash )
- {
- $this->registry->getClass('output')->showError( 'login_no_authkey', 10193, null, null, 403 );
- }
- }
-
- return $this->han_login->verifyLogin();
- }
-
- /**
- * Log a user out
- *
- * @param integer Flag to check md5 key
- * @return mixed Error message or array [0=immediate|redirect, 1=words to show, 2=URL to send to]
- */
- public function doLogout( $check_key=true )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- if ( $check_key )
- {
- $key = $this->request['k'];
-
- # Check for funny business
- if ( $key != $this->member->form_hash )
- {
- $this->registry->getClass('output')->showError( 'bad_logout_key', 2012 );
- }
- }
-
- //-----------------------------------------
- // Set some cookies
- //-----------------------------------------
-
- IPSCookie::set( "member_id" , "0" );
- IPSCookie::set( "pass_hash" , "0" );
-
- if( is_array( $_COOKIE ) )
- {
- foreach( $_COOKIE as $cookie => $value)
- {
- if ( stripos( $cookie, $this->settings['cookie_id'] . 'ipbforumpass' ) !== false AND ! strstr( $value, 'mobileApp' ) )
- {
- IPSCookie::set( str_replace( $this->settings['cookie_id'], "", $cookie ), '-', -1 );
- }
- }
- }
-
- //-----------------------------------------
- // Do it..
- //-----------------------------------------
-
- $this->member->sessionClass()->convertMemberToGuest();
-
- $privacy = intval( IPSMember::isLoggedInAnon($this->memberData) );
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW ) ) );
-
- //-----------------------------------------
- // Logout callbacks...
- //-----------------------------------------
-
- IPSLib::runMemberSync( 'onLogOut', $this->memberData );
-
- $this->han_login->logoutCallback();
-
- //-----------------------------------------
- // Return..
- //-----------------------------------------
-
- $url = "";
-
- if ( $this->request['return'] AND $this->request['return'] != "" )
- {
- $return = urldecode($this->request['return']);
-
- if ( strpos( $return, "http://" ) === 0 )
- {
- return array( 'immediate', '', $return );
- }
- }
-
- return array( 'redirect', $this->lang->words['thanks_for_logout'], $this->settings['base_url'] );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Login handler abstraction
+ * Last Updated: $Date: 2013-05-23 12:11:14 -0400 (Thu, 23 May 2013) $
+ *
+ *
+ * @author $Author: bfarber $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since Tuesday 1st March 2005 (11:52)
+ * @version $Revision: 12268 $
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class public_core_global_login extends ipsCommand
+{
+ /**
+ * Login handler object
+ *
+ * @var object
+ */
+ protected $han_login;
+
+ /**
+ * Facebook connect class
+ *
+ * @var object
+ */
+ protected $_facebook;
+
+ /**
+ * Initiate login handler
+ *
+ * @return @e void
+ */
+ public function initHanLogin()
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+ }
+
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen/redirects]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->lang = $this->registry->getClass('class_localization');
+ $this->member = $this->registry->member();
+ $this->memberData =& $this->registry->member()->fetchMemberData();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+ $this->registry->getClass( 'class_localization' )->loadLanguageFile( array( 'public_login' ), 'core' );
+
+ //-----------------------------------------
+ // Load handler...
+ //-----------------------------------------
+
+ $this->initHanLogin();
+
+ //-----------------------------------------
+ // Are we enforcing log ins?
+ //-----------------------------------------
+
+ $msg = "";
+
+ if ( !$this->request['do'] == 'showForm' AND $this->settings['force_login'] == 1 )
+ {
+ $msg = 'admin_force_log_in';
+ }
+
+ //-----------------------------------------
+ // Meta tags
+ //-----------------------------------------
+
+ $this->registry->output->addMetaTag( 'robots', 'noindex' );
+
+ //-----------------------------------------
+ // What to do?
+ //-----------------------------------------
+
+ switch( $this->request['do'] )
+ {
+ case 'process':
+ $return = $this->doLogin();
+
+ if( $return[2] )
+ {
+ //$this->registry->getClass('output')->showError( $return[2], 1014 );
+ $this->loginForm( $return[2], $return[3] );
+ }
+ else
+ {
+ $this->registry->getClass('output')->redirectScreen( $return[0], $return[1] );
+ }
+ break;
+
+ case 'logout':
+ $return = $this->doLogout();
+
+ /* URL */
+ $return[2] = $return[2] ? $return[2] : '';
+
+ if( $return[0] == 'immediate' )
+ {
+ $this->registry->getClass('output')->silentRedirect( $return[2] );
+ }
+ else
+ {
+ $this->registry->getClass('output')->redirectScreen( $return[1], $return[2] );
+ }
+ break;
+
+ case 'deleteCookies':
+ $return = $this->deleteCookies();
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] );
+ break;
+
+ case 'autologin':
+ $return = $this->autoLogin();
+ break;
+
+ case 'showForm':
+ default:
+ $return = $this->loginForm($msg);
+ break;
+ }
+
+ //-----------------------------------------
+ // If we have any HTML to print, do so...
+ //-----------------------------------------
+
+ $this->registry->getClass('output')->addContent( $this->output );
+ $this->registry->getClass('output')->sendOutput();
+ }
+
+ /**
+ * Attempt to automatically log a user in
+ *
+ * @return array [0=Words to display,1=URL to send to]
+ */
+ public function autoLogin()
+ {
+ /* Verify the login */
+ $this->han_login->verifyLogin();
+
+ /* Lang Bits */
+ $true_words = $this->lang->words['logged_in'];
+ $false_words = $this->lang->words['not_logged_in'];
+ $method = 'no_show';
+
+ /* Register Redirect */
+ if ($this->request['fromreg'] == 1)
+ {
+ $true_words = $this->lang->words['reg_log_in'];
+ $false_words = $this->lang->words['reg_not_log_in'];
+ $method = 'show';
+ }
+ /* Email Redirect */
+ else if ($this->request['fromemail'] == 1)
+ {
+ $true_words = $this->lang->words['email_log_in'];
+ $false_words = $this->lang->words['email_not_log_in'];
+ $method = 'show';
+ }
+ /* Password Redirect */
+ else if ($this->request['frompass'] == 1)
+ {
+ $true_words = $this->lang->words['pass_log_in'];
+ $false_words = $this->lang->words['pass_not_log_in'];
+ $method = 'show';
+ }
+
+ if( $this->memberData['member_id'] )
+ {
+ /* Member Sync */
+ IPSLib::runMemberSync( 'onLogin', $this->memberData );
+
+ if ( ! $this->request['fromreg'] )
+ {
+ IPSCookie::set('session_id', '0', -1 );
+ }
+
+ if( $method == 'show' )
+ {
+ $this->registry->getClass('output')->redirectScreen( $true_words, $this->settings['base_url'] );
+ }
+ else
+ {
+ $this->registry->getClass('output')->silentRedirect( $this->settings['board_url'] . '/index.php' );
+ }
+ }
+ else
+ {
+ if( $method == 'show' )
+ {
+ $this->registry->getClass('output')->redirectScreen( $false_words, $this->settings['base_url'] . 'app=core&module=global§ion=login' );
+ }
+ else
+ {
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=global§ion=login' );
+ }
+ }
+ }
+
+ /**
+ * Delete a user's cookies
+ *
+ * @param boolean Check the key
+ * @return mixed Output error page if key checking fails, else boolean true
+ */
+ public function deleteCookies( $check_key=true )
+ {
+ //-----------------------------------------
+ // Check the md5 key
+ //-----------------------------------------
+
+ if( $check_key )
+ {
+ $key = $this->request['k'];
+
+ if ( $key != $this->member->form_hash )
+ {
+ $this->registry->getClass('output')->showError( 'bad_delete_cookies_key', 2010 );
+ }
+ }
+
+ //-----------------------------------------
+ // Wipe out any forum password cookies
+ //-----------------------------------------
+
+ if ( is_array($_COOKIE) )
+ {
+ foreach( $_COOKIE as $cookie => $value )
+ {
+ if ( stripos( $cookie, $this->settings['cookie_id']."ipbforum" ) !== false )
+ {
+ IPSCookie::set( str_replace( $this->settings['cookie_id'], "", $cookie ), '-', -1 );
+ }
+
+ if ( stripos( $cookie, $this->settings['cookie_id']."itemMarking_" ) !== false )
+ {
+ IPSCookie::set( str_replace( $this->settings['cookie_id'], "", $cookie ), '-', -1 );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // And the rest of the cookies
+ //-----------------------------------------
+
+ IPSCookie::set('pass_hash' , '-1');
+ IPSCookie::set('member_id' , '-1');
+ IPSCookie::set('session_id', '-1');
+
+ return true;
+ }
+
+ /**
+ * Show the login form
+ *
+ * @param string Message to show on login form
+ * @return string Login form HTML
+ */
+ public function loginForm( $message="", $replacement='' )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $extra_form = "";
+ $show_form = 1;
+ $template = '';
+ $serviceClick = trim( $this->request['serviceClick'] );
+
+ //-----------------------------------------
+ // Are they banned?
+ //-----------------------------------------
+
+ if ( IPSMember::isBanned( 'ip', $this->member->ip_address ) )
+ {
+ $this->registry->getClass('output')->showError( 'you_are_banned', 2011, null, null, 403 );
+ }
+
+ if ( $message != "" )
+ {
+ if( $replacement )
+ {
+ $message = sprintf( $this->lang->words[ $message ], $replacement );
+ }
+ else
+ {
+ $message = $this->lang->words[ $message ];
+ }
+ $name = $this->request['UserName'] ? $this->request['UserName'] : $this->request['address'];
+ $message = str_replace( "<#NAME#>", "" . $name . " ", $message );
+
+ $template .= $this->registry->getClass('output')->getTemplate('login')->errors($message);
+ }
+
+ //-----------------------------------------
+ // Using an alternate log in form?
+ //-----------------------------------------
+
+ $this->han_login->checkLoginUrlRedirect();
+
+ /* Did we click a service? */
+ if ( $serviceClick )
+ {
+ switch ($serviceClick)
+ {
+ case 'facebook':
+ $this->registry->getClass('output')->silentRedirect( $this->settings['_original_base_url'] . "/interface/facebook/index.php?_reg=1" );
+ break;
+ case 'twitter':
+ $this->registry->getClass('output')->silentRedirect( $this->settings['_original_base_url'] . "/interface/twitter/index.php?_reg=1" );
+ break;
+ case 'vkontakte':
+ $this->registry->getClass('output')->silentRedirect( $this->settings['_original_base_url'] . "/interface/vkontakte/index.php?reg=1" );
+ break;
+ }
+ }
+
+ //-----------------------------------------
+ // Extra HTML?
+ //-----------------------------------------
+
+ $additionalForm = $this->han_login->additionalFormHTML();
+
+ if ( count($additionalForm[1]) )
+ {
+ if ( $additionalForm[0] == 'add' )
+ {
+ $extra_form = $additionalForm[1];
+ $show_form = 1;
+ }
+ else
+ {
+ if( is_array($additionalForm[1]) )
+ {
+ foreach( $additionalForm[1] as $_form )
+ {
+ $template .= $_form;
+ }
+ }
+ else
+ {
+ $template .= $additionalForm[1];
+ }
+ $show_form = 0;
+ }
+ }
+
+ //-----------------------------------------
+ // Continue...
+ //-----------------------------------------
+
+ if ( $show_form )
+ {
+ if( $this->request['referer'] )
+ {
+ $http_referrer = $this->request['referer'];
+ }
+ else
+ {
+ /* @link http://community.invisionpower.com/tracker/issue-32302-login-redirect-when-activating */
+ $_urlPieces = @parse_url($this->settings['board_url']);
+
+ if( strpos( my_getenv('HTTP_REFERER'), $_urlPieces['host'] ? $_urlPieces['host'] : $this->settings['board_url'] ) !== false )
+ {
+ $http_referrer = my_getenv('HTTP_REFERER');
+ }
+ else
+ {
+ $http_referrer = '';
+ }
+ }
+
+ $login_methods = false;
+ $uses_name = false;
+ $uses_email = false;
+
+ foreach( $this->cache->getCache('login_methods') as $method )
+ {
+ $login_methods[ $method['login_folder_name'] ] = $method['login_folder_name'];
+
+ if( $method['login_user_id'] == 'username' or $method['login_user_id'] == 'either' )
+ {
+ $uses_name = true;
+ }
+
+ if( $method['login_user_id'] == 'email' or $method['login_user_id'] == 'either' )
+ {
+ $uses_email = true;
+ }
+ }
+
+ if( $uses_name AND $uses_email )
+ {
+ $this->lang->words['enter_name'] = $this->lang->words['enter_name_and_email'];
+ }
+ else if( $uses_email )
+ {
+ $this->lang->words['enter_name'] = $this->lang->words['enter_useremail'];
+ }
+ else
+ {
+ $this->lang->words['enter_name'] = $this->lang->words['enter_username'];
+ }
+
+ $template .= $this->registry->getClass('output')->getTemplate('login')->showLogInForm( $this->lang->words['please_log_in'], htmlentities(urldecode($http_referrer)), $extra_form, $login_methods );
+ }
+
+
+ $this->registry->getClass('output')->addNavigation( $this->lang->words['log_in'], '' );
+ $this->registry->getClass('output')->setTitle( $this->lang->words['log_in'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->getClass('output')->addContent( $template );
+ $this->registry->getClass('output')->sendOutput();
+ }
+
+ /**
+ * Verify login form submission and log user in
+ *
+ * @return mixed array [0=Words to show, 1=URL to send to, 2=error array]
+ */
+ public function doLogin()
+ {
+ if( !defined('IGNORE_AUTH_KEY') OR !IGNORE_AUTH_KEY )
+ {
+ if ( $this->request['auth_key'] != $this->member->form_hash )
+ {
+ $this->registry->getClass('output')->showError( 'login_no_authkey', 10193, null, null, 403 );
+ }
+ }
+
+ return $this->han_login->verifyLogin();
+ }
+
+ /**
+ * Log a user out
+ *
+ * @param integer Flag to check md5 key
+ * @return mixed Error message or array [0=immediate|redirect, 1=words to show, 2=URL to send to]
+ */
+ public function doLogout( $check_key=true )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ if ( $check_key )
+ {
+ $key = $this->request['k'];
+
+ # Check for funny business
+ if ( $key != $this->member->form_hash )
+ {
+ $this->registry->getClass('output')->showError( 'bad_logout_key', 2012 );
+ }
+ }
+
+ //-----------------------------------------
+ // Set some cookies
+ //-----------------------------------------
+
+ IPSCookie::set( "member_id" , "0", 1, 0, FALSE, TRUE );
+ IPSCookie::set( "pass_hash" , "0", 1, 0, FALSE, TRUE );
+
+ if( IPSCookie::get( "ipsconnect_" . md5( $this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php' ) ) )
+ {
+ IPSCookie::set( "ipsconnect_" . md5( $this->settings['board_url'] . '/interface/ipsconnect/ipsconnect.php' ), '0', 1, 0, FALSE, FALSE );
+ }
+
+ //-----------------------------------------
+ // IPS Connect
+ //-----------------------------------------
+
+ foreach ( $this->caches['login_methods'] as $k => $data )
+ {
+ if ( $data['login_folder_name'] == 'ipsconnect' and $data['login_enabled'] )
+ {
+ $ipsConnectSettings = unserialize( $data['login_custom_config'] );
+
+ IPSCookie::set( "ipsconnect_" . md5( $ipsConnectSettings['master_url'] ), '0', 1, 0, FALSE, FALSE );
+ }
+ }
+
+
+ if( is_array( $_COOKIE ) )
+ {
+ foreach( $_COOKIE as $cookie => $value)
+ {
+ if ( stripos( $cookie, $this->settings['cookie_id'] . 'ipbforumpass' ) !== false AND ! strstr( $value, 'mobileApp' ) )
+ {
+ IPSCookie::set( str_replace( $this->settings['cookie_id'], "", $cookie ), '-', -1 );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Do it..
+ //-----------------------------------------
+
+ $this->member->sessionClass()->convertMemberToGuest();
+
+ $privacy = intval( IPSMember::isLoggedInAnon($this->memberData) );
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW ) ) );
+
+ //-----------------------------------------
+ // Logout callbacks...
+ //-----------------------------------------
+
+ IPSLib::runMemberSync( 'onLogOut', $this->memberData );
+
+ $this->han_login->logoutCallback( $this->memberData );
+
+ //-----------------------------------------
+ // Return..
+ //-----------------------------------------
+
+ $url = "";
+
+ if ( $this->request['return'] AND $this->request['return'] != "" )
+ {
+ $return = urldecode($this->request['return']);
+
+ if ( strpos( $return, "http://" ) === 0 )
+ {
+ return array( 'immediate', '', $return );
+ }
+ }
+
+ return array( 'redirect', $this->lang->words['thanks_for_logout'], $this->settings['board_url'] );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/global/lostpass.php b/upload/admin/applications/core/modules_public/global/lostpass.php
index 6c246d26..478dea0b 100644
--- a/upload/admin/applications/core/modules_public/global/lostpass.php
+++ b/upload/admin/applications/core/modules_public/global/lostpass.php
@@ -1,499 +1,484 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Recover Lost Password
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since 20th February 2002
- * @version $Rev: 10914 $
- *
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class public_core_global_lostpass extends ipsCommand
-{
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen/redirects]
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Load language */
- $this->registry->class_localization->loadLanguageFile( array( 'public_register' ), 'core' );
-
- //-----------------------------------------
- // Meta tags
- //-----------------------------------------
-
- $this->registry->output->addMetaTag( 'robots', 'noindex' );
-
- /* What to do */
- switch( $this->request['do'] )
- {
- case 'sendform':
- $this->lostPasswordValidateForm();
- break;
-
- case '11':
- $this->lostPasswordEnd();
- break;
-
- case '03':
- $this->lostPasswordValidate();
- break;
-
- default:
- case '10':
- $this->lostPasswordForm();
- break;
- }
-
- /* Output */
- $this->registry->output->addContent( $this->output );
- $this->registry->output->sendOutput();
- }
-
- /**
- * Validates a lost password request
- *
- * @return @e void
- */
- public function lostPasswordValidate()
- {
- /* Check for input and it's in a valid format. */
- $in_user_id = intval( trim( urldecode( $this->request['uid'] ) ) );
- $in_validate_key = IPSText::md5Clean( trim( urldecode( $this->request['aid'] ) ) );
-
- /* Check Input */
- if( ! $in_validate_key )
- {
- $this->registry->output->showError( 'validation_key_incorrect', 1015 );
- }
-
- if( ! preg_match( '/^(?:\d){1,}$/', $in_user_id ) )
- {
- $this->registry->output->showError( 'uid_key_incorrect', 1016 );
- }
-
- /* Attempt to get the profile of the requesting user */
- $member = IPSMember::load( $in_user_id );
-
- if( ! $member['member_id'] )
- {
- $this->registry->output->showError( 'lostpass_no_member', 1017 );
- }
-
- /* Get validating info.. */
- $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . ' and lost_pass=1' ) );
-
- if( ! $validate['member_id'] )
- {
- $this->registry->output->showError( 'lostpass_not_validating', 1018 );
- }
-
- if( ( $validate['new_reg'] == 1 ) && ( $this->settings['reg_auth_type'] == "admin" ) )
- {
- $this->registry->output->showError( 'lostpass_new_reg', 4010, true );
- }
-
- if( $validate['vid'] != $in_validate_key )
- {
- $this->registry->output->showError( 'lostpass_key_wrong', 1019 );
- }
- else
- {
- /* On the same page? */
- if( $validate['lost_pass'] != 1 )
- {
- $this->registry->output->showError( 'lostpass_not_lostpass', 4011, true );
- }
-
- /* Test GD image */
- if( $this->settings['bot_antispam_type'] != 'none' )
- {
- if ( $this->registry->getClass('class_captcha')->validate() !== TRUE )
- {
- $this->lostPasswordValidateForm( 'err_reg_code' );
- return;
- }
- }
-
- /* Send a new random password? */
- if( $this->settings['lp_method'] == 'random' )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $save_array = array();
-
- //-----------------------------------------
- // Generate a new random password
- //-----------------------------------------
-
- $new_pass = IPSMember::makePassword();
-
- //-----------------------------------------
- // Generate a new salt
- //-----------------------------------------
-
- $salt = IPSMember::generatePasswordSalt(5);
- $salt = str_replace( '\\', "\\\\", $salt );
-
- //-----------------------------------------
- // New log in key
- //-----------------------------------------
-
- $key = IPSMember::generateAutoLoginKey();
-
- //-----------------------------------------
- // Update...
- //-----------------------------------------
-
- $save_array['members_pass_salt'] = $salt;
- $save_array['members_pass_hash'] = md5( md5($salt) . md5( $new_pass ) );
- $save_array['member_login_key'] = $key;
- $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
- $save_array['failed_logins'] = null;
- $save_array['failed_login_count'] = 0;
-
- //-----------------------------------------
- // Load handler...
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
- $this->han_login->changePass( $member['email'], md5( $new_pass ), $new_pass, $member );
-
- //if ( $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
- //{
- // $this->registry->output->showError( $this->lang->words['lostpass_external_fail'], 2013 );
- //}
-
- IPSMember::save( $member['member_id'], array( 'members' => $save_array ) );
-
- /* Password has been changed! */
- IPSLib::runMemberSync( 'onPassChange', $member['member_id'], $new_pass );
-
- //-----------------------------------------
- // Send out the email...
- //-----------------------------------------
-
- IPSText::getTextClass('email')->getTemplate( "lost_pass_email_pass", $member['language'] );
-
- IPSText::getTextClass('email')->buildMessage( array(
- 'NAME' => $member['members_display_name'],
- 'THE_LINK' => $this->registry->getClass('output')->buildUrl( 'app=core&module=usercp&tab=core&area=email', 'publicNoSession' ),
- 'PASSWORD' => $new_pass,
- 'LOGIN' => $this->registry->getClass('output')->buildUrl( 'app=core&module=global§ion=login', 'publicNoSession' ),
- 'USERNAME' => $member['name'],
- 'EMAIL' => $member['email'],
- 'ID' => $member['member_id'],
- )
- );
-
- IPSText::getTextClass('email')->subject = $this->lang->words['lp_random_pass_subject'] . ' ' . $this->settings['board_name'];
- IPSText::getTextClass('email')->to = $member['email'];
-
- IPSText::getTextClass('email')->sendMail();
-
- $this->registry->output->setTitle( $this->lang->words['activation_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->output = $this->registry->getClass('output')->getTemplate('register')->showLostPassWaitRandom( $member );
- }
- else
- {
- if( $_POST['pass1'] == "" )
- {
- $this->registry->output->showError( 'pass_blank', 10184 );
- }
-
- if( $_POST['pass2'] == "" )
- {
- $this->registry->output->showError( 'pass_blank', 10185 );
- }
-
- $pass_a = trim( $this->request['pass1'] );
- $pass_b = trim( $this->request['pass2'] );
-
- if( strlen( $pass_a ) < 3 )
- {
- $this->registry->output->showError( 'pass_too_short', 10186 );
- }
-
- if( $pass_a != $pass_b )
- {
- $this->registry->output->showError( 'pass_no_match', 10187 );
- }
-
- $new_pass = md5( $pass_a );
-
- /* Update Member Array */
- $save_array = array();
-
- /* Generate a new salt */
- $salt = IPSMember::generatePasswordSalt(5);
- $salt = str_replace( '\\', "\\\\", $salt );
-
- /* New log in key */
- $key = IPSMember::generateAutoLoginKey();
-
- /* Update Array */
- $save_array['members_pass_salt'] = $salt;
- $save_array['members_pass_hash'] = md5( md5($salt) . $new_pass );
- $save_array['member_login_key'] = $key;
- $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
- $save_array['failed_logins'] = null;
- $save_array['failed_login_count'] = 0;
-
- /* Change the password */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
- $this->han_login->changePass( $member['email'], $new_pass, $pass_a, $member );
-
- //-----------------------------------------
- // We'll ignore any remote errors
- //-----------------------------------------
-
- /*if( $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
- {
- // Pass not changed remotely
- }*/
-
- /* Update the member */
- IPSMember::save( $member['member_id'], array( 'members' => $save_array ) );
-
- /* Password has been changed! */
- IPSLib::runMemberSync( 'onPassChange', $member['member_id'], $pass_a );
-
- /* Remove "dead" validation */
- $this->DB->delete( 'validating', "vid='{$validate['vid']}' OR (member_id={$member['member_id']} AND lost_pass=1)" );
-
- $this->registry->output->silentRedirect( $this->registry->getClass('output')->buildUrl( 'app=core&module=global§ion=login&do=autologin&frompass=1' ) );
- }
- }
- }
-
- /**
- * Completes the lost password request form
- *
- * @return @e void
- */
- public function lostPasswordEnd()
- {
- if( $this->settings['bot_antispam_type'] != 'none' )
- {
- if( !$this->registry->getClass('class_captcha')->validate( $this->request['regid'], $this->request['reg_code'] ) )
- {
- $this->lostPasswordForm( 'err_reg_code' );
- return;
- }
- }
-
- /* Back to the usual programming! :o */
- if( $this->request['member_name'] == "" AND $this->request['email_addy'] == "" )
- {
- $this->registry->output->showError( 'lostpass_name_email', 10110 );
- }
-
- /* Check for input and it's in a valid format. */
- $member_name = trim( strtolower( $this->request['member_name'] ) );
- $email_addy = trim( strtolower( $this->request['email_addy'] ) );
-
- if( $member_name == "" AND $email_addy == "" )
- {
- $this->registry->output->showError( 'lostpass_name_email', 10111 );
- }
-
- /* Attempt to get the user details from the DB */
- if( $member_name )
- {
- $this->DB->build( array( 'select' => 'members_display_name, name, member_id, email, member_group_id', 'from' => 'members', 'where' => "members_l_username='{$member_name}'" ) );
- $this->DB->execute();
- }
- else if( $email_addy )
- {
- $this->DB->build( array( 'select' => 'members_display_name, name, member_id, email, member_group_id', 'from' => 'members', 'where' => "email='{$email_addy}'" ) );
- $this->DB->execute();
- }
-
- if ( ! $this->DB->getTotalRows() )
- {
- $this->registry->output->showError( 'lostpass_no_user', 10112 );
- }
- else
- {
- $member = $this->DB->fetch();
-
- /* Is there a validation key? If so, we'd better not touch it */
- if( $member['member_id'] == "" )
- {
- $this->registry->output->showError( 'lostpass_no_mid', 2014 );
- }
-
- $validate_key = md5( IPSMember::makePassword() . uniqid( mt_rand(), TRUE ) );
-
- /* Get rid of old entries for this member */
- $this->DB->delete( 'validating', "member_id={$member['member_id']} AND lost_pass=1" );
-
- /* Update the DB for this member. */
- $db_str = array('vid' => $validate_key,
- 'member_id' => $member['member_id'],
- 'temp_group' => $member['member_group_id'],
- 'entry_date' => time(),
- 'coppa_user' => 0,
- 'lost_pass' => 1,
- 'ip_address' => $this->member->ip_address,
- );
-
- /* Are they already in the validating group? */
- if( $member['member_group_id'] != $this->settings['auth_group'] )
- {
- $db_str['real_group'] = $member['member_group_id'];
- }
-
- $this->DB->insert( 'validating', $db_str );
-
- /* Send out the email. */
- IPSText::getTextClass('email')->getTemplate( 'lost_pass', $member['language'] );
-
- IPSText::getTextClass('email')->buildMessage( array(
- 'USERNAME' => $member['name'],
- 'NAME' => $member['members_display_name'],
- 'THE_LINK' => $this->registry->getClass('output')->buildUrl( "app=core&module=global§ion=lostpass&do=sendform&uid={$member['member_id']}&aid={$validate_key}", 'publicNoSession' ),
- 'MAN_LINK' => $this->registry->getClass('output')->buildUrl( 'app=core&module=global§ion=lostpass&do=sendform', 'publicNoSession' ),
- 'EMAIL' => $member['email'],
- 'ID' => $member['member_id'],
- 'CODE' => $validate_key,
- 'IP_ADDRESS' => $this->member->ip_address,
- )
- );
-
- IPSText::getTextClass('email')->subject = $this->lang->words['lp_subject'] . ' ' . $this->settings['board_name'];
- IPSText::getTextClass('email')->to = $member['email'];
- IPSText::getTextClass('email')->sendMail();
-
- $this->output = $this->registry->getClass('output')->getTemplate('register')->lostPasswordWait( $member );
- }
-
- $this->registry->output->setTitle( $this->lang->words['lost_pass_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
- }
-
- /**
- * Displays the lost password form
- *
- * @param string $errors
- * @return @e void
- */
- public function lostPasswordForm( $errors="" )
- {
- //-----------------------------------------
- // Do we have another URL for password resets?
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $han_login = new $classToLoad( $this->registry );
- $han_login->init();
- $han_login->checkMaintenanceRedirect();
-
- /* CAPTCHA */
- if( $this->settings['bot_antispam_type'] != 'none' )
- {
- $captchaHTML = $this->registry->getClass('class_captcha')->getTemplate();
- }
-
- $this->registry->output->setTitle( $this->lang->words['lost_pass_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->output->addNavigation( $this->lang->words['lost_pass_form'], '' );
-
- $this->output .= $this->registry->output->getTemplate('register')->lostPasswordForm( $this->lang->words[ $errors ] );
-
- if ( $this->settings['bot_antispam_type'] != 'none' )
- {
- $this->output = str_replace( "", $captchaHTML, $this->output );
- }
- }
-
-
- /**
- * Shows the form for validating a lost password request
- *
- * @param string $msg
- * @return @e void
- */
- public function lostPasswordValidateForm( $msg='' )
- {
- $this->output .= $this->registry->getClass('output')->getTemplate('register')->showLostpassForm( $this->lang->words[$msg] );
-
- /* Check for input and it's in a valid format. */
- if( $this->request['uid'] AND $this->request['aid'] )
- {
- $in_user_id = intval( trim( urldecode( $this->request['uid'] ) ) );
- $in_validate_key = IPSText::md5Clean( trim( urldecode( $this->request['aid'] ) ) );
- $in_type = trim( $this->request['type'] );
-
- if ($in_type == "")
- {
- $in_type = 'reg';
- }
-
- /* Check and test input */
- if ( ! $in_validate_key )
- {
- $this->registry->output->showError( 'validation_key_incorrect', 10113 );
- }
-
- if (! preg_match( '/^(?:\d){1,}$/', $in_user_id ) )
- {
- $this->registry->output->showError( 'uid_key_incorrect', 10114 );
- }
-
- /* Attempt to get the profile of the requesting user */
- $member = IPSMember::load( $in_user_id );
-
- if( ! $member['member_id'] )
- {
- $this->registry->output->showError( 'lostpass_no_member', 10115 );
- }
-
- /* Get validating info.. */
- $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => "member_id={$in_user_id} and vid='{$in_validate_key}' and lost_pass=1" ) );
-
- if( ! $validate['member_id'] )
- {
- $this->registry->output->showError( 'validation_key_incorrect', 10116 );
- }
-
- $this->output = str_replace( "", $this->registry->output->getTemplate('register')->show_lostpass_form_auto( $in_validate_key, $in_user_id ), $this->output );
- }
- else
- {
- $this->output = str_replace( "", $this->registry->output->getTemplate('register')->show_lostpass_form_manual(), $this->output );
- }
-
- /* CAPTCHA */
- if( $this->settings['bot_antispam_type'] != 'none' )
- {
- $this->output = str_replace( "", $this->registry->getClass('class_captcha')->getTemplate(), $this->output );
- }
-
- $this->registry->output->setTitle( $this->lang->words['activation_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->output->addNavigation( $this->lang->words['activation_form'], '' );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Recover Lost Password
+ * Last Updated: $Date: 2012-11-28 04:54:58 -0500 (Wed, 28 Nov 2012) $
+ *
+ *
+ * @author $Author $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 20th February 2002
+ * @version $Rev: 11651 $
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class public_core_global_lostpass extends ipsCommand
+{
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen/redirects]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Load language */
+ $this->registry->class_localization->loadLanguageFile( array( 'public_register' ), 'core' );
+
+ //-----------------------------------------
+ // Meta tags
+ //-----------------------------------------
+
+ $this->registry->output->addMetaTag( 'robots', 'noindex' );
+
+ /* What to do */
+ switch( $this->request['do'] )
+ {
+ case 'sendform':
+ $this->lostPasswordValidateForm();
+ break;
+
+ case '11':
+ $this->lostPasswordEnd();
+ break;
+
+ case '03':
+ $this->lostPasswordValidate();
+ break;
+
+ default:
+ case '10':
+ $this->lostPasswordForm();
+ break;
+ }
+
+ /* Output */
+ $this->registry->output->addContent( $this->output );
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Validates a lost password request
+ *
+ * @return @e void
+ */
+ public function lostPasswordValidate()
+ {
+ /* Check for input and it's in a valid format. */
+ $in_user_id = intval( trim( urldecode( $this->request['uid'] ) ) );
+ $in_validate_key = IPSText::md5Clean( trim( urldecode( $this->request['aid'] ) ) );
+
+ /* Check Input */
+ if( ! $in_validate_key )
+ {
+ $this->registry->output->showError( 'validation_key_incorrect', 1015 );
+ }
+
+ if( ! preg_match( '/^(?:\d){1,}$/', $in_user_id ) )
+ {
+ $this->registry->output->showError( 'uid_key_incorrect', 1016 );
+ }
+
+ /* Attempt to get the profile of the requesting user */
+ $member = IPSMember::load( $in_user_id );
+
+ if( ! $member['member_id'] )
+ {
+ $this->registry->output->showError( 'lostpass_no_member', 1017 );
+ }
+
+ /* Get validating info.. */
+ $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . ' and lost_pass=1' ) );
+
+ if( ! $validate['member_id'] )
+ {
+ $this->registry->output->showError( 'lostpass_not_validating', 1018 );
+ }
+
+ if( ( $validate['new_reg'] == 1 ) && ( $this->settings['reg_auth_type'] == "admin" ) )
+ {
+ $this->registry->output->showError( 'lostpass_new_reg', 4010, true );
+ }
+
+ if( $validate['vid'] != $in_validate_key )
+ {
+ $this->registry->output->showError( 'lostpass_key_wrong', 1019 );
+ }
+ else
+ {
+ /* On the same page? */
+ if( $validate['lost_pass'] != 1 )
+ {
+ $this->registry->output->showError( 'lostpass_not_lostpass', 4011, true );
+ }
+
+ /* Send a new random password? */
+ if( $this->settings['lp_method'] == 'random' )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $save_array = array();
+
+ //-----------------------------------------
+ // Generate a new random password
+ //-----------------------------------------
+
+ $new_pass = IPSMember::makePassword();
+
+ //-----------------------------------------
+ // Generate a new salt
+ //-----------------------------------------
+
+ $salt = IPSMember::generatePasswordSalt(5);
+ $salt = str_replace( '\\', "\\\\", $salt );
+
+ //-----------------------------------------
+ // New log in key
+ //-----------------------------------------
+
+ $key = IPSMember::generateAutoLoginKey();
+
+ //-----------------------------------------
+ // Update...
+ //-----------------------------------------
+
+ $save_array['members_pass_salt'] = $salt;
+ $save_array['members_pass_hash'] = md5( md5($salt) . md5( $new_pass ) );
+ $save_array['member_login_key'] = $key;
+ $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
+ $save_array['failed_logins'] = null;
+ $save_array['failed_login_count'] = 0;
+
+ //-----------------------------------------
+ // Load handler...
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+ $this->han_login->changePass( $member['email'], md5( $new_pass ), $new_pass, $member );
+
+ //if ( $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
+ //{
+ // $this->registry->output->showError( $this->lang->words['lostpass_external_fail'], 2013 );
+ //}
+
+ IPSMember::save( $member['member_id'], array( 'members' => $save_array ) );
+
+ /* Password has been changed! */
+ IPSLib::runMemberSync( 'onPassChange', $member['member_id'], $new_pass );
+
+ //-----------------------------------------
+ // Send out the email...
+ //-----------------------------------------
+
+ $message = array( 'NAME' => $member['members_display_name'],
+ 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl( 'app=core&module=usercp&tab=core&area=email', 'publicNoSession', 'flase' ),
+ 'PASSWORD' => $new_pass,
+ 'LOGIN' => $this->registry->getClass('output')->buildSEOUrl( 'app=core&module=global§ion=login', 'publicNoSession', 'false' ),
+ 'USERNAME' => $member['name'],
+ 'EMAIL' => $member['email'],
+ 'ID' => $member['member_id'] );
+
+ IPSText::getTextClass('email')->setPlainTextTemplate( IPSText::getTextClass('email')->getTemplate( "lost_pass_email_pass", $member['language'] ) );
+ IPSText::getTextClass('email')->buildPlainTextContent( $message );
+ IPSText::getTextClass('email')->buildHtmlContent( $message );
+
+ IPSText::getTextClass('email')->subject = $this->lang->words['lp_random_pass_subject'] . ' ' . $this->settings['board_name'];
+ IPSText::getTextClass('email')->to = $member['email'];
+
+ IPSText::getTextClass('email')->sendMail();
+
+ $this->registry->output->setTitle( $this->lang->words['activation_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->output = $this->registry->getClass('output')->getTemplate('register')->showLostPassWaitRandom( $member );
+ }
+ else
+ {
+ if( $_POST['pass1'] == "" )
+ {
+ $this->registry->output->showError( 'pass_blank', 10184 );
+ }
+
+ if( $_POST['pass2'] == "" )
+ {
+ $this->registry->output->showError( 'pass_blank', 10185 );
+ }
+
+ $pass_a = trim( $this->request['pass1'] );
+ $pass_b = trim( $this->request['pass2'] );
+
+ /*
+ There's no reason for this - http://community.invisionpower.com/resources/bugs.html/_/ip-board/registrations-limit-passwords-to-32-characters-for-no-apparent-reason-r37770
+ if( strlen( $pass_a ) < 3 )
+ {
+ $this->registry->output->showError( 'pass_too_short', 10186 );
+ }
+ */
+
+ if( $pass_a != $pass_b )
+ {
+ $this->registry->output->showError( 'pass_no_match', 10187 );
+ }
+
+ $new_pass = md5( $pass_a );
+
+ /* Update Member Array */
+ $save_array = array();
+
+ /* Generate a new salt */
+ $salt = IPSMember::generatePasswordSalt(5);
+ $salt = str_replace( '\\', "\\\\", $salt );
+
+ /* New log in key */
+ $key = IPSMember::generateAutoLoginKey();
+
+ /* Update Array */
+ $save_array['members_pass_salt'] = $salt;
+ $save_array['members_pass_hash'] = md5( md5($salt) . $new_pass );
+ $save_array['member_login_key'] = $key;
+ $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
+ $save_array['failed_logins'] = null;
+ $save_array['failed_login_count'] = 0;
+
+ /* Change the password */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+ $this->han_login->changePass( $member['email'], $new_pass, $pass_a, $member );
+
+ //-----------------------------------------
+ // We'll ignore any remote errors
+ //-----------------------------------------
+
+ /*if( $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
+ {
+ // Pass not changed remotely
+ }*/
+
+ /* Update the member */
+ IPSMember::save( $member['member_id'], array( 'members' => $save_array ) );
+
+ /* Password has been changed! */
+ IPSLib::runMemberSync( 'onPassChange', $member['member_id'], $pass_a );
+
+ /* Remove "dead" validation */
+ $this->DB->delete( 'validating', "vid='{$validate['vid']}' OR (member_id={$member['member_id']} AND lost_pass=1)" );
+
+ $this->registry->output->silentRedirect( $this->registry->getClass('output')->buildSEOUrl( 'app=core&module=global§ion=login&do=autologin&frompass=1' ) );
+ }
+ }
+ }
+
+ /**
+ * Completes the lost password request form
+ *
+ * @return @e void
+ */
+ public function lostPasswordEnd()
+ {
+ if( $this->settings['bot_antispam_type'] != 'none' )
+ {
+ if( !$this->registry->getClass('class_captcha')->validate( $this->request['regid'], $this->request['reg_code'] ) )
+ {
+ $this->lostPasswordForm( 'err_reg_code' );
+ return;
+ }
+ }
+
+ /* Back to the usual programming! :o */
+ if( $this->request['member_name'] == "" AND $this->request['email_addy'] == "" )
+ {
+ $this->registry->output->showError( 'lostpass_name_email', 10110 );
+ }
+
+ /* Check for input and it's in a valid format. */
+ $member_name = trim( mb_strtolower( $this->request['member_name'] ) );
+ $email_addy = trim( strtolower( $this->request['email_addy'] ) );
+
+ if( $member_name == "" AND $email_addy == "" )
+ {
+ $this->registry->output->showError( 'lostpass_name_email', 10111 );
+ }
+
+ /* Attempt to get the user details from the DB */
+ if( $member_name )
+ {
+ $this->DB->build( array( 'select' => 'members_display_name, name, member_id, email, member_group_id', 'from' => 'members', 'where' => "members_l_username='{$member_name}'" ) );
+ $this->DB->execute();
+ }
+ else if( $email_addy )
+ {
+ $this->DB->build( array( 'select' => 'members_display_name, name, member_id, email, member_group_id', 'from' => 'members', 'where' => "email='{$email_addy}'" ) );
+ $this->DB->execute();
+ }
+
+ if ( ! $this->DB->getTotalRows() )
+ {
+ $this->registry->output->showError( 'lostpass_no_user', 10112 );
+ }
+ else
+ {
+ $member = $this->DB->fetch();
+
+ /* Is there a validation key? If so, we'd better not touch it */
+ if( $member['member_id'] == "" )
+ {
+ $this->registry->output->showError( 'lostpass_no_mid', 2014 );
+ }
+
+ $validate_key = md5( IPSMember::makePassword() . uniqid( mt_rand(), TRUE ) );
+
+ /* Get rid of old entries for this member */
+ $this->DB->delete( 'validating', "member_id={$member['member_id']} AND lost_pass=1" );
+
+ /* Update the DB for this member. */
+ $db_str = array('vid' => $validate_key,
+ 'member_id' => $member['member_id'],
+ 'temp_group' => $member['member_group_id'],
+ 'entry_date' => time(),
+ 'coppa_user' => 0,
+ 'lost_pass' => 1,
+ 'ip_address' => $this->member->ip_address,
+ );
+
+ /* Are they already in the validating group? */
+ if( $member['member_group_id'] != $this->settings['auth_group'] )
+ {
+ $db_str['real_group'] = $member['member_group_id'];
+ }
+
+ $this->DB->insert( 'validating', $db_str );
+
+ /* Send out the email. */
+ $message = array( 'USERNAME' => $member['name'],
+ 'NAME' => $member['members_display_name'],
+ 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl( "app=core&module=global§ion=lostpass&do=sendform&uid={$member['member_id']}&aid={$validate_key}", 'publicNoSession', 'false' ),
+ 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl( 'app=core&module=global§ion=lostpass&do=sendform', 'publicNoSession', 'false' ),
+ 'EMAIL' => $member['email'],
+ 'ID' => $member['member_id'],
+ 'CODE' => $validate_key,
+ 'IP_ADDRESS' => $this->member->ip_address );
+
+ IPSText::getTextClass('email')->setPlainTextTemplate( IPSText::getTextClass('email')->getTemplate( "lost_pass", $member['language'] ) );
+ IPSText::getTextClass('email')->buildPlainTextContent( $message );
+ IPSText::getTextClass('email')->buildHtmlContent( $message );
+
+ IPSText::getTextClass('email')->subject = $this->lang->words['lp_subject'] . ' ' . $this->settings['board_name'];
+ IPSText::getTextClass('email')->to = $member['email'];
+ IPSText::getTextClass('email')->sendMail();
+
+ $this->output = $this->registry->getClass('output')->getTemplate('register')->lostPasswordWait( $member );
+ }
+
+ $this->registry->output->setTitle( $this->lang->words['lost_pass_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ }
+
+ /**
+ * Displays the lost password form
+ *
+ * @param string $errors
+ * @return @e void
+ */
+ public function lostPasswordForm( $errors="" )
+ {
+ //-----------------------------------------
+ // Do we have another URL for password resets?
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $han_login = new $classToLoad( $this->registry );
+ $han_login->init();
+ $han_login->checkMaintenanceRedirect();
+
+ /* CAPTCHA */
+ if( $this->settings['bot_antispam_type'] != 'none' )
+ {
+ $captchaHTML = $this->registry->getClass('class_captcha')->getTemplate();
+ }
+
+ $this->registry->output->setTitle( $this->lang->words['lost_pass_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->addNavigation( $this->lang->words['lost_pass_form'], '' );
+
+ $this->output .= $this->registry->output->getTemplate('register')->lostPasswordForm( $this->lang->words[ $errors ] );
+
+ if ( $this->settings['bot_antispam_type'] != 'none' )
+ {
+ $this->output = str_replace( "", $captchaHTML, $this->output );
+ }
+ }
+
+
+ /**
+ * Shows the form for validating a lost password request
+ *
+ * @param string $msg
+ * @return @e void
+ */
+ public function lostPasswordValidateForm( $msg='' )
+ {
+ $this->output .= $this->registry->getClass('output')->getTemplate('register')->showLostpassForm( $this->lang->words[$msg] );
+
+ /* Check for input and it's in a valid format. */
+ if( $this->request['uid'] AND $this->request['aid'] )
+ {
+ $in_user_id = intval( trim( urldecode( $this->request['uid'] ) ) );
+ $in_validate_key = IPSText::md5Clean( trim( urldecode( $this->request['aid'] ) ) );
+ $in_type = trim( $this->request['type'] );
+
+ if ($in_type == "")
+ {
+ $in_type = 'reg';
+ }
+
+ /* Check and test input */
+ if ( ! $in_validate_key )
+ {
+ $this->registry->output->showError( 'validation_key_incorrect', 10113 );
+ }
+
+ if (! preg_match( '/^(?:\d){1,}$/', $in_user_id ) )
+ {
+ $this->registry->output->showError( 'uid_key_incorrect', 10114 );
+ }
+
+ /* Attempt to get the profile of the requesting user */
+ $member = IPSMember::load( $in_user_id );
+
+ if( ! $member['member_id'] )
+ {
+ $this->registry->output->showError( 'lostpass_no_member', 10115 );
+ }
+
+ /* Get validating info.. */
+ $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => "member_id={$in_user_id} and vid='{$in_validate_key}' and lost_pass=1" ) );
+
+ if( ! $validate['member_id'] )
+ {
+ $this->registry->output->showError( 'validation_key_incorrect', 10116 );
+ }
+
+ $this->output = str_replace( "", $this->registry->output->getTemplate('register')->show_lostpass_form_auto( $in_validate_key, $in_user_id ), $this->output );
+ }
+ else
+ {
+ $this->output = str_replace( "", $this->registry->output->getTemplate('register')->show_lostpass_form_manual(), $this->output );
+ }
+
+ $this->registry->output->setTitle( $this->lang->words['activation_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->addNavigation( $this->lang->words['activation_form'], '' );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/global/meta.php b/upload/admin/applications/core/modules_public/global/meta.php
new file mode 100644
index 00000000..61e908f4
--- /dev/null
+++ b/upload/admin/applications/core/modules_public/global/meta.php
@@ -0,0 +1,125 @@
+Incorrect accessYou cannot access this file directly.";
+ exit();
+}
+
+class public_core_global_meta extends ipsCommand
+{
+
+ /**
+ * Main class entry point
+ *
+ * @access public
+ * @param object ipsRegistry reference
+ * @return @e void [Outputs to screen]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ if ( $this->request['do'] != 'end' )
+ {
+ /* Are we a logged in admin? */
+ if ( empty($this->memberData['member_id']) || empty($this->memberData['g_access_cp']) )
+ {
+ $this->registry->output->showError( 'meta_editor_no_admin', 'IPSEO-META-ADMIN' );
+ }
+
+ /* Permission Check */
+ require_once IPS_ROOT_PATH . 'sources/classes/class_permissions.php';
+ $class_permissions = new class_permissions( $this->registry );
+ $class_permissions->checkPermissionAutoMsg( 'settemplates_meta', 'core', 'templates' );
+ }
+
+ switch ( $this->request['do'] )
+ {
+ case 'init':
+ $this->init();
+ break;
+
+ case 'save':
+ $this->save();
+ break;
+
+ case 'end':
+ $this->end();
+ break;
+ }
+ }
+
+ /**
+ * Activates the live meta editor
+ *
+ * @return @e void
+ */
+ public function init()
+ {
+ /* Enable live meta editor and redirect */
+ IPSMember::packMemberCache( $this->memberData['member_id'], array( 'ipseo_live_meta_edit' => 1 ) );
+
+ $this->registry->output->silentRedirect( $this->settings['base_url'] );
+ }
+
+ /**
+ * Saves the meta tags for the page
+ *
+ * @return @e void
+ */
+ public function save()
+ {
+ //-----------------------------------------
+ // Save em
+ //-----------------------------------------
+
+ /* Delete any DB entries for this page as we're about to rebuild them */
+ $escapedPage = $this->DB->addSlashes( $this->request['url'] );
+ $this->DB->delete( 'seo_meta', "url='{$escapedPage}'" );
+
+ /* Insert Tags */
+ foreach( $this->request['meta-tags-title'] as $k => $v )
+ {
+ if ( $v )
+ {
+ $cache[ $this->request['url'] ][ $v ] = $this->request['meta-tags-content'][ $k ];
+ $this->DB->insert('seo_meta', array(
+ 'url' => $this->request['url'],
+ 'name' => $v,
+ 'content' => $this->request['meta-tags-content'][ $k ]
+ ) );
+ }
+ }
+
+ /* Rebuild Cache */
+ ips_CacheRegistry::instance()->rebuildCache( 'meta_tags' );
+
+ /* Boink */
+ $this->registry->output->silentRedirect( ipsRegistry::$settings['base_url'] . $this->request['url'] );
+
+ }
+
+ /**
+ * Disables the live meta editor
+ *
+ * @return @e void
+ */
+ public function end()
+ {
+ IPSMember::packMemberCache( $this->memberData['member_id'], array( 'ipseo_live_meta_edit' => 0 ) );
+
+ $this->registry->output->silentRedirect( ipsRegistry::$settings['base_url'] . $this->request['url'] );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/global/navigation.php b/upload/admin/applications/core/modules_public/global/navigation.php
index 1c2606b1..c1ccf77b 100644
--- a/upload/admin/applications/core/modules_public/global/navigation.php
+++ b/upload/admin/applications/core/modules_public/global/navigation.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Captcha
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-04-16 15:13:53 -0400 (Tue, 16 Apr 2013) $
*
*
* @author $Author $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 20th February 2002
- * @version $Rev: 10914 $
+ * @version $Rev: 12182 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -34,7 +34,13 @@ class public_core_global_navigation extends ipsCommand
public function doExecute( ipsRegistry $registry )
{
/* Set up */
- $inapp = trim( $this->request['inapp'] );
+
+ $inapp = is_string( $this->request['inapp'] ) ? trim( $this->request['inapp'] ) : "";
+
+ if ( !$inapp )
+ {
+ $this->registry->output->showError( 'invalid_app', 1040007, null, null, 500 );
+ }
/* Load navigation stuff */
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/navigation/build.php', 'classes_navigation_build' );
@@ -43,7 +49,7 @@ class public_core_global_navigation extends ipsCommand
/* Return */
$html = $this->registry->output->getTemplate( 'global_other' )->quickNavigationWrapper( $navigation->loadApplicationTabs(), $navigation->loadNavigationData(), $inapp );
- $this->registry->getClass('output')->setTitle( $this->lang->words['navigation_title'] );
+ $this->registry->getClass('output')->setTitle( $this->lang->words['navigation_title'] . ' - ' . IPSLib::getAppTitle( $inapp ) );
$this->registry->getClass('output')->addContent( $html );
$this->registry->getClass('output')->sendOutput();
}
diff --git a/upload/admin/applications/core/modules_public/global/privacy.php b/upload/admin/applications/core/modules_public/global/privacy.php
index 71055332..845e8d81 100644
--- a/upload/admin/applications/core/modules_public/global/privacy.php
+++ b/upload/admin/applications/core/modules_public/global/privacy.php
@@ -3,7 +3,7 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Show forum rules
* Last Updated: $Date: 2011-05-05 12:03:47 +0100 (Thu, 05 May 2011) $
*
diff --git a/upload/admin/applications/core/modules_public/global/register.php b/upload/admin/applications/core/modules_public/global/register.php
index ab9c0431..bc1672a7 100644
--- a/upload/admin/applications/core/modules_public/global/register.php
+++ b/upload/admin/applications/core/modules_public/global/register.php
@@ -1,2086 +1,2115 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Register
- * Last Updated: $Date: 2012-06-22 07:58:19 -0400 (Fri, 22 Jun 2012) $
- *
- *
- * @author $Author $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since 20th February 2002
- * @version $Rev: 10970 $
- *
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class public_core_global_register extends ipsCommand
-{
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen/redirects]
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Load language */
- $this->registry->class_localization->loadLanguageFile( array( 'public_register' ), 'core' );
-
- //-----------------------------------------
- // Meta tags
- //-----------------------------------------
-
- $this->registry->output->addMetaTag( 'robots', 'noindex' );
-
- /* What to do */
- switch( $this->request['do'] )
- {
- default:
- case 'form':
- if( $this->settings['no_reg'] > 0 )
- {
- $this->registry->output->showError( 'registration_disabled', 10123, FALSE, '', 200 );
- }
-
- $this->registerForm();
- break;
-
- case 'process_form':
- if( $this->settings['no_reg'] > 0 )
- {
- $this->registry->output->showError( 'registration_disabled', 2016, true );
- }
-
- $this->registerProcessForm();
- break;
-
- case 'auto_validate':
- $this->_autoValidate();
- break;
-
- case 'coppa_two':
- $this->registerCoppaTwo();
- break;
-
- case '12':
- $this->registerCoppaPermsForm();
- break;
-
- //-----------------------------------------
- // Validation (i.e. registration, pw change, etc.)
- //-----------------------------------------
-
- case '05':
- $this->_showManualForm();
- break;
-
- case '07':
- $this->_showManualForm('newemail');
- break;
-
- case 'reval':
- $this->_revalidateForm();
- break;
-
- case 'reval2':
- $this->_revalidateComplete();
- break;
-
- //-----------------------------------------
- // Complete a partial login
- //-----------------------------------------
-
- case 'complete_login':
- $this->_completeRegistration();
- break;
- case 'complete_login_do':
- $this->_completeRegistrationSave();
- break;
- }
-
- /* Output */
- $this->registry->output->addContent( $this->output );
- $this->registry->output->sendOutput();
- }
-
- /**
- * Reset a member if they are logged in
- *
- * @return @e void
- */
- protected function _resetMember()
- {
- if( $this->memberData['member_id'] )
- {
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
-
- //-----------------------------------------
- // Set some cookies
- //-----------------------------------------
-
- IPSCookie::set( "member_id" , "0" );
- IPSCookie::set( "pass_hash" , "0" );
-
- if ( is_array($_COOKIE) )
- {
- foreach( $_COOKIE as $cookie => $value)
- {
- if ( stripos( $cookie, $this->settings['cookie_id']."ipbforum" ) !== false )
- {
- IPSCookie::set( str_replace( $this->settings['cookie_id'], "", $cookie ) , '-', -1 );
- }
- }
- }
-
- //-----------------------------------------
- // Logout callbacks...
- //-----------------------------------------
-
- $this->han_login->logoutCallback();
-
- //-----------------------------------------
- // Do it..
- //-----------------------------------------
-
- $this->member->sessionClass()->convertMemberToGuest();
-
- $privacy = intval( IPSMember::isLoggedInAnon($this->memberData) );
-
- IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW ) ) );
- }
- }
-
- /**
- * Displays the registration form
- *
- * @param array $form_errors
- * @return @e void
- */
- public function registerForm( $form_errors=array() )
- {
- //-----------------------------------------
- // Init
- //-----------------------------------------
-
- $final_errors = array();
- $coppa = IPSCookie::get( 'coppa' );
- $step = $this->request['step'] ? intval($this->request['step']) : 1;
-
- $this->settings['username_errormsg'] = str_replace( '{chars}', $this->settings['username_characters'], $this->settings['username_errormsg'] );
-
- if( $coppa == 'yes' )
- {
- $this->registry->output->showError( 'awaiting_coppa', 10124 );
- }
-
- $this->_resetMember();
-
- //-----------------------------------------
- // COPPA swapout
- //-----------------------------------------
-
- if( $this->settings['use_coppa'] )
- {
- $this->lang->words['confirm_over_thirteen'] = str_replace( "<#FORM_LINK#>", "{$this->settings['base_url']}app=core&module=global§ion=register&do=12", $this->lang->words['confirm_over_thirteen'] );
- }
-
- //-----------------------------------------
- // T & C
- //-----------------------------------------
-
- $cache = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key='reg_rules'" ) );
- $text = $cache['conf_value'] ? $cache['conf_value'] : $cache['conf_default'];
-
- IPSText::getTextClass( 'bbcode' )->parse_smilies = 1;
- IPSText::getTextClass( 'bbcode' )->parse_html = 1;
- IPSText::getTextClass( 'bbcode' )->parse_nl2br = 1;
- IPSText::getTextClass( 'bbcode' )->parse_bbcode = 1;
- IPSText::getTextClass( 'bbcode' )->parsing_section = 'global';
-
- $this->settings['_termsAndConditions'] = IPSText::getTextClass( 'bbcode' )->preDisplayParse( $text );
-
- //-----------------------------------------
- // Page title / navigation
- //-----------------------------------------
-
- $this->registry->output->setTitle( $this->lang->words['registration_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->output->addNavigation( $this->lang->words['registration_form'], '' );
-
- //-----------------------------------------
- // If Nexus is installed, that is the first step
- //-----------------------------------------
-
- if( IPSLib::appIsInstalled('nexus') AND $this->settings['nexus_reg_show'] AND $this->settings['nexus_store_online'] )
- {
- //-----------------------------------------
- // We just submitted the form
- //-----------------------------------------
-
- if( $this->request['nexus_pass'] )
- {
- $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'nexus' ) . '/sources/hooks.php', 'nexusHooks', 'nexus' );
- $hookGateway = new $classToLoad( $this->registry );
-
- //-----------------------------------------
- // Check for errors
- //-----------------------------------------
-
- if ( $this->settings['nexus_reg_force'] and !IPSCookie::get( 'cm_reg' ) and empty( $this->request['cm_package'] ) )
- {
- $nexusError = $this->lang->words['forceby_no_sel'];
- }
-
- }
-
- //-----------------------------------------
- // If no errors, create invoice and set cookie
- //-----------------------------------------
-
- if ( !$nexusError and $this->request['nexus_pass'] )
- {
- //-----------------------------------------
- // Did we buy a package?
- //-----------------------------------------
-
- $chosenPackages = ipsRegistry::$request['cm_package'];
-
- if ( !empty( $chosenPackages ) )
- {
- // Get our package data
- $imploded = implode( ',', ipsRegistry::$request['cm_package'] );
- $packages = array();
- ipsRegistry::DB()->build( array( 'select' => '*', 'from' => 'nexus_packages', 'where' => "p_id IN({$imploded})" ) );
- ipsRegistry::DB()->execute();
- while ( $row = ipsRegistry::DB()->fetch() )
- {
- $packages[ $row['p_id'] ] = $row;
- }
-
- // Bundle 'em all up
- foreach ( $chosenPackages as $itemID )
- {
- // Add title to the array
- $titles[] = $packages[ $itemID ]['p_name'];
-
- // Process information
- $shippingData = package::load( $itemID )->shippingData();
- $renewOptions = $packages[ $itemID ]['p_renew_options'] ? unserialize( $packages[ $itemID ]['p_renew_options'] ) : array();
- $renewTerm = empty( $renewOptions ) ? array( 'term' => 0, 'unit' => '', 'price' => 0 ) : array_shift( $renewOptions );
- $items[] = array(
- 'act' => 'new',
- 'app' => 'nexus',
- 'type' => $packages[ $itemID ]['p_type'],
- 'cost' => $packages[ $itemID ]['p_base_price'],
- 'renew_term' => $renewTerm['term'],
- 'renew_units' => $renewTerm['unit'],
- 'renew_cost' => $renewTerm['price'],
- 'itemName' => $packages[ $itemID ]['p_name'],
- 'itemID' => $itemID,
- 'physical' => is_null( $shippingData ) ? FALSE : TRUE,
- 'shipping' => is_null( $shippingData ) ? array() : $shippingData['shipping'],
- 'weight' => is_null( $shippingData ) ? 0 : $shippingData['weight'],
- );
- }
-
- // What are we calling this invoice?
- if ( count( $titles ) == 1 )
- {
- $title = $titles[0];
- }
- else
- {
- $title = implode( ', ', $titles );
- if ( strlen( $title ) > 50 )
- {
- array_pop( $titles );
- $title = implode( ', ', $titles );
- while ( strlen( $title ) > 47 and count( $titles ) > 1 )
- {
- array_pop( $titles );
- $title = implode( ', ', $titles );
- }
- $title .= '...';
- }
- }
-
- // Generate it
- require_once( IPSLib::getAppDir('nexus') . '/sources/nexusApi.php' );/*noLibHook*/
- $invoiceID = nexusApi::generateInvoice( $title, $this->memberData['member_id'], $items );
-
- IPSCookie::set( 'cm_reg', $invoiceID );
- }
- }
- else
- {
- //-----------------------------------------
- // "step 1" if Nexus is set to show packages on registration
- //-----------------------------------------
-
- require_once( IPSLib::getAppDir('nexus') . '/sources/packageCore.php' );/*noLibHook*/
-
- $packages = array();
- $this->DB->build( array( 'select' => '*', 'from' => 'nexus_packages', 'where' => 'p_reg=1', 'order' => 'p_position' ) );
- $e = $this->DB->execute();
- while ( $row = $this->DB->fetch( $e ) )
- {
- $packages[ $row['p_id'] ] = package::load( $row['p_id'] )->buildDisplayData();
- }
-
- if ( !empty( $packages ) )
- {
- if ( isset( $this->request['cm_package'] ) )
- {
- foreach ( $this->request['cm_package'] as $packageID )
- {
- $packages[ $packageID ]['checked'] = "checked='checked'";
- }
- }
- $this->output .= $this->registry->output->getTemplate('nexus_payments')->regForm32( $packages, $nexusError );
- return;
- }
- }
- }
-
- //-----------------------------------------
- // Send to an alternate registration URL?
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*', 'from' => 'login_methods', 'where' => 'login_enabled=1' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- if( $r['login_register_url'] )
- {
- $this->registry->output->silentRedirect( $r['login_register_url'] );
- }
- }
-
- //-----------------------------------------
- // Adjust text as needed based on validation type
- //-----------------------------------------
-
- if( $this->settings['reg_auth_type'] )
- {
- if( $this->settings['reg_auth_type'] == 'admin_user' OR $this->settings['reg_auth_type'] == 'user' )
- {
- $this->lang->words['std_text'] .= " " . $this->lang->words['email_validate_text'];
- }
-
- /* User then admin? */
- if( $this->settings['reg_auth_type'] == 'admin_user' )
- {
- $this->lang->words['std_text'] .= " " . $this->lang->words['user_admin_validation'];
- }
-
- if( $this->settings['reg_auth_type'] == 'admin' )
- {
- $this->lang->words['std_text'] .= " " . $this->lang->words['just_admin_validation'];
- }
- }
-
- //-----------------------------------------
- // Captcha / Q&A
- //-----------------------------------------
-
- $captchaHTML = '';
- $qandaHTML = '';
-
- $question = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'question_and_answer', 'order' => $this->DB->buildRandomOrder(), 'limit' => array(1) ) );
-
- if( $question AND count($question) )
- {
- $qandaHTML = $this->registry->output->getTemplate('global_other')->questionAndAnswer( $question );
- }
-
- if( $this->settings['bot_antispam_type'] != 'none' )
- {
- $captchaHTML = $this->registry->getClass('class_captcha')->getTemplate();
- }
-
- //-----------------------------------------
- // Custom fields
- //-----------------------------------------
-
- $custom_fields_out = array( 'required', 'optional' );
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
- $custom_fields = new $classToLoad();
-
- $custom_fields->member_data = $this->memberData;
- $custom_fields->initData( 'edit' );
- $custom_fields->parseToEdit( 'register' );
-
- if ( count( $custom_fields->out_fields ) )
- {
- foreach( $custom_fields->out_fields as $id => $form_element )
- {
- if ( $custom_fields->cache_data[ $id ]['pf_not_null'] == 1 )
- {
- $ftype = 'required';
- }
- else
- {
- $ftype = 'optional';
- }
-
- $custom_fields_out[$ftype][] = array(
- 'name' => $custom_fields->field_names[ $id ],
- 'desc' => $custom_fields->field_desc[ $id ],
- 'field' => $form_element,
- 'id' => $id,
- 'error' => '',
- 'type' => $custom_fields->cache_data[ $id ]['pf_type']
- );
- }
- }
-
- //-----------------------------------------
- // If Nexus is installed, also add billing information
- //-----------------------------------------
-
- $nexusFields = array();
- $nexusStates = array();
- if( IPSLib::appIsInstalled('nexus') AND $this->settings['nexus_reg_show'] AND $this->settings['nexus_store_online'] )
- {
- ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'public_countries' ), 'nexus' );
-
- $fields = array();
- $_fields = ipsRegistry::cache()->getCache('customer_fields');
-
- if( is_array($_fields) AND count($_fields) )
- {
- foreach ( $_fields['reg'] as $k )
- {
- $nexusFields[] = $_fields['fields'][ $k ];
- }
- }
-
- $nexusStates = customer::generateStateDropdown( TRUE );
- }
-
- //-----------------------------------------
- // Got errors to show?
- //-----------------------------------------
-
- $final_errors = array( 'dname' => NULL, 'password' => NULL, 'email' => NULL, 'tos' => NULL );
-
- foreach( array( 'dname', 'password', 'email', 'tos' ) as $thing )
- {
- if ( isset($form_errors[ $thing ]) AND is_array( $form_errors[ $thing ] ) AND count( $form_errors[ $thing ] ) )
- {
- $final_errors[ $thing ] = implode( " ", $form_errors[ $thing ] );
- }
- }
-
- $this->request['PassWord'] = $this->request['PassWord'] ? $this->request['PassWord'] : '' ;
- $this->request['EmailAddress'] = $this->request['EmailAddress'] ? $this->request['EmailAddress'] : '' ;
- $this->request['EmailAddress_two'] = $this->request['EmailAddress_two'] ? $this->request['EmailAddress_two'] : '' ;
- $this->request['PassWord_Check'] = $this->request['PassWord_Check'] ? $this->request['PassWord_Check'] : '' ;
- $this->request['members_display_name'] = $this->request['members_display_name'] ? $this->request['members_display_name'] : '' ;
- $this->request['time_offset'] = $this->request['time_offset'] ? $this->request['time_offset'] : '' ;
-
- //-----------------------------------------
- // Create time zone dropdown array
- //-----------------------------------------
-
- $this->registry->class_localization->loadLanguageFile( array( 'public_usercp' ), 'core' );
-
- $time_select = array();
-
- foreach( $this->lang->words as $k => $v )
- {
- if( strpos( $k, "time_" ) === 0 )
- {
- $k = str_replace( "time_", '', $k );
-
- if( preg_match( '/^[\-\d\.]+$/', $k ) )
- {
- $time_select[ $k ] = $v;
- }
- }
- }
-
- ksort( $time_select );
-
- $this->request['time_offset'] = ( $this->request['time_offset'] ) ? $this->request['time_offset'] : $this->settings['time_offset'];
-
- //-----------------------------------------
- // Start output
- //-----------------------------------------
-
- $this->output .= $this->registry->output->getTemplate('register')->registerForm(
- $form_errors['general'],
- array(
- 'TEXT' => $this->lang->words['std_text'],
- 'coppa_user' => $coppa,
- 'captchaHTML' => $captchaHTML,
- 'qandaHTML' => $qandaHTML,
- 'showCOPPA' => $this->settings['use_coppa'] AND !(IPSLib::appIsInstalled('nexus') AND $this->settings['nexus_reg_show'] AND $this->settings['nexus_store_online']),
- ),
- $final_errors,
- $time_select,
- $custom_fields_out,
- $nexusFields,
- $nexusStates );
-
- //-----------------------------------------
- // Member sync module
- //-----------------------------------------
-
- IPSLib::runMemberSync( 'onRegisterForm' );
- }
-
- /**
- * Save the data to complete the partial member record login/registration
- *
- * @return @e void [Outputs to screen/redirects]
- */
- public function _completeRegistrationSave()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $mid = intval( $this->request['mid'] );
- $key = intval( $this->request['key'] );
- $in_email = strtolower( trim($this->request['EmailAddress']) );
- $form_errors = array( 'dname' => array(), 'email' => array(), 'general' => array() );
- $members_display_name = trim( $this->request['members_display_name'] );
- $poss_session_id = "";
- $login_user = trim( $this->request['login_user'] );
- $login_pass = trim( $this->request['login_pass'] );
- $connectService = trim( strtolower( $this->request['connectService'] ) );
-
- //-----------------------------------------
- // Get DB row
- //-----------------------------------------
-
- $reg = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id={$mid} AND partial_date={$key}" ) );
- $tmp_member = IPSMember::load( $mid );
-
- //-----------------------------------------
- // Got it?
- //-----------------------------------------
-
- if ( ! $reg['partial_id'] OR ! $tmp_member['member_id'] )
- {
- $this->registry->output->showError( 'partial_reg_noid', 10117 );
- }
-
- //-----------------------------------------
- // Load log in handler...
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $han_login = new $classToLoad( $this->registry );
- $han_login->init();
-
- //-----------------------------------------
- // Custom profile field stuff
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
- $custom_fields = new $classToLoad();
-
- $custom_fields->initData( 'edit' );
- $custom_fields->parseToSave( $this->request, 'register' );
-
- /* Check */
- if( $custom_fields->error_messages )
- {
- $form_errors['general'] = $custom_fields->error_messages;
- }
-
- /* Check the website url field */
- $website_field = $custom_fields->getFieldIDByKey( 'website' );
-
- if( $website_field && $custom_fields->out_fields[ 'field_' . $website_field ] )
- {
- if( stristr( $custom_fields->out_fields[ 'field_' . $website_field ], 'http://' ) === FALSE && stristr( $custom_fields->out_fields[ 'field_' . $website_field ], 'https://' ) === FALSE )
- {
- $custom_fields->out_fields[ 'field_' . $website_field ] = 'http://' . $custom_fields->out_fields[ 'field_' . $website_field ];
- }
- }
-
- /* Are we trying to connect to an existing account */
- if ( $connectService AND $login_user AND $login_pass AND ( $this->settings['fb_realname'] == 'enforced' OR ! $members_display_name ) )
- {
- /* Load Full Member */
- $member = IPSMember::load( $mid, 'all' );
-
- /* Force email check */
- $han_login->setForceEmailCheck( TRUE );
-
- /* Now attempt to authorize member */
- $return = $han_login->loginPasswordCheck( $login_user, $login_user, $login_pass );
-
- if ( $return !== TRUE )
- {
- /* Wrong email/password */
- $form_errors['serviceLogIn'][] = $this->lang->words['connect_incorrect_details'];
- }
- else
- {
- /* Fetch data returned based on email address */
- $logInMember = $han_login->member_data;
-
- /* We're A-OK so allow service module to clean up member accounts, then log us the heck in! */
- if ( $connectService == 'facebook' AND $member['fb_uid'] )
- {
- /* Already FBd? */
- if ( $logInMember['fb_uid'] AND ( $member['fb_uid'] != $logInMember['fb_uid'] ) )
- {
- /* User already has facebook link */
- $form_errors['serviceLogIn'][] = sprintf( $this->lang->words['connect_already_linked'], $login_user, ucfirst( $connectService ) );
- }
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
- $facebook = new $classToLoad( $this->registry, $member['fb_token'], $member['fb_uid'] );
-
- if ( $facebook->finishNewConnection( $logInMember['member_id'], $member['member_id'] ) !== true )
- {
- /* Unknown error */
- $form_errors['serviceLogIn'][] = $this->lang->words['connect_unknown'];
- }
- }
- else if ( $connectService == 'twitter' AND $member['twitter_id'] )
- {
- /* Already Twitterd? */
- if ( $logInMember['twitter_id'] AND ( $member['twitter_id'] != $logInMember['twitter_id'] ) )
- {
- /* User already has facebook link */
- $form_errors['serviceLogIn'][] = sprintf( $this->lang->words['connect_already_linked'], $login_user, ucfirst( $connectService ) );
- }
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
- $twitter = new $classToLoad( $this->registry, $member['twitter_token'], $member['twitter_secret'] );
-
- if ( $twitter->finishNewConnection( $logInMember['member_id'], $member['member_id'] ) !== true )
- {
- /* Unknown error */
- $form_errors['serviceLogIn'][] = $this->lang->words['connect_unknown'];
- }
- }
-
- /* Ok to proceed? */
- if ( ! count( $form_errors['serviceLogIn'] ) )
- {
- IPSMember::remove( $member['member_id'] );
-
- /* Here, so log us in!! */
- $r = $han_login->loginWithoutCheckingCredentials( $logInMember['member_id'], TRUE );
-
- /* Boing */
- if ( is_array( $r ) )
- {
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=usercp§ion=register&tab=core&area=' . $connectService );
- }
- }
- }
- }
-
- //-----------------------------------------
- // Remove 'sneaky' spaces
- //-----------------------------------------
-
- if ( $this->settings['strip_space_chr'] )
- {
- $members_display_name = IPSText::removeControlCharacters( $members_display_name );
- }
-
- //-----------------------------------------
- // Testing email addresses?
- //-----------------------------------------
-
- if ( ! $reg['partial_email_ok'] AND $in_email )
- {
- //-----------------------------------------
- // Check the email address
- //-----------------------------------------
-
- if( ! IPSText::checkEmailAddress( $in_email ) )
- {
- $form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
- }
-
- //-----------------------------------------
- // Test email address
- //-----------------------------------------
-
- $this->request['EmailAddress_two'] = strtolower( trim($this->request['EmailAddress_two']) );
-
- if ( $in_email AND ( $this->request['EmailAddress_two'] != $in_email ) )
- {
- $form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
- }
-
- /* Is this email banned or does it exist already? */
- if ( IPSMember::isBanned( 'email', $in_email ) || IPSMember::checkByEmail( $in_email ) || $han_login->emailExistsCheck( trim(strtolower($in_email)) ) )
- {
- $form_errors['email'][] = $this->lang->words['reg_error_email_taken'];
- }
- }
- else if ( ! $reg['partial_email_ok'] AND ! $in_email AND ! $login_user )
- {
- $form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
- }
-
- if ( $this->settings['auth_allow_dnames'] )
- {
- /* Check the username */
- $user_check = IPSMember::getFunction()->cleanAndCheckName( $members_display_name, $tmp_member, 'members_display_name' );
-
- if( is_array( $user_check['errors'] ) && count( $user_check['errors'] ) )
- {
- $form_errors['dname'][] = $this->lang->words[ $user_check['errors']['dname'] ];
- }
- }
-
- //-----------------------------------------
- // CHECK 1: Any errors (duplicate names, etc)?
- //-----------------------------------------
-
- if ( count( $form_errors ) )
- {
- $errorMessages = array();
-
- foreach( $form_errors as $errorCat => $errorMessage )
- {
- foreach( $errorMessage as $error )
- {
- $errorMessages['general'][] = $error;
- }
- }
-
- if( count($errorMessages) )
- {
- $this->_completeRegistration( $errorMessages );
- return;
- }
- }
-
- //-----------------------------------------
- // Update: Members
- //-----------------------------------------
-
- $members_display_name = $this->settings['auth_allow_dnames'] ? $members_display_name : $tmp_member['name'];
- $member_group_id = ( $tmp_member['twitter_token'] AND $tmp_member['member_group_id'] == $this->settings['auth_group']) ? $this->settings['member_group'] : $tmp_member['member_group_id'];
-
- if ( ! $reg['partial_email_ok'] )
- {
- IPSMember::save( $mid, array( 'members' => array(
- 'email' => $in_email,
- 'members_display_name' => $members_display_name,
- 'members_seo_name' => IPSText::makeSeoTitle( $members_display_name ),
- 'name' => $tmp_member['name'] ? $tmp_member['name'] : $members_display_name,
- 'members_l_username' => $tmp_member['members_l_username'] ? $tmp_member['members_l_username'] : $members_display_name,
- 'member_group_id' => $member_group_id,
- 'members_l_display_name' => strtolower( $members_display_name )
- ) ) );
- }
- else
- {
- IPSMember::save( $mid, array( 'members' => array(
- 'members_display_name' => $members_display_name,
- 'members_seo_name' => IPSText::makeSeoTitle( $members_display_name ),
- 'name' => $tmp_member['name'] ? $tmp_member['name'] : $members_display_name,
- 'members_l_username' => $tmp_member['members_l_username'] ? $tmp_member['members_l_username'] : $members_display_name,
- 'member_group_id' => $member_group_id,
- 'members_l_display_name' => strtolower( $members_display_name )
- ) ) );
- }
-
- //-----------------------------------------
- // Delete: Partials row
- //-----------------------------------------
-
- $this->DB->delete( 'members_partial', 'partial_member_id=' . $mid );
-
- //-----------------------------------------
- // Update: Profile fields
- //-----------------------------------------
-
- $this->DB->resetDataTypes();
- $this->DB->setDataType( array_keys( $custom_fields->out_fields ), 'string' );
-
- if ( is_array($custom_fields->out_fields) and count($custom_fields->out_fields) )
- {
- $this->DB->update( 'pfields_content', $custom_fields->out_fields, 'member_id=' . $mid );
- }
-
- //-----------------------------------------
- // Pass twitter/facebook via spam service
- //-----------------------------------------
-
- if ( $connectService AND ! $login_user AND $this->settings['spam_service_enabled'] )
- {
- /* Load all member data */
- $member = IPSMember::load( $mid, 'all' );
-
- /* Spam Service */
- $spamCode = 0;
- $_spamFlag = 0;
-
- /* Query the service */
- $spamCode = IPSMember::querySpamService( $member['email'] );
-
- /* Action to perform */
- $action = $this->settings[ 'spam_service_action_' . $spamCode ];
-
- /* Perform Action */
- switch( $action )
- {
- /* Proceed with registration */
- case 1:
- break;
-
- /* Flag for admin approval */
- case 2:
- $member['member_group_id'] = $this->settings['auth_group'];
- $this->settings['reg_auth_type'] = 'admin';
- $_spamFlag = 1;
- break;
-
- /* Approve the account, but ban it */
- case 3:
- $member['member_banned'] = 1;
- $member['bw_is_spammer'] = 1;
- $this->settings['reg_auth_type'] = '';
- break;
- }
-
- /* Update member */
- IPSMember::save( $member['member_id'], array( 'core' => array( 'member_group_id' => $member['member_group_id'],
- 'member_banned' => intval( $member['member_banned'] ),
- 'bw_is_spammer' => intval( $member['bw_is_spammer'] ) ) ) );
-
- /* Did we put them in validating? */
- if ( $_spamFlag )
- {
- $validate_key = md5( IPSMember::makePassword() . time() );
- $time = time();
-
- $this->DB->insert( 'validating', array( 'vid' => $validate_key,
- 'member_id' => $member['member_id'],
- 'real_group' => $this->settings['member_group'],
- 'temp_group' => $this->settings['auth_group'],
- 'entry_date' => $time,
- 'coppa_user' => 0,
- 'new_reg' => 1,
- 'ip_address' => $member['ip_address'],
- 'spam_flag' => $_spamFlag ) );
-
- $this->output = $this->registry->output->getTemplate('register')->showPreview( $member );
- return; #Goes back to doExecute which sends $this->output to output class
- }
- }
-
- /* Send out notification */
- if ( $this->settings['new_reg_notify'] )
- {
- $date = $this->registry->getClass('class_localization')->getDate( time(), 'LONG', 1 );
-
- IPSText::getTextClass('email')->getTemplate("admin_newuser");
-
- IPSText::getTextClass('email')->buildMessage( array( 'DATE' => $date,
- 'LOG_IN_NAME' => $tmp_member['name'] ? $tmp_member['name'] : $members_display_name,
- 'EMAIL' => $in_email,
- 'IP' => $tmp_member['ip_address'],
- 'DISPLAY_NAME' => $members_display_name ) );
-
- IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email'], $this->settings['board_name'] );
- IPSText::getTextClass('email')->to = $this->settings['email_in'];
- IPSText::getTextClass('email')->sendMail();
- }
-
- /* Got admin validation enabled? */
- if ( $connectService && ! $login_user && in_array( $this->settings['reg_auth_type'], array( 'admin', 'admin_user' ) ) )
- {
- /* Make them validating */
- IPSMember::save( $member['member_id'], array( 'core' => array( 'member_group_id' => $this->settings['auth_group'] ) ) );
-
- //-----------------------------------------
- // We want to validate all reg's via email,
- // after email verificiation has taken place,
- // we restore their previous group and remove the validate_key
- //-----------------------------------------
-
- $this->DB->insert( 'validating', array( 'vid' => $validate_key,
- 'member_id' => $member['member_id'],
- 'real_group' => $this->settings['member_group'],
- 'temp_group' => $this->settings['auth_group'],
- 'entry_date' => $time,
- 'coppa_user' => 0,
- 'new_reg' => 1,
- 'ip_address' => $member['ip_address'],
- 'spam_flag' => $_spamFlag ) );
-
- $this->output = $this->registry->output->getTemplate('register')->showPreview( IPSMember::load( $member['member_id'] ) );
- }
-
- //-----------------------------------------
- // Set cookies
- //-----------------------------------------
-
- IPSCookie::set("member_id" , $mid , 1 );
- IPSCookie::set("pass_hash" , $tmp_member['member_login_key'] , 1 );
-
- //-----------------------------------------
- // Fix up session
- //-----------------------------------------
-
- $privacy = ( $this->caches['group_cache'][ $tmp_member['member_group_id'] ]['g_hide_online_list'] || ( empty($this->settings['disable_anonymous']) && ! empty($this->request['Privacy']) ) ) ? 1 : 0;
-
- $this->member->sessionClass()->convertGuestToMember( array( 'member_name' => $members_display_name,
- 'member_id' => $mid,
- 'member_group' => $tmp_member['member_group_id'],
- 'login_type' => $privacy ) );
-
- //-----------------------------------------
- // Update Stats
- //-----------------------------------------
-
- $cache = $this->cache->getCache('stats');
-
- if( $members_display_name AND $mid )
- {
- $cache['last_mem_name'] = $members_display_name;
- $cache['last_mem_name_seo'] = IPSText::makeSeoTitle( $members_display_name );
- $cache['last_mem_id'] = $mid;
- }
-
- $cache['mem_count'] += 1;
-
- $this->cache->setCache( 'stats', $cache, array( 'array' => 1 ) );
-
- /* Complete account */
- $memberData = IPSMember::load( $mid );
-
- IPSLib::runMemberSync( 'onCompleteAccount', $memberData );
- IPSLib::runMemberSync( 'onLogin', $memberData );
-
- //-----------------------------------------
- // Go to the board index
- //-----------------------------------------
-
- $this->registry->output->redirectScreen( $this->lang->words['clogin_done'], $this->settings['base_url'] );
- }
-
- /**
- * When a member logs in via an external login method and we do not have all of the data
- * to create the member's account, we create a partial record. This function shows the
- * form upon first visit by member (usually immediately after login) to complete the
- * login/registration.
- *
- * @param array Errors
- * @return @e void [Outputs to screen/redirects]
- */
- protected function _completeRegistration( $form_errors=array() )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $mid = intval( $this->request['mid'] );
- $key = intval( $this->request['key'] );
- $final_errors = '';
-
- //-----------------------------------------
- // Get DB row
- //-----------------------------------------
-
- $reg = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'members_partial',
- 'where' => "partial_member_id={$mid} AND partial_date={$key}" ) );
-
- //-----------------------------------------
- // Got it?
- //-----------------------------------------
-
- if ( ! $reg['partial_id'] )
- {
- $this->registry->output->showError( 'partial_reg_noid', 10118 );
- }
-
- /* Load Full Member */
- $member = IPSMember::load( $mid, 'all' );
-
- /* Twitter or Facebook? */
- if ( $member['fb_uid'] AND $member['fb_token'] )
- {
- /* Attempt to fetch user details */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
- $facebook = new $classToLoad( $this->registry, $member['fb_token'], $member['fb_uid'] );
-
- $userData = $facebook->fetchUserData();
-
- if ( $userData['id'] )
- {
- $userData['service'] = 'facebook';
- $userData['_name'] = $userData['name'];
- $userData['_pic'] = $userData['pic_square'];
- $userData['_sImage'] = $this->settings['public_dir'] . 'style_status/facebook.png';
-
- /* Enforcing / allowing real names? */
- if ( ! count( $form_errors['dname'] ) AND $this->settings['fb_realname'] != 'any' )
- {
- $userData['_displayName'] = $userData['_name'];
-
- /* Now, make sure we have a unique display name */
- $max = $this->DB->buildAndFetch( array( 'select' => 'MAX(member_id) as max',
- 'from' => 'members',
- 'where' => "members_l_display_name LIKE '" . $this->DB->addSlashes( strtolower( $userData['_displayName'] ) ) . "%'" ) );
-
- if ( $max['max'] )
- {
- /* does the username already have it set? */
- if ( stristr( $member['name'], $userData['_displayName'] ) )
- {
- $userData['_displayName'] = $member['name'];
- }
- else
- {
- $_num = $max['max'] + 1;
- $userData['_displayName'] = $userData['_displayName'] . '_' . $_num;
- }
- }
- }
- }
- }
- else if ( $member['twitter_id'] AND $member['twitter_token'] AND $member['twitter_secret'] )
- {
- /* Attempt to fetch user details */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
- $twitter = new $classToLoad( $this->registry, $member['twitter_token'], $member['twitter_secret'] );
-
- $userData = $twitter->fetchUserData();
-
- if ( $userData['id'] )
- {
- $userData['service'] = 'twitter';
- $userData['_name'] = $userData['screen_name'];
- $userData['_pic'] = $userData['profile_image_url'];
- $userData['_sImage'] = $this->settings['public_dir'] . 'style_status/twitter.png';
- }
- }
- else
- {
- /* Set defaults for any we have */
- $this->request['members_display_name'] = !empty($this->request['members_display_name']) ? $this->request['members_display_name'] : $member['members_display_name'];
- $this->request['EmailAddress'] = !empty($this->request['EmailAddress']) ? $this->request['EmailAddress'] : $member['email'];
- $this->request['EmailAddress_two'] = !empty($this->request['EmailAddress_two']) ? $this->request['EmailAddress_two'] : $member['email'];
- }
-
- /* Remote registrations disabled? */
- if ( $this->settings['no_reg'] == 2 )
- {
- /* Clean up incomplete reg */
- if ( $reg['partial_member_id'] )
- {
- IPSMember::remove( array( $reg['partial_member_id'] ) );
- }
-
- $this->registry->output->showError( 'no_remote_reg', 1090001 );
- }
-
- //-----------------------------------------
- // Custom profile fields stuff
- //-----------------------------------------
-
- $custom_fields_out = array( 'required', 'optional' );
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
- $custom_fields = new $classToLoad();
-
- $custom_fields->member_data = array();
- $custom_fields->initData( 'edit' );
- $custom_fields->parseToEdit( 'register' );
-
- if ( count( $custom_fields->out_fields ) )
- {
- foreach( $custom_fields->out_fields as $id => $form_element )
- {
- if ( $custom_fields->cache_data[ $id ]['pf_not_null'] == 1 )
- {
- $ftype = 'required';
- }
- else
- {
- $ftype = 'optional';
- }
-
- $custom_fields_out[$ftype][] = array(
- 'name' => $custom_fields->field_names[ $id ],
- 'desc' => $custom_fields->field_desc[ $id ],
- 'field' => $form_element,
- 'id' => $id,
- 'error' => '',
- 'type' => $custom_fields->cache_data[ $id ]['pf_type']
- );
- }
- }
-
- //-----------------------------------------
- // Other errors
- //-----------------------------------------
-
- foreach( array( 'dname', 'password', 'email', 'general', 'serviceLogIn' ) as $thing )
- {
- if ( is_array( $form_errors[ $thing ] ) AND count( $form_errors[ $thing ] ) )
- {
- $final_errors .= implode( " ", $form_errors[ $thing ] );
- }
- }
-
- //-----------------------------------------
- // No display name?
- //-----------------------------------------
-
- if ( ! $this->memberData['members_display_name'] )
- {
- $this->memberData['members_display_name'] = ( $member['members_display_name'] ) ? $member['members_display_name'] : $member['email'];
- }
-
- //-----------------------------------------
- // Show the form (email and display name)
- //-----------------------------------------
-
- $this->output .= $this->registry->getClass('output')->getTemplate('register')->completePartialLogin( $mid, $key, $custom_fields_out, $final_errors, $reg, $userData );
-
- $this->registry->output->setTitle( $this->lang->words['clogin_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->output->addNavigation( $this->lang->words['clogin_title'], '' );
- }
-
- /**
- * Show the form to request validation email to be resent
- *
- * @param string Errors
- * @return @e void [Outputs to screen/redirects]
- */
- protected function _revalidateForm( $errors="" )
- {
- $uses_name = false;
- $uses_email = false;
-
- foreach( $this->cache->getCache('login_methods') as $method )
- {
- if( $method['login_user_id'] == 'username' )
- {
- $uses_name = true;
- }
-
- if( $method['login_user_id'] == 'email' )
- {
- $uses_email = true;
- }
- }
-
- if( $uses_name AND $uses_email )
- {
- $name = $this->memberData['member_id'] == "" ? '' : $this->memberData['name'];
- $this->lang->words['rv_ins'] = $this->lang->words['rv_ins_both'];
- }
- else if( $uses_email )
- {
- $name = $this->memberData['member_id'] == "" ? '' : $this->memberData['email'];
- $this->lang->words['rv_ins'] = $this->lang->words['rv_ins_email'];
- }
- else
- {
- $name = $this->memberData['member_id'] == "" ? '' : $this->memberData['name'];
- $this->lang->words['rv_ins'] = $this->lang->words['rv_ins_name'];
- }
-
- $this->output .= $this->registry->getClass('output')->getTemplate('register')->showRevalidateForm( $name, $errors );
- $this->registry->output->setTitle( $this->lang->words['rv_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->output->addNavigation( $this->lang->words['rv_title'], '' );
- }
-
- /**
- * Resend email validation request for lost password, email change and new registration
- *
- * @return @e void [Outputs to screen/redirects]
- */
- protected function _revalidateComplete()
- {
- //-----------------------------------------
- // Check in the DB for entered member name
- //-----------------------------------------
-
- if ( $this->request['username'] == "" )
- {
- $this->_revalidateForm('err_no_username');
- return;
- }
-
- $username = $this->request['username'];
- $keyType = IPSText::checkEmailAddress( $this->request['username'] ) ? 'email' : 'username';
-
- $member = IPSMember::load( $username, 'extendedProfile', $keyType );
-
- if ( ! $member['member_id'] )
- {
- /**
- * Try the other key type just to be safe...
- */
- $member = IPSMember::load( $username, 'extendedProfile', $keyType == 'email' ? 'username' : 'email' );
-
- if ( ! $member['member_id'] )
- {
- $this->_revalidateForm('err_no_username');
- return;
- }
- }
-
- //-----------------------------------------
- // Check in the DB for any validations
- //-----------------------------------------
-
- $val = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => "member_id=" . intval($member['member_id']) ) );
-
- if ( empty($val['vid']) )
- {
- $this->_revalidateForm('err_no_validations');
- return;
- }
-
- //-----------------------------------------
- // Which type is it then?
- //-----------------------------------------
-
- if ( $val['lost_pass'] == 1 )
- {
- IPSText::getTextClass('email')->getTemplate("lost_pass", $member['language']);
-
- IPSText::getTextClass('email')->buildMessage( array(
- 'NAME' => $member['members_display_name'],
- 'THE_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=lostpass&do=sendform&uid=" . $member['member_id'] . "&aid=" . $val['vid'],
- 'MAN_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=lostpass&do=sendform",
- 'EMAIL' => $member['email'],
- 'ID' => $member['member_id'],
- 'CODE' => $val['vid'],
- 'IP_ADDRESS' => $this->member->ip_address,
- )
- );
-
- IPSText::getTextClass('email')->subject = $this->lang->words['lp_subject'].' '.$this->settings['board_name'];
- IPSText::getTextClass('email')->to = $member['email'];
-
- IPSText::getTextClass('email')->sendMail();
- }
- else if ( $val['new_reg'] == 1 )
- {
- IPSText::getTextClass('email')->getTemplate( "reg_validate", $member['language'] );
-
- IPSText::getTextClass('email')->buildMessage( array(
- 'THE_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=auto_validate&uid=" . $member['member_id'] . "&aid=" . $val['vid'],
- 'NAME' => $member['members_display_name'],
- 'MAN_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=05",
- 'EMAIL' => $member['email'],
- 'ID' => $member['member_id'],
- 'CODE' => $val['vid'],
- )
- );
-
- IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['email_reg_subj'], $this->settings['board_name'] );
- IPSText::getTextClass('email')->to = $member['email'];
-
- IPSText::getTextClass('email')->sendMail();
- }
- else if ( $val['email_chg'] == 1 )
- {
- IPSText::getTextClass('email')->getTemplate("newemail");
-
- IPSText::getTextClass('email')->buildMessage( array(
- 'NAME' => $member['members_display_name'],
- 'THE_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=auto_validate&type=newemail&uid=" . $member['member_id'] . "&aid=" . $val['vid'],
- 'ID' => $member['member_id'],
- 'MAN_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=07",
- 'CODE' => $val['vid'],
- )
- );
-
- IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['ne_subject'], $this->settings['board_name'] );
- IPSText::getTextClass('email')->to = $member['email'];
-
- IPSText::getTextClass('email')->sendMail();
- }
- else
- {
- $this->_revalidateForm('err_no_validations');
- return;
- }
-
- $this->output .= $this->registry->getClass('output')->getTemplate('register')->showRevalidated();
-
- $this->registry->output->setTitle( $this->lang->words['rv_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->output->addNavigation( $this->lang->words['rv_title'], '' );
- }
-
- /**
- * Show the form to manually enter in validation info if auto-validation failed.
- *
- * @param string Type of validation
- * @param string Error messages
- * @return @e void [Outputs to screen/redirects]
- */
- protected function _showManualForm($type='reg', $errors="")
- {
- //-----------------------------------------
- // In IPB3 this is handled by another section
- // If somehow a request comes in, send to correct location
- //-----------------------------------------
-
- if ( $type == 'lostpass' )
- {
- $this->registry->output->silentRedirect( $this->settings['base_url'] . 'app=core&module=global§ion=lostpass&do=sendform&uid=' . $this->request['uid'] . '&aid=' . $this->request['aid'] );
- }
- else
- {
- $this->output = $this->registry->getClass('output')->getTemplate('register')->showManualForm( $type );
- }
-
- $this->registry->output->setTitle( $this->lang->words['activation_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->output->addNavigation( $this->lang->words['activation_form'], '' );
- }
-
-
- /**
- * Show coppa form. This is the downloadable/printable form, and as such is just printed to the browser directly
- *
- * @return @e void
- */
- protected function registerCoppaPermsForm()
- {
- /* Keith said to strip these out - it's all his fault :( */
- $this->settings['coppa_address'] = str_replace( array( ' ', ' ' ), '', $this->settings['coppa_address'] );
- $this->settings['coppa_address'] = nl2br( $this->settings['coppa_address'] );
-
- echo( $this->registry->output->getTemplate('register')->registerCoppaForm() );
- exit();
- }
-
- /**
- * This is the second page a COPPA submission hits. Really, user hits this page and if birthday is older than 13
- * we just continue with registration form. Otherwise we show the coppa validation required message with link
- * to download/print coppa compliance sheet for parents to fill in.
- *
- * @return @e void
- */
- protected function registerCoppaTwo()
- {
- if( $this->request['coppa'] == 1 )
- {
- IPSCookie::set( 'coppa', 'no', 0, 1 );
- $this->registerForm();
- return;
- }
-
- IPSCookie::set( 'coppa', 'yes', 0, 1 );
-
- $this->lang->words['coppa_form_text'] = str_replace( "<#FORM_LINK#>", "" . $this->lang->words['coppa_link_form'] . " ", $this->lang->words['coppa_form_text']);
-
- $this->output .= $this->registry->output->getTemplate('register')->registerCoppaTwo();
-
- $this->registry->output->setTitle( $this->lang->words['coppa_title'] . ' - ' . ipsRegistry::$settings['board_name']);
- $this->registry->output->addNavigation( $this->lang->words['coppa_title'], '' );
- }
-
- /**
- * Validation completion. This is the action hit when a user clicks a validation link from their email for
- * lost password, email change and new registration.
- *
- * @return @e void
- */
- protected function _autoValidate()
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $in_user_id = intval(trim(urldecode($this->request['uid'])));
- $in_validate_key = substr( IPSText::alphanumericalClean( urldecode( $this->request['aid'] ) ), 0, 32 );
- $in_type = trim($this->request['type']);
- $in_type = $in_type ? $in_type : 'reg';
-
- //-----------------------------------------
- // Attempt to get the profile of the requesting user
- //-----------------------------------------
-
- $member = IPSMember::load( $in_user_id, 'members' );
-
- if ( ! $member['member_id'] )
- {
- $this->_showManualForm( $in_type, 'reg_error_validate' );
- return;
- }
-
- //-----------------------------------------
- // Get validating info..
- //-----------------------------------------
-
- if ( $in_type == 'lostpass' )
- {
- $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . " AND lost_pass=1" ) );
- }
- else if ( $in_type == 'newemail' )
- {
- $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . " AND email_chg=1" ) );
- }
- else
- {
- $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id ) );
- }
-
- //-----------------------------------------
- // Checks...
- //-----------------------------------------
-
- if ( ! $validate['member_id'] )
- {
- $this->registry->output->showError( 'no_validate_key', 10120 );
- }
-
- //-----------------------------------------
- // Changed to check if this is an admin flagged
- // account for a spam user too
- //-----------------------------------------
-
- if ( ( $validate['new_reg'] == 1 ) && (($this->settings['reg_auth_type'] == "admin" ) || $validate['spam_flag']) )
- {
- $this->registry->output->showError( 'validate_admin_turn', 10121 );
- }
-
- if ( $validate['vid'] != $in_validate_key )
- {
- $this->registry->output->showError( 'validation_key_invalid', 10122 );
- }
-
- //-----------------------------------------
- // Captcha (from posted form, not GET)
- //-----------------------------------------
-
- if ( $this->settings['use_captcha'] AND $this->request['uid'] )
- {
- if ( $this->registry->getClass('class_captcha')->validate( $this->request['captcha_unique_id'], $this->request['captcha_input'] ) !== TRUE )
- {
- $this->_showManualForm( $in_type, 'reg_error_anti_spam' );
- return;
- }
- }
- //-----------------------------------------
- // REGISTER VALIDATE
- //-----------------------------------------
-
- if ( $validate['new_reg'] == 1 )
- {
- if( $member['member_group_id'] == $this->settings['auth_group'] )
- {
- if ( ! $validate['real_group'] )
- {
- $validate['real_group'] = $this->settings['member_group'];
- }
- else if( !isset( $this->caches['group_cache'][ $validate['real_group'] ] ) )
- {
- $validate['real_group'] = $this->settings['member_group'];
- }
- }
-
- //-----------------------------------------
- // SELF-VERIFICATION...
- // 12.14.2009 Changed from != 'admin_user' to
- // be more inclusive (just self-verification only)
- //-----------------------------------------
-
- if ( $this->settings['reg_auth_type'] == 'user' )
- {
- if( $member['member_group_id'] == $this->settings['auth_group'] )
- {
- IPSMember::save( $member['member_id'], array( 'members' => array( 'member_group_id' => $validate['real_group'] ) ) );
- }
-
- /* Reset newest member */
- $stat_cache = $this->caches['stats'];
-
- if( $member['members_display_name'] AND $member['member_id'] AND !$this->caches['group_cache'][ $validate['real_group'] ]['g_hide_online_list'] )
- {
- $stat_cache['last_mem_name'] = $member['members_display_name'];
- $stat_cache['last_mem_name_seo'] = IPSText::makeSeoTitle( $member['members_display_name'] );
- $stat_cache['last_mem_id'] = $member['member_id'];
- }
-
- $stat_cache['mem_count'] += 1;
-
- $this->cache->setCache( 'stats', $stat_cache, array( 'array' => 1 ) );
-
- //-----------------------------------------
- // Remove "dead" validation
- //-----------------------------------------
-
- $this->DB->delete( 'validating', "vid='" . $validate['vid'] . "'" );
-
- IPSLib::runMemberSync( 'onCompleteAccount', $member );
-
- $this->registry->output->silentRedirect( $this->settings['base_url'] . '&app=core&module=global§ion=login&do=autologin&fromreg=1' );
- }
-
- //-----------------------------------------
- // ADMIN-VERIFICATION...
- //-----------------------------------------
-
- else
- {
- //-----------------------------------------
- // Update DB row...
- //-----------------------------------------
-
- $this->DB->update( 'validating', array( 'user_verified' => 1 ), 'vid=\'' . $validate['vid'] . '\'' );
-
- //-----------------------------------------
- // Print message
- //-----------------------------------------
-
- $this->registry->output->setTitle( $this->lang->words['validation_complete'] . ' - ' . ipsRegistry::$settings['board_name'] );
-
- $this->output = $this->registry->getClass('output')->getTemplate('register')->showPreview( $member );
- }
- }
-
- //-----------------------------------------
- // LOST PASS VALIDATE
- //-----------------------------------------
-
- else if ( $validate['lost_pass'] == 1 )
- {
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $save_array = array();
-
- //-----------------------------------------
- // Generate a new random password
- //-----------------------------------------
-
- $new_pass = IPSMember::makePassword();
-
- //-----------------------------------------
- // Generate a new salt
- //-----------------------------------------
-
- $salt = IPSMember::generatePasswordSalt(5);
- $salt = str_replace( '\\', "\\\\", $salt );
-
- //-----------------------------------------
- // New log in key
- //-----------------------------------------
-
- $key = IPSMember::generateAutoLoginKey();
-
- //-----------------------------------------
- // Update...
- //-----------------------------------------
-
- $save_array['members_pass_salt'] = $salt;
- $save_array['members_pass_hash'] = md5( md5($salt) . md5( $new_pass ) );
- $save_array['member_login_key'] = $key;
- $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
-
- //-----------------------------------------
- // Load handler...
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
- $this->han_login->changePass( $member['email'], md5( $new_pass ), $new_pass, $member );
-
- if ( $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
- {
- $this->registry->output->showError( 'lostpass_external_fail', 2015, true );
- }
-
- IPSMember::save( $member['member_id'], array( 'members' => $save_array ) );
-
- //-----------------------------------------
- // Send out the email...
- //-----------------------------------------
-
- IPSText::getTextClass('email')->getTemplate("lost_pass_email_pass", $member['language']);
-
- IPSText::getTextClass('email')->buildMessage( array(
- 'NAME' => $member['members_display_name'],
- 'THE_LINK' => $this->settings['base_url'] . 'app=core&module=usercp&tab=core&area=email',
- 'PASSWORD' => $new_pass,
- 'LOGIN' => $this->settings['base_url'] . 'app=core&module=global§ion=login',
- 'USERNAME' => $member['name'],
- 'EMAIL' => $member['email'],
- 'ID' => $member['member_id'],
- )
- );
-
- IPSText::getTextClass('email')->subject = $this->lang->words['lp_random_pass_subject'] . ' ' . $this->settings['board_name'];
- IPSText::getTextClass('email')->to = $member['email'];
-
- IPSText::getTextClass('email')->sendMail();
-
- $this->registry->output->setTitle( $this->lang->words['validation_complete'] . ' - ' . ipsRegistry::$settings['board_name'] );
-
- //-----------------------------------------
- // Remove "dead" validation
- //-----------------------------------------
-
- $this->DB->delete( 'validating', "vid='" . $validate['vid'] . "' OR (member_id={$member['member_id']} AND lost_pass=1)" );
-
- $this->output = $this->registry->getClass('output')->getTemplate('register')->showLostPassWaitRandom( $member );
- }
-
- //-----------------------------------------
- // EMAIL ADDY CHANGE
- //-----------------------------------------
-
- else if ( $validate['email_chg'] == 1 )
- {
- if ( !$validate['real_group'] )
- {
- $validate['real_group'] = $this->settings['member_group'];
- }
- else if( !isset( $this->caches['group_cache'][ $validate['real_group'] ] ) )
- {
- $validate['real_group'] = $this->settings['member_group'];
- }
-
- IPSMember::save( $member['member_id'], array( 'members' => array( 'member_group_id' => intval($validate['real_group']) ) ) );
-
- IPSCookie::set( "member_id", $member['member_id'] , 1 );
- IPSCookie::set( "pass_hash", $member['member_login_key'], 1 );
-
- //-----------------------------------------
- // Remove "dead" validation
- //-----------------------------------------
-
- $this->DB->delete( 'validating', "vid='" . $validate['vid'] . "' OR (member_id={$member['member_id']} AND email_chg=1)" );
-
- $this->registry->output->silentRedirect( $this->settings['base_url'].'&app=core&module=global§ion=login&do=autologin&fromemail=1' );
- }
- }
-
- /**
- * Processes the registration form
- *
- * @return @e void
- */
- public function registerProcessForm()
- {
- $this->_resetMember();
-
- $form_errors = array();
- $coppa = ( $this->request['coppa_user'] == 1 ) ? 1 : 0;
- $in_password = trim( $this->request['PassWord'] );
- $in_email = strtolower( trim( $this->request['EmailAddress'] ) );
-
- /* Did we agree to the t&c? */
- if( ! $this->request['agree_tos'] )
- {
- $form_errors['tos'] = array( $this->lang->words['must_agree_to_terms'] );
- }
-
- /* Custom profile field stuff */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
- $custom_fields = new $classToLoad();
-
- $custom_fields->initData( 'edit' );
- $custom_fields->parseToSave( $_POST, 'register' );
-
- /* Check */
- if( $custom_fields->error_messages )
- {
- $form_errors['general'] = $custom_fields->error_messages;
- }
-
- /* Check the email address */
- if ( ! $in_email OR strlen( $in_email ) < 6 OR !IPSText::checkEmailAddress( $in_email ) )
- {
- $form_errors['email'][$this->lang->words['err_invalid_email']] = $this->lang->words['err_invalid_email'];
- }
-
- if( trim($this->request['PassWord_Check']) != $in_password OR !$in_password )
- {
- $form_errors['password'][$this->lang->words['passwords_not_match']] = $this->lang->words['passwords_not_match'];
- }
- elseif ( strlen( $in_password ) < 3 )
- {
- $form_errors['password'][$this->lang->words['pass_too_short']] = $this->lang->words['pass_too_short'];
- }
- elseif ( strlen( $in_password ) > 32 )
- {
- $form_errors['password'][$this->lang->words['pass_too_long']] = $this->lang->words['pass_too_long'];
- }
-
- /* Check the username */
- $user_check = IPSMember::getFunction()->cleanAndCheckName( $this->request['members_display_name'], array(), 'name' );
- $disp_check = IPSMember::getFunction()->cleanAndCheckName( $this->request['members_display_name'], array(), 'members_display_name' );
-
- if( is_array( $user_check['errors'] ) && count( $user_check['errors'] ) )
- {
- foreach( $user_check['errors'] as $key => $error )
- {
- $form_errors['dname'][ $error ] = isset($this->lang->words[ $error ]) ? $this->lang->words[ $error ] : $error;
- }
- }
-
- /* this duplicates username error above */
- /*if( is_array( $disp_check['errors'] ) && count( $disp_check['errors'] ) )
- {
- foreach( $disp_check['errors'] as $key => $error )
- {
- $form_errors['dname'][ $error ] = isset($this->lang->words[ $error ]) ? $this->lang->words[ $error ] : $error;
- }
- }*/
-
- /* CHECK 1: Any errors (missing fields, etc)? */
- if( count( $form_errors ) )
- {
- $this->registerForm( $form_errors );
- return;
- }
-
- /* Is this email addy taken? */
- if( IPSMember::checkByEmail( $in_email ) == TRUE )
- {
- $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
- }
-
- /* Load handler... */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
- $this->han_login = new $classToLoad( $this->registry );
- $this->han_login->init();
- $this->han_login->emailExistsCheck( $in_email );
-
- if( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'EMAIL_NOT_IN_USE' )
- {
- $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
- }
-
- /* Are they banned [EMAIL]? */
- if ( IPSMember::isBanned( 'email', $in_email ) === TRUE )
- {
- $form_errors['email'][$this->lang->words['reg_error_email_ban']] = $this->lang->words['reg_error_email_ban'];
- }
-
- /* Check the CAPTCHA */
- if ( $this->settings['bot_antispam_type'] != 'none' )
- {
- if ( $this->registry->getClass('class_captcha')->validate() !== TRUE )
- {
- $form_errors['general'][$this->lang->words['err_reg_code']] = $this->lang->words['err_reg_code'];
- }
- }
-
- /* Check the Q and A */
- $qanda = intval($this->request['qanda_id']);
- $pass = true;
-
- if( $qanda )
- {
- $pass = false;
- $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'question_and_answer', 'where' => 'qa_id=' . $qanda ) );
-
- if( $data['qa_id'] )
- {
- $answers = explode( "\n", str_replace( "\r", "", $data['qa_answers'] ) );
-
- if( count($answers) )
- {
- foreach( $answers as $answer )
- {
- $answer = trim($answer);
-
- if( strlen($answer) AND strtolower($answer) == strtolower($this->request['qa_answer']) )
- {
- $pass = true;
- break;
- }
- }
- }
- }
- }
- else
- {
- //-----------------------------------------
- // Do we have any questions?
- //-----------------------------------------
-
- $data = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as questions', 'from' => 'question_and_answer' ) );
-
- if( $data['questions'] )
- {
- $pass = false;
- }
- }
-
- if( !$pass )
- {
- $form_errors['general'][$this->lang->words['err_q_and_a']] = $this->lang->words['err_q_and_a'];
- }
-
- /* CHECK 2: Any errors ? */
- if ( count( $form_errors ) )
- {
- $this->registerForm( $form_errors );
- return;
- }
-
- /* Build up the hashes */
- $mem_group = $this->settings['member_group'];
-
- /* Are we asking the member or admin to preview? */
- if( $this->settings['reg_auth_type'] )
- {
- $mem_group = $this->settings['auth_group'];
- }
- else if ($coppa == 1)
- {
- $mem_group = $this->settings['auth_group'];
- }
-
- /* Create member */
- $member = array(
- 'name' => $this->request['members_display_name'],
- 'password' => $in_password,
- 'members_display_name' => $this->request['members_display_name'],
- 'email' => $in_email,
- 'member_group_id' => $mem_group,
- 'joined' => time(),
- 'ip_address' => $this->member->ip_address,
- 'time_offset' => $this->request['time_offset'],
- 'coppa_user' => $coppa,
- 'members_auto_dst' => intval($this->settings['time_dst_auto_correction']),
- 'allow_admin_mails' => intval( $this->request['allow_admin_mail'] ),
- 'language' => $this->member->language_id,
- );
-
- /* Spam Service */
- $spamCode = 0;
- $_spamFlag = 0;
-
- if( $this->settings['spam_service_enabled'] )
- {
- /* Query the service */
- $spamCode = IPSMember::querySpamService( $in_email );
-
- /* Action to perform */
- $action = $this->settings[ 'spam_service_action_' . $spamCode ];
-
- /* Perform Action */
- switch( $action )
- {
- /* Proceed with registration */
- case 1:
- break;
-
- /* Flag for admin approval */
- case 2:
- $member['member_group_id'] = $this->settings['auth_group'];
- $this->settings['reg_auth_type'] = 'admin';
- $_spamFlag = 1;
- break;
-
- /* Approve the account, but ban it */
- case 3:
- $member['member_banned'] = 1;
- $member['bw_is_spammer'] = 1;
- $this->settings['reg_auth_type'] = '';
- break;
- }
- }
-
- //-----------------------------------------
- // Create the account
- //-----------------------------------------
-
- $member = IPSMember::create( array( 'members' => $member, 'pfields_content' => $custom_fields->out_fields ), FALSE, FALSE, FALSE );
-
- //-----------------------------------------
- // Login handler create account callback
- //-----------------------------------------
-
- $this->han_login->createAccount( array( 'email' => $member['email'],
- 'joined' => $member['joined'],
- 'password' => $in_password,
- 'ip_address' => $this->member->ip_address,
- 'username' => $member['members_display_name'],
- ) );
-
- //-----------------------------------------
- // We'll just ignore if this fails - it shouldn't hold up IPB anyways
- //-----------------------------------------
-
- /*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) )
- {
- $this->registry->output->showError( 'han_login_create_failed', 2017, true );
- }*/
-
- //-----------------------------------------
- // Validation
- //-----------------------------------------
-
- $validate_key = md5( IPSMember::makePassword() . time() );
- $time = time();
-
- if( $coppa != 1 )
- {
- if( ( $this->settings['reg_auth_type'] == 'user' ) or ( $this->settings['reg_auth_type'] == 'admin' ) or ( $this->settings['reg_auth_type'] == 'admin_user' ) )
- {
- //-----------------------------------------
- // We want to validate all reg's via email,
- // after email verificiation has taken place,
- // we restore their previous group and remove the validate_key
- //-----------------------------------------
-
- $this->DB->insert( 'validating', array(
- 'vid' => $validate_key,
- 'member_id' => $member['member_id'],
- 'real_group' => $this->settings['member_group'],
- 'temp_group' => $this->settings['auth_group'],
- 'entry_date' => $time,
- 'coppa_user' => $coppa,
- 'new_reg' => 1,
- 'ip_address' => $member['ip_address'],
- 'spam_flag' => $_spamFlag,
- ) );
-
- if( $this->settings['reg_auth_type'] == 'user' OR $this->settings['reg_auth_type'] == 'admin_user' )
- {
- IPSText::getTextClass('email')->getTemplate("reg_validate");
-
- IPSText::getTextClass('email')->buildMessage( array(
- 'THE_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=auto_validate&uid=" . urlencode( $member['member_id'] ) . "&aid=" . urlencode( $validate_key ),
- 'NAME' => $member['members_display_name'],
- 'MAN_LINK' => $this->settings['base_url'] . "app=core&module=global§ion=register&do=05",
- 'EMAIL' => $member['email'],
- 'ID' => $member['member_id'],
- 'CODE' => $validate_key,
- ) );
-
- IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email'], $this->settings['board_name'] );
- IPSText::getTextClass('email')->to = $member['email'];
-
- IPSText::getTextClass('email')->sendMail();
-
- $this->output = $this->registry->output->getTemplate('register')->showAuthorize( $member );
-
- }
- else if( $this->settings['reg_auth_type'] == 'admin' )
- {
- $this->output = $this->registry->output->getTemplate('register')->showPreview( $member );
- }
-
- /* Only send new registration email if the member wasn't banned */
- if( $this->settings['new_reg_notify'] AND ! $member['member_banned'] )
- {
- $date = $this->registry->class_localization->getDate( time(), 'LONG', 1 );
-
- IPSText::getTextClass('email')->getTemplate( 'admin_newuser' );
-
- IPSText::getTextClass('email')->buildMessage( array( 'DATE' => $date,
- 'LOG_IN_NAME' => $member['name'],
- 'EMAIL' => $member['email'],
- 'IP' => $member['ip_address'],
- 'DISPLAY_NAME' => $member['members_display_name'] ) );
-
- IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email1'], $this->settings['board_name'] );
- IPSText::getTextClass('email')->to = $this->settings['email_in'];
- IPSText::getTextClass('email')->sendMail();
- }
-
- $this->registry->output->setTitle( $this->lang->words['reg_success'] . ' - ' . ipsRegistry::$settings['board_name'] );
- $this->registry->output->addNavigation( $this->lang->words['nav_reg'], '' );
- }
- else
- {
- /* We don't want to preview, or get them to validate via email. */
- $stat_cache = $this->cache->getCache('stats');
-
- if( $member['members_display_name'] AND $member['member_id'] AND !$this->caches['group_cache'][ $member['member_group_id'] ]['g_hide_online_list'] )
- {
- $stat_cache['last_mem_name'] = $member['members_display_name'];
- $stat_cache['last_mem_name_seo'] = IPSText::makeSeoTitle( $member['members_display_name'] );
- $stat_cache['last_mem_id'] = $member['member_id'];
- }
-
- $stat_cache['mem_count'] += 1;
-
- $this->cache->setCache( 'stats', $stat_cache, array( 'array' => 1 ) );
-
- /* Only send new registration email if the member wasn't banned */
- if( $this->settings['new_reg_notify'] AND ! $member['member_banned'] )
- {
- $date = $this->registry->class_localization->getDate( time(), 'LONG', 1 );
-
- IPSText::getTextClass('email')->getTemplate( 'admin_newuser' );
-
- IPSText::getTextClass('email')->buildMessage( array( 'DATE' => $date,
- 'LOG_IN_NAME' => $member['name'],
- 'EMAIL' => $member['email'],
- 'IP' => $member['ip_address'],
- 'DISPLAY_NAME' => $member['members_display_name'] ) );
-
- IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email1'], $this->settings['board_name'] );
- IPSText::getTextClass('email')->to = $this->settings['email_in'];
- IPSText::getTextClass('email')->sendMail();
- }
-
- IPSCookie::set( 'pass_hash' , $member['member_login_key'], 1);
- IPSCookie::set( 'member_id' , $member['member_id'] , 1);
-
- //-----------------------------------------
- // Fix up session
- //-----------------------------------------
-
- $privacy = ( $member['g_hide_online_list'] || ( empty($this->settings['disable_anonymous']) && ! empty($this->request['Privacy']) ) ) ? 1 : 0;
-
- # Update value for onCompleteAccount call
- $member['login_anonymous'] = $privacy . '&1';
-
- $this->member->sessionClass()->convertGuestToMember( array( 'member_name' => $member['members_display_name'],
- 'member_id' => $member['member_id'],
- 'member_group' => $member['member_group_id'],
- 'login_type' => $privacy ) );
-
- IPSLib::runMemberSync( 'onCompleteAccount', $member );
-
- $this->registry->output->silentRedirect( $this->settings['base_url'] . '&app=core&module=global§ion=login&do=autologin&fromreg=1');
- }
- }
- else
- {
- /* This is a COPPA user, so lets tell them they registered OK and redirect to the form. */
- $this->DB->insert( 'validating', array (
- 'vid' => $validate_key,
- 'member_id' => $member['member_id'],
- 'real_group' => $this->settings['member_group'],
- 'temp_group' => $this->settings['auth_group'],
- 'entry_date' => $time,
- 'coppa_user' => $coppa,
- 'new_reg' => 1,
- 'ip_address' => $member['ip_address']
- ) );
-
- $this->registry->output->redirectScreen( $this->lang->words['cp_success'], $this->settings['base_url'] . 'app=core&module=global§ion=register&do=12' );
- }
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Register
+ * Last Updated: $Date: 2013-05-03 23:09:37 -0400 (Fri, 03 May 2013) $
+ *
+ *
+ * @author $Author $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 20th February 2002
+ * @version $Rev: 12226 $
+ *
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class public_core_global_register extends ipsCommand
+{
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen/redirects]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Load language */
+ $this->registry->class_localization->loadLanguageFile( array( 'public_register' ), 'core' );
+
+ //-----------------------------------------
+ // Meta tags
+ //-----------------------------------------
+
+ $this->registry->output->addMetaTag( 'robots', 'noindex' );
+
+ /* What to do */
+ switch( $this->request['do'] )
+ {
+ default:
+ case 'form':
+ if( $this->settings['no_reg'] > 0 )
+ {
+ $this->registry->output->showError( 'registration_disabled', 10123, FALSE, '', 200 );
+ }
+
+ $this->registerForm();
+ break;
+
+ case 'process_form':
+ if( $this->settings['no_reg'] > 0 )
+ {
+ $this->registry->output->showError( 'registration_disabled', 2016, true );
+ }
+
+ $this->registerProcessForm();
+ break;
+
+ case 'auto_validate':
+ $this->_autoValidate();
+ break;
+
+ case 'coppa_two':
+ $this->registerCoppaTwo();
+ break;
+
+ case '12':
+ $this->registerCoppaPermsForm();
+ break;
+
+ //-----------------------------------------
+ // Validation (i.e. registration, pw change, etc.)
+ //-----------------------------------------
+
+ case '05':
+ $this->_showManualForm();
+ break;
+
+ case '07':
+ $this->_showManualForm('newemail');
+ break;
+
+ case 'reval':
+ $this->_revalidateForm();
+ break;
+
+ case 'reval2':
+ $this->_revalidateComplete();
+ break;
+
+ //-----------------------------------------
+ // Complete a partial login
+ //-----------------------------------------
+
+ case 'complete_login':
+ $this->_completeRegistration();
+ break;
+ case 'complete_login_do':
+ $this->_completeRegistrationSave();
+ break;
+ }
+
+ /* Output */
+ $this->registry->output->addContent( $this->output );
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Reset a member if they are logged in
+ *
+ * @return @e void
+ */
+ protected function _resetMember()
+ {
+ if( $this->memberData['member_id'] )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+
+ //-----------------------------------------
+ // Set some cookies
+ //-----------------------------------------
+
+ IPSCookie::set( "member_id" , "0" );
+ IPSCookie::set( "pass_hash" , "0" );
+
+ if ( is_array($_COOKIE) )
+ {
+ foreach( $_COOKIE as $cookie => $value)
+ {
+ if ( stripos( $cookie, $this->settings['cookie_id']."ipbforum" ) !== false )
+ {
+ IPSCookie::set( str_replace( $this->settings['cookie_id'], "", $cookie ) , '-', -1 );
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Logout callbacks...
+ //-----------------------------------------
+
+ $this->han_login->logoutCallback( $this->memberData );
+
+ //-----------------------------------------
+ // Do it..
+ //-----------------------------------------
+
+ $this->member->sessionClass()->convertMemberToGuest();
+
+ $privacy = intval( IPSMember::isLoggedInAnon($this->memberData) );
+
+ IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'login_anonymous' => "{$privacy}&0", 'last_activity' => IPS_UNIX_TIME_NOW ) ) );
+ }
+ }
+
+ /**
+ * Displays the registration form
+ *
+ * @param array $form_errors
+ * @return @e void
+ */
+ public function registerForm( $form_errors=array() )
+ {
+ //-----------------------------------------
+ // Init
+ //-----------------------------------------
+
+ $final_errors = array();
+ $coppa = IPSCookie::get( 'coppa' );
+ $step = $this->request['step'] ? intval($this->request['step']) : 1;
+
+ $this->settings['username_errormsg'] = str_replace( '{chars}', $this->settings['username_characters'], $this->settings['username_errormsg'] );
+
+ if( $coppa == 'yes' )
+ {
+ $this->registry->output->showError( 'awaiting_coppa', 10124 );
+ }
+
+ $this->_resetMember();
+
+ //-----------------------------------------
+ // COPPA swapout
+ //-----------------------------------------
+
+ if( $this->settings['use_coppa'] )
+ {
+ $this->lang->words['confirm_over_thirteen'] = str_replace( "<#FORM_LINK#>", "{$this->settings['base_url']}app=core&module=global§ion=register&do=12", $this->lang->words['confirm_over_thirteen'] );
+ }
+
+ //-----------------------------------------
+ // T & C
+ //-----------------------------------------
+
+ $cache = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'core_sys_conf_settings', 'where' => "conf_key='reg_rules'" ) );
+ $text = $cache['conf_value'] ? $cache['conf_value'] : $cache['conf_default'];
+
+ IPSText::getTextClass( 'bbcode' )->parse_smilies = 1;
+ IPSText::getTextClass( 'bbcode' )->parse_html = 1;
+ IPSText::getTextClass( 'bbcode' )->parse_nl2br = 1;
+ IPSText::getTextClass( 'bbcode' )->parse_bbcode = 1;
+ IPSText::getTextClass( 'bbcode' )->parsing_section = 'global';
+
+ $this->settings['_termsAndConditions'] = IPSText::getTextClass( 'bbcode' )->preDisplayParse( $text );
+
+ //-----------------------------------------
+ // Page title / navigation
+ //-----------------------------------------
+
+ $this->registry->output->setTitle( $this->lang->words['registration_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->addNavigation( $this->lang->words['registration_form'], '' );
+
+ //-----------------------------------------
+ // If Nexus is installed, that is the first step
+ //-----------------------------------------
+
+ if( IPSLib::appIsInstalled('nexus') AND $this->settings['nexus_reg_show'] AND $this->settings['nexus_store_online'] )
+ {
+ //-----------------------------------------
+ // We just submitted the form
+ //-----------------------------------------
+
+ if( $this->request['nexus_pass'] )
+ {
+ $classToLoad = IPSLib::loadLibrary( IPSLib::getAppDir( 'nexus' ) . '/sources/hooks.php', 'nexusHooks', 'nexus' );
+ $hookGateway = new $classToLoad( $this->registry );
+
+ //-----------------------------------------
+ // Check for errors
+ //-----------------------------------------
+
+ if ( $this->settings['nexus_reg_force'] and !IPSCookie::get( 'cm_reg' ) and empty( $this->request['cm_package'] ) )
+ {
+ $nexusError = $this->lang->words['forceby_no_sel'];
+ }
+
+ }
+
+ //-----------------------------------------
+ // If no errors, create invoice and set cookie
+ //-----------------------------------------
+
+ if ( !$nexusError and $this->request['nexus_pass'] )
+ {
+ //-----------------------------------------
+ // Did we buy a package?
+ //-----------------------------------------
+
+ $chosenPackages = ipsRegistry::$request['cm_package'];
+
+ if ( !empty( $chosenPackages ) )
+ {
+ foreach ( $chosenPackages as $itemID )
+ {
+ require_once( IPSLib::getAppDir('nexus') . '/sources/packageCore.php' );/*noLibHook*/
+ $package = package::load( $itemID );
+ $shippingData = $package->shippingData();
+ $renewTerm = $package->renewalTerms();
+ $items[] = array(
+ 'act' => 'new',
+ 'app' => 'nexus',
+ 'type' => $package->data['p_type'],
+ 'cost' => $package->price( $this->memberData['member_id'], FALSE ),
+ 'tax' => $package->data['p_tax'],
+ 'renew_term' => $renewTerm['term'],
+ 'renew_units' => $renewTerm['unit'],
+ 'renew_cost' => $renewTerm['price'],
+ 'physical' => is_null( $shippingData ) ? FALSE : TRUE,
+ 'shipping' => is_null( $shippingData ) ? array() : $shippingData['shipping'],
+ 'weight' => is_null( $shippingData ) ? 0 : $shippingData['weight'],
+ 'itemName' => $package->data['p_name'],
+ 'itemID' => $package->data['p_id'],
+ 'groupRenewals' => $package->data['p_group_renewals'],
+ 'methods' => $package->data['p_methods'] ? explode( ',', $package->data['p_methods'] ) : array(),
+ );
+ }
+
+ // Generate it
+ require_once( IPSLib::getAppDir('nexus') . '/sources/nexusApi.php' );/*noLibHook*/
+ $invoiceID = nexusApi::generateInvoice( NULL, $this->memberData['member_id'], $items );
+
+ IPSCookie::set( 'cm_reg', $invoiceID );
+ }
+ }
+ else
+ {
+ //-----------------------------------------
+ // "step 1" if Nexus is set to show packages on registration
+ //-----------------------------------------
+
+ require_once( IPSLib::getAppDir('nexus') . '/sources/packageCore.php' );/*noLibHook*/
+
+ $packages = array();
+ $this->DB->build( array( 'select' => '*', 'from' => 'nexus_packages', 'where' => 'p_reg=1', 'order' => 'p_position' ) );
+ $e = $this->DB->execute();
+ while ( $row = $this->DB->fetch( $e ) )
+ {
+ $packages[ $row['p_id'] ] = package::load( $row['p_id'] )->buildDisplayData();
+ }
+
+ if ( !empty( $packages ) )
+ {
+ if ( isset( $this->request['cm_package'] ) )
+ {
+ foreach ( $this->request['cm_package'] as $packageID )
+ {
+ $packages[ $packageID ]['checked'] = "checked='checked'";
+ }
+ }
+ $this->output .= $this->registry->output->getTemplate('nexus_payments')->regForm32( $packages, $nexusError );
+ return;
+ }
+ else
+ {
+ $this->settings['nexus_reg_show'] = false;
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Send to an alternate registration URL?
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'login_methods', 'where' => 'login_enabled=1' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ if( $r['login_register_url'] )
+ {
+ $this->registry->output->silentRedirect( $r['login_register_url'] );
+ }
+ }
+
+ //-----------------------------------------
+ // Adjust text as needed based on validation type
+ //-----------------------------------------
+
+ if( $this->settings['reg_auth_type'] )
+ {
+ if( $this->settings['reg_auth_type'] == 'admin_user' OR $this->settings['reg_auth_type'] == 'user' )
+ {
+ $this->lang->words['std_text'] .= " " . $this->lang->words['email_validate_text'];
+ }
+
+ /* User then admin? */
+ if( $this->settings['reg_auth_type'] == 'admin_user' )
+ {
+ $this->lang->words['std_text'] .= " " . $this->lang->words['user_admin_validation'];
+ }
+
+ if( $this->settings['reg_auth_type'] == 'admin' )
+ {
+ $this->lang->words['std_text'] .= " " . $this->lang->words['just_admin_validation'];
+ }
+ }
+
+ //-----------------------------------------
+ // Captcha / Q&A
+ //-----------------------------------------
+
+ $captchaHTML = '';
+ $qandaHTML = '';
+
+ $question = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'question_and_answer', 'order' => $this->DB->buildRandomOrder(), 'limit' => array(1) ) );
+
+ if( $question AND count($question) )
+ {
+ $qandaHTML = $this->registry->output->getTemplate('global_other')->questionAndAnswer( $question );
+ }
+
+ if( $this->settings['bot_antispam_type'] != 'none' )
+ {
+ $captchaHTML = $this->registry->getClass('class_captcha')->getTemplate();
+ }
+
+ //-----------------------------------------
+ // Custom fields
+ //-----------------------------------------
+
+ $custom_fields_out = array( 'required', 'optional' );
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
+ $custom_fields = new $classToLoad();
+
+ $custom_fields->member_data = $this->memberData;
+ $custom_fields->initData( 'edit', 0, array( 'tabindex' => 6 ) );
+ $custom_fields->parseToEdit( 'register' );
+
+ if ( count( $custom_fields->out_fields ) )
+ {
+ foreach( $custom_fields->out_fields as $id => $form_element )
+ {
+ if ( $custom_fields->cache_data[ $id ]['pf_not_null'] == 1 )
+ {
+ $ftype = 'required';
+ }
+ else
+ {
+ $ftype = 'optional';
+ }
+
+ $custom_fields_out[$ftype][] = array(
+ 'name' => $custom_fields->field_names[ $id ],
+ 'desc' => $custom_fields->field_desc[ $id ],
+ 'field' => $form_element,
+ 'id' => $id,
+ 'error' => '',
+ 'type' => $custom_fields->cache_data[ $id ]['pf_type']
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // If Nexus is installed, also add billing information
+ //-----------------------------------------
+
+ $nexusFields = array();
+ $nexusStates = array();
+ if( IPSLib::appIsInstalled('nexus') AND $this->settings['nexus_reg_show'] AND $this->settings['nexus_store_online'] )
+ {
+ ipsRegistry::getClass('class_localization')->loadLanguageFile( array( 'public_countries' ), 'nexus' );
+
+ $fields = array();
+ $_fields = ipsRegistry::cache()->getCache('customer_fields');
+
+ if( is_array($_fields) AND count($_fields) )
+ {
+ foreach ( $_fields['reg'] as $k )
+ {
+ $nexusFields[] = $_fields['fields'][ $k ];
+ }
+ }
+
+ $nexusStates = customer::generateStateDropdown( TRUE );
+ }
+
+ //-----------------------------------------
+ // Got errors to show?
+ //-----------------------------------------
+
+ $final_errors = array( 'dname' => NULL, 'password' => NULL, 'email' => NULL, 'tos' => NULL );
+
+ foreach( array( 'dname', 'password', 'email', 'tos' ) as $thing )
+ {
+ if ( isset($form_errors[ $thing ]) AND is_array( $form_errors[ $thing ] ) AND count( $form_errors[ $thing ] ) )
+ {
+ $final_errors[ $thing ] = implode( " ", $form_errors[ $thing ] );
+ }
+ }
+
+ $this->request['PassWord'] = $this->request['PassWord'] ? $this->request['PassWord'] : '' ;
+ $this->request['EmailAddress'] = $this->request['EmailAddress'] ? $this->request['EmailAddress'] : '' ;
+ $this->request['EmailAddress_two'] = $this->request['EmailAddress_two'] ? $this->request['EmailAddress_two'] : '' ;
+ $this->request['PassWord_Check'] = $this->request['PassWord_Check'] ? $this->request['PassWord_Check'] : '' ;
+ $this->request['members_display_name'] = $this->request['members_display_name'] ? $this->request['members_display_name'] : '' ;
+ $this->request['time_offset'] = $this->request['time_offset'] ? $this->request['time_offset'] : '' ;
+
+ //-----------------------------------------
+ // Create time zone dropdown array
+ //-----------------------------------------
+
+ $this->registry->class_localization->loadLanguageFile( array( 'public_usercp' ), 'core' );
+
+ $time_select = array();
+
+ foreach( $this->lang->words as $k => $v )
+ {
+ if( strpos( $k, "time_" ) === 0 )
+ {
+ $k = str_replace( "time_", '', $k );
+
+ if( preg_match( '/^[\-\d\.]+$/', $k ) )
+ {
+ $time_select[ $k ] = $v;
+ }
+ }
+ }
+
+ ksort( $time_select );
+
+ $this->request['time_offset'] = ( $this->request['time_offset'] ) ? $this->request['time_offset'] : $this->settings['time_offset'];
+
+ //-----------------------------------------
+ // Start output
+ //-----------------------------------------
+
+ $this->output .= $this->registry->output->getTemplate('register')->registerForm(
+ $form_errors['general'],
+ array(
+ 'TEXT' => $this->lang->words['std_text'],
+ 'coppa_user' => $coppa,
+ 'captchaHTML' => $captchaHTML,
+ 'qandaHTML' => $qandaHTML,
+ 'showCOPPA' => $this->settings['use_coppa'] AND !(IPSLib::appIsInstalled('nexus') AND $this->settings['nexus_reg_show'] AND $this->settings['nexus_store_online']),
+ ),
+ $final_errors,
+ $time_select,
+ $custom_fields_out,
+ $nexusFields,
+ $nexusStates );
+
+ //-----------------------------------------
+ // Member sync module
+ //-----------------------------------------
+
+ IPSLib::runMemberSync( 'onRegisterForm' );
+ }
+
+ /**
+ * Save the data to complete the partial member record login/registration
+ *
+ * @return @e void [Outputs to screen/redirects]
+ */
+ public function _completeRegistrationSave()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $mid = intval( $this->request['mid'] );
+ $key = intval( $this->request['key'] );
+ $form_errors = array( 'dname' => array(), 'email' => array(), 'general' => array() );
+ $members_display_name = trim( $this->request['members_display_name'] );
+ $poss_session_id = "";
+ $login_user = trim( $this->request['login_user'] );
+ $login_pass = trim( $this->request['login_pass'] );
+ $connectService = trim( strtolower( $this->request['connectService'] ) );
+
+ //-----------------------------------------
+ // Get DB row
+ //-----------------------------------------
+
+ $reg = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'members_partial', 'where' => "partial_member_id={$mid} AND partial_date={$key}" ) );
+ $tmp_member = IPSMember::load( $mid );
+
+ //-----------------------------------------
+ // Got it?
+ //-----------------------------------------
+
+ if ( ! $reg['partial_id'] OR ! $tmp_member['member_id'] )
+ {
+ $this->registry->output->showError( 'partial_reg_noid', 10117 );
+ }
+
+ //-----------------------------------------
+ // Set up email
+ //-----------------------------------------
+
+ $in_email = ( $this->request['EmailAddress'] ) ? strtolower( trim($this->request['EmailAddress']) ) : $tmp_member['email'];
+
+ //-----------------------------------------
+ // Load log in handler...
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $han_login = new $classToLoad( $this->registry );
+ $han_login->init();
+
+ //-----------------------------------------
+ // Custom profile field stuff
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
+ $custom_fields = new $classToLoad();
+
+ $custom_fields->initData( 'edit' );
+ $custom_fields->parseToSave( $this->request, 'register' );
+
+ /* Check */
+ if( $custom_fields->error_messages )
+ {
+ $form_errors['general'] = $custom_fields->error_messages;
+ }
+
+ /* Check the website url field */
+ $website_field = $custom_fields->getFieldIDByKey( 'website' );
+
+ if( $website_field && $custom_fields->out_fields[ 'field_' . $website_field ] )
+ {
+ if( stristr( $custom_fields->out_fields[ 'field_' . $website_field ], 'http://' ) === FALSE && stristr( $custom_fields->out_fields[ 'field_' . $website_field ], 'https://' ) === FALSE )
+ {
+ $custom_fields->out_fields[ 'field_' . $website_field ] = 'http://' . $custom_fields->out_fields[ 'field_' . $website_field ];
+ }
+ }
+
+ /* Are we trying to connect to an existing account */
+ if ( $connectService AND $login_user AND $login_pass AND ( $this->settings['fb_realname'] == 'enforced' OR ! $members_display_name ) )
+ {
+ /* Load Full Member */
+ $member = IPSMember::load( $mid, 'all' );
+
+ /* Force email check */
+ $han_login->setForceEmailCheck( TRUE );
+
+ /* Now attempt to authorize member */
+ $return = $han_login->loginPasswordCheck( $login_user, $login_user, $login_pass );
+
+ if ( $return !== TRUE )
+ {
+ /* Wrong email/password */
+ $form_errors['serviceLogIn'][] = $this->lang->words['connect_incorrect_details'];
+ }
+ else
+ {
+ /* Fetch data returned based on email address */
+ $logInMember = $han_login->member_data;
+
+ /* We're A-OK so allow service module to clean up member accounts, then log us the heck in! */
+ if ( $connectService == 'facebook' AND $member['fb_uid'] )
+ {
+ /* Already FBd? */
+ if ( $logInMember['fb_uid'] AND ( $member['fb_uid'] != $logInMember['fb_uid'] ) )
+ {
+ /* User already has facebook link */
+ $form_errors['serviceLogIn'][] = sprintf( $this->lang->words['connect_already_linked'], $login_user, ucfirst( $connectService ) );
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
+ $facebook = new $classToLoad( $this->registry, $member['fb_token'], $member['fb_uid'] );
+
+ if ( $facebook->finishNewConnection( $logInMember['member_id'], $member['member_id'] ) !== true )
+ {
+ /* Unknown error */
+ $form_errors['serviceLogIn'][] = $this->lang->words['connect_unknown'];
+ }
+ }
+ else if ( $connectService == 'twitter' AND $member['twitter_id'] )
+ {
+ /* Already Twitterd? */
+ if ( $logInMember['twitter_id'] AND ( $member['twitter_id'] != $logInMember['twitter_id'] ) )
+ {
+ /* User already has facebook link */
+ $form_errors['serviceLogIn'][] = sprintf( $this->lang->words['connect_already_linked'], $login_user, ucfirst( $connectService ) );
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
+ $twitter = new $classToLoad( $this->registry, $member['twitter_token'], $member['twitter_secret'] );
+
+ if ( $twitter->finishNewConnection( $logInMember['member_id'], $member['member_id'] ) !== true )
+ {
+ /* Unknown error */
+ $form_errors['serviceLogIn'][] = $this->lang->words['connect_unknown'];
+ }
+ }
+ else if ( $connectService == 'vkontakte' AND $member['vk_uid'] )
+ {
+ /* Already VKd? */
+ if ( $logInMember['vk_uid'] AND ( $member['vk_uid'] != $logInMember['vk_uid'] ) )
+ {
+ /* User already has vkontakte link */
+ $form_errors['serviceLogIn'][] = sprintf( $this->lang->words['connect_already_linked'], $login_user, ucfirst( $connectService ) );
+ }
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/vkontakte/connect.php', 'vkontakte_connect' );
+ $vk = new $classToLoad( $this->registry, $key );
+
+ if ( $vk->finishNewConnection( $logInMember['member_id'], $member['member_id'] ) !== true )
+ {
+ /* Unknown error */
+ $form_errors['serviceLogIn'][] = $this->lang->words['connect_unknown'];
+ }
+ }
+
+ /* Ok to proceed? */
+ if ( ! count( $form_errors['serviceLogIn'] ) )
+ {
+ IPSMember::remove( $member['member_id'] );
+
+ /* Here, so log us in!! */
+ $r = $han_login->loginWithoutCheckingCredentials( $logInMember['member_id'], TRUE );
+
+ /* Boing */
+ if ( is_array( $r ) )
+ {
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url'] . 'app=core&module=usercp§ion=register&tab=core&area=' . $connectService );
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------
+ // Remove 'sneaky' spaces
+ //-----------------------------------------
+
+ if ( $this->settings['strip_space_chr'] )
+ {
+ $members_display_name = IPSText::removeControlCharacters( $members_display_name );
+ }
+
+ //-----------------------------------------
+ // Testing email addresses?
+ //-----------------------------------------
+
+ if ( ! $reg['partial_email_ok'] AND $in_email )
+ {
+ //-----------------------------------------
+ // Check the email address
+ //-----------------------------------------
+
+ if( ! IPSText::checkEmailAddress( $in_email ) )
+ {
+ $form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
+ }
+
+ //-----------------------------------------
+ // Test email address
+ //-----------------------------------------
+
+ $this->request['EmailAddress_two'] = strtolower( trim($this->request['EmailAddress_two']) );
+
+ if ( $in_email AND ( $this->request['EmailAddress_two'] != $in_email ) )
+ {
+ $form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
+ }
+
+ /* Is this email banned or does it exist already? */
+ if ( IPSMember::isBanned( 'email', $in_email ) || IPSMember::checkByEmail( $in_email ) || $han_login->emailExistsCheck( trim(strtolower($in_email)) ) )
+ {
+ $form_errors['email'][] = $this->lang->words['reg_error_email_taken'];
+ }
+ }
+ else if ( ! $reg['partial_email_ok'] AND ! $in_email AND ! $login_user )
+ {
+ $form_errors['email'][] = $this->lang->words['reg_error_email_nm'];
+ }
+
+ if ( $this->settings['auth_allow_dnames'] )
+ {
+ /* Check the username */
+ $user_check = IPSMember::getFunction()->cleanAndCheckName( $members_display_name, $tmp_member, 'members_display_name' );
+
+ if( is_array( $user_check['errors'] ) && count( $user_check['errors'] ) )
+ {
+ $form_errors['dname'][] = isset($this->lang->words[ $user_check['errors']['dname'] ]) ? $this->lang->words[ $user_check['errors']['dname'] ] : $user_check['errors']['dname'];
+ }
+ }
+
+ //-----------------------------------------
+ // CHECK 1: Any errors (duplicate names, etc)?
+ //-----------------------------------------
+
+ if ( count( $form_errors ) )
+ {
+ $errorMessages = array();
+
+ foreach( $form_errors as $errorCat => $errorMessage )
+ {
+ foreach( $errorMessage as $error )
+ {
+ $errorMessages['general'][] = $error;
+ }
+ }
+
+ if( count($errorMessages) )
+ {
+ $this->_completeRegistration( $errorMessages );
+ return;
+ }
+ }
+
+ //-----------------------------------------
+ // Update: Members
+ //-----------------------------------------
+
+ $members_display_name = $this->settings['auth_allow_dnames'] ? $members_display_name : $tmp_member['name'];
+ $member_group_id = ( $tmp_member['twitter_token'] AND $tmp_member['member_group_id'] == $this->settings['auth_group']) ? $this->settings['member_group'] : $tmp_member['member_group_id'];
+
+ if ( ! $reg['partial_email_ok'] )
+ {
+ IPSMember::save( $mid, array( 'members' => array(
+ 'email' => $in_email,
+ 'members_display_name' => $members_display_name,
+ 'members_seo_name' => IPSText::makeSeoTitle( $members_display_name ),
+ 'name' => $tmp_member['name'] ? $tmp_member['name'] : $members_display_name,
+ 'members_l_username' => $tmp_member['members_l_username'] ? $tmp_member['members_l_username'] : $members_display_name,
+ 'member_group_id' => $member_group_id,
+ 'members_l_display_name' => strtolower( $members_display_name )
+ ) ) );
+ }
+ else
+ {
+ IPSMember::save( $mid, array( 'members' => array(
+ 'members_display_name' => $members_display_name,
+ 'members_seo_name' => IPSText::makeSeoTitle( $members_display_name ),
+ 'name' => $tmp_member['name'] ? $tmp_member['name'] : $members_display_name,
+ 'members_l_username' => $tmp_member['members_l_username'] ? $tmp_member['members_l_username'] : $members_display_name,
+ 'member_group_id' => $member_group_id,
+ 'members_l_display_name' => mb_strtolower( $members_display_name )
+ ) ) );
+ }
+
+ //-----------------------------------------
+ // Delete: Partials row
+ //-----------------------------------------
+
+ $this->DB->delete( 'members_partial', 'partial_member_id=' . $mid );
+
+ //-----------------------------------------
+ // Update: Profile fields
+ //-----------------------------------------
+
+ $this->DB->resetDataTypes();
+ $this->DB->setDataType( array_keys( $custom_fields->out_fields ), 'string' );
+
+ if ( is_array($custom_fields->out_fields) and count($custom_fields->out_fields) )
+ {
+ $this->DB->update( 'pfields_content', $custom_fields->out_fields, 'member_id=' . $mid );
+ }
+
+ //-----------------------------------------
+ // Pass twitter/facebook via spam service
+ //-----------------------------------------
+
+ if ( $connectService AND ! $login_user AND $this->settings['spam_service_enabled'] )
+ {
+ /* Load all member data */
+ $member = IPSMember::load( $mid, 'all' );
+
+ /* Spam Service */
+ $spamCode = 0;
+ $_spamFlag = 0;
+
+ /* Query the service */
+ $spamCode = IPSMember::querySpamService( $member['email'] );
+
+ /* Action to perform */
+ $action = $this->settings[ 'spam_service_action_' . $spamCode ];
+
+ /* Perform Action */
+ switch( $action )
+ {
+ /* Proceed with registration */
+ case 1:
+ break;
+
+ /* Flag for admin approval */
+ case 2:
+ $member['member_group_id'] = $this->settings['auth_group'];
+ $this->settings['reg_auth_type'] = 'admin';
+ $_spamFlag = 1;
+ break;
+
+ /* Approve the account, but ban it */
+ case 3:
+ $member['member_banned'] = 1;
+ $member['bw_is_spammer'] = 1;
+ $this->settings['reg_auth_type'] = '';
+ break;
+ /* Deny registration */
+ case 4:
+ $this->registry->output->showError( 'spam_denied_account', '100x001', FALSE, '', 200 );
+ break;
+ }
+
+ /* Update member */
+ IPSMember::save( $member['member_id'], array( 'core' => array( 'member_group_id' => $member['member_group_id'],
+ 'member_banned' => intval( $member['member_banned'] ),
+ 'bw_is_spammer' => intval( $member['bw_is_spammer'] ) ) ) );
+
+ /* Did we put them in validating? */
+ if ( $_spamFlag )
+ {
+ $validate_key = md5( IPSMember::makePassword() . time() );
+ $time = time();
+
+ $this->DB->insert( 'validating', array( 'vid' => $validate_key,
+ 'member_id' => $member['member_id'],
+ 'real_group' => $this->settings['member_group'],
+ 'temp_group' => $this->settings['auth_group'],
+ 'entry_date' => $time,
+ 'coppa_user' => 0,
+ 'new_reg' => 1,
+ 'ip_address' => $member['ip_address'],
+ 'spam_flag' => $_spamFlag ) );
+
+ $this->output = $this->registry->output->getTemplate('register')->showPreview( $member );
+ return; #Goes back to doExecute which sends $this->output to output class
+ }
+ }
+
+ /* Send out notification */
+ if ( $this->settings['new_reg_notify'] )
+ {
+ $date = $this->registry->getClass('class_localization')->getDate( time(), 'LONG', 1 );
+
+ IPSText::getTextClass('email')->getTemplate("admin_newuser");
+
+ IPSText::getTextClass('email')->buildMessage( array( 'DATE' => $date,
+ 'LOG_IN_NAME' => $tmp_member['name'] ? $tmp_member['name'] : $members_display_name,
+ 'EMAIL' => $in_email,
+ 'IP' => $tmp_member['ip_address'],
+ 'DISPLAY_NAME' => $members_display_name ) );
+
+ IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email'], $this->settings['board_name'] );
+ IPSText::getTextClass('email')->to = $this->settings['email_in'];
+ IPSText::getTextClass('email')->sendMail();
+ }
+
+ //-----------------------------------------
+ // Update Stats
+ //-----------------------------------------
+
+ $cache = $this->cache->getCache('stats');
+
+ if( $members_display_name AND $mid )
+ {
+ $cache['last_mem_name'] = $members_display_name;
+ $cache['last_mem_name_seo'] = IPSText::makeSeoTitle( $members_display_name );
+ $cache['last_mem_id'] = $mid;
+ }
+
+ $cache['mem_count'] += 1;
+
+ $this->cache->setCache( 'stats', $cache, array( 'array' => 1 ) );
+
+ /* Complete account */
+ $memberData = IPSMember::load( $mid );
+
+ IPSLib::runMemberSync( 'onCompleteAccount', $memberData );
+
+ /* Got admin validation enabled? */
+ if ( $connectService && ! $login_user && in_array( $this->settings['reg_auth_type'], array( 'admin', 'admin_user' ) ) )
+ {
+ /* Make them validating */
+ IPSMember::save( $member['member_id'], array( 'core' => array( 'member_group_id' => $this->settings['auth_group'] ) ) );
+
+ //-----------------------------------------
+ // We want to validate all reg's via email,
+ // after email verificiation has taken place,
+ // we restore their previous group and remove the validate_key
+ //-----------------------------------------
+
+ $this->DB->insert( 'validating', array( 'vid' => $validate_key,
+ 'member_id' => $member['member_id'],
+ 'real_group' => $this->settings['member_group'],
+ 'temp_group' => $this->settings['auth_group'],
+ 'entry_date' => time(),
+ 'coppa_user' => 0,
+ 'new_reg' => 1,
+ 'ip_address' => $member['ip_address'],
+ 'spam_flag' => $_spamFlag ) );
+
+ $this->output = $this->registry->output->getTemplate('register')->showPreview( IPSMember::load( $member['member_id'] ) );
+ return;
+ }
+
+ //-----------------------------------------
+ // Set cookies
+ //-----------------------------------------
+
+ IPSCookie::set("member_id" , $mid , 1 );
+ IPSCookie::set("pass_hash" , $tmp_member['member_login_key'] , 1 );
+
+ //-----------------------------------------
+ // Fix up session
+ //-----------------------------------------
+
+ $privacy = ( $this->caches['group_cache'][ $tmp_member['member_group_id'] ]['g_hide_online_list'] || ( empty($this->settings['disable_anonymous']) && ! empty($this->request['Privacy']) ) ) ? 1 : 0;
+
+ $this->member->sessionClass()->convertGuestToMember( array( 'member_name' => $members_display_name,
+ 'member_id' => $mid,
+ 'member_group' => $tmp_member['member_group_id'],
+ 'login_type' => $privacy ) );
+
+ IPSLib::runMemberSync( 'onLogin', $memberData );
+
+ //-----------------------------------------
+ // Go to the board index
+ //-----------------------------------------
+
+ $this->registry->output->redirectScreen( $this->lang->words['clogin_done'], $this->settings['base_url'] );
+ }
+
+ /**
+ * When a member logs in via an external login method and we do not have all of the data
+ * to create the member's account, we create a partial record. This function shows the
+ * form upon first visit by member (usually immediately after login) to complete the
+ * login/registration.
+ *
+ * @param array Errors
+ * @return @e void [Outputs to screen/redirects]
+ */
+ protected function _completeRegistration( $form_errors=array() )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $mid = intval( $this->request['mid'] );
+ $key = intval( $this->request['key'] );
+ $final_errors = '';
+
+ //-----------------------------------------
+ // Get DB row
+ //-----------------------------------------
+
+ $reg = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'members_partial',
+ 'where' => "partial_member_id={$mid} AND partial_date={$key}" ) );
+
+ //-----------------------------------------
+ // Got it?
+ //-----------------------------------------
+
+ if ( ! $reg['partial_id'] )
+ {
+ $this->registry->output->showError( 'partial_reg_noid', 10118 );
+ }
+
+ /* Load Full Member */
+ $member = IPSMember::load( $mid, 'all' );
+
+ /* Twitter or Facebook? */
+ if ( $member['fb_uid'] AND $member['fb_token'] )
+ {
+ /* Attempt to fetch user details */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/facebook/connect.php', 'facebook_connect' );
+ $facebook = new $classToLoad( $this->registry, $member['fb_token'], $member['fb_uid'] );
+
+ $userData = $facebook->fetchUserData();
+
+ if ( $userData['id'] )
+ {
+ $userData['service'] = 'facebook';
+ $userData['_name'] = $userData['name'];
+ $userData['_pic'] = $userData['pic_square'];
+ $userData['_sImage'] = $this->settings['public_dir'] . 'style_status/facebook.png';
+
+ /* Enforcing / allowing real names? */
+ if ( ! count( $form_errors['dname'] ) AND $this->settings['fb_realname'] != 'any' )
+ {
+ $userData['_displayName'] = $userData['_name'];
+
+ /* Now, make sure we have a unique display name */
+ $max = $this->DB->buildAndFetch( array( 'select' => 'MAX(member_id) as max',
+ 'from' => 'members',
+ 'where' => "members_l_display_name LIKE '" . $this->DB->addSlashes( mb_strtolower( $userData['_displayName'] ) ) . "%'" ) );
+
+ if ( $max['max'] )
+ {
+ /* does the username already have it set? */
+ if ( stristr( $member['name'], $userData['_displayName'] ) )
+ {
+ $userData['_displayName'] = $member['name'];
+ }
+ else
+ {
+ $_num = $max['max'] + 1;
+ $userData['_displayName'] = $userData['_displayName'] . '_' . $_num;
+ }
+ }
+ }
+ }
+ }
+ else if ( $member['twitter_id'] AND $member['twitter_token'] AND $member['twitter_secret'] )
+ {
+ /* Attempt to fetch user details */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/twitter/connect.php', 'twitter_connect' );
+ $twitter = new $classToLoad( $this->registry, $member['twitter_token'], $member['twitter_secret'] );
+
+ $userData = $twitter->fetchUserData();
+
+ if ( $userData['id'] )
+ {
+ $userData['service'] = 'twitter';
+ $userData['_name'] = $userData['screen_name'];
+ $userData['_pic'] = $userData['profile_image_url'];
+ $userData['_sImage'] = $this->settings['public_dir'] . 'style_status/twitter.png';
+ }
+ }
+ else if ( $member['vk_uid'] AND $member['vk_token'] )
+ {
+ /* Attempt to fetch user details */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/vkontakte/connect.php', 'vkontakte_connect' );
+ $vk = new $classToLoad( $this->registry, $member['vk_token'], $member['vk_uid'] );
+
+ $userData = $vk->fetchUserData();
+
+ if ( $userData['uid'] )
+ {
+ $userData['service'] = 'vkontakte';
+ $userData['_name'] = $userData['first_name'] . ' ' . $userData['last_name'];
+ $userData['_pic'] = $userData['photo'];
+ $userData['_sImage'] = $this->settings['public_dir'] . 'style_status/vkontakte.png';
+ }
+ }
+ else
+ {
+ /* Set defaults for any we have */
+ $this->request['members_display_name'] = !empty($this->request['members_display_name']) ? $this->request['members_display_name'] : $member['members_display_name'];
+ $this->request['EmailAddress'] = !empty($this->request['EmailAddress']) ? $this->request['EmailAddress'] : ( ( substr( $member['email'], 0, 1 ) === '@' ? '' : $member['email'] ) );
+ $this->request['EmailAddress_two'] = !empty($this->request['EmailAddress_two']) ? $this->request['EmailAddress_two'] : ( ( substr( $member['email'], 0, 1 ) === '@' ? '' : $member['email'] ) );
+
+ // http://community.invisionpower.com/resources/bugs.html/_/ip-board/partial-registrations-from-windows-live-possibly-others-r41100
+ if ( substr( $in_email, 0, 1 ) === '@' )
+ {
+ $in_email = '';
+ }
+ }
+
+ /* Remote registrations disabled? */
+ if ( $this->settings['no_reg'] == 2 )
+ {
+ /* Clean up incomplete reg */
+ if ( $reg['partial_member_id'] )
+ {
+ IPSMember::remove( array( $reg['partial_member_id'] ) );
+ }
+
+ $this->registry->output->showError( 'no_remote_reg', 1090001 );
+ }
+
+ //-----------------------------------------
+ // Custom profile fields stuff
+ //-----------------------------------------
+
+ $custom_fields_out = array( 'required', 'optional' );
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
+ $custom_fields = new $classToLoad();
+
+ $custom_fields->member_data = array();
+ $custom_fields->initData( 'edit' );
+ $custom_fields->parseToEdit( 'register' );
+
+ if ( count( $custom_fields->out_fields ) )
+ {
+ foreach( $custom_fields->out_fields as $id => $form_element )
+ {
+ if ( $custom_fields->cache_data[ $id ]['pf_not_null'] == 1 )
+ {
+ $ftype = 'required';
+ }
+ else
+ {
+ $ftype = 'optional';
+ }
+
+ $custom_fields_out[$ftype][] = array(
+ 'name' => $custom_fields->field_names[ $id ],
+ 'desc' => $custom_fields->field_desc[ $id ],
+ 'field' => $form_element,
+ 'id' => $id,
+ 'error' => '',
+ 'type' => $custom_fields->cache_data[ $id ]['pf_type']
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Other errors
+ //-----------------------------------------
+
+ foreach( array( 'dname', 'password', 'email', 'general', 'serviceLogIn' ) as $thing )
+ {
+ if ( is_array( $form_errors[ $thing ] ) AND count( $form_errors[ $thing ] ) )
+ {
+ $final_errors .= implode( " ", $form_errors[ $thing ] );
+ }
+ }
+
+ //-----------------------------------------
+ // No display name?
+ //-----------------------------------------
+
+ if ( ! $this->memberData['members_display_name'] )
+ {
+ $this->memberData['members_display_name'] = ( $member['members_display_name'] ) ? $member['members_display_name'] : $member['email'];
+ }
+
+ //-----------------------------------------
+ // Show the form (email and display name)
+ //-----------------------------------------
+
+ $this->output .= $this->registry->getClass('output')->getTemplate('register')->completePartialLogin( $mid, $key, $custom_fields_out, $final_errors, $reg, $userData );
+
+ $this->registry->output->setTitle( $this->lang->words['clogin_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->addNavigation( $this->lang->words['clogin_title'], '' );
+ }
+
+ /**
+ * Show the form to request validation email to be resent
+ *
+ * @param string Errors
+ * @return @e void [Outputs to screen/redirects]
+ */
+ protected function _revalidateForm( $errors="" )
+ {
+ $uses_name = false;
+ $uses_email = false;
+
+ foreach( $this->cache->getCache('login_methods') as $method )
+ {
+ if( $method['login_user_id'] == 'username' )
+ {
+ $uses_name = true;
+ }
+
+ if( $method['login_user_id'] == 'email' )
+ {
+ $uses_email = true;
+ }
+ }
+
+ if( $uses_name AND $uses_email )
+ {
+ $name = $this->memberData['member_id'] == "" ? '' : $this->memberData['name'];
+ $this->lang->words['rv_ins'] = $this->lang->words['rv_ins_both'];
+ }
+ else if( $uses_email )
+ {
+ $name = $this->memberData['member_id'] == "" ? '' : $this->memberData['email'];
+ $this->lang->words['rv_ins'] = $this->lang->words['rv_ins_email'];
+ }
+ else
+ {
+ $name = $this->memberData['member_id'] == "" ? '' : $this->memberData['name'];
+ $this->lang->words['rv_ins'] = $this->lang->words['rv_ins_name'];
+ }
+
+ $this->output .= $this->registry->getClass('output')->getTemplate('register')->showRevalidateForm( $name, $errors );
+ $this->registry->output->setTitle( $this->lang->words['rv_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->addNavigation( $this->lang->words['rv_title'], '' );
+ }
+
+ /**
+ * Resend email validation request for lost password, email change and new registration
+ *
+ * @return @e void [Outputs to screen/redirects]
+ */
+ protected function _revalidateComplete()
+ {
+ //-----------------------------------------
+ // Check in the DB for entered member name
+ //-----------------------------------------
+
+ if ( $this->request['username'] == "" )
+ {
+ $this->_revalidateForm('err_no_username');
+ return;
+ }
+
+ $username = $this->request['username'];
+ $keyType = IPSText::checkEmailAddress( $this->request['username'] ) ? 'email' : 'username';
+
+ $member = IPSMember::load( $username, 'extendedProfile', $keyType );
+
+ if ( ! $member['member_id'] )
+ {
+ /**
+ * Try the other key type just to be safe...
+ */
+ $member = IPSMember::load( $username, 'extendedProfile', $keyType == 'email' ? 'username' : 'email' );
+
+ if ( ! $member['member_id'] )
+ {
+ $this->_revalidateForm('err_no_username');
+ return;
+ }
+ }
+
+ //-----------------------------------------
+ // Check in the DB for any validations
+ //-----------------------------------------
+
+ $val = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => "member_id=" . intval($member['member_id']) ) );
+
+ if ( empty($val['vid']) )
+ {
+ $this->_revalidateForm('err_no_validations');
+ return;
+ }
+
+ //-----------------------------------------
+ // Which type is it then?
+ //-----------------------------------------
+
+ if ( $val['lost_pass'] == 1 )
+ {
+ IPSText::getTextClass('email')->getTemplate("lost_pass", $member['language']);
+
+ IPSText::getTextClass('email')->buildMessage( array(
+ 'NAME' => $member['members_display_name'],
+ 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=lostpass&do=sendform&uid=" . $member['member_id'] . "&aid=" . $val['vid'], 'publicNoSession', 'false'),
+ 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=lostpass&do=sendform", 'publicNoSession', 'false'),
+ 'EMAIL' => $member['email'],
+ 'ID' => $member['member_id'],
+ 'CODE' => $val['vid'],
+ 'IP_ADDRESS' => $this->member->ip_address,
+ )
+ );
+
+ IPSText::getTextClass('email')->subject = $this->lang->words['lp_subject'].' '.$this->settings['board_name'];
+ IPSText::getTextClass('email')->to = $member['email'];
+
+ IPSText::getTextClass('email')->sendMail();
+ }
+ else if ( $val['new_reg'] == 1 )
+ {
+ IPSText::getTextClass('email')->getTemplate( "reg_validate", $member['language'] );
+
+ IPSText::getTextClass('email')->buildMessage( array(
+ 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl( "app=core&module=global§ion=register&do=auto_validate&uid=" . $member['member_id'] . "&aid=" . $val['vid'], 'publicNoSession', 'false'),
+ 'NAME' => $member['members_display_name'],
+ 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=05", 'publicNoSession', 'false'),
+ 'EMAIL' => $member['email'],
+ 'ID' => $member['member_id'],
+ 'CODE' => $val['vid'],
+ )
+ );
+
+ IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['email_reg_subj'], $this->settings['board_name'] );
+ IPSText::getTextClass('email')->to = $member['email'];
+
+ IPSText::getTextClass('email')->sendMail();
+ }
+ else if ( $val['email_chg'] == 1 )
+ {
+ IPSText::getTextClass('email')->getTemplate("newemail");
+
+ IPSText::getTextClass('email')->buildMessage( array(
+ 'NAME' => $member['members_display_name'],
+ 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=auto_validate&type=newemail&uid=" . $member['member_id'] . "&aid=" . $val['vid'], 'publicNoSession', 'false'),
+ 'ID' => $member['member_id'],
+ 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=07", 'publicNoSession', 'false'),
+ 'CODE' => $val['vid'],
+ )
+ );
+
+ IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['ne_subject'], $this->settings['board_name'] );
+ IPSText::getTextClass('email')->to = $member['email'];
+
+ IPSText::getTextClass('email')->sendMail();
+ }
+ else
+ {
+ $this->_revalidateForm('err_no_validations');
+ return;
+ }
+
+ $this->output .= $this->registry->getClass('output')->getTemplate('register')->showRevalidated();
+
+ $this->registry->output->setTitle( $this->lang->words['rv_title'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->addNavigation( $this->lang->words['rv_title'], '' );
+ }
+
+ /**
+ * Show the form to manually enter in validation info if auto-validation failed.
+ *
+ * @param string Type of validation
+ * @param string Error messages
+ * @return @e void [Outputs to screen/redirects]
+ */
+ protected function _showManualForm($type='reg', $errors="")
+ {
+ //-----------------------------------------
+ // In IPB3 this is handled by another section
+ // If somehow a request comes in, send to correct location
+ //-----------------------------------------
+
+ if ( $type == 'lostpass' )
+ {
+ $this->registry->output->silentRedirect( $this->settings['base_url'] . 'app=core&module=global§ion=lostpass&do=sendform&uid=' . $this->request['uid'] . '&aid=' . $this->request['aid'] );
+ }
+ else
+ {
+ $this->output = $this->registry->getClass('output')->getTemplate('register')->showManualForm( $type );
+ }
+
+ $this->registry->output->setTitle( $this->lang->words['activation_form'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->addNavigation( $this->lang->words['activation_form'], '' );
+ }
+
+
+ /**
+ * Show coppa form. This is the downloadable/printable form, and as such is just printed to the browser directly
+ *
+ * @return @e void
+ */
+ protected function registerCoppaPermsForm()
+ {
+ /* Keith said to strip these out - it's all his fault :( */
+ $this->settings['coppa_address'] = str_replace( array( ' ', ' ' ), '', $this->settings['coppa_address'] );
+ $this->settings['coppa_address'] = nl2br( $this->settings['coppa_address'] );
+
+ echo( $this->registry->output->getTemplate('register')->registerCoppaForm() );
+ exit();
+ }
+
+ /**
+ * This is the second page a COPPA submission hits. Really, user hits this page and if birthday is older than 13
+ * we just continue with registration form. Otherwise we show the coppa validation required message with link
+ * to download/print coppa compliance sheet for parents to fill in.
+ *
+ * @return @e void
+ */
+ protected function registerCoppaTwo()
+ {
+ if( $this->request['coppa'] == 1 )
+ {
+ IPSCookie::set( 'coppa', 'no', 0, 1 );
+ $this->registerForm();
+ return;
+ }
+
+ IPSCookie::set( 'coppa', 'yes', 0, 1 );
+
+ $this->lang->words['coppa_form_text'] = str_replace( "<#FORM_LINK#>", "" . $this->lang->words['coppa_link_form'] . " ", $this->lang->words['coppa_form_text']);
+
+ $this->output .= $this->registry->output->getTemplate('register')->registerCoppaTwo();
+
+ $this->registry->output->setTitle( $this->lang->words['coppa_title'] . ' - ' . ipsRegistry::$settings['board_name']);
+ $this->registry->output->addNavigation( $this->lang->words['coppa_title'], '' );
+ }
+
+ /**
+ * Validation completion. This is the action hit when a user clicks a validation link from their email for
+ * lost password, email change and new registration.
+ *
+ * @return @e void
+ */
+ protected function _autoValidate()
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $in_user_id = intval(trim(urldecode($this->request['uid'])));
+ $in_validate_key = substr( IPSText::alphanumericalClean( urldecode( $this->request['aid'] ) ), 0, 32 );
+ $in_type = trim($this->request['type']);
+ $in_type = $in_type ? $in_type : 'reg';
+
+ //-----------------------------------------
+ // Attempt to get the profile of the requesting user
+ //-----------------------------------------
+
+ $member = IPSMember::load( $in_user_id, 'members' );
+
+ if ( ! $member['member_id'] )
+ {
+ $this->_showManualForm( $in_type, 'reg_error_validate' );
+ return;
+ }
+
+ //-----------------------------------------
+ // Get validating info..
+ //-----------------------------------------
+
+ if ( $in_type == 'lostpass' )
+ {
+ $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . " AND lost_pass=1" ) );
+ }
+ else if ( $in_type == 'newemail' )
+ {
+ $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id . " AND email_chg=1" ) );
+ }
+ else
+ {
+ $validate = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'validating', 'where' => 'member_id=' . $in_user_id ) );
+ }
+
+ //-----------------------------------------
+ // Checks...
+ //-----------------------------------------
+
+ if ( ! $validate['member_id'] )
+ {
+ $this->registry->output->showError( 'no_validate_key', 10120 );
+ }
+
+ //-----------------------------------------
+ // Changed to check if this is an admin flagged
+ // account for a spam user too
+ //-----------------------------------------
+
+ if ( ( $validate['new_reg'] == 1 ) && (($this->settings['reg_auth_type'] == "admin" ) || $validate['spam_flag']) )
+ {
+ $this->registry->output->showError( 'validate_admin_turn', 10121 );
+ }
+
+ if ( $validate['vid'] != $in_validate_key )
+ {
+ $this->registry->output->showError( 'validation_key_invalid', 10122 );
+ }
+
+ //-----------------------------------------
+ // Captcha (from posted form, not GET)
+ //-----------------------------------------
+
+ if ( $this->settings['use_captcha'] AND $this->request['uid'] )
+ {
+ if ( $this->registry->getClass('class_captcha')->validate( $this->request['captcha_unique_id'], $this->request['captcha_input'] ) !== TRUE )
+ {
+ $this->_showManualForm( $in_type, 'reg_error_anti_spam' );
+ return;
+ }
+ }
+ //-----------------------------------------
+ // REGISTER VALIDATE
+ //-----------------------------------------
+
+ if ( $validate['new_reg'] == 1 )
+ {
+ if( $member['member_group_id'] == $this->settings['auth_group'] )
+ {
+ if ( ! $validate['real_group'] )
+ {
+ $validate['real_group'] = $this->settings['member_group'];
+ }
+ else if( !isset( $this->caches['group_cache'][ $validate['real_group'] ] ) )
+ {
+ $validate['real_group'] = $this->settings['member_group'];
+ }
+ }
+
+ //-----------------------------------------
+ // SELF-VERIFICATION...
+ // 12.14.2009 Changed from != 'admin_user' to
+ // be more inclusive (just self-verification only)
+ //-----------------------------------------
+
+ if ( $this->settings['reg_auth_type'] == 'user' )
+ {
+ if( $member['member_group_id'] == $this->settings['auth_group'] )
+ {
+ IPSMember::save( $member['member_id'], array( 'members' => array( 'member_group_id' => $validate['real_group'] ) ) );
+ }
+
+ /* Reset newest member */
+ $stat_cache = $this->caches['stats'];
+
+ if( $member['members_display_name'] AND $member['member_id'] AND !$this->caches['group_cache'][ $validate['real_group'] ]['g_hide_online_list'] )
+ {
+ $stat_cache['last_mem_name'] = $member['members_display_name'];
+ $stat_cache['last_mem_name_seo'] = IPSText::makeSeoTitle( $member['members_display_name'] );
+ $stat_cache['last_mem_id'] = $member['member_id'];
+ }
+
+ $stat_cache['mem_count'] += 1;
+
+ $this->cache->setCache( 'stats', $stat_cache, array( 'array' => 1 ) );
+
+ //-----------------------------------------
+ // Remove "dead" validation
+ //-----------------------------------------
+
+ $this->DB->delete( 'validating', "vid='" . $validate['vid'] . "'" );
+
+ IPSLib::runMemberSync( 'onCompleteAccount', $member );
+
+ $this->registry->output->silentRedirect( $this->settings['base_url'] . '&app=core&module=global§ion=login&do=autologin&fromreg=1' );
+ }
+
+ //-----------------------------------------
+ // ADMIN-VERIFICATION...
+ //-----------------------------------------
+
+ else
+ {
+ //-----------------------------------------
+ // Update DB row...
+ //-----------------------------------------
+
+ $this->DB->update( 'validating', array( 'user_verified' => 1 ), 'vid=\'' . $validate['vid'] . '\'' );
+
+ //-----------------------------------------
+ // Print message
+ //-----------------------------------------
+
+ $this->registry->output->setTitle( $this->lang->words['validation_complete'] . ' - ' . ipsRegistry::$settings['board_name'] );
+
+ $this->output = $this->registry->getClass('output')->getTemplate('register')->showPreview( $member );
+ }
+ }
+
+ //-----------------------------------------
+ // LOST PASS VALIDATE
+ //-----------------------------------------
+
+ else if ( $validate['lost_pass'] == 1 )
+ {
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $save_array = array();
+
+ //-----------------------------------------
+ // Generate a new random password
+ //-----------------------------------------
+
+ $new_pass = IPSMember::makePassword();
+
+ //-----------------------------------------
+ // Generate a new salt
+ //-----------------------------------------
+
+ $salt = IPSMember::generatePasswordSalt(5);
+ $salt = str_replace( '\\', "\\\\", $salt );
+
+ //-----------------------------------------
+ // New log in key
+ //-----------------------------------------
+
+ $key = IPSMember::generateAutoLoginKey();
+
+ //-----------------------------------------
+ // Update...
+ //-----------------------------------------
+
+ $save_array['members_pass_salt'] = $salt;
+ $save_array['members_pass_hash'] = md5( md5($salt) . md5( $new_pass ) );
+ $save_array['member_login_key'] = $key;
+ $save_array['member_login_key_expire'] = $this->settings['login_key_expire'] * 60 * 60 * 24;
+
+ //-----------------------------------------
+ // Load handler...
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+ $this->han_login->changePass( $member['email'], md5( $new_pass ), $new_pass, $member );
+
+ if ( $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'SUCCESS' )
+ {
+ $this->registry->output->showError( 'lostpass_external_fail', 2015, true );
+ }
+
+ IPSMember::save( $member['member_id'], array( 'members' => $save_array ) );
+
+ //-----------------------------------------
+ // Send out the email...
+ //-----------------------------------------
+
+ IPSText::getTextClass('email')->getTemplate("lost_pass_email_pass", $member['language']);
+
+ IPSText::getTextClass('email')->buildMessage( array(
+ 'NAME' => $member['members_display_name'],
+ 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl('app=core&module=usercp&tab=core&area=email', 'publicNoSession', 'false'),
+ 'PASSWORD' => $new_pass,
+ 'LOGIN' => $this->registry->getClass('output')->buildSEOUrl('app=core&module=global§ion=login', 'publicNoSession', 'false'),
+ 'USERNAME' => $member['name'],
+ 'EMAIL' => $member['email'],
+ 'ID' => $member['member_id'],
+ )
+ );
+
+ IPSText::getTextClass('email')->subject = $this->lang->words['lp_random_pass_subject'] . ' ' . $this->settings['board_name'];
+ IPSText::getTextClass('email')->to = $member['email'];
+
+ IPSText::getTextClass('email')->sendMail();
+
+ $this->registry->output->setTitle( $this->lang->words['validation_complete'] . ' - ' . ipsRegistry::$settings['board_name'] );
+
+ //-----------------------------------------
+ // Remove "dead" validation
+ //-----------------------------------------
+
+ $this->DB->delete( 'validating', "vid='" . $validate['vid'] . "' OR (member_id={$member['member_id']} AND lost_pass=1)" );
+
+ $this->output = $this->registry->getClass('output')->getTemplate('register')->showLostPassWaitRandom( $member );
+ }
+
+ //-----------------------------------------
+ // EMAIL ADDY CHANGE
+ //-----------------------------------------
+
+ else if ( $validate['email_chg'] == 1 )
+ {
+ if ( !$validate['real_group'] )
+ {
+ $validate['real_group'] = $this->settings['member_group'];
+ }
+ else if( !isset( $this->caches['group_cache'][ $validate['real_group'] ] ) )
+ {
+ $validate['real_group'] = $this->settings['member_group'];
+ }
+
+ IPSMember::save( $member['member_id'], array( 'members' => array( 'member_group_id' => intval($validate['real_group']) ) ) );
+
+ IPSCookie::set( "member_id", $member['member_id'] , 1 );
+ IPSCookie::set( "pass_hash", $member['member_login_key'], 1 );
+
+ //-----------------------------------------
+ // Remove "dead" validation
+ //-----------------------------------------
+
+ $this->DB->delete( 'validating', "vid='" . $validate['vid'] . "' OR (member_id={$member['member_id']} AND email_chg=1)" );
+
+ $this->registry->output->silentRedirect( $this->settings['base_url'].'&app=core&module=global§ion=login&do=autologin&fromemail=1' );
+ }
+ }
+
+ /**
+ * Processes the registration form
+ *
+ * @return @e void
+ */
+ public function registerProcessForm()
+ {
+ $this->_resetMember();
+
+ $form_errors = array();
+ $coppa = ( $this->request['coppa_user'] == 1 ) ? 1 : 0;
+ $in_password = trim( $this->request['PassWord'] );
+ $in_email = strtolower( trim( $this->request['EmailAddress'] ) );
+
+ /* Did we agree to the t&c? */
+ if( ! $this->request['agree_tos'] )
+ {
+ $form_errors['tos'] = array( $this->lang->words['must_agree_to_terms'] );
+ }
+
+ /* Custom profile field stuff */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/customfields/profileFields.php', 'customProfileFields' );
+ $custom_fields = new $classToLoad();
+
+ $custom_fields->initData( 'edit' );
+ $custom_fields->parseToSave( $_POST, 'register' );
+
+ /* Check */
+ if( $custom_fields->error_messages )
+ {
+ $form_errors['general'] = $custom_fields->error_messages;
+ }
+
+ /* Check the email address */
+ if ( ! $in_email OR strlen( $in_email ) < 6 OR !IPSText::checkEmailAddress( $in_email ) )
+ {
+ $form_errors['email'][$this->lang->words['err_invalid_email']] = $this->lang->words['err_invalid_email'];
+ }
+
+ if( trim($this->request['PassWord_Check']) != $in_password OR !$in_password )
+ {
+ $form_errors['password'][$this->lang->words['passwords_not_match']] = $this->lang->words['passwords_not_match'];
+ }
+
+ /*
+ There's no reason for this - http://community.invisionpower.com/resources/bugs.html/_/ip-board/registrations-limit-passwords-to-32-characters-for-no-apparent-reason-r37770
+ elseif ( strlen( $in_password ) < 3 )
+ {
+ $form_errors['password'][$this->lang->words['pass_too_short']] = $this->lang->words['pass_too_short'];
+ }
+ elseif ( strlen( $in_password ) > 32 )
+ {
+ $form_errors['password'][$this->lang->words['pass_too_long']] = $this->lang->words['pass_too_long'];
+ }
+ */
+
+ /* Check the username */
+ $user_check = IPSMember::getFunction()->cleanAndCheckName( $this->request['members_display_name'], array(), 'name' );
+ $disp_check = IPSMember::getFunction()->cleanAndCheckName( $this->request['members_display_name'], array(), 'members_display_name' );
+
+ if( is_array( $user_check['errors'] ) && count( $user_check['errors'] ) )
+ {
+ foreach( $user_check['errors'] as $key => $error )
+ {
+ $form_errors['dname'][ $error ] = isset($this->lang->words[ $error ]) ? $this->lang->words[ $error ] : $error;
+ }
+ }
+
+ /* this duplicates username error above */
+ /*if( is_array( $disp_check['errors'] ) && count( $disp_check['errors'] ) )
+ {
+ foreach( $disp_check['errors'] as $key => $error )
+ {
+ $form_errors['dname'][ $error ] = isset($this->lang->words[ $error ]) ? $this->lang->words[ $error ] : $error;
+ }
+ }*/
+
+ /* Is this email addy taken? */
+ if( IPSMember::checkByEmail( $in_email ) == TRUE )
+ {
+ $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
+ }
+
+ /* Load handler... */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/handlers/han_login.php', 'han_login' );
+ $this->han_login = new $classToLoad( $this->registry );
+ $this->han_login->init();
+ $this->han_login->emailExistsCheck( $in_email );
+
+ if( $this->han_login->return_code AND $this->han_login->return_code != 'METHOD_NOT_DEFINED' AND $this->han_login->return_code != 'EMAIL_NOT_IN_USE' )
+ {
+ $form_errors['email'][$this->lang->words['reg_error_email_taken']] = $this->lang->words['reg_error_email_taken'];
+ }
+
+ /* Are they banned [EMAIL]? */
+ if ( IPSMember::isBanned( 'email', $in_email ) === TRUE )
+ {
+ $form_errors['email'][$this->lang->words['reg_error_email_ban']] = $this->lang->words['reg_error_email_ban'];
+ }
+
+ /* Check the CAPTCHA */
+ if ( $this->settings['bot_antispam_type'] != 'none' )
+ {
+ if ( $this->registry->getClass('class_captcha')->validate() !== TRUE )
+ {
+ $form_errors['general'][$this->lang->words['err_reg_code']] = $this->lang->words['err_reg_code'];
+ }
+ }
+
+ /* Check the Q and A */
+ $qanda = intval($this->request['qanda_id']);
+ $pass = true;
+
+ if( $qanda )
+ {
+ $pass = false;
+ $data = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'question_and_answer', 'where' => 'qa_id=' . $qanda ) );
+
+ if( $data['qa_id'] )
+ {
+ $answers = explode( "\n", str_replace( "\r", "", $data['qa_answers'] ) );
+
+ if( count($answers) )
+ {
+ foreach( $answers as $answer )
+ {
+ $answer = trim($answer);
+
+ if( IPSText::mbstrlen($answer) AND mb_strtolower($answer) == mb_strtolower($this->request['qa_answer']) )
+ {
+ $pass = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ //-----------------------------------------
+ // Do we have any questions?
+ //-----------------------------------------
+
+ $data = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as questions', 'from' => 'question_and_answer' ) );
+
+ if( $data['questions'] )
+ {
+ $pass = false;
+ }
+ }
+
+ if( !$pass )
+ {
+ $form_errors['general'][$this->lang->words['err_q_and_a']] = $this->lang->words['err_q_and_a'];
+ }
+
+ /* CHECK 2: Any errors ? */
+ if ( count( $form_errors ) )
+ {
+ $this->registerForm( $form_errors );
+ return;
+ }
+
+ /* Build up the hashes */
+ $mem_group = $this->settings['member_group'];
+
+ /* Are we asking the member or admin to preview? */
+ if( $this->settings['reg_auth_type'] )
+ {
+ $mem_group = $this->settings['auth_group'];
+ }
+ else if ($coppa == 1)
+ {
+ $mem_group = $this->settings['auth_group'];
+ }
+
+ /* Create member */
+ $member = array(
+ 'name' => $this->request['members_display_name'],
+ 'password' => $in_password,
+ 'members_display_name' => $this->request['members_display_name'],
+ 'email' => $in_email,
+ 'member_group_id' => $mem_group,
+ 'joined' => time(),
+ 'ip_address' => $this->member->ip_address,
+ 'time_offset' => $this->request['time_offset'],
+ 'coppa_user' => $coppa,
+ 'members_auto_dst' => intval($this->settings['time_dst_auto_correction']),
+ 'allow_admin_mails' => intval( $this->request['allow_admin_mail'] ),
+ 'language' => $this->member->language_id,
+ );
+
+ /* Spam Service */
+ $spamCode = 0;
+ $_spamFlag = 0;
+
+ if( $this->settings['spam_service_enabled'] )
+ {
+ /* Query the service */
+ $spamCode = IPSMember::querySpamService( $in_email );
+
+ /* Action to perform */
+ $action = $this->settings[ 'spam_service_action_' . $spamCode ];
+
+ /* Perform Action */
+ switch( $action )
+ {
+ /* Proceed with registration */
+ case 1:
+ break;
+
+ /* Flag for admin approval */
+ case 2:
+ $member['member_group_id'] = $this->settings['auth_group'];
+ $this->settings['reg_auth_type'] = 'admin';
+ $_spamFlag = 1;
+ break;
+
+ /* Approve the account, but ban it */
+ case 3:
+ $member['member_banned'] = 1;
+ $member['bw_is_spammer'] = 1;
+ $this->settings['reg_auth_type'] = '';
+ break;
+
+ /* Deny registration */
+ case 4:
+ $this->registry->output->showError( 'spam_denied_account', '100x001', FALSE, '', 200 );
+ break;
+ }
+ }
+
+ //-----------------------------------------
+ // Create the account
+ //-----------------------------------------
+
+ $member = IPSMember::create( array( 'members' => $member, 'pfields_content' => $custom_fields->out_fields ), FALSE, FALSE, FALSE );
+
+ //-----------------------------------------
+ // Login handler create account callback
+ //-----------------------------------------
+
+ $this->han_login->createAccount( array( 'member_id' => $member['member_id'],
+ 'email' => $member['email'],
+ 'joined' => $member['joined'],
+ 'password' => $in_password,
+ 'ip_address' => $this->member->ip_address,
+ 'username' => $member['members_display_name'],
+ 'name' => $member['name'],
+ 'members_display_name' => $member['members_display_name'],
+ ) );
+
+ //-----------------------------------------
+ // We'll just ignore if this fails - it shouldn't hold up IPB anyways
+ //-----------------------------------------
+
+ /*if ( $han_login->return_code AND ( $han_login->return_code != 'METHOD_NOT_DEFINED' AND $han_login->return_code != 'SUCCESS' ) )
+ {
+ $this->registry->output->showError( 'han_login_create_failed', 2017, true );
+ }*/
+
+ //-----------------------------------------
+ // Validation
+ //-----------------------------------------
+
+ $validate_key = md5( IPSMember::makePassword() . time() );
+ $time = time();
+
+ if( $coppa != 1 )
+ {
+ if( ( $this->settings['reg_auth_type'] == 'user' ) or ( $this->settings['reg_auth_type'] == 'admin' ) or ( $this->settings['reg_auth_type'] == 'admin_user' ) )
+ {
+ //-----------------------------------------
+ // We want to validate all reg's via email,
+ // after email verificiation has taken place,
+ // we restore their previous group and remove the validate_key
+ //-----------------------------------------
+
+ $this->DB->insert( 'validating', array(
+ 'vid' => $validate_key,
+ 'member_id' => $member['member_id'],
+ 'real_group' => $this->settings['member_group'],
+ 'temp_group' => $this->settings['auth_group'],
+ 'entry_date' => $time,
+ 'coppa_user' => $coppa,
+ 'new_reg' => 1,
+ 'ip_address' => $member['ip_address'],
+ 'spam_flag' => $_spamFlag,
+ ) );
+
+ if ( $this->settings['reg_auth_type'] == 'user' OR $this->settings['reg_auth_type'] == 'admin_user' )
+ {
+ /* Send out the email. */
+ $message = array( 'THE_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=auto_validate&uid=" . urlencode( $member['member_id'] ) . "&aid=" . urlencode( $validate_key ), 'publicNoSession', 'false'),
+ 'NAME' => $member['members_display_name'],
+ 'MAN_LINK' => $this->registry->getClass('output')->buildSEOUrl("app=core&module=global§ion=register&do=05", 'publicNoSession', 'false'),
+ 'EMAIL' => $member['email'],
+ 'ID' => $member['member_id'],
+ 'CODE' => $validate_key );
+
+ IPSText::getTextClass('email')->setPlainTextTemplate( IPSText::getTextClass('email')->getTemplate( "reg_validate", $this->member->language_id ) );
+ IPSText::getTextClass('email')->buildPlainTextContent( $message );
+ IPSText::getTextClass('email')->buildHtmlContent( $message );
+
+ IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email'], $this->settings['board_name'] );
+ IPSText::getTextClass('email')->to = $member['email'];
+
+ IPSText::getTextClass('email')->sendMail();
+
+ $this->output = $this->registry->output->getTemplate('register')->showAuthorize( $member );
+
+ }
+ else if( $this->settings['reg_auth_type'] == 'admin' )
+ {
+ $this->output = $this->registry->output->getTemplate('register')->showPreview( $member );
+ }
+
+ /* Only send new registration email if the member wasn't banned */
+ if( $this->settings['new_reg_notify'] AND ! $member['member_banned'] )
+ {
+ $date = $this->registry->class_localization->getDate( time(), 'LONG', 1 );
+
+ IPSText::getTextClass('email')->getTemplate( 'admin_newuser' );
+
+ IPSText::getTextClass('email')->buildMessage( array( 'DATE' => $date,
+ 'LOG_IN_NAME' => $member['name'],
+ 'EMAIL' => $member['email'],
+ 'IP' => $member['ip_address'],
+ 'DISPLAY_NAME' => $member['members_display_name'] ) );
+
+ IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email1'], $this->settings['board_name'] );
+ IPSText::getTextClass('email')->to = $this->settings['email_in'];
+ IPSText::getTextClass('email')->sendMail();
+ }
+
+ $this->registry->output->setTitle( $this->lang->words['reg_success'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->addNavigation( $this->lang->words['nav_reg'], '' );
+ }
+ else
+ {
+ /* We don't want to preview, or get them to validate via email. */
+ $stat_cache = $this->cache->getCache('stats');
+
+ if( $member['members_display_name'] AND $member['member_id'] AND !$this->caches['group_cache'][ $member['member_group_id'] ]['g_hide_online_list'] )
+ {
+ $stat_cache['last_mem_name'] = $member['members_display_name'];
+ $stat_cache['last_mem_name_seo'] = IPSText::makeSeoTitle( $member['members_display_name'] );
+ $stat_cache['last_mem_id'] = $member['member_id'];
+ }
+
+ $stat_cache['mem_count'] += 1;
+
+ $this->cache->setCache( 'stats', $stat_cache, array( 'array' => 1 ) );
+
+ /* Only send new registration email if the member wasn't banned */
+ if( $this->settings['new_reg_notify'] AND ! $member['member_banned'] )
+ {
+ $date = $this->registry->class_localization->getDate( time(), 'LONG', 1 );
+
+ IPSText::getTextClass('email')->getTemplate( 'admin_newuser' );
+
+ IPSText::getTextClass('email')->buildMessage( array( 'DATE' => $date,
+ 'LOG_IN_NAME' => $member['name'],
+ 'EMAIL' => $member['email'],
+ 'IP' => $member['ip_address'],
+ 'DISPLAY_NAME' => $member['members_display_name'] ) );
+
+ IPSText::getTextClass('email')->subject = sprintf( $this->lang->words['new_registration_email1'], $this->settings['board_name'] );
+ IPSText::getTextClass('email')->to = $this->settings['email_in'];
+ IPSText::getTextClass('email')->sendMail();
+ }
+
+ IPSCookie::set( 'pass_hash' , $member['member_login_key'], 1);
+ IPSCookie::set( 'member_id' , $member['member_id'] , 1);
+
+ //-----------------------------------------
+ // Fix up session
+ //-----------------------------------------
+
+ $privacy = ( $member['g_hide_online_list'] || ( empty($this->settings['disable_anonymous']) && ! empty($this->request['Privacy']) ) ) ? 1 : 0;
+
+ # Update value for onCompleteAccount call
+ $member['login_anonymous'] = $privacy . '&1';
+
+ $this->member->sessionClass()->convertGuestToMember( array( 'member_name' => $member['members_display_name'],
+ 'member_id' => $member['member_id'],
+ 'member_group' => $member['member_group_id'],
+ 'login_type' => $privacy ) );
+
+ IPSLib::runMemberSync( 'onCompleteAccount', $member );
+
+ $this->registry->output->silentRedirect( $this->settings['base_url'] . '&app=core&module=global§ion=login&do=autologin&fromreg=1');
+ }
+ }
+ else
+ {
+ /* This is a COPPA user, so lets tell them they registered OK and redirect to the form. */
+ $this->DB->insert( 'validating', array (
+ 'vid' => $validate_key,
+ 'member_id' => $member['member_id'],
+ 'real_group' => $this->settings['member_group'],
+ 'temp_group' => $this->settings['auth_group'],
+ 'entry_date' => $time,
+ 'coppa_user' => $coppa,
+ 'new_reg' => 1,
+ 'ip_address' => $member['ip_address']
+ ) );
+
+ $this->registry->output->redirectScreen( $this->lang->words['cp_success'], $this->settings['base_url'] . 'app=core&module=global§ion=register&do=12' );
+ }
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/global/reputation.php b/upload/admin/applications/core/modules_public/global/reputation.php
index f1e78d74..8a210c8e 100644
--- a/upload/admin/applications/core/modules_public/global/reputation.php
+++ b/upload/admin/applications/core/modules_public/global/reputation.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Reputation
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-04-16 15:13:53 -0400 (Tue, 16 Apr 2013) $
*
*
* @author $Author $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 12182 $
*
*/
@@ -81,7 +81,7 @@ class public_core_global_reputation extends ipsCommand
/* Redirect to */
$return_url = '';
- if( !empty( $this->request['post_return'] ) )
+ if( !empty( $this->request['post_return'] ) && $app == 'forums' )
{
$return_url = $this->settings['base_url'] . 'app=forums&module=forums§ion=findpost&pid=' . intval( $this->request['post_return'] );
}
diff --git a/upload/admin/applications/core/modules_public/global/rss.php b/upload/admin/applications/core/modules_public/global/rss.php
index 65c0b95b..d9bb0ea7 100644
--- a/upload/admin/applications/core/modules_public/global/rss.php
+++ b/upload/admin/applications/core/modules_public/global/rss.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* RSS output functionality
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 18th March 2005
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
if ( ! defined( 'IN_IPB' ) )
diff --git a/upload/admin/applications/core/modules_public/global/share.php b/upload/admin/applications/core/modules_public/global/share.php
index 37912c2d..923f8f9f 100644
--- a/upload/admin/applications/core/modules_public/global/share.php
+++ b/upload/admin/applications/core/modules_public/global/share.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Captcha
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-01-07 12:09:37 -0500 (Mon, 07 Jan 2013) $
*
*
* @author $Author $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 20th February 2002
- * @version $Rev: 10914 $
+ * @version $Rev: 11791 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -38,13 +38,7 @@ class public_core_global_share extends ipsCommand
{
$this->registry->output->showError( 'no_permission', 100234.1, false, null, 403 );
}
-
- /* Disable for bots */
- if( $this->member->is_not_human )
- {
- $this->registry->output->showError( 'no_permission', 100234.2, false, null, 403 );
- }
-
+
$url = IPSText::base64_decode_urlSafe( $this->request['url'] );
$title = IPSText::base64_decode_urlSafe( $this->request['title'] );
$key = trim( $this->request['key'] );
diff --git a/upload/admin/applications/core/modules_public/global/sitemap.php b/upload/admin/applications/core/modules_public/global/sitemap.php
new file mode 100644
index 00000000..d6a91adc
--- /dev/null
+++ b/upload/admin/applications/core/modules_public/global/sitemap.php
@@ -0,0 +1,56 @@
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Sitemap Forwarder
+ * Last Updated: $Date: 2012-05-10 21:10:13 +0100 (Thu, 10 May 2012) $
+ *
+ *
+ * @author $Author $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @since 27th June 2012
+ * @version $Rev: 10721 $
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class public_core_global_sitemap extends ipsCommand
+{
+ public function doExecute( ipsRegistry $registry )
+ {
+ // Requesting a sitemap?
+ if(!array_key_exists('sitemap', $this->request))
+ {
+ $this->registry->output->showError( 'error_generic', 10850, null, null, 404 );
+ return false;
+ }
+
+ // Got a valid name?
+ if(!preg_match('/sitemap\_([a-zA-Z0-9\_]+)\.xml(\.gz)?/', $this->request['sitemap']))
+ {
+ $this->registry->output->showError( 'error_generic', 10850, null, null, 404 );
+ return false;
+ }
+
+ // Got a valid file?
+ if(!file_exists( IPS_CACHE_PATH . 'cache/' . $this->request['sitemap']))
+ {
+ $this->registry->output->showError( 'error_generic', 10850, null, null, 404 );
+ return false;
+ }
+
+ header('Content-Type: ' . (strpos($this->request['sitemap'], '.gz') ? 'application/x-gzip' : 'application/xml'));
+ header('Content-Disposition: attachment; filename=' . $this->request['sitemap']);
+
+ print file_get_contents( IPS_CACHE_PATH . 'cache/' . $this->request['sitemap']);
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/global/skin.php b/upload/admin/applications/core/modules_public/global/skin.php
index c6543af6..ea635632 100644
--- a/upload/admin/applications/core/modules_public/global/skin.php
+++ b/upload/admin/applications/core/modules_public/global/skin.php
@@ -4,11 +4,11 @@
*~TERABYTE_DOC_READY~
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: bfarber $
+ * $Author: AndyMillne $
* @since 27 March 2012
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $LastChangedDate: 2012-09-17 12:07:56 -0400 (Mon, 17 Sep 2012) $
+ * @version v3.4.5
+ * $Revision: 11342 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -52,7 +52,7 @@ class public_core_global_skin extends ipsCommand
if ( ( $this->request['skinId'] != 'setAsMobile' ) && $this->request['k'] != $this->member->form_hash )
{
- $this->registry->output->showError('no_permission');
+ $this->registry->output->showError('no_permission', 10122243, FALSE, '', 403);
}
if ( is_numeric( $skinId ) )
diff --git a/upload/admin/applications/core/modules_public/global/unsubscribe.php b/upload/admin/applications/core/modules_public/global/unsubscribe.php
new file mode 100644
index 00000000..3563de59
--- /dev/null
+++ b/upload/admin/applications/core/modules_public/global/unsubscribe.php
@@ -0,0 +1,45 @@
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+/**
+ * @class public_core_global_unsubscribe
+ * @brief Unsubscribes user from bulk mails
+ */
+class public_core_global_unsubscribe extends ipsCommand
+{
+ /**
+ * Main function executed automatically by the controller
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ $member = IPSMember::load( intval( $this->request['member'] ), 'none', 'id' );
+ if ( $member['member_id'] and $this->request['key'] == md5( $member['email'] . ':' . $member['members_pass_hash'] ) )
+ {
+ IPSMember::save( $member['member_id'], array( 'members' => array( 'allow_admin_mails' => 0 ) ) );
+
+ $this->registry->getClass('output')->addContent( $this->registry->output->getTemplate( 'ucp' )->unsubscribed() );
+ $this->registry->getClass('output')->sendOutput();
+ }
+
+ $this->registry->output->showError( 'email_no_unsubscribe' );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/help/defaultSection.php b/upload/admin/applications/core/modules_public/help/defaultSection.php
index 111887c5..452491bf 100644
--- a/upload/admin/applications/core/modules_public/help/defaultSection.php
+++ b/upload/admin/applications/core/modules_public/help/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_public/help/help.php b/upload/admin/applications/core/modules_public/help/help.php
index 0998d3d3..86f6db16 100644
--- a/upload/admin/applications/core/modules_public/help/help.php
+++ b/upload/admin/applications/core/modules_public/help/help.php
@@ -2,18 +2,18 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Help File System
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-11-15 09:58:24 -0500 (Thu, 15 Nov 2012) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 11605 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -160,7 +160,7 @@ class public_core_help_help extends ipsCommand
);
/* Navigation */
- $this->registry->output->setTitle( $this->lang->words['help_topic'] . ' - ' . ipsRegistry::$settings['board_name'] );
+ $this->registry->output->setTitle( $this->lang->words['help_topic'] . ': ' . $topic['title'] . ' - ' . ipsRegistry::$settings['board_name'] );
$this->registry->output->addNavigation( $this->lang->words['help_topics'], "app=core&module=help" );
$this->registry->output->addNavigation( $this->lang->words['help_topic'], '' );
diff --git a/upload/admin/applications/core/modules_public/modcp/defaultSection.php b/upload/admin/applications/core/modules_public/modcp/defaultSection.php
index d0c2156d..a13b1eb5 100644
--- a/upload/admin/applications/core/modules_public/modcp/defaultSection.php
+++ b/upload/admin/applications/core/modules_public/modcp/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 2/14/2011
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_public/modcp/modcp.php b/upload/admin/applications/core/modules_public/modcp/modcp.php
index cfc03db2..cc798635 100644
--- a/upload/admin/applications/core/modules_public/modcp/modcp.php
+++ b/upload/admin/applications/core/modules_public/modcp/modcp.php
@@ -3,11 +3,11 @@
* @file modcp.php Moderator control panel
* $Copyright: (c) 2001 - 2011 Invision Power Services, Inc.$
* $License: http://www.invisionpower.com/company/standards.php#license$
- * $Author: bfarber $
+ * $Author: AndyMillne $
* @since 2/14/2011
- * $LastChangedDate: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10914 $
+ * $LastChangedDate: 2013-05-28 10:00:25 -0400 (Tue, 28 May 2013) $
+ * @version v3.4.5
+ * $Revision: 12273 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -183,15 +183,15 @@ class public_core_modcp_modcp extends ipsCommand
break;
case 'doeditmember':
- $this->_doEditMember();
+ $_output = $this->_doEditMember();
break;
case 'setAsSpammer':
- $this->_setAsSpammer();
+ $_output = $this->_setAsSpammer();
break;
default:
- $_output = $this->registry->output->getTemplate('modcp')->memberLookup();
+ $_output = $this->registry->output->getTemplate('modcp')->overview();
break;
}
}
@@ -415,41 +415,33 @@ class public_core_modcp_modcp extends ipsCommand
// Init
//-----------------------------------------
- $editable = array();
-
+ $editable = array();
+ $isHtml = intval( $this->request['sig_htmlstatus'] );
+
//-----------------------------------------
// Signature and about me
//-----------------------------------------
- $signature = $this->editor->process( $_POST['Post'] );
- $aboutme = $this->editor->process( $_POST['aboutme'] );
-
+ /* Load parser */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
+ $parser = new $classToLoad();
+
+ $this->editor->setLegacyMode(false);
+
//-----------------------------------------
// Parse signature
//-----------------------------------------
- IPSText::getTextClass('bbcode')->parse_smilies = 0;
- IPSText::getTextClass('bbcode')->parse_html = $this->caches['group_cache'][ $this->warn_member['member_group_id'] ]['g_dohtml'];
- IPSText::getTextClass('bbcode')->parse_bbcode = 1;
- IPSText::getTextClass('bbcode')->parsing_section = 'signatures';
- IPSText::getTextClass('bbcode')->parsing_mgroup = $this->warn_member['member_group_id'];
- IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->warn_member['mgroup_others'];
-
- $signature = IPSText::getTextClass('bbcode')->preDbParse( $signature );
- $signatureCache = IPSText::getTextClass('bbcode')->preDisplayParse( $signature );
+ /* Set content in editor */
+ $this->editor->setAllowBbcode( true );
+ $this->editor->setAllowSmilies( false );
+ $this->editor->setIsHtml( $this->caches['group_cache'][ $this->warn_member['member_group_id'] ]['g_dohtml'] && $isHtml );
+ $this->editor->setBbcodeSection('signatures');
+
+ $signature = $this->editor->process( $_POST['Post'] );
- //-----------------------------------------
- // Parse about me
- //-----------------------------------------
-
- IPSText::getTextClass('bbcode')->parse_smilies = 1;
- IPSText::getTextClass('bbcode')->parse_html = $this->caches['group_cache'][ $this->warn_member['member_group_id'] ]['g_dohtml'];
- IPSText::getTextClass('bbcode')->parse_bbcode = 1;
- IPSText::getTextClass('bbcode')->parsing_section = 'aboutme';
- IPSText::getTextClass('bbcode')->parsing_mgroup = $this->warn_member['member_group_id'];
- IPSText::getTextClass('bbcode')->parsing_mgroup_others = $this->warn_member['mgroup_others'];
-
- $aboutme = IPSText::getTextClass('bbcode')->preDbParse( $aboutme );
+ /* About Me */
+ $aboutme = $this->editor->process( $_POST['aboutme'] );
//-----------------------------------------
// Add to array to save
@@ -458,6 +450,10 @@ class public_core_modcp_modcp extends ipsCommand
$save['extendedProfile'] = array( 'signature' => $signature, 'pp_about_me' => $aboutme );
$save['members'] = array( 'title' => $this->request['title'] );
+ //-----------------------------------------
+ // Removing photo?
+ //-----------------------------------------
+
if ( $this->request['photo'] == 1 )
{
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/member/photo.php', 'classes_member_photo' );
@@ -465,6 +461,25 @@ class public_core_modcp_modcp extends ipsCommand
$photos->remove( $this->warn_member['member_id'] );
}
+ //-----------------------------------------
+ // Removing Restrictions?
+ //-----------------------------------------
+
+ if ( $this->request['modpreview'] == 1 )
+ {
+ $save['core']['mod_posts'] = 0;
+ }
+
+ if ( $this->request['postingrestriction'] == 1 )
+ {
+ $save['core']['restrict_post'] = 0;
+ }
+
+ if ( $this->request['remove_suspension'] == 1 )
+ {
+ $save['core']['temp_ban'] = 0;
+ }
+
//-----------------------------------------
// Profile fields
//-----------------------------------------
@@ -483,10 +498,13 @@ class public_core_modcp_modcp extends ipsCommand
//-----------------------------------------
// Bitwise
//-----------------------------------------
-
- $bw = IPSBWOptions::thaw( $this->warn_member['members_bitoptions'], 'members' );
- $bw['bw_no_status_update'] = ( $this->request['status_updates'] ) ? 0 : 1;
- $save['core']['members_bitoptions'] = IPSBWOptions::freeze( $bw, 'members' );
+
+ if ( isset( $this->request['status_updates'] ) )
+ {
+ $bw = IPSBWOptions::thaw( $this->warn_member['members_bitoptions'], 'members' );
+ $bw['bw_no_status_update'] = ( $this->request['status_updates'] ) ? 0 : 1;
+ $save['core']['members_bitoptions'] = IPSBWOptions::freeze( $bw, 'members' );
+ }
//-----------------------------------------
// Write it to the DB.
@@ -498,7 +516,8 @@ class public_core_modcp_modcp extends ipsCommand
// Update signature content cache
//-----------------------------------------
- IPSContentCache::update( $this->warn_member['member_id'], 'sig', $signatureCache );
+ /* Update cache */
+ IPSContentCache::update( $this->warn_member['member_id'], 'sig', $parser->display( $signature ) );
//-----------------------------------------
// Add a mod log entry and redirect
@@ -540,7 +559,12 @@ class public_core_modcp_modcp extends ipsCommand
{
$this->registry->output->showError( 'moderate_no_permission', 10311900, true, null, 404 );
}
-
+
+ if ( ! $this->memberData['g_access_cp'] AND $member['g_access_cp'] )
+ {
+ return $this->registry->getClass('output')->getTemplate('modcp')->modcpMessage( $this->lang->words['mod_cannot_edit_admin'] );
+ }
+
//-----------------------------------------
// Check permissions
//-----------------------------------------
@@ -555,6 +579,11 @@ class public_core_modcp_modcp extends ipsCommand
$this->registry->output->showError( 'moderate_no_permission', 10311901, true, null, 403 );
}
+ if ( $this->request['auth_key'] != $this->member->form_hash )
+ {
+ $this->registry->output->showError( 'moderate_no_permission', 10311902, null, null, 403 );
+ }
+
//-----------------------------------------
// Do it
//-----------------------------------------
diff --git a/upload/admin/applications/core/modules_public/reports/defaultSection.php b/upload/admin/applications/core/modules_public/reports/defaultSection.php
index ebf7d386..c85f3d9d 100644
--- a/upload/admin/applications/core/modules_public/reports/defaultSection.php
+++ b/upload/admin/applications/core/modules_public/reports/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_public/reports/reports.php b/upload/admin/applications/core/modules_public/reports/reports.php
index ff6baf2d..b5c8eb98 100644
--- a/upload/admin/applications/core/modules_public/reports/reports.php
+++ b/upload/admin/applications/core/modules_public/reports/reports.php
@@ -7,9 +7,9 @@
* $Author: AndyMillne $
* @author Based on original "Report Center" by Luke Scott
* @since -
- * $LastChangedDate: 2012-06-26 07:24:43 -0400 (Tue, 26 Jun 2012) $
- * @version v3.3.4
- * $Revision: 10987 $
+ * $LastChangedDate: 2012-12-13 08:29:08 -0500 (Thu, 13 Dec 2012) $
+ * @version v3.4.5
+ * $Revision: 11713 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -275,7 +275,7 @@ class public_core_reports_reports extends ipsCommand
//-----------------------------------------
$COM_PERM = $this->registry->getClass('reportLibrary')->buildQueryPermissions();
-
+
$reports = array();
//-----------------------------------------
@@ -424,6 +424,11 @@ class public_core_reports_reports extends ipsCommand
$this->registry->getClass('output')->showError( 'no_permission', 20112, null, null, 403 );
}
+ if ( $this->request['newstatus'] == 'x' )
+ {
+ $this->registry->getClass('output')->showError( 'invalid_option', 20113, null, null, 403 );
+ }
+
//-----------------------------------------
// Are we pruning?
//-----------------------------------------
@@ -627,6 +632,18 @@ class public_core_reports_reports extends ipsCommand
$this->registry->getClass('output')->showError( 'no_permission', 20114, null, null, 403 );
}
+ //-----------------------------------------
+ // Check Captcha
+ //-----------------------------------------
+
+ if ( ! $this->memberData['member_id'] AND $this->settings['guest_captcha'] AND $this->settings['bot_antispam_type'] != 'none' )
+ {
+ if ( !$this->registry->getClass('class_captcha')->validate() )
+ {
+ $this->registry->output->showError( 'posting_bad_captcha', '20116', null, null, 403 );
+ }
+ }
+
//-----------------------------------------
// Empty report
//-----------------------------------------
@@ -698,13 +715,11 @@ class public_core_reports_reports extends ipsCommand
}
$COM_PERM = $this->registry->getClass('reportLibrary')->buildQueryPermissions();
-
- IPSText::getTextClass('bbcode')->parse_bbcode = 1;
- IPSText::getTextClass('bbcode')->parse_html = 0;
- IPSText::getTextClass('bbcode')->parse_emoticons = 1;
- IPSText::getTextClass('bbcode')->parse_nl2br = 0;
- IPSText::getTextClass('bbcode')->parsing_section = 'global';
+ /* Load parser */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
+ $parser = new $classToLoad();
+
//-----------------------------------------
// Get reports
//-----------------------------------------
@@ -714,9 +729,6 @@ class public_core_reports_reports extends ipsCommand
while( $row = $this->DB->fetch($outer) )
{
- IPSText::getTextClass( 'bbcode' )->parsing_mgroup = $row['member_group_id'];
- IPSText::getTextClass( 'bbcode' )->parsing_mgroup_others = $row['mgroup_others'];
-
$row['points'] = isset( $row['points'] ) ? $row['points'] : $this->settings['_tmpPoints'][ $row['id'] ];
if( !$options['url'] && $row['url'] )
@@ -757,7 +769,15 @@ class public_core_reports_reports extends ipsCommand
}
$row['title'] = $row['_title'];
- $row['report'] = IPSText::getTextClass('bbcode')->preDisplayParse( $row['report'] );
+
+ /* Set up some settings */
+ $parser->set( array( 'parseArea' => 'reports',
+ 'memberData' => $row['author'],
+ 'parseBBCode' => true,
+ 'parseHtml' => false,
+ 'parseEmoticons' => true ) );
+
+ $row['report'] = $parser->display( $row['report'] );
$reports[] = $row;
}
diff --git a/upload/admin/applications/core/modules_public/search/defaultSection.php b/upload/admin/applications/core/modules_public/search/defaultSection.php
index f9aa0e71..ccebd263 100644
--- a/upload/admin/applications/core/modules_public/search/defaultSection.php
+++ b/upload/admin/applications/core/modules_public/search/defaultSection.php
@@ -7,7 +7,7 @@
* $Author: ips_terabyte $
* @since 20th February 2002
* $LastChangedDate: 2011-05-05 12:40:49 -0400 (Thu, 05 May 2011) $
- * @version v3.3.4
+ * @version v3.4.5
* $Revision: 8655 $
*/
diff --git a/upload/admin/applications/core/modules_public/search/search.php b/upload/admin/applications/core/modules_public/search/search.php
index d1aa0618..2871ed52 100644
--- a/upload/admin/applications/core/modules_public/search/search.php
+++ b/upload/admin/applications/core/modules_public/search/search.php
@@ -1,1237 +1,1290 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Global Search
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @version $Rev: 10914 $
- */
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class public_core_search_search extends ipsCommand
-{
- /**
- * Generated output
- *
- * @var string
- */
- protected $output = '';
-
- /**
- * Page Title
- *
- * @var string
- */
- protected $title = '';
-
- /**
- * Object to handle searches
- *
- * @var string
- */
- protected $search_plugin = '';
-
- /**
- * Topics array
- *
- * @var array
- */
- protected $_topicArray = array();
- protected $_removedTerms = array();
-
- /**
- * Search controller
- *
- * @var obj
- */
- protected $searchController;
- protected $_session;
-
- /**
- * Class entry point
- *
- * @param object Registry reference
- * @return @e void [Outputs to screen/redirects]
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Load language */
- $this->registry->class_localization->loadLanguageFile( array( 'public_search' ), 'core' );
- $this->registry->class_localization->loadLanguageFile( array( 'public_forums', 'public_topic' ), 'forums' );
-
- /* Reset engine type */
- $this->settings['search_method'] = ( $this->settings['search_method'] == 'traditional' ) ? 'sql' : $this->settings['search_method'];
-
- /* Force SQL for view new content? */
- if ( ! empty( $this->settings['force_sql_vnc'] ) && $this->request['do'] == 'viewNewContent' )
- {
- $this->settings['search_method'] = 'sql';
- }
-
- /* Special consideration for contextual search */
- if ( isset( $this->request['search_app'] ) AND strstr( $this->request['search_app'], ':' ) )
- {
- list( $app, $type, $id ) = explode( ':', $this->request['search_app'] );
-
- $this->request['search_app'] = $app;
- $this->request['cType'] = $type;
- $this->request['cId'] = $id;
- }
- else
- {
- /* Force forums as default search */
- $this->request['search_in'] = ( $this->request['search_in'] AND IPSLib::appIsSearchable( $this->request['search_in'], 'search' ) ) ? $this->request['search_in'] : 'forums';
- $this->request['search_app'] = $this->request['search_app'] ? $this->request['search_app'] : $this->request['search_in'];
- }
-
- /* Check Access */
- $this->_canSearch();
-
- /* Start session - needs to be called before the controller is initiated */
- $this->_startSession();
-
- /* Load the controller */
- $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH. 'sources/classes/search/controller.php', 'IPSSearch' );
-
- /* Sanitzie */
- if ( ! is_string( $this->request['search_app'] ) )
- {
- $this->request['search_app'] = 'forums';
- }
-
- try
- {
- $this->searchController = new $classToLoad( $registry, $this->settings['search_method'], $this->request['search_app'] );
- }
- catch( Exception $error )
- {
- $msg = $error->getMessage();
-
- /* Start session */
- $this->_endSession();
-
- switch( $msg )
- {
- case 'NO_SUCH_ENGINE':
- case 'NO_SUCH_APP':
- case 'NO_SUCH_APP_ENGINE':
- $this->registry->output->showError( sprintf( $this->lang->words['no_search_app'], ipsRegistry::$applications[ $this->request['search_app'] ]['app_title'] ), 10145.1 );
- break;
- }
- }
-
- /* Log type */
- IPSDebug::addMessage( "Search type: " . $this->settings['search_method'] );
-
- /* Set up some defaults */
- IPSSearchRegistry::set('opt.noPostPreview', false );
- IPSSearchRegistry::set('in.start', intval( $this->request['st'] ) );
- IPSSearchRegistry::set('opt.search_per_page', intval( $this->settings['search_per_page'] ) ? intval( $this->settings['search_per_page'] ) : 25 );
-
- $this->settings['search_ucontent_days'] = ( $this->settings['search_ucontent_days'] ) ? $this->settings['search_ucontent_days'] : 365;
-
- /* Contextuals */
- if ( isset( $this->request['cType'] ) )
- {
- IPSSearchRegistry::set('contextual.type', $this->request['cType'] );
- IPSSearchRegistry::set('contextual.id' , $this->request['cId'] );
- }
-
- /* What to do */
- switch( $this->request['do'] )
- {
- case 'user_activity':
- $this->viewUserContent();
- break;
-
- case 'new_posts':
- case 'viewNewContent':
- case 'active':
- $this->viewNewContent();
- break;
-
- case 'search':
- case 'quick_search':
- $this->searchResults();
- break;
-
- case 'followed':
- $this->viewFollowedContent();
- break;
-
- case 'manageFollowed':
- $this->updateFollowedContent();
- break;
-
- default:
- case 'search_form':
- $this->searchAdvancedForm();
- break;
- }
-
- /* Start session */
- $this->_endSession();
-
- /* If we have any HTML to print, do so... */
- if ( $this->request['do'] == 'search' && ! empty( $this->request['search_tags'] ) )
- {
- $this->registry->output->setTitle( IPSText::urldecode_furlSafe( $this->request['search_tags'] ) . ' - ' . $this->lang->words['st_tags'] . ' - ' . IPSLib::getAppTitle( $this->request['search_app'] ) . ' - ' . ipsRegistry::$settings['board_name'] );
-
- /* Add canonical tag */
- $extra = ( $this->request['st'] ) ? '&st=' . $this->request['st'] : '';
- $this->registry->output->addCanonicalTag( 'app=core&module=search&do=search&search_tags=' . IPSText::urlencode_furlSafe( $this->request['search_tags'] ) . '&search_app=' . $this->request['search_app']. $extra, $this->request['search_tags'], 'tags' );
- }
- else
- {
- $this->registry->output->setTitle( $this->title . ' - ' . ipsRegistry::$settings['board_name'] );
- }
-
- $this->registry->output->addContent( $this->output );
- $this->registry->output->sendOutput();
- }
-
- /**
- * Moderate your list of liked content
- *
- * @author bfarber
- * @return string HTML to display
- */
- public function updateFollowedContent()
- {
- IPSSearchRegistry::set( 'in.search_app', $this->request['search_app'] );
-
- //-----------------------------------------
- // Get the likes we selected
- //-----------------------------------------
-
- $_likes = array();
-
- if( is_array($this->request['likes']) AND count($this->request['likes']) )
- {
- foreach( $this->request['likes'] as $_like )
- {
- $_thisLike = explode( '-', $_like );
- $_likes[] = array(
- 'app' => $_thisLike[0],
- 'area' => $_thisLike[1],
- 'id' => $_thisLike[2],
- );
- }
- }
-
- //-----------------------------------------
- // Got any?
- //-----------------------------------------
-
- if( !count($_likes) OR !is_array($_likes) )
- {
- return $this->viewFollowedContent( $this->lang->words['no_likes_for_del'] );
- }
-
- //-----------------------------------------
- // Get like helper class
- //-----------------------------------------
-
- $bootstraps = array();
-
- require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
-
- //-----------------------------------------
- // Loop over and moderate
- //-----------------------------------------
-
- foreach( $_likes as $_like )
- {
- $_bootstrap = classes_like::bootstrap( $_like['app'], $_like['area'] );
- $_likeKey = classes_like_registry::getKey( $_like['id'], $this->memberData['member_id'] );
- $_frequencies = $_bootstrap->allowedFrequencies();
-
- //-----------------------------------------
- // What action to take?
- //-----------------------------------------
-
- switch( $this->request['modaction'] )
- {
- case 'delete':
- $_bootstrap->remove( $_like['id'], $this->memberData['member_id'] );
- break;
-
- case 'change-donotify':
- $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'immediate' ), "like_id='" . addslashes($_likeKey) . "'" );
- break;
-
- case 'change-donotnotify':
- $this->DB->update( 'core_like', array( 'like_notify_do' => 0 ), "like_id='" . addslashes($_likeKey) . "'" );
- break;
-
- case 'change-immediate':
- if( in_array( 'immediate', $_frequencies ) )
- {
- $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'immediate' ), "like_id='" . addslashes($_likeKey) . "'" );
- }
- break;
-
- case 'change-offline':
- if( in_array( 'offline', $_frequencies ) )
- {
- $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'offline' ), "like_id='" . addslashes($_likeKey) . "'" );
- }
- break;
-
- case 'change-daily':
- if( in_array( 'daily', $_frequencies ) )
- {
- $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'daily' ), "like_id='" . addslashes($_likeKey) . "'" );
- }
- break;
-
- case 'change-weekly':
- if( in_array( 'weekly', $_frequencies ) )
- {
- $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'weekly' ), "like_id='" . addslashes($_likeKey) . "'" );
- }
- break;
-
- case 'change-anon':
- $this->DB->update( 'core_like', array( 'like_is_anon' => 1 ), "like_id='" . addslashes($_likeKey) . "'" );
- break;
-
- case 'change-noanon':
- $this->DB->update( 'core_like', array( 'like_is_anon' => 0 ), "like_id='" . addslashes($_likeKey) . "'" );
- break;
- }
- }
-
- $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=search&do=followed&search_app={$this->request['search_app']}&contentType={$this->request['contentType']}&confirm=1" );
- }
-
- /**
- * View content you are following
- *
- * @author Brandon Farber
- * @param string $error Error message
- * @return @e void
- */
- public function viewFollowedContent( $error='' )
- {
- IPSSearchRegistry::set( 'in.search_app', $this->request['search_app'] );
- IPSSearchRegistry::set( 'opt.searchType', 'titles' );
- IPSSearchRegistry::set( 'opt.noPostPreview', true );
-
- $results = array();
- $formatted = array();
- $count = 0;
-
- //-----------------------------------------
- // Determine content type
- //-----------------------------------------
-
- $contentTypes = IPSSearchRegistry::get('config.followContentTypes');
-
- //-----------------------------------------
- // Verify likes are available
- //-----------------------------------------
-
- if( count( IPSLib::getEnabledApplications('like') ) AND count( $contentTypes ) )
- {
- //-----------------------------------------
- // What content type?
- //-----------------------------------------
-
- $_type = '';
-
- if( $this->request['contentType'] AND in_array( $this->request['contentType'], $contentTypes ) )
- {
- $_type = $this->request['contentType'];
- }
- else
- {
- $_type = $contentTypes[0];
- }
-
- $this->request['contentType'] = $_type;
-
- IPSSearchRegistry::set( 'in.followContentType', $this->request['contentType'] );
-
- /* Fetch like class */
- try
- {
- require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
- $this->_like = classes_like::bootstrap( IPSSearchRegistry::get('in.search_app'), $_type );
- }
- catch ( Exception $e)
- {
- /* Fail safe... */
- $this->registry->output->addNavigation( $this->lang->words['followed_ct_title'], '' );
- $this->title = $this->lang->words['followed_ct_title'];
- $this->output .= $this->registry->output->getTemplate( 'search' )->followedContentView( array(), '', 0, $error, $contentTypes );
- }
-
- /* Do we have some custom join and sort data? */
- if ( method_exists( $this->_like, 'getSearchJoinAndSortBy' ) )
- {
- $custom = $this->_like->getSearchJoinAndSortBy();
-
- $countQ = array( 'select' => 'COUNT(*) as er',
- 'from' => array( 'core_like' => 'l' ),
- 'where' => 'like_member_id=' . $this->memberData['member_id'] . " AND like_visible=1 AND like_app='" . IPSSearchRegistry::get('in.search_app') . "' AND like_area='" . $_type . "'" );
- if ( $custom['from'] )
- {
- $countQ['add_join'][] = array( 'from' => $custom['from'], 'where' => $custom['where'] );
- }
- if ( $custom['order'] )
- {
- $countQ['order'] = $custom['order'] . ' DESC';
- }
- if ( $custom['extraWhere'] )
- {
- $countQ['where'] .= ' AND ' . $custom['extraWhere'];
- }
- $count = $this->DB->buildAndFetch( $countQ );
- $count = $count['er'];
-
- $q = array( 'select' => 'l.*',
- 'from' => array('core_like' => 'l'),
- 'where' => 'l.like_member_id=' . $this->memberData['member_id'] . " AND l.like_visible=1 AND l.like_app='" . IPSSearchRegistry::get('in.search_app') . "' AND l.like_area='" . $_type . "'",
- 'limit' => array( IPSSearchRegistry::get('in.start'), IPSSearchRegistry::get('opt.search_per_page') ),
- 'order' => 'like_added DESC'
- );
-
- if ( $custom['from'] )
- {
- $q['add_join'][] = array( 'from' => $custom['from'], 'where' => $custom['where'] );
- }
- if ( $custom['order'] )
- {
- $q['order'] = $custom['order'] . ' DESC';
- }
- if ( $custom['extraWhere'] )
- {
- $q['where'] .= ' AND ' . $custom['extraWhere'];
- }
-
- $this->DB->build( $q );
- }
- else
- {
- $count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as er',
- 'from' => 'core_like',
- 'where' => 'like_member_id=' . $this->memberData['member_id'] . " AND like_visible=1 AND like_app='" . IPSSearchRegistry::get('in.search_app') . "' AND like_area='" . $_type . "'" ) );
- $count = $count['er'];
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'core_like',
- 'where' => 'like_member_id=' . $this->memberData['member_id'] . " AND like_visible=1 AND like_app='" . IPSSearchRegistry::get('in.search_app') . "' AND like_area='" . $_type . "'",
- 'limit' => array( IPSSearchRegistry::get('in.start'), IPSSearchRegistry::get('opt.search_per_page') ),
- 'order' => 'like_added DESC' ) );
- }
-
- $outer = $this->DB->execute();
-
- while( $r = $this->DB->fetch($outer) )
- {
- $results[] = $r['like_rel_id'];
-
- $formatted[ $r['like_id'] ] = $r;
- }
-
- /* Process */
- $results = $this->searchController->fetchFollowedContentOutput( $results, $formatted );
-
- $pages = $this->registry->getClass('output')->generatePagination( array( 'totalItems' => $count,
- 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'),
- 'currentStartValue' => IPSSearchRegistry::get('in.start'),
- 'baseUrl' => "app=core&module=search&do=followed&search_app=" . IPSSearchRegistry::get('in.search_app') . '&sid=' . $this->request['_sid'] . "&contentType=" . $this->request['contentType'] ) );
- }
- else
- {
- $count = 0;
- $results = array();
- }
-
- /* Output */
- $this->registry->output->addNavigation( $this->lang->words['followed_ct_title'], '' );
- $this->title = $this->lang->words['followed_ct_title'];
- $this->output .= $this->registry->output->getTemplate( 'search' )->followedContentView( $results, $pages, $count, $error, $contentTypes );
- }
-
- /**
- * Builds the advanced search form
- *
- * @param string Message
- * @return @e void
- */
- public function searchAdvancedForm( $msg='', $removed_search_terms=array() )
- {
- /* Set up data */
- IPSSearchRegistry::set('view.search_form', true );
-
- /* Get any application specific filters */
- $appHtml = $this->searchController->getHtml();
- $isBoolean = $this->searchController->isBoolean();
- $tagSupport = $this->searchController->getTagSupport();
-
- /* Output */
- $this->title = $this->lang->words['search_form'];
- $this->registry->output->addNavigation( $this->lang->words['search_form'], '' );
- $this->output .= $this->registry->output->getTemplate( 'search' )->searchAdvancedForm( $appHtml, $msg, $this->request['search_app'], $removed_search_terms, $isBoolean, $tagSupport );
- }
-
- /**
- * Processes a search request
- *
- * @return @e void
- */
- public function searchResults()
- {
- /* Search Term */
- $_st = $this->searchController->formatSearchTerm( trim( $this->request['search_term'] ) );
- $search_term = $_st['search_term'];
- $removedTerms = $_st['removed'];
-
- /* Set up some defaults */
- $this->settings['max_search_word'] = $this->settings['max_search_word'] ? $this->settings['max_search_word'] : 300;
-
- /* Did we come in off a post request? */
- if ( $this->request['request_method'] == 'post' )
- {
- /* Set a no-expires header */
- $this->registry->getClass('output')->setCacheExpirationSeconds( 30 * 60 );
- }
-
- /* App specific */
- if ( isset( $this->request['search_sort_by_' . $this->request['search_app'] ] ) )
- {
- $this->request['search_sort_by'] = ( $_POST[ 'search_sort_by_' . $this->request['search_app'] ] ) ? $_POST[ 'search_sort_by_' . $this->request['search_app'] ] : $this->request['search_sort_by_' . $this->request['search_app'] ];
- $this->request['search_sort_order'] = ( $_POST[ 'search_sort_order_' . $this->request['search_app'] ] ) ? $_POST[ 'search_sort_order_' . $this->request['search_app'] ] : $this->request['search_sort_order_' . $this->request['search_app'] ];
- }
-
- /* Populate the registry */
- IPSSearchRegistry::set('in.search_app' , $this->request['search_app'] );
- IPSSearchRegistry::set('in.raw_search_term' , trim( $this->request['search_term'] ) );
- IPSSearchRegistry::set('in.clean_search_term', $search_term );
- IPSSearchRegistry::set('in.raw_search_tags' , str_replace( '&', '&', trim( IPSText::parseCleanValue( IPSText::urldecode_furlSafe( $_REQUEST['search_tags'] ) ) ) ) );
- IPSSearchRegistry::set('in.search_higlight' , str_replace( '.', '', $this->request['search_term'] ) );
- IPSSearchRegistry::set('in.search_date_end' , ( $this->request['search_date_start'] && $this->request['search_date_end'] ) ? $this->request['search_date_end'] : 'now' );
- IPSSearchRegistry::set('in.search_date_start', ( $this->request['search_date_start'] ) ? $this->request['search_date_start'] : '' );
- IPSSearchRegistry::set('in.search_author' , !empty( $this->request['search_author'] ) ? $this->request['search_author'] : '' );
-
- /* Set sort filters */
- $this->_setSortFilters();
-
- /* These can be overridden in the actual engine scripts */
- // IPSSearchRegistry::set('set.hardLimit' , 0 );
- IPSSearchRegistry::set('set.resultsCutToLimit', false );
- IPSSearchRegistry::set('set.resultsAsForum' , false );
-
- /* Are we option to show titles only / search in titles only */
- IPSSearchRegistry::set('opt.searchType', ( !empty( $this->request['search_content'] ) AND in_array( $this->request['search_content'], array( 'both', 'titles', 'content' ) ) ) ? $this->request['search_content'] : 'both' );
-
- /* Time check */
- if ( IPSSearchRegistry::get('in.search_date_start') AND strtotime( IPSSearchRegistry::get('in.search_date_start') ) > time() )
- {
- IPSSearchRegistry::set('in.search_date_start', 'now' );
- }
-
- if ( IPSSearchRegistry::get('in.search_date_end') AND strtotime( IPSSearchRegistry::get('in.search_date_end') ) > time() )
- {
- IPSSearchRegistry::set('in.search_date_end', 'now' );
- }
-
- /* Do some date checking */
- if( IPSSearchRegistry::get('in.search_date_end') AND IPSSearchRegistry::get('in.search_date_start') AND strtotime( IPSSearchRegistry::get('in.search_date_start') ) > strtotime( IPSSearchRegistry::get('in.search_date_end') ) )
- {
- $this->searchAdvancedForm( $this->lang->words['search_invalid_date_range'] );
- return;
- }
-
- /**
- * Lower limit
- */
- if ( $this->settings['min_search_word'] && ! IPSSearchRegistry::get('in.search_author') && ! IPSSearchRegistry::get('in.raw_search_tags') )
- {
- if ( $this->settings['search_method'] == 'sphinx' && substr_count( $search_term, '"' ) == 2 )
- {
- $_ok = true;
- }
- else
- {
- $_words = explode( ' ', preg_replace( "#\"(.*?)\"#", '', $search_term ) );
- $_ok = $search_term ? true : false;
-
- foreach( $_words as $_word )
- {
- $_word = preg_replace( '#^\+(.+?)$#', "\\1", $_word );
-
- if ( ! $_word OR $_word == '|' )
- {
- continue;
- }
-
- if( strlen( $_word ) < $this->settings['min_search_word'] )
- {
- $_ok = false;
- break;
- }
- }
- }
-
- if( ! $_ok )
- {
- $this->searchAdvancedForm( sprintf( $this->lang->words['search_term_short'], $this->settings['min_search_word'] ), $removedTerms );
- return;
- }
- }
-
- /**
- * Ok this is an upper limit.
- * If you needed to change this, you could do so via conf_global.php by adding:
- * $INFO['max_search_word'] = #####;
- */
- if ( $this->settings['max_search_word'] && strlen( IPSSearchRegistry::get('in.raw_search_term') ) > $this->settings['max_search_word'] )
- {
- $this->searchAdvancedForm( sprintf( $this->lang->words['search_term_long'], $this->settings['max_search_word'] ) );
- return;
- }
-
- /* Search Flood Check */
- if( $this->memberData['g_search_flood'] )
- {
- /* Check for a cookie */
- $last_search = IPSCookie::get( 'sfc' );
- $last_term = str_replace( """, '"', IPSCookie::get( 'sfct' ) );
- $last_term = str_replace( "&", '&', $last_term );
-
- /* If we have a last search time, check it */
- if( $last_search && $last_term )
- {
- if( ( time() - $last_search ) <= $this->memberData['g_search_flood'] && $last_term != IPSSearchRegistry::get('in.raw_search_term') )
- {
- $this->searchAdvancedForm( sprintf( $this->lang->words['xml_flood'], $this->memberData['g_search_flood'] - ( time() - $last_search ) ) );
- return;
- }
- else
- {
- /* Reset the cookie */
- IPSCookie::set( 'sfc', time() );
- IPSCookie::set( 'sfct', urlencode( IPSSearchRegistry::get('in.raw_search_term') ) );
- }
- }
- /* Set the cookie */
- else
- {
- IPSCookie::set( 'sfc', time() );
- IPSCookie::set( 'sfct', urlencode( IPSSearchRegistry::get('in.raw_search_term') ) );
- }
- }
-
- /* Clean search term for results view */
- $_search_term = trim( preg_replace( '#(^|\s)(\+|\-|\||\~)#', " ", $search_term ) );
-
- /* Got tag search only but app doesn't support tags */
- if ( IPSSearchRegistry::get('in.raw_search_tags') && ! IPSSearchRegistry::get( 'config.can_searchTags' ) && ! IPSSearchRegistry::get('in.raw_search_term') )
- {
- $count = 0;
- $results = array();
- }
- else if ( IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'search' ) )
- {
- /* Perform the search */
- $this->searchController->search();
-
- /* Get count */
- $count = $this->searchController->getResultCount();
-
- /* Get results which will be array of IDs */
- $results = $this->searchController->getResultSet();
-
- /* Get templates to use */
- $template = $this->searchController->fetchTemplates();
-
- /* Fetch sort details */
- $sortDropDown = $this->searchController->fetchSortDropDown();
-
- /* Set default sort option */
- $_a = IPSSearchRegistry::get('in.search_app');
- $_k = IPSSearchRegistry::get( $_a . '.searchInKey') ? IPSSearchRegistry::get( $_a . '.searchInKey') : '';
-
- if( $_k AND !$this->request['search_app_filters'][ $_a ][ $_k ]['sortKey'] AND is_array($sortDropDown) AND count($sortDropDown) )
- {
- $this->request['search_app_filters'][ $_a ][ $_k ]['sortKey'] = key( $sortDropDown );
- }
- else if( !$_k AND !$this->request['search_app_filters'][ $_a ]['sortKey'] AND is_array($sortDropDown) AND count($sortDropDown) )
- {
- $this->request['search_app_filters'][ $_a ]['sortKey'] = key( $sortDropDown );
- }
-
- /* Fetch sort details */
- $sortIn = $this->searchController->fetchSortIn();
-
- /* Build pagination */
- $links = $this->registry->output->generatePagination( array( 'totalItems' => $count,
- 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'),
- 'currentStartValue'=> IPSSearchRegistry::get('in.start'),
- 'baseUrl' => $this->_buildURLString() . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '' ) );
-
- /* Showing */
- $showing = array( 'start' => IPSSearchRegistry::get('in.start') + 1, 'end' => ( IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') ) > $count ? $count : IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') );
-
- /* Parse result set */
- $results = $this->registry->output->getTemplate( $template['group'] )->$template['template']( $results, ( IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ) ? 1 : 0 );
-
- /* Check for sortIn */
- if( count( $sortIn ) && !$this->request['search_app_filters'][ $this->request['search_app'] ]['searchInKey'] )
- {
- $this->request['search_app_filters'][ $this->request['search_app'] ]['searchInKey'] = $sortIn[0][0];
- }
- }
- else
- {
- $count = 0;
- $results = array();
- }
-
- /* Output */
- $this->title = $this->lang->words['search_results'];
- $this->output .= $this->registry->output->getTemplate( 'search' )->searchResultsWrapper( $results, $sortDropDown, $sortIn, $links, $count, $showing, $_search_term, $this->_buildURLString(), $this->request['search_app'], $removedTerms, IPSSearchRegistry::get('set.hardLimit'), IPSSearchRegistry::get('set.resultsCutToLimit'), IPSSearchRegistry::get('in.raw_search_tags') );
- }
-
- /**
- * Starts session
- * Loads / creates a session based on activity
- *
- * @return
- */
- protected function _startSession()
- {
- $session_id = IPSText::md5Clean( $this->request['sid'] );
- $requestType = ( $this->request['request_method'] == 'post' ) ? 'post' : 'get';
-
- if ( $session_id )
- {
- /* We check on member id 'cos we can. Obviously guests will have a member ID of zero, but meh */
- $this->_session = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'search_sessions',
- 'where' => 'session_id=\'' . $session_id . '\' AND session_member_id=' . $this->memberData['member_id'] ) );
- }
-
- /* Deflate */
- if ( $this->_session['session_id'] )
- {
- if ( $this->_session['session_data'] )
- {
- $this->_session['_session_data'] = unserialize( $this->_session['session_data'] );
-
- if ( isset( $this->_session['_session_data']['search_app_filters'] ) )
- {
- $this->request['search_app_filters'] = is_array( $this->request['search_app_filters'] ) ? array_merge( $this->_session['_session_data']['search_app_filters'], $this->request['search_app_filters'] ) : $this->_session['_session_data']['search_app_filters'];
- }
- }
-
- IPSDebug::addMessage( "Loaded search session: " . var_export( $this->_session['_session_data'], true ) . " " );
- }
- else
- {
- /* Create a session */
- $this->_session = array( 'session_id' => md5( uniqid( microtime(), true ) ),
- 'session_created' => time(),
- 'session_updated' => time(),
- 'session_member_id' => $this->memberData['member_id'],
- 'session_data' => serialize( array( 'search_app_filters' => $this->request['search_app_filters'] ) ) );
-
- $this->DB->insert( 'search_sessions', $this->_session );
-
- $this->_session['_session_data']['search_app_filters'] = $this->request['search_app_filters'];
-
- IPSDebug::addMessage( "Created search session: " . var_export( $this->_session['_session_data'], true ) . " " );
- }
-
- /* Do we have POST infos? */
- if ( isset( $_POST['search_app_filters'] ) )
- {
- $this->_session['_session_data']['search_app_filters'] = ( is_array( $this->_session['_session_data']['search_app_filters'] ) ) ? IPSLib::arrayMergeRecursive( $this->_session['_session_data']['search_app_filters'], $_POST['search_app_filters'] ) : $_POST['search_app_filters'];
- $this->request['search_app_filters'] = $this->_session['_session_data']['search_app_filters'];
-
- IPSDebug::addMessage( "Updated filters: " . var_export( $_POST['search_app_filters'], true ) . " " );
- }
-
- /* Globalize the session ID */
- $this->request['_sid'] = $this->_session['session_id'];
- }
-
- /**
- * End the session
- *
- */
- protected function _endSession()
- {
- if ( $this->_session['session_id'] )
- {
- $sd = array( 'session_updated' => time(),
- 'session_data' => serialize( $this->_session['_session_data'] ) );
-
- $this->DB->update( 'search_sessions', $sd, 'session_id=\'' . $this->_session['session_id'] . '\'' );
- }
-
- /* Delete old sessions */
- $this->DB->delete( 'search_sessions', 'session_updated < ' . ( time() - 86400 ) );
- }
-
- /**
- * Set the search order and key
- *
- * @return @e void
- */
- protected function _setSortFilters()
- {
- $app = $this->request['search_app'];
- $key = 'date';
- $dir = 'desc';
- $dun = false;
-
- /* multi search in options? */
- if ( isset( $this->request['search_app_filters'][ $app ]['searchInKey'] ) )
- {
- $_k = $this->request['search_app_filters'][ $app ]['searchInKey'];
-
- if ( isset( $this->request['search_app_filters'][ $app ][ $_k ]['sortKey'] ) )
- {
- $dun = true;
- $key = $this->request['search_app_filters'][ $app ][ $_k ]['sortKey'];
- $dir = $this->request['search_app_filters'][ $app ][ $_k ]['sortDir'];
- }
- }
-
- /* Normal options - although sometimes used even with multiple types */
- if ( ! $dun AND isset( $this->request['search_app_filters'][$app]['sortKey'] ) )
- {
- $key = $this->request['search_app_filters'][$app]['sortKey'];
- $dir = $this->request['search_app_filters'][$app]['sortDir'];
- }
- /* Global */
- else
- {
- if ( isset( $this->request['search_sort_by'] ) )
- {
- $key = $this->request['search_sort_by'];
- $dir = $this->request['search_sort_order'];
- }
- }
-
- /* Numeric? */
- if ( is_numeric( $dir ) )
- {
- $dir = ( $dir == 0 ) ? 'desc' : 'asc';
- }
- else
- {
- $dir = 'desc';
- }
-
- IPSSearchRegistry::set('in.search_sort_by' , trim( $key ) );
- IPSSearchRegistry::set('in.search_sort_order', ( $dir != 'desc' ) ? 'asc' : 'desc' );
- }
-
- /**
- * Displays latest user content
- *
- * @return @e void
- */
- public function viewUserContent()
- {
- /* INIT */
- $id = $this->request['mid'] ? intval( trim( $this->request['mid'] ) ) : $this->memberData['member_id'];
-
- /* Save query if we are viewing our own content */
- if( $this->memberData['member_id'] AND $id == $this->memberData['member_id'] )
- {
- $member = $this->memberData;
- }
- else
- {
- $member = IPSMember::load( $id, 'core' );
- }
-
- $beginStamp = 0;
-
- if ( ! $member['member_id'] )
- {
- $this->registry->output->showError( 'search_invalid_id', 10147, null, null, 403 );
- }
-
- $this->request['userMode'] = !empty($this->request['userMode']) ? $this->request['userMode'] : 'all';
-
- IPSSearchRegistry::set('in.search_app', $this->request['search_app'] );
- IPSSearchRegistry::set('in.userMode' , $this->request['userMode'] );
-
- /* Set sort filters */
- $this->_setSortFilters();
-
- /* Can we do this? */
- if ( IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'usercontent' ) )
- {
- /* Perform the search */
- $this->searchController->viewUserContent( $member );
-
- /* Get count */
- $count = $this->searchController->getResultCount();
-
- /* Get results which will be array of IDs */
- $results = $this->searchController->getResultSet();
-
- /* Get templates to use */
- $template = $this->searchController->fetchTemplates();
-
- /* Fetch sort details */
- $sortDropDown = $this->searchController->fetchSortDropDown();
-
- /* Set default sort option */
- $_a = IPSSearchRegistry::get('in.search_app');
- $_k = IPSSearchRegistry::get( $_a . '.searchInKey') ? IPSSearchRegistry::get( $_a . '.searchInKey') : '';
-
- if( $_k AND !$this->request['search_app_filters'][ $_a ][ $_k ]['sortKey'] AND is_array($sortDropDown) )
- {
- $this->request['search_app_filters'][ $_a ][ $_k ]['sortKey'] = key( $sortDropDown );
- }
- else if( !$_k AND !$this->request['search_app_filters'][ $_a ]['sortKey'] AND is_array($sortDropDown) )
- {
- $this->request['search_app_filters'][ $_a ]['sortKey'] = key( $sortDropDown );
- }
-
- /* Fetch sort details */
- $sortIn = $this->searchController->fetchSortIn();
-
- /* Reset for template */
- $this->_resetRequestParameters();
-
- /* Parse result set */
- $results = $this->registry->output->getTemplate( $template['group'] )->$template['template']( $results, ( IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ) ? 1 : 0 );
-
- /* Build pagination */
- $links = $this->registry->output->generatePagination( array( 'totalItems' => $count,
- 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'),
- 'currentStartValue' => IPSSearchRegistry::get('in.start'),
- 'baseUrl' => 'app=core&module=search&do=user_activity&mid=' . $id . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '&userMode=' . IPSSearchRegistry::get('in.userMode') . '&sid=' . $this->request['_sid'] . $this->_returnSearchAppFilters() ) );
- }
- else
- {
- $count = 0;
- $results = array();
- }
-
- $this->title = sprintf( $this->lang->words['s_participation_title'], $member['members_display_name'] );
- $this->registry->output->addNavigation( $this->title, '' );
- $this->output .= $this->registry->output->getTemplate( 'search' )->userPostsView( $results, $links, $count, $member, IPSSearchRegistry::get('set.hardLimit'), IPSSearchRegistry::get('set.resultsCutToLimit'), $beginStamp, $sortIn, $sortDropDown );
- }
-
- /**
- * View new posts since your last visit
- *
- * @return @e void
- */
- public function viewNewContent()
- {
- IPSSearchRegistry::set('in.search_app', $this->request['search_app'] );
-
- /* Fetch member cache to see if we have a value set */
- $vncPrefs = IPSMember::getFromMemberCache( $this->memberData, 'vncPrefs' );
-
- /* Guests */
- if ( ! $this->memberData['member_id'] AND ( ! $this->request['period'] OR $this->request['period'] == 'unread' ) )
- {
- $this->request['period'] = 'today';
- }
-
- /* In period */
- if ( $vncPrefs === null OR ! isset( $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['view'] ) OR ( ! empty( $this->request['period'] ) AND isset( $this->request['change'] ) ) )
- {
- $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['view'] = ( ! empty( $this->request['period'] ) ) ? $this->request['period'] : $this->settings['default_vnc_method'];
- }
-
- /* Follow filter enabled */
- if ( $vncPrefs === null OR ! isset( $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['view'] ) OR isset( $this->request['followedItemsOnly'] ) )
- {
- $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['vncFollowFilter'] = ( ! empty( $this->request['followedItemsOnly'] ) ) ? 1 : 0;
- }
-
- /* Filtering VNC by forum? */
- IPSSearchRegistry::set('forums.vncForumFilters', $vncPrefs['forums']['vnc_forum_filter'] );
-
- /* Set period up */
- IPSSearchRegistry::set('in.period' , $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['view'] );
- IPSSearchRegistry::set('in.vncFollowFilterOn', $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['vncFollowFilter'] );
-
- $this->request['userMode'] = !empty($this->request['userMode']) ? $this->request['userMode'] : '';
- IPSSearchRegistry::set('in.userMode' , $this->request['userMode'] );
-
- /* Update member cache */
- if ( isset( $this->request['period'] ) AND isset( $this->request['change'] ) )
- {
- IPSMember::setToMemberCache( $this->memberData, array( 'vncPrefs' => $vncPrefs ) );
- }
-
- IPSDebug::addMessage( var_export( $vncPrefs, true ) );
- IPSDebug::addMessage( 'Using: ' . IPSSearchRegistry::get('in.period') );
-
- /* Can we do this? */
- if ( IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'vnc' ) || IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'active' ) )
- {
- /* Can't do a specific unread search, so */
- if ( IPSSearchRegistry::get('in.period') == 'unread' && ! IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'vncWithUnreadContent' ) )
- {
- IPSSearchRegistry::set( 'in.period', 'lastvisit' );
- }
-
- /* Perform the search */
- $this->searchController->viewNewContent();
-
- /* Get count */
- $count = $this->searchController->getResultCount();
-
- /* Get results which will be array of IDs */
- $results = $this->searchController->getResultSet();
-
- /* Get templates to use */
- $template = $this->searchController->fetchTemplates();
-
- /* Fetch sort details */
- $sortDropDown = $this->searchController->fetchSortDropDown();
-
- /* Fetch sort details */
- $sortIn = $this->searchController->fetchSortIn();
-
- /* Reset for template */
- $this->_resetRequestParameters();
-
- if( IPSSearchRegistry::get('in.start') > 0 AND !count($results) )
- {
- $new_url = 'app=core&module=search&do=viewNewContent&period=' . IPSSearchRegistry::get('in.period') . '&userMode=' . IPSSearchRegistry::get('in.userMode') . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '&sid=' . $this->request['_sid'];
- $new_url .= '&st=' . ( IPSSearchRegistry::get('in.start') - IPSSearchRegistry::get('opt.search_per_page') ) . '&search_app_filters[' . IPSSearchRegistry::get('in.search_app') . '][searchInKey]=' . $this->request['search_app_filters'][ IPSSearchRegistry::get('in.search_app') ]['searchInKey'];
-
- $this->registry->output->silentRedirect( $this->settings['base_url'] . $new_url );
- }
-
- /* Parse result set */
- $results = $this->registry->output->getTemplate( $template['group'] )->$template['template']( $results, ( IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ) ? 1 : 0 );
-
- /* Build pagination */
- $links = $this->registry->output->generatePagination( array( 'totalItems' => $count,
- 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'),
- 'currentStartValue' => IPSSearchRegistry::get('in.start'),
- //'method' => 'nextPrevious',
- 'baseUrl' => 'app=core&module=search&do=viewNewContent&period=' . IPSSearchRegistry::get('in.period') . '&userMode=' . IPSSearchRegistry::get('in.userMode') . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '&sid=' . $this->request['_sid'] . $this->_returnSearchAppFilters() ) );
-
- /* Showing */
- $showing = array( 'start' => IPSSearchRegistry::get('in.start') + 1, 'end' => ( IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') ) > $count ? $count : IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') );
- }
- else
- {
- $count = 0;
- $results = array();
- }
-
- /* Add Debug message */
- IPSDebug::addMessage( "View New Content Matches: " . $count );
-
- /* Check for sortIn */
- if( count( $sortIn ) && !$this->request['search_app_filters'][ $this->request['search_app'] ]['searchInKey'] )
- {
- $this->request['search_app_filters'][ $this->request['search_app'] ]['searchInKey'] = $sortIn[0][0];
- }
-
- /* Output */
- $this->title = $this->lang->words['new_posts_title'];
- $this->registry->output->addNavigation( $this->lang->words['new_posts_title'], '' );
- $this->output .= $this->registry->output->getTemplate( 'search' )->newContentView( $results, $links, $count, $sortDropDown, $sortIn, IPSSearchRegistry::get('set.resultCutToDate') );
- }
-
-
- /**
- * Returns a url string that will maintain search results via links
- *
- * @return string
- */
- protected function _buildURLString()
- {
- /* INI */
- $url_string = 'app=core&module=search&do=search&andor_type=' . $this->request['andor_type'];
- $url_string .= '&sid=' . $this->request['_sid'];
-
- /* Add author name */
- if( !empty( $this->request['search_author'] ) )
- {
- $url_string .= "&search_author=" . urlencode($this->request['search_author']);
- }
-
- /* Search Range */
- if( !empty( $this->request['search_date_start'] ) )
- {
- $url_string .= "&search_date_start={$this->request['search_date_start']}";
- }
-
- if( !empty( $this->request['search_date_end'] ) )
- {
- $url_string .= "&search_date_end={$this->request['search_date_end']}";
- }
-
- if( !empty( $this->request['search_app_filters'][ $this->request['search_app'] ]['sortKey'] ) )
- {
- $url_string .= "&search_app_filters[{$this->request['search_app']}][sortKey]=" . $this->request['search_app_filters'][ $this->request['search_app'] ]['sortKey'];
- }
-
- if( !empty( $this->request['search_app_filters'][ $this->request['search_app'] ]['sortDir'] ) )
- {
- $url_string .= "&search_app_filters[{$this->request['search_app']}][sortDir]=" . $this->request['search_app_filters'][ $this->request['search_app'] ]['sortDir'];
- }
-
- /* Contextual Type */
- if ( IPSSearchRegistry::get('contextual.type') )
- {
- $url_string .= "&cType=" . IPSSearchRegistry::get('contextual.type') . "&cId=" . IPSSearchRegistry::get('contextual.id');
- }
-
- /* Content Only */
- if( !empty( $this->request['search_content'] ) )
- {
- $url_string .= "&search_content=" . $this->request['search_content'];
- }
-
- if ( IPSSearchRegistry::get('in.raw_search_tags') )
- {
- $url_string .= "&search_tags=" . urlencode( IPSSearchRegistry::get('in.raw_search_tags') );
- }
-
- /* Types */
- if( isset( $this->request['type'] ) && isset( $this->request['type_id'] ) )
- {
- $url_string .= "&type={$this->request['type']}&type_id={$this->request['type_id']}";
- }
-
- if( isset( $this->request['type_2'] ) && isset( $this->request['type_id_2'] ) )
- {
- $url_string .= "&type_2={$this->request['type_2']}&type_id_2={$this->request['type_id_2']}";
- }
-
- $url_string .= $this->_returnSearchAppFilters();
-
- /* Fix up the search term a bit */
- $_search_term = str_replace( '&', '&', $this->request['search_term'] );
- $_search_term = str_replace( '"', '"', $_search_term );
- $_search_term = str_replace( '>', '>', $_search_term );
- $_search_term = str_replace( '<', '<', $_search_term );
- $_search_term = str_replace( '$', '$', $_search_term );
-
- $url_string .= '&search_term=' . urlencode( $_search_term );
-
- return $url_string;
- }
-
- /**
- * Return search app filters
- *
- * @return @e string
- */
- protected function _returnSearchAppFilters()
- {
- $url_string = '';
-
- if( isset($this->request['search_app_filters']) AND $this->request['search_app_filters'] )
- {
- foreach( $this->request['search_app_filters'] as $app => $filters )
- {
- if( $app == $this->request['search_app'] AND count($filters) )
- {
- foreach( $filters as $_filterKey => $_filterValue )
- {
- if( is_array($_filterValue) )
- {
- foreach( $_filterValue as $_filterValueKey => $_filterValueValue )
- {
- $url_string .= "&search_app_filters[{$app}][{$_filterKey}][{$_filterValueKey}]={$_filterValueValue}";
- }
- }
- else
- {
- $url_string .= "&search_app_filters[{$app}][{$_filterKey}]={$_filterValue}";
- }
- }
- }
- }
- }
-
- return $url_string;
- }
-
- /**
- * Checks to see if the logged in user is allowed to use the search system
- *
- * @return @e void
- */
- protected function _canSearch()
- {
- /* Check the search setting */
- if( ! $this->settings['allow_search'] )
- {
- if( $this->xml_out )
- {
- @header( "Content-type: text/html;charset={$this->settings['gb_char_set']}" );
- print $this->lang->words['search_off'];
- exit();
- }
- else
- {
- $this->registry->output->showError( 'search_off', 10145 );
- }
- }
-
- /* Check the member authorization */
- if( ! isset( $this->memberData['g_use_search'] ) || ! $this->memberData['g_use_search'] )
- {
- /* Is it a bot and we're looking for tags? */
- if ( $this->member->is_not_human && ( $this->request['do'] == 'search' && ! empty( $this->request['search_tags'] ) ) )
- {
- return true;
- }
- else
- {
- if( $this->xml_out )
- {
- @header( "Content-type: text/html;charset={$this->settings['gb_char_set']}" );
- print $this->lang->words['no_xml_permission'];
- exit();
- }
- else
- {
- $this->registry->output->showError( 'no_permission_to_search', 10146, null, null, 403 );
- }
- }
- }
- }
-
- /**
- * Resets params for template
- */
- protected function _resetRequestParameters()
- {
- $this->request['period'] = IPSSearchRegistry::get('in.period');
- $this->request['real_period'] = IPSSearchRegistry::get('in.real_period');
- $this->request['search_app'] = IPSSearchRegistry::get('in.search_app');
- $this->request['vncFollowFilterOn'] = IPSSearchRegistry::get('in.vncFollowFilterOn');
- $this->request['followedItemsOnly'] = IPSSearchRegistry::get('in.vncFollowFilterOn');
- }
-
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Global Search
+ * Last Updated: $Date: 2013-03-20 10:14:51 -0400 (Wed, 20 Mar 2013) $
+ *
+ *
+ * @author $Author: mmecham $
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @package IP.Board
+ * @subpackage Core
+ * @link http://www.invisionpower.com
+ * @version $Rev: 12094 $
+ */
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class public_core_search_search extends ipsCommand
+{
+ /**
+ * Generated output
+ *
+ * @var string
+ */
+ protected $output = '';
+
+ /**
+ * Page Title
+ *
+ * @var string
+ */
+ protected $title = '';
+
+ /**
+ * Object to handle searches
+ *
+ * @var string
+ */
+ protected $search_plugin = '';
+
+ /**
+ * Topics array
+ *
+ * @var array
+ */
+ protected $_topicArray = array();
+ protected $_removedTerms = array();
+
+ /**
+ * Search controller
+ *
+ * @var obj
+ */
+ protected $searchController;
+ protected $_session;
+
+ /**
+ * Class entry point
+ *
+ * @param object Registry reference
+ * @return @e void [Outputs to screen/redirects]
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Load language */
+ $this->registry->class_localization->loadLanguageFile( array( 'public_search' ), 'core' );
+ $this->registry->class_localization->loadLanguageFile( array( 'public_forums', 'public_topic' ), 'forums' );
+
+ /* Reset engine type */
+ $this->settings['search_method'] = ( $this->settings['search_method'] == 'traditional' ) ? 'sql' : $this->settings['search_method'];
+
+ /* Force SQL for view new content? */
+ if ( ! empty( $this->settings['force_sql_vnc'] ) && $this->request['do'] == 'viewNewContent' )
+ {
+ $this->settings['search_method'] = 'sql';
+ }
+
+ $this->request['search_app_filters'] = $this->_cleanInputFilters( $this->request['search_app_filters'] );
+
+ /* Special consideration for contextual search */
+ if ( isset( $this->request['search_app'] ) AND strstr( $this->request['search_app'], ':' ) )
+ {
+ list( $app, $type, $id ) = explode( ':', $this->request['search_app'] );
+
+ $this->request['search_app'] = $app;
+ $this->request['cType'] = $type;
+ $this->request['cId'] = $id;
+ }
+ else
+ {
+ /* Force forums as default search */
+ $this->request['search_in'] = ( $this->request['search_in'] AND IPSLib::appIsSearchable( $this->request['search_in'], 'search' ) ) ? $this->request['search_in'] : 'forums';
+ $this->request['search_app'] = $this->request['search_app'] ? $this->request['search_app'] : $this->request['search_in'];
+ }
+
+ /* Check Access */
+ $this->_canSearch();
+
+ /* Start session - needs to be called before the controller is initiated */
+ $this->_startSession();
+
+ /* Load the controller */
+ $classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH. 'sources/classes/search/controller.php', 'IPSSearch' );
+
+ /* Sanitzie */
+ if ( ! is_string( $this->request['search_app'] ) )
+ {
+ $this->request['search_app'] = 'forums';
+ }
+
+ try
+ {
+ $this->searchController = new $classToLoad( $registry, $this->settings['search_method'], $this->request['search_app'] );
+ }
+ catch( Exception $error )
+ {
+ $msg = $error->getMessage();
+
+ /* Start session */
+ $this->_endSession();
+
+ switch( $msg )
+ {
+ case 'NO_SUCH_ENGINE':
+ case 'NO_SUCH_APP':
+ case 'NO_SUCH_APP_ENGINE':
+ $this->registry->output->showError( sprintf( $this->lang->words['no_search_app'], ipsRegistry::$applications[ $this->request['search_app'] ]['app_title'] ), 10145.1 );
+ break;
+ }
+ }
+
+ /* Log type */
+ IPSDebug::addMessage( "Search type: " . $this->settings['search_method'] );
+
+ /* Set up some defaults */
+ IPSSearchRegistry::set('opt.noPostPreview', false );
+ IPSSearchRegistry::set('in.start', intval( $this->request['st'] ) );
+ IPSSearchRegistry::set('opt.search_per_page', intval( $this->settings['search_per_page'] ) ? intval( $this->settings['search_per_page'] ) : 25 );
+
+ $this->settings['search_ucontent_days'] = ( $this->settings['search_ucontent_days'] ) ? $this->settings['search_ucontent_days'] : 365;
+
+ /* Contextuals */
+ if ( isset( $this->request['cType'] ) )
+ {
+ IPSSearchRegistry::set('contextual.type', $this->request['cType'] );
+ IPSSearchRegistry::set('contextual.id' , $this->request['cId'] );
+ }
+
+
+
+ /* What to do */
+ switch( $this->request['do'] )
+ {
+ case 'user_activity':
+ $this->viewUserContent();
+ break;
+
+ case 'new_posts':
+ case 'viewNewContent':
+ case 'active':
+ $this->viewNewContent();
+ break;
+
+ case 'search':
+ case 'quick_search':
+ $this->searchResults();
+ break;
+
+ case 'followed':
+ $this->viewFollowedContent();
+ break;
+
+ case 'manageFollowed':
+ $this->updateFollowedContent();
+ break;
+
+ default:
+ case 'search_form':
+ $this->searchAdvancedForm();
+ break;
+ }
+
+ /* Start session */
+ $this->_endSession();
+
+ /* If we have any HTML to print, do so... */
+ if ( $this->request['do'] == 'search' && ! empty( $this->request['search_tags'] ) )
+ {
+ $this->registry->output->setTitle( IPSText::urldecode_furlSafe( $this->request['search_tags'] ) . ' - ' . $this->lang->words['st_tags'] . ' - ' . IPSLib::getAppTitle( $this->request['search_app'] ) . ' - ' . ipsRegistry::$settings['board_name'] );
+
+ /* Add canonical tag */
+ $extra = ( $this->request['st'] ) ? '&st=' . $this->request['st'] : '';
+ $this->registry->output->addCanonicalTag( 'app=core&module=search&do=search&search_tags=' . IPSText::urlencode_furlSafe( $this->request['search_tags'] ) . '&search_app=' . $this->request['search_app']. $extra, $this->request['search_tags'], 'tags' );
+ }
+ else
+ {
+ $this->registry->output->setTitle( $this->title . ' - ' . ipsRegistry::$settings['board_name'] );
+ }
+
+ $this->registry->output->addContent( $this->output );
+ $this->registry->output->sendOutput();
+ }
+
+ /**
+ * Moderate your list of liked content
+ *
+ * @author bfarber
+ * @return string HTML to display
+ */
+ public function updateFollowedContent()
+ {
+ IPSSearchRegistry::set( 'in.search_app', $this->request['search_app'] );
+
+ //-----------------------------------------
+ // Get the likes we selected
+ //-----------------------------------------
+
+ $_likes = array();
+
+ if( is_array($this->request['likes']) AND count($this->request['likes']) )
+ {
+ foreach( $this->request['likes'] as $_like )
+ {
+ $_thisLike = explode( '-', $_like );
+ $_likes[] = array(
+ 'app' => $_thisLike[0],
+ 'area' => $_thisLike[1],
+ 'id' => $_thisLike[2],
+ );
+ }
+ }
+
+ //-----------------------------------------
+ // Got any?
+ //-----------------------------------------
+
+ if( !count($_likes) OR !is_array($_likes) )
+ {
+ return $this->viewFollowedContent( $this->lang->words['no_likes_for_del'] );
+ }
+
+ //-----------------------------------------
+ // Get like helper class
+ //-----------------------------------------
+
+ $bootstraps = array();
+
+ require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
+
+ //-----------------------------------------
+ // Loop over and moderate
+ //-----------------------------------------
+
+ foreach( $_likes as $_like )
+ {
+ $_bootstrap = classes_like::bootstrap( $_like['app'], $_like['area'] );
+ $_likeKey = classes_like_registry::getKey( $_like['id'], $this->memberData['member_id'] );
+ $_frequencies = $_bootstrap->allowedFrequencies();
+
+ //-----------------------------------------
+ // What action to take?
+ //-----------------------------------------
+
+ switch( $this->request['modaction'] )
+ {
+ case 'delete':
+ $_bootstrap->remove( $_like['id'], $this->memberData['member_id'] );
+ break;
+
+ case 'change-donotify':
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'immediate' ), "like_id='" . addslashes($_likeKey) . "'" );
+ break;
+
+ case 'change-donotnotify':
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 0 ), "like_id='" . addslashes($_likeKey) . "'" );
+ break;
+
+ case 'change-immediate':
+ if( in_array( 'immediate', $_frequencies ) )
+ {
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'immediate' ), "like_id='" . addslashes($_likeKey) . "'" );
+ }
+ break;
+
+ case 'change-offline':
+ if( in_array( 'offline', $_frequencies ) )
+ {
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'offline' ), "like_id='" . addslashes($_likeKey) . "'" );
+ }
+ break;
+
+ case 'change-daily':
+ if( in_array( 'daily', $_frequencies ) )
+ {
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'daily' ), "like_id='" . addslashes($_likeKey) . "'" );
+ }
+ break;
+
+ case 'change-weekly':
+ if( in_array( 'weekly', $_frequencies ) )
+ {
+ $this->DB->update( 'core_like', array( 'like_notify_do' => 1, 'like_notify_freq' => 'weekly' ), "like_id='" . addslashes($_likeKey) . "'" );
+ }
+ break;
+
+ case 'change-anon':
+ $this->DB->update( 'core_like', array( 'like_is_anon' => 1 ), "like_id='" . addslashes($_likeKey) . "'" );
+ break;
+
+ case 'change-noanon':
+ $this->DB->update( 'core_like', array( 'like_is_anon' => 0 ), "like_id='" . addslashes($_likeKey) . "'" );
+ break;
+ default:
+ return $this->viewFollowedContent( $this->lang->words['likes_no_action'] );
+ break;
+ }
+ }
+
+ $this->registry->getClass('output')->silentRedirect( $this->settings['base_url']."app=core&module=search&do=followed&search_app={$this->request['search_app']}&contentType={$this->request['contentType']}&confirm=1" );
+ }
+
+ /**
+ * View content you are following
+ *
+ * @author Brandon Farber
+ * @param string $error Error message
+ * @return @e void
+ */
+ public function viewFollowedContent( $error='' )
+ {
+ IPSSearchRegistry::set( 'in.search_app', $this->request['search_app'] );
+ IPSSearchRegistry::set( 'opt.searchType', 'titles' );
+ IPSSearchRegistry::set( 'opt.noPostPreview', true );
+
+ $results = array();
+ $formatted = array();
+ $count = 0;
+
+ //-----------------------------------------
+ // Determine content type
+ //-----------------------------------------
+
+ $contentTypes = IPSSearchRegistry::get('config.followContentTypes');
+
+ //-----------------------------------------
+ // Verify likes are available
+ //-----------------------------------------
+
+ if( count( IPSLib::getEnabledApplications('like') ) AND count( $contentTypes ) AND IPSLib::appIsInstalled( IPSSearchRegistry::get('in.search_app'), true ) )
+ {
+ //-----------------------------------------
+ // What content type?
+ //-----------------------------------------
+
+ $_type = '';
+
+ if( $this->request['contentType'] AND in_array( $this->request['contentType'], $contentTypes ) )
+ {
+ $_type = $this->request['contentType'];
+ }
+ else
+ {
+ $_type = $contentTypes[0];
+ }
+
+ $this->request['contentType'] = $_type;
+
+ IPSSearchRegistry::set( 'in.followContentType', $this->request['contentType'] );
+
+ /* Fetch like class */
+ try
+ {
+ require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
+ $this->_like = classes_like::bootstrap( IPSSearchRegistry::get('in.search_app'), $_type );
+ }
+ catch ( Exception $e)
+ {
+ /* Fail safe... */
+ $this->registry->output->addNavigation( $this->lang->words['followed_ct_title'], '' );
+ $this->title = $this->lang->words['followed_ct_title'];
+ $this->output .= $this->registry->output->getTemplate( 'search' )->followedContentView( array(), '', 0, $error, $contentTypes );
+ }
+
+ /* Do we have some custom join and sort data? */
+ if ( method_exists( $this->_like, 'getSearchJoinAndSortBy' ) )
+ {
+ $custom = $this->_like->getSearchJoinAndSortBy();
+
+ $countQ = array( 'select' => 'COUNT(*) as er',
+ 'from' => array( 'core_like' => 'l' ),
+ 'where' => 'like_member_id=' . $this->memberData['member_id'] . " AND like_visible=1 AND like_app='" . IPSSearchRegistry::get('in.search_app') . "' AND like_area='" . $_type . "'" );
+ if ( $custom['from'] )
+ {
+ $countQ['add_join'][] = array( 'from' => $custom['from'], 'where' => $custom['where'] );
+ }
+ if ( $custom['order'] )
+ {
+ $countQ['order'] = $custom['order'] . ' DESC';
+ }
+ if ( $custom['extraWhere'] )
+ {
+ $countQ['where'] .= ' AND ' . $custom['extraWhere'];
+ }
+ $count = $this->DB->buildAndFetch( $countQ );
+ $count = $count['er'];
+
+ $q = array( 'select' => 'l.*',
+ 'from' => array('core_like' => 'l'),
+ 'where' => 'l.like_member_id=' . $this->memberData['member_id'] . " AND l.like_visible=1 AND l.like_app='" . IPSSearchRegistry::get('in.search_app') . "' AND l.like_area='" . $_type . "'",
+ 'limit' => array( IPSSearchRegistry::get('in.start'), IPSSearchRegistry::get('opt.search_per_page') ),
+ 'order' => 'like_added DESC'
+ );
+
+ if ( $custom['from'] )
+ {
+ $q['add_join'][] = array( 'from' => $custom['from'], 'where' => $custom['where'] );
+ }
+ if ( $custom['order'] )
+ {
+ $q['order'] = $custom['order'] . ' DESC';
+ }
+ if ( $custom['extraWhere'] )
+ {
+ $q['where'] .= ' AND ' . $custom['extraWhere'];
+ }
+
+ $this->DB->build( $q );
+ }
+ else
+ {
+ $count = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as er',
+ 'from' => 'core_like',
+ 'where' => 'like_member_id=' . $this->memberData['member_id'] . " AND like_visible=1 AND like_app='" . IPSSearchRegistry::get('in.search_app') . "' AND like_area='" . $_type . "'" ) );
+ $count = $count['er'];
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'core_like',
+ 'where' => 'like_member_id=' . $this->memberData['member_id'] . " AND like_visible=1 AND like_app='" . IPSSearchRegistry::get('in.search_app') . "' AND like_area='" . $_type . "'",
+ 'limit' => array( IPSSearchRegistry::get('in.start'), IPSSearchRegistry::get('opt.search_per_page') ),
+ 'order' => 'like_added DESC' ) );
+ }
+
+ $outer = $this->DB->execute();
+
+ while( $r = $this->DB->fetch($outer) )
+ {
+ $results[] = $r['like_rel_id'];
+
+ $formatted[ $r['like_id'] ] = $r;
+ }
+
+ /* Process */
+ $results = $this->searchController->fetchFollowedContentOutput( $results, $formatted );
+
+ $pages = $this->registry->getClass('output')->generatePagination( array( 'totalItems' => $count,
+ 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'),
+ 'currentStartValue' => IPSSearchRegistry::get('in.start'),
+ 'baseUrl' => "app=core&module=search&do=followed&search_app=" . IPSSearchRegistry::get('in.search_app') . '&sid=' . $this->request['_sid'] . "&contentType=" . $this->request['contentType'] ) );
+ }
+ else
+ {
+ $count = 0;
+ $results = array();
+ }
+
+ /* Output */
+ $this->registry->output->addNavigation( $this->lang->words['followed_ct_title'], '' );
+ $this->title = $this->lang->words['followed_ct_title'];
+ $this->output .= $this->registry->output->getTemplate( 'search' )->followedContentView( $results, $pages, $count, $error, $contentTypes );
+ }
+
+ /**
+ * Builds the advanced search form
+ *
+ * @param string Message
+ * @return @e void
+ */
+ public function searchAdvancedForm( $msg='', $removed_search_terms=array() )
+ {
+ /* Set up data */
+ IPSSearchRegistry::set('view.search_form', true );
+
+ /* Get any application specific filters */
+ $appHtml = $this->searchController->getHtml();
+ $isBoolean = $this->searchController->isBoolean();
+ $tagSupport = $this->searchController->getTagSupport();
+
+ /* Output */
+ $this->title = $this->lang->words['search_form'];
+ $this->registry->output->addNavigation( $this->lang->words['search_form'], '' );
+ $this->output .= $this->registry->output->getTemplate( 'search' )->searchAdvancedForm( $appHtml, $msg, $this->request['search_app'], $removed_search_terms, $isBoolean, $tagSupport );
+ }
+
+ /**
+ * Processes a search request
+ *
+ * @return @e void
+ */
+ public function searchResults()
+ {
+ /* Search Term */
+ if( isset( $this->request['search_term'] ) && !is_string( $this->request['search_term'] ) )
+ {
+ $this->registry->getClass('output')->showError( 'invalid_search_term', 10312564 );
+ }
+
+ $_st = $this->searchController->formatSearchTerm( trim( $this->request['search_term'] ) );
+ $search_term = $_st['search_term'];
+ $removedTerms = $_st['removed'];
+
+ /* Set up some defaults */
+ $this->settings['max_search_word'] = $this->settings['max_search_word'] ? $this->settings['max_search_word'] : 300;
+
+ /* Did we come in off a post request? */
+ if ( $this->request['request_method'] == 'post' )
+ {
+ /* Set a no-expires header */
+ $this->registry->getClass('output')->setCacheExpirationSeconds( 30 * 60 );
+ }
+
+ if ( is_array( $this->request['search_app_filters'] ) )
+ {
+ array_walk_recursive( $this->request['search_app_filters'], create_function('&$item, $key', '$item = IPSText::htmlspecialchars($item);' ) );
+ }
+
+ /* App specific */
+ if ( isset( $this->request['search_sort_by_' . $this->request['search_app'] ] ) )
+ {
+ $this->request['search_sort_by'] = ( $_POST[ 'search_sort_by_' . $this->request['search_app'] ] ) ? htmlspecialchars( $_POST[ 'search_sort_by_' . $this->request['search_app'] ] ) : $this->request['search_sort_by_' . $this->request['search_app'] ];
+ $this->request['search_sort_order'] = ( $_POST[ 'search_sort_order_' . $this->request['search_app'] ] ) ? htmlspecialchars( $_POST[ 'search_sort_order_' . $this->request['search_app'] ] ) : $this->request['search_sort_order_' . $this->request['search_app'] ];
+ }
+
+ /* Populate the registry */
+ IPSSearchRegistry::set('in.search_app' , $this->request['search_app'] );
+ IPSSearchRegistry::set('in.raw_search_term' , trim( $this->request['search_term'] ) );
+ IPSSearchRegistry::set('in.clean_search_term', $search_term );
+ IPSSearchRegistry::set('in.raw_search_tags' , str_replace( '&', '&', trim( IPSText::parseCleanValue( IPSText::urldecode_furlSafe( $_REQUEST['search_tags'] ) ) ) ) );
+ IPSSearchRegistry::set('in.search_higlight' , str_replace( '.', '', $this->request['search_term'] ) );
+ IPSSearchRegistry::set('in.search_date_end' , ( $this->request['search_date_start'] && $this->request['search_date_end'] ) ? $this->request['search_date_end'] : 'now' );
+ IPSSearchRegistry::set('in.search_date_start', ( $this->request['search_date_start'] ) ? $this->request['search_date_start'] : '' );
+ IPSSearchRegistry::set('in.search_author' , !empty( $this->request['search_author'] ) ? $this->request['search_author'] : '' );
+
+ /* Set sort filters */
+ $this->_setSortFilters();
+
+ /* These can be overridden in the actual engine scripts */
+ // IPSSearchRegistry::set('set.hardLimit' , 0 );
+ IPSSearchRegistry::set('set.resultsCutToLimit', false );
+ IPSSearchRegistry::set('set.resultsAsForum' , false );
+
+ /* Are we option to show titles only / search in titles only */
+ IPSSearchRegistry::set('opt.searchType', ( !empty( $this->request['search_content'] ) AND in_array( $this->request['search_content'], array( 'both', 'titles', 'content' ) ) ) ? $this->request['search_content'] : 'both' );
+
+ /* Time check */
+ if ( IPSSearchRegistry::get('in.search_date_start') AND strtotime( IPSText::monthNameRu2En(IPSSearchRegistry::get('in.search_date_start')) ) > time() )
+ {
+ IPSSearchRegistry::set('in.search_date_start', 'now' );
+ }
+
+ if ( IPSSearchRegistry::get('in.search_date_end') AND strtotime( IPSText::monthNameRu2En(IPSSearchRegistry::get('in.search_date_end')) ) > time() )
+ {
+ IPSSearchRegistry::set('in.search_date_end', 'now' );
+ }
+
+ /* Do some date checking */
+ if( IPSSearchRegistry::get('in.search_date_end') AND IPSSearchRegistry::get('in.search_date_start') AND strtotime( IPSText::monthNameRu2En(IPSSearchRegistry::get('in.search_date_start')) ) > strtotime( IPSText::monthNameRu2En(IPSSearchRegistry::get('in.search_date_end')) ) )
+ {
+ $this->searchAdvancedForm( $this->lang->words['search_invalid_date_range'] );
+ return;
+ }
+
+ /**
+ * Lower limit
+ */
+ if ( $this->settings['min_search_word'] && ! IPSSearchRegistry::get('in.search_author') && ! IPSSearchRegistry::get('in.raw_search_tags') )
+ {
+ if ( $this->settings['search_method'] == 'sphinx' && substr_count( $search_term, '"' ) >= 2 )
+ {
+ $_ok = true;
+ }
+ else
+ {
+ $_words = explode( ' ', preg_replace( "#\"(.*?)\"#", '', $search_term ) );
+ $_ok = $search_term ? true : false;
+
+ foreach( $_words as $_word )
+ {
+ $_word = preg_replace( '#^\+(.+?)$#', "\\1", $_word );
+
+ if ( ! $_word OR $_word == '|' )
+ {
+ continue;
+ }
+
+ if( strlen( $_word ) < $this->settings['min_search_word'] )
+ {
+ $_ok = false;
+ break;
+ }
+ }
+ }
+
+ if( ! $_ok )
+ {
+ $this->searchAdvancedForm( sprintf( $this->lang->words['search_term_short'], $this->settings['min_search_word'] ), $removedTerms );
+ return;
+ }
+ }
+
+ /**
+ * Ok this is an upper limit.
+ * If you needed to change this, you could do so via conf_global.php by adding:
+ * $INFO['max_search_word'] = #####;
+ */
+ if ( $this->settings['max_search_word'] && strlen( IPSSearchRegistry::get('in.raw_search_term') ) > $this->settings['max_search_word'] )
+ {
+ $this->searchAdvancedForm( sprintf( $this->lang->words['search_term_long'], $this->settings['max_search_word'] ) );
+ return;
+ }
+
+ /* Search Flood Check */
+ if( $this->memberData['g_search_flood'] )
+ {
+ /* Check for a cookie */
+ $last_search = IPSCookie::get( 'sfc' );
+ $last_term = str_replace( """, '"', IPSCookie::get( 'sfct' ) );
+ $last_term = str_replace( "&", '&', $last_term );
+
+ /* If we have a last search time, check it */
+ if( $last_search && $last_term )
+ {
+ if( ( time() - $last_search ) <= $this->memberData['g_search_flood'] && $last_term != IPSSearchRegistry::get('in.raw_search_term') )
+ {
+ $this->searchAdvancedForm( sprintf( $this->lang->words['xml_flood'], $this->memberData['g_search_flood'] - ( time() - $last_search ) ) );
+ return;
+ }
+ else
+ {
+ /* Reset the cookie */
+ IPSCookie::set( 'sfc', time() );
+ IPSCookie::set( 'sfct', urlencode( IPSSearchRegistry::get('in.raw_search_term') ) );
+ }
+ }
+ /* Set the cookie */
+ else
+ {
+ IPSCookie::set( 'sfc', time() );
+ IPSCookie::set( 'sfct', urlencode( IPSSearchRegistry::get('in.raw_search_term') ) );
+ }
+ }
+
+ /* Clean search term for results view */
+ $_search_term = trim( preg_replace( '#(^|\s)(\+|\-|\||\~)#', " ", $search_term ) );
+
+ /* Got tag search only but app doesn't support tags */
+ if ( IPSSearchRegistry::get('in.raw_search_tags') && ! IPSSearchRegistry::get( 'config.can_searchTags' ) && ! IPSSearchRegistry::get('in.raw_search_term') )
+ {
+ $count = 0;
+ $results = array();
+ }
+ else if ( IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'search' ) )
+ {
+ /* Perform the search */
+ $this->searchController->search();
+
+ /* Get count */
+ $count = $this->searchController->getResultCount();
+
+ /* Get results which will be array of IDs */
+ $results = $this->searchController->getResultSet();
+
+ /* Get templates to use */
+ $template = $this->searchController->fetchTemplates();
+
+ /* Fetch sort details */
+ $sortDropDown = $this->searchController->fetchSortDropDown();
+
+ /* Set default sort option */
+ $_a = IPSSearchRegistry::get('in.search_app');
+ $_k = IPSSearchRegistry::get( $_a . '.searchInKey') ? IPSSearchRegistry::get( $_a . '.searchInKey') : '';
+
+ if( $_k AND !$this->request['search_app_filters'][ $_a ][ $_k ]['sortKey'] AND is_array($sortDropDown) AND count($sortDropDown) )
+ {
+ $this->request['search_app_filters'][ $_a ][ $_k ]['sortKey'] = key( $sortDropDown );
+ }
+ else if( !$_k AND !$this->request['search_app_filters'][ $_a ]['sortKey'] AND is_array($sortDropDown) AND count($sortDropDown) )
+ {
+ $this->request['search_app_filters'][ $_a ]['sortKey'] = key( $sortDropDown );
+ }
+
+ /* Fetch sort details */
+ $sortIn = $this->searchController->fetchSortIn();
+
+ /* Build pagination */
+ $links = $this->registry->output->generatePagination( array( 'totalItems' => $count,
+ 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'),
+ 'currentStartValue'=> IPSSearchRegistry::get('in.start'),
+ 'baseUrl' => $this->_buildURLString() . '&search_app=' . IPSSearchRegistry::get('in.search_app') ) );
+
+ /* Showing */
+ $showing = array( 'start' => IPSSearchRegistry::get('in.start') + 1, 'end' => ( IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') ) > $count ? $count : IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') );
+
+ /* Parse result set */
+ $results = $this->registry->output->getTemplate( $template['group'] )->$template['template']( $results, ( IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ) ? 1 : 0 );
+
+ /* Check for sortIn */
+ if( count( $sortIn ) && !$this->request['search_app_filters'][ $this->request['search_app'] ]['searchInKey'] )
+ {
+ $this->request['search_app_filters'][ $this->request['search_app'] ]['searchInKey'] = $sortIn[0][0];
+ }
+ }
+ else
+ {
+ $count = 0;
+ $results = array();
+ }
+
+ /* Output */
+ $this->title = $this->lang->words['search_results'];
+ $this->output .= $this->registry->output->getTemplate( 'search' )->searchResultsWrapper( $results, $sortDropDown, $sortIn, $links, $count, $showing, $_search_term, $this->_buildURLString(), $this->request['search_app'], $removedTerms, IPSSearchRegistry::get('set.hardLimit'), IPSSearchRegistry::get('set.resultsCutToLimit'), IPSSearchRegistry::get('in.raw_search_tags') );
+ }
+
+ /**
+ * Starts session
+ * Loads / creates a session based on activity
+ *
+ * @return
+ */
+ protected function _startSession()
+ {
+ $session_id = IPSText::md5Clean( $this->request['sid'] );
+ $requestType = ( $this->request['request_method'] == 'post' ) ? 'post' : 'get';
+
+ if ( $session_id )
+ {
+ /* We check on member id 'cos we can. Obviously guests will have a member ID of zero, but meh */
+ $this->_session = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'search_sessions',
+ 'where' => 'session_id=\'' . $session_id . '\' AND session_member_id=' . $this->memberData['member_id'] ) );
+ }
+
+ /* Deflate */
+ if ( $this->_session['session_id'] )
+ {
+ if ( $this->_session['session_data'] )
+ {
+ $this->_session['_session_data'] = unserialize( $this->_session['session_data'] );
+
+ if ( isset( $this->_session['_session_data']['search_app_filters'] ) )
+ {
+ $this->request['search_app_filters'] = is_array( $this->request['search_app_filters'] ) ? array_merge( $this->_session['_session_data']['search_app_filters'], $this->request['search_app_filters'] ) : $this->_session['_session_data']['search_app_filters'];
+ }
+ }
+
+ IPSDebug::addMessage( "Loaded search session: " . var_export( $this->_session['_session_data'], true ) . " " );
+ }
+ else
+ {
+ /* Create a session */
+ $this->_session = array( 'session_id' => md5( uniqid( microtime(), true ) ),
+ 'session_created' => time(),
+ 'session_updated' => time(),
+ 'session_member_id' => $this->memberData['member_id'],
+ 'session_data' => serialize( array( 'search_app_filters' => $this->request['search_app_filters'] ) ) );
+
+ $this->DB->insert( 'search_sessions', $this->_session );
+
+ $this->_session['_session_data']['search_app_filters'] = $this->request['search_app_filters'];
+
+ IPSDebug::addMessage( "Created search session: " . var_export( $this->_session['_session_data'], true ) . " " );
+ }
+
+ /* Do we have POST infos? */
+ if ( isset( $_POST['search_app_filters'] ) )
+ {
+ $this->_session['_session_data']['search_app_filters'] = ( is_array( $this->_session['_session_data']['search_app_filters'] ) ) ? IPSLib::arrayMergeRecursive( $this->_session['_session_data']['search_app_filters'], $_POST['search_app_filters'] ) : $_POST['search_app_filters'];
+ $this->request['search_app_filters'] = $this->_session['_session_data']['search_app_filters'];
+
+ IPSDebug::addMessage( "Updated filters: " . var_export( $_POST['search_app_filters'], true ) . " " );
+ }
+
+ /* Globalize the session ID */
+ $this->request['_sid'] = $this->_session['session_id'];
+ }
+
+ /**
+ * End the session
+ *
+ */
+ protected function _endSession()
+ {
+ if ( $this->_session['session_id'] )
+ {
+ $sd = array( 'session_updated' => time(),
+ 'session_data' => serialize( $this->_session['_session_data'] ) );
+
+ $this->DB->update( 'search_sessions', $sd, 'session_id=\'' . $this->_session['session_id'] . '\'' );
+ }
+
+ /* Delete old sessions */
+ $this->DB->delete( 'search_sessions', 'session_updated < ' . ( time() - 86400 ) );
+ }
+
+ /**
+ * Set the search order and key
+ *
+ * @return @e void
+ */
+ protected function _setSortFilters()
+ {
+ $app = $this->request['search_app'];
+ $key = 'date';
+ $dir = 'desc';
+ $dun = false;
+
+ /* multi search in options? */
+ if ( isset( $this->request['search_app_filters'][ $app ]['searchInKey'] ) )
+ {
+ $_k = $this->request['search_app_filters'][ $app ]['searchInKey'];
+
+ if ( isset( $this->request['search_app_filters'][ $app ][ $_k ]['sortKey'] ) )
+ {
+ $dun = true;
+ $key = $this->request['search_app_filters'][ $app ][ $_k ]['sortKey'];
+ $dir = $this->request['search_app_filters'][ $app ][ $_k ]['sortDir'];
+ }
+ }
+
+ /* Normal options - although sometimes used even with multiple types */
+ if ( ! $dun AND isset( $this->request['search_app_filters'][$app]['sortKey'] ) )
+ {
+ $key = $this->request['search_app_filters'][$app]['sortKey'];
+ $dir = $this->request['search_app_filters'][$app]['sortDir'];
+ }
+ /* Global */
+ else
+ {
+ if ( isset( $this->request['search_sort_by'] ) )
+ {
+ $key = $this->request['search_sort_by'];
+ $dir = $this->request['search_sort_order'];
+ }
+ }
+
+ /* Valid search key? */
+ if( !is_string( $key ) )
+ {
+ $this->registry->getClass('output')->showError( 'invalid_search_key', 10312565 );
+ }
+
+ /* Numeric? */
+ if ( is_numeric( $dir ) )
+ {
+ $dir = ( $dir == 0 ) ? 'desc' : 'asc';
+ }
+ else
+ {
+ $dir = 'desc';
+ }
+
+ IPSSearchRegistry::set('in.search_sort_by' , trim( $key ) );
+ IPSSearchRegistry::set('in.search_sort_order', ( $dir != 'desc' ) ? 'asc' : 'desc' );
+ }
+
+ /**
+ * Displays latest user content
+ *
+ * @return @e void
+ */
+ public function viewUserContent()
+ {
+
+ /* INIT */
+ $id = $this->request['mid'] ? intval( trim( $this->request['mid'] ) ) : $this->memberData['member_id'];
+
+ /* Save query if we are viewing our own content */
+ if( $this->memberData['member_id'] AND $id == $this->memberData['member_id'] )
+ {
+ $member = $this->memberData;
+ }
+ else
+ {
+ $member = IPSMember::load( $id, 'core' );
+ }
+
+ $beginStamp = 0;
+
+ if ( ! $member['member_id'] )
+ {
+ $this->registry->output->showError( 'search_invalid_id', 10147, null, null, 403 );
+ }
+
+ $this->request['userMode'] = !empty($this->request['userMode']) ? $this->request['userMode'] : 'all';
+
+ IPSSearchRegistry::set('in.search_app', $this->request['search_app'] );
+ IPSSearchRegistry::set('in.userMode' , $this->request['userMode'] );
+
+ /* Set sort filters */
+ $this->_setSortFilters();
+
+ /* Can we do this? */
+ if ( IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'usercontent' ) )
+ {
+ /* Perform the search */
+ $this->searchController->viewUserContent( $member );
+
+ /* Get count */
+ $count = $this->searchController->getResultCount();
+
+ /* Get results which will be array of IDs */
+ $results = $this->searchController->getResultSet();
+
+ /* Get templates to use */
+ $template = $this->searchController->fetchTemplates();
+
+ /* Fetch sort details */
+ $sortDropDown = $this->searchController->fetchSortDropDown();
+
+ /* Set default sort option */
+ $_a = IPSSearchRegistry::get('in.search_app');
+ $_k = IPSSearchRegistry::get( $_a . '.searchInKey') ? IPSSearchRegistry::get( $_a . '.searchInKey') : '';
+
+ if( $_k AND !$this->request['search_app_filters'][ $_a ][ $_k ]['sortKey'] AND is_array($sortDropDown) )
+ {
+ $this->request['search_app_filters'][ $_a ][ $_k ]['sortKey'] = key( $sortDropDown );
+ }
+ else if( !$_k AND !$this->request['search_app_filters'][ $_a ]['sortKey'] AND is_array($sortDropDown) )
+ {
+ $this->request['search_app_filters'][ $_a ]['sortKey'] = key( $sortDropDown );
+ }
+
+ /* Fetch sort details */
+ $sortIn = $this->searchController->fetchSortIn();
+
+ /* Reset for template */
+ $this->_resetRequestParameters();
+
+ /* Parse result set */
+ $results = $this->registry->output->getTemplate( $template['group'] )->$template['template']( $results, ( IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ) ? 1 : 0 );
+
+ /* Build pagination */
+ $links = $this->registry->output->generatePagination( array( 'totalItems' => $count,
+ 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'),
+ 'currentStartValue' => IPSSearchRegistry::get('in.start'),
+ 'baseUrl' => 'app=core&module=search&do=user_activity&mid=' . $id . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '&userMode=' . IPSSearchRegistry::get('in.userMode') . '&sid=' . $this->request['_sid'] . $this->_returnSearchAppFilters() ) );
+ }
+ else
+ {
+ $count = 0;
+ $results = array();
+ }
+
+ $this->title = sprintf( $this->lang->words['s_participation_title'], $member['members_display_name'] );
+ $this->registry->output->addNavigation( $this->title, '' );
+ $this->output .= $this->registry->output->getTemplate( 'search' )->userPostsView( $results, $links, $count, $member, IPSSearchRegistry::get('set.hardLimit'), IPSSearchRegistry::get('set.resultsCutToLimit'), $beginStamp, $sortIn, $sortDropDown );
+ }
+
+ /**
+ * View new posts since your last visit
+ *
+ * @return @e void
+ */
+ public function viewNewContent()
+ {
+
+ IPSSearchRegistry::set('in.search_app', $this->request['search_app'] );
+
+ /* Fetch member cache to see if we have a value set */
+ $vncPrefs = IPSMember::getFromMemberCache( $this->memberData, 'vncPrefs' );
+
+ /* Guests */
+ if ( ! $this->memberData['member_id'] AND ( ! $this->request['period'] OR $this->request['period'] == 'unread' ) )
+ {
+ $this->request['period'] = 'today';
+ }
+
+ /* In period */
+ if ( $vncPrefs === null OR ! isset( $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['view'] ) OR ( ! empty( $this->request['period'] ) AND isset( $this->request['change'] ) ) )
+ {
+ $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['view'] = ( ! empty( $this->request['period'] ) ) ? $this->request['period'] : $this->settings['default_vnc_method'];
+ }
+
+ /* Follow filter enabled */
+ if ( $vncPrefs === null OR ! isset( $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['view'] ) OR isset( $this->request['followedItemsOnly'] ) )
+ {
+ $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['vncFollowFilter'] = ( ! empty( $this->request['followedItemsOnly'] ) ) ? 1 : 0;
+ }
+
+ /* Filtering VNC by forum? */
+ IPSSearchRegistry::set('forums.vncForumFilters', $vncPrefs['forums']['vnc_forum_filter'] );
+
+ /* Set period up */
+ IPSSearchRegistry::set('in.period' , $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['view'] );
+ IPSSearchRegistry::set('in.vncFollowFilterOn', $vncPrefs[ IPSSearchRegistry::get('in.search_app') ]['vncFollowFilter'] );
+
+ $this->request['userMode'] = !empty($this->request['userMode']) ? $this->request['userMode'] : '';
+ IPSSearchRegistry::set('in.userMode' , $this->request['userMode'] );
+
+ /* Update member cache */
+ if ( isset( $this->request['period'] ) AND isset( $this->request['change'] ) )
+ {
+ IPSMember::setToMemberCache( $this->memberData, array( 'vncPrefs' => $vncPrefs ) );
+ }
+
+ IPSDebug::addMessage( var_export( $vncPrefs, true ) );
+ IPSDebug::addMessage( 'Using: ' . IPSSearchRegistry::get('in.period') );
+
+ /* Can we do this? */
+ if ( IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'vnc' ) || IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'active' ) )
+ {
+ /* Can't do a specific unread search, so */
+ if ( IPSSearchRegistry::get('in.period') == 'unread' && ! IPSLib::appIsSearchable( IPSSearchRegistry::get('in.search_app'), 'vncWithUnreadContent' ) )
+ {
+ IPSSearchRegistry::set( 'in.period', 'lastvisit' );
+ }
+
+ /* Perform the search */
+ $this->searchController->viewNewContent();
+
+ /* Get count */
+ $count = $this->searchController->getResultCount();
+
+ /* Get results which will be array of IDs */
+ $results = $this->searchController->getResultSet();
+
+ /* Get templates to use */
+ $template = $this->searchController->fetchTemplates();
+
+ /* Fetch sort details */
+ $sortDropDown = $this->searchController->fetchSortDropDown();
+
+ /* Fetch sort details */
+ $sortIn = $this->searchController->fetchSortIn();
+
+ /* Reset for template */
+ $this->_resetRequestParameters();
+
+ if( IPSSearchRegistry::get('in.start') > 0 AND !count($results) )
+ {
+ $new_url = 'app=core&module=search&do=viewNewContent&period=' . IPSSearchRegistry::get('in.period') . '&userMode=' . IPSSearchRegistry::get('in.userMode') . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '&sid=' . $this->request['_sid'];
+ $new_url .= '&st=' . ( IPSSearchRegistry::get('in.start') - IPSSearchRegistry::get('opt.search_per_page') ) . '&search_app_filters[' . IPSSearchRegistry::get('in.search_app') . '][searchInKey]=' . $this->request['search_app_filters'][ IPSSearchRegistry::get('in.search_app') ]['searchInKey'];
+
+ $this->registry->output->silentRedirect( $this->settings['base_url'] . $new_url );
+ }
+
+ /* Parse result set */
+ $results = $this->registry->output->getTemplate( $template['group'] )->$template['template']( $results, ( IPSSearchRegistry::get('opt.searchType') == 'titles' || IPSSearchRegistry::get('opt.noPostPreview') ) ? 1 : 0 );
+
+ /* Build pagination */
+ $links = $this->registry->output->generatePagination( array( 'totalItems' => $count,
+ 'itemsPerPage' => IPSSearchRegistry::get('opt.search_per_page'),
+ 'currentStartValue' => IPSSearchRegistry::get('in.start'),
+ //'method' => 'nextPrevious',
+ 'baseUrl' => 'app=core&module=search&do=viewNewContent&period=' . IPSSearchRegistry::get('in.period') . '&userMode=' . IPSSearchRegistry::get('in.userMode') . '&search_app=' . IPSSearchRegistry::get('in.search_app') . '&sid=' . $this->request['_sid'] . $this->_returnSearchAppFilters() ) );
+
+ /* Showing */
+ $showing = array( 'start' => IPSSearchRegistry::get('in.start') + 1, 'end' => ( IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') ) > $count ? $count : IPSSearchRegistry::get('in.start') + IPSSearchRegistry::get('opt.search_per_page') );
+ }
+ else
+ {
+ $count = 0;
+ $results = array();
+ }
+
+ /* Add Debug message */
+ IPSDebug::addMessage( "View New Content Matches: " . $count );
+
+ /* Check for sortIn */
+ if( count( $sortIn ) && !$this->request['search_app_filters'][ $this->request['search_app'] ]['searchInKey'] )
+ {
+ $this->request['search_app_filters'][ $this->request['search_app'] ]['searchInKey'] = $sortIn[0][0];
+ }
+
+ /* Output */
+ $this->title = $this->lang->words['new_posts_title'];
+ $this->registry->output->addNavigation( $this->lang->words['new_posts_title'], '' );
+ $this->output .= $this->registry->output->getTemplate( 'search' )->newContentView( $results, $links, $count, $sortDropDown, $sortIn, IPSSearchRegistry::get('set.resultCutToDate') );
+ }
+
+
+ /**
+ * Returns a url string that will maintain search results via links
+ *
+ * @return string
+ */
+ protected function _buildURLString()
+ {
+ /* INI */
+ $url_string = 'app=core&module=search&do=search&andor_type=' . $this->request['andor_type'];
+ $url_string .= '&sid=' . $this->request['_sid'];
+
+ /* Add author name */
+ if( !empty( $this->request['search_author'] ) )
+ {
+ $url_string .= "&search_author=" . urlencode($this->request['search_author']);
+ }
+
+ /* Search Range */
+ if( !empty( $this->request['search_date_start'] ) )
+ {
+ $url_string .= "&search_date_start={$this->request['search_date_start']}";
+ }
+
+ if( !empty( $this->request['search_date_end'] ) )
+ {
+ $url_string .= "&search_date_end={$this->request['search_date_end']}";
+ }
+
+ if( !empty( $this->request['search_app_filters'][ $this->request['search_app'] ]['sortKey'] ) )
+ {
+ $url_string .= "&search_app_filters[{$this->request['search_app']}][sortKey]=" . $this->request['search_app_filters'][ $this->request['search_app'] ]['sortKey'];
+ }
+
+ if( !empty( $this->request['search_app_filters'][ $this->request['search_app'] ]['sortDir'] ) )
+ {
+ $url_string .= "&search_app_filters[{$this->request['search_app']}][sortDir]=" . $this->request['search_app_filters'][ $this->request['search_app'] ]['sortDir'];
+ }
+
+ /* Contextual Type */
+ if ( IPSSearchRegistry::get('contextual.type') )
+ {
+ $url_string .= "&cType=" . IPSSearchRegistry::get('contextual.type') . "&cId=" . IPSSearchRegistry::get('contextual.id');
+ }
+
+ /* Content Only */
+ if( !empty( $this->request['search_content'] ) )
+ {
+ $url_string .= "&search_content=" . $this->request['search_content'];
+ }
+
+ if ( IPSSearchRegistry::get('in.raw_search_tags') )
+ {
+ $url_string .= "&search_tags=" . urlencode( IPSSearchRegistry::get('in.raw_search_tags') );
+ }
+
+ /* Types */
+ if( isset( $this->request['type'] ) && isset( $this->request['type_id'] ) )
+ {
+ $url_string .= "&type={$this->request['type']}&type_id={$this->request['type_id']}";
+ }
+
+ if( isset( $this->request['type_2'] ) && isset( $this->request['type_id_2'] ) )
+ {
+ $url_string .= "&type_2={$this->request['type_2']}&type_id_2={$this->request['type_id_2']}";
+ }
+
+ $url_string .= $this->_returnSearchAppFilters();
+
+ /* Fix up the search term a bit */
+ $_search_term = str_replace( '&', '&', $this->request['search_term'] );
+ $_search_term = str_replace( '"', '"', $_search_term );
+ $_search_term = str_replace( '>', '>', $_search_term );
+ $_search_term = str_replace( '<', '<', $_search_term );
+ $_search_term = str_replace( '$', '$', $_search_term );
+
+ $url_string .= '&search_term=' . urlencode( $_search_term );
+
+ return $url_string;
+ }
+
+ /**
+ * Return search app filters
+ *
+ * @return @e string
+ */
+ protected function _returnSearchAppFilters()
+ {
+ $url_string = '';
+
+ if( isset($this->request['search_app_filters']) AND $this->request['search_app_filters'] )
+ {
+ foreach( $this->request['search_app_filters'] as $app => $filters )
+ {
+ if( $app == $this->request['search_app'] AND is_array( $filters ) AND count($filters) )
+ {
+ foreach( $filters as $_filterKey => $_filterValue )
+ {
+ if( is_array($_filterValue) )
+ {
+ foreach( $_filterValue as $_filterValueKey => $_filterValueValue )
+ {
+ $url_string .= "&search_app_filters[{$app}][{$_filterKey}][{$_filterValueKey}]={$_filterValueValue}";
+ }
+ }
+ else
+ {
+ $url_string .= "&search_app_filters[{$app}][{$_filterKey}]={$_filterValue}";
+ }
+ }
+ }
+ }
+ }
+
+ return $url_string;
+ }
+
+ /**
+ * Checks to see if the logged in user is allowed to use the search system
+ *
+ * @return @e void
+ */
+ protected function _canSearch()
+ {
+ /* Check the search setting */
+ if( ! $this->settings['allow_search'] )
+ {
+ if( $this->xml_out )
+ {
+ @header( "Content-type: text/html;charset={$this->settings['gb_char_set']}" );
+ print $this->lang->words['search_off'];
+ exit();
+ }
+ else
+ {
+ $this->registry->output->showError( 'search_off', 10145 );
+ }
+ }
+
+ /* Check the member authorization */
+ if( ! isset( $this->memberData['g_use_search'] ) || ! $this->memberData['g_use_search'] )
+ {
+ /* Is it a bot and we're looking for tags? */
+ if ( $this->member->is_not_human && ( $this->request['do'] == 'search' && ! empty( $this->request['search_tags'] ) ) )
+ {
+ return true;
+ }
+ else
+ {
+ if( $this->xml_out )
+ {
+ @header( "Content-type: text/html;charset={$this->settings['gb_char_set']}" );
+ print $this->lang->words['no_xml_permission'];
+ exit();
+ }
+ else
+ {
+ $this->registry->output->showError( 'no_permission_to_search', 10146, null, null, 403 );
+ }
+ }
+ }
+ }
+
+ /**
+ * Clean search keys and values
+ */
+ protected function _cleanInputFilters( $filters )
+ {
+ if ( is_array( $filters ) )
+ {
+ foreach( $filters as $k => $v )
+ {
+ unset( $filters[ $k ] );
+
+ $k = IPSText::alphanumericalClean( $k );
+
+ if ( is_array( $v ) )
+ {
+ $filters[ $k ] = $this->_cleanInputFilters( $v );
+ }
+ else
+ {
+ $filters[ $k ] = IPSText::htmlspecialchars( $v );
+ }
+ }
+ }
+
+ return $filters;
+ }
+
+ /**
+ * Resets params for template
+ */
+ protected function _resetRequestParameters()
+ {
+ $this->request['period'] = IPSSearchRegistry::get('in.period');
+ $this->request['real_period'] = IPSSearchRegistry::get('in.real_period');
+ $this->request['search_app'] = IPSSearchRegistry::get('in.search_app');
+ $this->request['vncFollowFilterOn'] = IPSSearchRegistry::get('in.vncFollowFilterOn');
+ $this->request['followedItemsOnly'] = IPSSearchRegistry::get('in.vncFollowFilterOn');
+ }
+
+
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/modules_public/task/manualResolver.php b/upload/admin/applications/core/modules_public/task/manualResolver.php
index 799a005a..649c84ed 100644
--- a/upload/admin/applications/core/modules_public/task/manualResolver.php
+++ b/upload/admin/applications/core/modules_public/task/manualResolver.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Task Manager
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -13,7 +13,7 @@
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
- * @version $Rev: 10914 $
+ * @version $Rev: 10721 $
*
*/
diff --git a/upload/admin/applications/core/modules_public/usercp/manualResolver.php b/upload/admin/applications/core/modules_public/usercp/manualResolver.php
index 8a10bcf8..28fd0d32 100644
--- a/upload/admin/applications/core/modules_public/usercp/manualResolver.php
+++ b/upload/admin/applications/core/modules_public/usercp/manualResolver.php
@@ -3,9 +3,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* User control panel resolver
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-05-06 14:16:05 -0400 (Mon, 06 May 2013) $
*
*
* @author $Author: bfarber $
@@ -15,7 +15,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since 1st march 2002
- * @version $Revision: 10914 $
+ * @version $Revision: 12229 $
*/
if ( ! defined( 'IN_IPB' ) )
@@ -121,6 +121,12 @@ class public_core_usercp_manualResolver extends ipsCommand
}
$__class = IPSLib::loadLibrary( $ext_dir . '/usercpForms.php', 'usercpForms_' . $app_dir, $app_dir );
+
+ if( !class_exists($__class) )
+ {
+ continue;
+ }
+
$_usercp_module = new $__class();
/* Block based on version to prevent old files showing up/causing an error */
diff --git a/upload/admin/applications/core/setup/upgradeCheck.php b/upload/admin/applications/core/setup/upgradeCheck.php
index b817e914..bad82b82 100644
--- a/upload/admin/applications/core/setup/upgradeCheck.php
+++ b/upload/admin/applications/core/setup/upgradeCheck.php
@@ -3,16 +3,16 @@
*
* Invision Power Services
* IP.Board - requirements checker
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-21 09:09:36 -0400 (Mon, 21 May 2012) $
*
*
- * @author $Author: bfarber $ (Orginal: Mark)
+ * @author $Author: ips_terabyte $ (Orginal: Mark)
* @copyright (c) 2010 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @link http://www.invisionpower.com
* @since 8th September 2010
- * @version $Revision: 10914 $
+ * @version $Revision: 10771 $
*/
class core_upgradeCheck
@@ -61,7 +61,7 @@ class core_upgradeCheck
$appName = ipsRegistry::$applications[ $k ]['app_title'];
$allVersions = IPSSetUp::fetchXmlAppVersions( $k );
- return "The version of {$appName} you have installed will not work with this version of IP.Board. You must upgrade {$appName} to {$allVersions[ $v ]} or higher, or disable it in the Admin CP in order continue.";
+ return "Установленная версия {$appName} не будет работать с этой версией IP.Board. Вы должны обновить {$appName} версии {$allVersions[ $v ]} или выше, или отключить приложение в админцентре для продолжения.";
}
}
}
diff --git a/upload/admin/applications/core/setup/versions/install/sql/core_mysql_inserts.php b/upload/admin/applications/core/setup/versions/install/sql/core_mysql_inserts.php
index 0364f8c1..364475f4 100644
--- a/upload/admin/applications/core/setup/versions/install/sql/core_mysql_inserts.php
+++ b/upload/admin/applications/core/setup/versions/install/sql/core_mysql_inserts.php
@@ -48,24 +48,24 @@ $INSERT[] = "INSERT INTO emoticons (id, typed, image, clickable, emo_set, emo_po
$INSERT[] = "INSERT INTO pfields_data (pf_id, pf_title, pf_desc, pf_content, pf_type, pf_not_null, pf_member_hide, pf_max_input, pf_member_edit, pf_position, pf_show_on_reg, pf_input_format, pf_admin_only, pf_topic_format, pf_group_id, pf_icon, pf_key) VALUES
(1, 'AIM', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_aim.gif', 'aim'),
(2, 'MSN', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_msn.gif', 'msn'),
-(3, 'Website URL', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_website.gif', 'website'),
+(3, 'Сайт', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_website.gif', 'website'),
(4, 'ICQ', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_icq.gif', 'icq'),
-(5, 'Gender', '', 'u=Not Telling|m=Male|f=Female', 'drop', 0, 0, 0, 1, 0, 0, '', 0, '', 2, '', 'gender'),
-(6, 'Location', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '{title} {content} ', 2, '', 'location'),
-(7, 'Interests', '', '', 'textarea', 0, 0, 0, 1, 0, 0, '', 0, '', 2, '', 'interests'),
+(5, 'Пол', '', 'u=Не определился|m=Мужчина|f=Женщина', 'drop', 0, 0, 0, 1, 0, 0, '', 0, '', 2, '', 'gender'),
+(6, 'Город', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '{title} {content} ', 2, '', 'location'),
+(7, 'Интересы', '', '', 'textarea', 0, 0, 0, 1, 0, 0, '', 0, '', 2, '', 'interests'),
(8, 'Yahoo', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_yahoo.gif', 'yahoo'),
(9, 'Jabber', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_jabber.gif', 'jabber'),
(10, 'Skype', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_skype.gif', 'skype')";
$INSERT[] = "INSERT INTO pfields_groups (pf_group_id, pf_group_name, pf_group_key) VALUES
-(1, 'Contact Methods', 'contact'),
-(2, 'Profile Information', 'profile_info')";
+(1, 'Контакты', 'contact'),
+(2, 'Информация', 'profile_info')";
-$INSERT[] = "INSERT INTO core_sys_lang VALUES(1, 'en_US', 'English (USA)', 1, 0, 1)";
+$INSERT[] = "INSERT INTO core_sys_lang VALUES(1, 'ru_RU.UTF-8', 'Русский (RU)', 1, 0, 1)";
-$INSERT[] = "INSERT INTO titles (id, posts, title, pips) VALUES (1, 0, 'Newbie', '1');";
-$INSERT[] = "INSERT INTO titles (id, posts, title, pips) VALUES (2, 10, 'Member', '2');";
-$INSERT[] = "INSERT INTO titles (id, posts, title, pips) VALUES (4, 30, 'Advanced Member', '3');";
+$INSERT[] = "INSERT INTO titles (id, posts, title, pips) VALUES (1, 0, 'Новичок', '1');";
+$INSERT[] = "INSERT INTO titles (id, posts, title, pips) VALUES (2, 10, 'Пользователь', '2');";
+$INSERT[] = "INSERT INTO titles (id, posts, title, pips) VALUES (4, 30, 'Продвинутый пользователь', '3');";
$INSERT[] ="INSERT INTO permission_index VALUES(1, 'members', 'profile_view', 1, '*', '', '', '', '', '', '', 0, 0, NULL)";
$INSERT[] ="INSERT INTO permission_index VALUES(2, 'core', 'help', 1, '*', '', '', '', '', '', '', 0, 0, NULL)";
@@ -74,25 +74,25 @@ $INSERT[] ="INSERT INTO permission_index VALUES(2, 'core', 'help', 1, '*', '', '
$INSERT[] = <<getPrefix()."cache_store (
+ /*$SQL[]="create table ".ipsRegistry::dbFunctions()->getPrefix()."cache_store (
cs_key varchar(255) NOT NULL default '',
cs_value text NULL,
cs_extra varchar(255) NOT NULL default '',
PRIMARY KEY(cs_key)
- );";
+ );";*/
$SQL[]="create table ".ipsRegistry::dbFunctions()->getPrefix()."email_logs (
email_id int(10) NOT NULL auto_increment,
@@ -934,7 +934,7 @@ class version_upgrade
function step_6()
{
- $SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."macro rename ibf_skin_macro;";
+ $SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."macro rename ".ipsRegistry::dbFunctions()->getPrefix()."skin_macro;";
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."skin_macro change can_remove macro_can_remove tinyint(1) default '0';";
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."groups add g_bypass_badwords tinyint(1) NOT NULL default '0';";
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."cache_store change cs_value cs_value mediumtext NULL;";
@@ -1739,6 +1739,53 @@ class version_upgrade
function step_17()
{
+ if( !ipsRegistry::DB()->checkForTable('pfields_content') )
+ {
+ $SQL[] = "CREATE TABLE ".ipsRegistry::dbFunctions()->getPrefix()."pfields_content ( member_id mediumint(8) NOT NULL default 0, PRIMARY KEY (member_id) );";
+ }
+
+ if( !ipsRegistry::DB()->checkForTable('pfields_data') )
+ {
+ $SQL[] = "CREATE TABLE ".ipsRegistry::dbFunctions()->getPrefix()."pfields_data (
+ pf_id smallint(5) NOT NULL auto_increment,
+ pf_title varchar(250) NOT NULL default '',
+ pf_desc varchar(250) NOT NULL default '',
+ pf_content text,
+ pf_type varchar(250) NOT NULL default '',
+ pf_not_null tinyint(1) NOT NULL default 0,
+ pf_member_hide tinyint(1) NOT NULL default 0,
+ pf_max_input smallint(6) NOT NULL default 0,
+ pf_member_edit tinyint(1) NOT NULL default 0,
+ pf_position smallint(6) NOT NULL default 0,
+ pf_show_on_reg tinyint(1) NOT NULL default 0,
+ pf_input_format text,
+ pf_admin_only tinyint(1) NOT NULL default 0,
+ pf_topic_format text,
+ pf_group_id mediumint(4) unsigned NOT NULL,
+ pf_icon varchar(255) default NULL,
+ pf_key varchar(255) default NULL,
+ pf_search_type varchar(5) NOT NULL default 'loose',
+ pf_filtering TINYINT( 1 ) NOT NULL DEFAULT '0',
+ PRIMARY KEY (pf_id)
+ );";
+ }
+
+ if( !ipsRegistry::DB()->checkForTable('warn_logs') )
+ {
+ $SQL[] = "CREATE TABLE ".ipsRegistry::dbFunctions()->getPrefix()."warn_logs (
+ wlog_id int(10) NOT NULL auto_increment,
+ wlog_mid mediumint(8) NOT NULL default 0,
+ wlog_notes text,
+ wlog_contact varchar(250) NOT NULL default 'none',
+ wlog_contact_content text,
+ wlog_date int(10) NOT NULL default 0,
+ wlog_type varchar(6) NOT NULL default 'pos',
+ wlog_addedby mediumint(8) NOT NULL default 0,
+ PRIMARY KEY (wlog_id),
+ KEY wlog_mid (wlog_mid, wlog_date)
+ );";
+ }
+
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."groups add g_attach_per_post int(10) NOT NULL default '0';";
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."topic_mmod add topic_approve tinyint(1) NOT NULL default '0';";
diff --git a/upload/admin/applications/core/setup/versions/upg_10004/version_upgrade_mysql.php b/upload/admin/applications/core/setup/versions/upg_10004/version_upgrade_mysql.php
index d5f05a1b..d2559263 100644
--- a/upload/admin/applications/core/setup/versions/upg_10004/version_upgrade_mysql.php
+++ b/upload/admin/applications/core/setup/versions/upg_10004/version_upgrade_mysql.php
@@ -2,7 +2,7 @@
/*
+--------------------------------------------------------------------------
-| IP.Board v3.3.4
+| IP.Board v3.4.5
| ========================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services
@@ -714,7 +714,7 @@ class version_upgrade
function step_6()
{
- $SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."macro rename ibf_skin_macro;";
+ $SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."macro rename ".ipsRegistry::dbFunctions()->getPrefix()."skin_macro;";
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."skin_macro change can_remove macro_can_remove tinyint(1) default '0';";
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."groups add g_bypass_badwords tinyint(1) NOT NULL default '0';";
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."cache_store change cs_value cs_value mediumtext NULL;";
@@ -1530,6 +1530,53 @@ class version_upgrade
function step_17()
{
+ if( !ipsRegistry::DB()->checkForTable('pfields_content') )
+ {
+ $SQL[] = "CREATE TABLE ".ipsRegistry::dbFunctions()->getPrefix()."pfields_content ( member_id mediumint(8) NOT NULL default 0, PRIMARY KEY (member_id) );";
+ }
+
+ if( !ipsRegistry::DB()->checkForTable('pfields_data') )
+ {
+ $SQL[] = "CREATE TABLE ".ipsRegistry::dbFunctions()->getPrefix()."pfields_data (
+ pf_id smallint(5) NOT NULL auto_increment,
+ pf_title varchar(250) NOT NULL default '',
+ pf_desc varchar(250) NOT NULL default '',
+ pf_content text,
+ pf_type varchar(250) NOT NULL default '',
+ pf_not_null tinyint(1) NOT NULL default 0,
+ pf_member_hide tinyint(1) NOT NULL default 0,
+ pf_max_input smallint(6) NOT NULL default 0,
+ pf_member_edit tinyint(1) NOT NULL default 0,
+ pf_position smallint(6) NOT NULL default 0,
+ pf_show_on_reg tinyint(1) NOT NULL default 0,
+ pf_input_format text,
+ pf_admin_only tinyint(1) NOT NULL default 0,
+ pf_topic_format text,
+ pf_group_id mediumint(4) unsigned NOT NULL,
+ pf_icon varchar(255) default NULL,
+ pf_key varchar(255) default NULL,
+ pf_search_type varchar(5) NOT NULL default 'loose',
+ pf_filtering TINYINT( 1 ) NOT NULL DEFAULT '0',
+ PRIMARY KEY (pf_id)
+ );";
+ }
+
+ if( !ipsRegistry::DB()->checkForTable('warn_logs') )
+ {
+ $SQL[] = "CREATE TABLE ".ipsRegistry::dbFunctions()->getPrefix()."warn_logs (
+ wlog_id int(10) NOT NULL auto_increment,
+ wlog_mid mediumint(8) NOT NULL default 0,
+ wlog_notes text,
+ wlog_contact varchar(250) NOT NULL default 'none',
+ wlog_contact_content text,
+ wlog_date int(10) NOT NULL default 0,
+ wlog_type varchar(6) NOT NULL default 'pos',
+ wlog_addedby mediumint(8) NOT NULL default 0,
+ PRIMARY KEY (wlog_id),
+ KEY wlog_mid (wlog_mid, wlog_date)
+ );";
+ }
+
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."groups add g_attach_per_post int(10) NOT NULL default '0';";
$SQL[] = "alter table ".ipsRegistry::dbFunctions()->getPrefix()."topic_mmod add topic_approve tinyint(1) NOT NULL default '0';";
diff --git a/upload/admin/applications/core/setup/versions/upg_20004/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_20004/mysql_updates.php
index 1d2a653c..5e6ca57b 100644
--- a/upload/admin/applications/core/setup/versions/upg_20004/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_20004/mysql_updates.php
@@ -2,7 +2,7 @@
/*
+--------------------------------------------------------------------------
-| IP.Board v3.3.4
+| IP.Board v3.4.5
| ========================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services
diff --git a/upload/admin/applications/core/setup/versions/upg_20005/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_20005/mysql_updates.php
index 0b8201bc..992bbb0e 100644
--- a/upload/admin/applications/core/setup/versions/upg_20005/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_20005/mysql_updates.php
@@ -2,7 +2,7 @@
/*
+--------------------------------------------------------------------------
-| IP.Board v3.3.4
+| IP.Board v3.4.5
| ========================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services
diff --git a/upload/admin/applications/core/setup/versions/upg_20007/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_20007/mysql_updates.php
index 94cc3439..0ee24752 100644
--- a/upload/admin/applications/core/setup/versions/upg_20007/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_20007/mysql_updates.php
@@ -2,7 +2,7 @@
/*
+--------------------------------------------------------------------------
-| IP.Board v3.3.4
+| IP.Board v3.4.5
| ========================================
| by Matthew Mecham
| (c) 2001 - 2004 Invision Power Services
diff --git a/upload/admin/applications/core/setup/versions/upg_20009/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_20009/mysql_updates.php
index 00c4d9c7..f2981ed3 100644
--- a/upload/admin/applications/core/setup/versions/upg_20009/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_20009/mysql_updates.php
@@ -1,7 +1,7 @@
IPB UPGRADE MODULE:: IPB 2.0.2 -> IPB 2.0.3
-| > Script written by Matt Mecham
-| > Date started: 23rd April 2004
-| > "So what, pop is dead - it's no great loss.
- So many facelifts, it's face flew off"
-+--------------------------------------------------------------------------
-*/
-
-if ( ! defined( 'IN_IPB' ) )
-{
- print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class version_upgrade
-{
- /**
- * Custom HTML to show
- *
- * @var string
- */
- protected $_output = '';
-
- /**
- * fetchs output
- *
- * @return string
- */
- public function fetchOutput()
- {
- return $this->_output;
- }
-
- /**
- * Execute selected method
- *
- * @param object Registry object
- * @return @e void
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
-
- //--------------------------------
- // What are we doing?
- //--------------------------------
-
- switch( $this->request['workact'] )
- {
- case 'sql':
- $this->upgrade_sql(1);
- break;
- case 'sql1':
- $this->upgrade_sql(1);
- break;
- case 'sql2':
- $this->upgrade_sql(2);
- break;
- case 'sql3':
- $this->upgrade_sql(3);
- break;
- case 'sql4':
- $this->upgrade_sql(4);
- break;
- case 'polls':
- $this->convert_polls();
- break;
- case 'calevents':
- $this->convert_calevents();
- break;
- case 'skin':
- $this->add_skin();
- break;
-
- default:
- $this->upgrade_sql(1);
- break;
- }
-
- if ( $this->request['workact'] )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
-
- /*-------------------------------------------------------------------------*/
- // SQL: 0
- /*-------------------------------------------------------------------------*/
-
- function upgrade_sql( $id=1 )
- {
- $man = 0; // Manual upgrade ? intval( $this->request['man'] );
- $cnt = 0;
- $SQL = array();
- $file = '_updates_'.$id.'.php';
- $output = "";
- $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_21003/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
- $prefix = $this->registry->dbFunctions()->getPrefix();
-
- if ( is_file( $path ) )
- {
- require( $path );/*noLibHook*/
-
- $this->error = array();
- $this->sqlcount = 0;
- $output = "";
-
- $this->DB->return_die = 1;
-
- foreach( $SQL as $query )
- {
- $this->DB->allow_sub_select = 1;
- $this->DB->error = '';
-
- $query = str_replace( "<%time%>", time(), $query );
-
- /* Need to tack on a prefix? */
- if ( $prefix )
- {
- $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
- }
-
- if ( IPSSetUp::getSavedData('man') )
- {
- $output .= preg_replace( "/\s{1,}/", " ", $query ) . "\n\n";
- }
- else
- {
- if( ! $query )
- {
- continue;
- }
-
- $this->DB->query( $query );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( $query." ".$this->DB->error );
- }
- else
- {
- $this->sqlcount++;
- }
- }
- }
-
- $this->registry->output->addMessage("{$this->sqlcount} queries ran....");
- }
-
- //--------------------------------
- // Next page...
- //--------------------------------
-
- $this->request['st'] = 0;
-
- if ( $id != 4 )
- {
- $nextid = $id + 1;
- $this->request['workact'] = 'sql'.$nextid;
- }
- else
- {
- $this->request['workact'] = 'polls';
- }
-
- if ( IPSSetUp::getSavedData('man') AND $output )
- {
- /* Create source file */
- if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
- {
- $sourceFile = IPSSetUp::createSqlSourceFile( $output, '21003', $id );
- }
-
- $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
- }
- }
-
-
- /*-------------------------------------------------------------------------*/
- // POLLS
- /*-------------------------------------------------------------------------*/
-
- function convert_polls()
- {
- $start = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
- $lend = 50;
- $end = $start + $lend;
- $max = intval(IPSSetUp::getSavedData('max'));
- $converted = intval(IPSSetUp::getSavedData('conv'));
-
- //-----------------------------------------
- // First off.. grab number of polls to convert
- //-----------------------------------------
-
- if ( ! $max )
- {
- $total = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as max',
- 'from' => 'topics',
- 'where' => "poll_state IN ('open', 'close', 'closed')" ) );
-
- $max = $total['max'];
- }
-
- //-----------------------------------------
- // In steps...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'topics',
- 'where' => "poll_state IN ('open', 'close', 'closed' )",
- 'limit' => array( 0, $lend ) ) );
- $o = $this->DB->execute();
-
- //-----------------------------------------
- // Do it...
- //-----------------------------------------
-
- if ( $this->DB->getTotalRows($o) )
- {
- //-----------------------------------------
- // Got some to convert!
- //-----------------------------------------
-
- while ( $r = $this->DB->fetch($o) )
- {
- $converted++;
-
- //-----------------------------------------
- // All done?
- //-----------------------------------------
-
- if ( $converted >= $max )
- {
- $done = 1;
- }
-
- $new_poll = array( 1 => array() );
-
- $poll_data = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'polls',
- 'where' => "tid=".$r['tid']
- ) );
- if ( ! $poll_data['pid'] )
- {
- continue;
- }
-
- if ( ! $poll_data['poll_question'] )
- {
- $poll_data['poll_question'] = $r['title'];
- }
-
- //-----------------------------------------
- // Kick start new poll
- //-----------------------------------------
-
- $new_poll[1]['question'] = $poll_data['poll_question'];
-
- //-----------------------------------------
- // Get OLD polls
- //-----------------------------------------
-
- $poll_answers = unserialize( stripslashes( $poll_data['choices'] ) );
-
- reset($poll_answers);
-
- foreach ( $poll_answers as $entry )
- {
- $id = $entry[0];
- $choice = $entry[1];
- $votes = $entry[2];
-
- $total_votes += $votes;
-
- if ( strlen($choice) < 1 )
- {
- continue;
- }
-
- $new_poll[ 1 ]['choice'][ $id ] = $choice;
- $new_poll[ 1 ]['votes'][ $id ] = $votes;
- }
-
- //-----------------------------------------
- // Got something?
- //-----------------------------------------
-
- if ( count( $new_poll[1]['choice'] ) )
- {
- $this->DB->update( 'polls' , array( 'choices' => serialize( $new_poll ) ), 'tid='.$r['tid'] );
- $this->DB->update( 'topics', array( 'poll_state' => 1 ), 'tid='.$r['tid'] );
- }
- }
- }
- else
- {
- $done = 1;
- }
-
-
- if ( ! $done )
- {
- $this->registry->output->addMessage("Polls: $start to $end completed....");
- $this->request['workact'] = 'polls';
- $this->request['st'] = $end;
- IPSSetUp::setSavedData('max', $max);
- IPSSetUp::setSavedData('conv', $converted);
- return FALSE;
- }
- else
- {
- $this->registry->output->addMessage("Polls converted, proceeding to calendar events...");
- $this->request['workact'] = 'calevents';
- $this->request['st'] = '0';
- return FALSE;
- }
- }
-
-
- /*-------------------------------------------------------------------------*/
- // CALENDAR EVENTS
- /*-------------------------------------------------------------------------*/
-
- function convert_calevents()
- {
- $start = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
- $lend = 50;
- $end = $start + $lend;
-
- //-----------------------------------------
- // In steps...
- //-----------------------------------------
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'calendar_events',
- 'limit' => array( $start, $lend ) ) );
- $o = $this->DB->execute();
-
- //-----------------------------------------
- // Do it...
- //-----------------------------------------
-
- if ( $this->DB->getTotalRows($o) )
- {
- //-----------------------------------------
- // Got some to convert!
- //-----------------------------------------
-
- while ( $r = $this->DB->fetch($o) )
- {
- $recur_remap = array( 'w' => 1,
- 'm' => 2,
- 'y' => 3 );
-
- $begin_date = IPSTime::date_getgmdate( $r['unix_stamp'] );
- $end_date = IPSTime::date_getgmdate( $r['end_unix_stamp'] );
-
- if ( ! $begin_date OR ! $end_date )
- {
- continue;
- }
-
- $day = $begin_date['mday'];
- $month = $begin_date['mon'];
- $year = $begin_date['year'];
-
- $end_day = $end_date['mday'];
- $end_month = $end_date['mon'];
- $end_year = $end_date['year'];
-
- $_final_unix_from = gmmktime(0, 0, 0, $month, $day, $year );
-
- //-----------------------------------------
- // Recur or ranged...
- //-----------------------------------------
-
- if ( $r['event_repeat'] OR $r['event_ranged'] )
- {
- $_final_unix_to = gmmktime(11, 59, 59, $end_month, $end_day, $end_year);
- }
- else
- {
- $_final_unix_to = 0;
- }
-
- $new_event = array( 'event_calendar_id' => 1,
- 'event_member_id' => $r['userid'],
- 'event_content' => $r['event_text'],
- 'event_title' => $r['title'],
- 'event_smilies' => $r['show_emoticons'],
- 'event_perms' => $r['read_perms'],
- 'event_private' => $r['priv_event'],
- 'event_approved' => 1,
- 'event_unixstamp' => $r['unix_stamp'],
- 'event_recurring' => ( $r['event_repeat'] && $recur_remap[ $r['repeat_unit'] ] ) ? $recur_remap[ $r['repeat_unit'] ] : 0,
- 'event_tz' => 0,
- 'event_unix_from' => $_final_unix_from,
- 'event_unix_to' => $_final_unix_to );
-
- //-----------------------------------------
- // INSERT
- //-----------------------------------------
-
- $this->DB->insert( 'cal_events', $new_event );
- }
-
- $this->registry->output->addMessage("Calendar events: $start to $end completed....");
- $this->request['workact'] = 'calevents';
- $this->request['st'] = $end;
- return FALSE;
- }
- else
- {
- $this->registry->output->addMessage("Calendar events converted, Creating new IPB 2.1 skin...");
- $this->request['workact'] = 'skin';
- return FALSE;
- }
- }
-
-
-
- /*-------------------------------------------------------------------------*/
- // CALENDAR EVENTS
- /*-------------------------------------------------------------------------*/
-
- function add_skin()
- {
- $this->registry->output->addMessage("Skipping 2.1 skin creation (latest skin will be inserted later)...");
- unset($this->request['workact']);
- return TRUE;
- }
+ IPB UPGRADE MODULE:: IPB 2.0.2 -> IPB 2.0.3
+| > Script written by Matt Mecham
+| > Date started: 23rd April 2004
+| > "So what, pop is dead - it's no great loss.
+ So many facelifts, it's face flew off"
++--------------------------------------------------------------------------
+*/
+
+if ( ! defined( 'IN_IPB' ) )
+{
+ print "Incorrect access You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class version_upgrade
+{
+ /**
+ * Custom HTML to show
+ *
+ * @var string
+ */
+ protected $_output = '';
+
+ /**
+ * fetchs output
+ *
+ * @return string
+ */
+ public function fetchOutput()
+ {
+ return $this->_output;
+ }
+
+ /**
+ * Execute selected method
+ *
+ * @param object Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+ //--------------------------------
+ // What are we doing?
+ //--------------------------------
+
+ switch( $this->request['workact'] )
+ {
+ case 'sql':
+ $this->upgrade_sql(1);
+ break;
+ case 'sql1':
+ $this->upgrade_sql(1);
+ break;
+ case 'sql2':
+ $this->upgrade_sql(2);
+ break;
+ case 'sql3':
+ $this->upgrade_sql(3);
+ break;
+ case 'sql4':
+ $this->upgrade_sql(4);
+ break;
+ case 'polls':
+ $this->convert_polls();
+ break;
+ case 'calevents':
+ $this->convert_calevents();
+ break;
+ case 'skin':
+ $this->add_skin();
+ break;
+
+ default:
+ $this->upgrade_sql(1);
+ break;
+ }
+
+ if ( $this->request['workact'] )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+
+ /*-------------------------------------------------------------------------*/
+ // SQL: 0
+ /*-------------------------------------------------------------------------*/
+
+ function upgrade_sql( $id=1 )
+ {
+ $man = 0; // Manual upgrade ? intval( $this->request['man'] );
+ $cnt = 0;
+ $SQL = array();
+ $file = '_updates_'.$id.'.php';
+ $output = "";
+ $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_21003/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
+ $prefix = $this->registry->dbFunctions()->getPrefix();
+
+ if ( is_file( $path ) )
+ {
+ require( $path );/*noLibHook*/
+
+ $this->error = array();
+ $this->sqlcount = 0;
+ $output = "";
+
+ $this->DB->return_die = 1;
+
+ foreach( $SQL as $query )
+ {
+ $this->DB->allow_sub_select = 1;
+ $this->DB->error = '';
+
+ $query = str_replace( "<%time%>", time(), $query );
+
+ /* Need to tack on a prefix? */
+ if ( $prefix )
+ {
+ $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
+ }
+
+ if ( IPSSetUp::getSavedData('man') )
+ {
+ $output .= preg_replace( "/\s{1,}/", " ", $query ) . "\n\n";
+ }
+ else
+ {
+ if( ! $query )
+ {
+ continue;
+ }
+
+ $this->DB->query( $query );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( $query." ".$this->DB->error );
+ }
+ else
+ {
+ $this->sqlcount++;
+ }
+ }
+ }
+
+ $this->registry->output->addMessage("{$this->sqlcount} запросов выполнено....");
+ }
+
+ //--------------------------------
+ // Next page...
+ //--------------------------------
+
+ $this->request['st'] = 0;
+
+ if ( $id != 4 )
+ {
+ $nextid = $id + 1;
+ $this->request['workact'] = 'sql'.$nextid;
+ }
+ else
+ {
+ $this->request['workact'] = 'polls';
+ }
+
+ if ( IPSSetUp::getSavedData('man') AND $output )
+ {
+ /* Create source file */
+ if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
+ {
+ $sourceFile = IPSSetUp::createSqlSourceFile( $output, '21003', $id );
+ }
+
+ $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
+ }
+ }
+
+
+ /*-------------------------------------------------------------------------*/
+ // POLLS
+ /*-------------------------------------------------------------------------*/
+
+ function convert_polls()
+ {
+ $start = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
+ $lend = 50;
+ $end = $start + $lend;
+ $max = intval(IPSSetUp::getSavedData('max'));
+ $converted = intval(IPSSetUp::getSavedData('conv'));
+
+ //-----------------------------------------
+ // First off.. grab number of polls to convert
+ //-----------------------------------------
+
+ if ( ! $max )
+ {
+ $total = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as max',
+ 'from' => 'topics',
+ 'where' => "poll_state IN ('open', 'close', 'closed')" ) );
+
+ $max = $total['max'];
+ }
+
+ //-----------------------------------------
+ // In steps...
+ //-----------------------------------------
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'topics',
+ 'where' => "poll_state IN ('open', 'close', 'closed' )",
+ 'limit' => array( 0, $lend ) ) );
+ $o = $this->DB->execute();
+
+ //-----------------------------------------
+ // Do it...
+ //-----------------------------------------
+
+ if ( $this->DB->getTotalRows($o) )
+ {
+ //-----------------------------------------
+ // Got some to convert!
+ //-----------------------------------------
+
+ while ( $r = $this->DB->fetch($o) )
+ {
+ $converted++;
+
+ //-----------------------------------------
+ // All done?
+ //-----------------------------------------
+
+ if ( $converted >= $max )
+ {
+ $done = 1;
+ }
+
+ $new_poll = array( 1 => array() );
+
+ $poll_data = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'polls',
+ 'where' => "tid=".$r['tid']
+ ) );
+ if ( ! $poll_data['pid'] )
+ {
+ continue;
+ }
+
+ if ( ! $poll_data['poll_question'] )
+ {
+ $poll_data['poll_question'] = $r['title'];
+ }
+
+ //-----------------------------------------
+ // Kick start new poll
+ //-----------------------------------------
+
+ $new_poll[1]['question'] = $poll_data['poll_question'];
+
+ //-----------------------------------------
+ // Get OLD polls
+ //-----------------------------------------
+
+ $poll_answers = unserialize( stripslashes( $poll_data['choices'] ) );
+
+ reset($poll_answers);
+
+ foreach ( $poll_answers as $entry )
+ {
+ $id = $entry[0];
+ $choice = $entry[1];
+ $votes = $entry[2];
+
+ $total_votes += $votes;
+
+ if ( strlen($choice) < 1 )
+ {
+ continue;
+ }
+
+ $new_poll[ 1 ]['choice'][ $id ] = $choice;
+ $new_poll[ 1 ]['votes'][ $id ] = $votes;
+ }
+
+ //-----------------------------------------
+ // Got something?
+ //-----------------------------------------
+
+ if ( count( $new_poll[1]['choice'] ) )
+ {
+ $this->DB->update( 'polls' , array( 'choices' => serialize( $new_poll ) ), 'tid='.$r['tid'] );
+ $this->DB->update( 'topics', array( 'poll_state' => 1 ), 'tid='.$r['tid'] );
+ }
+ }
+ }
+ else
+ {
+ $done = 1;
+ }
+
+
+ if ( ! $done )
+ {
+ $this->registry->output->addMessage("Polls: $start to $end completed....");
+ $this->request['workact'] = 'polls';
+ $this->request['st'] = $end;
+ IPSSetUp::setSavedData('max', $max);
+ IPSSetUp::setSavedData('conv', $converted);
+ return FALSE;
+ }
+ else
+ {
+ $this->registry->output->addMessage("Polls converted, proceeding to calendar events...");
+ $this->request['workact'] = 'calevents';
+ $this->request['st'] = '0';
+ return FALSE;
+ }
+ }
+
+
+ /*-------------------------------------------------------------------------*/
+ // CALENDAR EVENTS
+ /*-------------------------------------------------------------------------*/
+
+ function convert_calevents()
+ {
+ $start = intval($this->request['st']) > 0 ? intval($this->request['st']) : 0;
+ $lend = 50;
+ $end = $start + $lend;
+
+ //-----------------------------------------
+ // In steps...
+ //-----------------------------------------
+
+ if( !$this->DB->checkForTable('calendar_events') )
+ {
+ $this->registry->output->addMessage("События календаря не найдены, Создается новый стиль внешнего вида IPB 2.1...");
+ $this->request['workact'] = 'skin';
+ return FALSE;
+ }
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'calendar_events',
+ 'limit' => array( $start, $lend ) ) );
+ $o = $this->DB->execute();
+
+ //-----------------------------------------
+ // Do it...
+ //-----------------------------------------
+
+ if ( $this->DB->getTotalRows($o) )
+ {
+ //-----------------------------------------
+ // Got some to convert!
+ //-----------------------------------------
+
+ while ( $r = $this->DB->fetch($o) )
+ {
+ $recur_remap = array( 'w' => 1,
+ 'm' => 2,
+ 'y' => 3 );
+
+ $begin_date = IPSTime::date_getgmdate( $r['unix_stamp'] );
+ $end_date = IPSTime::date_getgmdate( $r['end_unix_stamp'] );
+
+ if ( ! $begin_date OR ! $end_date )
+ {
+ continue;
+ }
+
+ $day = $begin_date['mday'];
+ $month = $begin_date['mon'];
+ $year = $begin_date['year'];
+
+ $end_day = $end_date['mday'];
+ $end_month = $end_date['mon'];
+ $end_year = $end_date['year'];
+
+ $_final_unix_from = gmmktime(0, 0, 0, $month, $day, $year );
+
+ //-----------------------------------------
+ // Recur or ranged...
+ //-----------------------------------------
+
+ if ( $r['event_repeat'] OR $r['event_ranged'] )
+ {
+ $_final_unix_to = gmmktime(11, 59, 59, $end_month, $end_day, $end_year);
+ }
+ else
+ {
+ $_final_unix_to = 0;
+ }
+
+ $new_event = array( 'event_calendar_id' => 1,
+ 'event_member_id' => $r['userid'],
+ 'event_content' => $r['event_text'],
+ 'event_title' => $r['title'],
+ 'event_smilies' => $r['show_emoticons'],
+ 'event_perms' => $r['read_perms'],
+ 'event_private' => $r['priv_event'],
+ 'event_approved' => 1,
+ 'event_unixstamp' => $r['unix_stamp'],
+ 'event_recurring' => ( $r['event_repeat'] && $recur_remap[ $r['repeat_unit'] ] ) ? $recur_remap[ $r['repeat_unit'] ] : 0,
+ 'event_tz' => 0,
+ 'event_unix_from' => $_final_unix_from,
+ 'event_unix_to' => $_final_unix_to );
+
+ //-----------------------------------------
+ // INSERT
+ //-----------------------------------------
+
+ $this->DB->insert( 'cal_events', $new_event );
+ }
+
+ $this->registry->output->addMessage("Calendar events: $start to $end completed....");
+ $this->request['workact'] = 'calevents';
+ $this->request['st'] = $end;
+ return FALSE;
+ }
+ else
+ {
+ $this->registry->output->addMessage("Calendar events converted, Creating new IPB 2.1 skin...");
+ $this->request['workact'] = 'skin';
+ return FALSE;
+ }
+ }
+
+
+
+ /*-------------------------------------------------------------------------*/
+ // CALENDAR EVENTS
+ /*-------------------------------------------------------------------------*/
+
+ function add_skin()
+ {
+ $this->registry->output->addMessage("Skipping 2.1 skin creation (latest skin will be inserted later)...");
+ unset($this->request['workact']);
+ return TRUE;
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_21005/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_21005/mysql_updates.php
index ac5e7214..8b28c54c 100644
--- a/upload/admin/applications/core/setup/versions/upg_21005/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_21005/mysql_updates.php
@@ -1,7 +1,7 @@
Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class version_upgrade
-{
- /**
- * Custom HTML to show
- *
- * @var string
- */
- protected $_output = '';
-
- /**
- * fetchs output
- *
- * @return string
- */
- public function fetchOutput()
- {
- return $this->_output;
- }
-
- /**
- * Execute selected method
- *
- * @param object Registry object
- * @return @e void
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
-
- //-----------------------------------------
- // Remove dupe categories
- //-----------------------------------------
-
- $title_id_to_keep = array();
- $title_id_to_delete = array();
- $title_deleted_count = 0;
- $msg = '';
-
- $this->DB->build( array( 'select' => '*', 'from' => 'conf_settings_titles', 'order' => 'conf_title_id DESC' ) );
- $this->DB->execute();
-
- while ( $r = $this->DB->fetch() )
- {
- if ( $title_id_to_keep[ $r['conf_title_title'] ] )
- {
- $title_id_to_delete[ $r['conf_title_id'] ] = $r['conf_title_id'];
- }
- else
- {
- $title_id_to_keep[ $r['conf_title_title'] ] = $r['conf_title_id'];
- }
- }
-
- if ( count( $title_id_to_delete ) )
- {
- $this->DB->delete( 'conf_settings_titles', 'conf_title_id IN ('.implode( ',', $title_id_to_delete ).')' );
- }
-
- $title_deleted_count = intval( count($title_id_to_delete) );
-
- $this->registry->output->addMessage("$title_deleted_count duplicate settings deleted");
-
- return true;
- }
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class version_upgrade
+{
+ /**
+ * Custom HTML to show
+ *
+ * @var string
+ */
+ protected $_output = '';
+
+ /**
+ * fetchs output
+ *
+ * @return string
+ */
+ public function fetchOutput()
+ {
+ return $this->_output;
+ }
+
+ /**
+ * Execute selected method
+ *
+ * @param object Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+ //-----------------------------------------
+ // Remove dupe categories
+ //-----------------------------------------
+
+ $title_id_to_keep = array();
+ $title_id_to_delete = array();
+ $title_deleted_count = 0;
+ $msg = '';
+
+ $this->DB->build( array( 'select' => '*', 'from' => 'conf_settings_titles', 'order' => 'conf_title_id DESC' ) );
+ $this->DB->execute();
+
+ while ( $r = $this->DB->fetch() )
+ {
+ if ( $title_id_to_keep[ $r['conf_title_title'] ] )
+ {
+ $title_id_to_delete[ $r['conf_title_id'] ] = $r['conf_title_id'];
+ }
+ else
+ {
+ $title_id_to_keep[ $r['conf_title_title'] ] = $r['conf_title_id'];
+ }
+ }
+
+ if ( count( $title_id_to_delete ) )
+ {
+ $this->DB->delete( 'conf_settings_titles', 'conf_title_id IN ('.implode( ',', $title_id_to_delete ).')' );
+ }
+
+ $title_deleted_count = intval( count($title_id_to_delete) );
+
+ $this->registry->output->addMessage("$title_deleted_count дубликатов настроек удалено");
+
+ return true;
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_21008/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_21008/mysql_updates.php
index caa981c8..745f1b7d 100644
--- a/upload/admin/applications/core/setup/versions/upg_21008/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_21008/mysql_updates.php
@@ -1,7 +1,7 @@
Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class version_upgrade
-{
- /**
- * Custom HTML to show
- *
- * @var string
- */
- private $_output = '';
-
- /**
- * fetchs output
- *
- * @return string
- */
- public function fetchOutput()
- {
- return $this->_output;
- }
-
- /**
- * Execute selected method
- *
- * @param object Registry object
- * @return @e void
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
-
- /* Set DB driver to return any errors */
- $this->DB->return_die = 1;
-
- //--------------------------------
- // What are we doing?
- //--------------------------------
-
- switch( $this->request['workact'] )
- {
- case 'sql':
- $this->upgrade_sql(1);
- break;
- case 'sql1':
- $this->upgrade_sql(1);
- break;
- case 'sql2':
- $this->upgrade_sql(2);
- break;
- case 'sql3':
- $this->upgrade_sql(3);
- break;
- case 'sql4':
- $this->upgrade_sql(4);
- break;
- case 'forums':
- $this->update_forums();
- break;
- case 'finish':
- $this->finish_up();
- break;
- case 'skin':
- $this->add_skin();
- break;
- case 'update_template_bits':
- $this->update_template_bits();
- break;
-
- default:
- $this->upgrade_sql(1);
- break;
- }
-
- if ( $this->request['workact'] )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
-
- /*-------------------------------------------------------------------------*/
- // SQL: 0
- /*-------------------------------------------------------------------------*/
-
- function upgrade_sql( $id=1 )
- {
- $man = 0; // Manual upgrade ? intval( $this->request['man'] );
- $cnt = 0;
- $SQL = array();
- $file = '_updates_'.$id.'.php';
- $output = "";
- $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_22005/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
- $prefix = $this->registry->dbFunctions()->getPrefix();
-
- if ( is_file( $path ) )
- {
- require_once( $path );/*noLibHook*/
-
- $this->sqlcount = 0;
- $output = "";
-
- $this->DB->return_die = 1;
-
- foreach( $SQL as $query )
- {
- $this->DB->allow_sub_select = 1;
- $this->DB->error = '';
-
- $query = str_replace( "<%time%>", time(), $query );
-
- if( $this->settings['mysql_tbl_type'] )
- {
- if( preg_match( "/^create table(.+?)/i", $query ) )
- {
- $query = preg_replace( "/^(.+?)\);$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $query );
- }
- }
-
- /* Need to tack on a prefix? */
- if ( $prefix )
- {
- $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
- }
-
- if ( IPSSetUp::getSavedData('man') )
- {
- $output .= preg_replace( "/\s{1,}/", " ", $query ) ."\n\n";
- }
- else
- {
- $this->DB->query( $query );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( $query." ".$this->DB->error );
- }
- else
- {
- $this->sqlcount++;
- }
- }
- }
-
- $this->registry->output->addMessage("$this->sqlcount queries ran....");
- }
-
- //--------------------------------
- // Next page...
- //--------------------------------
-
- $this->request['st'] = 0;
-
- if ( $id != 4 )
- {
- $nextid = $id + 1;
- $this->request['workact'] = 'sql'.$nextid;
- }
- else
- {
- $this->request['workact'] = 'forums';
- }
-
- if ( IPSSetUp::getSavedData('man') AND $output )
- {
- /* Create source file */
- if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
- {
- $sourceFile = IPSSetUp::createSqlSourceFile( $output, '22005', $id );
- }
-
- $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
- }
- }
-
-
- /*-------------------------------------------------------------------------*/
- // Update forums
- /*-------------------------------------------------------------------------*/
-
- function update_forums()
- {
- //-----------------------------------------
- // Update latest news...
- //-----------------------------------------
-
- $this->DB->update( "forums", "newest_title=last_title, newest_id=last_id", 'last_title IS NOT NULL AND last_id IS NOT NULL', false, true );
- $this->DB->execute();
-
- //-----------------------------------------
- // INIT
- //-----------------------------------------
-
- $ignore_me = array( 'redirect_url', 'redirect_loc', 'rules_text', 'permission_custom_error', 'notify_modq_emails' );
-
- if ( !empty($this->settings['forum_cache_minimum']) )
- {
- $ignore_me[] = 'description';
- $ignore_me[] = 'rules_title';
- }
-
- $this->caches['forum_cache'] = array();
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'forums',
- 'order' => 'parent_id, position'
- ) );
- $o = $this->DB->execute();
-
- while( $f = $this->DB->fetch( $o ) )
- {
- $fr = array();
-
- $perms = unserialize(stripslashes($f['permission_array']));
-
- //-----------------------------------------
- // Stuff we don't need...
- //-----------------------------------------
-
- if ( $f['parent_id'] == -1 )
- {
- $fr['id'] = $f['id'];
- $fr['sub_can_post'] = $f['sub_can_post'];
- $fr['name'] = $f['name'];
- $fr['parent_id'] = $f['parent_id'];
- $fr['show_perms'] = $perms['show_perms'];
- $fr['skin_id'] = $f['skin_id'];
- $fr['permission_showtopic'] = $f['permission_showtopic'];
- }
- else
- {
- foreach( $f as $k => $v )
- {
- if ( in_array( $k, $ignore_me ) )
- {
- continue;
- }
- else
- {
- if ( $v != "" )
- {
- $fr[ $k ] = $v;
- }
- }
- }
-
- $fr['read_perms'] = isset($perms['read_perms']) ? $perms['read_perms'] : '';
- $fr['reply_perms'] = isset($perms['reply_perms']) ? $perms['reply_perms'] : '';
- $fr['start_perms'] = isset($perms['start_perms']) ? $perms['start_perms'] : '';
- $fr['upload_perms'] = isset($perms['upload_perms']) ? $perms['upload_perms'] : '';
- $fr['download_perms'] = $perms['upload_perms'];
- $fr['show_perms'] = isset($perms['show_perms']) ? $perms['show_perms'] : '';
-
- unset($fr['permission_array']);
- }
-
- $this->caches['forum_cache'][ $fr['id'] ] = $fr;
-
- $perm_array = addslashes(serialize(array(
- 'start_perms' => $fr['start_perms'],
- 'reply_perms' => $fr['reply_perms'],
- 'read_perms' => $fr['read_perms'],
- 'upload_perms' => $fr['upload_perms'],
- 'download_perms' => $fr['download_perms'],
- 'show_perms' => $fr['show_perms']
- ) ) );
-
- //-----------------------------------------
- // Add to save array
- //-----------------------------------------
-
- $this->DB->update( 'forums', array( 'permission_array' => $perm_array ), 'id='.$fr['id'] );
-
- }
-
- $this->cache->setCache( 'forum_cache', $this->caches['forum_cache'], array( 'array' => 1 ) );
-
- $this->registry->output->addMessage("Download permissions added, Converting template bit HTML logic...");
- $this->request['workact'] = 'update_template_bits';
- }
-
- /*-------------------------------------------------------------------------*/
- // Update template bits
- /*-------------------------------------------------------------------------*/
-
- function update_template_bits()
- {
- $this->registry->output->addMessage("Template bits skipped, finishing up...");
- $this->request['workact'] = 'finish';
- return FALSE;
- }
-
- /*-------------------------------------------------------------------------*/
- // Update forums
- /*-------------------------------------------------------------------------*/
-
- function finish_up()
- {
- //-----------------------------------------
- // Has gallery?
- //-----------------------------------------
-
- $this->DB->return_die = 1;
- $this->DB->error = '';
-
- $table = 'members';
-
- if ( ! $this->DB->checkForField( 'has_gallery', $table ) )
- {
- $this->DB->addField( 'members', 'has_gallery', 'INT(1)', '0' );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( "ALTER TABLE {$this->DB->obj['sql_tbl_prefix']}members ADD has_gallery INT(1) default 0 ".$this->DB->error );
- }
- }
-
- if( $this->settings['conv_configured'] != 1 OR $this->settings['conv_chosen'] == "" )
- {
- if( $this->DB->checkForField( "legacy_password", "members" ) )
- {
- $this->DB->dropField( 'members', 'legacy_password' );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( "ALTER TABLE {$this->DB->obj['sql_tbl_prefix']}members DROP legacy_password ".$this->DB->error );
- }
- }
- }
-
- $test = $this->DB->buildAndFetch( array( 'select' => 'count(*) as numrows',
- 'from' => 'cache_store',
- 'where' => "cs_key='calendars'"
- ) );
-
- if ( ! $test['numrows'] )
- {
- $this->DB->insert( 'cache_store', array( 'cs_key' => 'calendars' ) );
- }
-
- $this->registry->output->addMessage("Clean up performed, Creating new IPB 2.2.0 skin...");
- $this->request['workact'] = 'skin';
- }
-
- /*-------------------------------------------------------------------------*/
- // Add new skin
- /*-------------------------------------------------------------------------*/
-
- function add_skin()
- {
- $this->registry->output->addMessage("2.2.0 skin skipped...");
- unset($this->request['workact']);
-
- return TRUE;
- }
-
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class version_upgrade
+{
+ /**
+ * Custom HTML to show
+ *
+ * @var string
+ */
+ private $_output = '';
+
+ /**
+ * fetchs output
+ *
+ * @return string
+ */
+ public function fetchOutput()
+ {
+ return $this->_output;
+ }
+
+ /**
+ * Execute selected method
+ *
+ * @param object Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+ /* Set DB driver to return any errors */
+ $this->DB->return_die = 1;
+
+ //--------------------------------
+ // What are we doing?
+ //--------------------------------
+
+ switch( $this->request['workact'] )
+ {
+ case 'sql':
+ $this->upgrade_sql(1);
+ break;
+ case 'sql1':
+ $this->upgrade_sql(1);
+ break;
+ case 'sql2':
+ $this->upgrade_sql(2);
+ break;
+ case 'sql3':
+ $this->upgrade_sql(3);
+ break;
+ case 'sql4':
+ $this->upgrade_sql(4);
+ break;
+ case 'forums':
+ $this->update_forums();
+ break;
+ case 'finish':
+ $this->finish_up();
+ break;
+ case 'skin':
+ $this->add_skin();
+ break;
+ case 'update_template_bits':
+ $this->update_template_bits();
+ break;
+
+ default:
+ $this->upgrade_sql(1);
+ break;
+ }
+
+ if ( $this->request['workact'] )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+
+ /*-------------------------------------------------------------------------*/
+ // SQL: 0
+ /*-------------------------------------------------------------------------*/
+
+ function upgrade_sql( $id=1 )
+ {
+ $man = 0; // Manual upgrade ? intval( $this->request['man'] );
+ $cnt = 0;
+ $SQL = array();
+ $file = '_updates_'.$id.'.php';
+ $output = "";
+ $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_22005/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
+ $prefix = $this->registry->dbFunctions()->getPrefix();
+
+ if ( is_file( $path ) )
+ {
+ require_once( $path );/*noLibHook*/
+
+ $this->sqlcount = 0;
+ $output = "";
+
+ $this->DB->return_die = 1;
+
+ foreach( $SQL as $query )
+ {
+ $this->DB->allow_sub_select = 1;
+ $this->DB->error = '';
+
+ $query = str_replace( "<%time%>", time(), $query );
+
+ if( $this->settings['mysql_tbl_type'] )
+ {
+ if( preg_match( "/^create table(.+?)/i", $query ) )
+ {
+ $query = preg_replace( "/^(.+?)\);$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $query );
+ }
+ }
+
+ /* Need to tack on a prefix? */
+ if ( $prefix )
+ {
+ $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
+ }
+
+ if ( IPSSetUp::getSavedData('man') )
+ {
+ $output .= preg_replace( "/\s{1,}/", " ", $query ) ."\n\n";
+ }
+ else
+ {
+ $this->DB->query( $query );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( $query." ".$this->DB->error );
+ }
+ else
+ {
+ $this->sqlcount++;
+ }
+ }
+ }
+
+ $this->registry->output->addMessage("$this->sqlcount запросов выполнено....");
+ }
+
+ //--------------------------------
+ // Next page...
+ //--------------------------------
+
+ $this->request['st'] = 0;
+
+ if ( $id != 4 )
+ {
+ $nextid = $id + 1;
+ $this->request['workact'] = 'sql'.$nextid;
+ }
+ else
+ {
+ $this->request['workact'] = 'forums';
+ }
+
+ if ( IPSSetUp::getSavedData('man') AND $output )
+ {
+ /* Create source file */
+ if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
+ {
+ $sourceFile = IPSSetUp::createSqlSourceFile( $output, '22005', $id );
+ }
+
+ $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
+ }
+ }
+
+
+ /*-------------------------------------------------------------------------*/
+ // Update forums
+ /*-------------------------------------------------------------------------*/
+
+ function update_forums()
+ {
+ //-----------------------------------------
+ // Update latest news...
+ //-----------------------------------------
+
+ $this->DB->update( "forums", "newest_title=last_title, newest_id=last_id", 'last_title IS NOT NULL AND last_id IS NOT NULL', false, true );
+ $this->DB->execute();
+
+ //-----------------------------------------
+ // INIT
+ //-----------------------------------------
+
+ $ignore_me = array( 'redirect_url', 'redirect_loc', 'rules_text', 'permission_custom_error', 'notify_modq_emails' );
+
+ if ( !empty($this->settings['forum_cache_minimum']) )
+ {
+ $ignore_me[] = 'description';
+ $ignore_me[] = 'rules_title';
+ }
+
+ $this->caches['forum_cache'] = array();
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'forums',
+ 'order' => 'parent_id, position'
+ ) );
+ $o = $this->DB->execute();
+
+ while( $f = $this->DB->fetch( $o ) )
+ {
+ $fr = array();
+
+ $perms = unserialize(stripslashes($f['permission_array']));
+
+ //-----------------------------------------
+ // Stuff we don't need...
+ //-----------------------------------------
+
+ if ( $f['parent_id'] == -1 )
+ {
+ $fr['id'] = $f['id'];
+ $fr['sub_can_post'] = $f['sub_can_post'];
+ $fr['name'] = $f['name'];
+ $fr['parent_id'] = $f['parent_id'];
+ $fr['show_perms'] = $perms['show_perms'];
+ $fr['skin_id'] = $f['skin_id'];
+ $fr['permission_showtopic'] = $f['permission_showtopic'];
+ }
+ else
+ {
+ foreach( $f as $k => $v )
+ {
+ if ( in_array( $k, $ignore_me ) )
+ {
+ continue;
+ }
+ else
+ {
+ if ( $v != "" )
+ {
+ $fr[ $k ] = $v;
+ }
+ }
+ }
+
+ $fr['read_perms'] = isset($perms['read_perms']) ? $perms['read_perms'] : '';
+ $fr['reply_perms'] = isset($perms['reply_perms']) ? $perms['reply_perms'] : '';
+ $fr['start_perms'] = isset($perms['start_perms']) ? $perms['start_perms'] : '';
+ $fr['upload_perms'] = isset($perms['upload_perms']) ? $perms['upload_perms'] : '';
+ $fr['download_perms'] = $perms['upload_perms'];
+ $fr['show_perms'] = isset($perms['show_perms']) ? $perms['show_perms'] : '';
+
+ unset($fr['permission_array']);
+ }
+
+ $this->caches['forum_cache'][ $fr['id'] ] = $fr;
+
+ $perm_array = addslashes(serialize(array(
+ 'start_perms' => $fr['start_perms'],
+ 'reply_perms' => $fr['reply_perms'],
+ 'read_perms' => $fr['read_perms'],
+ 'upload_perms' => $fr['upload_perms'],
+ 'download_perms' => $fr['download_perms'],
+ 'show_perms' => $fr['show_perms']
+ ) ) );
+
+ //-----------------------------------------
+ // Add to save array
+ //-----------------------------------------
+
+ $this->DB->update( 'forums', array( 'permission_array' => $perm_array ), 'id='.$fr['id'] );
+
+ }
+
+ $this->cache->setCache( 'forum_cache', $this->caches['forum_cache'], array( 'array' => 1 ) );
+
+ $this->registry->output->addMessage("Download permissions added, Converting template bit HTML logic...");
+ $this->request['workact'] = 'update_template_bits';
+ }
+
+ /*-------------------------------------------------------------------------*/
+ // Update template bits
+ /*-------------------------------------------------------------------------*/
+
+ function update_template_bits()
+ {
+ $this->registry->output->addMessage("Template bits skipped, finishing up...");
+ $this->request['workact'] = 'finish';
+ return FALSE;
+ }
+
+ /*-------------------------------------------------------------------------*/
+ // Update forums
+ /*-------------------------------------------------------------------------*/
+
+ function finish_up()
+ {
+ //-----------------------------------------
+ // Has gallery?
+ //-----------------------------------------
+
+ $this->DB->return_die = 1;
+ $this->DB->error = '';
+
+ $table = 'members';
+
+ if ( ! $this->DB->checkForField( 'has_gallery', $table ) )
+ {
+ $this->DB->addField( 'members', 'has_gallery', 'INT(1)', '0' );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( "ALTER TABLE {$this->DB->obj['sql_tbl_prefix']}members ADD has_gallery INT(1) default 0 ".$this->DB->error );
+ }
+ }
+
+ if( $this->settings['conv_configured'] != 1 OR $this->settings['conv_chosen'] == "" )
+ {
+ if( $this->DB->checkForField( "legacy_password", "members" ) )
+ {
+ $this->DB->dropField( 'members', 'legacy_password' );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( "ALTER TABLE {$this->DB->obj['sql_tbl_prefix']}members DROP legacy_password ".$this->DB->error );
+ }
+ }
+ }
+
+ $test = $this->DB->buildAndFetch( array( 'select' => 'count(*) as numrows',
+ 'from' => 'cache_store',
+ 'where' => "cs_key='calendars'"
+ ) );
+
+ if ( ! $test['numrows'] )
+ {
+ $this->DB->insert( 'cache_store', array( 'cs_key' => 'calendars' ) );
+ }
+
+ $this->registry->output->addMessage("Clean up performed, Creating new IPB 2.2.0 skin...");
+ $this->request['workact'] = 'skin';
+ }
+
+ /*-------------------------------------------------------------------------*/
+ // Add new skin
+ /*-------------------------------------------------------------------------*/
+
+ function add_skin()
+ {
+ $this->registry->output->addMessage("2.2.0 skin skipped...");
+ unset($this->request['workact']);
+
+ return TRUE;
+ }
+
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_22006/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_22006/mysql_updates.php
index 83cf90cb..5b7bf7b3 100644
--- a/upload/admin/applications/core/setup/versions/upg_22006/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_22006/mysql_updates.php
@@ -1,7 +1,7 @@
{title}:{content} ', 2, '', 'gender'),
-(NULL, 'Location', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '{title}: {content} ', 2, '', 'location'),
-(NULL, 'Interests', '', '', 'textarea', 0, 0, 0, 1, 0, 0, '', 0, '{title}: {content} ', 2, '', 'interests'),
+(NULL, 'Пол', '', 'm=Мужчина|f=Женщина|u=Не определился', 'drop', 0, 0, 0, 1, 0, 0, '', 0, '{title}: {content} ', 2, '', 'gender'),
+(NULL, 'Город', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '{title}: {content} ', 2, '', 'location'),
+(NULL, 'Интересы', '', '', 'textarea', 0, 0, 0, 1, 0, 0, '', 0, '{title}: {content} ', 2, '', 'interests'),
(NULL, 'Yahoo', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_yahoo.gif', 'yahoo'),
(NULL, 'Jabber', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_jabber.gif', 'jabber'),
(NULL, 'Skype', '', '', 'input', 0, 0, 0, 1, 0, 0, '', 0, '', 1, 'style_extra/cprofile_icons/profile_skype.gif', 'skype');
@@ -100,10 +100,10 @@ $SQL[] = "TRUNCATE TABLE task_manager;";
$SQL[] = "DELETE FROM cache_store WHERE cs_key='skin_id_cache';";
$SQL[] = "DELETE FROM cache_store WHERE cs_key='forum_cache';";
-$SQL[] = "INSERT INTO reputation_levels VALUES(1, -20, 'Bad', '');";
-$SQL[] = "INSERT INTO reputation_levels VALUES(2, -10, 'Poor', '');";
-$SQL[] = "INSERT INTO reputation_levels VALUES(3, 0, 'Neutral', '');";
-$SQL[] = "INSERT INTO reputation_levels VALUES(4, 10, 'Good', '');";
-$SQL[] = "INSERT INTO reputation_levels VALUES(5, 20, 'Excellent', '');";
+$SQL[] = "INSERT INTO reputation_levels VALUES(1, -20, 'Очень плохой', '');";
+$SQL[] = "INSERT INTO reputation_levels VALUES(2, -10, 'Плохой', '');";
+$SQL[] = "INSERT INTO reputation_levels VALUES(3, 0, 'Обычный', '');";
+$SQL[] = "INSERT INTO reputation_levels VALUES(4, 10, 'Хороший', '');";
+$SQL[] = "INSERT INTO reputation_levels VALUES(5, 20, 'Очень хороший', '');";
?>
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_30001/mysql_updates_6.php b/upload/admin/applications/core/setup/versions/upg_30001/mysql_updates_6.php
index 51ea7194..2f399600 100644
--- a/upload/admin/applications/core/setup/versions/upg_30001/mysql_updates_6.php
+++ b/upload/admin/applications/core/setup/versions/upg_30001/mysql_updates_6.php
@@ -1,7 +1,7 @@
getPrefix();
+ if( empty($field) )
+ {
+ return null;
+ }
+
return "UPDATE {$PRE}pfields_content p, {$PRE}member_extra m
SET p.field_{$field['pf_id']}=m.{$old}
WHERE p.member_id=m.id";
diff --git a/upload/admin/applications/core/setup/versions/upg_30001/version_class.php b/upload/admin/applications/core/setup/versions/upg_30001/version_class.php
index bb1ee48e..5998065f 100644
--- a/upload/admin/applications/core/setup/versions/upg_30001/version_class.php
+++ b/upload/admin/applications/core/setup/versions/upg_30001/version_class.php
@@ -1,161 +1,161 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Upgrade Class
- *
- * Class to add options and notices for IP.Board upgrade
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author Matt Mecham
- * @version $Rev: 10914 $
- * @since 3.0
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @link http://www.invisionpower.com
- * @package IP.Board
- */
-
-class version_class_core_30001
-{
- /**
- * Constructor
- *
- * @param object $registry Registry object
- * @return @e void
- */
- public function __construct( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
- }
-
- /**
- * Add pre-upgrade options: Form
- *
- * @return string HTML block
- */
- public function preInstallOptionsForm()
- {
-return <<
-
-
- Export current skin's modified template bits and CSS? (This will be saved in /cache/previousSkinFiles)
-
-
-
- Copy language PHP files into /cache/previousLangFiles before upgrading?
-
-
-
- Skip PM Conversion? If so, old tables will not be removed and you can use the provided shell tool post-upgrade
-
-
-
- Remove all "non-root" admin ACP permissions? Due to the change in permission models, root admins and admins have the same default permissions.
- You have the option to restrict all non-root admins and then manually set up their permissions after the upgrade. Not ticking this box will effectively give all
- administrators full access regardless of administrator type.
-
-
-EOF;
-
- }
-
- /**
- * Add pre-upgrade options: Save
- *
- * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
- *
- * @return array Key / value pairs to save
- */
- public function preInstallOptionsSave()
- {
- /* Return */
- return array( 'exportSkins' => intval( $_REQUEST['exportSkins'] ),
- 'exportLangs' => intval( $_REQUEST['exportLangs'] ),
- 'skipPms' => intval( $_REQUEST['skipPms'] )
- );
-
- }
-
- /**
- * Return any post-installation notices
- *
- * @return array Array of notices
- */
- public function postInstallNotices()
- {
- $options = IPSSetUp::getSavedData('custom_options');
- $_doSkin = $options['core'][30001]['exportSkins'];
- $_doLang = $options['core'][30001]['exportLangs'];
- $rootAdmins = $options['core'][30001]['rootAdmins'];
- $skipPms = $options['core'][30001]['skipPms'];
-
- $notices = array();
-
- if ( $_doSkin )
- {
- $notices[] = "All previous skins have been exported into 'cache/previousSkinFiles'";
- }
-
- if ( $_doLang )
- {
- $notices[] = "All previous language files have been exported into 'cache/previousLangFiles'";
- }
-
- if ( $skipPms )
- {
- $notices[] = "PM Conversion was skipped. If you want to convert PMs, please use the provided shell tool found in your 'tools' directory of the download";
- }
-
- /* Notice about post content */
- $notices[] = "You should now log into your Admin CP and rebuild post content (System > Recount & Rebuild)";
-
- /* Notice about admin restrictions */
- $notices[] = "Due to the change in permission systems, any admins that had restrictions have been updated to have no access to any module until you edit them.";
-
- /* Notice about admin restrictions */
- if ( $rootAdmins )
- {
- $notices[] = "Due to the change in permission systems, 'Root Admins' and 'Administrators' both have full access to the ACP including SQL toolbox, etc. You chose to remove all ACP permissions on upgrade. You can restore selective permissions via the ACP.";
- }
- else
- {
- $notices[] = "Due to the change in permission systems, 'Root Admins' and 'Administrators' both have full access to the ACP including SQL toolbox, etc. You can restrict individual admins using the ACP permission system.";
- }
-
- /* Notice about custom time settings */
- $notices[] = "Due to the change in how times are shown, all custom time/clock formats have been reset.";
-
- /* Notice about FURLs */
- $notices[] = "If you wish to use Friendly URLs, you will need to edit your conf_global.php file and add: \$INFO['use_friendly_urls'] = '1';. Once this is done run also the tool in \"ACP -> System TAB -> Recount & Rebuild -> Resynchronize Forums\".";
-
- return $notices;
- }
-
-
- /**
- * Return any pre-installation notices
- *
- * @return array Array of notices
- */
- public function preInstallNotices()
- {
- $notices = array();
-
- $notices[] = "Skins made for prior versions will not be compatible with this version. The default skin will be restored.";
-
- return $notices;
-
- }
-}
-
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Upgrade Class
+ *
+ * Class to add options and notices for IP.Board upgrade
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
+ *
+ *
+ * @author Matt Mecham
+ * @version $Rev: 10721 $
+ * @since 3.0
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @link http://www.invisionpower.com
+ * @package IP.Board
+ */
+
+class version_class_core_30001
+{
+ /**
+ * Constructor
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function __construct( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+ }
+
+ /**
+ * Add pre-upgrade options: Form
+ *
+ * @return string HTML block
+ */
+ public function preInstallOptionsForm()
+ {
+return <<
+
+
+ Экспортировать текущие шаблоны и CSS? (Будут сохранены в директории /cache/previousSkinFiles)
+
+
+
+ Скопировать старые директории языков в /cache/previousLangFiles ?
+
+
+
+ Пропустить конвертацию личных сообщений? Старые сообщения будут оставлены, вы в любой момент сможете сконвертировать ЛС при помощи shell или утилиты в админцентре.
+
+
+
+ Запретить доступ в АЦ для неглавных администраторов? В систему распеределния прав в IP.Board 3 внесены изменения, поэтому больше нет необходимости разделять администраторов и главных администраторов на разные группы.
+ Вы можете сохранить доступ в АЦ только для главных администраторов и вручную выставить права доступа. Если опция отключена, то
+ все администраторы получат доступ в АЦ независимо от типа.
+
+
+EOF;
+
+ }
+
+ /**
+ * Add pre-upgrade options: Save
+ *
+ * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
+ *
+ * @return array Key / value pairs to save
+ */
+ public function preInstallOptionsSave()
+ {
+ /* Return */
+ return array( 'exportSkins' => intval( $_REQUEST['exportSkins'] ),
+ 'exportLangs' => intval( $_REQUEST['exportLangs'] ),
+ 'skipPms' => intval( $_REQUEST['skipPms'] )
+ );
+
+ }
+
+ /**
+ * Return any post-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function postInstallNotices()
+ {
+ $options = IPSSetUp::getSavedData('custom_options');
+ $_doSkin = $options['core'][30001]['exportSkins'];
+ $_doLang = $options['core'][30001]['exportLangs'];
+ $rootAdmins = $options['core'][30001]['rootAdmins'];
+ $skipPms = $options['core'][30001]['skipPms'];
+
+ $notices = array();
+
+ if ( $_doSkin )
+ {
+ $notices[] = "Все старые стили сохранены в 'cache/previousSkinFiles'";
+ }
+
+ if ( $_doLang )
+ {
+ $notices[] = "Все старые языки сохранены в 'cache/previousLangFiles'";
+ }
+
+ if ( $skipPms )
+ {
+ $notices[] = "Конвертация личных сообщений пропущена. Для конвертации личных сообщений в будущем воспользуйтесь shell-скриптом из директории 'tools' дистрибутива";
+ }
+
+ /* Notice about post content */
+ $notices[] = "Теперь вам необходимо обновить содержимое всех сообщений через админцентр (Система > Пересчет и обновление). ";
+
+ /* Notice about admin restrictions */
+ $notices[] = "Из-за изменений в системе прав доступа. Все администраторы, имевшие ограничения, будут лишены доступа ко всем модулям, пока вы не измените права.";
+
+ /* Notice about admin restrictions */
+ if ( $rootAdmins )
+ {
+ $notices[] = "Были сброшены все ограничения для доступа в админцентр Вы можете восстановить их через АЦ. ";
+ }
+ else
+ {
+ $notices[] = "Все администраторы получили полный доступ к админцентру. Вы можете ограничить их доступ через АЦ. ";
+ }
+
+ /* Notice about custom time settings */
+ $notices[] = "Формат показа времени изменен в настройках. ";
+
+ /* Notice about FURLs */
+ $notices[] = "Для использования Friendly URLs (ЧПУ), добавьте в ваш conf_global.php строчку: \$INFO['use_friendly_urls'] = '1';.";
+
+ return $notices;
+ }
+
+
+ /**
+ * Return any pre-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function preInstallNotices()
+ {
+ $notices = array();
+
+ $notices[] = "Стили внешнего вида более ранних версий будут несовместимы с этой версией форума. Будет восстановлен стиль по-умолчанию.";
+
+ return $notices;
+
+ }
+}
+
diff --git a/upload/admin/applications/core/setup/versions/upg_30001/version_upgrade.php b/upload/admin/applications/core/setup/versions/upg_30001/version_upgrade.php
index 8ac21535..f5ba2057 100644
--- a/upload/admin/applications/core/setup/versions/upg_30001/version_upgrade.php
+++ b/upload/admin/applications/core/setup/versions/upg_30001/version_upgrade.php
@@ -1,1703 +1,1731 @@
-Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class version_upgrade
-{
- /**
- * Custom HTML to show
- *
- * @var string
- */
- protected $_output = '';
-
- /**
- * fetchs output
- *
- * @return string
- */
- public function fetchOutput()
- {
- return $this->_output;
- }
-
- /**
- * Execute selected method
- *
- * @param object Registry object
- * @return @e void
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
-
- //--------------------------------
- // What are we doing?
- //--------------------------------
-
- switch( $this->request['workact'] )
- {
- case 'sql':
- case 'sql1':
- $this->upgradeSql(1);
- break;
- case 'sql2':
- $this->upgradeSql(2);
- break;
- case 'sql3':
- $this->upgradeSql(3);
- break;
- case 'sql4':
- $this->upgradeSql(4);
- break;
- case 'sql5':
- $this->upgradeSql(5);
- break;
- case 'sql6':
- $this->upgradeSql(6);
- break;
- case 'applications':
- $this->addApplications();
- break;
- case 'settings':
- $this->addSettings();
- break;
- case 'profile':
- $this->addProfile();
- break;
- case 'permsAndBbcode':
- $this->permsAndBbcode();
- break;
- case 'skinlang':
- $this->exportSkinLang();
- break;
- case 'pms':
- $this->convertPms();
- break;
- case 'contacts':
- $this->convertBlockLists();
- break;
- case 'pmblock':
- $this->convertPmBlockLists();
- break;
- case 'finish':
- $this->finish();
- break;
-
- default:
- $this->upgradeSql(1);
- break;
- }
-
- /* Workact is set in the function, so if it has not been set, then we're done. The last function should unset it. */
- if ( $this->request['workact'] )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- /**
- * Run SQL files
- *
- * @param int
- * @return @e void
- */
- public function upgradeSql( $id=1 )
- {
- $cnt = 0;
- $SQL = array();
- $file = '_updates_'.$id.'.php';
- $output = "";
- $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_30001/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
- $prefix = $this->registry->dbFunctions()->getPrefix();
- $sourceFile = '';
-
- if ( is_file( $path ) )
- {
- require( $path );/*noLibHook*/
-
- /* Set DB driver to return any errors */
- $this->DB->return_die = 1;
-
- foreach( $SQL as $query )
- {
- $this->DB->allow_sub_select = 1;
- $this->DB->error = '';
-
- $query = str_replace( "<%time%>", time(), $query );
-
- if ( $this->settings['mysql_tbl_type'] )
- {
- if ( preg_match( "/^create table(.+?)/i", $query ) )
- {
- $query = preg_replace( "/^(.+?)\);$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $query );
- }
- }
-
- /* Need to tack on a prefix? */
- if ( $prefix )
- {
- $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
- }
-
- if( IPSSetUp::getSavedData('man') )
- {
- $query = trim( $query );
-
- /* Ensure the last character is a semi-colon */
- if ( substr( $query, -1 ) != ';' )
- {
- $query .= ';';
- }
-
- $output .= $query . "\n\n";
- }
- else
- {
- $this->DB->query( $query );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( " " . $query." ".$this->DB->error );
- }
- else
- {
- $cnt++;
- }
- }
- }
-
- $this->registry->output->addMessage("$cnt queries ran....");
- }
-
- /* Next Page */
- $this->request['st'] = 0;
-
- if ( $id < 6 )
- {
- $nextid = $id + 1;
- $this->request['workact'] = 'sql'.$nextid;
- }
- else
- {
- $this->request['workact'] = 'applications';
- }
-
- if ( IPSSetUp::getSavedData('man') AND $output )
- {
- /* Create source file */
- if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
- {
- $sourceFile = IPSSetUp::createSqlSourceFile( $output, '30001', $id );
- }
-
- $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
- }
- }
-
-
- /**
- * Add Applications
- *
- * @return @e void
- */
- public function addApplications()
- {
- /* Add applications.. */
- $apps = array( 'core' => array(), 'ips' => array(), 'other' => array() );
- $components = array();
-
- foreach( array( 'applications', 'applications_addon/ips', 'applications_addon/other' ) as $_pBit )
- {
- $path = IPS_ROOT_PATH . $_pBit;
- $handle = opendir( $path );
-
- while ( ( $file = readdir( $handle ) ) !== FALSE )
- {
- if ( ! preg_match( "#^\.#", $file ) )
- {
- if ( is_dir( $path . '/' . $file ) )
- {
- //-----------------------------------------
- // Get it!
- //-----------------------------------------
-
- if ( ! is_file( IPS_ROOT_PATH . $_pBit . '/' . $file . '/xml/information.xml' ) )
- {
- continue;
- }
-
- $data = IPSSetUp::fetchXmlAppInformation( $file );
-
- switch( $_pBit )
- {
- case 'applications':
- $apps['core'][ $file ] = $data;
- break;
- case 'applications_addon/ips':
- $apps['ips'][ $file ] = $data;
- break;
- case 'applications_addon/other':
- $apps['other'][ $file ] = $data;
- break;
- }
- }
- }
- }
-
- closedir( $handle );
- }
-
- /* Reorder the array so that core is first */
- $new_array = array();
- $new_array['core'] = $apps['core']['core'];
-
- foreach( $apps['core'] as $app => $data )
- {
- if( $app == 'core' )
- {
- continue;
- }
-
- $new_array[$app] = $data;
- }
-
- $apps['core'] = $new_array;
-
- /* Fetch data for current 'components' */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'components' ) );
-
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $components[ $row['com_section'] ] = $row;
- }
-
- /* Got Gallery? */
- if ( $components['gallery']['com_enabled'] AND $this->DB->checkForTable( 'gallery_upgrade_history' ) )
- {
- /* Fetch current version number */
- $version = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'gallery_upgrade_history',
- 'order' => 'gallery_version_id DESC',
- 'limit' => array( 0, 1 ) ) );
-
- $apps['ips']['gallery']['_currentLong'] = $version['gallery_version_id'];
- $apps['ips']['gallery']['_currentHuman'] = $version['gallery_version_human'];
- }
-
- /* Got Blog? */
- if ( $components['blog']['com_enabled'] AND $this->DB->checkForTable( 'blog_upgrade_history' ) )
- {
- /* Fetch current version number */
- $version = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'blog_upgrade_history',
- 'order' => 'blog_version_id DESC',
- 'limit' => array( 0, 1 ) ) );
-
- $apps['ips']['blog']['_currentLong'] = $version['blog_version_id'];
- $apps['ips']['blog']['_currentHuman'] = $version['blog_version_human'];
- }
-
- /* Got Downloads? */
- if ( $components['downloads']['com_enabled'] AND $this->DB->checkForTable( 'downloads_upgrade_history' ) )
- {
- /* Fetch current version number */
- $version = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'downloads_upgrade_history',
- 'order' => 'idm_version_id DESC',
- 'limit' => array( 0, 1 ) ) );
-
- $apps['ips']['downloads']['_currentLong'] = $version['idm_version_id'];
- $apps['ips']['downloads']['_currentHuman'] = $version['idm_version_human'];
- }
-
- /* Others.. */
- $apps['core']['forums']['_currentLong'] = '30001';
- $apps['core']['forums']['_currentHuman'] = '3.0.0';
-
- $apps['core']['core']['_currentLong'] = '30001';
- $apps['core']['core']['_currentHuman'] = '3.0.0';
-
- $apps['core']['members']['_currentLong'] = '30001';
- $apps['core']['members']['_currentHuman'] = '3.0.0';
-
- $apps['ips']['portal']['_currentLong'] = '30003';
- $apps['ips']['portal']['_currentHuman'] = '3.0.0';
-
- //$apps['ips']['chat']['_currentLong'] = '30003';
- //$apps['ips']['chat']['_currentHuman'] = '3.0.0';
-
- /* If we are upgrading from 2.3 and did not upload the calendar files, we still need to insert
- the applications table entry, otherwise you won't be able to upgrade down the road. We will
- insert it as disabled, however, as calendar won't function since files are not available
- @link http://community.invisionpower.com/tracker/issue-33543-ipb2-upgrades */
- if( !isset($apps['ips']['calendar']['name']) )
- {
- $apps['ips']['calendar'] = array(
- 'name' => 'Calendar',
- 'public_name' => 'Calendar',
- 'description' => "",
- 'author' => "Invision Power Services, Inc.",
- 'hide_tab' => 0,
- 'key' => 'calendar',
- 'disabledatinstall' => 1,
- 'ipskey' => "fa038db69fa627d8e8e034d65f554d1f",
- '_locationkey' => 'ips',
- );
- }
-
- $apps['ips']['calendar']['_currentLong'] = '30003';
- $apps['ips']['calendar']['_currentHuman'] = '3.0.0';
-
- /* Now install them.. */
- $num = 0;
-
- foreach( $apps as $where => $data )
- {
- foreach( $apps[ $where ] as $dir => $appData )
- {
- //-----------------------------------------
- // Had Gallery (e.g.) but didn't upload updated files
- //-----------------------------------------
-
- if( !$appData['name'] )
- {
- continue;
- }
-
- $num++;
- $_protected = ( in_array( $appData['key'], array( 'core', 'forums', 'members' ) ) ) ? 1 : 0;
- $_enabled = ( $appData['disabledatinstall'] ) ? 0 : 1;
-
- if ( ! $appData['_currentLong'] )
- {
- continue;
- }
-
- $this->registry->output->addMessage("Adding application: {$appData['name']}....");
-
- $this->DB->insert( 'core_applications', array( 'app_title' => $appData['name'],
- 'app_public_title' => ( $appData['public_name'] ) ? $appData['public_name'] : '', // Allow blank in case it's an admin-only app
- 'app_description' => $appData['description'],
- 'app_author' => $appData['author'],
- 'app_hide_tab' => intval($appData['hide_tab']),
- 'app_version' => $appData['_currentHuman'],
- 'app_long_version' => $appData['_currentLong'],
- 'app_directory' => $appData['key'],
- 'app_added' => time(),
- 'app_position' => $num,
- 'app_protected' => $_protected,
- 'app_location' => $appData['_locationkey'] ? $appData['_locationkey'] : IPSLib::extractAppLocationKey( $appData['key'] ),
- 'app_enabled' => $_enabled,
- 'app_website' => $appData['website'],
- 'app_update_check' => $appData['update_check'],
- 'app_global_caches' => $appData['global_caches'],
- ) );
- }
- }
-
- /* Next Page */
- $this->request['workact'] = 'settings';
- }
-
- /**
- * Add Settings
- *
- * @return @e void
- */
- public function addSettings()
- {
- /* INIT */
- $known = array();
- $apps = array();
-
- /* Grab all known settings */
- $this->DB->build( array( 'select' => '*', 'from' => 'conf_settings' ) );
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- if ( $row['conf_value'] != '' )
- {
- $known[ $row['conf_key'] ] = $row['conf_value'];
- }
- }
-
- /* Brandon's bug report thingy #12516*/
- if ( ! $known['gb_char_set'] )
- {
- /* No charset, set - so we need to now ensure that iso-8859-1 is set */
- $known['gb_char_set'] = 'iso-8859-1';
- }
-
- /* Wipe out custom time/date settings */
- foreach( array( 'clock_short', 'clock_long', 'clock_tiny', 'clock_date', 'clock_joined', 'time_use_relative_format' ) as $setting )
- {
- unset( $known[ $setting ] );
- }
-
- /* Now we need to fix moderator groups who have permission to RC */
- $groups = array();
-
- $this->DB->build( array( 'select' => 'g_id', 'from' => 'groups', 'where' => 'g_access_cp=1 OR g_is_supmod=1' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $groups[] = $r['g_id'];
- }
-
- $known['report_mod_group_access'] = implode( ',', $groups );
-
- /* Load apps */
- $this->DB->build( array( 'select' => '*', 'from' => 'core_applications' ) );
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $apps[ $row['app_directory'] ] = $row;
- }
-
- /* Add 'em */
- foreach( $apps as $dir => $data )
- {
- if ( is_file( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_settings.xml' ) )
- {
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/settings/settings.php', 'admin_core_settings_settings' );
- $settings = new $classToLoad();
- $settings->makeRegistryShortcuts( $this->registry );
-
- $this->request['app_dir'] = $dir;
- $settings->importAllSettings( 1, 1, $known );
-
- $this->registry->output->addMessage("Added settings for {$data['app_title']}....");
- }
- }
-
- /* Next Page */
- $this->request['workact'] = 'profile';
- }
-
- /**
- * Sort out profile fields
- *
- * @return @e void
- */
- public function addProfile()
- {
- /* INIT */
- $fields = array();
- $prefix = $this->registry->dbFunctions()->getPrefix();
- $sourceFile = '';
-
- /* Get DB driver file */
- require_once( IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_30001/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . '_version_upgrade.php' );/*noLibHook*/
-
- /* First off, move all current profile fields to group ID 3 */
- $this->DB->update( 'pfields_data', array( 'pf_group_id' => 3 ), 'pf_group_id=0' );
-
- /* Grab all custom fields */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'pfields_data' ) );
-
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $fields[ $row['pf_id'] ] = $row;
- }
-
- foreach( $fields as $id => $data )
- {
- /* Now add any missing content fields */
- if ( ! $this->DB->checkForField( "field_$id", 'pfields_content' ) )
- {
- $this->DB->addField( 'pfields_content', "field_$id", 'text' );
- }
- }
-
- $this->DB->optimize( 'pfields_content' );
-
- /* Now make add a key */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'pfields_data',
- 'where' => 'pf_group_id=3' ) );
-
- $o = $this->DB->execute();
-
- while( $row = $this->DB->fetch( $o ) )
- {
- /* Attempt basic conversion of data */
- if ( $row['pf_topic_format'] )
- {
- if ( $row['pf_topic_format'] == '{title}: {content} ' )
- {
- $row['pf_topic_format'] = '{title}: {content} ';
- }
- else if ( $row['pf_topic_format'] == '{title}: {key} ' )
- {
- $row['pf_topic_format'] = '{title}: {key} ';
- }
- }
-
- /* 2.3.x used 'text', 3.0.0 uses 'input'... */
- $row['pf_type'] = ( $row['pf_type'] == 'text' ) ? 'input' : $row['pf_type'];
-
- $this->DB->update( 'pfields_data', array( 'pf_type' => $row['pf_type'], 'pf_topic_format' => $row['pf_topic_format'], 'pf_key' => IPSText::makeSeoTitle( $row['pf_title'] ) ), 'pf_id=' . $row['pf_id'] );
- }
-
- /* Now, move profile data into the correct fields */
- foreach( array( 'aim_name' => 'aim',
- 'icq_number' => 'icq',
- 'website' => 'website',
- 'yahoo' => 'yahoo',
- 'interests' => 'interests',
- 'msnname' => 'msn',
- 'location' => 'location' ) as $old => $new )
- {
- $field = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'pfields_data',
- 'where' => 'pf_key=\'' . $new . '\'' ) );
-
-
-
-
- $query = SQLVC::UpdateOne( $old, $field );
-
- if ( IPSSetUp::getSavedData('man') )
- {
- $query = trim( $query );
-
- /* Ensure the last character is a semi-colon */
- if ( substr( $query, -1 ) != ';' )
- {
- $query .= ';';
- }
-
- $output .= $query . "\n\n";
- }
- else
- {
- $this->DB->query( $query );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( $query." ".$this->DB->error );
- }
- else
- {
- $this->registry->output->addMessage("Converted field: {$old}....");
- }
- }
- }
-
- /* Update gender */
- $gender = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'pfields_data',
- 'where' => 'pf_key=\'gender\'' ) );
-
- if ( $gender['pf_id'] )
- {
- $queries = array( SQLVC::UpdateTwo( $gender ),
- SQLVC::UpdateThree( $gender ) );
-
- foreach( $queries as $query )
- {
- if ( IPSSetUp::getSavedData('man') )
- {
- $query = trim( $query );
-
- /* Ensure the last character is a semi-colon */
- if ( substr( $query, -1 ) != ';' )
- {
- $query .= ';';
- }
-
- $output .= $query . "\n\n";
- }
- else
- {
- $this->DB->query( $query );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( $query." ".$this->DB->error );
- }
- else
- {
- $this->registry->output->addMessage("Converted Gender Field....");
- }
- }
- }
- }
-
- if ( IPSSetUp::getSavedData('man') AND $output )
- {
- /* Create source file */
- if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
- {
- $sourceFile = IPSSetUp::createSqlSourceFile( $output, '30001', 'pf' );
- }
-
- $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
- }
-
- /* Next Page */
- $this->request['workact'] = 'permsAndBbcode';
- }
-
- /**
- * Sort out bbcode and permissions
- *
- * @return @e void
- */
- public function permsAndBbcode()
- {
- /* INIT */
- $options = IPSSetUp::getSavedData('custom_options');
- $rootAdmins = $options['core'][30001]['rootAdmins'];
-
- /* First off, import default BBCode */
- $apps = array();
- $bbcodeOld = array();
- $bbcodeNew = array();
-
- /* Load apps */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'core_applications' ) );
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $apps[ $row['app_directory'] ] = $row;
- }
-
- /* Load old codes */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'custom_bbcode_old' ) );
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $bbcodeOld[ $row['bbcode_tag'] ] = $row;
- }
-
- /* Add 'em */
- foreach( $apps as $dir => $data )
- {
- if ( is_file( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_bbcode.xml' ) )
- {
- //-----------------------------------------
- // Continue
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/posts/bbcode.php', 'admin_core_posts_bbcode' );
- $bbcode = new $classToLoad();
- $bbcode->makeRegistryShortcuts( $this->registry );
-
- $bbcode->bbcodeImportDo( file_get_contents( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_bbcode.xml' ) );
- }
-
- if ( is_file( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_mediatag.xml' ) )
- {
- //-----------------------------------------
- // Continue
- //-----------------------------------------
-
- $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/posts/media.php', 'admin_core_posts_media' );
- $bbcode = new $classToLoad();
- $bbcode->makeRegistryShortcuts( $this->registry );
-
- $bbcode->doMediaImport( file_get_contents( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_mediatag.xml' ) );
- }
- }
-
- /* Load current code */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'custom_bbcode' ) );
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $bbcodeCurrent[ $row['bbcode_tag'] ] = $row;
-
- //-----------------------------------------
- // Need to take into account aliases too!
- //-----------------------------------------
-
- if( $row['bbcode_aliases'] )
- {
- $aliases = explode( ',', $row['bbcode_aliases'] );
-
- if( count($aliases) )
- {
- foreach( $aliases as $alias )
- {
- $bbcodeCurrent[ $alias ] = $row;
- }
- }
- }
- }
-
- if ( count( $bbcodeOld ) )
- {
- foreach( $bbcodeOld as $tag => $row )
- {
- if ( ! $bbcodeCurrent[ $row['bbcode_tag'] ] )
- {
- $bbcodeNew[ $row['bbcode_tag'] ] = $row;
- }
- }
- }
-
- $this->registry->output->addMessage("BBCode tags upgraded....");
-
- /* Now see if there's anything we need to move back over */
- if ( count( $bbcodeNew ) )
- {
- foreach( $bbcodeNew as $tag => $data )
- {
- $bbarray = array(
- 'bbcode_title' => $data['bbcode_title'],
- 'bbcode_desc' => $data['bbcode_desc'],
- 'bbcode_tag' => $data['bbcode_tag'],
- 'bbcode_replace' => IPSText::safeslashes($data['bbcode_replace']),
- 'bbcode_useoption' => $data['bbcode_useoption'],
- 'bbcode_example' => $data['bbcode_example'],
- 'bbcode_switch_option' => $data['bbcode_switch_option'],
- 'bbcode_menu_option_text' => $data['bbcode_menu_option_text'],
- 'bbcode_menu_content_text' => $data['bbcode_menu_content_text'],
- 'bbcode_groups' => 'all',
- 'bbcode_sections' => 'all',
- 'bbcode_php_plugin' => '',
- 'bbcode_parse' => 2,
- 'bbcode_no_parsing' => 0,
- 'bbcode_optional_option' => 0,
- 'bbcode_aliases' => '',
- 'bbcode_image' => ''
- );
-
- $this->DB->insert( 'custom_bbcode', $bbarray );
- }
- }
-
- /* OK, now onto permissions... */
- /* Insert basic perms for profiles and help */
- $this->DB->insert( 'permission_index', array( 'app' => 'members',
- 'perm_type' => 'profile_view',
- 'perm_type_id' => 1,
- 'perm_view' => '*',
- 'perm_2' => '',
- 'perm_3' => '',
- 'perm_4' => '',
- 'perm_5' => '',
- 'perm_6' => '',
- 'perm_7' => '' ) );
-
- $this->DB->insert( 'permission_index', array( 'app' => 'core',
- 'perm_type' => 'help',
- 'perm_type_id' => 1,
- 'perm_view' => '*',
- 'perm_2' => '',
- 'perm_3' => '',
- 'perm_4' => '',
- 'perm_5' => '',
- 'perm_6' => '',
- 'perm_7' => '' ) );
-
- /* And now calendars */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'cal_calendars' ) );
-
- $o = $this->DB->execute();
-
- while( $row = $this->DB->fetch( $o ) )
- {
- if ( strstr( $row['cal_permissions'], 'a:' ) )
- {
- $_perms = unserialize( stripslashes( $row['cal_permissions'] ) );
-
- if ( is_array( $_perms ) )
- {
- $_view = ( $_perms['perm_read'] ) ? ',' . implode( ',', explode( ',', $_perms['perm_read'] ) ) . ',' : '';
- $_start = ( $_perms['perm_post'] ) ? ',' . implode( ',', explode( ',', $_perms['perm_post'] ) ) . ',' : '';
- $_nomod = ( $_perms['perm_nomod'] ) ? ',' . implode( ',', explode( ',', $_perms['perm_nomod'] ) ). ',' : '';
-
- $this->DB->insert( 'permission_index', array( 'app' => 'calendar',
- 'perm_type' => 'calendar',
- 'perm_type_id' => $row['cal_id'],
- 'perm_view' => str_replace( ',*,', '*', $_view ),
- 'perm_2' => str_replace( ',*,', '*', $_start ),
- 'perm_3' => str_replace( ',*,', '*', $_nomod ),
- 'perm_4' => '',
- 'perm_5' => '',
- 'perm_6' => '',
- 'perm_7' => '' ) );
- }
- else
- {
- $this->DB->insert( 'permission_index', array( 'app' => 'calendar',
- 'perm_type' => 'calendar',
- 'perm_type_id' => $row['cal_id'],
- 'perm_view' => '',
- 'perm_2' => '',
- 'perm_3' => '',
- 'perm_4' => '',
- 'perm_5' => '',
- 'perm_6' => '',
- 'perm_7' => '' ) );
- }
- }
- else
- {
- $this->DB->insert( 'permission_index', array( 'app' => 'calendar',
- 'perm_type' => 'calendar',
- 'perm_type_id' => $row['cal_id'],
- 'perm_view' => '',
- 'perm_2' => '',
- 'perm_3' => '',
- 'perm_4' => '',
- 'perm_5' => '',
- 'perm_6' => '',
- 'perm_7' => '' ) );
- }
- }
-
- /* And now forums */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'forums' ) );
-
- $o = $this->DB->execute();
-
- while( $row = $this->DB->fetch( $o ) )
- {
- /* Do we need to tidy up the title? */
- if ( strstr( $row['name'], '&' ) )
- {
- $row['name'] = preg_replace( "#& #", "& ", $row['name'] );
-
- $this->DB->update( 'forums', array( 'name' => $row['name'] ), 'id=' . $row['id'] );
- }
-
- if ( strstr( $row['permission_array'], 'a:' ) )
- {
- $_perms = unserialize( stripslashes( $row['permission_array'] ) );
-
- if ( is_array( $_perms ) )
- {
- $_view = ( $_perms['show_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['show_perms'] ) ) . ',' : '';
- $_read = ( $_perms['read_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['read_perms'] ) ) . ',' : '';
- $_reply = ( $_perms['reply_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['reply_perms'] ) ) . ',' : '';
- $_start = ( $_perms['start_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['start_perms'] ) ) . ',' : '';
- $_upload = ( $_perms['upload_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['upload_perms'] ) ) . ',' : '';
- $_download = ( $_perms['download_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['download_perms'] ) ) . ',' : '';
-
- $this->DB->insert( 'permission_index', array( 'app' => 'forums',
- 'perm_type' => 'forum',
- 'perm_type_id' => $row['id'],
- 'perm_view' => str_replace( ',*,', '*', $_view ),
- 'perm_2' => str_replace( ',*,', '*', $_read ),
- 'perm_3' => str_replace( ',*,', '*', $_reply ),
- 'perm_4' => str_replace( ',*,', '*', $_start ),
- 'perm_5' => str_replace( ',*,', '*', $_upload ),
- 'perm_6' => str_replace( ',*,', '*', $_download ),
- 'perm_7' => '' ) );
- }
- else
- {
- $this->DB->insert( 'permission_index', array( 'app' => 'forums',
- 'perm_type' => 'forum',
- 'perm_type_id' => $row['id'],
- 'perm_view' => '',
- 'perm_2' => '',
- 'perm_3' => '',
- 'perm_4' => '',
- 'perm_5' => '',
- 'perm_6' => '',
- 'perm_7' => '' ) );
-
- IPSSetUp::addLogMessage( "Skipped perms (no array) for forum id: " . $row['id'], '30001', 'core' );
- }
- }
- else
- {
- $this->DB->insert( 'permission_index', array( 'app' => 'forums',
- 'perm_type' => 'forum',
- 'perm_type_id' => $row['id'],
- 'perm_view' => '',
- 'perm_2' => '',
- 'perm_3' => '',
- 'perm_4' => '',
- 'perm_5' => '',
- 'perm_6' => '',
- 'perm_7' => '' ) );
-
- IPSSetUp::addLogMessage( "Skipped perms (no array) for forum id: " . $row['id'], '30001', 'core' );
- }
- }
-
- $this->registry->output->addMessage("Permission indexes built....");
-
- /* Fix up forum moderators */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'moderators' ) );
-
- $o = $this->DB->execute();
-
- while( $r = $this->DB->fetch( $o ) )
- {
- $this->DB->update( 'moderators', array( 'forum_id' => ',' . IPSText::cleanPermString( $r['forum_id'] ) . ',' ), 'mid=' . $r['mid'] );
- }
-
- $this->registry->output->addMessage("Forum moderators updated....");
-
- /* Root admin reset? */
- if ( $rootAdmins )
- {
- /* Find all admin groups */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'groups',
- 'where' => 'g_id != ' . $this->settings['admin_group'] . ' AND g_access_cp=1' ) );
-
- $o = $this->DB->execute();
-
- while( $row = $this->DB->fetch( $o ) )
- {
- /* Insert blank perm row */
- $this->DB->insert( 'admin_permission_rows', array( 'row_id' => $row['g_id'],
- 'row_id_type' => 'group',
- 'row_perm_cache' => serialize( array() ),
- 'row_updated' => time() ) );
- }
-
- $this->registry->output->addMessage("Non Root Admin groups restricted....");
- }
-
- /* Report center reset */
- $canReport = array();
- $canView = array();
-
- $this->DB->build( array( 'select' => 'g_id, g_view_board, g_access_cp, g_is_supmod',
- 'from' => 'groups' ) );
-
- $o = $this->DB->execute();
-
- while( $r = $this->DB->fetch( $o ) )
- {
- if( $r['g_access_cp'] OR $r['g_is_supmod'] )
- {
- $canView[] = $r['g_id'];
- }
-
- if( $r['g_view_board'] AND $r['g_id'] != $this->settings['guest_group'] )
- {
- $canReport[] = $r['g_id'];
- }
- }
-
- $this->DB->update( 'rc_classes', array( 'group_can_report' => ',' . implode( ',', $canReport ) . ',', 'mod_group_perm' => ',' . implode( ',', $canView ) . ',' ) );
-
- /* Next Page */
- $this->request['workact'] = 'skinlang';
- }
-
- /**
- * Export skin and languages
- *
- * @return @e void
- */
- public function exportSkinLang()
- {
- /* INIT */
- $start = intval( $this->request['st'] );
- $converted = 0;
- $options = IPSSetUp::getSavedData('custom_options');
- $_doSkin = $options['core'][30001]['exportSkins'];
- $_doLang = $options['core'][30001]['exportLangs'];
-
- /* Doing anything? */
- if ( ! $_doSkin AND ! $_doLang )
- {
- $this->registry->output->addMessage( "Nothing to export" );
-
- /* Next Page */
- $this->request['workact'] = 'pms';
- return;
- }
-
- /* Ok... */
- if ( ! $start )
- {
- /* Do langs.. */
- if ( $_doLang )
- {
- if ( ! is_dir( IPS_CACHE_PATH . 'cache/previousLangFiles' ) )
- {
- if ( @mkdir( IPS_CACHE_PATH . 'cache/previousLangFiles', IPS_FOLDER_PERMISSION ) )
- {
- @chmod( IPS_CACHE_PATH . 'cache/previousLangFiles', IPS_FOLDER_PERMISSION );
- }
- }
-
- try
- {
- foreach( new DirectoryIterator( IPS_CACHE_PATH . 'cache/lang_cache' ) as $file )
- {
- if ( ! $file->isDot() AND $file->isDir() )
- {
- $name = $file->getFilename();
-
- if ( substr( $name, 0, 1 ) != '.' )
- {
- $this->registry->output->addMessage( "Moved Language Directory: {$name}" );
-
- @rename( IPS_CACHE_PATH . 'cache/lang_cache/' . $name, IPS_CACHE_PATH . 'cache/previousLangFiles/' . $name );
- }
- }
- }
- } catch ( Exception $e ) {}
- }
- }
-
- /* Doing skins? */
- if ( $_doSkin )
- {
- $this->DB->build( array( 'select' => '*',
- 'from' => 'skin_sets',
- 'where' => 'set_skin_set_id > ' . $start,
- 'limit' => array( 0, 1 ),
- 'order' => 'set_skin_set_id ASC' ) );
-
- $this->DB->execute();
-
- $set = $this->DB->fetch();
-
- if ( ! $set )
- {
- $this->request['st'] = 0;
-
- /* All done.. */
- $this->registry->output->addMessage( "No more skin sets to export" );
-
- /* Next Page */
- $this->request['workact'] = 'pms';
- return;
- }
- else
- {
- if ( ! is_dir( IPS_CACHE_PATH . 'cache/previousSkinFiles' ) )
- {
- if ( @mkdir( IPS_CACHE_PATH . 'cache/previousSkinFiles', IPS_FOLDER_PERMISSION ) )
- {
- @chmod( IPS_CACHE_PATH . 'cache/previousSkinFiles', IPS_FOLDER_PERMISSION );
- }
- }
-
- $safeName = IPSText::alphanumericalClean( $set['set_name'] );
- $dirPath = IPS_CACHE_PATH . 'cache/previousSkinFiles/' . $safeName;
-
- if ( @mkdir( $dirPath, IPS_FOLDER_PERMISSION ) )
- {
- @chmod( $dirPath, IPS_FOLDER_PERMISSION );
- }
-
- if ( is_dir( $dirPath ) )
- {
- /* Export CSS */
- if ( @mkdir( $dirPath . '/css', IPS_FOLDER_PERMISSION ) )
- {
- @chmod( $dirPath . '/css', IPS_FOLDER_PERMISSION );
- }
-
- @file_put_contents( $dirPath . '/css/css.css', $set['set_cache_css'] );
-
- /* Export Wrapper */
- if ( @mkdir( $dirPath . '/wrapper', IPS_FOLDER_PERMISSION ) )
- {
- @chmod( $dirPath . '/wrapper', IPS_FOLDER_PERMISSION );
- }
-
- @file_put_contents( $dirPath . '/wrapper/wrapper.html', $set['set_wrapper'] );
-
- /* Export Templates */
- if ( @mkdir( $dirPath . '/templates', IPS_FOLDER_PERMISSION ) )
- {
- @chmod( $dirPath . '/templates', IPS_FOLDER_PERMISSION );
- }
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'skin_templates_old',
- 'where' => 'set_id=' . $set['set_skin_set_id'],
- 'order' => 'func_name ASC' ) );
-
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $_groupName = IPSText::alphanumericalClean( $row['group_name'] );
- $_bitName = IPSText::alphanumericalClean( $row['func_name'] );
-
- /* Make section dir */
- if ( @mkdir( $dirPath . '/templates/' . $_groupName, IPS_FOLDER_PERMISSION ) )
- {
- @chmod( $dirPath . '/templates/' . $_groupName, IPS_FOLDER_PERMISSION );
- }
-
- @file_put_contents( $dirPath . '/templates/' . $_groupName . '/' . $_bitName . '.html', $row['section_content'] );
- }
- }
-
- /* Set ID */
- $this->request['st'] = $set['set_skin_set_id'];
-
- /* We did some, go check again.. */
- $this->registry->output->addMessage( $set['set_name'] . " Exported" );
-
- /* Next Page */
- $this->request['workact'] = 'skinlang';
- return;
- }
- }
-
- /* We did some, go check again.. */
- $this->registry->output->addMessage( 'No skins or languages to export' );
-
- /* Next Page */
- $this->request['workact'] = 'pms';
- return;
- }
-
- /**
- * Convert PMs
- *
- * @return @e void
- */
- public function convertPms()
- {
- /* INIT */
- $pergo = 200;
- $start = intval( $this->request['st'] );
- $converted = 0;
- $seen = 0;
-
- $options = IPSSetUp::getSavedData('custom_options');
- $skipPms = $options['core'][30001]['skipPms'];
-
- /* Skipping? */
- if ( $skipPms )
- {
- /* Update all members */
- $this->DB->update( 'members', array( 'msg_count_reset' => 1, 'msg_count_new' => 0 ) );
-
- /* add a message */
- $this->registry->output->addMessage( "Skipping PM Conversion" );
-
- $this->request['workact'] = 'contacts';
- $this->request['st'] = 0;
- return;
- }
-
- /* Select max topic ID thus far */
- $_tmp = $this->DB->buildAndFetch( array( 'select' => 'MAX(mt_id) as max',
- 'from' => 'message_topics' ) );
-
- $topicID = intval( $_tmp['max'] );
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'message_text',
- 'order' => 'msg_id ASC',
- 'limit' => array( $start, $pergo ) ) );
-
- $o = $this->DB->execute();
-
- while( $post = $this->DB->fetch( $o ) )
- {
- $seen++;
-
- /* Make sure all data is valid */
- if ( intval( $post['msg_sent_to_count'] ) < 1 )
- {
- continue;
- }
-
- /* a little set up */
- $oldTopics = array();
-
- /* Now fetch all topics */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'message_topics_old',
- 'where' => 'mt_msg_id=' . intval( $post['msg_id'] ) ) );
-
- $t = $this->DB->execute();
-
- while( $topic = $this->DB->fetch( $t ) )
- {
- /* Got any data? */
- if ( ! $topic['mt_from_id'] OR ! $topic['mt_to_id'] )
- {
- continue;
- }
-
- $oldTopics[ $topic['mt_id'] ] = $topic; # Luke added that space. That's his first contribution to the code vaults at IPS.
- }
-
- /* Fail safe */
- if ( ! count( $oldTopics ) )
- {
- continue;
- }
-
- /* Increment number */
- $topicID++;
-
- /* Add in the post */
- $this->DB->insert( 'message_posts', array( 'msg_topic_id' => $topicID,
- 'msg_date' => $post['msg_date'],
- 'msg_post' => $post['msg_post'],
- 'msg_post_key' => $post['msg_post_key'],
- 'msg_author_id' => $post['msg_author_id'],
- 'msg_ip_address' => $post['msg_ip_address'],
- 'msg_is_first_post' => 1 ) );
- $postID = $this->DB->getInsertId();
-
- /* Update attachments */
- $this->DB->update( 'attachments', array( 'attach_rel_id' => $postID ), "attach_rel_module='msg' AND attach_rel_id=".$post['msg_id'] );
-
- /* Define some stuff. "To" member is added last in IPB 2 */
- $_tmp = $oldTopics;
- ksort( $_tmp );
- $topicData = array_pop( $_tmp );
- $_invited = array();
- $_seenOwner = array();
- $_isDeleted = 0;
-
- /* Add the member rows */
- foreach( $oldTopics as $mt_id => $data )
- {
- /* Prevent SQL error with unique index: Seen the owner ID already? */
- if ( $_seenOwner[ $data['mt_owner_id'] ] )
- {
- continue;
- }
-
- $_seenOwner[ $data['mt_owner_id'] ] = $data['mt_owner_id'];
-
- /* Build invited - does not include 'to' person */
- if ( $data['mt_owner_id'] AND ( $post['msg_author_id'] != $data['mt_owner_id'] ) AND ( $topicData['mt_to_id'] != $data['mt_owner_id'] ) )
- {
- $_invited[ $data['mt_owner_id'] ] = $data['mt_owner_id'];/*noLibHook*/
- }
-
- $_isSent = ( $data['mt_vid_folder'] == 'sent' ) ? 1 : 0;
- $_isDraft = ( $data['mt_vid_folder'] == 'unsent' ) ? 1 : 0;
-
- $this->DB->insert( 'message_topic_user_map', array( 'map_user_id' => $data['mt_owner_id'],
- 'map_topic_id' => $topicID,
- 'map_folder_id' => ( $_isDraft ) ? 'drafts' : 'myconvo',
- 'map_read_time' => ( $data['mt_user_read'] ) ? $data['mt_user_read'] : ( $data['mt_read'] ? time() : 0 ),
- 'map_user_active' => 1,
- 'map_user_banned' => 0,
- 'map_has_unread' => 0, //( $data['mt_read'] ) ? 0 : 1,
- 'map_is_system' => 0,
- 'map_last_topic_reply' => $post['msg_date'],
- 'map_is_starter' => ( $data['mt_owner_id'] == $post['msg_author_id'] ) ? 1 : 0 ) );
-
- }
-
- /* Now, did we see the author? If not, add them too but as inactive */
- if ( ! $_seenOwner[ $post['msg_author_id'] ] )
- {
- $_isDeleted = 1;
-
- /*$this->DB->insert( 'message_topic_user_map', array( 'map_user_id' => $post['msg_author_id'],
- 'map_topic_id' => $topicID,
- 'map_folder_id' => 'myconvo',
- 'map_read_time' => 0,
- 'map_user_active' => 0,
- 'map_user_banned' => 0,
- 'map_has_unread' => 0,
- 'map_is_system' => 0,
- 'map_is_starter' => 1 ) );*/
- }
-
- $_isSent = ( $topicData['mt_vid_folder'] == 'sent' ) ? 1 : 0;
- $_isDraft = ( $topicData['mt_vid_folder'] == 'unsent' ) ? 1 : 0;
-
- /* This is for MSSQL. I need a quick fix. This is it. Enjoy. */
- if ( method_exists( $this->DB, 'setTableIdentityInsert' ) )
- {
- $this->DB->setTableIdentityInsert( 'message_topics', 'ON' );
- }
-
- /* Add the topic */
- $this->DB->insert( 'message_topics', array( 'mt_id' => $topicID,
- 'mt_date' => $topicData['mt_date'],
- 'mt_title' => $topicData['mt_title'],
- 'mt_starter_id' => $post['msg_author_id'],
- 'mt_start_time' => $post['msg_date'],
- 'mt_last_post_time' => $post['msg_date'],
- 'mt_invited_members' => serialize( array_keys( $_invited ) ),
- 'mt_to_count' => count( array_keys( $_invited ) ) + 1,
- 'mt_to_member_id' => $topicData['mt_to_id'],
- 'mt_replies' => 0,
- 'mt_last_msg_id' => $postID,
- 'mt_first_msg_id' => $postID,
- 'mt_is_draft' => $_isDraft,
- 'mt_is_deleted' => $_isDeleted,
- 'mt_is_system' => 0 ) );
-
- /* This is for MSSQL. I need a quick fix. This is it. Enjoy. */
- if ( method_exists( $this->DB, 'setTableIdentityInsert' ) )
- {
- $this->DB->setTableIdentityInsert( 'message_topics', 'OFF' );
- }
-
- $converted++;
- }
-
- /* What to do? */
- if ( $seen )
- {
- $this->request['st'] = $start + $pergo;
-
- /* We did some, go check again.. */
- $this->registry->output->addMessage( "Checked " . $this->request['st'] . " PMs so far. This cycle: $converted Private Messages converted into conversations.." );
-
- /* Re-do Page */
- $this->request['workact'] = 'pms';
- }
- else
- {
- /* Update all members */
- $this->DB->update( 'members', array( 'msg_count_reset' => 1 ) );
-
- /* Nope, nothing to do - we're done! */
- /* Next Page */
- $this->request['workact'] = 'contacts';
- $this->request['st'] = 0;
- }
- }
-
- /**
- * Convert Block lists
- *
- * @return @e void
- */
- public function convertBlockLists()
- {
- /* INIT */
- $pergo = 200;
- $start = intval( $this->request['st'] );
- $options = IPSSetUp::getSavedData('custom_options');
- $skipPms = $options['core'][30001]['skipPms'];
- $converted = 0;
- $seen = 0;
-
- /* Skipping? */
- if ( $skipPms )
- {
- /* add a message */
- $this->registry->output->addMessage( "Skipping Block List Conversion" );
-
- $this->request['workact'] = 'pmblock';
- $this->request['st'] = 0;
- return;
- }
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'members',
- 'where' => method_exists( $this->DB, 'setTableIdentityInsert' ) ? 'ignored_users NOT LIKE \'\'' : $this->DB->buildLength('ignored_users') . ' > 0',
- 'order' => 'member_id ASC',
- 'limit' => array( $start, $pergo ) ) );
-
- $o = $this->DB->execute();
-
- while( $member = $this->DB->fetch( $o ) )
- {
- $seen++;
-
- /* Got anything? */
- if ( strstr( $member['ignored_users'], ',' ) )
- {
- $ignored = explode( ',', $member['ignored_users'] );
- }
-
- if ( ! is_array( $ignored ) )
- {
- continue;
- }
-
- /* Add it to the table */
- foreach( $ignored as $iid )
- {
- if ( ! $iid )
- {
- continue;
- }
-
- $this->DB->insert( 'ignored_users', array( 'ignore_owner_id' => $member['member_id'],
- 'ignore_ignore_id' => $iid,
- 'ignore_topics' => 1 ) );
- }
-
- $converted++;
- }
-
- /* What to do? */
- if ( $seen )
- {
- $this->request['st'] = $start + $pergo;
-
- /* We did some, go check again.. */
- $this->registry->output->addMessage( "$converted member's ignore list converted." );
-
- /* Re-do Page */
- $this->request['workact'] = 'contacts';
- }
- else
- {
- /* Nope, nothing to do - we're done! */
- /* Next Page */
- $this->request['workact'] = 'pmblock';
- $this->request['st'] = 0;
- }
- }
-
- /**
- * Convert Block lists
- *
- * @return @e void
- */
- public function convertPmBlockLists()
- {
- /* INIT */
- $pergo = 200;
- $start = intval( $this->request['st'] );
- $converted = 0;
- $seen = 0;
- $options = IPSSetUp::getSavedData('custom_options');
- $skipPms = $options['core'][30001]['skipPms'];
-
- /* Skipping? */
- if ( $skipPms )
- {
- /* add a message */
- $this->registry->output->addMessage( "Skipping PM Block List Conversion" );
-
- $this->request['workact'] = 'finish';
- $this->request['st'] = 0;
- return;
- }
-
- $this->DB->build( array( 'select' => '*',
- 'from' => 'contacts',
- 'where' => 'allow_msg=0',
- 'order' => 'id ASC',
- 'limit' => array( $start, $pergo ) ) );
-
- $o = $this->DB->execute();
-
- while( $contact = $this->DB->fetch( $o ) )
- {
- $seen++;
-
- /* Already got an entry for this contact? */
- $test = $this->DB->buildAndFetch( array( 'select' => '*',
- 'from' => 'ignored_users',
- 'where' => 'ignore_owner_id=' . intval( $contact['member_id'] ) ) );
-
- /* Got anything? */
- if ( $test['ignore_owner_id'] )
- {
- $this->DB->update( 'ignored_users', array( 'ignore_messages' => 1 ), 'ignore_id=' . $test['ignore_id'] );
- }
- else
- {
- $this->DB->insert( 'ignored_users', array( 'ignore_owner_id' => $contact['member_id'],
- 'ignore_ignore_id' => $contact['contact_id'],
- 'ignore_messages' => 1 ) );
- }
-
- $converted++;
- }
-
- /* What to do? */
- if ( $seen )
- {
- $this->request['st'] = $start + $pergo;
-
- /* We did some, go check again.. */
- $this->registry->output->addMessage( "$converted member's PM block list converted." );
-
- /* Re-do Page */
- $this->request['workact'] = 'pmblock';
- }
- else
- {
- /* Nope, nothing to do - we're done! */
- /* Next Page */
- $this->request['workact'] = 'finish';
- $this->request['st'] = 0;
- }
- }
-
- /**
- * Finish up conversion stuff
- *
- * @return @e void
- */
- public function finish()
- {
- $options = IPSSetUp::getSavedData('custom_options');
- $skipPms = $options['core'][30001]['skipPms'];
- $output = array();
-
- /* Emoticons */
- if ( file_exists( DOC_IPS_ROOT_PATH . 'style_emoticons/default' ) )
- {
- try
- {
- foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . 'style_emoticons/default' ) as $file )
- {
- if ( ! $file->isDot() )
- {
- $_name = $file->getFileName();
-
- /* Annoyingly, isDot doesn't match .svn, etc */
- if ( substr( $_name, 0, 1 ) == '.' )
- {
- continue;
- }
-
- if ( @copy( DOC_IPS_ROOT_PATH . 'style_emoticons/default/' . $_name, IPS_PUBLIC_PATH . 'style_emoticons/default/' . $_name ) )
- {
- $output[] = "Emoticon: Copying $_name...";
- }
- else
- {
- $output[] = "Could not copy $_name - move it manually post-installation";
- }
- }
- }
- } catch ( Exception $e ) {}
- }
-
- /* LOG IN METHODS */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'login_methods' ) );
-
- $this->DB->execute();
-
- while( $row = $this->DB->fetch() )
- {
- $loginMethods[ $row['login_folder_name'] ] = $row;
- }
-
- $count = 6;
- $recount = array( 'internal' => 1,
- 'ipconverge' => 2,
- 'ldap' => 3,
- 'external' => 4 );
-
- /* Fetch XML */
- require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
- $xml = new classXML( IPSSetUp::charSet );
-
- $xml->load( IPS_ROOT_PATH . 'setup/xml/loginauth.xml' );
-
- foreach( $xml->fetchElements( 'login_methods' ) as $xmlelement )
- {
- $data = $xml->fetchElementsFromRecord( $xmlelement );
-
- $data['login_order'] = ( isset( $recount[ $data['login_folder_name'] ] ) ) ? $recount[ $data['login_folder_name'] ] : ++$count;
-
- unset( $data['login_id'] );
-
- if ( ! $loginMethods[ $data['login_folder_name'] ] )
- {
- $this->DB->insert( 'login_methods', $data );
- }
- else
- {
- $this->DB->update( 'login_methods', array( 'login_order' => $data['login_order'] ), 'login_folder_name=\'' . $data['login_folder_name'] . '\'' );
- }
- }
-
- /* Reset member languages and skins */
- $this->DB->update( 'members', array( 'language' => IPSLib::getDefaultLanguage(), 'skin' => 0 ) );
-
- /* Empty caches */
- $this->DB->delete( 'cache_store', "cs_key='forum_cache'");
- $this->DB->delete( 'cache_store', "cs_key='skin_id_cache'");
-
- /* Empty other tables */
- $this->DB->delete( 'skin_cache' );
- $this->DB->delete( 'skin_templates_cache' );
-
- /* Reset admin permissions */
- $this->DB->update( 'admin_permission_rows', array( 'row_perm_cache' => '' ) );
-
- /* Drop Tables */
- $this->DB->dropTable( 'contacts' );
- $this->DB->dropTable( 'skin_macro' );
- $this->DB->dropTable( 'skin_template_links' );
- $this->DB->dropTable( 'skin_templates_old' );
- $this->DB->dropTable( 'skin_sets' );
- $this->DB->dropTable( 'languages' );
- $this->DB->dropTable( 'topics_read' );
- $this->DB->dropTable( 'topic_markers' );
- $this->DB->dropTable( 'acp_help' );
- $this->DB->dropTable( 'members_converge' );
- $this->DB->dropTable( 'member_extra' );
- $this->DB->dropTable( 'custom_bbcode_old' );
- $this->DB->dropTable( 'admin_sessions' );
- $this->DB->dropTable( 'components' );
- $this->DB->dropTable( 'admin_permission_keys' );
- $this->DB->dropTable( 'conf_settings' );
- $this->DB->dropTable( 'conf_settings_titles' );
- $this->DB->dropTable( 'reg_antispam' );
-
- if ( ! $skipPms )
- {
- $this->DB->dropTable( 'message_text' );
- $this->DB->dropTable( 'message_topics_old' );
- }
-
- $message = ( is_array( $output ) AND count($output) ) ? implode( " ", $output ) . ' ' : '';
-
- $this->registry->output->addMessage( $message . "SQL clean up finished....");
-
- /* Last function, so unset workact */
- $this->request['workact'] = '';
- }
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class version_upgrade
+{
+ /**
+ * Custom HTML to show
+ *
+ * @var string
+ */
+ protected $_output = '';
+
+ /**
+ * fetchs output
+ *
+ * @return string
+ */
+ public function fetchOutput()
+ {
+ return $this->_output;
+ }
+
+ /**
+ * Execute selected method
+ *
+ * @param object Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+ //--------------------------------
+ // What are we doing?
+ //--------------------------------
+
+ switch( $this->request['workact'] )
+ {
+ case 'sql':
+ case 'sql1':
+ $this->upgradeSql(1);
+ break;
+ case 'sql2':
+ $this->upgradeSql(2);
+ break;
+ case 'sql3':
+ $this->upgradeSql(3);
+ break;
+ case 'sql4':
+ $this->upgradeSql(4);
+ break;
+ case 'sql5':
+ $this->upgradeSql(5);
+ break;
+ case 'sql6':
+ $this->upgradeSql(6);
+ break;
+ case 'applications':
+ $this->addApplications();
+ break;
+ case 'settings':
+ $this->addSettings();
+ break;
+ case 'profile':
+ $this->addProfile();
+ break;
+ case 'permsAndBbcode':
+ $this->permsAndBbcode();
+ break;
+ case 'skinlang':
+ $this->exportSkinLang();
+ break;
+ case 'pms':
+ $this->convertPms();
+ break;
+ case 'contacts':
+ $this->convertBlockLists();
+ break;
+ case 'pmblock':
+ $this->convertPmBlockLists();
+ break;
+ case 'polls':
+ $this->rebuildPolls();
+ break;
+ case 'finish':
+ $this->finish();
+ break;
+
+ default:
+ $this->upgradeSql(1);
+ break;
+ }
+
+ /* Workact is set in the function, so if it has not been set, then we're done. The last function should unset it. */
+ if ( $this->request['workact'] )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Run SQL files
+ *
+ * @param int
+ * @return @e void
+ */
+ public function upgradeSql( $id=1 )
+ {
+ $cnt = 0;
+ $SQL = array();
+ $file = '_updates_'.$id.'.php';
+ $output = "";
+ $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_30001/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
+ $prefix = $this->registry->dbFunctions()->getPrefix();
+ $sourceFile = '';
+
+ if ( is_file( $path ) )
+ {
+ require( $path );/*noLibHook*/
+
+ /* Set DB driver to return any errors */
+ $this->DB->return_die = 1;
+
+ foreach( $SQL as $query )
+ {
+ $this->DB->allow_sub_select = 1;
+ $this->DB->error = '';
+
+ $query = str_replace( "<%time%>", time(), $query );
+
+ if ( $this->settings['mysql_tbl_type'] )
+ {
+ if ( preg_match( "/^create table(.+?)/i", $query ) )
+ {
+ $query = preg_replace( "/^(.+?)\);$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $query );
+ }
+ }
+
+ /* Need to tack on a prefix? */
+ if ( $prefix )
+ {
+ $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
+ }
+
+ if( IPSSetUp::getSavedData('man') )
+ {
+ $query = trim( $query );
+
+ /* Ensure the last character is a semi-colon */
+ if ( substr( $query, -1 ) != ';' )
+ {
+ $query .= ';';
+ }
+
+ $output .= $query . "\n\n";
+ }
+ else
+ {
+ $this->DB->query( $query );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( " " . $query." ".$this->DB->error );
+ }
+ else
+ {
+ $cnt++;
+ }
+ }
+ }
+
+ $this->registry->output->addMessage("$cnt запросов выполнено....");
+ }
+
+ /* Next Page */
+ $this->request['st'] = 0;
+
+ if ( $id < 6 )
+ {
+ $nextid = $id + 1;
+ $this->request['workact'] = 'sql'.$nextid;
+ }
+ else
+ {
+ $this->request['workact'] = 'applications';
+ }
+
+ if ( IPSSetUp::getSavedData('man') AND $output )
+ {
+ /* Create source file */
+ if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
+ {
+ $sourceFile = IPSSetUp::createSqlSourceFile( $output, '30001', $id );
+ }
+
+ $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
+ }
+ }
+
+
+ /**
+ * Add Applications
+ *
+ * @return @e void
+ */
+ public function addApplications()
+ {
+ /* Add applications.. */
+ $apps = array( 'core' => array(), 'ips' => array(), 'other' => array() );
+ $components = array();
+
+ foreach( array( 'applications', 'applications_addon/ips', 'applications_addon/other' ) as $_pBit )
+ {
+ $path = IPS_ROOT_PATH . $_pBit;
+ $handle = opendir( $path );
+
+ while ( ( $file = readdir( $handle ) ) !== FALSE )
+ {
+ if ( ! preg_match( "#^\.#", $file ) )
+ {
+ if ( is_dir( $path . '/' . $file ) )
+ {
+ //-----------------------------------------
+ // Get it!
+ //-----------------------------------------
+
+ if ( ! is_file( IPS_ROOT_PATH . $_pBit . '/' . $file . '/xml/information.xml' ) )
+ {
+ continue;
+ }
+
+ $data = IPSSetUp::fetchXmlAppInformation( $file );
+
+ switch( $_pBit )
+ {
+ case 'applications':
+ $apps['core'][ $file ] = $data;
+ break;
+ case 'applications_addon/ips':
+ $apps['ips'][ $file ] = $data;
+ break;
+ case 'applications_addon/other':
+ $apps['other'][ $file ] = $data;
+ break;
+ }
+ }
+ }
+ }
+
+ closedir( $handle );
+ }
+
+ /* Reorder the array so that core is first */
+ $new_array = array();
+ $new_array['core'] = $apps['core']['core'];
+
+ foreach( $apps['core'] as $app => $data )
+ {
+ if( $app == 'core' )
+ {
+ continue;
+ }
+
+ $new_array[$app] = $data;
+ }
+
+ $apps['core'] = $new_array;
+
+ /* Fetch data for current 'components' */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'components' ) );
+
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $components[ $row['com_section'] ] = $row;
+ }
+
+ /* Got Gallery? */
+ if ( $components['gallery']['com_enabled'] AND $this->DB->checkForTable( 'gallery_upgrade_history' ) )
+ {
+ /* Fetch current version number */
+ $version = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'gallery_upgrade_history',
+ 'order' => 'gallery_version_id DESC',
+ 'limit' => array( 0, 1 ) ) );
+
+ $apps['ips']['gallery']['_currentLong'] = $version['gallery_version_id'];
+ $apps['ips']['gallery']['_currentHuman'] = $version['gallery_version_human'];
+ }
+
+ /* Got Blog? */
+ if ( $components['blog']['com_enabled'] AND $this->DB->checkForTable( 'blog_upgrade_history' ) )
+ {
+ /* Fetch current version number */
+ $version = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'blog_upgrade_history',
+ 'order' => 'blog_version_id DESC',
+ 'limit' => array( 0, 1 ) ) );
+
+ $apps['ips']['blog']['_currentLong'] = $version['blog_version_id'];
+ $apps['ips']['blog']['_currentHuman'] = $version['blog_version_human'];
+ }
+
+ /* Got Downloads? */
+ if ( $components['downloads']['com_enabled'] AND $this->DB->checkForTable( 'downloads_upgrade_history' ) )
+ {
+ /* Fetch current version number */
+ $version = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'downloads_upgrade_history',
+ 'order' => 'idm_version_id DESC',
+ 'limit' => array( 0, 1 ) ) );
+
+ $apps['ips']['downloads']['_currentLong'] = $version['idm_version_id'];
+ $apps['ips']['downloads']['_currentHuman'] = $version['idm_version_human'];
+ }
+
+ /* Others.. */
+ $apps['core']['forums']['_currentLong'] = '30001';
+ $apps['core']['forums']['_currentHuman'] = '3.0.0';
+
+ $apps['core']['core']['_currentLong'] = '30001';
+ $apps['core']['core']['_currentHuman'] = '3.0.0';
+
+ $apps['core']['members']['_currentLong'] = '30001';
+ $apps['core']['members']['_currentHuman'] = '3.0.0';
+
+ $apps['ips']['portal']['_currentLong'] = '30003';
+ $apps['ips']['portal']['_currentHuman'] = '3.0.0';
+
+ //$apps['ips']['chat']['_currentLong'] = '30003';
+ //$apps['ips']['chat']['_currentHuman'] = '3.0.0';
+
+ /* If we are upgrading from 2.3 and did not upload the calendar files, we still need to insert
+ the applications table entry, otherwise you won't be able to upgrade down the road. We will
+ insert it as disabled, however, as calendar won't function since files are not available
+ @link http://community.invisionpower.com/tracker/issue-33543-ipb2-upgrades */
+ if( !isset($apps['ips']['calendar']['name']) )
+ {
+ $apps['ips']['calendar'] = array(
+ 'name' => 'Calendar',
+ 'public_name' => 'Calendar',
+ 'description' => "",
+ 'author' => "Invision Power Services, Inc.",
+ 'hide_tab' => 0,
+ 'key' => 'calendar',
+ 'disabledatinstall' => 1,
+ 'ipskey' => "fa038db69fa627d8e8e034d65f554d1f",
+ '_locationkey' => 'ips',
+ );
+ }
+
+ $apps['ips']['calendar']['_currentLong'] = '30003';
+ $apps['ips']['calendar']['_currentHuman'] = '3.0.0';
+
+ /* Now install them.. */
+ $num = 0;
+
+ foreach( $apps as $where => $data )
+ {
+ foreach( $apps[ $where ] as $dir => $appData )
+ {
+ //-----------------------------------------
+ // Had Gallery (e.g.) but didn't upload updated files
+ //-----------------------------------------
+
+ if( !$appData['name'] )
+ {
+ continue;
+ }
+
+ $num++;
+ $_protected = ( in_array( $appData['key'], array( 'core', 'forums', 'members' ) ) ) ? 1 : 0;
+ $_enabled = ( $appData['disabledatinstall'] ) ? 0 : 1;
+
+ if ( ! $appData['_currentLong'] )
+ {
+ continue;
+ }
+
+ $this->registry->output->addMessage("Добавление приложения: {$appData['name']}....");
+
+ $this->DB->insert( 'core_applications', array( 'app_title' => $appData['name'],
+ 'app_public_title' => ( $appData['public_name'] ) ? $appData['public_name'] : '', // Allow blank in case it's an admin-only app
+ 'app_description' => $appData['description'],
+ 'app_author' => $appData['author'],
+ 'app_hide_tab' => intval($appData['hide_tab']),
+ 'app_version' => $appData['_currentHuman'],
+ 'app_long_version' => $appData['_currentLong'],
+ 'app_directory' => $appData['key'],
+ 'app_added' => time(),
+ 'app_position' => $num,
+ 'app_protected' => $_protected,
+ 'app_location' => $appData['_locationkey'] ? $appData['_locationkey'] : IPSLib::extractAppLocationKey( $appData['key'] ),
+ 'app_enabled' => $_enabled,
+ 'app_website' => $appData['website'],
+ 'app_update_check' => $appData['update_check'],
+ 'app_global_caches' => $appData['global_caches'],
+ ) );
+ }
+ }
+
+ /* Next Page */
+ $this->request['workact'] = 'settings';
+ }
+
+ /**
+ * Add Settings
+ *
+ * @return @e void
+ */
+ public function addSettings()
+ {
+ /* INIT */
+ $known = array();
+ $apps = array();
+
+ /* Grab all known settings */
+ $this->DB->build( array( 'select' => '*', 'from' => 'conf_settings' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ if ( $row['conf_value'] != '' )
+ {
+ $known[ $row['conf_key'] ] = $row['conf_value'];
+ }
+ }
+
+ /* Brandon's bug report thingy #12516*/
+ if ( ! $known['gb_char_set'] )
+ {
+ /* No charset, set - so we need to now ensure that iso-8859-1 is set */
+ $known['gb_char_set'] = 'utf-8';
+ }
+
+ /* Wipe out custom time/date settings */
+ foreach( array( 'clock_short', 'clock_long', 'clock_tiny', 'clock_date', 'clock_joined', 'time_use_relative_format' ) as $setting )
+ {
+ unset( $known[ $setting ] );
+ }
+
+ /* Now we need to fix moderator groups who have permission to RC */
+ $groups = array();
+
+ $this->DB->build( array( 'select' => 'g_id', 'from' => 'groups', 'where' => 'g_access_cp=1 OR g_is_supmod=1' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $groups[] = $r['g_id'];
+ }
+
+ $known['report_mod_group_access'] = implode( ',', $groups );
+
+ /* Load apps */
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_applications' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $apps[ $row['app_directory'] ] = $row;
+ }
+
+ /* Add 'em */
+ foreach( $apps as $dir => $data )
+ {
+ if ( is_file( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_settings.xml' ) )
+ {
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/settings/settings.php', 'admin_core_settings_settings' );
+ $settings = new $classToLoad();
+ $settings->makeRegistryShortcuts( $this->registry );
+
+ $this->request['app_dir'] = $dir;
+ $settings->importAllSettings( 1, 1, $known );
+
+ $this->registry->output->addMessage("Добавление настроек для приложения {$data['app_title']}....");
+ }
+ }
+
+ /* Next Page */
+ $this->request['workact'] = 'profile';
+ }
+
+ /**
+ * Sort out profile fields
+ *
+ * @return @e void
+ */
+ public function addProfile()
+ {
+ /* INIT */
+ $fields = array();
+ $prefix = $this->registry->dbFunctions()->getPrefix();
+ $sourceFile = '';
+
+ /* Get DB driver file */
+ require_once( IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_30001/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . '_version_upgrade.php' );/*noLibHook*/
+
+ /* First off, move all current profile fields to group ID 3 */
+ $this->DB->update( 'pfields_data', array( 'pf_group_id' => 3 ), 'pf_group_id=0' );
+
+ /* Grab all custom fields */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'pfields_data' ) );
+
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $fields[ $row['pf_id'] ] = $row;
+ }
+
+ foreach( $fields as $id => $data )
+ {
+ /* Now add any missing content fields */
+ if ( ! $this->DB->checkForField( "field_$id", 'pfields_content' ) )
+ {
+ $this->DB->addField( 'pfields_content', "field_$id", 'text' );
+ }
+ }
+
+ $this->DB->optimize( 'pfields_content' );
+
+ /* Now make add a key */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'pfields_data',
+ 'where' => 'pf_group_id=3' ) );
+
+ $o = $this->DB->execute();
+
+ while( $row = $this->DB->fetch( $o ) )
+ {
+ /* Attempt basic conversion of data */
+ if ( $row['pf_topic_format'] )
+ {
+ if ( $row['pf_topic_format'] == '{title}: {content} ' )
+ {
+ $row['pf_topic_format'] = '{title}: {content} ';
+ }
+ else if ( $row['pf_topic_format'] == '{title}: {key} ' )
+ {
+ $row['pf_topic_format'] = '{title}: {key} ';
+ }
+ }
+
+ /* 2.3.x used 'text', 3.0.0 uses 'input'... */
+ $row['pf_type'] = ( $row['pf_type'] == 'text' ) ? 'input' : $row['pf_type'];
+
+ $this->DB->update( 'pfields_data', array( 'pf_type' => $row['pf_type'], 'pf_topic_format' => $row['pf_topic_format'], 'pf_key' => IPSText::makeSeoTitle( $row['pf_title'] ) ), 'pf_id=' . $row['pf_id'] );
+ }
+
+ /* Now, move profile data into the correct fields */
+ foreach( array( 'aim_name' => 'aim',
+ 'icq_number' => 'icq',
+ 'website' => 'website',
+ 'yahoo' => 'yahoo',
+ 'interests' => 'interests',
+ 'msnname' => 'msn',
+ 'location' => 'location' ) as $old => $new )
+ {
+ $field = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'pfields_data',
+ 'where' => 'pf_key=\'' . $new . '\'' ) );
+
+
+
+
+ $query = SQLVC::UpdateOne( $old, $field );
+
+ if( is_null($query) )
+ {
+ continue;
+ }
+
+ if ( IPSSetUp::getSavedData('man') )
+ {
+ $query = trim( $query );
+
+ /* Ensure the last character is a semi-colon */
+ if ( substr( $query, -1 ) != ';' )
+ {
+ $query .= ';';
+ }
+
+ $output .= $query . "\n\n";
+ }
+ else
+ {
+ $this->DB->query( $query );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( $query." ".$this->DB->error );
+ }
+ else
+ {
+ $this->registry->output->addMessage("Конвертирование поля: {$old}....");
+ }
+ }
+ }
+
+ /* Update gender */
+ $gender = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'pfields_data',
+ 'where' => 'pf_key=\'gender\'' ) );
+
+ if ( $gender['pf_id'] )
+ {
+ $queries = array( SQLVC::UpdateTwo( $gender ),
+ SQLVC::UpdateThree( $gender ) );
+
+ foreach( $queries as $query )
+ {
+ if ( IPSSetUp::getSavedData('man') )
+ {
+ $query = trim( $query );
+
+ /* Ensure the last character is a semi-colon */
+ if ( substr( $query, -1 ) != ';' )
+ {
+ $query .= ';';
+ }
+
+ $output .= $query . "\n\n";
+ }
+ else
+ {
+ $this->DB->query( $query );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( $query." ".$this->DB->error );
+ }
+ else
+ {
+ $this->registry->output->addMessage("Конвертирование поля «Пол»....");
+ }
+ }
+ }
+ }
+
+ if ( IPSSetUp::getSavedData('man') AND $output )
+ {
+ /* Create source file */
+ if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
+ {
+ $sourceFile = IPSSetUp::createSqlSourceFile( $output, '30001', 'pf' );
+ }
+
+ $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
+ }
+
+ /* Next Page */
+ $this->request['workact'] = 'permsAndBbcode';
+ }
+
+ /**
+ * Sort out bbcode and permissions
+ *
+ * @return @e void
+ */
+ public function permsAndBbcode()
+ {
+ /* INIT */
+ $options = IPSSetUp::getSavedData('custom_options');
+ $rootAdmins = $options['core'][30001]['rootAdmins'];
+
+ /* First off, import default BBCode */
+ $apps = array();
+ $bbcodeOld = array();
+ $bbcodeNew = array();
+
+ /* Load apps */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'core_applications' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $apps[ $row['app_directory'] ] = $row;
+ }
+
+ /* Load old codes */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'custom_bbcode_old' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $bbcodeOld[ $row['bbcode_tag'] ] = $row;
+ }
+
+ /* Add 'em */
+ foreach( $apps as $dir => $data )
+ {
+ if ( is_file( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_bbcode.xml' ) )
+ {
+ //-----------------------------------------
+ // Continue
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/posts/bbcode.php', 'admin_core_posts_bbcode' );
+ $bbcode = new $classToLoad();
+ $bbcode->makeRegistryShortcuts( $this->registry );
+
+ $bbcode->bbcodeImportDo( file_get_contents( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_bbcode.xml' ) );
+ }
+
+ if ( is_file( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_mediatag.xml' ) )
+ {
+ //-----------------------------------------
+ // Continue
+ //-----------------------------------------
+
+ $classToLoad = IPSLib::loadActionOverloader( IPS_ROOT_PATH . 'applications/core/modules_admin/posts/media.php', 'admin_core_posts_media' );
+ $bbcode = new $classToLoad();
+ $bbcode->makeRegistryShortcuts( $this->registry );
+
+ $bbcode->doMediaImport( file_get_contents( IPSLib::getAppDir( $dir ) . '/xml/' . $dir . '_mediatag.xml' ) );
+ }
+ }
+
+ /* Load current code */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'custom_bbcode' ) );
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $bbcodeCurrent[ $row['bbcode_tag'] ] = $row;
+
+ //-----------------------------------------
+ // Need to take into account aliases too!
+ //-----------------------------------------
+
+ if( $row['bbcode_aliases'] )
+ {
+ $aliases = explode( ',', $row['bbcode_aliases'] );
+
+ if( count($aliases) )
+ {
+ foreach( $aliases as $alias )
+ {
+ $bbcodeCurrent[ $alias ] = $row;
+ }
+ }
+ }
+ }
+
+ if ( count( $bbcodeOld ) )
+ {
+ foreach( $bbcodeOld as $tag => $row )
+ {
+ if ( ! $bbcodeCurrent[ $row['bbcode_tag'] ] )
+ {
+ $bbcodeNew[ $row['bbcode_tag'] ] = $row;
+ }
+ }
+ }
+
+ $this->registry->output->addMessage("BB-коды обновлены....");
+
+ /* Now see if there's anything we need to move back over */
+ if ( count( $bbcodeNew ) )
+ {
+ foreach( $bbcodeNew as $tag => $data )
+ {
+ $bbarray = array(
+ 'bbcode_title' => $data['bbcode_title'],
+ 'bbcode_desc' => $data['bbcode_desc'],
+ 'bbcode_tag' => $data['bbcode_tag'],
+ 'bbcode_replace' => IPSText::safeslashes($data['bbcode_replace']),
+ 'bbcode_useoption' => $data['bbcode_useoption'],
+ 'bbcode_example' => $data['bbcode_example'],
+ 'bbcode_switch_option' => $data['bbcode_switch_option'],
+ 'bbcode_menu_option_text' => $data['bbcode_menu_option_text'],
+ 'bbcode_menu_content_text' => $data['bbcode_menu_content_text'],
+ 'bbcode_groups' => 'all',
+ 'bbcode_sections' => 'all',
+ 'bbcode_php_plugin' => '',
+ 'bbcode_parse' => 2,
+ 'bbcode_no_parsing' => 0,
+ 'bbcode_optional_option' => 0,
+ 'bbcode_aliases' => '',
+ 'bbcode_image' => ''
+ );
+
+ $this->DB->insert( 'custom_bbcode', $bbarray );
+ }
+ }
+
+ /* OK, now onto permissions... */
+ /* Insert basic perms for profiles and help */
+ $this->DB->insert( 'permission_index', array( 'app' => 'members',
+ 'perm_type' => 'profile_view',
+ 'perm_type_id' => 1,
+ 'perm_view' => '*',
+ 'perm_2' => '',
+ 'perm_3' => '',
+ 'perm_4' => '',
+ 'perm_5' => '',
+ 'perm_6' => '',
+ 'perm_7' => '' ) );
+
+ $this->DB->insert( 'permission_index', array( 'app' => 'core',
+ 'perm_type' => 'help',
+ 'perm_type_id' => 1,
+ 'perm_view' => '*',
+ 'perm_2' => '',
+ 'perm_3' => '',
+ 'perm_4' => '',
+ 'perm_5' => '',
+ 'perm_6' => '',
+ 'perm_7' => '' ) );
+
+ /* And now calendars */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'cal_calendars' ) );
+
+ $o = $this->DB->execute();
+
+ while( $row = $this->DB->fetch( $o ) )
+ {
+ if ( strstr( $row['cal_permissions'], 'a:' ) )
+ {
+ $_perms = unserialize( stripslashes( $row['cal_permissions'] ) );
+
+ if ( is_array( $_perms ) )
+ {
+ $_view = ( $_perms['perm_read'] ) ? ',' . implode( ',', explode( ',', $_perms['perm_read'] ) ) . ',' : '';
+ $_start = ( $_perms['perm_post'] ) ? ',' . implode( ',', explode( ',', $_perms['perm_post'] ) ) . ',' : '';
+ $_nomod = ( $_perms['perm_nomod'] ) ? ',' . implode( ',', explode( ',', $_perms['perm_nomod'] ) ). ',' : '';
+
+ $this->DB->insert( 'permission_index', array( 'app' => 'calendar',
+ 'perm_type' => 'calendar',
+ 'perm_type_id' => $row['cal_id'],
+ 'perm_view' => str_replace( ',*,', '*', $_view ),
+ 'perm_2' => str_replace( ',*,', '*', $_start ),
+ 'perm_3' => str_replace( ',*,', '*', $_nomod ),
+ 'perm_4' => '',
+ 'perm_5' => '',
+ 'perm_6' => '',
+ 'perm_7' => '' ) );
+ }
+ else
+ {
+ $this->DB->insert( 'permission_index', array( 'app' => 'calendar',
+ 'perm_type' => 'calendar',
+ 'perm_type_id' => $row['cal_id'],
+ 'perm_view' => '',
+ 'perm_2' => '',
+ 'perm_3' => '',
+ 'perm_4' => '',
+ 'perm_5' => '',
+ 'perm_6' => '',
+ 'perm_7' => '' ) );
+ }
+ }
+ else
+ {
+ $this->DB->insert( 'permission_index', array( 'app' => 'calendar',
+ 'perm_type' => 'calendar',
+ 'perm_type_id' => $row['cal_id'],
+ 'perm_view' => '',
+ 'perm_2' => '',
+ 'perm_3' => '',
+ 'perm_4' => '',
+ 'perm_5' => '',
+ 'perm_6' => '',
+ 'perm_7' => '' ) );
+ }
+ }
+
+ /* And now forums */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'forums' ) );
+
+ $o = $this->DB->execute();
+
+ while( $row = $this->DB->fetch( $o ) )
+ {
+ /* Do we need to tidy up the title? */
+ if ( strstr( $row['name'], '&' ) )
+ {
+ $row['name'] = preg_replace( "#& #", "& ", $row['name'] );
+
+ $this->DB->update( 'forums', array( 'name' => $row['name'] ), 'id=' . $row['id'] );
+ }
+
+ if ( strstr( $row['permission_array'], 'a:' ) )
+ {
+ $_perms = unserialize( stripslashes( $row['permission_array'] ) );
+
+ if ( is_array( $_perms ) )
+ {
+ $_view = ( $_perms['show_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['show_perms'] ) ) . ',' : '';
+ $_read = ( $_perms['read_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['read_perms'] ) ) . ',' : '';
+ $_reply = ( $_perms['reply_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['reply_perms'] ) ) . ',' : '';
+ $_start = ( $_perms['start_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['start_perms'] ) ) . ',' : '';
+ $_upload = ( $_perms['upload_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['upload_perms'] ) ) . ',' : '';
+ $_download = ( $_perms['download_perms'] ) ? ',' . implode( ',', explode( ',', $_perms['download_perms'] ) ) . ',' : '';
+
+ $this->DB->insert( 'permission_index', array( 'app' => 'forums',
+ 'perm_type' => 'forum',
+ 'perm_type_id' => $row['id'],
+ 'perm_view' => str_replace( ',*,', '*', $_view ),
+ 'perm_2' => str_replace( ',*,', '*', $_read ),
+ 'perm_3' => str_replace( ',*,', '*', $_reply ),
+ 'perm_4' => str_replace( ',*,', '*', $_start ),
+ 'perm_5' => str_replace( ',*,', '*', $_upload ),
+ 'perm_6' => str_replace( ',*,', '*', $_download ),
+ 'perm_7' => '' ) );
+ }
+ else
+ {
+ $this->DB->insert( 'permission_index', array( 'app' => 'forums',
+ 'perm_type' => 'forum',
+ 'perm_type_id' => $row['id'],
+ 'perm_view' => '',
+ 'perm_2' => '',
+ 'perm_3' => '',
+ 'perm_4' => '',
+ 'perm_5' => '',
+ 'perm_6' => '',
+ 'perm_7' => '' ) );
+
+ IPSSetUp::addLogMessage( "Пропущены права доступа для форума ID: " . $row['id'], '30001', 'core' );
+ }
+ }
+ else
+ {
+ $this->DB->insert( 'permission_index', array( 'app' => 'forums',
+ 'perm_type' => 'forum',
+ 'perm_type_id' => $row['id'],
+ 'perm_view' => '',
+ 'perm_2' => '',
+ 'perm_3' => '',
+ 'perm_4' => '',
+ 'perm_5' => '',
+ 'perm_6' => '',
+ 'perm_7' => '' ) );
+
+ IPSSetUp::addLogMessage( "Пропущены права доступа для форума ID: " . $row['id'], '30001', 'core' );
+ }
+ }
+
+ $this->registry->output->addMessage("Права доступа обновлены....");
+
+ /* Fix up forum moderators */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'moderators' ) );
+
+ $o = $this->DB->execute();
+
+ while( $r = $this->DB->fetch( $o ) )
+ {
+ $this->DB->update( 'moderators', array( 'forum_id' => ',' . IPSText::cleanPermString( $r['forum_id'] ) . ',' ), 'mid=' . $r['mid'] );
+ }
+
+ $this->registry->output->addMessage("Модераторы форумов обновлены....");
+
+ /* Root admin reset? */
+ if ( $rootAdmins )
+ {
+ /* Find all admin groups */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'groups',
+ 'where' => 'g_id != ' . $this->settings['admin_group'] . ' AND g_access_cp=1' ) );
+
+ $o = $this->DB->execute();
+
+ while( $row = $this->DB->fetch( $o ) )
+ {
+ /* Insert blank perm row */
+ $this->DB->insert( 'admin_permission_rows', array( 'row_id' => $row['g_id'],
+ 'row_id_type' => 'group',
+ 'row_perm_cache' => serialize( array() ),
+ 'row_updated' => time() ) );
+ }
+
+ $this->registry->output->addMessage("Удалены вторичные группы администраторов....");
+ }
+
+ /* Report center reset */
+ $canReport = array();
+ $canView = array();
+
+ $this->DB->build( array( 'select' => 'g_id, g_view_board, g_access_cp, g_is_supmod',
+ 'from' => 'groups' ) );
+
+ $o = $this->DB->execute();
+
+ while( $r = $this->DB->fetch( $o ) )
+ {
+ if( $r['g_access_cp'] OR $r['g_is_supmod'] )
+ {
+ $canView[] = $r['g_id'];
+ }
+
+ if( $r['g_view_board'] AND $r['g_id'] != $this->settings['guest_group'] )
+ {
+ $canReport[] = $r['g_id'];
+ }
+ }
+
+ $this->DB->update( 'rc_classes', array( 'group_can_report' => ',' . implode( ',', $canReport ) . ',', 'mod_group_perm' => ',' . implode( ',', $canView ) . ',' ) );
+
+ /* Next Page */
+ $this->request['workact'] = 'skinlang';
+ }
+
+ /**
+ * Export skin and languages
+ *
+ * @return @e void
+ */
+ public function exportSkinLang()
+ {
+ /* INIT */
+ $start = intval( $this->request['st'] );
+ $converted = 0;
+ $options = IPSSetUp::getSavedData('custom_options');
+ $_doSkin = $options['core'][30001]['exportSkins'];
+ $_doLang = $options['core'][30001]['exportLangs'];
+
+ /* Doing anything? */
+ if ( ! $_doSkin AND ! $_doLang )
+ {
+ $this->registry->output->addMessage( "Нечего экспортировать" );
+
+ /* Next Page */
+ $this->request['workact'] = 'pms';
+ return;
+ }
+
+ /* Ok... */
+ if ( ! $start )
+ {
+ /* Do langs.. */
+ if ( $_doLang )
+ {
+ if ( ! is_dir( IPS_CACHE_PATH . 'cache/previousLangFiles' ) )
+ {
+ if ( @mkdir( IPS_CACHE_PATH . 'cache/previousLangFiles', IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( IPS_CACHE_PATH . 'cache/previousLangFiles', IPS_FOLDER_PERMISSION );
+ }
+ }
+
+ try
+ {
+ foreach( new DirectoryIterator( IPS_CACHE_PATH . 'cache/lang_cache' ) as $file )
+ {
+ if ( ! $file->isDot() AND $file->isDir() )
+ {
+ $name = $file->getFilename();
+
+ if ( substr( $name, 0, 1 ) != '.' )
+ {
+ $this->registry->output->addMessage( "Перенесена директория языка: {$name}" );
+
+ @rename( IPS_CACHE_PATH . 'cache/lang_cache/' . $name, IPS_CACHE_PATH . 'cache/previousLangFiles/' . $name );
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+ }
+ }
+
+ /* Doing skins? */
+ if ( $_doSkin )
+ {
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'skin_sets',
+ 'where' => 'set_skin_set_id > ' . $start,
+ 'limit' => array( 0, 1 ),
+ 'order' => 'set_skin_set_id ASC' ) );
+
+ $this->DB->execute();
+
+ $set = $this->DB->fetch();
+
+ if ( ! $set )
+ {
+ $this->request['st'] = 0;
+
+ /* All done.. */
+ $this->registry->output->addMessage( "Все стили обработаны" );
+
+ /* Next Page */
+ $this->request['workact'] = 'pms';
+ return;
+ }
+ else
+ {
+ if ( ! is_dir( IPS_CACHE_PATH . 'cache/previousSkinFiles' ) )
+ {
+ if ( @mkdir( IPS_CACHE_PATH . 'cache/previousSkinFiles', IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( IPS_CACHE_PATH . 'cache/previousSkinFiles', IPS_FOLDER_PERMISSION );
+ }
+ }
+
+ $safeName = IPSText::alphanumericalClean( $set['set_name'] );
+ $dirPath = IPS_CACHE_PATH . 'cache/previousSkinFiles/' . $safeName;
+
+ if ( @mkdir( $dirPath, IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( $dirPath, IPS_FOLDER_PERMISSION );
+ }
+
+ if ( is_dir( $dirPath ) )
+ {
+ /* Export CSS */
+ if ( @mkdir( $dirPath . '/css', IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( $dirPath . '/css', IPS_FOLDER_PERMISSION );
+ }
+
+ @file_put_contents( $dirPath . '/css/css.css', $set['set_cache_css'] );
+
+ /* Export Wrapper */
+ if ( @mkdir( $dirPath . '/wrapper', IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( $dirPath . '/wrapper', IPS_FOLDER_PERMISSION );
+ }
+
+ @file_put_contents( $dirPath . '/wrapper/wrapper.html', $set['set_wrapper'] );
+
+ /* Export Templates */
+ if ( @mkdir( $dirPath . '/templates', IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( $dirPath . '/templates', IPS_FOLDER_PERMISSION );
+ }
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'skin_templates_old',
+ 'where' => 'set_id=' . $set['set_skin_set_id'],
+ 'order' => 'func_name ASC' ) );
+
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $_groupName = IPSText::alphanumericalClean( $row['group_name'] );
+ $_bitName = IPSText::alphanumericalClean( $row['func_name'] );
+
+ /* Make section dir */
+ if ( @mkdir( $dirPath . '/templates/' . $_groupName, IPS_FOLDER_PERMISSION ) )
+ {
+ @chmod( $dirPath . '/templates/' . $_groupName, IPS_FOLDER_PERMISSION );
+ }
+
+ @file_put_contents( $dirPath . '/templates/' . $_groupName . '/' . $_bitName . '.html', $row['section_content'] );
+ }
+ }
+
+ /* Set ID */
+ $this->request['st'] = $set['set_skin_set_id'];
+
+ /* We did some, go check again.. */
+ $this->registry->output->addMessage( $set['set_name'] . " Exported" );
+
+ /* Next Page */
+ $this->request['workact'] = 'skinlang';
+ return;
+ }
+ }
+
+ /* We did some, go check again.. */
+ $this->registry->output->addMessage( 'Нет языков или стилей для экспорта' );
+
+ /* Next Page */
+ $this->request['workact'] = 'pms';
+ return;
+ }
+
+ /**
+ * Convert PMs
+ *
+ * @return @e void
+ */
+ public function convertPms()
+ {
+ /* INIT */
+ $pergo = 200;
+ $start = intval( $this->request['st'] );
+ $converted = 0;
+ $seen = 0;
+
+ $options = IPSSetUp::getSavedData('custom_options');
+ $skipPms = $options['core'][30001]['skipPms'];
+
+ /* Skipping? */
+ if ( $skipPms )
+ {
+ /* Update all members */
+ $this->DB->update( 'members', array( 'msg_count_reset' => 1, 'msg_count_new' => 0 ) );
+
+ /* add a message */
+ $this->registry->output->addMessage( "Пропускаем конвертирование ЛС" );
+
+ $this->request['workact'] = 'contacts';
+ $this->request['st'] = 0;
+ return;
+ }
+
+ /* Select max topic ID thus far */
+ $_tmp = $this->DB->buildAndFetch( array( 'select' => 'MAX(mt_id) as max',
+ 'from' => 'message_topics' ) );
+
+ $topicID = intval( $_tmp['max'] );
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'message_text',
+ 'order' => 'msg_id ASC',
+ 'limit' => array( $start, $pergo ) ) );
+
+ $o = $this->DB->execute();
+
+ while( $post = $this->DB->fetch( $o ) )
+ {
+ $seen++;
+
+ /* Make sure all data is valid */
+ if ( intval( $post['msg_sent_to_count'] ) < 1 )
+ {
+ continue;
+ }
+
+ /* a little set up */
+ $oldTopics = array();
+
+ /* Now fetch all topics */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'message_topics_old',
+ 'where' => 'mt_msg_id=' . intval( $post['msg_id'] ) ) );
+
+ $t = $this->DB->execute();
+
+ while( $topic = $this->DB->fetch( $t ) )
+ {
+ /* Got any data? */
+ if ( ! $topic['mt_from_id'] OR ! $topic['mt_to_id'] )
+ {
+ continue;
+ }
+
+ $oldTopics[ $topic['mt_id'] ] = $topic; # Luke added that space. That's his first contribution to the code vaults at IPS.
+ }
+
+ /* Fail safe */
+ if ( ! count( $oldTopics ) )
+ {
+ continue;
+ }
+
+ /* Increment number */
+ $topicID++;
+
+ /* Add in the post */
+ $this->DB->insert( 'message_posts', array( 'msg_topic_id' => $topicID,
+ 'msg_date' => $post['msg_date'],
+ 'msg_post' => $post['msg_post'],
+ 'msg_post_key' => $post['msg_post_key'],
+ 'msg_author_id' => $post['msg_author_id'],
+ 'msg_ip_address' => $post['msg_ip_address'],
+ 'msg_is_first_post' => 1 ) );
+ $postID = $this->DB->getInsertId();
+
+ /* Update attachments */
+ $this->DB->update( 'attachments', array( 'attach_rel_id' => $postID ), "attach_rel_module='msg' AND attach_rel_id=".$post['msg_id'] );
+
+ /* Define some stuff. "To" member is added last in IPB 2 */
+ $_tmp = $oldTopics;
+ ksort( $_tmp );
+ $topicData = array_pop( $_tmp );
+ $_invited = array();
+ $_seenOwner = array();
+ $_isDeleted = 0;
+
+ /* Add the member rows */
+ foreach( $oldTopics as $mt_id => $data )
+ {
+ /* Prevent SQL error with unique index: Seen the owner ID already? */
+ if ( $_seenOwner[ $data['mt_owner_id'] ] )
+ {
+ continue;
+ }
+
+ $_seenOwner[ $data['mt_owner_id'] ] = $data['mt_owner_id'];
+
+ /* Build invited - does not include 'to' person */
+ if ( $data['mt_owner_id'] AND ( $post['msg_author_id'] != $data['mt_owner_id'] ) AND ( $topicData['mt_to_id'] != $data['mt_owner_id'] ) )
+ {
+ $_invited[ $data['mt_owner_id'] ] = $data['mt_owner_id'];/*noLibHook*/
+ }
+
+ $_isSent = ( $data['mt_vid_folder'] == 'sent' ) ? 1 : 0;
+ $_isDraft = ( $data['mt_vid_folder'] == 'unsent' ) ? 1 : 0;
+
+ $this->DB->insert( 'message_topic_user_map', array( 'map_user_id' => $data['mt_owner_id'],
+ 'map_topic_id' => $topicID,
+ 'map_folder_id' => ( $_isDraft ) ? 'drafts' : 'myconvo',
+ 'map_read_time' => ( $data['mt_user_read'] ) ? $data['mt_user_read'] : ( $data['mt_read'] ? time() : 0 ),
+ 'map_user_active' => 1,
+ 'map_user_banned' => 0,
+ 'map_has_unread' => 0, //( $data['mt_read'] ) ? 0 : 1,
+ 'map_is_system' => 0,
+ 'map_last_topic_reply' => $post['msg_date'],
+ 'map_is_starter' => ( $data['mt_owner_id'] == $post['msg_author_id'] ) ? 1 : 0 ) );
+
+ }
+
+ /* Now, did we see the author? If not, add them too but as inactive */
+ if ( ! $_seenOwner[ $post['msg_author_id'] ] )
+ {
+ $_isDeleted = 1;
+
+ /*$this->DB->insert( 'message_topic_user_map', array( 'map_user_id' => $post['msg_author_id'],
+ 'map_topic_id' => $topicID,
+ 'map_folder_id' => 'myconvo',
+ 'map_read_time' => 0,
+ 'map_user_active' => 0,
+ 'map_user_banned' => 0,
+ 'map_has_unread' => 0,
+ 'map_is_system' => 0,
+ 'map_is_starter' => 1 ) );*/
+ }
+
+ $_isSent = ( $topicData['mt_vid_folder'] == 'sent' ) ? 1 : 0;
+ $_isDraft = ( $topicData['mt_vid_folder'] == 'unsent' ) ? 1 : 0;
+
+ /* This is for MSSQL. I need a quick fix. This is it. Enjoy. */
+ if ( method_exists( $this->DB, 'setTableIdentityInsert' ) )
+ {
+ $this->DB->setTableIdentityInsert( 'message_topics', 'ON' );
+ }
+
+ /* Add the topic */
+ $this->DB->insert( 'message_topics', array( 'mt_id' => $topicID,
+ 'mt_date' => $topicData['mt_date'],
+ 'mt_title' => $topicData['mt_title'],
+ 'mt_starter_id' => $post['msg_author_id'],
+ 'mt_start_time' => $post['msg_date'],
+ 'mt_last_post_time' => $post['msg_date'],
+ 'mt_invited_members' => serialize( array_keys( $_invited ) ),
+ 'mt_to_count' => count( array_keys( $_invited ) ) + 1,
+ 'mt_to_member_id' => $topicData['mt_to_id'],
+ 'mt_replies' => 0,
+ 'mt_last_msg_id' => $postID,
+ 'mt_first_msg_id' => $postID,
+ 'mt_is_draft' => $_isDraft,
+ 'mt_is_deleted' => $_isDeleted,
+ 'mt_is_system' => 0 ) );
+
+ /* This is for MSSQL. I need a quick fix. This is it. Enjoy. */
+ if ( method_exists( $this->DB, 'setTableIdentityInsert' ) )
+ {
+ $this->DB->setTableIdentityInsert( 'message_topics', 'OFF' );
+ }
+
+ $converted++;
+ }
+
+ /* What to do? */
+ if ( $seen )
+ {
+ $this->request['st'] = $start + $pergo;
+
+ /* We did some, go check again.. */
+ $this->registry->output->addMessage( "Проверено " . $this->request['st'] . " личных сообщений. Сконвертировано за этот проход $converted." );
+
+ /* Re-do Page */
+ $this->request['workact'] = 'pms';
+ }
+ else
+ {
+ /* Update all members */
+ $this->DB->update( 'members', array( 'msg_count_reset' => 1 ) );
+
+ /* Nope, nothing to do - we're done! */
+ /* Next Page */
+ $this->request['workact'] = 'contacts';
+ $this->request['st'] = 0;
+ }
+ }
+
+ /**
+ * Convert Block lists
+ *
+ * @return @e void
+ */
+ public function convertBlockLists()
+ {
+ /* INIT */
+ $pergo = 200;
+ $start = intval( $this->request['st'] );
+ $options = IPSSetUp::getSavedData('custom_options');
+ $skipPms = $options['core'][30001]['skipPms'];
+ $converted = 0;
+ $seen = 0;
+
+ /* Skipping? */
+ if ( $skipPms )
+ {
+ /* add a message */
+ $this->registry->output->addMessage( "Skipping Block List Conversion" );
+
+ $this->request['workact'] = 'pmblock';
+ $this->request['st'] = 0;
+ return;
+ }
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'members',
+ 'where' => method_exists( $this->DB, 'setTableIdentityInsert' ) ? 'ignored_users NOT LIKE \'\'' : $this->DB->buildLength('ignored_users') . ' > 0',
+ 'order' => 'member_id ASC',
+ 'limit' => array( $start, $pergo ) ) );
+
+ $o = $this->DB->execute();
+
+ while( $member = $this->DB->fetch( $o ) )
+ {
+ $seen++;
+
+ /* Got anything? */
+ if ( strstr( $member['ignored_users'], ',' ) )
+ {
+ $ignored = explode( ',', $member['ignored_users'] );
+ }
+
+ if ( ! is_array( $ignored ) )
+ {
+ continue;
+ }
+
+ /* Add it to the table */
+ foreach( $ignored as $iid )
+ {
+ if ( ! $iid )
+ {
+ continue;
+ }
+
+ $this->DB->insert( 'ignored_users', array( 'ignore_owner_id' => $member['member_id'],
+ 'ignore_ignore_id' => $iid,
+ 'ignore_topics' => 1 ) );
+ }
+
+ $converted++;
+ }
+
+ /* What to do? */
+ if ( $seen )
+ {
+ $this->request['st'] = $start + $pergo;
+
+ /* We did some, go check again.. */
+ $this->registry->output->addMessage( "$converted списков игнорирования сконвертировано." );
+
+ /* Re-do Page */
+ $this->request['workact'] = 'contacts';
+ }
+ else
+ {
+ /* Nope, nothing to do - we're done! */
+ /* Next Page */
+ $this->request['workact'] = 'pmblock';
+ $this->request['st'] = 0;
+ }
+ }
+
+ /**
+ * Convert Block lists
+ *
+ * @return @e void
+ */
+ public function convertPmBlockLists()
+ {
+ /* INIT */
+ $pergo = 200;
+ $start = intval( $this->request['st'] );
+ $converted = 0;
+ $seen = 0;
+ $options = IPSSetUp::getSavedData('custom_options');
+ $skipPms = $options['core'][30001]['skipPms'];
+
+ /* Skipping? */
+ if ( $skipPms )
+ {
+ /* add a message */
+ $this->registry->output->addMessage( "Skipping PM Block List Conversion" );
+
+ $this->request['workact'] = 'finish';
+ $this->request['st'] = 0;
+ return;
+ }
+
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'contacts',
+ 'where' => 'allow_msg=0',
+ 'order' => 'id ASC',
+ 'limit' => array( $start, $pergo ) ) );
+
+ $o = $this->DB->execute();
+
+ while( $contact = $this->DB->fetch( $o ) )
+ {
+ $seen++;
+
+ /* Already got an entry for this contact? */
+ $test = $this->DB->buildAndFetch( array( 'select' => '*',
+ 'from' => 'ignored_users',
+ 'where' => 'ignore_owner_id=' . intval( $contact['member_id'] ) ) );
+
+ /* Got anything? */
+ if ( $test['ignore_owner_id'] )
+ {
+ $this->DB->update( 'ignored_users', array( 'ignore_messages' => 1 ), 'ignore_id=' . $test['ignore_id'] );
+ }
+ else
+ {
+ $this->DB->insert( 'ignored_users', array( 'ignore_owner_id' => $contact['member_id'],
+ 'ignore_ignore_id' => $contact['contact_id'],
+ 'ignore_messages' => 1 ) );
+ }
+
+ $converted++;
+ }
+
+ /* What to do? */
+ if ( $seen )
+ {
+ $this->request['st'] = $start + $pergo;
+
+ /* We did some, go check again.. */
+ $this->registry->output->addMessage( "$converted списков игнорирования личных сообщений сконвертировано." );
+
+ /* Re-do Page */
+ $this->request['workact'] = 'pmblock';
+ }
+ else
+ {
+ /* Nope, nothing to do - we're done! */
+ /* Next Page */
+ $this->request['workact'] = 'polls';
+ }
+ }
+
+ /**
+ * Rebuild polls
+ * Ensures that serialized polls are correctly converted to utf8
+ */
+ public function rebuildPolls()
+ {
+ $this->DB->build( array( 'select' => 'pid, choices', 'from' => 'polls' ) );
+ $o = $this->DB->execute();
+
+ while( $row = $this->DB->fetch( $o ) )
+ {
+ $row['choices'] = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $row['choices'] );
+ $this->DB->update( 'polls', array( 'choices' => $row['choices'] ), 'pid = ' . $row['pid'] );
+ }
+
+ $this->registry->output->addMessage( "Обновление опросов завершено." );
+ $this->request['workact'] = 'finish';
+ $this->request['st'] = 0;
+ }
+
+
+ /**
+ * Finish up conversion stuff
+ *
+ * @return @e void
+ */
+ public function finish()
+ {
+ $options = IPSSetUp::getSavedData('custom_options');
+ $skipPms = $options['core'][30001]['skipPms'];
+ $output = array();
+
+ /* Emoticons */
+ if ( file_exists( DOC_IPS_ROOT_PATH . 'style_emoticons/default' ) )
+ {
+ try
+ {
+ foreach( new DirectoryIterator( DOC_IPS_ROOT_PATH . 'style_emoticons/default' ) as $file )
+ {
+ if ( ! $file->isDot() )
+ {
+ $_name = $file->getFileName();
+
+ /* Annoyingly, isDot doesn't match .svn, etc */
+ if ( substr( $_name, 0, 1 ) == '.' )
+ {
+ continue;
+ }
+
+ if ( @copy( DOC_IPS_ROOT_PATH . 'style_emoticons/default/' . $_name, IPS_PUBLIC_PATH . 'style_emoticons/default/' . $_name ) )
+ {
+ $output[] = "Смайлики: скопирован $_name...";
+ }
+ else
+ {
+ $output[] = "Не удалось скопировать $_name - после обновления перенесите его самостоятельно";
+ }
+ }
+ }
+ } catch ( Exception $e ) {}
+ }
+
+ /* LOG IN METHODS */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'login_methods' ) );
+
+ $this->DB->execute();
+
+ while( $row = $this->DB->fetch() )
+ {
+ $loginMethods[ $row['login_folder_name'] ] = $row;
+ }
+
+ $count = 6;
+ $recount = array( 'internal' => 1,
+ 'ipconverge' => 2,
+ 'ldap' => 3,
+ 'external' => 4 );
+
+ /* Fetch XML */
+ require_once( IPS_KERNEL_PATH . 'classXML.php' );/*noLibHook*/
+ $xml = new classXML( IPSSetUp::charSet );
+
+ $xml->load( IPS_ROOT_PATH . 'setup/xml/loginauth.xml' );
+
+ foreach( $xml->fetchElements( 'login_methods' ) as $xmlelement )
+ {
+ $data = $xml->fetchElementsFromRecord( $xmlelement );
+
+ $data['login_order'] = ( isset( $recount[ $data['login_folder_name'] ] ) ) ? $recount[ $data['login_folder_name'] ] : ++$count;
+
+ unset( $data['login_id'] );
+
+ if ( ! $loginMethods[ $data['login_folder_name'] ] )
+ {
+ $this->DB->insert( 'login_methods', $data );
+ }
+ else
+ {
+ $this->DB->update( 'login_methods', array( 'login_order' => $data['login_order'] ), 'login_folder_name=\'' . $data['login_folder_name'] . '\'' );
+ }
+ }
+
+ /* Reset member languages and skins */
+ $this->DB->update( 'members', array( 'language' => IPSLib::getDefaultLanguage(), 'skin' => 0 ) );
+
+ /* Empty caches */
+ $this->DB->delete( 'cache_store', "cs_key='forum_cache'");
+ $this->DB->delete( 'cache_store', "cs_key='skin_id_cache'");
+
+ /* Empty other tables */
+ $this->DB->delete( 'skin_cache' );
+ $this->DB->delete( 'skin_templates_cache' );
+
+ /* Reset admin permissions */
+ $this->DB->update( 'admin_permission_rows', array( 'row_perm_cache' => '' ) );
+
+ /* Drop Tables */
+ $this->DB->dropTable( 'contacts' );
+ $this->DB->dropTable( 'skin_macro' );
+ $this->DB->dropTable( 'skin_template_links' );
+ $this->DB->dropTable( 'skin_templates_old' );
+ $this->DB->dropTable( 'skin_sets' );
+ $this->DB->dropTable( 'languages' );
+ $this->DB->dropTable( 'topics_read' );
+ $this->DB->dropTable( 'topic_markers' );
+ $this->DB->dropTable( 'acp_help' );
+ $this->DB->dropTable( 'members_converge' );
+ $this->DB->dropTable( 'member_extra' );
+ $this->DB->dropTable( 'custom_bbcode_old' );
+ $this->DB->dropTable( 'admin_sessions' );
+ $this->DB->dropTable( 'components' );
+ $this->DB->dropTable( 'admin_permission_keys' );
+ $this->DB->dropTable( 'conf_settings' );
+ $this->DB->dropTable( 'conf_settings_titles' );
+ $this->DB->dropTable( 'reg_antispam' );
+
+ if ( ! $skipPms )
+ {
+ $this->DB->dropTable( 'message_text' );
+ $this->DB->dropTable( 'message_topics_old' );
+ }
+
+ $message = ( is_array( $output ) AND count($output) ) ? implode( " ", $output ) . ' ' : '';
+
+ $this->registry->output->addMessage( $message . "очистка SQL завершена...");
+
+ /* Last function, so unset workact */
+ $this->request['workact'] = '';
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_30003/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_30003/mysql_updates.php
index 991ec1bf..fb89bc52 100644
--- a/upload/admin/applications/core/setup/versions/upg_30003/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_30003/mysql_updates.php
@@ -1,7 +1,7 @@
Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class version_upgrade
-{
- /**
- * Custom HTML to show
- *
- * @var string
- */
- protected $_output = '';
-
- /**
- * fetchs output
- *
- * @return string
- */
- public function fetchOutput()
- {
- return $this->_output;
- }
-
- /**
- * Execute selected method
- *
- * @param object Registry object
- * @return @e void
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
-
-
- /* Now make add a key */
- $this->DB->build( array( 'select' => '*',
- 'from' => 'pfields_data' ) );
-
- $o = $this->DB->execute();
-
- while( $row = $this->DB->fetch( $o ) )
- {
- /* Attempt conversion of dd / dt microformats */
- if ( stristr( $row['pf_topic_format'], '' ) OR stristr( $row['pf_topic_format'], ' ' ) )
- {
- $row['pf_topic_format'] = str_replace( ' ', "", $row['pf_topic_format'] );
- $row['pf_topic_format'] = str_replace( '', "", $row['pf_topic_format'] );
- $row['pf_topic_format'] = str_replace( array( ' ', '' ), "", $row['pf_topic_format'] );
-
- $this->DB->update( 'pfields_data', array( 'pf_topic_format' => $row['pf_topic_format'] ), 'pf_id=' . $row['pf_id'] );
- }
- }
-
- $this->registry->output->addMessage( "Updated custom profile fields");
-
- return true;
- }
-}
-
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class version_upgrade
+{
+ /**
+ * Custom HTML to show
+ *
+ * @var string
+ */
+ protected $_output = '';
+
+ /**
+ * fetchs output
+ *
+ * @return string
+ */
+ public function fetchOutput()
+ {
+ return $this->_output;
+ }
+
+ /**
+ * Execute selected method
+ *
+ * @param object Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+
+ /* Now make add a key */
+ $this->DB->build( array( 'select' => '*',
+ 'from' => 'pfields_data' ) );
+
+ $o = $this->DB->execute();
+
+ while( $row = $this->DB->fetch( $o ) )
+ {
+ /* Attempt conversion of dd / dt microformats */
+ if ( stristr( $row['pf_topic_format'], '' ) OR stristr( $row['pf_topic_format'], ' ' ) )
+ {
+ $row['pf_topic_format'] = str_replace( ' ', "", $row['pf_topic_format'] );
+ $row['pf_topic_format'] = str_replace( '', "", $row['pf_topic_format'] );
+ $row['pf_topic_format'] = str_replace( array( ' ', '' ), "", $row['pf_topic_format'] );
+
+ $this->DB->update( 'pfields_data', array( 'pf_topic_format' => $row['pf_topic_format'] ), 'pf_id=' . $row['pf_id'] );
+ }
+ }
+
+ $this->registry->output->addMessage( "Обновление пользовательских полей профиля");
+
+ return true;
+ }
+}
+
?>
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_30009/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_30009/mysql_updates.php
index 13c9ddc4..4737fa2f 100644
--- a/upload/admin/applications/core/setup/versions/upg_30009/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_30009/mysql_updates.php
@@ -1,7 +1,7 @@
build( array( 'select' => '*',
diff --git a/upload/admin/applications/core/setup/versions/upg_31003/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_31003/mysql_updates.php
index 264108bc..4360a72f 100644
--- a/upload/admin/applications/core/setup/versions/upg_31003/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_31003/mysql_updates.php
@@ -1,7 +1,7 @@
checkForField( 'replacement_master_key', 'skin_replacements' ) )
$SQL[] = "UPDATE skin_replacements SET replacement_master_key='root' WHERE replacement_set_id=0;";
}
+$SQL[] = "CREATE TABLE vkontakte_connect (
+ v_key varchar(32) NOT NULL default '',
+ v_user varchar(255) NOT NULL default '',
+ v_data varchar(255) NOT NULL default '',
+ v_id bigint(20) NOT NULL
+);";
+
+$SQL[] = "ALTER TABLE members ADD vk_uid bigint(20) unsigned NOT NULL default '0';";
+$SQL[] = "ALTER TABLE members ADD INDEX vk_uid (vk_uid);";
diff --git a/upload/admin/applications/core/setup/versions/upg_31004/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_31004/mysql_updates.php
index 7865f298..b97315d8 100644
--- a/upload/admin/applications/core/setup/versions/upg_31004/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_31004/mysql_updates.php
@@ -1,7 +1,7 @@
- * Invision Power Services
- * IP.Board v3.3.4
- * Upgrade Class
- *
- * Class to add options and notices for IP.Board upgrade
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author Matt Mecham
- * @version $Rev: 10914 $
- * @since 3.0
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @link http://www.invisionpower.com
- * @package IP.Board
- */
-
-class version_class_core_32000
-{
- /**
- * Constructor
- *
- * @param object $registry Registry object
- * @return @e void
- */
- public function __construct( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
- }
-
- /**
- * Add pre-upgrade options: Form
- *
- * @return string HTML block
- */
- public function preInstallOptionsForm()
- {
- $_wrapper = "";
- $_html = '';
- $posts = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'posts' ) );
-
- /* Got more than 100K posts? */
- if( $posts['total'] > 100000 )
- {
-$_html .= <<
-
- Manually apply changes to the posts table? Your site has more than 100,000 posts. We strongly recommend that you enable this option and manually run the provided
- SQL query to alter your posts table in order to prevent timeouts in the web-based upgrader. If you uncheck this option, it is very possible the upgrader will timeout attempting to
- update your posts table.
-
-EOF;
- }
-
- if( $_html )
- {
- return sprintf( $_wrapper, $_html );
- }
- else
- {
- return '';
- }
- }
-
- /**
- * Add pre-upgrade options: Save
- *
- * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
- *
- * @return array Key / value pairs to save
- */
- public function preInstallOptionsSave()
- {
- return array( 'manualPostsTableQuery' => intval( $_REQUEST['manualPostsTableQuery'] )
- );
- }
-
- /**
- * Return any post-installation notices
- *
- * @return array Array of notices
- */
- public function postInstallNotices()
- {
- return array();
- }
-
-
- /**
- * Return any pre-installation notices
- *
- * @return array Array of notices
- */
- public function preInstallNotices()
- {
- $notices = array();
-
- $notices[] = "All XML skins will be uninstalled during the upgrade.";
-
- return $notices;
-
- }
-}
-
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Upgrade Class
+ *
+ * Class to add options and notices for IP.Board upgrade
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
+ *
+ *
+ * @author Matt Mecham
+ * @version $Rev: 10721 $
+ * @since 3.0
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @link http://www.invisionpower.com
+ * @package IP.Board
+ */
+
+class version_class_core_32000
+{
+ /**
+ * Constructor
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function __construct( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+ }
+
+ /**
+ * Add pre-upgrade options: Form
+ *
+ * @return string HTML block
+ */
+ public function preInstallOptionsForm()
+ {
+ $_wrapper = "";
+ $_html = '';
+ $posts = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'posts' ) );
+
+ /* Got more than 100K posts? */
+ if( $posts['total'] > 100000 )
+ {
+$_html .= <<
+
+ Внести изменение в структуру таблицы сообщений вручную? Ваш форум содержит более 100,000 сообщений. Мы крайне рекомендуем чтобы вы включили эту опцию для предотвращения возможных проблем при обновлении мастером обновления. В процессе обновления мастер на необходимом шаге выведет запросы, которые вы должны будете выполнить напрямую в базе данных, после чего вам достаточно будет обновить страницу и процесс будет продолжен.
+
+EOF;
+ }
+
+ if( $_html )
+ {
+ return sprintf( $_wrapper, $_html );
+ }
+ else
+ {
+ return '';
+ }
+ }
+
+ /**
+ * Add pre-upgrade options: Save
+ *
+ * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
+ *
+ * @return array Key / value pairs to save
+ */
+ public function preInstallOptionsSave()
+ {
+ return array( 'manualPostsTableQuery' => intval( $_REQUEST['manualPostsTableQuery'] )
+ );
+ }
+
+ /**
+ * Return any post-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function postInstallNotices()
+ {
+ return array();
+ }
+
+
+ /**
+ * Return any pre-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function preInstallNotices()
+ {
+ $notices = array();
+
+ $notices[] = "При обновлении будут удалены все XML стили.";
+
+ return $notices;
+
+ }
+}
+
diff --git a/upload/admin/applications/core/setup/versions/upg_32000/version_upgrade.php b/upload/admin/applications/core/setup/versions/upg_32000/version_upgrade.php
index 2104d436..e3c9202f 100644
--- a/upload/admin/applications/core/setup/versions/upg_32000/version_upgrade.php
+++ b/upload/admin/applications/core/setup/versions/upg_32000/version_upgrade.php
@@ -1,940 +1,945 @@
-Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class version_upgrade
-{
- /**
- * Custom HTML to show
- *
- * @var string
- */
- protected $_output = '';
-
- /**
- * fetchs output
- *
- * @return string
- */
- public function fetchOutput()
- {
- return $this->_output;
- }
-
- /**
- * Execute selected method
- *
- * @param object Registry object
- * @return @e void
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
-
- //--------------------------------
- // What are we doing?
- //--------------------------------
-
- switch( $this->request['workact'] )
- {
- case 'sql':
- case 'sql1':
- default:
- $this->upgradeSql(1);
- break;
- case 'sql2':
- $this->upgradeSql(2);
- break;
- case 'sql3':
- $this->upgradeSql(3);
- break;
- case 'sql4':
- $this->upgradeSql(4);
- break;
- case 'sql5':
- $this->upgradeSql(5);
- break;
- case 'sql6':
- $this->upgradeSql(6);
- break;
-
- case 'logs':
- case 'logs1':
- $this->upgradeLogs(1);
- break;
- case 'logs2':
- $this->upgradeLogs(2);
- break;
- case 'logs3':
- $this->upgradeLogs(3);
- break;
- case 'logs4':
- $this->upgradeLogs(4);
- break;
- case 'logs5':
- $this->upgradeLogs(5);
- break;
- case 'logs6':
- $this->upgradeLogs(6);
- break;
- case 'logs7':
- $this->upgradeLogs(7);
- break;
- case 'logs8':
- $this->upgradeLogs(8);
- break;
- case 'logs9':
- $this->upgradeLogs(9);
- break;
- case 'logs10':
- $this->upgradeLogs(10);
- break;
-
- case 'forums':
- $this->fixArchiveForums();
- break;
-
- case 'loginmethods':
- $this->fixLoginMethods();
- break;
-
- case 'oldhooks':
- $this->removeOldHooks();
- break;
-
- case 'setdefaultskin':
- $this->setDefaultSkin();
- break;
-
- case 'hooks':
- $this->convertHooks();
- break;
-
- case 'photos':
- $this->convertPhotos();
- break;
- }
-
- /* Workact is set in the function, so if it has not been set, then we're done. The last function should unset it. */
- if ( $this->request['workact'] )
- {
- return false;
- }
- else
- {
- return true;
- }
- }
-
- /**
- * Run SQL files
- *
- * @param int
- * @return @e void
- */
- public function upgradeSql( $id=1 )
- {
- $cnt = 0;
- $file = '_updates_'.$id.'.php';
- $output = "";
- $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_32000/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
- $prefix = $this->registry->dbFunctions()->getPrefix();
- $sourceFile = '';
- $options = IPSSetUp::getSavedData('custom_options');
- $postTable = $options['core'][32000]['manualPostsTableQuery'];
-
- if ( is_file( $path ) )
- {
- $SQL = array();
-
- require( $path );/*noLibHook*/
-
- /* Set DB driver to return any errors */
- $this->DB->return_die = 1;
-
- foreach( $SQL as $query )
- {
- $this->DB->allow_sub_select = 1;
- $this->DB->error = '';
-
- $query = str_replace( "<%time%>", time(), $query );
-
- if ( $this->settings['mysql_tbl_type'] )
- {
- if ( preg_match( "/^create table(.+?)/i", $query ) )
- {
- $query = preg_replace( "/^(.+?)\);$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $query );
- }
- }
-
- /* Need to tack on a prefix? */
- if ( $prefix )
- {
- $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
- }
-
- if( IPSSetUp::getSavedData('man') OR ( $id == 6 AND $postTable ) )
- {
- $query = trim( $query );
-
- /* Ensure the last character is a semi-colon */
- if ( substr( $query, -1 ) != ';' )
- {
- $query .= ';';
- }
-
- $output .= $query . "\n\n";
- }
- else
- {
- $this->DB->query( $query );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( " " . $query . " " . $this->DB->error );
- }
- else
- {
- $cnt++;
- }
- }
- }
-
- $this->registry->output->addMessage("{$cnt} queries ran....");
- }
-
- /* Next Page */
- if ( $id < 6 )
- {
- $nextid = $id + 1;
- $this->request['workact'] = 'sql' . $nextid;
- }
- else
- {
- $this->request['workact'] = 'logs';
- }
-
- if ( $output )
- {
- /* Create source file */
- if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
- {
- $sourceFile = IPSSetUp::createSqlSourceFile( $output, '32000', $id );
- }
-
- $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
- }
- }
-
- /**
- * Upgrade log file tables
- *
- * @param int
- * @return @e void
- */
- public function upgradeLogs( $id=1 )
- {
- /* Verify posts alter table query has run */
- if( $id == 1 )
- {
- if( !$this->DB->checkForField( 'post_bwoptions', 'posts' ) )
- {
- $this->_output = ' ';
- $this->registry->output->addError( "You must first run the query to alter the posts table before you can proceed. Once you have run this query, you can hit refresh to continue." );
- return;
- }
- }
-
- $cnt = 0;
- $file = '_updates_logs_'.$id.'.php';
- $output = "";
- $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_32000/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
- $prefix = $this->registry->dbFunctions()->getPrefix();
-
- if ( is_file( $path ) )
- {
- $SQL = array();
- $TABLE = '';
-
- require( $path );/*noLibHook*/
-
- /* Set DB driver to return any errors */
- $this->DB->return_die = 1;
-
- foreach( $SQL as $query )
- {
- $this->DB->allow_sub_select = 1;
- $this->DB->error = '';
-
- /* Need to tack on a prefix? */
- if ( $prefix )
- {
- $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
- }
-
- /* Chose to prune and run? */
- if( $this->request['pruneAndRun'] )
- {
- $this->DB->delete( $TABLE );
-
- $man = false;
- }
- else
- {
- /* Show alter table / prune option? */
- $man = IPSSetUp::getSavedData('man');
-
- if( $TABLE )
- {
- $count = $this->DB->buildAndFetch( array( 'select' => 'count(*) as logs', 'from' => $TABLE ) );
-
- if( $count['logs'] > 100000 )
- {
- $man = true;
- }
- }
- }
-
- /* Show option to run manually or prune ? */
- if( $man )
- {
- $query = trim( $query );
-
- /* Ensure the last character is a semi-colon */
- if ( substr( $query, -1 ) != ';' )
- {
- $query .= ';';
- }
-
- $output .= $query . "\n\n";
- }
- else
- {
- $this->DB->query( $query );
-
- if ( $this->DB->error )
- {
- $this->registry->output->addError( " " . $query . " " . $this->DB->error );
- }
- else
- {
- $cnt++;
- }
- }
- }
-
- $this->registry->output->addMessage("{$cnt} queries ran....");
- }
-
- /* Next Page */
- if ( $id < 10 )
- {
- $nextid = $id + 1;
- $this->request['workact'] = 'logs' . $nextid;
- }
- else
- {
- $this->request['workact'] = 'forums';
- }
-
- if ( $output )
- {
- $this->_output = $this->registry->output->template()->upgrade_manual_queries_logs( $output, $id, $TABLE );
- }
- }
-
- /**
- * Convert archive forums to read-only forums
- *
- * @return @e void
- */
- public function fixArchiveForums()
- {
- /* Update array for archive forums */
- $_total = 0;
- $_update = array(
- 'perm_3' => '',
- 'perm_4' => '',
- 'perm_5' => '',
- );
-
- /* Get 'archive' forums */
- $this->DB->build( array( 'select' => '*', 'from' => 'forums', 'where' => 'status=0' ) );
- $outer = $this->DB->execute();
-
- while( $r = $this->DB->fetch($outer) )
- {
- $this->DB->update( 'permission_index', $_update, "app='forums' AND perm_type='forum' AND perm_type_id={$r['id']}" );
-
- $_total++;
- }
-
- /* Now drop the status field in forums table */
- $this->DB->dropField( 'forums', 'status' );
-
- /* Message */
- $this->registry->output->addMessage("{$_total} forums with 'archive' status converted to read-only forums....");
-
- /* Next Page */
- $this->request['workact'] = 'loginmethods';
- }
-
- /**
- * Pull login method conf to DB
- *
- * @return @e void
- */
- public function fixLoginMethods()
- {
- /* Init */
- $_total = 0;
-
- if( !defined('IPS_PATH_CUSTOM_LOGIN') )
- {
- define( 'IPS_PATH_CUSTOM_LOGIN' , IPS_ROOT_PATH . 'sources/loginauth' );
- }
-
- /* Try to loop over all login methods to grab current configs */
- try
- {
- foreach( new DirectoryIterator( IPS_PATH_CUSTOM_LOGIN ) as $file )
- {
- if ( $file->isDir() )
- {
- if( is_file( $file->getPathname() . '/conf.php' ) )
- {
- $LOGIN_CONF = array();
-
- include( $file->getPathname() . '/conf.php' );/*noLibHook*/
-
- if( is_array($LOGIN_CONF) AND count($LOGIN_CONF) )
- {
- $this->DB->update( 'login_methods', array( 'login_custom_config' => @serialize($LOGIN_CONF) ), "login_folder_name='" . $this->DB->addSlashes( $file->getFilename() ) . "'" );
-
- $_total++;
- }
- }
- }
- }
- }
- catch( Exception $e )
- {
- }
-
- /* Message */
- $this->registry->output->addMessage("{$_total} login method configs imported....");
-
- /* Next Page */
- $this->request['workact'] = 'oldhooks';
- }
-
- /**
- * Remove old hooks
- *
- * @return @e void
- */
- public function removeOldHooks()
- {
- /* Hooks to remove */
- $hooks = array( 'watched_content', 'todays_top_posters', 'unread_notifications' );
- $_hookIds = array();
- $_total = 0;
-
- /* Get hook records */
- $this->DB->build( array( 'select' => 'hook_id', 'from' => 'core_hooks', 'where' => "hook_key IN('" . implode( "','", $hooks ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $_hookIds[] = $r['hook_id'];
- }
-
- /* Remove associated files */
- if( count($_hookIds) )
- {
- $this->DB->build( array( 'select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
- }
-
- /* Remove hook records */
- $this->DB->delete( 'core_hooks_files', 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' );
- $this->DB->delete( 'core_hooks', 'hook_id IN(' . implode( ',', $_hookIds ) . ')' );
-
- $_total++;
- }
-
- /* Message */
- $this->registry->output->addMessage("{$_total} outdated hook(s) uninstalled....");
-
- /* Next Page */
- $this->request['workact'] = 'setdefaultskin';
- }
-
- /**
- * Restore IPB default skin as default
- *
- * @return @e void
- */
- public function setDefaultSkin()
- {
- /* Get skin functions library */
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
- require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
-
- $skinFunctions = new skinCaching( $this->registry );
-
- /* Update members to use default skin */
- $this->DB->update( 'members', array( 'skin' => 0 ) );
-
- /* Update forums to use default skin */
- $this->DB->update( 'forums', array( 'skin_id' => 0 ) );
-
- /* Reset any default skin(s) */
- $this->DB->update( 'skin_collections', array( 'set_is_default' => 0 ) );
-
- /* Set IPB default skin as default */
- $this->DB->update( 'skin_collections', array( 'set_is_default' => 1 ), "set_key='default'" );
-
- /* Verify we have a skin set as default */
- $_check = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'skin_collections', 'where' => 'set_is_default=1' ) );
-
- if( $_check['total'] < 1 )
- {
- $this->DB->build( array( 'update' => 'skin_collections', 'set' => 'set_is_default=1', 'where' => "set_output_format='html'", 'limit' => array( 0, 1 ) ) );
- $this->DB->execute();
- }
-
- /* Check for any modifications in IPB default skin */
- $_master = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'skin_collections', 'where' => "set_key='default'" ) );
- $_master['set_id'] = intval($_master['set_id']);
- $_modifiedTemplates = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'skin_templates', 'where' => "template_set_id={$_master['set_id']} AND template_removable=1 OR template_user_edited=1" ) );
- $_modifiedCSS = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'skin_css', 'where' => "css_set_id={$_master['set_id']} AND css_master_key=''" ) );
-
- if( $_modifiedTemplates['total'] OR $_modifiedCSS['total'] )
- {
- /* Create a new skin with IPB default as parent */
- $curPos = $skinFunctions->fetchHighestSetPosition();
-
- $_master['set_key'] = 'default_modified';
- $_master['set_parent_id'] = $_master['set_id'];
- $_master['set_is_default'] = 0;
- $_master['set_name'] = $_master['set_name'] . ' (Pre 3.2)';
- $_master['set_order'] = (int)$curPos++;
- unset($_master['set_id']);
-
- $this->DB->insert( 'skin_collections', $_master );
- $set_id = $this->DB->getInsertId();
-
- $this->DB->update( 'skin_templates', array( 'template_set_id' => $set_id ), "template_set_id={$_master['set_parent_id']} AND template_removable=1 OR template_user_edited=1" );
- $this->DB->update( 'skin_css', array( 'css_set_id' => $set_id ), "css_set_id={$_master['set_parent_id']} AND css_master_key=''" );
-
- $skinFunctions->rebuildSkinSetsCache();
- $skinFunctions->rebuildTreeInformation( $set_id );
- //$skinFunctions->flushSkinData();
-
- $skinFunctions->rebuildCSS( $set_id );
- $skinFunctions->rebuildPHPTemplates( $set_id );
- $skinFunctions->rebuildReplacementsCache( $set_id );
- }
-
- /* Message */
- $this->registry->output->addMessage("Default skin restored....");
-
- /* Next Page */
- $this->request['workact'] = 'hooks';
- }
-
- /**
- * Convert stored hook data
- *
- * @return @e void
- */
- public function convertHooks()
- {
- $_total = 0;
-
- /* Grab all hooks */
- $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks' ) );
- $outer = $this->DB->execute();
-
- while( $hook = $this->DB->fetch($outer) )
- {
- $_extraData = unserialize($hook['hook_extra_data']);
-
- /* Fix setting groups */
- if( is_array($_extraData['settingGroups']) AND count($_extraData['settingGroups']) )
- {
- $_settingGroups = array();
-
- foreach( $_extraData['settingGroups'] as $_group )
- {
- if( intval($_group) == $_group )
- {
- $_settingGroups[ $_group ] = intval($_group);
- }
- }
-
- if( count($_settingGroups) )
- {
- $_extraData['settingGroups'] = array();
-
- $this->DB->build( array( 'select' => 'conf_title_id, conf_title_keyword', 'from' => 'core_sys_settings_titles' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- if( in_array( $r['conf_title_id'], $_settingGroups ) )
- {
- $_extraData['settingGroups'][] = $r['conf_title_keyword'];
- }
- }
- }
- }
-
- /* Fix settings */
- if( is_array($_extraData['settings']) AND count($_extraData['settings']) )
- {
- $_settings = array();
-
- foreach( $_extraData['settings'] as $_id )
- {
- if( intval($_id) == $_id )
- {
- $_settings[ $_id ] = intval($_id);
- }
- }
-
- if( count($_settings) )
- {
- $_extraData['settings'] = array();
-
- $this->DB->build( array( 'select' => 'conf_id, conf_key', 'from' => 'core_sys_conf_settings' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- if( in_array( $r['conf_id'], $_settings ) )
- {
- $_extraData['settings'][] = $r['conf_key'];
- }
- }
- }
- }
-
- /* Fix tasks */
- if( is_array($_extraData['tasks']) AND count($_extraData['tasks']) )
- {
- $_tasks = array();
-
- foreach( $_extraData['tasks'] as $_id )
- {
- if( intval($_id) == $_id )
- {
- $_tasks[ $_id ] = intval($_id);
- }
- }
-
- if( count($_tasks) )
- {
- $_extraData['tasks'] = array();
-
- $this->DB->build( array( 'select' => 'task_id, task_key', 'from' => 'task_manager' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- if( in_array( $r['task_id'], $_tasks ) )
- {
- $_extraData['tasks'][] = $r['task_key'];
- }
- }
- }
- }
-
- /* Fix help files */
- if( is_array($_extraData['help']) AND count($_extraData['help']) )
- {
- $_help = array();
-
- foreach( $_extraData['help'] as $_id )
- {
- if( intval($_id) == $_id )
- {
- $_help[ $_id ] = intval($_id);
- }
- }
-
- if( count($_help) )
- {
- $_extraData['help'] = array();
-
- $this->DB->build( array( 'select' => 'id, title', 'from' => 'faq' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- if( in_array( $r['id'], $_help ) )
- {
- $_extraData['help'][] = $r['title'];
- }
- }
- }
- }
-
- /* Fix modules */
- if( is_array($_extraData['modules']) AND count($_extraData['modules']) )
- {
- $_modules = array();
-
- foreach( $_extraData['modules'] as $_id )
- {
- if( intval($_id) == $_id )
- {
- $_modules[ $_id ] = intval($_id);
- }
- }
-
- if( count($_modules) )
- {
- $_extraData['modules'] = array();
-
- $this->DB->build( array( 'select' => 'sys_module_id, sys_module_admin, sys_module_application, sys_module_key', 'from' => 'core_sys_module' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- if( in_array( $r['sys_module_id'], $_modules ) )
- {
- $_extraData['modules'][] = ( $r['sys_module_admin'] ? 'admin' : 'public' ) . '-' . $r['sys_module_application'] . '-' . $r['sys_module_key'];
- }
- }
- }
- }
-
- /* Fix templates */
- if( is_array($_extraData['templates']) AND count($_extraData['templates']) )
- {
- $_newTemplates = array();
-
- foreach( $_extraData['templates'] as $file => $templates )
- {
- foreach( $templates as $template )
- {
- $_newTemplates[ $file ][ $template ] = $template;
- }
- }
-
- $_extraData['templates'] = $_newTemplates;
- }
-
- /* Fix CSS */
- if( is_array($_extraData['css']) AND count($_extraData['css']) )
- {
- $_css = array();
-
- foreach( $_extraData['css'] as $_id )
- {
- if( intval($_id) == $_id )
- {
- $_css[ $_id ] = intval($_id);
- }
- }
-
- if( count($_css) )
- {
- $_extraData['css'] = array();
-
- $this->DB->build( array( 'select' => 'css_group', 'from' => 'skin_css', 'where' => "css_id IN(" . implode( ',', $_css ) . ")" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $_extraData['css'][ $r['css_group'] ] = $r['css_group'];
- }
- }
- }
-
- $this->DB->update( 'core_hooks', array( 'hook_extra_data' => serialize( $_extraData ) ), 'hook_id=' . $hook['hook_id'] );
-
- $_total++;
- }
-
- /* Message */
- $this->registry->output->addMessage("{$_total} hooks updated....");
-
- /* Next Page */
- $this->request['workact'] = 'photos';
- }
-
- /**
- * Convert and rebuild photos
- *
- * @param int
- * @return @e void
- */
- public function convertPhotos()
- {
- /* Is this the first cycle? */
- if( !$this->request['from'] )
- {
- $this->_output = <<Profile Photo Conversion
-
- IP.Board 3.2 supports one image to identify each user. You can choose to retain your existing avatars or your existing profile photos for this image.
-
-
- Use avatars
- Use profile photos
-
-
- The image you save will need to be rebuilt. You can let the upgrader handle this now, or you can skip this step and complete it later from the ACP.
-
-
Rebuild thumbnails now
-
Skip this step and rebuild thumbnails from the ACP later
-EOF;
-
- return;
- }
-
- /* Our options */
- $convertFrom = $this->request['from'] == 'avatars' ? 'avatars' : 'photos';
- $skipRebuild = intval($this->request['skip']);
-
- /* Init */
- $st = intval($this->request['st']);
- $did = 0;
- $each = 200;
-
- require_once( IPS_ROOT_PATH . 'sources/classes/member/photo.php' );/*noLibHook*/
- $photo = new classes_member_photo( $this->registry );
-
- /* Loop over members */
- $this->DB->build( array( 'select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'limit' => array( $st, $each ) ) );
- $outer = $this->DB->execute();
-
- while( $r = $this->DB->fetch($outer) )
- {
- $did++;
-
- $update = array();
-
- if( $r['fb_photo'] )
- {
- $update['pp_photo_type'] = 'facebook';
- }
- else if( $r['tc_photo'] )
- {
- $update['pp_photo_type'] = 'twitter';
- }
- else
- {
- if( $convertFrom == 'avatars' )
- {
- if( $r['avatar_type'] == 'upload' AND $r['avatar_location'] )
- {
- $update['pp_photo_type'] = 'custom';
- $update['pp_main_photo'] = $r['avatar_location'];
- $_dims = @getimagesize( $this->settings['upload_dir'] . '/' . $r['avatar_location'] );
- $update['pp_main_width'] = $_dims[0] ? $_dims[0] : 1;
- $update['pp_main_height'] = $_dims[1] ? $_dims[1] : 1;
- }
- else if( $r['avatar_type'] == 'gravatar' )
- {
- $update['pp_photo_type'] = 'gravatar';
- $update['pp_gravatar'] = $r['avatar_location'];
-
- $md5Gravatar = md5( $update['pp_gravatar'] );
-
- $_url = "http://www.gravatar.com";
-
- if( $this->registry->output->isHTTPS )
- {
- $_url = "https://secure.gravatar.com";
- }
-
- $update['pp_main_photo'] = $_url . "/avatar/" .$md5Gravatar . "?s=100";
- $update['pp_main_width'] = 100;
- $update['pp_main_height'] = 100;
- $update['pp_thumb_photo'] = $_url . "/avatar/" .$md5Gravatar . "?s=100";
- $update['pp_thumb_width'] = 100;
- $update['pp_thumb_height'] = 100;
- }
- }
- else
- {
- if( $r['pp_main_photo'] )
- {
- $update['pp_photo_type'] = 'custom';
- $update['pp_main_photo'] = $r['pp_main_photo'];
- }
- }
- }
-
- if( !$skipRebuild AND $update['pp_photo_type'] == 'custom' )
- {
- $info = $photo->buildSizedPhotos( str_replace( 'upload:', '', $update['pp_main_photo'] ), $r['pp_member_id'], true );
-
- $update['pp_main_width'] = intval( $info['final_width'] );
- $update['pp_main_height'] = intval( $info['final_height'] );
- $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
- $update['pp_thumb_width'] = intval( $info['t_final_width'] );
- $update['pp_thumb_height'] = intval( $info['t_final_height'] );
- }
-
- if( count($update) )
- {
- $this->DB->update( 'profile_portal', $update, 'pp_member_id=' . $r['pp_member_id'] );
- }
- }
-
- /* Show message and redirect */
- if( $did > 0 )
- {
- $this->request['st'] = ( $st + $did );
- $this->request['workact'] = 'photos';
-
- $message = $skipRebuild ? "Up to {$this->request['st']} profile photos converted ..." : "Up to {$this->request['st']} profile photos converted and rebuilt...";
- $this->registry->output->addMessage( $message );
-
- /* Yes, we are being sneaky here. Shhhhh */
- $this->request['st'] = $this->request['st'] . '&from=' . $this->request['from'] . '&skip=' . $skipRebuild;
- }
- else
- {
- $this->request['st'] = 0;
- $this->request['workact'] = '';
-
- $this->registry->output->addMessage( "All profile photos converted..." );
- }
-
- /* Next Page */
- return;
- }
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class version_upgrade
+{
+ /**
+ * Custom HTML to show
+ *
+ * @var string
+ */
+ protected $_output = '';
+
+ /**
+ * fetchs output
+ *
+ * @return string
+ */
+ public function fetchOutput()
+ {
+ return $this->_output;
+ }
+
+ /**
+ * Execute selected method
+ *
+ * @param object Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+ //--------------------------------
+ // What are we doing?
+ //--------------------------------
+
+ switch( $this->request['workact'] )
+ {
+ case 'sql':
+ case 'sql1':
+ default:
+ $this->upgradeSql(1);
+ break;
+ case 'sql2':
+ $this->upgradeSql(2);
+ break;
+ case 'sql3':
+ $this->upgradeSql(3);
+ break;
+ case 'sql4':
+ $this->upgradeSql(4);
+ break;
+ case 'sql5':
+ $this->upgradeSql(5);
+ break;
+ case 'sql6':
+ $this->upgradeSql(6);
+ break;
+
+ case 'logs':
+ case 'logs1':
+ $this->upgradeLogs(1);
+ break;
+ case 'logs2':
+ $this->upgradeLogs(2);
+ break;
+ case 'logs3':
+ $this->upgradeLogs(3);
+ break;
+ case 'logs4':
+ $this->upgradeLogs(4);
+ break;
+ case 'logs5':
+ $this->upgradeLogs(5);
+ break;
+ case 'logs6':
+ $this->upgradeLogs(6);
+ break;
+ case 'logs7':
+ $this->upgradeLogs(7);
+ break;
+ case 'logs8':
+ $this->upgradeLogs(8);
+ break;
+ case 'logs9':
+ $this->upgradeLogs(9);
+ break;
+ case 'logs10':
+ $this->upgradeLogs(10);
+ break;
+
+ case 'forums':
+ $this->fixArchiveForums();
+ break;
+
+ case 'loginmethods':
+ $this->fixLoginMethods();
+ break;
+
+ case 'oldhooks':
+ $this->removeOldHooks();
+ break;
+
+ case 'setdefaultskin':
+ $this->setDefaultSkin();
+ break;
+
+ case 'hooks':
+ $this->convertHooks();
+ break;
+
+ case 'photos':
+ $this->convertPhotos();
+ break;
+ }
+
+ /* Workact is set in the function, so if it has not been set, then we're done. The last function should unset it. */
+ if ( $this->request['workact'] )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Run SQL files
+ *
+ * @param int
+ * @return @e void
+ */
+ public function upgradeSql( $id=1 )
+ {
+ $cnt = 0;
+ $file = '_updates_'.$id.'.php';
+ $output = "";
+ $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_32000/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
+ $prefix = $this->registry->dbFunctions()->getPrefix();
+ $sourceFile = '';
+ $options = IPSSetUp::getSavedData('custom_options');
+ $postTable = $options['core'][32000]['manualPostsTableQuery'];
+
+ if ( is_file( $path ) )
+ {
+ $SQL = array();
+
+ require( $path );/*noLibHook*/
+
+ /* Set DB driver to return any errors */
+ $this->DB->return_die = 1;
+
+ foreach( $SQL as $query )
+ {
+ $this->DB->allow_sub_select = 1;
+ $this->DB->error = '';
+
+ $query = str_replace( "<%time%>", time(), $query );
+
+ if ( $this->settings['mysql_tbl_type'] )
+ {
+ if ( preg_match( "/^create table(.+?)/i", $query ) )
+ {
+ $query = preg_replace( "/^(.+?)\);$/is", "\\1) ENGINE={$this->settings['mysql_tbl_type']};", $query );
+ }
+ }
+
+ /* Need to tack on a prefix? */
+ if ( $prefix )
+ {
+ $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
+ }
+
+ if( IPSSetUp::getSavedData('man') OR ( $id == 6 AND $postTable ) )
+ {
+ $query = trim( $query );
+
+ /* Ensure the last character is a semi-colon */
+ if ( substr( $query, -1 ) != ';' )
+ {
+ $query .= ';';
+ }
+
+ $output .= $query . "\n\n";
+ }
+ else
+ {
+ $this->DB->query( $query );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( "
" . $query . "
" . $this->DB->error );
+ }
+ else
+ {
+ $cnt++;
+ }
+ }
+ }
+
+ $this->registry->output->addMessage("{$cnt} запросов выполнено....");
+ }
+
+ /* Next Page */
+ if ( $id < 6 )
+ {
+ $nextid = $id + 1;
+ $this->request['workact'] = 'sql' . $nextid;
+ }
+ else
+ {
+ $this->request['workact'] = 'logs';
+ }
+
+ if ( $output )
+ {
+ /* Create source file */
+ if ( $this->registry->dbFunctions()->getDriverType() == 'mysql' )
+ {
+ $sourceFile = IPSSetUp::createSqlSourceFile( $output, '32000', $id );
+ }
+
+ $this->_output = $this->registry->output->template()->upgrade_manual_queries( $output, $sourceFile );
+ }
+ }
+
+ /**
+ * Upgrade log file tables
+ *
+ * @param int
+ * @return @e void
+ */
+ public function upgradeLogs( $id=1 )
+ {
+ /* Verify posts alter table query has run */
+ if( $id == 1 )
+ {
+ if( !$this->DB->checkForField( 'post_bwoptions', 'posts' ) )
+ {
+ $this->_output = ' ';
+ $this->registry->output->addError( "Вы должны выполнить запрос изменяющий таблицу posts. После того как вы выполните это, просто обновите данную страницу и обновление будет продолжено." );
+ return;
+ }
+ }
+
+ $cnt = 0;
+ $file = '_updates_logs_'.$id.'.php';
+ $output = "";
+ $path = IPSLib::getAppDir( 'core' ) . '/setup/versions/upg_32000/' . strtolower( $this->registry->dbFunctions()->getDriverType() ) . $file;
+ $prefix = $this->registry->dbFunctions()->getPrefix();
+
+ if ( is_file( $path ) )
+ {
+ $SQL = array();
+ $TABLE = '';
+
+ require( $path );/*noLibHook*/
+
+ /* Set DB driver to return any errors */
+ $this->DB->return_die = 1;
+
+ foreach( $SQL as $query )
+ {
+ $this->DB->allow_sub_select = 1;
+ $this->DB->error = '';
+
+ /* Need to tack on a prefix? */
+ if ( $prefix )
+ {
+ $query = IPSSetUp::addPrefixToQuery( $query, $prefix );
+ }
+
+ /* Chose to prune and run? */
+ if( $this->request['pruneAndRun'] )
+ {
+ $this->DB->delete( $TABLE );
+
+ $man = false;
+ }
+ else
+ {
+ /* Show alter table / prune option? */
+ $man = IPSSetUp::getSavedData('man');
+
+ if( $TABLE )
+ {
+ $count = $this->DB->buildAndFetch( array( 'select' => 'count(*) as logs', 'from' => $TABLE ) );
+
+ if( $count['logs'] > 100000 )
+ {
+ $man = true;
+ }
+ }
+ }
+
+ /* Show option to run manually or prune ? */
+ if( $man )
+ {
+ $query = trim( $query );
+
+ /* Ensure the last character is a semi-colon */
+ if ( substr( $query, -1 ) != ';' )
+ {
+ $query .= ';';
+ }
+
+ $output .= $query . "\n\n";
+ }
+ else
+ {
+ $this->DB->query( $query );
+
+ if ( $this->DB->error )
+ {
+ $this->registry->output->addError( "
" . $query . "
" . $this->DB->error );
+ }
+ else
+ {
+ $cnt++;
+ }
+ }
+ }
+
+ $this->registry->output->addMessage("{$cnt} запросов выполнено....");
+ }
+
+ /* Next Page */
+ if ( $id < 10 )
+ {
+ $nextid = $id + 1;
+ $this->request['workact'] = 'logs' . $nextid;
+ }
+ else
+ {
+ $this->request['workact'] = 'forums';
+ }
+
+ if ( $output )
+ {
+ $this->_output = $this->registry->output->template()->upgrade_manual_queries_logs( $output, $id, $TABLE );
+ }
+ }
+
+ /**
+ * Convert archive forums to read-only forums
+ *
+ * @return @e void
+ */
+ public function fixArchiveForums()
+ {
+ /* Update array for archive forums */
+ $_total = 0;
+ $_update = array(
+ 'perm_3' => '',
+ 'perm_4' => '',
+ 'perm_5' => '',
+ );
+
+ /* Get 'archive' forums */
+ $this->DB->build( array( 'select' => '*', 'from' => 'forums', 'where' => 'status=0' ) );
+ $outer = $this->DB->execute();
+
+ while( $r = $this->DB->fetch($outer) )
+ {
+ $this->DB->update( 'permission_index', $_update, "app='forums' AND perm_type='forum' AND perm_type_id={$r['id']}" );
+
+ $_total++;
+ }
+
+ /* Now drop the status field in forums table */
+ $this->DB->dropField( 'forums', 'status' );
+
+ /* Message */
+ $this->registry->output->addMessage("{$_total} форумов со статусом 'архивный' переведено в форумы только для чтения....");
+
+ /* Next Page */
+ $this->request['workact'] = 'loginmethods';
+ }
+
+ /**
+ * Pull login method conf to DB
+ *
+ * @return @e void
+ */
+ public function fixLoginMethods()
+ {
+ /* Init */
+ $_total = 0;
+
+ if( !defined('IPS_PATH_CUSTOM_LOGIN') )
+ {
+ define( 'IPS_PATH_CUSTOM_LOGIN' , IPS_ROOT_PATH . 'sources/loginauth' );
+ }
+
+ /* Try to loop over all login methods to grab current configs */
+ try
+ {
+ foreach( new DirectoryIterator( IPS_PATH_CUSTOM_LOGIN ) as $file )
+ {
+ if ( $file->isDir() )
+ {
+ if( is_file( $file->getPathname() . '/conf.php' ) )
+ {
+ $LOGIN_CONF = array();
+
+ include( $file->getPathname() . '/conf.php' );/*noLibHook*/
+
+ if( is_array($LOGIN_CONF) AND count($LOGIN_CONF) )
+ {
+ $this->DB->update( 'login_methods', array( 'login_custom_config' => @serialize($LOGIN_CONF) ), "login_folder_name='" . $this->DB->addSlashes( $file->getFilename() ) . "'" );
+
+ $_total++;
+ }
+ }
+ }
+ }
+ }
+ catch( Exception $e )
+ {
+ }
+
+ /* Message */
+ $this->registry->output->addMessage("{$_total} login method configs imported....");
+
+ /* Next Page */
+ $this->request['workact'] = 'oldhooks';
+ }
+
+ /**
+ * Remove old hooks
+ *
+ * @return @e void
+ */
+ public function removeOldHooks()
+ {
+ /* Hooks to remove */
+ $hooks = array( 'watched_content', 'todays_top_posters', 'unread_notifications' );
+ $_hookIds = array();
+ $_total = 0;
+
+ /* Get hook records */
+ $this->DB->build( array( 'select' => 'hook_id', 'from' => 'core_hooks', 'where' => "hook_key IN('" . implode( "','", $hooks ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $_hookIds[] = $r['hook_id'];
+ }
+
+ /* Remove associated files */
+ if( count($_hookIds) )
+ {
+ $this->DB->build( array( 'select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
+ }
+
+ /* Remove hook records */
+ $this->DB->delete( 'core_hooks_files', 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' );
+ $this->DB->delete( 'core_hooks', 'hook_id IN(' . implode( ',', $_hookIds ) . ')' );
+
+ $_total++;
+ }
+
+ /* Message */
+ $this->registry->output->addMessage("{$_total} устаревших хуков удалено....");
+
+ /* Next Page */
+ $this->request['workact'] = 'setdefaultskin';
+ }
+
+ /**
+ * Restore IPB default skin as default
+ *
+ * @return @e void
+ */
+ public function setDefaultSkin()
+ {
+ /* Get skin functions library */
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinFunctions.php' );/*noLibHook*/
+ require_once( IPS_ROOT_PATH . 'sources/classes/skins/skinCaching.php' );/*noLibHook*/
+
+ $skinFunctions = new skinCaching( $this->registry );
+
+ /* Update members to use default skin */
+ $this->DB->update( 'members', array( 'skin' => 0 ) );
+
+ /* Update forums to use default skin */
+ $this->DB->update( 'forums', array( 'skin_id' => 0 ) );
+
+ /* Reset any default skin(s) */
+ $this->DB->update( 'skin_collections', array( 'set_is_default' => 0 ) );
+
+ /* Set IPB default skin as default */
+ $this->DB->update( 'skin_collections', array( 'set_is_default' => 1 ), "set_key='default'" );
+
+ /* Verify we have a skin set as default */
+ $_check = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'skin_collections', 'where' => 'set_is_default=1' ) );
+
+ if( $_check['total'] < 1 )
+ {
+ $this->DB->build( array( 'update' => 'skin_collections', 'set' => 'set_is_default=1', 'where' => "set_output_format='html'", 'limit' => array( 0, 1 ) ) );
+ $this->DB->execute();
+ }
+
+ /* Check for any modifications in IPB default skin */
+ $_master = $this->DB->buildAndFetch( array( 'select' => '*', 'from' => 'skin_collections', 'where' => "set_key='default'" ) );
+ $_master['set_id'] = intval($_master['set_id']);
+ $_modifiedTemplates = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'skin_templates', 'where' => "template_set_id={$_master['set_id']} AND template_removable=1 OR template_user_edited=1" ) );
+ $_modifiedCSS = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'skin_css', 'where' => "css_set_id={$_master['set_id']} AND css_master_key=''" ) );
+
+ if( $_modifiedTemplates['total'] OR $_modifiedCSS['total'] )
+ {
+ /* Create a new skin with IPB default as parent */
+ $curPos = $skinFunctions->fetchHighestSetPosition();
+
+ $_master['set_key'] = 'default_modified';
+ $_master['set_parent_id'] = $_master['set_id'];
+ $_master['set_is_default'] = 0;
+ $_master['set_name'] = $_master['set_name'] . ' (Pre 3.2)';
+ $_master['set_order'] = (int)$curPos++;
+ unset($_master['set_id']);
+
+ $this->DB->insert( 'skin_collections', $_master );
+ $set_id = $this->DB->getInsertId();
+
+ $this->DB->update( 'skin_templates', array( 'template_set_id' => $set_id ), "template_set_id={$_master['set_parent_id']} AND template_removable=1 OR template_user_edited=1" );
+ $this->DB->update( 'skin_css', array( 'css_set_id' => $set_id ), "css_set_id={$_master['set_parent_id']} AND css_master_key=''" );
+
+ $skinFunctions->rebuildSkinSetsCache();
+ $skinFunctions->rebuildTreeInformation( $set_id );
+ //$skinFunctions->flushSkinData();
+
+ $skinFunctions->rebuildCSS( $set_id );
+ $skinFunctions->rebuildPHPTemplates( $set_id );
+ $skinFunctions->rebuildReplacementsCache( $set_id );
+ }
+
+ /* Message */
+ $this->registry->output->addMessage("Восстановлен новый базовый стиль....");
+
+ /* Next Page */
+ $this->request['workact'] = 'hooks';
+ }
+
+ /**
+ * Convert stored hook data
+ *
+ * @return @e void
+ */
+ public function convertHooks()
+ {
+ $_total = 0;
+
+ /* Grab all hooks */
+ $this->DB->build( array( 'select' => '*', 'from' => 'core_hooks' ) );
+ $outer = $this->DB->execute();
+
+ while( $hook = $this->DB->fetch($outer) )
+ {
+ $_extraData = unserialize($hook['hook_extra_data']);
+
+ /* Fix setting groups */
+ if( is_array($_extraData['settingGroups']) AND count($_extraData['settingGroups']) )
+ {
+ $_settingGroups = array();
+
+ foreach( $_extraData['settingGroups'] as $_group )
+ {
+ if( intval($_group) == $_group )
+ {
+ $_settingGroups[ $_group ] = intval($_group);
+ }
+ }
+
+ if( count($_settingGroups) )
+ {
+ $_extraData['settingGroups'] = array();
+
+ $this->DB->build( array( 'select' => 'conf_title_id, conf_title_keyword', 'from' => 'core_sys_settings_titles' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ if( in_array( $r['conf_title_id'], $_settingGroups ) )
+ {
+ $_extraData['settingGroups'][] = $r['conf_title_keyword'];
+ }
+ }
+ }
+ }
+
+ /* Fix settings */
+ if( is_array($_extraData['settings']) AND count($_extraData['settings']) )
+ {
+ $_settings = array();
+
+ foreach( $_extraData['settings'] as $_id )
+ {
+ if( intval($_id) == $_id )
+ {
+ $_settings[ $_id ] = intval($_id);
+ }
+ }
+
+ if( count($_settings) )
+ {
+ $_extraData['settings'] = array();
+
+ $this->DB->build( array( 'select' => 'conf_id, conf_key', 'from' => 'core_sys_conf_settings' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ if( in_array( $r['conf_id'], $_settings ) )
+ {
+ $_extraData['settings'][] = $r['conf_key'];
+ }
+ }
+ }
+ }
+
+ /* Fix tasks */
+ if( is_array($_extraData['tasks']) AND count($_extraData['tasks']) )
+ {
+ $_tasks = array();
+
+ foreach( $_extraData['tasks'] as $_id )
+ {
+ if( intval($_id) == $_id )
+ {
+ $_tasks[ $_id ] = intval($_id);
+ }
+ }
+
+ if( count($_tasks) )
+ {
+ $_extraData['tasks'] = array();
+
+ $this->DB->build( array( 'select' => 'task_id, task_key', 'from' => 'task_manager' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ if( in_array( $r['task_id'], $_tasks ) )
+ {
+ $_extraData['tasks'][] = $r['task_key'];
+ }
+ }
+ }
+ }
+
+ /* Fix help files */
+ if( is_array($_extraData['help']) AND count($_extraData['help']) )
+ {
+ $_help = array();
+
+ foreach( $_extraData['help'] as $_id )
+ {
+ if( intval($_id) == $_id )
+ {
+ $_help[ $_id ] = intval($_id);
+ }
+ }
+
+ if( count($_help) )
+ {
+ $_extraData['help'] = array();
+
+ $this->DB->build( array( 'select' => 'id, title', 'from' => 'faq' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ if( in_array( $r['id'], $_help ) )
+ {
+ $_extraData['help'][] = $r['title'];
+ }
+ }
+ }
+ }
+
+ /* Fix modules */
+ if( is_array($_extraData['modules']) AND count($_extraData['modules']) )
+ {
+ $_modules = array();
+
+ foreach( $_extraData['modules'] as $_id )
+ {
+ if( intval($_id) == $_id )
+ {
+ $_modules[ $_id ] = intval($_id);
+ }
+ }
+
+ if( count($_modules) )
+ {
+ $_extraData['modules'] = array();
+
+ $this->DB->build( array( 'select' => 'sys_module_id, sys_module_admin, sys_module_application, sys_module_key', 'from' => 'core_sys_module' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ if( in_array( $r['sys_module_id'], $_modules ) )
+ {
+ $_extraData['modules'][] = ( $r['sys_module_admin'] ? 'admin' : 'public' ) . '-' . $r['sys_module_application'] . '-' . $r['sys_module_key'];
+ }
+ }
+ }
+ }
+
+ /* Fix templates */
+ if( is_array($_extraData['templates']) AND count($_extraData['templates']) )
+ {
+ $_newTemplates = array();
+
+ foreach( $_extraData['templates'] as $file => $templates )
+ {
+ foreach( $templates as $template )
+ {
+ $_newTemplates[ $file ][ $template ] = $template;
+ }
+ }
+
+ $_extraData['templates'] = $_newTemplates;
+ }
+
+ /* Fix CSS */
+ if( is_array($_extraData['css']) AND count($_extraData['css']) )
+ {
+ $_css = array();
+
+ foreach( $_extraData['css'] as $_id )
+ {
+ if( intval($_id) == $_id )
+ {
+ $_css[ $_id ] = intval($_id);
+ }
+ }
+
+ if( count($_css) )
+ {
+ $_extraData['css'] = array();
+
+ $this->DB->build( array( 'select' => 'css_group', 'from' => 'skin_css', 'where' => "css_id IN(" . implode( ',', $_css ) . ")" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $_extraData['css'][ $r['css_group'] ] = $r['css_group'];
+ }
+ }
+ }
+
+ $this->DB->update( 'core_hooks', array( 'hook_extra_data' => serialize( $_extraData ) ), 'hook_id=' . $hook['hook_id'] );
+
+ $_total++;
+ }
+
+ /* Message */
+ $this->registry->output->addMessage("{$_total} хуков обновлено....");
+
+ /* Next Page */
+ $this->request['workact'] = 'photos';
+ }
+
+ /**
+ * Convert and rebuild photos
+ *
+ * @param int
+ * @return @e void
+ */
+ public function convertPhotos()
+ {
+ /* Is this the first cycle? */
+ if( !$this->request['from'] )
+ {
+ $this->_output = <<
Конвертация фотографий пользователей
+
+ IP.Board 3.2 теперь использует только одно изображение для идентификации пользователя. Вы должны выбрать, что именно (аватар или фотография из профиля) будет сохранено и использовано новой версией.
+
+
+ Использвать аватары
+ Использовать фотографии из профиля
+
+
+ В процессе конвертации также будут изменены размеры существующих изображений и созданы новые превью. Вы можете отложить этот процесс, отметив чекбокс. Процесс перестроения изображений может быть запущен вами после обновления в админ-центре форума.
+
+
Перестроить сейчас
+
Пропустить
+EOF;
+
+ return;
+ }
+
+ /* Our options */
+ $convertFrom = $this->request['from'] == 'avatars' ? 'avatars' : 'photos';
+ $skipRebuild = intval($this->request['skip']);
+
+ /* Init */
+ $st = intval($this->request['st']);
+ $did = 0;
+ $each = 200;
+
+ require_once( IPS_ROOT_PATH . 'sources/classes/member/photo.php' );/*noLibHook*/
+ $photo = new classes_member_photo( $this->registry );
+
+ /* Loop over members */
+ $this->DB->build( array( 'select' => '*', 'from' => 'profile_portal', 'order' => 'pp_member_id ASC', 'limit' => array( $st, $each ) ) );
+ $outer = $this->DB->execute();
+
+ while( $r = $this->DB->fetch($outer) )
+ {
+ $did++;
+
+ $update = array();
+
+ if( $r['fb_photo'] )
+ {
+ $update['pp_photo_type'] = 'facebook';
+ }
+ else if( $r['tc_photo'] )
+ {
+ $update['pp_photo_type'] = 'twitter';
+ }
+ else if( $r['vc_photo'] )
+ {
+ $update['pp_photo_type'] = 'vkontakte';
+ }
+
+ else
+ {
+ if( $convertFrom == 'avatars' )
+ {
+ if( $r['avatar_type'] == 'upload' AND $r['avatar_location'] )
+ {
+ $update['pp_photo_type'] = 'custom';
+ $update['pp_main_photo'] = $r['avatar_location'];
+ $_dims = @getimagesize( $this->settings['upload_dir'] . '/' . $r['avatar_location'] );
+ $update['pp_main_width'] = $_dims[0] ? $_dims[0] : 1;
+ $update['pp_main_height'] = $_dims[1] ? $_dims[1] : 1;
+ }
+ else if( $r['avatar_type'] == 'gravatar' )
+ {
+ $update['pp_photo_type'] = 'gravatar';
+ $update['pp_gravatar'] = $r['avatar_location'];
+
+ $md5Gravatar = md5( $update['pp_gravatar'] );
+
+ $_url = "http://www.gravatar.com";
+
+ if( $this->registry->output->isHTTPS )
+ {
+ $_url = "https://secure.gravatar.com";
+ }
+
+ $update['pp_main_photo'] = $_url . "/avatar/" .$md5Gravatar . "?s=100";
+ $update['pp_main_width'] = 100;
+ $update['pp_main_height'] = 100;
+ $update['pp_thumb_photo'] = $_url . "/avatar/" .$md5Gravatar . "?s=100";
+ $update['pp_thumb_width'] = 100;
+ $update['pp_thumb_height'] = 100;
+ }
+ }
+ else
+ {
+ if( $r['pp_main_photo'] )
+ {
+ $update['pp_photo_type'] = 'custom';
+ $update['pp_main_photo'] = $r['pp_main_photo'];
+ }
+ }
+ }
+
+ if( !$skipRebuild AND $update['pp_photo_type'] == 'custom' )
+ {
+ $info = $photo->buildSizedPhotos( str_replace( 'upload:', '', $update['pp_main_photo'] ), $r['pp_member_id'], true );
+
+ $update['pp_main_width'] = intval( $info['final_width'] );
+ $update['pp_main_height'] = intval( $info['final_height'] );
+ $update['pp_thumb_photo'] = $info['t_final_location'] ? $info['t_final_location'] : $info['final_location'];
+ $update['pp_thumb_width'] = intval( $info['t_final_width'] );
+ $update['pp_thumb_height'] = intval( $info['t_final_height'] );
+ }
+
+ if( count($update) )
+ {
+ $this->DB->update( 'profile_portal', $update, 'pp_member_id=' . $r['pp_member_id'] );
+ }
+ }
+
+ /* Show message and redirect */
+ if( $did > 0 )
+ {
+ $this->request['st'] = ( $st + $did );
+ $this->request['workact'] = 'photos';
+
+ $message = $skipRebuild ? "{$this->request['st']} фотографий сконвертировано ..." : "{$this->request['st']} фотографий сконвертировано и перестроено...";
+ $this->registry->output->addMessage( $message );
+
+ /* Yes, we are being sneaky here. Shhhhh */
+ $this->request['st'] = $this->request['st'] . '&from=' . $this->request['from'] . '&skip=' . $skipRebuild;
+ }
+ else
+ {
+ $this->request['st'] = 0;
+ $this->request['workact'] = '';
+
+ $this->registry->output->addMessage( "Все фотографии сконвертированы..." );
+ }
+
+ /* Next Page */
+ return;
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_32001/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_32001/mysql_updates.php
index 9f8d6e13..f5b2f928 100644
--- a/upload/admin/applications/core/setup/versions/upg_32001/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_32001/mysql_updates.php
@@ -1,7 +1,7 @@
Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
- exit();
-}
-
-class version_upgrade
-{
- /**
- * Custom HTML to show
- *
- * @var string
- */
- protected $_output = '';
-
- /**
- * fetchs output
- *
- * @return string
- */
- public function fetchOutput()
- {
- return $this->_output;
- }
-
- /**
- * Execute selected method
- *
- * @param object Registry object
- * @return @e void
- */
- public function doExecute( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
-
- //--------------------------------
- // What are we doing?
- //--------------------------------
-
- switch( $this->request['workact'] )
- {
- default:
- case 'oldhooks':
- $this->removeOldHooks();
- break;
- }
-
- return true;
- }
-
- /**
- * Remove old hooks
- *
- * @return @e void
- */
- public function removeOldHooks()
- {
- /* Hooks to remove */
- $hooks = array( 'sharelinks', 'fb_like' );
- $_hookIds = array();
- $_total = 0;
-
- /* Get hook records */
- $this->DB->build( array( 'select' => 'hook_id', 'from' => 'core_hooks', 'where' => "hook_key IN('" . implode( "','", $hooks ) . "')" ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- $_hookIds[] = $r['hook_id'];
- }
-
- /* Remove associated files */
- if( count($_hookIds) )
- {
- $this->DB->build( array( 'select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' ) );
- $this->DB->execute();
-
- while( $r = $this->DB->fetch() )
- {
- @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
- }
-
- /* Remove hook records */
- $this->DB->delete( 'core_hooks_files', 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' );
- $this->DB->delete( 'core_hooks', 'hook_id IN(' . implode( ',', $_hookIds ) . ')' );
-
- $_total++;
- }
-
- /* Message */
- $this->registry->output->addMessage("{$_total} outdated hook(s) uninstalled....");
-
- /* Next Page */
- $this->request['workact'] = '';
- }
+Incorrect accessYou cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
+ exit();
+}
+
+class version_upgrade
+{
+ /**
+ * Custom HTML to show
+ *
+ * @var string
+ */
+ protected $_output = '';
+
+ /**
+ * fetchs output
+ *
+ * @return string
+ */
+ public function fetchOutput()
+ {
+ return $this->_output;
+ }
+
+ /**
+ * Execute selected method
+ *
+ * @param object Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+ //--------------------------------
+ // What are we doing?
+ //--------------------------------
+
+ switch( $this->request['workact'] )
+ {
+ default:
+ case 'oldhooks':
+ $this->removeOldHooks();
+ break;
+ }
+
+ return true;
+ }
+
+ /**
+ * Remove old hooks
+ *
+ * @return @e void
+ */
+ public function removeOldHooks()
+ {
+ /* Hooks to remove */
+ $hooks = array( 'sharelinks', 'fb_like' );
+ $_hookIds = array();
+ $_total = 0;
+
+ /* Get hook records */
+ $this->DB->build( array( 'select' => 'hook_id', 'from' => 'core_hooks', 'where' => "hook_key IN('" . implode( "','", $hooks ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $_hookIds[] = $r['hook_id'];
+ }
+
+ /* Remove associated files */
+ if( count($_hookIds) )
+ {
+ $this->DB->build( array( 'select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
+ }
+
+ /* Remove hook records */
+ $this->DB->delete( 'core_hooks_files', 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' );
+ $this->DB->delete( 'core_hooks', 'hook_id IN(' . implode( ',', $_hookIds ) . ')' );
+
+ $_total++;
+ }
+
+ /* Message */
+ $this->registry->output->addMessage("{$_total} устаревших хуков удалено....");
+
+ /* Next Page */
+ $this->request['workact'] = '';
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_32002/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_32002/mysql_updates.php
index 4ae9cbef..e5d975aa 100644
--- a/upload/admin/applications/core/setup/versions/upg_32002/mysql_updates.php
+++ b/upload/admin/applications/core/setup/versions/upg_32002/mysql_updates.php
@@ -1,7 +1,7 @@
- * Invision Power Services
- * IP.Board v3.3.4
- * Upgrade Class
- *
- * Class to add options and notices for IP.Board upgrade
- * Last Updated: $Date: 2011-05-25 19:58:10 +0100 (Wed, 25 May 2011) $
- *
- *
- * @author Matt Mecham
- * @version $Rev: 8891 $
- * @since 3.0
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @link http://www.invisionpower.com
- * @package IP.Board
- */
-
-class version_class_core_33000
-{
- /**
- * Constructor
- *
- * @param object $registry Registry object
- * @return @e void
- */
- public function __construct( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
- }
-
- /**
- * Add pre-upgrade options: Form
- *
- * @return string HTML block
- */
- public function preInstallOptionsForm()
- {
- $_wrapper = "";
- $_html = '';
- $posts = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'posts' ) );
-
- // Is 3.1?
- if ( IPSSetUp::is300plus() && ! IPSSetUp::is320plus() )
- {
- // Got more than 100K posts?
- if( $posts['total'] > 100000 && ! $this->DB->checkForField( 'post_field_int', 'posts' ) )
- {
-$_html .= <<
-
- Manually apply changes to the posts table? Your site has more than 100,000 posts. We strongly recommend that you enable this option and manually run the provided
- SQL query to alter your posts table in order to prevent timeouts in the web-based upgrader. If you uncheck this option, it is very possible the upgrader will timeout attempting to
- update your posts table.
-
-EOF;
- }
- }
-
- $_html .= <<
-
- Flag all members in the Banned member group as banned
- 3.3.0 removes the need for a specific Banned Group and uses the built in 'flag' on a per-member basis. However, unless you choose to update all
- members in the current Banned Group as 'banned' they may not appear when searching for banned members in the ACP.
- We recommend you keep this box ticked
-
-EOF;
-
- if( $_html )
- {
- return sprintf( $_wrapper, $_html );
- }
- else
- {
- return '';
- }
- }
-
- /**
- * Add pre-upgrade options: Save
- *
- * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
- *
- * @return array Key / value pairs to save
- */
- public function preInstallOptionsSave()
- {
- return array( 'flagBanned' => intval( $_REQUEST['flagBanned'] ), 'manualPostsTableQuery' => intval( $_REQUEST['manualPostsTableQuery'] ) );
- }
-
- /**
- * Return any post-installation notices
- *
- * @return array Array of notices
- */
- public function postInstallNotices()
- {
- return array();
- }
-
- /**
- * Return any pre-installation notices
- *
- * @return array Array of notices
- */
- public function preInstallNotices()
- {
- return array();
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Upgrade Class
+ *
+ * Class to add options and notices for IP.Board upgrade
+ * Last Updated: $Date: 2011-05-25 19:58:10 +0100 (Wed, 25 May 2011) $
+ *
+ *
+ * @author Matt Mecham
+ * @version $Rev: 8891 $
+ * @since 3.0
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @link http://www.invisionpower.com
+ * @package IP.Board
+ */
+
+class version_class_core_33000
+{
+ /**
+ * Constructor
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function __construct( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+ }
+
+ /**
+ * Add pre-upgrade options: Form
+ *
+ * @return string HTML block
+ */
+ public function preInstallOptionsForm()
+ {
+ $_wrapper = "";
+ $_html = '';
+ $posts = $this->DB->buildAndFetch( array( 'select' => 'count(*) as total', 'from' => 'posts' ) );
+
+ // Is 3.1?
+ if ( IPSSetUp::is300plus() && ! IPSSetUp::is320plus() )
+ {
+ // Got more than 100K posts?
+ if( $posts['total'] > 100000 && ! $this->DB->checkForField( 'post_field_int', 'posts' ) )
+ {
+$_html .= <<
+
+ Внести изменения в структуру таблицы Posts вручную? На вашем форуме более 100,000 сообщений. Мы настоятельно рекомендуем вам включить данную опцию и самостоятельно выполнить
+ SQL запросы для обновления таблицы сообщений. Если вы отключите данную опцию существует большая вероятность того, что мастер обновления не сможет обновить форум.
+
+EOF;
+ }
+ }
+
+ $_html .= <<
+
+ Отметить всех пользователей из группы "Забаненные", как забаненных
+ В 3.3.0 удалена отдельная группа для заблокированных, теперь проверка осуществляется на основе метки для каждого пользователя. Возможно, что часть пользователей, отмеченных как
+ забаненные, в результате такого переноса, не будут находится поиском в админ-центре при применении фильтра поиска по заблокированным.
+ Мы рекомендуем воспользоваться этой опцией.
+
+EOF;
+
+ if( $_html )
+ {
+ return sprintf( $_wrapper, $_html );
+ }
+ else
+ {
+ return '';
+ }
+ }
+
+ /**
+ * Add pre-upgrade options: Save
+ *
+ * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
+ *
+ * @return array Key / value pairs to save
+ */
+ public function preInstallOptionsSave()
+ {
+ return array( 'flagBanned' => intval( $_REQUEST['flagBanned'] ), 'manualPostsTableQuery' => intval( $_REQUEST['manualPostsTableQuery'] ) );
+ }
+
+ /**
+ * Return any post-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function postInstallNotices()
+ {
+ return array();
+ }
+
+ /**
+ * Return any pre-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function preInstallNotices()
+ {
+ return array();
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_33000/version_upgrade.php b/upload/admin/applications/core/setup/versions/upg_33000/version_upgrade.php
index 2791ca60..d57aa350 100644
--- a/upload/admin/applications/core/setup/versions/upg_33000/version_upgrade.php
+++ b/upload/admin/applications/core/setup/versions/upg_33000/version_upgrade.php
@@ -155,7 +155,7 @@ class version_upgrade
}
}
- $this->registry->output->addMessage("{$cnt} queries ran... ");
+ $this->registry->output->addMessage("{$cnt} запросов выполнено... ");
}
/* Next Page */
diff --git a/upload/admin/applications/core/setup/versions/upg_33007/version_upgrade.php b/upload/admin/applications/core/setup/versions/upg_33007/version_upgrade.php
index dc59ac2e..83b1aa98 100644
--- a/upload/admin/applications/core/setup/versions/upg_33007/version_upgrade.php
+++ b/upload/admin/applications/core/setup/versions/upg_33007/version_upgrade.php
@@ -91,7 +91,7 @@ class version_upgrade
}
}
- $this->registry->output->addMessage( "XML Skin restored" );
+ $this->registry->output->addMessage( "XML стиль восстановлен" );
$this->request['workact'] = '';
}
diff --git a/upload/admin/applications/core/setup/versions/upg_33010/version_class.php b/upload/admin/applications/core/setup/versions/upg_33010/version_class.php
index 2aa3c860..a135f286 100644
--- a/upload/admin/applications/core/setup/versions/upg_33010/version_class.php
+++ b/upload/admin/applications/core/setup/versions/upg_33010/version_class.php
@@ -1,82 +1,82 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Upgrade Class
- *
- * Class to add options and notices for IP.Board upgrade
- * Last Updated: $Date: 2011-05-25 19:58:10 +0100 (Wed, 25 May 2011) $
- *
- *
- * @author Matt Mecham
- * @version $Rev: 8891 $
- * @since 3.0
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @link http://www.invisionpower.com
- * @package IP.Board
- */
-
-class version_class_core_33010
-{
- /**
- * Constructor
- *
- * @param object $registry Registry object
- * @return @e void
- */
- public function __construct( ipsRegistry $registry )
- {
- /* Make object */
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
- }
-
- /**
- * Add pre-upgrade options: Form
- *
- * @return string HTML block
- */
- public function preInstallOptionsForm()
- {
- return '';
- }
-
- /**
- * Add pre-upgrade options: Save
- *
- * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
- *
- * @return array Key / value pairs to save
- */
- public function preInstallOptionsSave()
- {
- return array();
- }
-
- /**
- * Return any post-installation notices
- *
- * @return array Array of notices
- */
- public function postInstallNotices()
- {
- return array();
- }
-
- /**
- * Return any pre-installation notices
- *
- * @return array Array of notices
- */
- public function preInstallNotices()
- {
- return array( "Please note: The OpenID login method will be removed in the 3.3.0 Beta 4 upgrade and all associated OpenID data removed from the database. This will not affect your board unless you configured your board to use OpenID as a log in method." );
- }
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Upgrade Class
+ *
+ * Class to add options and notices for IP.Board upgrade
+ * Last Updated: $Date: 2011-05-25 19:58:10 +0100 (Wed, 25 May 2011) $
+ *
+ *
+ * @author Matt Mecham
+ * @version $Rev: 8891 $
+ * @since 3.0
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @link http://www.invisionpower.com
+ * @package IP.Board
+ */
+
+class version_class_core_33010
+{
+ /**
+ * Constructor
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function __construct( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+ }
+
+ /**
+ * Add pre-upgrade options: Form
+ *
+ * @return string HTML block
+ */
+ public function preInstallOptionsForm()
+ {
+ return '';
+ }
+
+ /**
+ * Add pre-upgrade options: Save
+ *
+ * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
+ *
+ * @return array Key / value pairs to save
+ */
+ public function preInstallOptionsSave()
+ {
+ return array();
+ }
+
+ /**
+ * Return any post-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function postInstallNotices()
+ {
+ return array();
+ }
+
+ /**
+ * Return any pre-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function preInstallNotices()
+ {
+ return array( "Внимание поддержка входа по OpenID удалена в 3.3.0 версии. Это недолжно отразиться на работе вашего форума, если вы не включали данный метод входа." );
+ }
}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_33016/index.html b/upload/admin/applications/core/setup/versions/upg_33016/index.html
new file mode 100644
index 00000000..bae2d5ed
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_33016/index.html
@@ -0,0 +1,10 @@
+
+IP.Board - Bulletin Board System
+
+403: IP.Board -> Forbidden
+
+You have reached this page in error, please use your back button to return to the forum.
+
+IP.Board
+
+
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_33016/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_33016/mysql_updates.php
new file mode 100644
index 00000000..b0ff1f03
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_33016/mysql_updates.php
@@ -0,0 +1,19 @@
+getPrefix());
+$DB = ipsRegistry::DB();
+
+
+$SQL[] = "ALTER TABLE upgrade_history CHANGE upgrade_notes upgrade_notes TEXT NULL default NULL;";
+
+$SQL[] = "ALTER TABLE members_warn_logs ADD INDEX wl_expire ( wl_expire, wl_expire_date, wl_date );";
+
+/* Do we have an old binary 16 column perhaps? */
+$tableCheck = $DB->getTableSchematic('core_like');
+
+if ( stripos( $tableCheck['Create Table'], 'binary' ) !== FALSE )
+{
+ /* Iz that zo? Thiz iz no good! */
+ $SQL[] = "ALTER TABLE core_like CHANGE like_id like_id VARCHAR(32) NOT NULL DEFAULT '', CHANGE like_lookup_id like_lookup_id VARCHAR(32) NOT NULL DEFAULT '';";
+ $SQL[] = "UPDATE core_like SET like_id=MD5( CONCAT( like_app, ';', like_area, ';', like_rel_id, ';', like_member_id ) ), like_lookup_id=MD5( CONCAT( like_app, ';', like_area, ';', like_rel_id ) );";
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_34000/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_34000/mysql_updates.php
new file mode 100644
index 00000000..9e90901a
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_34000/mysql_updates.php
@@ -0,0 +1,89 @@
+checkForTable( 'seo_meta' ) )
+{
+ $SQL[] = "CREATE TABLE seo_meta (
+ url varchar(255) NOT NULL DEFAULT '*',
+ name varchar(50) NOT NULL DEFAULT '',
+ content text NOT NULL
+ )";
+}
+
+if( !ipsRegistry::DB()->checkForTable( 'seo_acronyms' ) )
+{
+ $SQL[] = "CREATE TABLE seo_acronyms (
+ a_id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ a_short varchar(255) DEFAULT NULL,
+ a_long varchar(255) DEFAULT NULL,
+ a_semantic tinyint(1) DEFAULT NULL,
+ a_casesensitive tinyint(1) DEFAULT NULL,
+ PRIMARY KEY (a_id),
+ KEY a_short (a_short)
+ )";
+}
+
+//
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_34000/version_class.php b/upload/admin/applications/core/setup/versions/upg_34000/version_class.php
new file mode 100644
index 00000000..60e6fe69
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_34000/version_class.php
@@ -0,0 +1,82 @@
+
+ * Invision Power Services
+ * IP.Board v3.4.5
+ * Upgrade Class
+ *
+ * Class to add options and notices for IP.Board upgrade
+ * Last Updated: $Date: 2013-01-29 14:15:42 -0500 (Tue, 29 Jan 2013) $
+ *
+ *
+ * @author Matt Mecham
+ * @version $Rev: 11913 $
+ * @since 3.0
+ * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
+ * @license http://www.invisionpower.com/company/standards.php#license
+ * @link http://www.invisionpower.com
+ * @package IP.Board
+ */
+
+class version_class_core_34000
+{
+ /**
+ * Constructor
+ *
+ * @param object $registry Registry object
+ * @return @e void
+ */
+ public function __construct( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+ }
+
+ /**
+ * Add pre-upgrade options: Form
+ *
+ * @return string HTML block
+ */
+ public function preInstallOptionsForm()
+ {
+ return '';
+ }
+
+ /**
+ * Add pre-upgrade options: Save
+ *
+ * Data will be saved in saved data array as: appOptions[ app ][ versionLong ] = ( key => value );
+ *
+ * @return array Key / value pairs to save
+ */
+ public function preInstallOptionsSave()
+ {
+ return array();
+ }
+
+ /**
+ * Return any post-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function postInstallNotices()
+ {
+ return array();
+ }
+
+ /**
+ * Return any pre-installation notices
+ *
+ * @return array Array of notices
+ */
+ public function preInstallNotices()
+ {
+ return array( "Please note: 3rd party hooks will be temporarily disabled as part of this upgrade process. They can be re-enabled from the admin control panel at ACP > Applications & Modules > Manage Hooks." );
+ }
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_34000/version_upgrade.php b/upload/admin/applications/core/setup/versions/upg_34000/version_upgrade.php
new file mode 100644
index 00000000..728846b3
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_34000/version_upgrade.php
@@ -0,0 +1,169 @@
+_output;
+ }
+
+ /**
+ * Execute selected method
+ *
+ * @param object Registry object
+ * @return @e void
+ */
+ public function doExecute( ipsRegistry $registry )
+ {
+ /* Make object */
+ $this->registry = $registry;
+ $this->DB = $this->registry->DB();
+ $this->settings =& $this->registry->fetchSettings();
+ $this->request =& $this->registry->fetchRequest();
+ $this->cache = $this->registry->cache();
+ $this->caches =& $this->registry->cache()->fetchCaches();
+
+ //--------------------------------
+ // What are we doing?
+ //--------------------------------
+
+ switch( $this->request['workact'] )
+ {
+ case 'system_templates':
+ $this->_writeSystemTemplates();
+ break;
+ case 'oldhooks':
+ $this->removeOldHooks();
+ break;
+ case 'seo':
+ default:
+ $this->_convertIPSeo();
+ break;
+ }
+
+ /* Workact is set in the function, so if it has not been set, then we're done. The last function should unset it. */
+ if ( $this->request['workact'] )
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Write system templayes
+ */
+ public function _writeSystemTemplates()
+ {
+ require_once( IPS_ROOT_PATH . 'sources/classes/output/systemTemplates.php' );/*noLibHook*/
+ $systemTemplates = new systemTemplates();
+ $systemTemplates->writeDefaults();
+
+ $this->registry->output->addMessage( "Запись шаблонов системы..." );
+ $this->request['workact'] = '';
+ }
+
+ /**
+ * Convert IP.SEO
+ */
+ public function _convertIPSeo()
+ {
+ if ( IPSLib::appIsInstalled('ipseo') )
+ {
+ if ( $this->settings['seo_index_md'] )
+ {
+ $this->DB->insert( 'seo_meta', array( 'url' => '', 'name' => 'description', 'content' => $this->settings['seo_index_md'] ) );
+ }
+ if ( $this->settings['seo_index_mk'] )
+ {
+ $this->DB->insert( 'seo_meta', array( 'url' => '', 'name' => 'keywords', 'content' => $this->settings['seo_index_mk'] ) );
+ }
+ if ( $this->settings['seo_index_title'] )
+ {
+ $this->DB->insert( 'seo_meta', array( 'url' => '', 'name' => 'title', 'content' => $this->settings['seo_index_title'] ) );
+ }
+ }
+
+ $this->DB->delete( 'core_sys_conf_settings', "conf_key IN( 'seo_index_md', 'seo_index_mk', 'seo_index_title', 'ipseo_ping_services', 'ipseo_guest_skin' )" );
+
+ $this->DB->delete( 'core_sys_settings_titles', "conf_title_keyword='ipseo'" );
+
+ if ( !$this->DB->checkForField( 'ipseo_priority', 'forums' ) )
+ {
+ $this->DB->addField( 'forums', 'ipseo_priority', 'varchar(3)', "''" );
+ }
+
+ $this->DB->delete( 'core_applications', "app_directory='ipseo'" );
+ $this->DB->delete( 'upgrade_history', "upgrade_app='ipseo'" );
+
+ $this->registry->output->addMessage( "Сконвертированы данные IP.SEO..." );
+ $this->request['workact'] = 'oldhooks';
+ }
+
+ /**
+ * Remove old hooks
+ *
+ * @return @e void
+ */
+ public function removeOldHooks()
+ {
+ /* Hooks to remove */
+ $hooks = array( 'ipseo_acronyms', 'ipseo_guest_skin', 'ipseo_meta', 'ipseo_ping_services', 'ipseo_tracking' );
+ $_hookIds = array();
+ $_total = 0;
+
+ /* Get hook records */
+ $this->DB->build( array( 'select' => 'hook_id', 'from' => 'core_hooks', 'where' => "hook_key IN('" . implode( "','", $hooks ) . "')" ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ $_hookIds[] = $r['hook_id'];
+ }
+
+ /* Remove associated files */
+ if( count($_hookIds) )
+ {
+ $this->DB->build( array( 'select' => 'hook_file_stored', 'from' => 'core_hooks_files', 'where' => 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' ) );
+ $this->DB->execute();
+
+ while( $r = $this->DB->fetch() )
+ {
+ @unlink( IPS_HOOKS_PATH . $r['hook_file_stored'] );
+ }
+
+ /* Remove hook records */
+ $this->DB->delete( 'core_hooks_files', 'hook_hook_id IN(' . implode( ',', $_hookIds ) . ')' );
+ $this->DB->delete( 'core_hooks', 'hook_id IN(' . implode( ',', $_hookIds ) . ')' );
+
+ $_total++;
+ }
+
+ /* Message */
+ $this->registry->output->addMessage("{$_total} устаревших хуков удалено....");
+
+ /* Next Page */
+ $this->request['workact'] = 'system_templates';
+ }
+
+
+}
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_34005/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_34005/mysql_updates.php
new file mode 100644
index 00000000..75af02e5
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_34005/mysql_updates.php
@@ -0,0 +1,34 @@
+checkForIndex( 'wl_expire', 'members_warn_logs' ) )
+{
+ $SQL[] = "ALTER TABLE members_warn_logs ADD INDEX wl_expire ( wl_expire, wl_expire_date, wl_date )";
+}
+
+if( !ipsRegistry::DB()->checkForTable( 'search_keywords' ) )
+{
+ $SQL[] = "CREATE TABLE search_keywords (
+ `keyword` varchar(250) NOT NULL,
+ `count` int(11) NOT NULL DEFAULT '0',
+ UNIQUE KEY `idx_keyword_unq` (`keyword`),
+ KEY `idx_kw_cnt` (`keyword`,`count`)
+ )";
+
+}
+
+if( !ipsRegistry::DB()->checkForTable( 'search_visitors' ) )
+{
+ $SQL[] = "CREATE TABLE search_visitors (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `member` int(11),
+ `date` int(11) NOT NULL DEFAULT '0',
+ `engine` varchar(50) NOT NULL,
+ `keywords` varchar(250) NOT NULL,
+ `url` varchar(2048) NOT NULL,
+ PRIMARY KEY (`id`),
+ KEY `idx_date_engine` (`date`,`engine`)
+ )";
+}
+
+
+//
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_34007/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_34007/mysql_updates.php
new file mode 100644
index 00000000..e5727bd6
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_34007/mysql_updates.php
@@ -0,0 +1,6 @@
+\' WHERE mediatag_name=\'YouTube\';';
+$SQL[] = 'UPDATE bbcode_mediatag SET mediatag_match=\'http://(www.)?youtu.be/([\\d\\w-_]+?)\', mediatag_replace=\'VIDEO \' WHERE mediatag_name=\'YouTu.be\';';
+
+$SQL[] = "ALTER TABLE members ADD COLUMN ipsconnect_revalidate_url TEXT NULL;";
+
+$SQL[] = "DELETE FROM core_sys_conf_settings WHERE conf_key = 'upload_domain';";
+$SQL[] = "UPDATE core_sys_settings_titles SET conf_title_noshow=0 WHERE conf_title_keyword='iphoneappsettings'";
+$SQL[] = "DELETE FROM task_manager WHERE task_key='mobile_notifications';";
+
+$SQL[] = "ALTER TABLE core_share_links ADD COLUMN share_groups TEXT NULL;";
+$SQL[] = "UPDATE core_share_links SET share_groups='*';";
+
+$SQL[] = "ALTER TABLE profile_portal ADD vc_photo TEXT;";
+
+$SQL[] = "DELETE FROM core_sys_settings_titles WHERE conf_title_keyword='vk';";
+//
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_34009/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_34009/mysql_updates.php
new file mode 100644
index 00000000..7f512f24
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_34009/mysql_updates.php
@@ -0,0 +1,19 @@
+getPrefix());
+
+$SQL[] = "DELETE FROM core_sys_lang_words WHERE word_pack='public_cookies';";
+$SQL[] = "DELETE FROM core_sys_lang_words WHERE word_app='core' AND word_pack='public_cookie_view';";
+$SQL[] = "DELETE FROM core_sys_lang_words WHERE word_app='forums' AND word_pack='public_cookies';";
+$SQL[] = "DELETE FROM core_sys_lang_words WHERE word_app='forums' AND word_pack='public_printpage';";
+
+$SQL[] = "ALTER TABLE seo_meta CHANGE url url TEXT NULL";
+
+$SQL[] = "UPDATE bbcode_mediatag SET mediatag_replace='VIDEO ' WHERE mediatag_name='YouTube';";
+$SQL[] = "UPDATE bbcode_mediatag SET mediatag_replace='VIDEO ' WHERE mediatag_name='YouTu.be';";
+$SQL[] = "UPDATE bbcode_mediatag SET mediatag_replace='' WHERE mediatag_name='Vimeo';";
+
+# Ensure that members who can use HTML have HTML enabled when viewing and editing signatures
+$SQL[] = "UPDATE members SET members_bitoptions=members_bitoptions | 16384 WHERE member_group_id IN( SELECT g_id FROM `{$PRE}groups` WHERE g_dohtml=1 )";
+
+//
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_34010/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_34010/mysql_updates.php
new file mode 100644
index 00000000..228b6fa9
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_34010/mysql_updates.php
@@ -0,0 +1,6 @@
+getPrefix());
+
+$SQL[] = "UPDATE custom_bbcode SET bbcode_replace=' ' where bbcode_tag='hr';";
+//
\ No newline at end of file
diff --git a/upload/admin/applications/core/setup/versions/upg_34011/mysql_updates.php b/upload/admin/applications/core/setup/versions/upg_34011/mysql_updates.php
new file mode 100644
index 00000000..30645ebc
--- /dev/null
+++ b/upload/admin/applications/core/setup/versions/upg_34011/mysql_updates.php
@@ -0,0 +1,18 @@
+getPrefix());
+
+$hook = ipsRegistry::DB()->buildAndFetch( array( 'select' => '*', 'from' => 'core_hooks', 'where'=> "hook_key = 'othRandomTopic'" ) );
+
+if( !$hook )
+{
+ $SQL[] = "DELETE FROM core_sys_conf_settings WHERE conf_key IN( 'oth_rand_topics_no_archived_plz', 'oth_rand_topic_fids', 'oth_rand_enabled' );";
+ $SQL[] = "DELETE FROM core_sys_settings_titles WHERE conf_title_keyword='othRandomTopic';";
+}
+
+$SQL[] = "ALTER TABLE forums ADD INDEX ( last_poster_id );";
+$SQL[] = "ALTER TABLE topics ADD INDEX ( last_poster_id );";
+
+$SQL[] = "ALTER TABLE core_hooks CHANGE hook_key hook_key VARCHAR( 128 ) NULL DEFAULT NULL;";
+
+$SQL[] = "ALTER TABLE core_like DROP INDEX like_lookup_area, ADD INDEX like_lookup_area ( like_lookup_area , like_visible , like_added );";
\ No newline at end of file
diff --git a/upload/admin/applications/core/skin_cp/cp_skin_adminlogs.php b/upload/admin/applications/core/skin_cp/cp_skin_adminlogs.php
index 80fded1d..85d1f70b 100644
--- a/upload/admin/applications/core/skin_cp/cp_skin_adminlogs.php
+++ b/upload/admin/applications/core/skin_cp/cp_skin_adminlogs.php
@@ -2,19 +2,19 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* Admin log skin file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2013-01-03 15:22:09 -0500 (Thu, 03 Jan 2013) $
*
*
- * @author $Author: bfarber $
+ * @author $Author: AndyMillne $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.invisionpower.com/company/standards.php#license
* @package IP.Board
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 11780 $
*/
class cp_skin_adminlogs
@@ -185,7 +185,7 @@ $IPBHTML .= <<{$this->lang->words['sched_error_logs']}
{$this->lang->words['al_error_logs']}
{$this->lang->words['slog_spamlogs']}
- {$this->lang->words['mlog_mobilelogs']}
+
HTML;
if ( $this->registry->class_permissions->checkPermission( 'sqlerrorlogs_view' ) )
{
diff --git a/upload/admin/applications/core/skin_cp/cp_skin_api.php b/upload/admin/applications/core/skin_cp/cp_skin_api.php
index 81eac510..ddda5600 100644
--- a/upload/admin/applications/core/skin_cp/cp_skin_api.php
+++ b/upload/admin/applications/core/skin_cp/cp_skin_api.php
@@ -2,9 +2,9 @@
/**
*
* Invision Power Services
- * IP.Board v3.3.4
+ * IP.Board v3.4.5
* API users skin file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
+ * Last Updated: $Date: 2012-05-10 16:10:13 -0400 (Thu, 10 May 2012) $
*
*
* @author $Author: bfarber $
@@ -14,7 +14,7 @@
* @subpackage Core
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
+ * @version $Revision: 10721 $
*/
class cp_skin_api
diff --git a/upload/admin/applications/core/skin_cp/cp_skin_applications.php b/upload/admin/applications/core/skin_cp/cp_skin_applications.php
index 11cf24fe..d5c73770 100644
--- a/upload/admin/applications/core/skin_cp/cp_skin_applications.php
+++ b/upload/admin/applications/core/skin_cp/cp_skin_applications.php
@@ -1,2889 +1,3269 @@
-
- * Invision Power Services
- * IP.Board v3.3.4
- * Applications skin file
- * Last Updated: $Date: 2012-06-12 10:14:49 -0400 (Tue, 12 Jun 2012) $
- *
- *
- * @author $Author: bfarber $
- * @copyright (c) 2001 - 2009 Invision Power Services, Inc.
- * @license http://www.invisionpower.com/company/standards.php#license
- * @package IP.Board
- * @subpackage Core
- * @link http://www.invisionpower.com
- * @since Friday 19th May 2006 17:33
- * @version $Revision: 10914 $
- */
-
-class cp_skin_applications
-{
- /**
- * Registry Object Shortcuts
- *
- * @var $registry
- * @var $DB
- * @var $settings
- * @var $request
- * @var $lang
- * @var $member
- * @var $memberData
- * @var $cache
- * @var $caches
- */
- protected $registry;
- protected $DB;
- protected $settings;
- protected $request;
- protected $lang;
- protected $member;
- protected $memberData;
- protected $cache;
- protected $caches;
-
- /**
- * Constructor
- *
- * @param object $registry Registry object
- * @return @e void
- */
- public function __construct( ipsRegistry $registry )
- {
- $this->registry = $registry;
- $this->DB = $this->registry->DB();
- $this->settings =& $this->registry->fetchSettings();
- $this->request =& $this->registry->fetchRequest();
- $this->member = $this->registry->member();
- $this->memberData =& $this->registry->member()->fetchMemberData();
- $this->cache = $this->registry->cache();
- $this->caches =& $this->registry->cache()->fetchCaches();
- $this->lang = $this->registry->class_localization;
- }
-/**
- * Add/edit module form
- *
- * @param array Form elements
- * @param string Form title
- * @param string Action code
- * @param string Button text
- * @param array Module information
- * @param array Application information
- * @return string HTML
- */
-public function module_form( $form, $title, $formcode, $button, $module, $application ) {
-
-$IPBHTML = "";
-//--starthtml--//
-
-$title = $formcode == 'module_edit_do' ? $this->lang->words['module_form_edit_title'] : $this->lang->words['module_form_add_title'];
-
-$IPBHTML .= <<
- {$title}
-
-
-